diff --git a/.gitignore b/.gitignore index 86fceae..08e02d8 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ /libpeerconnection.log npm-debug.log testem.log +.firebase diff --git a/README.md b/README.md index 4e4e4bb..aa5a107 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# clostridiumdotinfo +# hymenobacterdotinfo This ember application is an interface for the [bactdb](https://github.com/thermokarst/bactdb). diff --git a/app/index.html b/app/index.html index ab0cdf9..96799a6 100644 --- a/app/index.html +++ b/app/index.html @@ -3,7 +3,7 @@ - clostridium.info + hymenobacter.info @@ -12,7 +12,7 @@ {{content-for 'head'}} - + {{content-for 'head-footer'}} @@ -20,7 +20,7 @@ {{content-for 'body'}} - + {{content-for 'body-footer'}} diff --git a/app/mirage/config.js b/app/mirage/config.js index ca17f7b..418da09 100644 --- a/app/mirage/config.js +++ b/app/mirage/config.js @@ -7,7 +7,7 @@ export default function() { export function testConfig() { this.urlPrefix = 'https://bactdb-test.herokuapp.com'; - this.namespace = '/api/clostridium'; + this.namespace = '/api/hymenobacter'; this.timing = 0; this.get('/users'); diff --git a/app/mixins/delete-model.js b/app/mixins/delete-model.js index 73f6ec5..9e113a0 100644 --- a/app/mixins/delete-model.js +++ b/app/mixins/delete-model.js @@ -8,7 +8,10 @@ export default Mixin.create({ actions: { delete: function() { this.get('model').destroyRecord().then(() => { - this.get('store').unloadAll(); + // Instead of unloading the entire store, we keep the loaded user models + ['species', 'strain', 'characteristic', 'measurement'].map((model) => { + this.get('store').unloadAll(model); + }); this.transitionToRoute(this.get('transitionRoute')); }); }, diff --git a/app/pods/login/login-form/template.hbs b/app/pods/login/login-form/template.hbs index 45afb9b..52773ca 100644 --- a/app/pods/login/login-form/template.hbs +++ b/app/pods/login/login-form/template.hbs @@ -10,3 +10,7 @@
{{link-to 'Forget your password?' 'users.requestlockouthelp'}}
+
+
+ Just checking things out? Log in with email read-only and password bacteria! +
diff --git a/app/pods/protected/about/template.hbs b/app/pods/protected/about/template.hbs index b583288..2b95e93 100644 --- a/app/pods/protected/about/template.hbs +++ b/app/pods/protected/about/template.hbs @@ -1,3 +1,3 @@
-

This is some information about clostridium.info

+

This is some information about hymenobacter.info

