Fixed smart inv button bug navigating to page 2 of hosts. Added tooltip when button is disabled.

This commit is contained in:
mabashian 2017-10-12 16:52:59 -04:00
parent f6bf0ad21f
commit 3ede367df4
5 changed files with 27 additions and 11 deletions

View File

@ -104,12 +104,14 @@ export default ['i18n', function(i18n) {
smart_inventory: {
mode: 'all',
ngClick: "smartInventory()",
awToolTip: i18n._("Create a new Smart Inventory from search results."),
awToolTip: "{{ smartInventoryButtonTooltip }}",
dataTipWatch: 'smartInventoryButtonTooltip',
actionClass: 'btn List-buttonDefault',
buttonContent: i18n._('SMART INVENTORY'),
ngShow: 'canAdd && (hosts.length > 0 || !(searchTags | isEmpty))',
dataPlacement: "top",
ngDisabled: '!enableSmartInventoryButton'
ngDisabled: '!enableSmartInventoryButton',
showTipWhenDisabled: true
}
}
};

View File

@ -7,7 +7,7 @@
function HostsList($scope, HostsList, $rootScope, GetBasePath,
rbacUiControlService, Dataset, $state, $filter, Prompt, Wait,
HostsService, SetStatus, canAdd) {
HostsService, SetStatus, canAdd, InventoryHostsStrings) {
let list = HostsList;
@ -16,6 +16,7 @@ function HostsList($scope, HostsList, $rootScope, GetBasePath,
function init(){
$scope.canAdd = canAdd;
$scope.enableSmartInventoryButton = false;
$scope.smartInventoryButtonTooltip = InventoryHostsStrings.get('smartinventorybutton.DISABLED_INSTRUCTIONS');
// Search init
$scope.list = list;
@ -37,14 +38,16 @@ function HostsList($scope, HostsList, $rootScope, GetBasePath,
if(toParams && toParams.host_search) {
let hasMoreThanDefaultKeys = false;
angular.forEach(toParams.host_search, function(value, key) {
if(key !== 'order_by' && key !== 'page_size') {
if(key !== 'order_by' && key !== 'page_size' && key !== 'page') {
hasMoreThanDefaultKeys = true;
}
});
$scope.enableSmartInventoryButton = hasMoreThanDefaultKeys ? true : false;
$scope.smartInventoryButtonTooltip = hasMoreThanDefaultKeys ? InventoryHostsStrings.get('smartinventorybutton.ENABLED_INSTRUCTIONS') : InventoryHostsStrings.get('smartinventorybutton.DISABLED_INSTRUCTIONS');
}
else {
$scope.enableSmartInventoryButton = false;
$scope.smartInventoryButtonTooltip = InventoryHostsStrings.get('smartinventorybutton.DISABLED_INSTRUCTIONS');
}
});
@ -114,5 +117,5 @@ function HostsList($scope, HostsList, $rootScope, GetBasePath,
export default ['$scope', 'HostsList', '$rootScope', 'GetBasePath',
'rbacUiControlService', 'Dataset', '$state', '$filter', 'Prompt', 'Wait',
'HostsService', 'SetStatus', 'canAdd', HostsList
'HostsService', 'SetStatus', 'canAdd', 'InventoryHostsStrings', HostsList
];

View File

@ -6,10 +6,10 @@
export default ['$scope', 'NestedHostsListDefinition', '$rootScope', 'GetBasePath',
'rbacUiControlService', 'Dataset', '$state', '$filter', 'Prompt', 'Wait',
'HostsService', 'SetStatus', 'canAdd', 'GroupsService', 'ProcessErrors', 'groupData', 'inventoryData',
'HostsService', 'SetStatus', 'canAdd', 'GroupsService', 'ProcessErrors', 'groupData', 'inventoryData', 'InventoryHostsStrings',
function($scope, NestedHostsListDefinition, $rootScope, GetBasePath,
rbacUiControlService, Dataset, $state, $filter, Prompt, Wait,
HostsService, SetStatus, canAdd, GroupsService, ProcessErrors, groupData, inventoryData) {
HostsService, SetStatus, canAdd, GroupsService, ProcessErrors, groupData, inventoryData, InventoryHostsStrings) {
let list = NestedHostsListDefinition;
@ -19,6 +19,7 @@ export default ['$scope', 'NestedHostsListDefinition', '$rootScope', 'GetBasePat
$scope.canAdd = canAdd;
$scope.enableSmartInventoryButton = false;
$scope.disassociateFrom = groupData;
$scope.smartInventoryButtonTooltip = InventoryHostsStrings.get('smartinventorybutton.DISABLED_INSTRUCTIONS');
// Search init
$scope.list = list;
@ -50,14 +51,16 @@ export default ['$scope', 'NestedHostsListDefinition', '$rootScope', 'GetBasePat
if(toParams && toParams.host_search) {
let hasMoreThanDefaultKeys = false;
angular.forEach(toParams.host_search, function(value, key) {
if(key !== 'order_by' && key !== 'page_size') {
if(key !== 'order_by' && key !== 'page_size' && key !== 'page') {
hasMoreThanDefaultKeys = true;
}
});
$scope.enableSmartInventoryButton = hasMoreThanDefaultKeys ? true : false;
$scope.smartInventoryButtonTooltip = hasMoreThanDefaultKeys ? InventoryHostsStrings.get('smartinventorybutton.ENABLED_INSTRUCTIONS') : InventoryHostsStrings.get('smartinventorybutton.DISABLED_INSTRUCTIONS');
}
else {
$scope.enableSmartInventoryButton = false;
$scope.smartInventoryButtonTooltip = InventoryHostsStrings.get('smartinventorybutton.DISABLED_INSTRUCTIONS');
}
});

View File

@ -7,10 +7,10 @@
// import HostsService from './../hosts/host.service';
export default ['$scope', 'ListDefinition', '$rootScope', 'GetBasePath',
'rbacUiControlService', 'Dataset', '$state', '$filter', 'Prompt', 'Wait',
'HostsService', 'SetStatus', 'canAdd', 'i18n',
'HostsService', 'SetStatus', 'canAdd', 'i18n', 'InventoryHostsStrings',
function($scope, ListDefinition, $rootScope, GetBasePath,
rbacUiControlService, Dataset, $state, $filter, Prompt, Wait,
HostsService, SetStatus, canAdd, i18n) {
HostsService, SetStatus, canAdd, i18n, InventoryHostsStrings) {
let list = ListDefinition;
@ -19,6 +19,7 @@ export default ['$scope', 'ListDefinition', '$rootScope', 'GetBasePath',
function init(){
$scope.canAdd = canAdd;
$scope.enableSmartInventoryButton = false;
$scope.smartInventoryButtonTooltip = InventoryHostsStrings.get('smartinventorybutton.DISABLED_INSTRUCTIONS');
// Search init
$scope.list = list;
@ -45,14 +46,16 @@ export default ['$scope', 'ListDefinition', '$rootScope', 'GetBasePath',
if(toParams && toParams.host_search) {
let hasMoreThanDefaultKeys = false;
angular.forEach(toParams.host_search, function(value, key) {
if(key !== 'order_by' && key !== 'page_size') {
if(key !== 'order_by' && key !== 'page_size' && key !== 'page') {
hasMoreThanDefaultKeys = true;
}
});
$scope.enableSmartInventoryButton = hasMoreThanDefaultKeys ? true : false;
$scope.smartInventoryButtonTooltip = hasMoreThanDefaultKeys ? InventoryHostsStrings.get('smartinventorybutton.ENABLED_INSTRUCTIONS') : InventoryHostsStrings.get('smartinventorybutton.DISABLED_INSTRUCTIONS');
}
else {
$scope.enableSmartInventoryButton = false;
$scope.smartInventoryButtonTooltip = InventoryHostsStrings.get('smartinventorybutton.DISABLED_INSTRUCTIONS');
}
});

View File

@ -28,6 +28,11 @@ function InventoryHostsStrings (BaseString) {
MISSING_PERMISSIONS: t.s('You do not have sufficient permissions to edit the host filter.')
}
};
ns.smartinventorybutton = {
DISABLED_INSTRUCTIONS: "Please enter at least one search term to create a new Smart Inventory.",
ENABLED_INSTRUCTIONS: "Create a new Smart Inventory from search results."
};
}
InventoryHostsStrings.$inject = ['BaseStringService'];