ENH: Collection Edit (parity with reading) (#48)
This commit is contained in:
parent
bfae4422f4
commit
cb3bc081a6
19 changed files with 337 additions and 121 deletions
|
@ -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);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue