ENH: Collections (update) (#40)

Fixes #36
This commit is contained in:
Matthew Ryan Dillon 2017-10-07 17:37:24 -07:00 committed by GitHub
parent e1abc5e4cb
commit f41f4caccd
17 changed files with 221 additions and 77 deletions

View file

@ -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);
},
},
});

View 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);
},
},
});

View 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'));
},
},
});