author | Chloe Laisne <chloe.laisne@gmail.com> |
Thu, 25 Aug 2016 19:10:41 +0200 | |
changeset 270 | 6ddc52965fb8 |
parent 269 | 9659e91242e1 |
child 289 | 7cae80e5748c |
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'), |
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
126
diff
changeset
|
10 |
language: DS.attr('string'), |
242 | 11 |
publisher: 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
|
12 |
transcript: DS.attr({ defaultValue: function() { return {}; } }), |
242 | 13 |
|
14 |
publishers: DS.attr({ defaultValue: function() { return []; } }), |
|
15 |
contributors: DS.attr({ defaultValue: function() { return []; } }), |
|
16 |
geoInfo: DS.attr({ defaultValue: function() { return {}; } }), |
|
17 |
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
|
18 |
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
|
19 |
|
229
744379451219
add publisher and duration_ms to model
ymh <ymh.work@gmail.com>
parents:
220
diff
changeset
|
20 |
duration_ms: DS.attr('number', { |
744379451219
add publisher and duration_ms to model
ymh <ymh.work@gmail.com>
parents:
220
diff
changeset
|
21 |
defaultValue: function() { |
744379451219
add publisher and duration_ms to model
ymh <ymh.work@gmail.com>
parents:
220
diff
changeset
|
22 |
var self = this; |
744379451219
add publisher and duration_ms to model
ymh <ymh.work@gmail.com>
parents:
220
diff
changeset
|
23 |
var duration = 0; |
744379451219
add publisher and duration_ms to model
ymh <ymh.work@gmail.com>
parents:
220
diff
changeset
|
24 |
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
|
25 |
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
|
26 |
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 |
} |
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 |
return duration; |
744379451219
add publisher and duration_ms to model
ymh <ymh.work@gmail.com>
parents:
220
diff
changeset
|
30 |
} |
744379451219
add publisher and duration_ms to model
ymh <ymh.work@gmail.com>
parents:
220
diff
changeset
|
31 |
}), |
91 | 32 |
|
242 | 33 |
media: Ember.computed('mediaArray', function() { |
34 |
var array = []; |
|
35 |
_.forEach(this.get('mediaArray'), function(media) { |
|
36 |
var index = array.findIndex(element => element.format === media.format); |
|
37 |
if(index > -1) { |
|
38 |
if (media.master) { |
|
39 |
array.splice(index, 1, media); |
|
40 |
} |
|
41 |
} else { |
|
42 |
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
|
43 |
} |
35cb7200bb0a
Separate playlist and player component with player service as bridge
Chloe Laisne <chloe.laisne@gmail.com>
parents:
126
diff
changeset
|
44 |
}); |
242 | 45 |
return array; |
46 |
}), |
|
47 |
||
48 |
video: Ember.computed('media', function() { |
|
49 |
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
|
50 |
}), |
989b9c36b849
Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
210
diff
changeset
|
51 |
|
229
744379451219
add publisher and duration_ms to model
ymh <ymh.work@gmail.com>
parents:
220
diff
changeset
|
52 |
duration: Ember.computed('duration_ms', function() { |
744379451219
add publisher and duration_ms to model
ymh <ymh.work@gmail.com>
parents:
220
diff
changeset
|
53 |
return this.get('duration_ms')/1000; |
744379451219
add publisher and duration_ms to model
ymh <ymh.work@gmail.com>
parents:
220
diff
changeset
|
54 |
}), |
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 |
publishers_disp: Ember.computed('publisher', 'publishers', function() { |
744379451219
add publisher and duration_ms to model
ymh <ymh.work@gmail.com>
parents:
220
diff
changeset
|
57 |
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
|
58 |
}) |
126
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
125
diff
changeset
|
59 |
|
91 | 60 |
}); |