mirror of
https://github.com/ansible/awx.git
synced 2026-01-12 10:30:03 -03:30
Fixed group delete/promote message tense
This commit is contained in:
parent
6cd8fbdf6d
commit
da8dff143c
@ -7,9 +7,11 @@
|
||||
['$scope', '$rootScope', '$state', '$stateParams', 'GroupList', 'InventoryUpdate',
|
||||
'GroupsService', 'CancelSourceUpdate', 'rbacUiControlService', 'GetBasePath',
|
||||
'GetHostsStatusMsg', 'Dataset', 'Find', 'QuerySet', 'inventoryData', 'canAdd',
|
||||
'InventoryHostsStrings',
|
||||
function($scope, $rootScope, $state, $stateParams, GroupList, InventoryUpdate,
|
||||
GroupsService, CancelSourceUpdate, rbacUiControlService, GetBasePath,
|
||||
GetHostsStatusMsg, Dataset, Find, qs, inventoryData, canAdd){
|
||||
GetHostsStatusMsg, Dataset, Find, qs, inventoryData, canAdd,
|
||||
InventoryHostsStrings){
|
||||
|
||||
let list = GroupList;
|
||||
|
||||
@ -20,6 +22,10 @@
|
||||
$scope.canAdhoc = inventoryData.summary_fields.user_capabilities.adhoc;
|
||||
$scope.canAdd = canAdd;
|
||||
|
||||
$scope.strings = {
|
||||
deleteModal: {}
|
||||
};
|
||||
|
||||
// Search init
|
||||
$scope.list = list;
|
||||
$scope[`${list.iterator}_dataset`] = Dataset.data;
|
||||
@ -89,26 +95,58 @@
|
||||
};
|
||||
$scope.deleteGroup = function(group){
|
||||
$scope.toDelete = {};
|
||||
$scope.strings.deleteModal = {};
|
||||
angular.extend($scope.toDelete, group);
|
||||
if($scope.toDelete.total_groups === 0 && $scope.toDelete.total_hosts === 0) {
|
||||
// This group doesn't have any child groups or hosts - the user is just trying to delete
|
||||
// the group
|
||||
$scope.deleteOption = "delete";
|
||||
}
|
||||
else {
|
||||
$scope.strings.deleteModal.group = $scope.toDelete.total_groups === 1 ? InventoryHostsStrings.get('filter.GROUP') : InventoryHostsStrings.get('filter.GROUPS');
|
||||
$scope.strings.deleteModal.host = $scope.toDelete.total_hosts === 1 ? InventoryHostsStrings.get('filter.HOST') : InventoryHostsStrings.get('filter.HOSTS');
|
||||
|
||||
if($scope.toDelete.total_groups > 1 && $scope.toDelete.total_hosts > 1) {
|
||||
$scope.strings.deleteModal.deleteGroupsHosts = InventoryHostsStrings.get('filter.DELETEGROUPSHOSTS');
|
||||
$scope.strings.deleteModal.promoteGroupsHosts = InventoryHostsStrings.get('filter.PROMOTEGROUPSHOSTS');
|
||||
}
|
||||
else if($scope.toDelete.total_groups > 1 && $scope.toDelete.total_hosts === 1) {
|
||||
$scope.strings.deleteModal.deleteGroupsHosts = InventoryHostsStrings.get('filter.DELETEGROUPSHOST');
|
||||
$scope.strings.deleteModal.promoteGroupsHosts = InventoryHostsStrings.get('filter.PROMOTEGROUPSHOST');
|
||||
}
|
||||
else if($scope.toDelete.total_groups === 1 && $scope.toDelete.total_hosts > 1) {
|
||||
$scope.strings.deleteModal.deleteGroupsHosts = InventoryHostsStrings.get('filter.DELETEGROUPHOSTS');
|
||||
$scope.strings.deleteModal.promoteGroupsHosts = InventoryHostsStrings.get('filter.PROMOTEGROUPHOSTS');
|
||||
}
|
||||
else if($scope.toDelete.total_groups === 1 && $scope.toDelete.total_hosts === 1) {
|
||||
$scope.strings.deleteModal.deleteGroupsHosts = InventoryHostsStrings.get('filter.DELETEGROUPHOST');
|
||||
$scope.strings.deleteModal.promoteGroupsHosts = InventoryHostsStrings.get('filter.PROMOTEGROUPHOST');
|
||||
}
|
||||
else if($scope.toDelete.total_groups === 0) {
|
||||
if($scope.toDelete.total_hosts > 1) {
|
||||
$scope.strings.deleteModal.deleteGroupsHosts = InventoryHostsStrings.get('filter.DELETEHOSTS');
|
||||
$scope.strings.deleteModal.promoteGroupsHosts = InventoryHostsStrings.get('filter.PROMOTEHOSTS');
|
||||
}
|
||||
else {
|
||||
$scope.strings.deleteModal.deleteGroupsHosts = InventoryHostsStrings.get('filter.DELETEHOST');
|
||||
$scope.strings.deleteModal.promoteGroupsHosts = InventoryHostsStrings.get('filter.PROMOTEHOST');
|
||||
}
|
||||
}
|
||||
else if($scope.toDelete.total_hosts === 0) {
|
||||
if($scope.toDelete.total_groups > 1) {
|
||||
$scope.strings.deleteModal.deleteGroupsHosts = InventoryHostsStrings.get('filter.DELETEGROUPS');
|
||||
$scope.strings.deleteModal.promoteGroupsHosts = InventoryHostsStrings.get('filter.PROMOTEGROUPS');
|
||||
}
|
||||
else {
|
||||
$scope.strings.deleteModal.deleteGroupsHosts = InventoryHostsStrings.get('filter.DELETEGROUP');
|
||||
$scope.strings.deleteModal.promoteGroupsHosts = InventoryHostsStrings.get('filter.PROMOTEGROUP');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$('#group-delete-modal').modal('show');
|
||||
};
|
||||
$scope.confirmDelete = function(){
|
||||
|
||||
// Bind an even listener for the modal closing. Trying to $state.go() before the modal closes
|
||||
// will mean that these two things are running async and the modal may not finish closing before
|
||||
// the state finishes transitioning.
|
||||
$('#group-delete-modal').off('hidden.bs.modal').on('hidden.bs.modal', function () {
|
||||
// Remove the event handler so that we don't end up with multiple bindings
|
||||
$('#group-delete-modal').off('hidden.bs.modal');
|
||||
// Reload the inventory manage page and show that the group has been removed
|
||||
$state.go('.', null, {reload: true});
|
||||
});
|
||||
|
||||
let reloadListStateParams = null;
|
||||
|
||||
if($scope.groups.length === 1 && $state.params.group_search && !_.isEmpty($state.params.group_search.page) && $state.params.group_search.page !== '1') {
|
||||
|
||||
@ -21,42 +21,20 @@
|
||||
<div ng-show="toDelete.total_groups > 0 || toDelete.total_hosts > 0">
|
||||
<div>
|
||||
<p class="Prompt-bodyQuery">Deleting group <em>{{ toDelete.name }}</em>.
|
||||
<span ng-show="toDelete.total_groups > 0 && toDelete.total_hosts > 0"> <translate>This group contains</translate> {{ toDelete.total_groups }} <translate>groups and</translate> {{ toDelete.total_hosts }} <translate>hosts</translate>. </span>
|
||||
<span ng-show="toDelete.total_groups == 0 && toDelete.total_hosts > 0"> <translate>This group contains</translate> {{ toDelete.total_hosts }} <translate>hosts</translate>. </span>
|
||||
<span ng-show="toDelete.total_groups > 0 && toDelete.total_hosts == 0"> <translate>This group contains</translate> {{ toDelete.total_groups }} <translate>groups</translate>. </span>
|
||||
<span ng-show="toDelete.total_groups > 0 && toDelete.total_hosts > 0"> <translate>This group contains</translate> {{ toDelete.total_groups }} {{strings.deleteModal.group}} <translate>and</translate> {{ toDelete.total_hosts }} {{strings.deleteModal.host}}. </span>
|
||||
<span ng-show="toDelete.total_groups == 0 && toDelete.total_hosts > 0"> <translate>This group contains</translate> {{ toDelete.total_hosts }} {{strings.deleteModal.host}}. </span>
|
||||
<span ng-show="toDelete.total_groups > 0 && toDelete.total_hosts == 0"> <translate>This group contains</translate> {{ toDelete.total_groups }} {{strings.deleteModal.group}}. </span>
|
||||
<translate>Delete or promote the group's children?</translate></p>
|
||||
<div style="margin: 15px auto;">
|
||||
|
||||
<div class="radio" ng-show="toDelete.total_groups > 0 && toDelete.total_hosts > 0">
|
||||
<div class="radio">
|
||||
<label>
|
||||
<input type="radio" ng-model="deleteOption" value="promote"> <translate>Promote groups and hosts</translate>
|
||||
<input type="radio" ng-model="deleteOption" value="delete" > {{ strings.deleteModal.deleteGroupsHosts }}
|
||||
</label>
|
||||
</div>
|
||||
<div class="radio" ng-show="toDelete.total_groups > 0 && toDelete.total_hosts > 0">
|
||||
<div class="radio">
|
||||
<label>
|
||||
<input type="radio" ng-model="deleteOption" value="delete"> <translate>Delete groups and hosts</translate>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="radio" ng-show="toDelete.total_groups > 0 && toDelete.total_hosts == 0">
|
||||
<label>
|
||||
<input type="radio" ng-model="deleteOption" value="promote"> <translate>Promote groups</translate>
|
||||
</label>
|
||||
</div>
|
||||
<div class="radio" ng-show="toDelete.total_groups > 0 && toDelete.total_hosts == 0">
|
||||
<label>
|
||||
<input type="radio" ng-model="deleteOption" value="delete"> <translate>Delete groups</translate>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="radio" ng-show="toDelete.total_groups == 0 && toDelete.total_hosts > 0">
|
||||
<label>
|
||||
<input type="radio" ng-model="deleteOption" value="promote"> <translate>Promote hosts</translate>
|
||||
</label>
|
||||
</div>
|
||||
<div class="radio" ng-show="toDelete.total_groups == 0 && toDelete.total_hosts > 0">
|
||||
<label>
|
||||
<input type="radio" ng-model="deleteOption" value="delete"> <translate>Delete hosts</translate>
|
||||
<input type="radio" ng-model="deleteOption" value="promote"> {{ strings.deleteModal.promoteGroupsHosts }}
|
||||
</label>
|
||||
</div>
|
||||
|
||||
@ -71,7 +49,7 @@
|
||||
</div>
|
||||
<div class="Modal-footer">
|
||||
<a href="#" data-target="#group-delete-modal" data-dismiss="modal" id="prompt_cancel_btn_groups_list" class="btn Modal-defaultButton Modal-footerButton" translate>CANCEL</a>
|
||||
<a href="" ng-class="promptActionBtnClass" ng-click="confirmDelete()" id="prompt_action_btn_groups_list" class="btn Modal-footerButton Modal-errorButton" translate>DELETE</a>
|
||||
<a href="" ng-class="promptActionBtnClass" ng-click="confirmDelete()" id="prompt_action_btn_groups_list" ng-disabled="!deleteOption && (toDelete.total_groups > 0 || toDelete.total_hosts > 0)" class="btn Modal-footerButton Modal-errorButton" translate>DELETE</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -0,0 +1,33 @@
|
||||
function InventoryHostsStrings (BaseString) {
|
||||
BaseString.call(this, 'inventoryhosts');
|
||||
|
||||
let t = this.t;
|
||||
let ns = this.inventoryhosts;
|
||||
|
||||
ns.filter = {
|
||||
GROUP: t('group'),
|
||||
GROUPS: t('groups'),
|
||||
HOST: t('host'),
|
||||
HOSTS: t('hosts'),
|
||||
PROMOTEGROUPSHOSTS: t('Promote groups and hosts'),
|
||||
PROMOTEGROUPHOSTS: t('Promote group and hosts'),
|
||||
PROMOTEGROUPSHOST: t('Promote groups and host'),
|
||||
PROMOTEGROUPHOST: t('Promote group and host'),
|
||||
DELETEGROUPSHOSTS: t('Delete groups and hosts'),
|
||||
DELETEGROUPHOSTS: t('Delete group and hosts'),
|
||||
DELETEGROUPSHOST: t('Delete groups and host'),
|
||||
DELETEGROUPHOST: t('Delete group and host'),
|
||||
PROMOTEGROUPS: t('Promote groups'),
|
||||
PROMOTEGROUP: t('Promote group'),
|
||||
DELETEGROUPS: t('Delete groups'),
|
||||
DELETEGROUP: t('Delete group'),
|
||||
PROMOTEHOSTS: t('Promote hosts'),
|
||||
PROMOTEHOST: t('Promote host'),
|
||||
DELETEHOSTS: t('Delete hosts'),
|
||||
DELETEHOST: t('Delete host')
|
||||
};
|
||||
}
|
||||
|
||||
InventoryHostsStrings.$inject = ['BaseStringService'];
|
||||
|
||||
export default InventoryHostsStrings;
|
||||
@ -7,10 +7,12 @@
|
||||
import hosts from './hosts/main';
|
||||
import inventories from './inventories/main';
|
||||
import shared from './shared/main';
|
||||
import InventoryHostsStrings from './inventory-hosts.strings';
|
||||
|
||||
export default
|
||||
angular.module('inventories-hosts', [
|
||||
hosts.name,
|
||||
inventories.name,
|
||||
shared.name
|
||||
]);
|
||||
])
|
||||
.service('InventoryHostsStrings', InventoryHostsStrings);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user