ENH: Collection List (#20)

This commit is contained in:
Matthew Ryan Dillon 2017-09-10 08:23:31 -07:00 committed by GitHub
parent 77071dfa35
commit 55a1c4fca6
26 changed files with 284 additions and 3 deletions

View file

@ -0,0 +1,10 @@
import DS from 'ember-data';
const { Model, attr } = DS;
export default Model.extend({
name: attr('string'),
code: attr('string'),
collectionMethodClass: attr('string'),
sortOrder: attr('number'),
});

View file

@ -0,0 +1,9 @@
import DS from 'ember-data';
const { Model, attr } = DS;
export default Model.extend({
name: attr('string'),
code: attr('string'),
sortOrder: attr('number'),
});

31
app/models/collection.js Normal file
View file

@ -0,0 +1,31 @@
import Ember from 'ember';
import DS from 'ember-data';
const { computed } = Ember;
const { Model, attr, belongsTo } = DS;
export default Model.extend({
displayName: attr('string'),
numberOfTraps: attr('number'),
collectionStartDate: attr('string-null-to-empty'),
collectionStartTime: attr('string-null-to-empty'),
collectionEndDate: attr('string-null-to-empty'),
collectionEndTime: attr('string-null-to-empty'),
project: belongsTo('project'),
studyLocation: belongsTo('study-location'),
collectionMethod: belongsTo('collection-method'),
collectionType: belongsTo('collection-type'),
startDateTime: computed('collectionStartDate', 'collectionStartTime',
function() { return this._mergeDateTime('Start'); }),
endDateTime: computed('collectionEndDate', 'collectionEndTime',
function() { return this._mergeDateTime('End'); }),
_mergeDateTime(timepoint) {
const date = this.get(`collection${timepoint}Date`);
const time = this.get(`collection${timepoint}Time`);
return `${date} ${time}`.trim();
},
});

11
app/models/project.js Normal file
View file

@ -0,0 +1,11 @@
import DS from 'ember-data';
const { Model, attr } = DS;
export default Model.extend({
name: attr('string'),
code: attr('string'),
iacucNumber: attr('string'),
description: attr('string'),
sortOrder: attr('number'),
});

View file

@ -0,0 +1,13 @@
import DS from 'ember-data';
const { Model, attr } = DS;
export default Model.extend({
name: attr('string'),
code: attr('string'),
studyLocationType: attr('string'),
treatmentType: attr('string'),
collectingLocation: attr('string'),
description: attr('string'),
sortOrder: attr('number'),
});