e58a95ed2f
* New variable creation adds the first namespace in your available list at variable creation time * Changelog
22 lines
634 B
JavaScript
22 lines
634 B
JavaScript
import Route from '@ember/routing/route';
|
|
|
|
export default class VariablesNewRoute extends Route {
|
|
async model(params) {
|
|
const namespaces = await this.store.peekAll('namespace');
|
|
return this.store.createRecord('variable', {
|
|
path: params.path,
|
|
namespace: namespaces.objectAt(0)?.id,
|
|
});
|
|
}
|
|
resetController(controller, isExiting) {
|
|
// If the user navigates away from /new, clear the path
|
|
controller.set('path', null);
|
|
if (isExiting) {
|
|
// If user didn't save, delete the freshly created model
|
|
if (controller.model.isNew) {
|
|
controller.model.destroyRecord();
|
|
}
|
|
}
|
|
}
|
|
}
|