diff --git a/app/models/characteristic.js b/app/models/characteristic.js index d896ca1..ca4c5d9 100644 --- a/app/models/characteristic.js +++ b/app/models/characteristic.js @@ -12,4 +12,5 @@ export default DS.Model.extend({ updatedBy : DS.attr('number'), deletedBy : DS.attr('number'), sortOrder : DS.attr('number'), + canEdit : DS.attr('boolean'), }); diff --git a/app/pods/components/x-application/template.hbs b/app/pods/components/x-application/template.hbs index 635b605..a2097bd 100644 --- a/app/pods/components/x-application/template.hbs +++ b/app/pods/components/x-application/template.hbs @@ -5,9 +5,6 @@ {{#link-to 'protected.compare' tagName='li' href=false}} {{link-to 'Compare' 'protected.compare'}} {{/link-to}} - {{#link-to 'protected.measurements' tagName='li' href=false}} - {{link-to 'Measurements' 'protected.measurements'}} - {{/link-to}} {{#link-to 'protected.characteristics' tagName='li' href=false}} {{link-to 'Characteristics' 'protected.characteristics'}} {{/link-to}} diff --git a/app/pods/protected/characteristics/controller.js b/app/pods/protected/characteristics/controller.js index be9f042..0403cc5 100644 --- a/app/pods/protected/characteristics/controller.js +++ b/app/pods/protected/characteristics/controller.js @@ -1,6 +1,6 @@ import Ember from 'ember'; export default Ember.Controller.extend({ - sortParams: ['characteristicTypeName', 'sortOrder'], + sortParams: ['characteristicTypeName', 'sortOrder', 'characteristicName'], sortedCharacteristics: Ember.computed.sort('model', 'sortParams'), }); diff --git a/app/pods/protected/characteristics/editable-row/component.js b/app/pods/protected/characteristics/editable-row/component.js new file mode 100644 index 0000000..384d254 --- /dev/null +++ b/app/pods/protected/characteristics/editable-row/component.js @@ -0,0 +1,28 @@ +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 new file mode 100644 index 0000000..8230297 --- /dev/null +++ b/app/pods/protected/characteristics/editable-row/template.hbs @@ -0,0 +1,15 @@ +{{#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/template.hbs b/app/pods/protected/characteristics/template.hbs index a599cbd..12ce1c1 100644 --- a/app/pods/protected/characteristics/template.hbs +++ b/app/pods/protected/characteristics/template.hbs @@ -7,15 +7,12 @@ Name Type Sort Order + {{#each sortedCharacteristics as |row|}} - - {{row.characteristicName}} - {{row.characteristicTypeName}} - {{row.sortOrder}} - + {{protected/characteristics/editable-row row=row}} {{/each}} diff --git a/app/pods/protected/compare/controller.js b/app/pods/protected/compare/controller.js index da7295b..00ef991 100644 --- a/app/pods/protected/compare/controller.js +++ b/app/pods/protected/compare/controller.js @@ -9,6 +9,33 @@ export default Ember.Controller.extend({ }; this.transitionToRoute('protected.compare.results', {queryParams: query}); - } + }, + + selectAllStrains: function() { + let strains = this.get('strains'); + let strain_ids = []; + strains.forEach((strain) => { + strain_ids.push(strain.id); + }); + this.set('selectedStrains', strain_ids.join(",")); + }, + + deselectAllStrains: function() { + this.set('selectedStrains', ''); + }, + + selectAllCharacteristics: function() { + let chars = this.get('characteristics'); + let char_ids = []; + chars.forEach((char) => { + char_ids.push(char.id); + }); + this.set('selectedCharacteristics', char_ids.join(",")); + }, + + deselectAllCharacteristics: function() { + this.set('selectedCharacteristics', ''); + }, + } }); diff --git a/app/pods/protected/compare/template.hbs b/app/pods/protected/compare/template.hbs index 48c2bd3..fefe9a6 100644 --- a/app/pods/protected/compare/template.hbs +++ b/app/pods/protected/compare/template.hbs @@ -16,6 +16,14 @@ placeholder="Select one or more strains" }} +
  • + + +
  • {{ @@ -28,6 +36,14 @@ placeholder="Select one or more characteristics" }}
  • +
  • + + +