Pass host filter through to the smart inv form. Fixed inventory list name link

This commit is contained in:
Michael Abashian 2017-04-13 13:18:57 -04:00 committed by Jared Tabor
parent e411d5c69b
commit 9131ee59a2
3 changed files with 16 additions and 3 deletions

View File

@ -115,7 +115,20 @@ function HostsList($scope, HostsList, $rootScope, GetBasePath,
};
$scope.smartInventory = function() {
$state.go('inventories.addSmartInventory');
// Gather up search terms and pass them to the add smart inventory form
let stateParamsCopy = angular.copy($state.params.host_search);
let defaults = _.find($state.$current.path, (step) => {
if(step && step.params && step.params.hasOwnProperty(`host_search`)){
return step.params.hasOwnProperty(`host_search`);
}
}).params[`host_search`].config.value;
// Strip defaults out of the state params copy
angular.forEach(Object.keys(defaults), function(value) {
delete stateParamsCopy[value];
});
$state.go('inventories.addSmartInventory', {hostfilter: JSON.stringify(stateParamsCopy)});
};
}

View File

@ -47,7 +47,7 @@ export default ['i18n', function(i18n) {
modalColumnClass: 'col-md-11',
awToolTip: "{{ inventory.description }}",
awTipPlacement: "top"
linkTo: '/#/inventories/{{inventory.id}}'
linkTo: '/#/inventories/basic_inventory/{{inventory.id}}'
},
organization: {
label: i18n._('Organization'),

View File

@ -59,7 +59,7 @@ angular.module('inventory', [
let smartInventoryAdd = stateDefinitions.generateTree({
name: 'inventories.addSmartInventory', // top-most node in the generated tree (will replace this state definition)
url: '/smart_inventory/add',
url: '/smart_inventory/add?hostfilter',
modes: ['add'],
form: 'SmartInventoryForm',
controllers: {