mirror of
https://github.com/ansible/awx.git
synced 2026-03-22 03:17:39 -02:30
Inventory Manage > copy/move groups disable copy option where impossible, add to Root Group target, resolves #1749 (#2218)
This commit is contained in:
@@ -26,24 +26,43 @@
|
|||||||
GroupManageService.associateGroup(group, $scope.selected.id).then(() => $state.go('^', null, {reload: true}));
|
GroupManageService.associateGroup(group, $scope.selected.id).then(() => $state.go('^', null, {reload: true}));
|
||||||
break;
|
break;
|
||||||
case 'move':
|
case 'move':
|
||||||
// at the root group level, no dissassociation is needed
|
switch($scope.targetRootGroup){
|
||||||
if (!$stateParams.group){
|
case true:
|
||||||
GroupManageService.associateGroup(group, $scope.selected.id).then(() => $state.go('^', null, {reload: true}));
|
// disassociating group will bubble it to the root group level
|
||||||
}
|
GroupManageService.disassociateGroup(group.id, _.last($stateParams.group)).then(() => $state.go('^', null, {reload: true}));
|
||||||
else{
|
break;
|
||||||
// unsure if orphaned resources get garbage collected, safe bet is to associate before disassociate
|
default:
|
||||||
GroupManageService.associateGroup(group, $scope.selected.id).then(() => {
|
// at the root group level, no dissassociation is needed
|
||||||
GroupManageService.disassociateGroup(group, _.last($stateParams.group))
|
if (!$stateParams.group){
|
||||||
.then(() => $state.go('^', null, {reload: true}));
|
GroupManageService.associateGroup(group, $scope.selected.id).then(() => $state.go('^', null, {reload: true}));
|
||||||
});
|
}
|
||||||
|
else{
|
||||||
|
// unsure if orphaned resources get garbage collected, safe bet is to associate before disassociate
|
||||||
|
GroupManageService.associateGroup(group, $scope.selected.id).then(() => {
|
||||||
|
GroupManageService.disassociateGroup(group.id, _.last($stateParams.group))
|
||||||
|
.then(() => $state.go('^', null, {reload: true}));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
$scope.toggleTargetRootGroup = function(){
|
||||||
|
$scope.selected = !$scope.selected;
|
||||||
|
// cannot perform copy operations to root group level
|
||||||
|
$scope.submitMode = 'move';
|
||||||
|
// toggle off anything currently selected in the list, for clarity
|
||||||
|
_.forEach($scope.groups, (item) => {item.checked = null;});
|
||||||
|
// disable list selections
|
||||||
|
$('#copyMove-list :input').each((idx, el) => {
|
||||||
|
$(el).prop('disabled', (idx, value) => !value);
|
||||||
|
});
|
||||||
|
};
|
||||||
var init = function(){
|
var init = function(){
|
||||||
var url = GetBasePath('inventory') + $stateParams.inventory_id + '/groups/';
|
var url = GetBasePath('inventory') + $stateParams.inventory_id + '/groups/';
|
||||||
url += $stateParams.group ? '?not__id__in=' + group.id + ',' + _.last($stateParams.group) : '?not__id=' + group.id;
|
url += $stateParams.group ? '?not__id__in=' + group.id + ',' + _.last($stateParams.group) : '?not__id=' + group.id;
|
||||||
list.basePath = url;
|
list.basePath = url;
|
||||||
|
$scope.atRootLevel = $stateParams.group ? false : true;
|
||||||
view.inject(list, {
|
view.inject(list, {
|
||||||
mode: 'lookup',
|
mode: 'lookup',
|
||||||
id: 'copyMove-list',
|
id: 'copyMove-list',
|
||||||
|
|||||||
@@ -24,3 +24,6 @@
|
|||||||
height: 30px;
|
height: 30px;
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
}
|
}
|
||||||
|
.copyMove-root{
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,16 +2,18 @@
|
|||||||
<div class="Form-header">
|
<div class="Form-header">
|
||||||
<div class="Form-title ng-binding">{{item.name}}</div>
|
<div class="Form-title ng-binding">{{item.name}}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group copyMove-choices">
|
<div class="form-group copyMove-choices clearfix">
|
||||||
<label class="radio-inline">
|
<label class="radio-inline" ng-disabled="atRootLevel || targetRootGroup">
|
||||||
<input type="radio" ng-model="submitMode" value="copy" class="ng-pristine ng-valid ng-touched"> Copy
|
<input type="radio" ng-model="submitMode" value="copy" class="ng-pristine ng-valid ng-touched" ng-disabled="atRootLevel || targetRootGroup"> Copy
|
||||||
</label>
|
</label>
|
||||||
<label class="radio-inline">
|
<label class="radio-inline">
|
||||||
<input type="radio" ng-model="submitMode" value="move" class="ng-pristine ng-untouched ng-valid"> Move
|
<input type="radio" ng-model="submitMode" value="move" class="ng-pristine ng-untouched ng-valid"> Move
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div id="copyMove-select"></div>
|
|
||||||
<div id="copyMove-list"></div>
|
<div id="copyMove-list"></div>
|
||||||
|
<div class="copyMove-root form-group pull-left" ng-hide="atRootLevel">
|
||||||
|
<span><input type="checkbox" ng-model="targetRootGroup" ng-change="toggleTargetRootGroup()"> Use the inventory root</span>
|
||||||
|
</div>
|
||||||
<div class="copyMove-buttons">
|
<div class="copyMove-buttons">
|
||||||
<button type="button" class="pull-right btn btn-sm btn-default Form-cancelButton" ng-click="formCancel()">Cancel</button>
|
<button type="button" class="pull-right btn btn-sm btn-default Form-cancelButton" ng-click="formCancel()">Cancel</button>
|
||||||
<button type="button" class="pull-right btn btn-sm Form-saveButton" ng-disabled="!selected" ng-click="formSave()">Save</button>
|
<button type="button" class="pull-right btn btn-sm Form-saveButton" ng-disabled="!selected" ng-click="formSave()">Save</button>
|
||||||
|
|||||||
Reference in New Issue
Block a user