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

import Ember from 'ember';

export default Ember.Component.extend({

    player: Ember.inject.service(),
    filter: Ember.inject.service(),

    classNames: ['notice-component'],

    item: Ember.computed('model', 'player.model', function() {
        return this.get('model') || this.get('player').get('model');
    }),

    participants: Ember.computed('item.contributors', function() {
        let participants = [];
        const contributors = this.get('item.contributors') || [];
        let identifier;
        contributors.forEach(function(contributor) {
          identifier = contributor.name || contributor.url;
          var participant = participants.find(participant => participant.identifier === identifier);
          if(participant) {
              participant['role'].push(contributor.role.split('/').pop());
          } else {
              participants.push({ identifier: identifier, role: [ contributor.role.split('/').pop() ] });
          }
        });
        return participants;
    }),

    location: Ember.computed('item.geoInfo', function() {
        var location = '';
        if(this.get('item')) {
            var meta = this.get('item').get('geoInfo').notes.find(element => element.lang);
            if(meta) {
                location = meta.value;
            }
        }
        return location;
    }),

    actions: {

        addThemeFilter: function(id) {
            this.get('filter').setFilter('theme', id);
        },

        addLanguageFilter: function(id) {
            this.get('filter').setFilter('language', id);
        }

    }

});