cms/app-client/app/components/notice-component.js
author ymh <ymh.work@gmail.com>
Fri, 09 Dec 2016 11:41:15 +0100
changeset 467 762fc0eb4946
parent 447 38d5789e30d0
child 502 74fba571487e
permissions -rw-r--r--
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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(),
217
989b9c36b849 Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     7
989b9c36b849 Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     8
    classNames: ['notice-component'],
989b9c36b849 Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
     9
228
a2497a2b6224 Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents: 217
diff changeset
    10
    item: Ember.computed('model', 'player.model', function() {
a2497a2b6224 Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents: 217
diff changeset
    11
        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
    12
    }),
989b9c36b849 Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    13
228
a2497a2b6224 Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents: 217
diff changeset
    14
    participants: Ember.computed('item.contributors', function() {
447
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents: 446
diff changeset
    15
        let participants = [];
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents: 446
diff changeset
    16
        const contributors = this.get('item.contributors') || [];
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents: 446
diff changeset
    17
        let identifier;
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents: 446
diff changeset
    18
        contributors.forEach(function(contributor) {
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents: 446
diff changeset
    19
          identifier = contributor.name || contributor.url;
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents: 446
diff changeset
    20
          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
    21
          if(participant) {
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents: 446
diff changeset
    22
              participant['role'].push(contributor.role.split('/').pop());
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents: 446
diff changeset
    23
          } else {
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents: 446
diff changeset
    24
              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
    25
          }
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents: 446
diff changeset
    26
        });
217
989b9c36b849 Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    27
        return participants;
989b9c36b849 Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    28
    }),
989b9c36b849 Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    29
228
a2497a2b6224 Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents: 217
diff changeset
    30
    location: Ember.computed('item.geoInfo', function() {
217
989b9c36b849 Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    31
        var location = '';
228
a2497a2b6224 Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents: 217
diff changeset
    32
        if(this.get('item')) {
a2497a2b6224 Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents: 217
diff changeset
    33
            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
    34
            if(meta) {
989b9c36b849 Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    35
                location = meta.value;
989b9c36b849 Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    36
            }
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
        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
    39
    }),
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
    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
    42
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
    43
        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
    44
            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
    45
        },
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
    46
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
        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
    48
            this.get('filter').setFilter('language', 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
    49
        }
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
    50
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
    }
217
989b9c36b849 Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    52
989b9c36b849 Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    53
});