Skip to content

Commit

Permalink
Init multiple selection in collection view
Browse files Browse the repository at this point in the history
  • Loading branch information
bperel committed Jul 5, 2024
1 parent 03e22c6 commit 23295d0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
13 changes: 12 additions & 1 deletion apps/whattheduck/src/components/List.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
:is-owned="isOwned"
:next-item-type="nextItemType"
@click="updateCurrentNavigationItem(key)"
@ionChange="toggleCheckedIssuenumber(item)"
v-on-long-press.prevent="
toggleCheckedIssuenumber(item)
"
>
<template #fill-bar v-if="item">
<slot name="fill-bar" :item="item" />
Expand Down Expand Up @@ -84,9 +88,11 @@ const props = defineProps<{
getItemTextFn: (item: Item) => string;
issueViewModes?: { label: string; icon: { ios: string; md: string } }[];
filter?: { label: string; icon: { ios: string; md: string } }[];
isMultipleSelection?: boolean
}>();
const emit = defineEmits<(e: 'items-filtered', items: string[]) => void>();
const emit = defineEmits<{ (e: "items-filtered", items: string[]): void; (e: "enable-multiple-selection"): void }>();
const {
coverId: { services: coverIdServices },
Expand Down Expand Up @@ -148,6 +154,11 @@ const updateCurrentNavigationItem = (key: string) => {
}
};
const toggleCheckedIssuenumber = (item: Item ) => {
emit('enable-multiple-selection')
selectedIssuenumbers.value[item.issuenumber] = !selectedIssuenumbers.value[item.issuenumber]
}
const itemInCenterOfViewport = computed(() => {
if (!props.items.length) {
return undefined;
Expand Down
11 changes: 8 additions & 3 deletions apps/whattheduck/src/views/IssueList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
v-if="hasCoaData"
:items="sortedItems"
:get-item-text-fn="getItemTextFn"
:is-multiple-selection="isMultipleSelection"
@enable-multiple-selection="isMultipleSelection = true"
@items-filtered="filteredIssuenumbers = $event"
>
<template v-if="currentIssueViewMode.id === 'list'" #row-prefix="{ item }">
<ion-checkbox
v-if="isMultipleSelection"
:checked="selectedIssuenumbers[item.issuenumber]"
v-if="isCoaView"
@ionChange="selectedIssuenumbers[item.issuenumber] = $event.detail.checked"
@click.stop="() => {}"
>&nbsp;</ion-checkbox
>
<Condition v-if="item.condition" :value="item.condition" />
Expand Down Expand Up @@ -98,6 +98,11 @@ const userIssues = computed(() =>
(issues.value || []).filter((issue) => issue.publicationcode === publicationcode.value),
);
const isMultipleSelection = ref(false)
watch(isCoaView, () => {
isMultipleSelection.value = isCoaView.value;
});
type Item = NonNullable<(typeof issues)['value']>[number];
const items = computed(() =>
Expand Down

0 comments on commit 23295d0

Please sign in to comment.