JSLinting on /langues endpoint
authorChloe Laisne <chloe.laisne@gmail.com>
Tue, 14 Jun 2016 18:28:34 +0200
changeset 190 226ae8f2e8e9
parent 189 21b30ee23191
child 191 db5711fbbb6c
JSLinting on /langues endpoint
cms/app-client/app/controllers/application.js
cms/app-client/app/controllers/tabs/chrono.js
cms/app-client/app/templates/results.hbs
--- a/cms/app-client/app/controllers/application.js	Tue Jun 14 18:15:26 2016 +0200
+++ b/cms/app-client/app/controllers/application.js	Tue Jun 14 18:28:34 2016 +0200
@@ -1,124 +1,126 @@
 import Ember from 'ember';
 
 export default Ember.Controller.extend({
-  queryParams: ['location', 'langue', 'discours', 'date', 'thematique', 'detail'],
-  location: null,
-  langue: null,
-  discours: null,
-  date: [],
-  thematique: null,
-  detail: null,
 
-  dateIntervals: Ember.computed('date', function() {
-    var intervals = [];
+    queryParams: ['location', 'langue', 'discours', 'date', 'thematique', 'detail'],
+    location: null,
+    langue: null,
+    discours: null,
+    date: [],
+    thematique: null,
+    detail: null,
 
-    this.get('date').forEach(function(date) {
-      var intervalDate = false;
+    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;
+    }),
 
-      intervals.forEach(function(interval) {
-        if(interval.length && (interval.includes(date + 1) || interval.includes(date - 1))) {
-          interval.push(date);
-          intervalDate = true;
+    currentId: null,
+    currentItem: Ember.computed('currentId', function() {
+        Ember.$(".result-item").toggleClass("playing", false);
+        if (this.get('currentId') === null){
+            return null;
         }
-      });
+        Ember.$("#"+this.get('currentId').replace( /(:|\.|\[|\]|,)/g, "\\$1" )).toggleClass("playing", true);
+        return this.store.findRecord('document', this.get('currentId'));
+    }),
+
+    modalItem: Ember.computed('detail', function() {
+        return this.store.findRecord('document', this.get('detail'));
+    }),
 
-      if (!intervalDate) { intervals.push([date]); }
-    });
+    filteredDocuments: Ember.computed('location', 'langue', 'discours', 'date', 'thematique', 'model', function() {
+        var location = this.get('location');
+        var langue = this.get('langue');
+        var discours = this.get('discours');
+        var date = this.get('date');
+        var thematique = this.get('thematique');
 
-    return intervals;
-  }),
+        var documents = this.get('model');
 
-  currentId: null,
-  currentItem: Ember.computed('currentId', function() {
-    Ember.$(".result-item").toggleClass("playing", false);
-    if (this.get('currentId') === null){
-      return null;
-    }
-    Ember.$("#"+this.get('currentId').replace( /(:|\.|\[|\]|,)/g, "\\$1" )).toggleClass("playing", true);
-    return this.store.findRecord('document', this.get('currentId'));
-  }),
-  modalItem: Ember.computed('detail', function() {
-    return this.store.findRecord('document', this.get('detail'));
-  }),
-  filteredDocuments: Ember.computed('location', 'langue', 'discours', 'date', 'thematique', 'model', function() {
-    var location = this.get('location');
-    var langue = this.get('langue');
-    var discours = this.get('discours');
-    var date = this.get('date');
-    var thematique = this.get('thematique');
+        if (location) {
+            documents = documents.filterBy('spatial', location);
+        }
+        if (langue) {
+            documents = documents.filterBy('language', langue);
+        }
+        if (discours) {
+            documents = documents.filterBy('type', discours);
+        }
+        if (date.length > 0) {
+            var temp = documents;
+            documents.map(function(elt){
+                if (date.indexOf(elt.get('created')) === -1){
+                    temp = temp.without(elt);
+                }
+            });
+            documents = temp;
+        }
+        if (thematique) {
+            documents = documents.filterBy('thematique', thematique);
+        }
+        return documents;
+    }),
+
+    actions: {
 
-    var documents = this.get('model');
+        deleteTag: function(key, value){
+            var newValue = null;
+            if (key === 'date'){
+                newValue = [];
+                Ember.$.each(this.get('date'), function(index, date){
+                    if(!value.includes(date)) {
+                        newValue.push(date);
+                    }
+                });
+            }
+            this.set(key, newValue);
+        },
 
-    if (location) {
-      documents = documents.filterBy('spatial', location);
-    }
-    if (langue) {
-      documents = documents.filterBy('language', langue);
-    }
-    if (discours) {
-      documents = documents.filterBy('type', discours);
+        changeDocument: function(docDirection){
+            var direction = (docDirection === "next") ? 1 : -1;
+            var currentObject = this.get("filteredDocuments").findBy('id', this.get("currentItem").get('id'));
+            if ( currentObject !== 'undefined'){
+                var index = this.get("filteredDocuments").indexOf(currentObject);
+                if ( typeof(this.get("filteredDocuments").objectAt(index+direction)) !== 'undefined'){
+                    return this.set('currentId', this.get("filteredDocuments").objectAt(index+direction).id);
+                }
+            }
+            return this.set('currentId', this.get('filteredDocuments').get('firstObject').id);
+        },
+        play: function(item){
+            this.set("currentId", item.id);
+        },
+
+        showMore: function(item){
+            var domItem = Ember.$("#"+item.id.replace( /(:|\.|\[|\]|,)/g, "\\$1" ));
+            if (domItem.hasClass("show-more")){
+                domItem.toggleClass("show-more", false);
+            } else{
+                Ember.$(".result-item").toggleClass("show-more", false);
+                domItem.toggleClass("show-more", true);
+            }
+        },
+
+        toggleModal: function(item){
+            if (typeof(item) !== 'undefined'){
+                this.set("detail", item.id);
+            } else {
+                this.set("detail", null);
+            }
+        }
+
     }
-    if (date.length > 0) {
-      var temp = documents;
-      documents.map(function(elt){
-        if (date.indexOf(elt.get('created')) === -1){
-          temp = temp.without(elt);
-        }
-      });
-      documents = temp;
-    }
-    if (thematique) {
-      documents = documents.filterBy('thematique', thematique);
-    }
-    return documents;
-  }),
-
-  actions: {
-
-    deleteTag: function(key, value){
-      var newValue = null;
-
-      if (key === 'date'){
-        newValue = [];
-        Ember.$.each(this.get('date'), function(index, date){
-          if(!value.includes(date)) {
-            newValue.push(date);
-          }
-        });
-      }
-
-      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'));
-      if ( currentObject !== 'undefined'){
-        var index = this.get("filteredDocuments").indexOf(currentObject);
-          if ( typeof(this.get("filteredDocuments").objectAt(index+direction)) !== 'undefined'){
-            return this.set('currentId', this.get("filteredDocuments").objectAt(index+direction).id);
-          }
-      }
-      return this.set('currentId', this.get('filteredDocuments').get('firstObject').id);
-    },
-    play: function(item){
-      this.set("currentId", item.id);
-    },
-    showMore: function(item){
-      var domItem = Ember.$("#"+item.id.replace( /(:|\.|\[|\]|,)/g, "\\$1" ));
-      if (domItem.hasClass("show-more")){
-          domItem.toggleClass("show-more", false);
-      } else{
-        Ember.$(".result-item").toggleClass("show-more", false);
-        domItem.toggleClass("show-more", true);
-      }
-    },
-    toggleModal: function(item){
-      if (typeof(item) !== 'undefined'){
-        this.set("detail", item.id);
-      } else {
-        this.set("detail", null);
-      }
-    }
-  }
 });
