constructor()

in public/src/js/models/collections/collection.js [22:111]


    constructor(opts = {}) {
        super();
        if (!opts.id) { return; }

        this.id = opts.id;

        this.front = opts.front;
        this.raw = undefined;

        this.groups = this.createGroups(opts.groups);

        this.alsoOn = opts.alsoOn || [];
        this.alsoOnDedupedPriorities = _.uniq(this.alsoOn.map(front => front.priority));
        this.alsoOnHasDifferentPriority = this.alsoOn.some(front => front.isDifferentPriority);
        this.alsoOnMeritsWarning = this.alsoOnHasDifferentPriority
            && this.alsoOn.some(front => front.priority === 'commercial');

        this.isDynamic = opts.type.indexOf('dynamic/') === 0;
        this.isFlexible = opts.type === ('flexible/general') || opts.type === ('flexible/special');

        this.dom = undefined;
        var onDomLoadResolve;
        var onDomLoad = new Promise(resolve => {
            onDomLoadResolve = resolve;
        });
        this.registerElement = element => {
            this.dom = element;
            onDomLoadResolve();
        };

        this.visibleStories = null;

        // properties from the config, about this collection
        this.configMeta = asObservableProps([
            'type',
            'displayName',
            'hideShowMore',
            'href',
            'uneditable',
            'metadata',
            'platform',
            'frontsToolSettings'
        ]);
        populateObservables(this.configMeta, opts);

        // properties from the collection itself
        this.collectionMeta = asObservableProps([
            'displayName',
            'href',
            'lastUpdated',
            'updatedBy',
            'updatedEmail']);

        this.state = asObservableProps([
            'lastUpdated',
            'hasConcurrentEdits',
            'collapsed',
            'hasDraft',
            'pending',
            'editingConfig',
            'count',
            'timeAgo',
            'alsoOnVisible',
            'showIndicators',
            'hasExtraActions',
            'isHistoryOpen',
            'visibleCount']);

        this.itemDefaults = _.reduce({
            showTags: 'showKickerTag',
            showSections: 'showKickerSection'
        }, (defaults = {}, val, key) => {
            if (_.has(opts, key)) {
                defaults[val] = opts[key];
            }
            return defaults;
        }, undefined);

        this.history = ko.observableArray();
        this.state.isHistoryOpen(false);

        this.setPending(true);
        this.loaded = this.load().then(() => onDomLoad);
        this.state.visibleCount({});

        this.lastAlertSentHuman = ko.observable(this.getLastAlertHuman());

        this.displayEditWarning = this.configMeta.frontsToolSettings() && this.configMeta.frontsToolSettings().displayEditWarning;

    }