lkt-table 1.2.13 → 1.2.15
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/dist/build.d.ts +393 -393
- package/dist/build.js +235 -229
- package/package.json +3 -2
- package/src/lib-components/LktTable.vue +25 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lkt-table",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.15",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lkt",
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
"license": "MIT",
|
|
30
30
|
"sideEffects": false,
|
|
31
31
|
"scripts": {
|
|
32
|
-
"build": "
|
|
32
|
+
"build": "vue-tsc --declaration --emitDeclarationOnly; vite build; tsc --project tsconfig.build.json; cp build/* dist/",
|
|
33
|
+
"rebuild": "rm -rf dist/*; vue-tsc --declaration --emitDeclarationOnly; vite build; tsc --project tsconfig.build.json; cp build/* dist/"
|
|
33
34
|
},
|
|
34
35
|
"author": "Antonio Ibáñez",
|
|
35
36
|
"devDependencies": {
|
|
@@ -15,7 +15,7 @@ import Sortable from 'sortablejs';
|
|
|
15
15
|
import TableHeader from "../components/TableHeader.vue";
|
|
16
16
|
import {__} from "lkt-i18n";
|
|
17
17
|
|
|
18
|
-
const emit = defineEmits(['update:modelValue', 'sort', 'click', 'save', 'error', 'before-save', 'read-response']);
|
|
18
|
+
const emit = defineEmits(['update:modelValue', 'sort', 'click', 'save', 'error', 'before-save', 'read-response', 'click-create']);
|
|
19
19
|
|
|
20
20
|
const slots = useSlots();
|
|
21
21
|
|
|
@@ -62,6 +62,8 @@ const props = withDefaults(defineProps<{
|
|
|
62
62
|
editModeText?: string
|
|
63
63
|
switchEditionEnabled?: boolean
|
|
64
64
|
canCreate?: boolean
|
|
65
|
+
canCreateWithoutEdition?: boolean
|
|
66
|
+
canEditButton?: boolean
|
|
65
67
|
canDrop?: boolean
|
|
66
68
|
dropConfirm?: string
|
|
67
69
|
dropResource?: string
|
|
@@ -114,6 +116,8 @@ const props = withDefaults(defineProps<{
|
|
|
114
116
|
editModeText: 'Edit mode',
|
|
115
117
|
switchEditionEnabled: false,
|
|
116
118
|
canCreate: false,
|
|
119
|
+
canCreateWithoutEdition: false,
|
|
120
|
+
canEditButton: false,
|
|
117
121
|
canDrop: false,
|
|
118
122
|
dropConfirm: '',
|
|
119
123
|
dropResource: '',
|
|
@@ -224,6 +228,7 @@ const emptyColumns = computed(() => {
|
|
|
224
228
|
}),
|
|
225
229
|
showEditionButtons = computed(() => {
|
|
226
230
|
// if (hasCreatePerm.value || hasUpdatePerm.value || hasDropPerm.value)
|
|
231
|
+
if (computedDisplayCreateButton.value) return true;
|
|
227
232
|
if (props.switchEditionEnabled) return true;
|
|
228
233
|
return showSaveButton.value || (editModeEnabled.value && props.canCreate);
|
|
229
234
|
}),
|
|
@@ -345,15 +350,19 @@ const getItemByEvent = (e: any) => {
|
|
|
345
350
|
return true;
|
|
346
351
|
},
|
|
347
352
|
onClickAddItem = () => {
|
|
348
|
-
if (
|
|
349
|
-
|
|
353
|
+
if (!props.canCreateWithoutEdition) {
|
|
354
|
+
if (typeof props.newValueGenerator === 'function') {
|
|
355
|
+
let newValue = props.newValueGenerator();
|
|
350
356
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
357
|
+
if (typeof newValue === 'object') {
|
|
358
|
+
Items.value.push(newValue);
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
354
361
|
}
|
|
362
|
+
Items.value.push({});
|
|
363
|
+
} else {
|
|
364
|
+
emit('click-create');
|
|
355
365
|
}
|
|
356
|
-
Items.value.push({});
|
|
357
366
|
},
|
|
358
367
|
onButtonLoading = () => {
|
|
359
368
|
loading.value = true;
|
|
@@ -433,6 +442,10 @@ const getItemByEvent = (e: any) => {
|
|
|
433
442
|
createEnabled = computed(() => {
|
|
434
443
|
if (typeof props.createEnabledValidator === 'function') return props.createEnabledValidator({items: Items.value});
|
|
435
444
|
return true;
|
|
445
|
+
}),
|
|
446
|
+
computedDisplayCreateButton = computed(() => {
|
|
447
|
+
if (!hasCreatePerm.value) return false;
|
|
448
|
+
return props.canCreateWithoutEdition || (props.canCreate && editModeEnabled.value);
|
|
436
449
|
});
|
|
437
450
|
|
|
438
451
|
onMounted(() => {
|
|
@@ -503,7 +516,7 @@ defineExpose({
|
|
|
503
516
|
</lkt-button>
|
|
504
517
|
|
|
505
518
|
<create-button
|
|
506
|
-
v-if="
|
|
519
|
+
v-if="computedDisplayCreateButton && Items.length >= requiredItemsForTopCreate"
|
|
507
520
|
:disabled="!createEnabled"
|
|
508
521
|
:text="createText"
|
|
509
522
|
:icon="createIcon"
|
|
@@ -552,7 +565,7 @@ defineExpose({
|
|
|
552
565
|
class="lkt-table-col-drop"
|
|
553
566
|
/>
|
|
554
567
|
<th
|
|
555
|
-
v-if="hasUpdatePerm && editModeEnabled"
|
|
568
|
+
v-if="canEditButton && hasUpdatePerm && editModeEnabled"
|
|
556
569
|
class="lkt-table-col-edit"
|
|
557
570
|
/>
|
|
558
571
|
</tr>
|
|
@@ -579,7 +592,7 @@ defineExpose({
|
|
|
579
592
|
:drop-resource="dropResource"
|
|
580
593
|
:drop-text="dropText"
|
|
581
594
|
:drop-icon="dropIcon"
|
|
582
|
-
:can-edit="hasUpdatePerm && editModeEnabled"
|
|
595
|
+
:can-edit="canEditButton && hasUpdatePerm && editModeEnabled"
|
|
583
596
|
:edit-text="editText"
|
|
584
597
|
:edit-icon="editIcon"
|
|
585
598
|
:edit-link="editLink"
|
|
@@ -656,9 +669,9 @@ defineExpose({
|
|
|
656
669
|
{{ noResultsText }}
|
|
657
670
|
</div>
|
|
658
671
|
|
|
659
|
-
<div v-if="
|
|
672
|
+
<div v-if="computedDisplayCreateButton" class="lkt-table-page-buttons lkt-table-page-buttons-bottom">
|
|
660
673
|
<create-button
|
|
661
|
-
v-if="
|
|
674
|
+
v-if="computedDisplayCreateButton && Items.length >= requiredItemsForBottomCreate"
|
|
662
675
|
:disabled="!createEnabled"
|
|
663
676
|
:text="createText"
|
|
664
677
|
:icon="createIcon"
|