quasar-ui-danx 0.0.37 → 0.0.38
Sign up to get free protection for your applications and to get access to all the features.
package/package.json
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
<template>
|
2
2
|
<PopoverMenu
|
3
3
|
class="px-2 flex action-button"
|
4
|
-
:items="
|
4
|
+
:items="activeActions"
|
5
5
|
:disabled="targets.length === 0"
|
6
6
|
:tooltip="targets.length === 0 ? tooltip : null"
|
7
|
-
:loading="isSaving"
|
7
|
+
:loading="loading || isSaving"
|
8
8
|
:loading-component="loadingComponent"
|
9
9
|
@action-item="onAction"
|
10
10
|
/>
|
@@ -16,7 +16,7 @@ import { PopoverMenu } from '../Utility';
|
|
16
16
|
|
17
17
|
const emit = defineEmits(['action']);
|
18
18
|
const props = defineProps({
|
19
|
-
|
19
|
+
actions: {
|
20
20
|
type: Array,
|
21
21
|
required: true
|
22
22
|
},
|
@@ -28,22 +28,23 @@ const props = defineProps({
|
|
28
28
|
type: String,
|
29
29
|
default: 'First select records to perform a batch action'
|
30
30
|
},
|
31
|
+
loading: Boolean,
|
31
32
|
loadingComponent: {
|
32
33
|
type: [Function, Object],
|
33
34
|
default: undefined
|
34
35
|
}
|
35
36
|
});
|
36
37
|
|
37
|
-
const
|
38
|
-
if (
|
39
|
-
return typeof
|
38
|
+
const activeActions = computed(() => props.actions.filter(action => {
|
39
|
+
if (action.enabled === undefined) return true;
|
40
|
+
return typeof action.enabled === 'function' ? !!action.enabled(props.targets?.[0] ?? null, props.targets) : !!action.enabled;
|
40
41
|
}));
|
41
42
|
|
42
43
|
const isSaving = ref(false);
|
43
|
-
async function onAction(
|
44
|
-
emit('action',
|
44
|
+
async function onAction(action) {
|
45
|
+
emit('action', action);
|
45
46
|
isSaving.value = true;
|
46
|
-
await performAction(
|
47
|
+
await performAction(action, props.targets);
|
47
48
|
isSaving.value = false;
|
48
49
|
}
|
49
50
|
</script>
|
@@ -75,8 +75,9 @@
|
|
75
75
|
</div>
|
76
76
|
<div v-if="rowProps.col.actions" class="flex-grow flex justify-end pl-2">
|
77
77
|
<ActionMenu
|
78
|
-
:
|
78
|
+
:actions="rowProps.col.actions"
|
79
79
|
:targets="[rowProps.row]"
|
80
|
+
:loading="isSavingItem?.id === rowProps.row.id"
|
80
81
|
@action="(action) => $emit('action', {action: action, row: rowProps.row})"
|
81
82
|
/>
|
82
83
|
</div>
|
@@ -112,6 +113,10 @@ const props = defineProps({
|
|
112
113
|
type: Object,
|
113
114
|
required: true
|
114
115
|
},
|
116
|
+
isSavingItem: {
|
117
|
+
type: Object,
|
118
|
+
default: null
|
119
|
+
},
|
115
120
|
isLoadingList: Boolean,
|
116
121
|
pagedItems: {
|
117
122
|
type: Object,
|
@@ -228,11 +228,11 @@ export function useListActions(name: string, {
|
|
228
228
|
/**
|
229
229
|
* Applies an action to an item.
|
230
230
|
*/
|
231
|
-
const
|
231
|
+
const isSavingItem = ref(null);
|
232
232
|
let actionResultCount = 0;
|
233
233
|
|
234
234
|
async function applyAction(item, input, itemData = {}) {
|
235
|
-
|
235
|
+
isSavingItem.value = item;
|
236
236
|
const resultNumber = ++actionResultCount;
|
237
237
|
setItemInPagedList({ ...item, ...input, ...itemData });
|
238
238
|
const result = await applyActionRoute(item, input);
|
@@ -248,7 +248,7 @@ export function useListActions(name: string, {
|
|
248
248
|
activeItem.value = { ...activeItem.value, ...result.item };
|
249
249
|
}
|
250
250
|
}
|
251
|
-
|
251
|
+
isSavingItem.value = null;
|
252
252
|
return result;
|
253
253
|
}
|
254
254
|
|
@@ -355,7 +355,7 @@ export function useListActions(name: string, {
|
|
355
355
|
isLoadingSummary,
|
356
356
|
pager,
|
357
357
|
quasarPagination,
|
358
|
-
|
358
|
+
isSavingItem,
|
359
359
|
activeItem,
|
360
360
|
activePanel,
|
361
361
|
|