diff --git a/app/models/characteristic.js b/app/models/characteristic.js index ca4c5d9..8851175 100644 --- a/app/models/characteristic.js +++ b/app/models/characteristic.js @@ -3,8 +3,8 @@ import DS from 'ember-data'; export default DS.Model.extend({ characteristicName : DS.attr('string'), characteristicTypeName: DS.attr('string'), - strains : DS.hasMany('strain', { async: true }), - measurements : DS.hasMany('measurements', { async: true }), + strains : DS.hasMany('strain', { async: false }), + measurements : DS.hasMany('measurements', { async: false }), createdAt : DS.attr('date'), updatedAt : DS.attr('date'), deletedAt : DS.attr('date'), diff --git a/app/models/measurement.js b/app/models/measurement.js index 32ceac5..80b6136 100644 --- a/app/models/measurement.js +++ b/app/models/measurement.js @@ -1,8 +1,8 @@ import DS from 'ember-data'; export default DS.Model.extend({ - strain : DS.belongsTo('strain', { async: true }), - characteristic : DS.belongsTo('characteristic', { async: true }), + strain : DS.belongsTo('strain', { async: false }), + characteristic : DS.belongsTo('characteristic', { async: false }), textMeasurementType: DS.attr('string'), txtValue : DS.attr('string'), numValue : DS.attr('number'), diff --git a/app/models/strain.js b/app/models/strain.js index 1f54647..7bd4e50 100644 --- a/app/models/strain.js +++ b/app/models/strain.js @@ -2,7 +2,8 @@ import DS from 'ember-data'; import Ember from 'ember'; export default DS.Model.extend({ - measurements : DS.hasMany('measurements', { async: true }), + measurements : DS.hasMany('measurements', { async: false }), + characteristics : DS.hasMany('characteristics', { async: false }), species : DS.belongsTo('species', { async: false }), strainName : DS.attr('string'), typeStrain : DS.attr('boolean'), diff --git a/app/models/user.js b/app/models/user.js index ae851d0..bb7c5fd 100644 --- a/app/models/user.js +++ b/app/models/user.js @@ -7,5 +7,22 @@ export default DS.Model.extend({ role : DS.attr('string'), createdAt: DS.attr('date'), updatedAt: DS.attr('date'), - deletedAt: DS.attr('date') + deletedAt: DS.attr('date'), + + isAdmin: function() { + return this.get('role') === 'A'; + }.property('role'), + + fullRole: function() { + let role = this.get('role'); + if (role === 'R') { + return 'Read-Only'; + } else if (role === 'W') { + return 'Write'; + } else if (role === 'A') { + return 'Admin'; + } else { + return 'Error'; + } + }.property('role'), }); diff --git a/app/pods/components/x-application/template.hbs b/app/pods/components/x-application/template.hbs index a2097bd..e859890 100644 --- a/app/pods/components/x-application/template.hbs +++ b/app/pods/components/x-application/template.hbs @@ -5,21 +5,26 @@ {{#link-to 'protected.compare' tagName='li' href=false}} {{link-to 'Compare' 'protected.compare'}} {{/link-to}} - {{#link-to 'protected.characteristics' tagName='li' href=false}} - {{link-to 'Characteristics' 'protected.characteristics'}} - {{/link-to}} {{#link-to 'protected.species' tagName='li' href=false}} {{link-to 'Species' 'protected.species'}} {{/link-to}} {{#link-to 'protected.strains' tagName='li' href=false}} {{link-to 'Strains' 'protected.strains'}} {{/link-to}} + {{#link-to 'protected.characteristics' tagName='li' href=false}} + {{link-to 'Characteristics' 'protected.characteristics'}} + {{/link-to}} + {{#if session.currentUser.isAdmin}} + {{#link-to 'protected.users' tagName='li' href=false}} + {{link-to 'Users' 'protected.users'}} + {{/link-to}} + {{/if}} {{#link-to 'protected.about' tagName='li' href=false}} {{link-to 'About' 'protected.about'}} {{/link-to}}

- {{session.currentUser.name}}
+ {{link-to session.currentUser.name 'protected.users.show' session.currentUser.id}}
Logout

{{else}} diff --git a/app/pods/components/forms/species-form/component.js b/app/pods/protected/characteristics/characteristic-form/component.js similarity index 100% rename from app/pods/components/forms/species-form/component.js rename to app/pods/protected/characteristics/characteristic-form/component.js diff --git a/app/pods/protected/characteristics/characteristic-form/template.hbs b/app/pods/protected/characteristics/characteristic-form/template.hbs new file mode 100644 index 0000000..b1d68c0 --- /dev/null +++ b/app/pods/protected/characteristics/characteristic-form/template.hbs @@ -0,0 +1,30 @@ +
+
+ {{characteristic.characteristicName}} +
+
+ + {{input value=characteristic.characteristicName}} +
+
+
+
+ + {{input value=characteristic.characteristicTypeName}} +
+
+ + {{input value=characteristic.sortOrder}} +
+
+
+
+ + Cancel + + {{#if characteristic.hasDirtyAttributes}} + + {{/if}} +
diff --git a/app/pods/protected/characteristics/edit/controller.js b/app/pods/protected/characteristics/edit/controller.js new file mode 100644 index 0000000..d0f2ec0 --- /dev/null +++ b/app/pods/protected/characteristics/edit/controller.js @@ -0,0 +1,30 @@ +import Ember from 'ember'; + +export default Ember.Controller.extend({ + actions: { + save: function() { + let characteristic = this.get('model'); + + if (characteristic.get('hasDirtyAttributes')) { + characteristic.save().then((characteristic) => { + this.transitionToRoute('protected.characteristics.show', characteristic); + }, (err) => { + this.get('flashMessages').error(err.responseJSON.error); + }); + } else { + characteristic.deleteRecord(); + this.transitionToRoute('protected.characteristics.show', characteristic); + } + }, + + cancel: function() { + let characteristic = this.get('model'); + + characteristic.get('errors').clear(); + characteristic.rollbackAttributes(); + + this.transitionToRoute('protected.characteristics.show', characteristic); + }, + + }, +}); diff --git a/app/pods/protected/characteristics/edit/route.js b/app/pods/protected/characteristics/edit/route.js new file mode 100644 index 0000000..3ab3562 --- /dev/null +++ b/app/pods/protected/characteristics/edit/route.js @@ -0,0 +1,15 @@ +import Ember from 'ember'; +import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin'; + +export default Ember.Route.extend(AuthenticatedRouteMixin, { + model: function(params) { + return this.store.findRecord('characteristic', params.characteristic_id, { reload: true }); + }, + + afterModel: function(model) { + if (!model.get('canEdit')) { + this.transitionTo('characteristics.show', model.get('id')); + } + }, + +}); diff --git a/app/pods/protected/characteristics/edit/template.hbs b/app/pods/protected/characteristics/edit/template.hbs new file mode 100644 index 0000000..3f1fe65 --- /dev/null +++ b/app/pods/protected/characteristics/edit/template.hbs @@ -0,0 +1,6 @@ +{{ + protected/characteristics/characteristic-form + characteristic=model + save="save" + cancel="cancel" +}} diff --git a/app/pods/protected/characteristics/editable-row/component.js b/app/pods/protected/characteristics/editable-row/component.js deleted file mode 100644 index 384d254..0000000 --- a/app/pods/protected/characteristics/editable-row/component.js +++ /dev/null @@ -1,28 +0,0 @@ -import Ember from 'ember'; - -export default Ember.Component.extend({ - tagName: 'tr', - - actions: { - edit: function() { - this.set('characteristicName', this.get('row.characteristicName')); - this.set('characteristicTypeName', this.get('row.characteristicTypeName')); - this.set('sortOrder', this.get('row.sortOrder')); - this.toggleProperty('isEditing'); - }, - - save: function() { - if (this.get('characteristicName') !== this.get('row.characteristicName') || - this.get('characteristicTypeName') !== this.get('row.characteristicTypeName') || - this.get('sortOrder') !== this.get('row.sortOrder')) { - this.set('row.characteristicName', this.get('characteristicName')); - this.set('row.characteristicTypeName', this.get('characteristicTypeName')); - this.set('row.sortOrder', this.get('sortOrder')); - this.get('row').save(); - } - this.toggleProperty('isEditing'); - }, - - } - -}); diff --git a/app/pods/protected/characteristics/editable-row/template.hbs b/app/pods/protected/characteristics/editable-row/template.hbs deleted file mode 100644 index 8230297..0000000 --- a/app/pods/protected/characteristics/editable-row/template.hbs +++ /dev/null @@ -1,15 +0,0 @@ -{{#if isEditing}} - {{input value=characteristicName}} - {{input value=characteristicTypeName}} - {{input value=sortOrder}} - Save -{{else}} - {{row.characteristicName}} - {{row.characteristicTypeName}} - {{row.sortOrder}} - {{#if row.canEdit}} - Edit - {{else}} - - {{/if}} -{{/if}} diff --git a/app/pods/protected/characteristics/controller.js b/app/pods/protected/characteristics/index/controller.js similarity index 100% rename from app/pods/protected/characteristics/controller.js rename to app/pods/protected/characteristics/index/controller.js diff --git a/app/pods/protected/characteristics/index/route.js b/app/pods/protected/characteristics/index/route.js new file mode 100644 index 0000000..83aa3ef --- /dev/null +++ b/app/pods/protected/characteristics/index/route.js @@ -0,0 +1,13 @@ +import Ember from 'ember'; + +export default Ember.Route.extend({ + model: function() { + return this.store.findAll('characteristic'); + }, + + setupController: function(controller, model) { + controller.set('model', model); + controller.set('metaData', this.store.metadataFor('characteristic')); + }, + +}); diff --git a/app/pods/protected/characteristics/index/template.hbs b/app/pods/protected/characteristics/index/template.hbs new file mode 100644 index 0000000..3430386 --- /dev/null +++ b/app/pods/protected/characteristics/index/template.hbs @@ -0,0 +1,27 @@ +

{{genus-name}} Characteristics

+

Total characteristics: {{model.length}}

+ +{{add-button label="Add Characteristic" link="protected.characteristics.new" canAdd=metaData.canAdd}} + + + + + + + + + + + {{#each sortedCharacteristics as |row|}} + + + + + + {{/each}} + +
NameTypeSort Order
+ {{#link-to 'protected.characteristics.show' row}} + {{row.characteristicName}} + {{/link-to}} + {{row.characteristicTypeName}}{{row.sortOrder}}
diff --git a/app/pods/protected/characteristics/loading/template.hbs b/app/pods/protected/characteristics/loading/template.hbs new file mode 100644 index 0000000..e5a3e05 --- /dev/null +++ b/app/pods/protected/characteristics/loading/template.hbs @@ -0,0 +1 @@ +{{loading-panel}} diff --git a/app/pods/protected/characteristics/new/controller.js b/app/pods/protected/characteristics/new/controller.js new file mode 100644 index 0000000..c211ec8 --- /dev/null +++ b/app/pods/protected/characteristics/new/controller.js @@ -0,0 +1,24 @@ +import Ember from 'ember'; + +export default Ember.Controller.extend({ + actions: { + save: function() { + let characteristic = this.get('model'); + + if (characteristic.get('hasDirtyAttributes')) { + characteristic.save().then((characteristic) => { + this.transitionToRoute('protected.characteristics.show', characteristic); + }, (err) => { + this.get('flashMessages').error(err.responseJSON.error); + }); + } else { + this.transitionToRoute('protected.characteristics.index'); + } + }, + + cancel: function() { + this.transitionToRoute('protected.characteristics.index'); + }, + + }, +}); diff --git a/app/pods/protected/characteristics/new/route.js b/app/pods/protected/characteristics/new/route.js new file mode 100644 index 0000000..6ddb337 --- /dev/null +++ b/app/pods/protected/characteristics/new/route.js @@ -0,0 +1,26 @@ +import Ember from 'ember'; + +export default Ember.Route.extend({ + beforeModel: function(transition) { + this._super(transition); + if (this.get('session.currentUser.role') === 'R') { + this.transitionTo('characteristics.index'); + } + }, + + model: function() { + return this.store.createRecord('characteristic'); + }, + + actions: { + willTransition: function(/*transition*/) { + let controller = this.get('controller'); + let characteristic = controller.get('model'); + + if (characteristic.get('isNew')) { + characteristic.deleteRecord(); + } + }, + }, + +}); diff --git a/app/pods/protected/characteristics/new/template.hbs b/app/pods/protected/characteristics/new/template.hbs new file mode 100644 index 0000000..3f1fe65 --- /dev/null +++ b/app/pods/protected/characteristics/new/template.hbs @@ -0,0 +1,6 @@ +{{ + protected/characteristics/characteristic-form + characteristic=model + save="save" + cancel="cancel" +}} diff --git a/app/pods/protected/characteristics/route.js b/app/pods/protected/characteristics/route.js deleted file mode 100644 index cf8c61a..0000000 --- a/app/pods/protected/characteristics/route.js +++ /dev/null @@ -1,8 +0,0 @@ -import Ember from 'ember'; - -export default Ember.Route.extend({ - model: function() { - return this.store.findAll('characteristic'); - }, - -}); diff --git a/app/pods/protected/characteristics/show/measurements-table/component.js b/app/pods/protected/characteristics/show/measurements-table/component.js new file mode 100644 index 0000000..63d3165 --- /dev/null +++ b/app/pods/protected/characteristics/show/measurements-table/component.js @@ -0,0 +1,20 @@ +import Ember from 'ember'; + +export default Ember.Component.extend({ + measurementsPresent: function() { + return this.get('model.measurements.length') > 0; + }.property('model.measurements'), + + measurementsTable: function() { + let measurements = this.get('model.measurements'); + let table = []; + measurements.forEach((measurement) => { + let row = {}; + row['measurement'] = measurement; + row['strain'] = this.store.peekRecord('strain', measurement.get('strain.id')); + table.push(row); + }); + return table; + }.property(), + +}); diff --git a/app/pods/protected/characteristics/show/measurements-table/template.hbs b/app/pods/protected/characteristics/show/measurements-table/template.hbs new file mode 100644 index 0000000..1813ed8 --- /dev/null +++ b/app/pods/protected/characteristics/show/measurements-table/template.hbs @@ -0,0 +1,30 @@ +{{#if measurementsPresent}} + + + + + + + + + + {{#each measurementsTable as |row|}} + + + + + + {{/each}} + +
StrainValueNotes
+ {{#link-to 'protected.strains.show' row.strain.id}} + {{{row.strain.strainNameMU}}} + {{/link-to}} + + {{row.measurement.value}} + + {{row.measurement.notes}} +
+{{else}} +No measurements on record. +{{/if}} diff --git a/app/pods/protected/characteristics/show/route.js b/app/pods/protected/characteristics/show/route.js new file mode 100644 index 0000000..f66a9c7 --- /dev/null +++ b/app/pods/protected/characteristics/show/route.js @@ -0,0 +1,8 @@ +import Ember from 'ember'; + +export default Ember.Route.extend({ + model: function(params) { + return this.store.findRecord('characteristic', params.characteristic_id, { reload: true }); + }, + +}); diff --git a/app/pods/protected/characteristics/show/template.hbs b/app/pods/protected/characteristics/show/template.hbs new file mode 100644 index 0000000..ccdb9f4 --- /dev/null +++ b/app/pods/protected/characteristics/show/template.hbs @@ -0,0 +1,57 @@ +
+
+
+ + {{model.characteristicName}} + + + {{! ROW 1 }} +
+
+
Characteristic Type
+
+ {{model.characteristicTypeName}} +
+
+
+
Sort Order
+
+ {{model.sortOrder}} +
+
+
+ + {{! ROW 2 }} +
+
+
Measurements
+
+ {{protected/characteristics/show/measurements-table model=model}} +
+
+
+ + {{! ROW 3 }} +
+
+
Record Created
+
{{null-time model.createdAt 'LL'}}
+
+
+
Record Updated
+
{{null-time model.updatedAt 'LL'}}
+
+
+
Record Deleted
+
{{null-time model.deletedAt 'LL'}}
+
+
+
+
+
+{{#if model.canEdit}} +
+ {{#link-to 'protected.characteristics.edit' model.id class="button-gray smaller"}} + Edit + {{/link-to}} +{{/if}} diff --git a/app/pods/protected/characteristics/template.hbs b/app/pods/protected/characteristics/template.hbs deleted file mode 100644 index 12ce1c1..0000000 --- a/app/pods/protected/characteristics/template.hbs +++ /dev/null @@ -1,18 +0,0 @@ -

{{genus-name}} Characteristics

-

Total characteristics: {{model.length}}

- - - - - - - - - - - - {{#each sortedCharacteristics as |row|}} - {{protected/characteristics/editable-row row=row}} - {{/each}} - -
NameTypeSort Order
diff --git a/app/pods/protected/compare/loading/template.hbs b/app/pods/protected/compare/loading/template.hbs new file mode 100644 index 0000000..e5a3e05 --- /dev/null +++ b/app/pods/protected/compare/loading/template.hbs @@ -0,0 +1 @@ +{{loading-panel}} diff --git a/app/pods/protected/species/edit/template.hbs b/app/pods/protected/species/edit/template.hbs index 5c6c82f..c3b8a05 100644 --- a/app/pods/protected/species/edit/template.hbs +++ b/app/pods/protected/species/edit/template.hbs @@ -1,5 +1,5 @@ {{ - forms/species-form + protected/species/species-form species=model save="save" cancel="cancel" diff --git a/app/pods/protected/species/loading/template.hbs b/app/pods/protected/species/loading/template.hbs new file mode 100644 index 0000000..e5a3e05 --- /dev/null +++ b/app/pods/protected/species/loading/template.hbs @@ -0,0 +1 @@ +{{loading-panel}} diff --git a/app/pods/protected/species/new/template.hbs b/app/pods/protected/species/new/template.hbs index 5c6c82f..c3b8a05 100644 --- a/app/pods/protected/species/new/template.hbs +++ b/app/pods/protected/species/new/template.hbs @@ -1,5 +1,5 @@ {{ - forms/species-form + protected/species/species-form species=model save="save" cancel="cancel" diff --git a/app/pods/protected/species/species-form/component.js b/app/pods/protected/species/species-form/component.js new file mode 100644 index 0000000..a53a469 --- /dev/null +++ b/app/pods/protected/species/species-form/component.js @@ -0,0 +1,13 @@ +import Ember from 'ember'; + +export default Ember.Component.extend({ + actions: { + save: function() { + this.sendAction('save'); + }, + + cancel: function() { + this.sendAction('cancel'); + }, + } +}); diff --git a/app/pods/components/forms/species-form/template.hbs b/app/pods/protected/species/species-form/template.hbs similarity index 100% rename from app/pods/components/forms/species-form/template.hbs rename to app/pods/protected/species/species-form/template.hbs diff --git a/app/pods/protected/strains/edit/template.hbs b/app/pods/protected/strains/edit/template.hbs index e15fec0..d9c4d43 100644 --- a/app/pods/protected/strains/edit/template.hbs +++ b/app/pods/protected/strains/edit/template.hbs @@ -1,5 +1,5 @@ {{ - forms/strain-form + protected/strains/strain-form strain=strain species=species save="save" diff --git a/app/pods/protected/strains/loading/template.hbs b/app/pods/protected/strains/loading/template.hbs new file mode 100644 index 0000000..e5a3e05 --- /dev/null +++ b/app/pods/protected/strains/loading/template.hbs @@ -0,0 +1 @@ +{{loading-panel}} diff --git a/app/pods/protected/strains/new/template.hbs b/app/pods/protected/strains/new/template.hbs index e15fec0..d9c4d43 100644 --- a/app/pods/protected/strains/new/template.hbs +++ b/app/pods/protected/strains/new/template.hbs @@ -1,5 +1,5 @@ {{ - forms/strain-form + protected/strains/strain-form strain=strain species=species save="save" diff --git a/app/pods/protected/strains/show/loading/template.hbs b/app/pods/protected/strains/show/loading/template.hbs new file mode 100644 index 0000000..e5a3e05 --- /dev/null +++ b/app/pods/protected/strains/show/loading/template.hbs @@ -0,0 +1 @@ +{{loading-panel}} diff --git a/app/pods/protected/strains/show/measurements-table/component.js b/app/pods/protected/strains/show/measurements-table/component.js new file mode 100644 index 0000000..bddc5d1 --- /dev/null +++ b/app/pods/protected/strains/show/measurements-table/component.js @@ -0,0 +1,25 @@ +import Ember from 'ember'; + +export default Ember.Component.extend({ + measurementsPresent: function() { + return this.get('model.measurements.length') > 0; + }.property('model.measurements'), + + measurementsTable: function() { + let measurements = this.get('model.measurements'); + let table = []; + measurements.forEach((measurement) => { + let row = {}; + row['measurement'] = measurement; + row['characteristic'] = this.store.peekRecord('characteristic', measurement.get('characteristic.id')); + table.push(row); + }); + table.sort((a, b) => { + let a_sort = a['characteristic'] && a['characteristic'].get('sortOrder'); + let b_sort = b['characteristic'] && b['characteristic'].get('sortOrder'); + return a_sort - b_sort; + }); + return table; + }.property(), + +}); diff --git a/app/pods/protected/strains/show/measurements-table/loading/template.hbs b/app/pods/protected/strains/show/measurements-table/loading/template.hbs new file mode 100644 index 0000000..e5a3e05 --- /dev/null +++ b/app/pods/protected/strains/show/measurements-table/loading/template.hbs @@ -0,0 +1 @@ +{{loading-panel}} diff --git a/app/pods/protected/strains/show/measurements-table/template.hbs b/app/pods/protected/strains/show/measurements-table/template.hbs new file mode 100644 index 0000000..188ac47 --- /dev/null +++ b/app/pods/protected/strains/show/measurements-table/template.hbs @@ -0,0 +1,30 @@ +{{#if measurementsPresent}} + + + + + + + + + + {{#each measurementsTable as |row|}} + + + + + + {{/each}} + +
CharacteristicValueNotes
+ {{#link-to 'protected.characteristics.show' row.characteristic.id}} + {{{row.characteristic.characteristicName}}} + {{/link-to}} + + {{row.measurement.value}} + + {{row.measurement.notes}} +
+{{else}} +No measurements on record. +{{/if}} diff --git a/app/pods/protected/strains/show/template.hbs b/app/pods/protected/strains/show/template.hbs index 55b2bff..7504458 100644 --- a/app/pods/protected/strains/show/template.hbs +++ b/app/pods/protected/strains/show/template.hbs @@ -59,12 +59,26 @@
Notes
- {{{model.notes}}} + {{#if model.notes}} + {{{model.notes}}} + {{else}} + No notes. + {{/if}}
{{! ROW 5 }} +
+
+
Characteristics
+
+ {{protected/strains/show/measurements-table model=model}} +
+
+
+ + {{! ROW 6 }}
Record Created
diff --git a/app/pods/components/forms/strain-form/component.js b/app/pods/protected/strains/strain-form/component.js similarity index 100% rename from app/pods/components/forms/strain-form/component.js rename to app/pods/protected/strains/strain-form/component.js diff --git a/app/pods/components/forms/strain-form/template.hbs b/app/pods/protected/strains/strain-form/template.hbs similarity index 100% rename from app/pods/components/forms/strain-form/template.hbs rename to app/pods/protected/strains/strain-form/template.hbs diff --git a/app/pods/protected/users/index/route.js b/app/pods/protected/users/index/route.js new file mode 100644 index 0000000..e8b6bc7 --- /dev/null +++ b/app/pods/protected/users/index/route.js @@ -0,0 +1,17 @@ +import Ember from 'ember'; + +export default Ember.Route.extend({ + beforeModel: function(transition) { + this._super(transition); + this.get('session.currentUser').then((user) => { + if (!user.get('isAdmin')) { + this.transitionTo('protected.index'); + } + }); + }, + + model: function() { + return this.store.findAll('user'); + }, + +}); diff --git a/app/pods/protected/users/index/template.hbs b/app/pods/protected/users/index/template.hbs new file mode 100644 index 0000000..adb5b55 --- /dev/null +++ b/app/pods/protected/users/index/template.hbs @@ -0,0 +1,33 @@ +

{{genus-name}} Users

+

Total users: {{model.length}}

+ + + + + + + + + + + + {{#each model as |row|}} + + + + + + + {{/each}} + +
NameEmailRoleDate Registered
+ {{#link-to 'protected.users.show' row}} + {{row.name}} + {{/link-to}} + + {{row.email}} + + {{row.fullRole}} + + {{null-time row.createdAt 'LL'}} +
diff --git a/app/pods/protected/users/show/route.js b/app/pods/protected/users/show/route.js new file mode 100644 index 0000000..bc22dc0 --- /dev/null +++ b/app/pods/protected/users/show/route.js @@ -0,0 +1,8 @@ +import Ember from 'ember'; + +export default Ember.Route.extend({ + model: function(params) { + return this.store.findRecord('user', params.user_id, { reload: true }); + }, + +}); diff --git a/app/pods/protected/users/show/template.hbs b/app/pods/protected/users/show/template.hbs new file mode 100644 index 0000000..de032f9 --- /dev/null +++ b/app/pods/protected/users/show/template.hbs @@ -0,0 +1,49 @@ +
+
+ + {{model.name}} + + + {{! ROW 1 }} +
+
+
Email
+
+ {{model.email}} +
+
+
+
Role
+
+ {{model.fullRole}} +
+
+
+ + {{! ROW 2 }} +
+
+
Record Created
+
{{null-time model.createdAt 'LL'}}
+
+
+
Record Updated
+
{{null-time model.updatedAt 'LL'}}
+
+
+
Record Deleted
+
{{null-time model.deletedAt 'LL'}}
+
+
+
+
+
+{{#link-to 'protected.users.show' model.id class="button-gray smaller"}} + Change Password (Does nothing at the moment) +{{/link-to}} +{{#if model.canEdit}} +
+ {{#link-to 'protected.user.edit' model.id class="button-gray smaller"}} + Edit + {{/link-to}} +{{/if}} diff --git a/app/router.js b/app/router.js index c34e885..5f48eec 100644 --- a/app/router.js +++ b/app/router.js @@ -18,13 +18,22 @@ Router.map(function() { this.route('protected', { path: '/' }, function() { this.route('about'); - this.route('characteristics'); - this.route('measurements'); + + this.route('users', function() { + this.route('show', { path: ':user_id' }); + this.route('edit', { path: ':user_id/edit' }); + }); this.route('compare', function() { this.route('results'); }); + this.route('characteristics', function() { + this.route('new'); + this.route('show', { path: ':characteristic_id' }); + this.route('edit', { path: ':characteristic_id/edit' }); + }); + this.route('species', function() { this.route('new'); this.route('show', { path: ':species_id' }); diff --git a/app/serializers/strain.js b/app/serializers/application.js similarity index 57% rename from app/serializers/strain.js rename to app/serializers/application.js index ddadf39..52f555e 100644 --- a/app/serializers/strain.js +++ b/app/serializers/application.js @@ -9,6 +9,17 @@ export default DS.RESTSerializer.extend({ var belongsTo = snapshot.belongsTo(key); key = this.keyForRelationship ? this.keyForRelationship(key, "belongsTo", "serialize") : key; json[key] = Ember.isNone(belongsTo) ? belongsTo : +belongsTo.record.id; - } + }, + + serializeHasMany: function(snapshot, json, relationship) { + var key = relationship.key; + var hasMany = snapshot.hasMany(key); + key = this.keyForRelationship ? this.keyForRelationship(key, "hasMany", "serialize") : key; + + json[key] = []; + hasMany.forEach((item) => { + json[key].push(+item.id); + }); + }, }); diff --git a/app/serializers/characteristic.js b/app/serializers/characteristic.js deleted file mode 100644 index 41ce180..0000000 --- a/app/serializers/characteristic.js +++ /dev/null @@ -1,18 +0,0 @@ -import DS from 'ember-data'; -import Ember from 'ember'; - -export default DS.RESTSerializer.extend({ - isNewSerializerAPI: true, - - serializeHasMany: function(snapshot, json, relationship) { - var key = relationship.key; - var hasMany = snapshot.hasMany(key); - key = this.keyForRelationship ? this.keyForRelationship(key, "hasMany", "serialize") : key; - - json[key] = []; - hasMany.forEach((item) => { - json[key].push(+item.get('id')); - }); - } - -});