--- a/cms/app-client/app/controllers/tabs/chrono.js	Tue Jun 14 18:15:26 2016 +0200
+++ b/cms/app-client/app/controllers/tabs/chrono.js	Tue Jun 14 18:28:34 2016 +0200
@@ -2,9 +2,9 @@
 
 export default Ember.Controller.extend({
 
-  actions: {
-    updateUrl: function(selection){
-      this.transitionToRoute({queryParams: {date: selection}});
+    actions: {
+        updateUrl: function(selection){
+            this.transitionToRoute({queryParams: {'date': selection}});
+        }
     }
-  }
 });
--- a/cms/app-client/app/templates/results.hbs	Tue Jun 14 18:15:26 2016 +0200
+++ b/cms/app-client/app/templates/results.hbs	Tue Jun 14 18:28:34 2016 +0200
@@ -1,37 +1,33 @@
 <div class="result-header">
-  <p>
-    Filtres:
-    {{#if location}}
-      <span class="filters location">{{location}}<span class="fa fa-times" {{action 'deleteTag' 'location'}}></span></span>
-    {{/if}}
-    {{#if langue}}
-      <span class="filters langue">{{langue}}<span class="fa fa-times" {{action 'deleteTag' 'langue'}}></span></span>
-    {{/if}}
-    {{#if discours}}
-      <span class="filters discours">{{discours}}<span class="fa fa-times" {{action 'deleteTag' 'discours'}}></span></span>
-    {{/if}}
-    {{#if dateIntervals}}
-      {{#each dateIntervals as |item| }}
-        <span class="filters date" data-dates="{{item}}">{{interval item}}<span class="fa fa-times" {{action 'deleteTag' 'date' item }}></span></span>
-      {{/each}}
-    {{/if}}
-    {{#if thematique}}
-      <span class="filters thematique">{{thematique}}<span class="fa fa-times" {{action 'deleteTag' 'thematique'}}></span></span>
-    {{/if}}
-  </p>
+    <p>
+        Filtres:
+        {{#if location}}
+            <span class="filters location">{{location}}<span class="fa fa-times" {{action 'deleteTag' 'location'}}></span></span>
+        {{/if}}
+        {{#if langue}}
+            <span class="filters langue">{{langue}}<span class="fa fa-times" {{action 'deleteTag' 'langue'}}></span></span>
+        {{/if}}
+        {{#if discours}}
+        <span class="filters discours">{{discours}}<span class="fa fa-times" {{action 'deleteTag' 'discours'}}></span></span>
+        {{/if}}
+        {{#if dateIntervals}}
+            {{#each dateIntervals as |item| }}
+                <span class="filters date" data-dates="{{item}}">{{interval item}}<span class="fa fa-times" {{action 'deleteTag' 'date' item }}></span></span>
+            {{/each}}
+        {{/if}}
+        {{#if thematique}}
+            <span class="filters thematique">{{thematique}}<span class="fa fa-times" {{action 'deleteTag' 'thematique'}}></span></span>
+        {{/if}}
+    </p>
 </div>
 
 <div class='result-list'>
-  {{#each filteredDocuments as |item| }}
+    {{#each filteredDocuments as |item| }}
     <div id="{{item.id}}" {{action "showMore" item}} class='result-item'>
-      <span class="playing-indicator fa fa-play-circle fa-lg fa-fw pull-right" {{action 'play' item}}></span>
-      <strong>{{ item.title }}</strong>
-      <div class="description">
-        {{doc-language url=item.language}}
-      </div>
-      <div class="hidden-elt">
-        <button class="pull-right" {{action 'toggleModal' item}}>Details</button>
-      </div>
+        <span class="playing-indicator fa fa-play-circle fa-lg fa-fw pull-right" {{action 'play' item}}></span>
+        <strong>{{ item.title }}</strong>
+        <div class="description">{{doc-language url=item.language}}</div>
+        <div class="hidden-elt"><button class="pull-right" {{action 'toggleModal' item}}>Details</button></div>
     </div>
-  {{/each}}
+    {{/each}}
 </div>