diff --git a/awx/ui/client/src/inventories/inventories.partial.html b/awx/ui/client/src/inventories/inventories.partial.html index 26d66de7af..875d23486b 100644 --- a/awx/ui/client/src/inventories/inventories.partial.html +++ b/awx/ui/client/src/inventories/inventories.partial.html @@ -1,5 +1,6 @@
+
diff --git a/awx/ui/client/src/inventories/inventory.form.js b/awx/ui/client/src/inventories/inventory.form.js index cf02ce202a..317800d0fb 100644 --- a/awx/ui/client/src/inventories/inventory.form.js +++ b/awx/ui/client/src/inventories/inventory.form.js @@ -11,9 +11,10 @@ */ export default ['i18n', 'buildGroupsListState', 'buildGroupsAddState', - 'buildGroupsEditState', 'buildHostListState', + 'buildGroupsEditState', 'buildHostListState', 'buildHostAddState', + 'buildHostEditState', function(i18n, buildGroupsListState, buildGroupsAddState, buildGroupsEditState, - buildHostListState) { + buildHostListState, buildHostAddState, buildHostEditState) { return { addTitle: i18n._('NEW INVENTORY'), @@ -149,8 +150,8 @@ function(i18n, buildGroupsListState, buildGroupsAddState, buildGroupsEditState, title: i18n._('Hosts'), iterator: 'host', listState: buildHostListState, - // addState: buildGroupsAddState, - // editState: buildGroupsEditState + addState: buildHostAddState, + editState: buildHostEditState }, inventory_sources: { name: 'inventory_sources', diff --git a/awx/ui/client/src/inventories/related-hosts/add/build-host-add-state.factory.js b/awx/ui/client/src/inventories/related-hosts/add/build-host-add-state.factory.js new file mode 100644 index 0000000000..4a1ed4c9d7 --- /dev/null +++ b/awx/ui/client/src/inventories/related-hosts/add/build-host-add-state.factory.js @@ -0,0 +1,46 @@ +/************************************************* +* Copyright (c) 2017 Ansible, Inc. +* +* All Rights Reserved +*************************************************/ + +import RelatedHostAddController from './host-add.controller'; + +export default ['$stateExtender', 'templateUrl', '$injector', + function($stateExtender, templateUrl, $injector){ + var val = function(field, formStateDefinition, params) { + let state, + list = field.include ? $injector.get(field.include) : field, + breadcrumbLabel = (field.iterator.replace('_', ' ') + 's').toUpperCase(), + stateConfig = { + name: `${formStateDefinition.name}.${list.iterator}s.add`, + url: `/add`, + ncyBreadcrumb: { + parent: `${formStateDefinition.name}`, + label: `${breadcrumbLabel}` + }, + views: { + 'hostForm@inventories': { + templateProvider: function(GenerateForm, RelatedHostsFormDefinition) { + let form = RelatedHostsFormDefinition; + return GenerateForm.buildHTML(form, { + mode: 'add', + related: false + }); + }, + controller: RelatedHostAddController + } + }, + resolve: { + 'FormDefinition': [params.form, function(definition) { + return definition; + }] + } + }; + + state = $stateExtender.buildDefinition(stateConfig); + return state; + }; + return val; + } +]; diff --git a/awx/ui/client/src/inventories/related-hosts/add/host-add.controller.js b/awx/ui/client/src/inventories/related-hosts/add/host-add.controller.js index 7042800ee2..6bb5d0ab40 100644 --- a/awx/ui/client/src/inventories/related-hosts/add/host-add.controller.js +++ b/awx/ui/client/src/inventories/related-hosts/add/host-add.controller.js @@ -4,9 +4,9 @@ * All Rights Reserved *************************************************/ -export default ['$state', '$stateParams', '$scope', 'HostForm', 'ParseTypeChange', +export default ['$state', '$stateParams', '$scope', 'RelatedHostsFormDefinition', 'ParseTypeChange', 'GenerateForm', 'HostManageService', 'rbacUiControlService', 'GetBasePath', 'ToJSON', - function($state, $stateParams, $scope, HostForm, ParseTypeChange, + function($state, $stateParams, $scope, RelatedHostsFormDefinition, ParseTypeChange, GenerateForm, HostManageService, rbacUiControlService, GetBasePath, ToJSON) { init(); @@ -21,7 +21,7 @@ export default ['$state', '$stateParams', '$scope', 'HostForm', 'ParseTypeChange $scope.parseType = 'yaml'; $scope.host = { enabled: true }; // apply form definition's default field values - GenerateForm.applyDefaults(HostForm, $scope); + GenerateForm.applyDefaults(RelatedHostsFormDefinition, $scope); ParseTypeChange({ scope: $scope, diff --git a/awx/ui/client/src/inventories/related-hosts/add/main.js b/awx/ui/client/src/inventories/related-hosts/add/main.js index 7a55327c9f..48128f9a38 100644 --- a/awx/ui/client/src/inventories/related-hosts/add/main.js +++ b/awx/ui/client/src/inventories/related-hosts/add/main.js @@ -4,8 +4,10 @@ * All Rights Reserved *************************************************/ +import buildHostAddState from './build-host-add-state.factory'; import controller from './host-add.controller'; export default angular.module('relatedHostsAdd', []) + .factory('buildHostAddState', buildHostAddState) .controller('RelatedHostAddController', controller); diff --git a/awx/ui/client/src/inventories/related-hosts/edit/host-edit.controller.js b/awx/ui/client/src/inventories/related-hosts/edit/host-edit.controller.js index 250c65e4d7..048388f791 100644 --- a/awx/ui/client/src/inventories/related-hosts/edit/host-edit.controller.js +++ b/awx/ui/client/src/inventories/related-hosts/edit/host-edit.controller.js @@ -34,10 +34,10 @@ }; var init = function(){ - $scope.host = host.data; - $scope.name = host.data.name; - $scope.description = host.data.description; - $scope.variables = getVars(host.data.variables); + $scope.host = host; + $scope.name = host.name; + $scope.description = host.description; + $scope.variables = getVars(host.variables); ParseTypeChange({ scope: $scope, field_id: 'host_variables', diff --git a/awx/ui/client/src/inventories/related-hosts/edit/main.js b/awx/ui/client/src/inventories/related-hosts/edit/main.js index 854a520053..731113f6e5 100644 --- a/awx/ui/client/src/inventories/related-hosts/edit/main.js +++ b/awx/ui/client/src/inventories/related-hosts/edit/main.js @@ -3,9 +3,10 @@ * * All Rights Reserved *************************************************/ - +import buildHostEditState from './build-host-edit-state.factory'; import controller from './host-edit.controller'; export default angular.module('relatedHostEdit', []) - .controller('HostEditController', controller); + .factory('buildHostEditState', buildHostEditState) + .controller('RelatedHostEditController', controller); diff --git a/awx/ui/client/src/inventories/related-hosts/main.js b/awx/ui/client/src/inventories/related-hosts/main.js index 717c359046..2f892270b3 100644 --- a/awx/ui/client/src/inventories/related-hosts/main.js +++ b/awx/ui/client/src/inventories/related-hosts/main.js @@ -9,10 +9,6 @@ import relatedHostList from './list/main'; import relatedHostsListDefinition from './related-host.list'; import relatedHostsFormDefinition from './related-host.form'; - // import HostManageService from './hosts.service'; - // import SetStatus from './set-status.factory'; - // import SetEnabledMsg from './set-enabled-msg.factory'; - // import SmartInventory from './smart-inventory/main'; export default angular.module('relatedHost', [ @@ -20,8 +16,5 @@ angular.module('relatedHost', [ relatedHostEdit.name, relatedHostList.name ]) - .value('RelatedHostsFormDefinition', relatedHostsFormDefinition) + .factory('RelatedHostsFormDefinition', relatedHostsFormDefinition) .value('RelatedHostsListDefinition', relatedHostsListDefinition); - // .factory('SetStatus', SetStatus) - // .factory('SetEnabledMsg', SetEnabledMsg) - // .service('HostManageService', HostManageService); diff --git a/awx/ui/client/src/shared/stateDefinitions.factory.js b/awx/ui/client/src/shared/stateDefinitions.factory.js index ad995d62bf..a5e9797f38 100644 --- a/awx/ui/client/src/shared/stateDefinitions.factory.js +++ b/awx/ui/client/src/shared/stateDefinitions.factory.js @@ -553,18 +553,20 @@ function($injector, $stateExtender, $log, i18n) { function buildListNodes(field) { let states = []; - if(field.iterator === 'group'){ - states.push(field.listState(field, formStateDefinition)); - states.push(field.addState(field, formStateDefinition, params)); - states.push(field.editState(field, formStateDefinition, params)); - states = _.flatten(states); + if(field && (field.listState || field.addState || field.editState)){ + if(field && field.listState){ + states.push(field.listState(field, formStateDefinition)); + states = _.flatten(states); + } + if(field && field.addState){ + states.push(field.addState(field, formStateDefinition, params)); + states = _.flatten(states); + } + if(field && field.editState){ + states.push(field.editState(field, formStateDefinition, params)); + states = _.flatten(states); + } } - else if(field.iterator === 'host'){ - states.push(field.listState(field, formStateDefinition)); - } - // if(field && field.listState){ - // states.push(field.listState(field, formStateDefinition)); - // } else if(field.iterator === 'notification'){ states.push(buildNotificationState(field)); states = _.flatten(states);