--- a/cms/app-client/app/components/sorting-component.js Fri Jun 10 23:42:11 2016 +0200
+++ b/cms/app-client/app/components/sorting-component.js Sat Jun 11 01:07:57 2016 +0200
@@ -3,11 +3,14 @@
export default Ember.Component.extend({
classNames: ['sorting-component'],
- sorting: [],
+
+ sorting: ['label'],
sortedThemes: Ember.computed.sort('themes', 'sorting'),
+ isAlphabetical: true,
+ isPopularity: Ember.computed('isAlphabetical', function() { return !this.get('isAlphabetical'); }),
+
minimum: Ember.computed('themes', function() { return Math.min(...this.themes.mapBy('count')); }),
-
maximum: Ember.computed('themes', function() { return Math.max(...this.themes.mapBy('count')); }),
actions: {
@@ -18,10 +21,16 @@
},
sortBy: function (type) {
- this.set('sorting', type === 'popularity' ? ['count:desc'] : ['label']);
+ if(type === 'alphabetical') {
+ this.set('isAlphabetical', true);
+ this.set('sorting', ['label']);
+ } else {
+ this.set('isAlphabetical', false);
+ this.set('sorting', ['count:desc']);
+ }
this.get('sortedThemes');
}
}
-});
+});
\ No newline at end of file
--- a/cms/app-client/app/styles/components/sorting-component.scss Fri Jun 10 23:42:11 2016 +0200
+++ b/cms/app-client/app/styles/components/sorting-component.scss Sat Jun 11 01:07:57 2016 +0200
@@ -48,3 +48,7 @@
ul.tags li.very-popular{
font-size: 24px;
}
+
+ul.options li.active {
+ font-weight: bold;
+}
\ No newline at end of file
--- a/cms/app-client/app/templates/components/sorting-component.hbs Fri Jun 10 23:42:11 2016 +0200
+++ b/cms/app-client/app/templates/components/sorting-component.hbs Sat Jun 11 01:07:57 2016 +0200
@@ -5,8 +5,8 @@
Trier par :
<ul class="options">
- <li {{ action 'sortBy' 'alphabetical' }}>Ordre alphabétique</li>
- <li {{ action 'sortBy' 'popularity' }}>Popularité</li>
+ <li {{ action 'sortBy' 'alphabetical' }} class="{{if isAlphabetical "active"}}">Ordre alphabétique</li>
+ <li {{ action 'sortBy' 'popularity' }} class="{{if isPopularity "active"}}">Popularité</li>
</ul>
</div>