parent
e1abc5e4cb
commit
f41f4caccd
17 changed files with 221 additions and 77 deletions
|
@ -1,16 +1,21 @@
|
|||
import Ember from 'ember';
|
||||
import CollectionValidations from '../../validations/collection';
|
||||
import { schema } from '../../models/collection';
|
||||
import ValidationMixin from '../../mixins/validation';
|
||||
|
||||
const { Controller } = Ember;
|
||||
|
||||
export default Controller.extend({
|
||||
export default Controller.extend(ValidationMixin, {
|
||||
CollectionValidations,
|
||||
|
||||
actions: {
|
||||
onSave(changeset) {
|
||||
changeset.save();
|
||||
this.transitionToRoute('collections.index');
|
||||
const postSave = () => { this.transitionToRoute('collections.index'); };
|
||||
return this.validationSave(changeset, schema, postSave);
|
||||
},
|
||||
onCancel(changeset) {
|
||||
changeset.rollback();
|
||||
this.transitionToRoute('collections.index');
|
||||
const postCancel = () => { this.transitionToRoute('collections.index'); };
|
||||
return this.validationCancel(changeset, postCancel);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
27
app/controllers/collections/detail/edit.js
Normal file
27
app/controllers/collections/detail/edit.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
import Ember from 'ember';
|
||||
import CollectionValidations from '../../../validations/collection';
|
||||
import { schema } from '../../../models/collection';
|
||||
import ValidationMixin from '../../../mixins/validation';
|
||||
|
||||
const { Controller } = Ember;
|
||||
|
||||
export default Controller.extend(ValidationMixin, {
|
||||
CollectionValidations,
|
||||
|
||||
actions: {
|
||||
onSave(changeset) {
|
||||
const postSave = () => {
|
||||
// Use the model's ID here because of the ArrayProxy in the route
|
||||
this.transitionToRoute('collections.detail', this.get('model.id'));
|
||||
};
|
||||
return this.validationSave(changeset, schema, postSave);
|
||||
},
|
||||
onCancel(changeset) {
|
||||
const postCancel = () => {
|
||||
// Use the model's ID here because of the ArrayProxy in the route
|
||||
return this.transitionToRoute('collections.detail', this.get('model.id'));
|
||||
};
|
||||
return this.validationCancel(changeset, postCancel);
|
||||
},
|
||||
},
|
||||
});
|
11
app/controllers/collections/detail/index.js
Normal file
11
app/controllers/collections/detail/index.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
const { Controller } = Ember;
|
||||
|
||||
export default Controller.extend({
|
||||
actions: {
|
||||
editCollection() {
|
||||
this.transitionToRoute('collections.detail.edit', this.get('model'));
|
||||
},
|
||||
},
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue