constructor()

in public/src/js/models/config/collection.js [17:106]


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

        this.id = opts.id;

        const defaults = vars.model.state().defaults;

        this.parents = ko.observableArray(findParents(opts.id));
        this.userVisibilities = CONST.userVisibilities;
        this.availableTerritories = (defaults && defaults.availableTerritories) ? defaults.availableTerritories : [];

        this.meta = Object.assign(
            asObservableProps([
                'displayName',
                'href',
                'groups',
                'type',
                'uneditable',
                'showTags',
                'showSections',
                'hideKickers',
                'showDateHeader',
                'showLatestUpdate',
                'showTimestamps',
                'excludeFromRss',
                'hideShowMore',
                'backfill',
                'description',
                'metadata',
                'platform',
                'frontsToolSettings',
                'userVisibility',
                'targetedTerritory'
            ]),
            {
                displayHints: asObservableProps([
                    'maxItemsToDisplay',
                    'suppressImages'
                ], observableNumeric)
            },
            {
                frontsToolSettings: asObservableProps([
                    'displayEditWarning'
                ])
            },
      {
          groupsConfig: ko.observableArray(
            opts.groupsConfig !== undefined && Array.isArray(opts.groupsConfig) ?
              opts.groupsConfig.map((groupConfig) => {
                return {
                  name: groupConfig.name,
                  maxItems: observableNumeric(groupConfig.maxItems)
                };
              }) : []
            )}
        );

        populateObservables(this.meta, opts);

        this.state = asObservableProps([
            'isOpen',
            'isOpenTypePicker',
            'underDrag',
            'underControlDrag'
        ]);

        this.containerThumbnail = ko.pureComputed(() => {
            var containerId = this.meta.type();

            if (/^(fixed|dynamic|flexible|scrollable|static)\//.test(containerId)) {
                return '/thumbnails/' + containerId + '.svg';
            } else {
                return null;
            }
        });

        this.subscribeOn(this.meta.type, type => {
            this.meta.groups(vars.model.typesGroups[type]);
            const groupsConfig = vars.model.typesGroupsConfig[type];
            this.meta.groupsConfig(groupsConfig !== undefined ? groupsConfig() : undefined);
        });

        this.typePicker = this._typePicker.bind(this);

        this.thisIsPlatformSpecificCollection = isPlatformSpecificCollection(this.meta.platform());

        this.thisIsBetaCollection = ko.pureComputed(() => {
            return isBetaCollection(this.meta.type());
        });
    }