lkt-table 1.3.2 → 1.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lkt-table",
3
- "version": "1.3.2",
3
+ "version": "1.3.4",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "lkt",
@@ -14,13 +14,26 @@ import TableHeader from "../components/TableHeader.vue";
14
14
  import {__} from "lkt-i18n";
15
15
  import {time} from "lkt-date-tools";
16
16
  import {Settings} from "../settings/Settings";
17
-
18
- const emit = defineEmits(['update:modelValue', 'update:perms', 'sort', 'click', 'save', 'error', 'before-save', 'read-response', 'click-create']);
17
+ import {TypeOfTable} from "../enums/TypeOfTable";
18
+
19
+ const emit = defineEmits([
20
+ 'update:modelValue',
21
+ 'update:perms',
22
+ 'sort',
23
+ 'click',
24
+ 'save',
25
+ 'error',
26
+ 'before-save',
27
+ 'read-response',
28
+ 'click-create',
29
+ 'page',
30
+ ]);
19
31
 
20
32
  const slots = useSlots();
21
33
 
22
34
  const props = withDefaults(defineProps<{
23
35
  modelValue: LktObject[]
36
+ type?: TypeOfTable,
24
37
  columns: Column[]
25
38
  sorter?: Function
26
39
  draggableChecker?: Function
@@ -81,6 +94,7 @@ const props = withDefaults(defineProps<{
81
94
  slotItemVar: string
82
95
  }>(), {
83
96
  modelValue: () => [],
97
+ type: TypeOfTable.Table,
84
98
  columns: () => [],
85
99
  sorter: defaultTableSorter,
86
100
  draggableChecker: (item: any) => true,
@@ -160,6 +174,13 @@ const Page = ref(props.page),
160
174
  updateTimeStamp = ref(0)
161
175
  ;
162
176
 
177
+ watch(Page, (v) => emit('page', v));
178
+
179
+ const Type = ref(props.type);
180
+ if (props.itemMode && Type.value === TypeOfTable.Table) {
181
+ Type.value = TypeOfTable.Item;
182
+ }
183
+
163
184
  const onResults = (r: any) => {
164
185
  //@ts-ignore
165
186
  if (Array.isArray(r)) Items.value = r;
@@ -540,7 +561,7 @@ const hasEmptySlot = computed(() => {
540
561
  <lkt-loader v-if="loading"/>
541
562
 
542
563
  <div v-show="!loading && Items.length > 0" class="lkt-table" :data-sortable="sortable">
543
- <table v-if="!itemMode">
564
+ <table v-if="Type === TypeOfTable.Table">
544
565
  <thead>
545
566
  <tr>
546
567
  <th v-if="sortable && editModeEnabled" data-role="drag-indicator"/>
@@ -644,7 +665,7 @@ const hasEmptySlot = computed(() => {
644
665
  </tbody>
645
666
  </table>
646
667
 
647
- <div v-else class="lkt-table-items-container" :class="itemsContainerClass">
668
+ <div v-else-if="Type === TypeOfTable.Item" class="lkt-table-items-container" :class="itemsContainerClass">
648
669
  <template
649
670
  v-for="(item, i) in Items">
650
671
  <div class="lkt-table-item" v-if="canDisplayItem(item)">
@@ -661,6 +682,42 @@ const hasEmptySlot = computed(() => {
661
682
  </div>
662
683
  </template>
663
684
  </div>
685
+
686
+ <ul v-else-if="TypeOfTable.Ul" class="lkt-table-items-container" :class="itemsContainerClass">
687
+ <template
688
+ v-for="(item, i) in Items">
689
+ <li class="lkt-table-item" v-if="canDisplayItem(item)">
690
+ <slot name="item"
691
+ v-bind:[slotItemVar]="item"
692
+ v-bind:index="i"
693
+ v-bind:can-create="hasCreatePerm"
694
+ v-bind:can-read="hasReadPerm"
695
+ v-bind:can-update="hasUpdatePerm"
696
+ v-bind:can-drop="hasDropPerm"
697
+ v-bind:is-loading="loading"
698
+ v-bind:do-drop="() => onItemDrop(i)"
699
+ />
700
+ </li>
701
+ </template>
702
+ </ul>
703
+
704
+ <ol v-else-if="TypeOfTable.Ul" class="lkt-table-items-container" :class="itemsContainerClass">
705
+ <template
706
+ v-for="(item, i) in Items">
707
+ <li class="lkt-table-item" v-if="canDisplayItem(item)">
708
+ <slot name="item"
709
+ v-bind:[slotItemVar]="item"
710
+ v-bind:index="i"
711
+ v-bind:can-create="hasCreatePerm"
712
+ v-bind:can-read="hasReadPerm"
713
+ v-bind:can-update="hasUpdatePerm"
714
+ v-bind:can-drop="hasDropPerm"
715
+ v-bind:is-loading="loading"
716
+ v-bind:do-drop="() => onItemDrop(i)"
717
+ />
718
+ </li>
719
+ </template>
720
+ </ol>
664
721
  </div>
665
722
 
666
723
  <div class="lkt-table-empty" v-if="!loading && Items.length === 0">