summaryrefslogtreecommitdiffstats
path: root/toolkit/components/satchel/megalist/aggregator/datasources/DataSourceBase.sys.mjs
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/components/satchel/megalist/aggregator/datasources/DataSourceBase.sys.mjs')
-rw-r--r--toolkit/components/satchel/megalist/aggregator/datasources/DataSourceBase.sys.mjs41
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;