ENH: Collection Edit (parity with reading) (#48)

This commit is contained in:
Matthew Ryan Dillon 2017-11-30 15:51:16 -07:00 committed by GitHub
parent bfae4422f4
commit cb3bc081a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 337 additions and 121 deletions

View file

@ -1,27 +1,41 @@
import Ember from 'ember';
import CollectionValidations from 'ccdb-web/validations/collection';
import { schema } from 'ccdb-web/models/collection';
import CollectionSpeciesValidations from 'ccdb-web/validations/collection-species';
import ValidationMixin from 'ccdb-web/mixins/validation';
const { Controller } = Ember;
const { Controller, computed } = Ember;
export default Controller.extend(ValidationMixin, {
CollectionValidations,
CollectionSpeciesValidations,
options: computed('projectOptions', 'studyLocationOptions',
'collectionTypeOptions', 'collectionMethodOptions',
'speciesOptions', 'adfgPermitOptions', function() {
return {
projects: this.get('projectOptions'),
studyLocations: this.get('studyLocationOptions'),
collectionTypes: this.get('collectionTypeOptions'),
collectionMethods: this.get('collectionMethodOptions'),
species: this.get('speciesOptions'),
adfgPermits: this.get('adfgPermitOptions'),
};
}),
actions: {
onSave(changeset) {
onSave(changesets) {
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);
return this.validationSave(changesets, postSave);
},
onCancel(changeset) {
onCancel(changesets) {
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);
return this.validationCancel(changesets, postCancel);
},
},
});