all files / common/models/link-view-config/ link-view-config.js

90.91% Statements 30/33
100% Branches 3/3
78.57% Functions 11/14
93.75% Lines 30/32
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54    11×                                            
"use strict";
var immutable_1 = require('immutable');
var immutable_class_1 = require('immutable-class');
var general_1 = require('../../utils/general/general');
var link_item_1 = require('../link-item/link-item');
var check;
var LinkViewConfig = (function () {
    function LinkViewConfig(parameters) {
        this.title = parameters.title;
        this.linkItems = parameters.linkItems;
    }
    LinkViewConfig.isLinkViewConfig = function (candidate) {
        return immutable_class_1.isInstanceOf(candidate, LinkViewConfig);
    };
    LinkViewConfig.fromJS = function (parameters, context) {
        return new LinkViewConfig({
            title: parameters.title,
            linkItems: immutable_1.List(parameters.linkItems.map(function (linkItem) { return link_item_1.LinkItem.fromJS(linkItem, context); }))
        });
    };
    LinkViewConfig.prototype.valueOf = function () {
        return {
            title: this.title,
            linkItems: this.linkItems
        };
    };
    LinkViewConfig.prototype.toJS = function () {
        return {
            title: this.title,
            linkItems: this.linkItems.toArray().map(function (linkItem) { return linkItem.toJS(); })
        };
    };
    LinkViewConfig.prototype.toJSON = function () {
        return this.toJS();
    };
    LinkViewConfig.prototype.toString = function () {
        return "[LinkViewConfig: " + this.title + "]";
    };
    LinkViewConfig.prototype.equals = function (other) {
        return LinkViewConfig.isLinkViewConfig(other) &&
            this.title === other.title &&
            general_1.immutableListsEqual(this.linkItems, other.linkItems);
    };
    LinkViewConfig.prototype.defaultLinkItem = function () {
        return this.linkItems.first();
    };
    LinkViewConfig.prototype.findByName = function (name) {
        return this.linkItems.find(function (li) { return li.name === name; });
    };
    return LinkViewConfig;
}());
exports.LinkViewConfig = LinkViewConfig;
check = LinkViewConfig;