PluginProbe
The Innovative Form Builder – IvyForms / 1.1
The Innovative Form Builder – IvyForms v1.1
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
ivyforms / frontend / src / views / _components / table / IvyTableBulkHeader.vue

IvyTableBulkHeader.vue in The Innovative Form Builder – IvyForms 1.1, at frontend/src/views/_components/table/IvyTableBulkHeader.vue

104 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <template>
2 <div class="ivyforms-table-bulk-header">
3 <IvyCheckbox
4 type="checkmark"
5 size="s"
6 :model-value="checkboxValue"
7 :indeterminate="someSelected && !allSelected"
8 :disabled="loading"
9 class="ivyforms-ml-6"
10 @update:model-value="onCheckboxChange"
11 >
12 <slot></slot>
13 </IvyCheckbox>
14 <IvyButtonAction
15 v-if="primaryAction"
16 :priority="primaryAction.danger ? 'danger' : 'tertiary'"
17 size="xs"
18 :disabled="loading || !selectedIds.length"
19 @click="primaryAction.onClick"
20 >
21 {{ primaryAction.label }}
22 </IvyButtonAction>
23 <IvyButtonAction
24 v-if="menuActions && menuActions.length"
25 ref="bulkMenuButtonRef"
26 icon-only
27 icon-start="context-menu-dot"
28 size="xs"
29 type="fill"
30 priority="tertiary"
31 class="ivyforms-flex ivyforms-align-items-center ivyforms-gap-8 ivyforms-ml-8"
32 :disabled="loading || !selectedIds.length"
33 :aria-label="getLabel('more_actions')"
34 @click="openBulkMenu"
35 >
36 </IvyButtonAction>
37 </div>
38 </template>
39
40 <script setup lang="ts">
41 import { computed, ref } from 'vue'
42 import IvyButtonAction from '@/views/_components/button/IvyButtonAction.vue'
43 import type { ComponentPublicInstance } from 'vue'
44 import IvyCheckbox from '@/views/_components/checkbox/IvyCheckbox.vue'
45 import { useLabels } from '@/composables/useLabels.ts'
46 import { useContextMenuStore } from '@/stores/contextMenuStore.ts'
47 import type { ContextMenuAction } from '@/views/_components/context-menu/context-menu-action'
48
49 export interface BulkPrimaryAction {
50 label: string
51 danger?: boolean
52 onClick: () => void
53 }
54
55 const { getLabel } = useLabels()
56 const contextMenuStore = useContextMenuStore()
57 const bulkMenuButtonRef = ref<ComponentPublicInstance | null>(null)
58
59 const props = defineProps<{
60 selectedIds: Array<number | string>
61 loading?: boolean
62 primaryAction?: BulkPrimaryAction
63 menuActions?: ContextMenuAction[]
64 allSelected?: boolean
65 someSelected?: boolean
66 }>()
67
68 const emit = defineEmits<{
69 (e: 'unselect-all'): void
70 (e: 'toggle-all'): void
71 }>()
72
73 const checkboxValue = computed(() => Boolean(props.allSelected))
74
75 const onCheckboxChange = (value: boolean) => {
76 if (props.loading) return
77 if (!value) {
78 emit('unselect-all')
79 } else {
80 emit('toggle-all')
81 }
82 }
83
84 const openBulkMenu = () => {
85 if (props.loading) return
86 if (!props.selectedIds.length || !props.menuActions?.length) return
87 contextMenuStore.openContextMenu({
88 actions: props.menuActions,
89 contextMenuButtonRef: bulkMenuButtonRef.value,
90 })
91 }
92 </script>
93
94 <style lang="scss">
95 .ivyforms-table-bulk-header {
96 display: flex;
97 height: 48px;
98 padding: 0 16px 0 8px;
99 align-items: center;
100 align-self: stretch;
101 background: var(--map-ground-level-1-foreground);
102 }
103 </style>
104