Skip to content

Commit 6951df7

Browse files
committed
Use tree for keywords
Signed-off-by: worksofliam <mrliamallan@live.co.uk>
1 parent b94ea3f commit 6951df7

File tree

1 file changed

+32
-34
lines changed

1 file changed

+32
-34
lines changed

webui/main.js

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,42 +1022,40 @@ function createKeywordPanel(id, keywords, onUpdate) {
10221022
return cell;
10231023
};
10241024

1025-
const table = document.createElement(`vscode-table`);
1026-
table.id = id;
1027-
1028-
const tableBody = document.createElement(`vscode-table-body`);
1029-
tableBody.setAttribute(`slot`, `body`);
1030-
1031-
const readonly = onUpdate === undefined;
1032-
const ROW_PREFIX = `c-row-`;
1033-
for (let i = 0; i < keywords.length; i++) {
1034-
const keyword = keywords[i];
1035-
const row = document.createElement(`vscode-table-row`);
1036-
row.id = `${ROW_PREFIX}${i}`;
1037-
1038-
// TODO: delete button? on the keyword?
1039-
const deleteKeywordButton = createDeleteButtonCell(() => {
1040-
row.remove();
1041-
});
1042-
1043-
// TODO: might be cool to have the keyword validated against a list?
1044-
const keywordCell = createInputCell(`c-${i}-keyword`, keyword.name, readonly);
1045-
const valueCell = createInputCell(`c-${i}-value`, keyword.value || ``, readonly);
1046-
// TODO: Consider how conditions should be handled?
1047-
1048-
if (!readonly) {
1049-
row.appendChild(deleteKeywordButton);
1050-
}
1051-
1052-
row.appendChild(keywordCell);
1053-
row.appendChild(valueCell);
1025+
const tree = document.createElement(`vscode-tree`);
1026+
tree.id = id;
10541027

1055-
tableBody.appendChild(row);
1056-
}
1057-
1058-
table.appendChild(tableBody);
1028+
const actions = [
1029+
{
1030+
icon: "edit",
1031+
actionId: "rename",
1032+
tooltip: "Rename",
1033+
},
1034+
{
1035+
icon: "trash",
1036+
actionId: "delete",
1037+
tooltip: "Delete",
1038+
},
1039+
];
1040+
1041+
tree.data = keywords.map((keyword, index) => {
1042+
return {
1043+
icons: {
1044+
leaf: `account`,
1045+
open: `delete`,
1046+
branch: `edit`
1047+
},
1048+
label: keyword.name,
1049+
value: keyword.value,
1050+
description: keyword.value,
1051+
actions,
1052+
subItems: keyword.conditions.map(c => ({
1053+
label: `${c.indicator} ${c.negate ? `(negated)` : ``}`,
1054+
})),
1055+
};
1056+
});
10591057

1060-
section.appendChild(table);
1058+
section.appendChild(tree);
10611059

10621060
if (onUpdate) {
10631061

0 commit comments

Comments
 (0)