diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
commit | 59203c63bb777a3bacec32fb8830fba33540e809 (patch) | |
tree | 58298e711c0ff0575818c30485b44a2f21bf28a0 /toolkit/components/satchel/megalist/aggregator/datasources/DataSourceBase.sys.mjs | |
parent | Adding upstream version 126.0.1. (diff) | |
download | firefox-59203c63bb777a3bacec32fb8830fba33540e809.tar.xz firefox-59203c63bb777a3bacec32fb8830fba33540e809.zip |
Adding upstream version 127.0.upstream/127.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/satchel/megalist/aggregator/datasources/DataSourceBase.sys.mjs')
-rw-r--r-- | toolkit/components/satchel/megalist/aggregator/datasources/DataSourceBase.sys.mjs | 41 |
1 files changed, 35 insertions, 6 deletions
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; |