cms/app-client/app/components/notice-component.js
author Chloe Laisne <chloe.laisne@gmail.com>
Sun, 16 Oct 2016 22:23:31 +0530
changeset 338 4a3899b6a7ed
parent 335 9247384cb264
child 446 2a93eb9f38f5
permissions -rw-r--r--
Fix notice/transcript display when adding filter from notice, switching from playlist, toolbar, and player
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() {
217
989b9c36b849 Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    15
        var participants = [];
228
a2497a2b6224 Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents: 217
diff changeset
    16
        if(this.get('item')) {
a2497a2b6224 Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents: 217
diff changeset
    17
            this.get('item').get('contributors').forEach(function(contributor) {
217
989b9c36b849 Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    18
                if(contributor.name) {
270
6ddc52965fb8 Remove participants doubles
Chloe Laisne <chloe.laisne@gmail.com>
parents: 228
diff changeset
    19
                    var participant = participants.find(participant => participant.name === contributor.name);
6ddc52965fb8 Remove participants doubles
Chloe Laisne <chloe.laisne@gmail.com>
parents: 228
diff changeset
    20
                    if(participant) {
278
f2c2c80a49f7 Disable click on map areas w/o geoname + development/production disabled color + geostat endpoint
Chloe Laisne <chloe.laisne@gmail.com>
parents: 271
diff changeset
    21
                        participant['role'].push(contributor.role.split('/').pop());
270
6ddc52965fb8 Remove participants doubles
Chloe Laisne <chloe.laisne@gmail.com>
parents: 228
diff changeset
    22
                    } else {
6ddc52965fb8 Remove participants doubles
Chloe Laisne <chloe.laisne@gmail.com>
parents: 228
diff changeset
    23
                        participants.push({ name: contributor.name, role: [ contributor.role.split('/').pop() ] });
6ddc52965fb8 Remove participants doubles
Chloe Laisne <chloe.laisne@gmail.com>
parents: 228
diff changeset
    24
                    }    
217
989b9c36b849 Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    25
                }
989b9c36b849 Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    26
            });
989b9c36b849 Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    27
        }
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
270
6ddc52965fb8 Remove participants doubles
Chloe Laisne <chloe.laisne@gmail.com>
parents: 228
diff changeset
    31
    subjects: Ember.computed('item.subjects', function() {
6ddc52965fb8 Remove participants doubles
Chloe Laisne <chloe.laisne@gmail.com>
parents: 228
diff changeset
    32
        var subjects = [];
6ddc52965fb8 Remove participants doubles
Chloe Laisne <chloe.laisne@gmail.com>
parents: 228
diff changeset
    33
        if(this.get('item')) {
271
e234339fe8df Fix display notice error + Hide notice/transcript/video when changing route
Chloe Laisne <chloe.laisne@gmail.com>
parents: 270
diff changeset
    34
            this.get('item').get('subjects').forEach(function(subject) {
270
6ddc52965fb8 Remove participants doubles
Chloe Laisne <chloe.laisne@gmail.com>
parents: 228
diff changeset
    35
                var object = {};
6ddc52965fb8 Remove participants doubles
Chloe Laisne <chloe.laisne@gmail.com>
parents: 228
diff changeset
    36
                if(typeof subject === 'object') {
6ddc52965fb8 Remove participants doubles
Chloe Laisne <chloe.laisne@gmail.com>
parents: 228
diff changeset
    37
                    if(subject.datatype) {
6ddc52965fb8 Remove participants doubles
Chloe Laisne <chloe.laisne@gmail.com>
parents: 228
diff changeset
    38
                        object['url'] = subject.datatype;
6ddc52965fb8 Remove participants doubles
Chloe Laisne <chloe.laisne@gmail.com>
parents: 228
diff changeset
    39
                    }
6ddc52965fb8 Remove participants doubles
Chloe Laisne <chloe.laisne@gmail.com>
parents: 228
diff changeset
    40
                    if(subject.value) {
6ddc52965fb8 Remove participants doubles
Chloe Laisne <chloe.laisne@gmail.com>
parents: 228
diff changeset
    41
                        object['name'] = subject.value;
6ddc52965fb8 Remove participants doubles
Chloe Laisne <chloe.laisne@gmail.com>
parents: 228
diff changeset
    42
                    }
6ddc52965fb8 Remove participants doubles
Chloe Laisne <chloe.laisne@gmail.com>
parents: 228
diff changeset
    43
                } else {
6ddc52965fb8 Remove participants doubles
Chloe Laisne <chloe.laisne@gmail.com>
parents: 228
diff changeset
    44
                    object['url'] = subject;
6ddc52965fb8 Remove participants doubles
Chloe Laisne <chloe.laisne@gmail.com>
parents: 228
diff changeset
    45
                }
6ddc52965fb8 Remove participants doubles
Chloe Laisne <chloe.laisne@gmail.com>
parents: 228
diff changeset
    46
                subjects.push(object);
6ddc52965fb8 Remove participants doubles
Chloe Laisne <chloe.laisne@gmail.com>
parents: 228
diff changeset
    47
            });
6ddc52965fb8 Remove participants doubles
Chloe Laisne <chloe.laisne@gmail.com>
parents: 228
diff changeset
    48
        }
6ddc52965fb8 Remove participants doubles
Chloe Laisne <chloe.laisne@gmail.com>
parents: 228
diff changeset
    49
        return subjects;
6ddc52965fb8 Remove participants doubles
Chloe Laisne <chloe.laisne@gmail.com>
parents: 228
diff changeset
    50
    }),
6ddc52965fb8 Remove participants doubles
Chloe Laisne <chloe.laisne@gmail.com>
parents: 228
diff changeset
    51
228
a2497a2b6224 Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents: 217
diff changeset
    52
    location: Ember.computed('item.geoInfo', function() {
217
989b9c36b849 Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    53
        var location = '';
228
a2497a2b6224 Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents: 217
diff changeset
    54
        if(this.get('item')) {
a2497a2b6224 Notice display logic and design
Chloe Laisne <chloe.laisne@gmail.com>
parents: 217
diff changeset
    55
            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
    56
            if(meta) {
989b9c36b849 Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    57
                location = meta.value;
989b9c36b849 Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    58
            }
989b9c36b849 Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    59
        }
989b9c36b849 Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    60
        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
    61
    }),
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
    62
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
    63
    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
    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
        addThemeFilter: function(id) {
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
    66
            this.get('filter').set('theme', id);
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
    67
        },
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
    68
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
    69
        addLanguageFilter: function(id) {
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
    70
            this.get('filter').set('language', id);
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
    71
        }
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
    72
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
    73
    }
217
989b9c36b849 Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    74
989b9c36b849 Toolbar and Notice component styles
Chloe Laisne <chloe.laisne@gmail.com>
parents:
diff changeset
    75
});