github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/ui/app/routes/variables/new.js (about) 1 import Route from '@ember/routing/route'; 2 3 export default class VariablesNewRoute extends Route { 4 async model(params) { 5 const namespaces = await this.store.peekAll('namespace'); 6 return this.store.createRecord('variable', { 7 path: params.path, 8 namespace: namespaces.objectAt(0)?.id, 9 }); 10 } 11 resetController(controller, isExiting) { 12 // If the user navigates away from /new, clear the path 13 controller.set('path', null); 14 if (isExiting) { 15 // If user didn't save, delete the freshly created model 16 if (controller.model.isNew) { 17 controller.model.destroyRecord(); 18 } 19 } 20 } 21 }