constructor()

in public/src/js/models/collections/collection.js [18:78]


    constructor(opts = {}) {
        super();

        if (!opts.id) { return; }

        this.id = opts.id;

        this.front = opts.front;

        this.raw = undefined;

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

        var onDomLoadResolve;
        var onDomLoad = new Promise(function (resolve) {
            onDomLoadResolve = resolve;
        });
        this.registerElement = function () {
            onDomLoadResolve();
        };

        // properties from the config, about this collection
        this.configMeta = asObservableProps(['displayName']);
        populateObservables(this.configMeta, opts);

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

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

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

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

        this.setPending(true);
        this.loaded = this.load().then(() => onDomLoad);
        sparklines.subscribe(this);
    }