Skip to content

Commit

Permalink
Add merge button form merging list into top list
Browse files Browse the repository at this point in the history
  • Loading branch information
bas080 committed Jun 27, 2024
1 parent 471f874 commit 738561e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lit-component.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ const shareUrl = (items) => {
};

const trs = {
merge: "Merge",
appTitle: "Top List 🍒",
newItem: "New Item",
addItem: "Add Item",
Expand Down Expand Up @@ -258,7 +259,10 @@ const toplist = {
<summary>${tr("listActions")}</summary>
${when(vm.isTopList, () => toplist.action(vm, "newList", svg.plus))}
${when(!vm.isTopList, () => toplist.action(vm, "raise", svg.up))}
${when(!vm.isTopList, () => [
toplist.action(vm, "merge", svg.merge),
toplist.action(vm, "raise", svg.up),
])}
${toplist.anchor(vm, "shareList", svg.share)}
${toplist.anchor(vm, "qrShareList", svg.qr)}
</details>
Expand Down
3 changes: 2 additions & 1 deletion toplist.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const newList = () => ({
data.lists[0] = data.lists[0] ?? newList();

const mergeItems = (items) => () => {
window.dialog.close();
window.dialog?.close();
data.lists[0].items.push(...items);
rerender();
};
Expand Down Expand Up @@ -192,6 +192,7 @@ const lists = (isTopList) => (lists) =>

const actions = {
addItem,
mergeAction: (event) => mergeItems(event.detail.items),
addAction(event) {
data.lists[0].items.unshift(event.detail.item);
rerender();
Expand Down

0 comments on commit 738561e

Please sign in to comment.