author | ymh <ymh.work@gmail.com> |
Sat, 12 Nov 2016 17:21:25 +0100 | |
changeset 414 | 5c6c526a7fc1 |
parent 327 | 13564bb13ccc |
child 445 | b1e5ad6b2a29 |
permissions | -rw-r--r-- |
91 | 1 |
import DS from 'ember-data'; |
2 |
import Ember from 'ember'; |
|
94
62984937a062
- add params when modal appear so we can come back right on this document modal
nowmad@23.1.168.192.in-addr.arpa
parents:
91
diff
changeset
|
3 |
import _ from 'lodash/lodash'; |
91 | 4 |
|
217
989b9c36b849
Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
210
diff
changeset
|
5 |
export default DS.Model.extend({ |
209
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
126
diff
changeset
|
6 |
|
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
126
diff
changeset
|
7 |
uri: DS.attr('string'), |
210 | 8 |
issued: DS.attr('date'), |
209
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
126
diff
changeset
|
9 |
title: DS.attr('string'), |
327
13564bb13ccc
In the serialized document the lan files id 'languages' and not 'language'
ymh <ymh.work@gmail.com>
parents:
326
diff
changeset
|
10 |
languages: DS.attr({ defaultValue: function() { return []; } }), |
242 | 11 |
publisher: DS.attr('string'), |
289
7cae80e5748c
Add transcript icon to playlist items
Chloe Laisne <chloe.laisne@gmail.com>
parents:
270
diff
changeset
|
12 |
transcript_url: DS.attr('string'), |
253
0be9770b09b4
Hide/show transcript button in the player - Do not request transscript when property is null in the document request
Chloe Laisne <chloe.laisne@gmail.com>
parents:
243
diff
changeset
|
13 |
transcript: DS.attr({ defaultValue: function() { return {}; } }), |
242 | 14 |
|
15 |
publishers: DS.attr({ defaultValue: function() { return []; } }), |
|
16 |
contributors: DS.attr({ defaultValue: function() { return []; } }), |
|
17 |
geoInfo: DS.attr({ defaultValue: function() { return {}; } }), |
|
18 |
mediaArray: DS.attr({ defaultValue: function() { return []; } }), |
|
269
9659e91242e1
Add subjects to notice + Background color two notice type + Remove empty notice fields
Chloe Laisne <chloe.laisne@gmail.com>
parents:
253
diff
changeset
|
19 |
subjects: DS.attr({ defaultValue: function() { return []; } }), |
9659e91242e1
Add subjects to notice + Background color two notice type + Remove empty notice fields
Chloe Laisne <chloe.laisne@gmail.com>
parents:
253
diff
changeset
|
20 |
|
229
744379451219
add publisher and duration_ms to model
ymh <ymh.work@gmail.com>
parents:
220
diff
changeset
|
21 |
duration_ms: DS.attr('number', { |
414
5c6c526a7fc1
Display for single notice, preparation for share link
ymh <ymh.work@gmail.com>
parents:
327
diff
changeset
|
22 |
defaultValue: () => { |
229
744379451219
add publisher and duration_ms to model
ymh <ymh.work@gmail.com>
parents:
220
diff
changeset
|
23 |
var self = this; |
744379451219
add publisher and duration_ms to model
ymh <ymh.work@gmail.com>
parents:
220
diff
changeset
|
24 |
var duration = 0; |
744379451219
add publisher and duration_ms to model
ymh <ymh.work@gmail.com>
parents:
220
diff
changeset
|
25 |
Object.keys(this.get('mediaArray')).forEach(function(key) { |
744379451219
add publisher and duration_ms to model
ymh <ymh.work@gmail.com>
parents:
220
diff
changeset
|
26 |
if (!duration && self.get('mediaArray')[key].extent_ms) { |
744379451219
add publisher and duration_ms to model
ymh <ymh.work@gmail.com>
parents:
220
diff
changeset
|
27 |
duration = self.get('mediaArray')[key].extent_ms; |
744379451219
add publisher and duration_ms to model
ymh <ymh.work@gmail.com>
parents:
220
diff
changeset
|
28 |
} |
744379451219
add publisher and duration_ms to model
ymh <ymh.work@gmail.com>
parents:
220
diff
changeset
|
29 |
}); |
744379451219
add publisher and duration_ms to model
ymh <ymh.work@gmail.com>
parents:
220
diff
changeset
|
30 |
return duration; |
744379451219
add publisher and duration_ms to model
ymh <ymh.work@gmail.com>
parents:
220
diff
changeset
|
31 |
} |
744379451219
add publisher and duration_ms to model
ymh <ymh.work@gmail.com>
parents:
220
diff
changeset
|
32 |
}), |
91 | 33 |
|
242 | 34 |
media: Ember.computed('mediaArray', function() { |
35 |
var array = []; |
|
36 |
_.forEach(this.get('mediaArray'), function(media) { |
|
37 |
var index = array.findIndex(element => element.format === media.format); |
|
38 |
if(index > -1) { |
|
39 |
if (media.master) { |
|
40 |
array.splice(index, 1, media); |
|
41 |
} |
|
42 |
} else { |
|
43 |
array.push(media); |
|
209
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
126
diff
changeset
|
44 |
} |
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
126
diff
changeset
|
45 |
}); |
242 | 46 |
return array; |
47 |
}), |
|
48 |
||
49 |
video: Ember.computed('media', function() { |
|
50 |
return this.get('media').findIndex(element => element.format.match(new RegExp('^video/'))) > -1; |
|
217
989b9c36b849
Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
210
diff
changeset
|
51 |
}), |
989b9c36b849
Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
210
diff
changeset
|
52 |
|
229
744379451219
add publisher and duration_ms to model
ymh <ymh.work@gmail.com>
parents:
220
diff
changeset
|
53 |
duration: Ember.computed('duration_ms', function() { |
744379451219
add publisher and duration_ms to model
ymh <ymh.work@gmail.com>
parents:
220
diff
changeset
|
54 |
return this.get('duration_ms')/1000; |
744379451219
add publisher and duration_ms to model
ymh <ymh.work@gmail.com>
parents:
220
diff
changeset
|
55 |
}), |
744379451219
add publisher and duration_ms to model
ymh <ymh.work@gmail.com>
parents:
220
diff
changeset
|
56 |
|
744379451219
add publisher and duration_ms to model
ymh <ymh.work@gmail.com>
parents:
220
diff
changeset
|
57 |
publishers_disp: Ember.computed('publisher', 'publishers', function() { |
744379451219
add publisher and duration_ms to model
ymh <ymh.work@gmail.com>
parents:
220
diff
changeset
|
58 |
return this.get('publisher')?this.get('publisher'):this.get('publishers').join(', '); |
209
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
126
diff
changeset
|
59 |
}) |
126
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
125
diff
changeset
|
60 |
|
91 | 61 |
}); |