Merge branch 'master' into clostridium

* master:
  Removing measurements route
  Edit characteristic
  'Select All' in compare.
  Fixed sort order in strains list
  genbank url for whole genome sequences
This commit is contained in:
Matthew Dillon 2015-09-04 09:32:05 -07:00
commit 1ce84c7269
13 changed files with 111 additions and 18 deletions

View file

@ -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'),
});

View file

@ -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}}

View file

@ -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'),
});

View file

@ -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');
},
}
});

View file

@ -0,0 +1,15 @@
{{#if isEditing}}
<td>{{input value=characteristicName}}</td>
<td>{{input value=characteristicTypeName}}</td>
<td>{{input value=sortOrder}}</td>
<td {{action 'save'}}>Save</td>
{{else}}
<td>{{row.characteristicName}}</td>
<td>{{row.characteristicTypeName}}</td>
<td>{{row.sortOrder}}</td>
{{#if row.canEdit}}
<td {{action 'edit'}}>Edit</td>
{{else}}
<td></td>
{{/if}}
{{/if}}

View file

@ -7,15 +7,12 @@
<th>Name</th>
<th>Type</th>
<th>Sort Order</th>
<th></th>
</tr>
</thead>
<tbody>
{{#each sortedCharacteristics as |row|}}
<tr>
<td>{{row.characteristicName}}</td>
<td>{{row.characteristicTypeName}}</td>
<td>{{row.sortOrder}}</td>
</tr>
{{protected/characteristics/editable-row row=row}}
{{/each}}
</tbody>
</table>

View file

@ -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', '');
},
}
});

View file

@ -16,6 +16,14 @@
placeholder="Select one or more strains"
}}
</li>
<li>
<button class="action button-green smaller right" {{action 'selectAllStrains'}}>
Select All
</button>
<button class="action button-red smaller right" {{action 'deselectAllStrains'}}>
Deselect All
</button>
</li>
<li>
<label>Characteristics</label>
{{
@ -28,6 +36,14 @@
placeholder="Select one or more characteristics"
}}
</li>
<li>
<button class="action button-green smaller right" {{action 'selectAllCharacteristics'}}>
Select All
</button>
<button class="action button-red smaller right" {{action 'deselectAllCharacteristics'}}>
Deselect All
</button>
</li>
<li>
<button type="submit" class="action button-gray smaller right">
Search

View file

@ -1,3 +0,0 @@
import Ember from 'ember';
export default Ember.Route.extend({});

View file

@ -1,3 +0,0 @@
<h2>{{genus-name}} Measurements</h2>
Be back soon

View file

@ -1,6 +1,6 @@
import Ember from 'ember';
export default Ember.Controller.extend({
sortParams: ['fullNameMU', 'totalMeasurements'],
sortParams: ['sortOrder'],
sortedStrains: Ember.computed.sort('model', 'sortParams'),
});

View file

@ -39,7 +39,7 @@
<dl class="span-1">
<dt>Whole Genome Sequence</dt>
<dd>
{{model.wholeGenomeSequence}}
{{genbank-url genbank=model.wholeGenomeSequence}}
</dd>
</dl>
</div>

View file

@ -0,0 +1,18 @@
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'));
});
}
});