feat: 🎸 allow host set typed creation

This commit is contained in:
dharini committed 2022-02-09 18:50:31 -08:00
1 parent 3437d4e665
commit a93bf5d4aa
2 files changed
+20 -3

No files matched your search

@@ -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 } });
}
}
@@ -4,4 +4,5 @@
@model={{@model}}
@submit={{route-action 'save' @model}}
@cancel={{route-action 'cancel' @model}}
@changeType={{route-action 'changeType' @model.type}}
/>