diff --git a/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets/new.js b/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets/new.js index 3980cf51b..952e5d195 100644 --- a/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets/new.js +++ b/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets/new.js @@ -1,18 +1,26 @@ import Route from '@ember/routing/route'; +import { action } from '@ember/object'; +import { inject as service } from '@ember/service'; export default class ScopesScopeHostCatalogsHostCatalogHostSetsNewRoute extends Route { - // =methods + // =services + @service router; + // =methods /** * Creates a new unsaved host set in current host catalog scope. * @return {HostSetModel} */ model() { - const { id: host_catalog_id } = this.modelFor( + const { id: host_catalog_id, compositeType } = this.modelFor( 'scopes.scope.host-catalogs.host-catalog' ); + if (this.currentModel?.isNew) { + this.currentModel.rollbackAttributes(); + } + console.log('typedwed', compositeType); return this.store.createRecord('host-set', { - type: 'static', + compositeType, host_catalog_id, }); } @@ -47,4 +55,12 @@ export default class ScopesScopeHostCatalogsHostCatalogHostSetsNewRoute extends model: model, }); } + /** + * Update type of host set + * @param {string} type + */ + @action + async changeType(type) { + await this.router.replaceWith({ queryParams: { type } }); + } } diff --git a/ui/admin/app/templates/scopes/scope/host-catalogs/host-catalog/host-sets/new.hbs b/ui/admin/app/templates/scopes/scope/host-catalogs/host-catalog/host-sets/new.hbs index 9f68f1549..941f3e819 100644 --- a/ui/admin/app/templates/scopes/scope/host-catalogs/host-catalog/host-sets/new.hbs +++ b/ui/admin/app/templates/scopes/scope/host-catalogs/host-catalog/host-sets/new.hbs @@ -4,4 +4,5 @@ @model={{@model}} @submit={{route-action 'save' @model}} @cancel={{route-action 'cancel' @model}} + @changeType={{route-action 'changeType' @model.type}} /> \ No newline at end of file