diff --git a/app/pods/protected/strains/edit/controller.js b/app/pods/protected/strains/edit/controller.js index 4d68665..509b1e7 100644 --- a/app/pods/protected/strains/edit/controller.js +++ b/app/pods/protected/strains/edit/controller.js @@ -1,36 +1,61 @@ import Ember from 'ember'; -import SaveModel from '../../../../mixins/save-model'; -import ajaxError from '../../../../utils/ajax-error'; -const { Controller } = Ember; +const { Controller, RSVP, inject: { service } } = Ember; + +export default Controller.extend({ + ajaxError: service('ajax-error'), -export default Controller.extend(SaveModel, { - // Required for SaveModel mixin fallbackRouteSave: 'protected.strains.show', fallbackRouteCancel: 'protected.strains.show', actions: { - addCharacteristic: function() { - return this.store.createRecord('measurement', { - characteristic: this.store.createRecord('characteristic', { sortOrder: -999 }), + save: function(properties, deleteQueue, updateQueue) { + let promises = []; + properties.measurements.forEach((measurement) => { + if (measurement.get('isNew')) { + promises.push(measurement.save()); + } + }); + + updateQueue.forEach((measurement) => { + promises.push(measurement.save()); + }); + + deleteQueue.forEach((measurement) => { + promises.push(measurement.destroyRecord()); + }); + + const model = this.get('model'); + const fallbackRoute = this.get('fallbackRouteSave'); + + RSVP.all(promises).then(() => { + // Can't call _super inside promise, have to reproduce save-model + // mixin here :-( + model.setProperties(properties); + model.save().then((model) => { + this.get('flashMessages').clearMessages(); + this.transitionToRoute(fallbackRoute, model); + }); + }, (errors) => { + this.get('ajaxError').alert(errors); }); }, - saveMeasurement: function(measurement, properties) { - measurement.setProperties(properties); - measurement.save().then(() => { - this.get('flashMessages').clearMessages(); - }, () => { - ajaxError(measurement.get('errors'), this.get('flashMessages')); - }); - }, + cancel: function() { + const model = this.get('model'); - deleteMeasurement: function(measurement) { - const characteristic = measurement.get('characteristic'); - if (characteristic.get('isNew')) { - characteristic.destroyRecord(); + model.get('errors').clear(); + model.rollbackAttributes(); + + if (model.get('isNew')) { + this.transitionToRoute(this.get('fallbackRouteCancel')); + } else { + this.transitionToRoute(this.get('fallbackRouteCancel'), model); } - measurement.destroyRecord(); + }, + + addMeasurement: function() { + return this.store.createRecord('measurement'); }, }, diff --git a/app/pods/protected/strains/edit/template.hbs b/app/pods/protected/strains/edit/template.hbs index 59d1633..334ad07 100644 --- a/app/pods/protected/strains/edit/template.hbs +++ b/app/pods/protected/strains/edit/template.hbs @@ -2,10 +2,8 @@ protected/strains/strain-form strain=model speciesList=speciesList - add-characteristic=(action "addCharacteristic") + add-measurement=(action "addMeasurement") allCharacteristics=allCharacteristics - save-measurement=(action "saveMeasurement") - delete-measurement=(action "deleteMeasurement") on-save=(action "save") on-cancel=(action "cancel") }} diff --git a/app/pods/protected/strains/measurements-table-row/component.js b/app/pods/protected/strains/measurements-table-row/component.js index ad63dc9..6b67968 100644 --- a/app/pods/protected/strains/measurements-table-row/component.js +++ b/app/pods/protected/strains/measurements-table-row/component.js @@ -10,6 +10,8 @@ export default Component.extend({ allCharacteristics: null, measurement: null, isDirty: null, + isNew: false, + isQueued: false, // Actions "save-measurement": null, @@ -22,11 +24,23 @@ export default Component.extend({ notes: null, resetOnInit: Ember.on('init', function() { + this._resetProperties(); + }), + + _resetProperties: function() { this.get('propertiesList').forEach((field) => { const valueInMeasurement = this.get('measurement').get(field); this.set(field, valueInMeasurement); }); - }), + // Read-only attributes + this.set('isNew', this.get('measurement.isNew')); + if (this.get('isNew') && !this.get('isQueued')) { + this.set('isEditing', true); + } else { + this.set('isEditing', false); + } + this.set('isDirty', false); + }, updateField: function(property, value) { this.set(property, value); @@ -40,12 +54,22 @@ export default Component.extend({ actions: { edit: function() { - this.toggleProperty('isEditing'); + this.set('isEditing', true); }, save: function() { this.attrs['save-measurement'](this.get('measurement'), this.getProperties(this.get('propertiesList'))); - this.toggleProperty('isEditing'); + this.set('isQueued', true); + this._resetProperties(); + }, + + cancel: function() { + if (this.get('isNew')) { + this.attrs['delete-measurement'](this.get('measurement')); + } else { + this._resetProperties(); + this.set('isEditing', false); + } }, delete: function() { diff --git a/app/pods/protected/strains/measurements-table-row/loading/template.hbs b/app/pods/protected/strains/measurements-table-row/loading/template.hbs new file mode 100644 index 0000000..e5a3e05 --- /dev/null +++ b/app/pods/protected/strains/measurements-table-row/loading/template.hbs @@ -0,0 +1 @@ +{{loading-panel}} diff --git a/app/pods/protected/strains/measurements-table-row/template.hbs b/app/pods/protected/strains/measurements-table-row/template.hbs index 0dc03b7..7a51e78 100644 --- a/app/pods/protected/strains/measurements-table-row/template.hbs +++ b/app/pods/protected/strains/measurements-table-row/template.hbs @@ -1,5 +1,7 @@ {{#if isEditing}} - + + {{{characteristic.characteristicTypeName}}} +