cms/app-client/app/controllers/application.js
changeset 196 7550cb541901
parent 194 02c6aa9a99d7
child 197 7b266ccf6d3d
--- a/cms/app-client/app/controllers/application.js	Mon Jun 20 17:04:59 2016 +0200
+++ b/cms/app-client/app/controllers/application.js	Tue Jun 21 14:24:30 2016 +0200
@@ -3,11 +3,45 @@
 export default Ember.Controller.extend({
 
     queryParams: ['location', 'langue', 'discours', 'date', 'thematique', 'detail'],
-    location: null,
-    langue: null,
+
+    filter: Ember.inject.service(),
+
+    date: [],
+    setDateFilter: Ember.observer('date', function() {
+        this.get('filter').set('date', this.get('date'));
+    }),
+    setDate: Ember.observer('filter.date', function() {
+        this.set('date', this.get('filter').get('date'));
+    }),
     discours: null,
-    date: [],
+    setDiscoursFilter: Ember.observer('discours', function() {
+        this.get('filter').set('discours', this.get('discours'));
+    }),
+    setDiscours: Ember.observer('filter.discours', function() {
+        this.set('discours', this.get('filter').get('discours'));
+    }),
+    langue: null,
+    setLangueFilter: Ember.observer('langue', function() {
+        this.get('filter').set('langue', this.get('langue'));
+    }),
+    setLangue: Ember.observer('filter.langue', function() {
+        this.set('langue', this.get('filter').get('langue'));
+    }),
+    location: null,
+    setLocationFilter: Ember.observer('location', function() {
+        this.get('filter').set('location', this.get('location'));
+    }),
+    setLocation: Ember.observer('filter.location', function() {
+        this.set('location', this.get('filter').get('location'));
+    }),
     thematique: null,
+    setThematiqueFilter: Ember.observer('thematique', function() {
+        this.get('filter').set('thematique', this.get('thematique'));
+    }),
+    setThematique: Ember.observer('filter.thematique', function() {
+        this.set('thematique', this.get('filter').get('thematique'));
+    }),
+
     detail: null,
 
     dateIntervals: Ember.computed('date', function() {
@@ -41,7 +75,7 @@
         return this.store.findRecord('document', this.get('detail'));
     }),
 
-    filteredDocuments: Ember.computed('location', 'langue', 'discours', 'date', 'thematique', 'model', function() {
+    filteredDocuments: Ember.computed('filter.location', 'filter.langue', 'filter.discours', 'filter.date', 'filter.thematique', 'model', function() {
         var location = this.get('location');
         var langue = this.get('langue');
         var discours = this.get('discours');