cms/app-client/app/controllers/application.js
changeset 81 848e4a5ad4d9
parent 72 9a7ea5349882
child 84 36f84e8f1ad5
--- a/cms/app-client/app/controllers/application.js	Thu Dec 31 10:22:55 2015 +0100
+++ b/cms/app-client/app/controllers/application.js	Thu Jan 07 17:46:50 2016 +0100
@@ -5,7 +5,7 @@
   location: null,
   langue: null,
   discours: null,
-  date: null,
+  date: [],
   thematique: null,
   currentItem: {title: "example", master: 'http://www.noiseaddicts.com/samples_1w72b820/3921.mp3'},
   filteredSounds: Ember.computed('location', 'langue', 'discours', 'date', 'thematique', 'model', function() {
@@ -13,7 +13,7 @@
     var langue = this.get('langue');
     var discours = this.get('discours');
     var date = this.get('date');
-    // var thematique = this.get('thematique');
+    var thematique = this.get('thematique');
 
     var sounds = this.get('model');
 
@@ -26,19 +26,30 @@
     if (discours) {
       sounds = sounds.filterBy('type', discours);
     }
-    if (date) {
-      sounds = sounds.filterBy('created', parseInt(date));
+    if (date.length > 0) {
+      var temp = sounds;
+      sounds.map(function(elt, index){
+        if (date.indexOf(elt.get('created')) === -1){
+          temp = temp.without(elt);
+        }
+      });
+      sounds = temp;
     }
-    // if (thematique) {
-    //   sounds = sounds.filterBy('thematique', thematique);
-    // }
-
+    if (thematique) {
+      sounds = sounds.filterBy('thematique', thematique);
+    }
     return sounds;
   }),
   actions: {
-    deleteTag: function(query){
+    deleteTag: function(query, item){
       var queryParams = {};
-      queryParams[query]  = null;
+      if (query === 'date'){
+        var array = this.get('date');
+        if(array.indexOf(item) !== -1) {
+        	array.splice(array.indexOf(item), 1);
+        }
+      }
+      queryParams[query] = array || null;
       this.transitionToRoute({queryParams: queryParams});
     },
     play: function(item){