--- a/cms/app-client/app/controllers/application.js Sun Jun 12 22:53:25 2016 +0200
+++ b/cms/app-client/app/controllers/application.js Tue Jun 14 18:15:26 2016 +0200
@@ -9,6 +9,25 @@
thematique: null,
detail: null,
+ dateIntervals: Ember.computed('date', function() {
+ var intervals = [];
+
+ this.get('date').forEach(function(date) {
+ var intervalDate = false;
+
+ intervals.forEach(function(interval) {
+ if(interval.length && (interval.includes(date + 1) || interval.includes(date - 1))) {
+ interval.push(date);
+ intervalDate = true;
+ }
+ });
+
+ if (!intervalDate) { intervals.push([date]); }
+ });
+
+ return intervals;
+ }),
+
currentId: null,
currentItem: Ember.computed('currentId', function() {
Ember.$(".result-item").toggleClass("playing", false);
@@ -53,21 +72,24 @@
}
return documents;
}),
+
actions: {
- deleteTag: function(query, item){
- var newParams = null;
+
+ deleteTag: function(key, value){
+ var newValue = null;
- if (query === 'date'){
- newParams = [];
- Ember.$.each(this.get('date'), function(index, elt){
- if (elt !== item){
- newParams.push(elt);
+ if (key === 'date'){
+ newValue = [];
+ Ember.$.each(this.get('date'), function(index, date){
+ if(!value.includes(date)) {
+ newValue.push(date);
}
});
}
- this.set(query, newParams);
+ this.set(key, newValue);
},
+
changeDocument: function(docDirection){
var direction = (docDirection === "next") ? 1 : -1;
var currentObject = this.get("filteredDocuments").findBy('id', this.get("currentItem").get('id'));