Correct bug on display of notices on permalinks. Correct bug #0025750
authorymh <ymh.work@gmail.com>
Tue, 17 Jan 2017 18:57:25 +0100
changeset 488 0161e028afb7
parent 487 514dc9b6f875
child 489 18613f052d56
Correct bug on display of notices on permalinks. Correct bug #0025750
cms/app-client/app/models/document.js
cms/app-client/app/templates/components/notice-component.hbs
--- a/cms/app-client/app/models/document.js	Tue Jan 17 13:30:54 2017 +0100
+++ b/cms/app-client/app/models/document.js	Tue Jan 17 18:57:25 2017 +0100
@@ -34,18 +34,18 @@
     }),
 
     media: Ember.computed('mediaArray', function() {
-        var array = [];
+        var arrayMedia = [];
         var master = null;
         _.forEach(this.get('mediaArray'), function(media) {
-            var index = array.findIndex(element => element.format === media.format);
+            var index = arrayMedia.findIndex(element => element.format === media.format);
             if(media.master) {
               master = media;
             }
             if(index === -1 && !media.master) {
-                array.push(media);
+                arrayMedia.push(media);
             }
         });
-        array.sort((m1, m2) => {
+        arrayMedia.sort((m1, m2) => {
 
           const f1 = m1.format;
           const f2 = m2.format;
@@ -54,17 +54,17 @@
 
           return w1-w2;
         });
-        if(array.length === 0 && master) {
-          array.push(master);
+        if(arrayMedia.length === 0 && master) {
+          arrayMedia.push(master);
         }
-        return array;
+        return arrayMedia;
     }),
 
     video: Ember.computed('media', function() {
         return this.get('media').findIndex(element => element.format.match(new RegExp('^video/'))) > -1;
     }),
 
-    duration: Ember.computed('duration_ms', function() {
+    duration: Ember.computed( 'duration_ms', function() {
         return this.get('duration_ms')/1000;
     }),
 
--- a/cms/app-client/app/templates/components/notice-component.hbs	Tue Jan 17 13:30:54 2017 +0100
+++ b/cms/app-client/app/templates/components/notice-component.hbs	Tue Jan 17 18:57:25 2017 +0100
@@ -1,5 +1,5 @@
 <h2>{{ item.title }}</h2>
-<h5><a href={{abs-url-for "document" item.id}} class="notice-permalink" target="_blank">permalien</a></h5>
+<h5>{{#if item.id }}<a href={{abs-url-for "document" item.id}} class="notice-permalink" target="_blank">permalien</a>{{/if}}</h5>
 <table>
   <tr>
     <td class="title">Editeur{{#if (if-operator item.publishers.length '>' 1)}}s{{/if}}</td>