Source: widget/tourlist/TileControl.js

(function() {
    /**
     * @typedef {Help4.control2.Tile.Params} Help4.widget.tourlist.TileControl.Params
     * @property {boolean} [extended = false] - whether this tour is extended
     * @property {boolean} [hidden = false] - whether this tour is hidden
     * @property {?string} [status = null] - tour published status
     */

    /**
     * Control that creates a tourlist tile.
     * @augments Help4.control2.Tile
     * @property {boolean} extended - whether this tour is extended
     * @property {boolean} hidden - whether this tour is hidden
     * @property {?string} status - tour published status
     */
    Help4.widget.tourlist.TileControl = class extends Help4.control2.Tile {
        /**
         * @override
         * @param {Help4.widget.tourlist.TileControl.Params} [params]
         */
        constructor(params) {
            const T = Help4.jscore.ControlBase.TYPES;
            super(params, {
                params: {
                    extended: {type: T.boolean},
                    hidden:   {type: T.boolean},
                    status:   {type: T.string_null}
                },
                config: {
                    css: 'tour-project'
                }
            });
        }

        /**
        * @override
        * @returns {Object|null}
        */
        getControlTexts() {
            const {status} = this;
            const tileTexts = super.getControlTexts();

            if (status && tileTexts?.title) {
                // XRAY-6356: if status is set (see _setTitle) the title will be a combination of the caption and a static string from us
                // therefore the language of the title is mostly system language and not content language
                // <caption - contentLanguage>: <status_text - systemLanguage>
                const {uacp} = Help4.getShell().getLanguage() || {};
                tileTexts.title.language = uacp;
            }

            return tileTexts;
        }

        /**
         * @override
         * @param {Help4.jscore.ControlBase.PropertyChangeEvent} event - the change event
         */
        _applyPropertyToDom({name, value, oldValue}) {
            switch (name) {
                case 'extended':
                    value ? this.addCss(name) : this.removeCss(name);
                    break;
                case 'hidden':
                    const css = 'hiddenedit';
                    value ? this.addCss(css) : this.removeCss(css);
                    break;
                case 'status':
                    Help4.Element.setAttribute(this.getDom(), {'data-state': value || undefined});
                    _setTitle.call(this);
                    break;
                case 'caption':
                    _setTitle.call(this);
                    super._applyPropertyToDom({name, value, oldValue});
                    break;
                default:
                    super._applyPropertyToDom({name, value, oldValue});
                    break;
            }
        }
    }

    /**
     * @memberof Help4.widget.tourlist.TileControl#
     * @private
     */
    function _setTitle() {
        const {caption, status} = this;
        const title = status ? Help4.Localization.getText(`tooltip.tourstatus.${status}`) : '';
        this.title = title ? `${caption}: ${title}` : caption;
    }
})();