From a90a5cba08fdf6c0ceb95101c275108a152a3aed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:35:37 +0200 Subject: Merging upstream version 127.0. Signed-off-by: Daniel Baumann --- .../aggregator/datasources/DataSourceBase.sys.mjs | 41 ++++++++++++++++++---- 1 file changed, 35 insertions(+), 6 deletions(-) (limited to 'toolkit/components/satchel/megalist/aggregator/datasources/DataSourceBase.sys.mjs') diff --git a/toolkit/components/satchel/megalist/aggregator/datasources/DataSourceBase.sys.mjs b/toolkit/components/satchel/megalist/aggregator/datasources/DataSourceBase.sys.mjs index 49be733aef..ee7dfed5eb 100644 --- a/toolkit/components/satchel/megalist/aggregator/datasources/DataSourceBase.sys.mjs +++ b/toolkit/components/satchel/megalist/aggregator/datasources/DataSourceBase.sys.mjs @@ -63,7 +63,30 @@ export class DataSourceBase { this.#aggregatorApi.refreshAllLinesOnScreen(); } + setLayout(layout) { + this.#aggregatorApi.setLayout(layout); + } + formatMessages = createFormatMessages("preview/megalist.ftl"); + static ftl = new Localization(["preview/megalist.ftl"]); + + async localizeStrings(strings) { + const keys = Object.keys(strings); + const localisationIds = Object.values(strings).map(id => ({ id })); + const messages = await DataSourceBase.ftl.formatMessages(localisationIds); + + for (let i = 0; i < messages.length; i++) { + let { attributes, value } = messages[i]; + if (attributes) { + value = attributes.reduce( + (result, { name, value }) => ({ ...result, [name]: value }), + {} + ); + } + strings[keys[i]] = value; + } + return strings; + } /** * Prototype for the each line. @@ -94,6 +117,10 @@ export class DataSourceBase { return true; }, + isEditing() { + return this.editingValue !== undefined; + }, + copyToClipboard(text) { lazy.ClipboardHelper.copyString(text, lazy.ClipboardHelper.Sensitive); }, @@ -135,6 +162,9 @@ export class DataSourceBase { refreshOnScreen() { this.source.refreshSingleLineOnScreen(this); }, + setLayout(data) { + this.source.setLayout(data); + }, }; /** @@ -144,7 +174,6 @@ export class DataSourceBase { * @returns {object} section header line */ createHeaderLine(label) { - const toggleCommand = { id: "Toggle", label: "" }; const result = { label, value: "", @@ -164,7 +193,7 @@ export class DataSourceBase { lineIsReady: () => true, - commands: [toggleCommand], + commands: [{ id: "Toggle", label: "command-toggle" }], executeToggle() { this.collapsed = !this.collapsed; @@ -172,10 +201,6 @@ export class DataSourceBase { }, }; - this.formatMessages("command-toggle").then(([toggleLabel]) => { - toggleCommand.label = toggleLabel; - }); - return result; } @@ -244,6 +269,10 @@ export class DataSourceBase { return this.lines[index]; } + cancelDialog() { + this.setLayout(null); + } + *enumerateLinesForMatchingRecords(searchText, stats, match) { stats.total = 0; stats.count = 0; -- cgit v1.2.3