author | ymh <ymh.work@gmail.com> |
Thu, 16 Feb 2017 16:10:07 +0100 | |
changeset 513 | dad9471f0d63 |
parent 502 | 74fba571487e |
child 519 | ef3e4841d506 |
permissions | -rw-r--r-- |
217
989b9c36b849
Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
1 |
import Ember from 'ember'; |
989b9c36b849
Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
2 |
|
989b9c36b849
Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
3 |
export default Ember.Component.extend({ |
989b9c36b849
Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
4 |
|
989b9c36b849
Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
5 |
player: Ember.inject.service(), |
338
4a3899b6a7ed
Fix notice/transcript display when adding filter from notice, switching from playlist, toolbar, and player
Chloe Laisne <chloe.laisne@gmail.com>
parents:
335
diff
changeset
|
6 |
filter: Ember.inject.service(), |
502
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
447
diff
changeset
|
7 |
constants: Ember.inject.service(), |
217
989b9c36b849
Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
8 |
|
989b9c36b849
Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
9 |
classNames: ['notice-component'], |
989b9c36b849
Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
10 |
|
228
a2497a2b6224
Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents:
217
diff
changeset
|
11 |
item: Ember.computed('model', 'player.model', function() { |
a2497a2b6224
Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents:
217
diff
changeset
|
12 |
return this.get('model') || this.get('player').get('model'); |
217
989b9c36b849
Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
13 |
}), |
989b9c36b849
Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
14 |
|
228
a2497a2b6224
Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents:
217
diff
changeset
|
15 |
participants: Ember.computed('item.contributors', function() { |
447
38d5789e30d0
Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents:
446
diff
changeset
|
16 |
let participants = []; |
38d5789e30d0
Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents:
446
diff
changeset
|
17 |
const contributors = this.get('item.contributors') || []; |
38d5789e30d0
Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents:
446
diff
changeset
|
18 |
let identifier; |
38d5789e30d0
Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents:
446
diff
changeset
|
19 |
contributors.forEach(function(contributor) { |
38d5789e30d0
Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents:
446
diff
changeset
|
20 |
identifier = contributor.name || contributor.url; |
38d5789e30d0
Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents:
446
diff
changeset
|
21 |
var participant = participants.find(participant => participant.identifier === identifier); |
38d5789e30d0
Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents:
446
diff
changeset
|
22 |
if(participant) { |
38d5789e30d0
Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents:
446
diff
changeset
|
23 |
participant['role'].push(contributor.role.split('/').pop()); |
38d5789e30d0
Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents:
446
diff
changeset
|
24 |
} else { |
38d5789e30d0
Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents:
446
diff
changeset
|
25 |
participants.push({ identifier: identifier, role: [ contributor.role.split('/').pop() ] }); |
38d5789e30d0
Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents:
446
diff
changeset
|
26 |
} |
38d5789e30d0
Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents:
446
diff
changeset
|
27 |
}); |
217
989b9c36b849
Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
28 |
return participants; |
989b9c36b849
Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
29 |
}), |
989b9c36b849
Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
30 |
|
228
a2497a2b6224
Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents:
217
diff
changeset
|
31 |
location: Ember.computed('item.geoInfo', function() { |
217
989b9c36b849
Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
32 |
var location = ''; |
228
a2497a2b6224
Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents:
217
diff
changeset
|
33 |
if(this.get('item')) { |
a2497a2b6224
Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents:
217
diff
changeset
|
34 |
var meta = this.get('item').get('geoInfo').notes.find(element => element.lang); |
217
989b9c36b849
Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
35 |
if(meta) { |
989b9c36b849
Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
36 |
location = meta.value; |
989b9c36b849
Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
37 |
} |
989b9c36b849
Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
38 |
} |
989b9c36b849
Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
39 |
return location; |
338
4a3899b6a7ed
Fix notice/transcript display when adding filter from notice, switching from playlist, toolbar, and player
Chloe Laisne <chloe.laisne@gmail.com>
parents:
335
diff
changeset
|
40 |
}), |
4a3899b6a7ed
Fix notice/transcript display when adding filter from notice, switching from playlist, toolbar, and player
Chloe Laisne <chloe.laisne@gmail.com>
parents:
335
diff
changeset
|
41 |
|
502
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
447
diff
changeset
|
42 |
noticeCocoonPurlUrl: Ember.computed('item', function() { |
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
447
diff
changeset
|
43 |
const item = this.get('item'); |
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
447
diff
changeset
|
44 |
return this.get('constants').COCOON_PURL_BASE_URL + item.get('cocoonId'); |
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
447
diff
changeset
|
45 |
}), |
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
447
diff
changeset
|
46 |
|
338
4a3899b6a7ed
Fix notice/transcript display when adding filter from notice, switching from playlist, toolbar, and player
Chloe Laisne <chloe.laisne@gmail.com>
parents:
335
diff
changeset
|
47 |
actions: { |
4a3899b6a7ed
Fix notice/transcript display when adding filter from notice, switching from playlist, toolbar, and player
Chloe Laisne <chloe.laisne@gmail.com>
parents:
335
diff
changeset
|
48 |
|
4a3899b6a7ed
Fix notice/transcript display when adding filter from notice, switching from playlist, toolbar, and player
Chloe Laisne <chloe.laisne@gmail.com>
parents:
335
diff
changeset
|
49 |
addThemeFilter: function(id) { |
446
2a93eb9f38f5
pb m3.22 - set correct filter when clicking on subject and language in notice
ymh <ymh.work@gmail.com>
parents:
338
diff
changeset
|
50 |
this.get('filter').setFilter('theme', id); |
338
4a3899b6a7ed
Fix notice/transcript display when adding filter from notice, switching from playlist, toolbar, and player
Chloe Laisne <chloe.laisne@gmail.com>
parents:
335
diff
changeset
|
51 |
}, |
4a3899b6a7ed
Fix notice/transcript display when adding filter from notice, switching from playlist, toolbar, and player
Chloe Laisne <chloe.laisne@gmail.com>
parents:
335
diff
changeset
|
52 |
|
4a3899b6a7ed
Fix notice/transcript display when adding filter from notice, switching from playlist, toolbar, and player
Chloe Laisne <chloe.laisne@gmail.com>
parents:
335
diff
changeset
|
53 |
addLanguageFilter: function(id) { |
446
2a93eb9f38f5
pb m3.22 - set correct filter when clicking on subject and language in notice
ymh <ymh.work@gmail.com>
parents:
338
diff
changeset
|
54 |
this.get('filter').setFilter('language', id); |
502
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
447
diff
changeset
|
55 |
}, |
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
447
diff
changeset
|
56 |
|
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
447
diff
changeset
|
57 |
addTypeFilter: function(id) { |
74fba571487e
Complete the notice display. add various fields to document to correctly display the notice. Correct bug #0025746
ymh <ymh.work@gmail.com>
parents:
447
diff
changeset
|
58 |
this.get('filter').setFilter('theme', id); |
513
dad9471f0d63
add filter on created date in notice
ymh <ymh.work@gmail.com>
parents:
502
diff
changeset
|
59 |
}, |
dad9471f0d63
add filter on created date in notice
ymh <ymh.work@gmail.com>
parents:
502
diff
changeset
|
60 |
|
dad9471f0d63
add filter on created date in notice
ymh <ymh.work@gmail.com>
parents:
502
diff
changeset
|
61 |
addCreatedFilter: function(dateStr) { |
dad9471f0d63
add filter on created date in notice
ymh <ymh.work@gmail.com>
parents:
502
diff
changeset
|
62 |
const date = new Date(dateStr); |
dad9471f0d63
add filter on created date in notice
ymh <ymh.work@gmail.com>
parents:
502
diff
changeset
|
63 |
this.get('filter').setFilter('date', date.getFullYear().toString()); |
338
4a3899b6a7ed
Fix notice/transcript display when adding filter from notice, switching from playlist, toolbar, and player
Chloe Laisne <chloe.laisne@gmail.com>
parents:
335
diff
changeset
|
64 |
} |
4a3899b6a7ed
Fix notice/transcript display when adding filter from notice, switching from playlist, toolbar, and player
Chloe Laisne <chloe.laisne@gmail.com>
parents:
335
diff
changeset
|
65 |
} |
217
989b9c36b849
Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
66 |
|
989b9c36b849
Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff
changeset
|
67 |
}); |