(function() {
/** @returns {?string} */
const getScreenId = () => Help4.getShell()?.getScreenId();
/**
* this backend connector is able to handle Quick Tour content
* @augments Help4.widget.help.project._Special
*/
Help4.widget.help.project.QuickTour = class extends Help4.widget.help.project._Special {
static NAME = 'QuickTour';
static data = /** @type {Object} */ {};
static lastUpdate = 0;
/**
* @param {Help4.widget.help.ProjectTile[]} output
* @param {string} catalogueKey
*/
static getTiles(output, catalogueKey) {
const data = this.getData();
data && output.push(/** @type {Help4.widget.help.ProjectTile} */ {...data, _catalogueKey: catalogueKey});
}
/**
* clears all data, not just for current screen
* @returns {Promise<void>}
*/
static async clearData() {
if (!this.hasData()) return;
this.data = {};
this.lastUpdate = Date.now();
await super._refreshWidget();
}
/**
* @param {string} url
* @param {Help4.control2.SizeWH} size
* @returns {Promise<void>}
*/
static async setData(url, size) {
const screenId = getScreenId();
if (!screenId) return; // better to show no Quick Tour than to show it on an unknown screen
const {Localization} = Help4;
const {[this.NAME]: catalogue} = Help4.widget.help.catalogues;
const {ID, CATALOGUE_TYPE} = catalogue;
this.data[screenId] = /** @type {Help4.widget.help.ProjectTile} */ {
id: ID,
linkTo: url,
linkLightbox: true,
lightboxSize: {width: size.w, height: size.h},
lightboxSizing: 'explicit',
fullCover: true,
type: 'link',
showAsButton: true,
showDetach: false,
title: Localization.getText('label.quicktour.title'),
_dataType: catalogue.getDataType(),
_catalogueType: CATALOGUE_TYPE,
_projectId: ID
};
this.lastUpdate = Date.now();
await super._refreshWidget();
}
/** @throws {Error} */
static addData() {
throw new Error('addData not supported for Help4.widget.help.project.QuickTour');
}
/** @returns {?Help4.widget.help.ProjectTile} */
static getData() {
return this.data[getScreenId()] || null;
}
/** @returns {boolean} */
static hasData() {
return !!this.getData();
}
}
})();