all files / common/models/customization/ customization.js

100% Statements 41/41
100% Branches 18/18
100% Functions 11/11
100% Lines 39/39
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 55 56 57 58 59 60 61 62  19× 19× 19× 13×   30×   16×       16× 16× 16× 18× 11×   16×             18× 18× 12× 18× 18× 18×   18×       24×            
"use strict";
var immutable_class_1 = require('immutable-class');
var external_view_1 = require('../external-view/external-view');
var check;
var Customization = (function () {
    function Customization(parameters) {
        this.headerBackground = parameters.headerBackground || null;
        this.customLogoSvg = parameters.customLogoSvg || null;
        if (parameters.externalViews)
            this.externalViews = parameters.externalViews;
    }
    Customization.isCustomization = function (candidate) {
        return immutable_class_1.isInstanceOf(candidate, Customization);
    };
    Customization.fromJS = function (parameters) {
        var value = {
            headerBackground: parameters.headerBackground,
            customLogoSvg: parameters.customLogoSvg
        };
        var paramViewsJS = parameters.externalViews;
        var externalViews = null;
        if (Array.isArray(paramViewsJS)) {
            externalViews = paramViewsJS.map(function (view, i) { return external_view_1.ExternalView.fromJS(view); });
            value.externalViews = externalViews;
        }
        return new Customization(value);
    };
    Customization.prototype.valueOf = function () {
        return {
            headerBackground: this.headerBackground,
            customLogoSvg: this.customLogoSvg,
            externalViews: this.externalViews
        };
    };
    Customization.prototype.toJS = function () {
        var js = {};
        if (this.headerBackground)
            js.headerBackground = this.headerBackground;
        if (this.customLogoSvg)
            js.customLogoSvg = this.customLogoSvg;
        if (this.externalViews) {
            js.externalViews = this.externalViews.map(function (view) { return view.toJS(); });
        }
        return js;
    };
    Customization.prototype.toJSON = function () {
        return this.toJS();
    };
    Customization.prototype.toString = function () {
        return "[custom: headerBackground: " + this.headerBackground + ", logo: " + Boolean(this.customLogoSvg) + ",\n    externalViews: " + Boolean(this.externalViews) + "]";
    };
    Customization.prototype.equals = function (other) {
        return Customization.isCustomization(other) &&
            this.headerBackground === other.headerBackground &&
            this.customLogoSvg === other.customLogoSvg &&
            immutable_class_1.immutableArraysEqual(this.externalViews, other.externalViews);
    };
    return Customization;
}());
exports.Customization = Customization;
check = Customization;