From 9d816ce9c8e40cef1fe2e2f5fe781a7539d178c7 Mon Sep 17 00:00:00 2001 From: Bastian Allgeier Date: Thu, 17 Oct 2024 22:44:20 +0200 Subject: [PATCH 01/37] Selectable items --- panel/lab/components/items/1_list/index.vue | 29 +++++++++++++++++++ panel/lab/components/items/2_cards/index.vue | 29 +++++++++++++++++++ .../lab/components/items/3_cardlets/index.vue | 29 +++++++++++++++++++ .../src/components/Collection/Collection.vue | 4 +++ panel/src/components/Collection/Item.vue | 20 +++++++++++-- panel/src/components/Collection/Items.vue | 1 + 6 files changed, 110 insertions(+), 2 deletions(-) diff --git a/panel/lab/components/items/1_list/index.vue b/panel/lab/components/items/1_list/index.vue index 935cda2769..905fbc5877 100644 --- a/panel/lab/components/items/1_list/index.vue +++ b/panel/lab/components/items/1_list/index.vue @@ -3,6 +3,11 @@ + + +
+ Selected: {{ selected.join(", ") }} +
@@ -10,6 +15,30 @@ export default { props: { items: Array + }, + data() { + return { + selected: [] + }; + }, + computed: { + selectableItems() { + return this.items.map((item) => { + return { + ...item, + selectable: true + }; + }); + } + }, + methods: { + onSelect(event, item, index) { + if (event.target.checked) { + this.selected.push(index); + } else { + this.selected = this.selected.filter((i) => i !== index); + } + } } }; diff --git a/panel/lab/components/items/2_cards/index.vue b/panel/lab/components/items/2_cards/index.vue index e9ae98d1d1..a212ef07a5 100644 --- a/panel/lab/components/items/2_cards/index.vue +++ b/panel/lab/components/items/2_cards/index.vue @@ -3,6 +3,11 @@ + + +
+ Selected: {{ selected.join(", ") }} +
@@ -10,6 +15,30 @@ export default { props: { items: Array + }, + data() { + return { + selected: [] + }; + }, + computed: { + selectableItems() { + return this.items.map((item) => { + return { + ...item, + selectable: true + }; + }); + } + }, + methods: { + onSelect(event, item, index) { + if (event.target.checked) { + this.selected.push(index); + } else { + this.selected = this.selected.filter((i) => i !== index); + } + } } }; diff --git a/panel/lab/components/items/3_cardlets/index.vue b/panel/lab/components/items/3_cardlets/index.vue index aead0089f0..ae3c9246e2 100644 --- a/panel/lab/components/items/3_cardlets/index.vue +++ b/panel/lab/components/items/3_cardlets/index.vue @@ -3,6 +3,11 @@ + + +
+ Selected: {{ selected.join(", ") }} +
@@ -10,6 +15,30 @@ export default { props: { items: Array + }, + data() { + return { + selected: [] + }; + }, + computed: { + selectableItems() { + return this.items.map((item) => { + return { + ...item, + selectable: true + }; + }); + } + }, + methods: { + onSelect(event, item, index) { + if (event.target.checked) { + this.selected.push(index); + } else { + this.selected = this.selected.filter((i) => i !== index); + } + } } }; diff --git a/panel/src/components/Collection/Collection.vue b/panel/src/components/Collection/Collection.vue index 3042b57f67..cfed43655d 100644 --- a/panel/src/components/Collection/Collection.vue +++ b/panel/src/components/Collection/Collection.vue @@ -22,6 +22,7 @@ @change="$emit('change', $event)" @item="$emit('item', $event)" @option="onOption" + @select="onSelect" @sort="$emit('sort', $event)" >