quasar-ui-danx 0.0.29 → 0.0.31
Sign up to get free protection for your applications and to get access to all the features.
package/package.json
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
<template>
|
2
2
|
<PopoverMenu
|
3
3
|
class="px-4 h-full flex"
|
4
|
-
:items="
|
4
|
+
:items="activeItems"
|
5
5
|
@action-item="onAction"
|
6
6
|
/>
|
7
7
|
</template>
|
8
8
|
<script setup>
|
9
|
+
import { computed } from 'vue';
|
9
10
|
import { performAction } from '../../helpers';
|
10
11
|
import { PopoverMenu } from '../Utility';
|
11
12
|
|
@@ -15,15 +16,19 @@ const props = defineProps({
|
|
15
16
|
type: Array,
|
16
17
|
required: true
|
17
18
|
},
|
18
|
-
|
19
|
+
targets: {
|
19
20
|
type: Array,
|
20
21
|
required: true
|
21
22
|
}
|
22
23
|
});
|
23
24
|
|
25
|
+
const activeItems = computed(() => props.items.filter(item => {
|
26
|
+
if (item.enabled === undefined) return true;
|
27
|
+
return typeof item.enabled === 'function' ? !!item.enabled(props.targets) : !!item.enabled;
|
28
|
+
}));
|
24
29
|
|
25
30
|
function onAction(item) {
|
26
31
|
emit('action', item);
|
27
|
-
performAction(item, props.
|
32
|
+
performAction(item, props.targets);
|
28
33
|
}
|
29
34
|
</script>
|
@@ -52,6 +52,7 @@
|
|
52
52
|
<component
|
53
53
|
:is="rowProps.col.onClick ? 'a' : 'div'"
|
54
54
|
class="flex items-center flex-nowrap"
|
55
|
+
:class="{'justify-end': rowProps.col.align === 'right', 'justify-center': rowProps.col.align === 'center', 'justify-start': rowProps.col.align === 'left'}"
|
55
56
|
@click="() => rowProps.col.onClick && rowProps.col.onClick(rowProps.row)"
|
56
57
|
>
|
57
58
|
<RenderComponent
|
@@ -72,7 +73,7 @@
|
|
72
73
|
<ActionMenu
|
73
74
|
v-if="rowProps.col.actions" class="ml-2"
|
74
75
|
:items="rowProps.col.actions"
|
75
|
-
:
|
76
|
+
:targets="[rowProps.row]"
|
76
77
|
@action="(action) => $emit('action', {action: action, row: rowProps.row})"
|
77
78
|
/>
|
78
79
|
</component>
|
@@ -165,7 +165,7 @@ export function useListActions(name, {
|
|
165
165
|
* @returns {Promise<Awaited<void>[]>}
|
166
166
|
*/
|
167
167
|
async function refreshAll() {
|
168
|
-
return Promise.all([loadList(), loadSummary(), loadFilterFieldOptions()]);
|
168
|
+
return Promise.all([loadList(), loadSummary(), loadFilterFieldOptions(), getActiveItemDetails()]);
|
169
169
|
}
|
170
170
|
|
171
171
|
/**
|
@@ -260,19 +260,30 @@ export function useListActions(name, {
|
|
260
260
|
// Controls the tab on the Ad Form
|
261
261
|
const formTab = ref("general");
|
262
262
|
|
263
|
+
/**
|
264
|
+
* Gets the additional details for the currently active item.
|
265
|
+
* (ie: data that is not normally loaded in the list because it is not needed for the list view)
|
266
|
+
* @returns {Promise<void>}
|
267
|
+
*/
|
268
|
+
async function getActiveItemDetails() {
|
269
|
+
if (!activeItem.value) return;
|
270
|
+
|
271
|
+
const result = await itemDetailsRoute(activeItem.value);
|
272
|
+
|
273
|
+
// Only set the ad details if we are the response for the currently loaded item
|
274
|
+
// NOTE: race conditions might allow the finished loading item to be different to the currently
|
275
|
+
// requested item
|
276
|
+
if (result?.id === activeItem.value?.id) {
|
277
|
+
activeItem.value = result;
|
278
|
+
}
|
279
|
+
}
|
280
|
+
|
263
281
|
// Whenever the active item changes, fill the additional item details
|
264
282
|
// (ie: tasks, verifications, creatives, etc.)
|
265
283
|
if (itemDetailsRoute) {
|
266
284
|
watch(() => activeItem.value, async (newItem, oldItem) => {
|
267
285
|
if (newItem && oldItem?.id !== newItem.id) {
|
268
|
-
|
269
|
-
|
270
|
-
// Only set the ad details if we are the response for the currently loaded item
|
271
|
-
// NOTE: race conditions might allow the finished loading item to be different to the currently
|
272
|
-
// requested item
|
273
|
-
if (result?.id === activeItem.value?.id) {
|
274
|
-
activeItem.value = result;
|
275
|
-
}
|
286
|
+
await getActiveItemDetails();
|
276
287
|
}
|
277
288
|
});
|
278
289
|
}
|
@@ -18,17 +18,20 @@ export function usePerformAction(actions: any[]) {
|
|
18
18
|
*
|
19
19
|
* @param name - can either be a string or an action object
|
20
20
|
* @param targets - an array of targets (or a single target object)
|
21
|
+
* @param options
|
21
22
|
* @returns {Promise<void>}
|
22
23
|
*/
|
23
|
-
async performAction(name, targets) {
|
24
|
+
async performAction(name, targets, options = {}) {
|
24
25
|
const action = typeof name === "string" ? actions.find(a => a.name === name) : name;
|
25
26
|
if (!action) {
|
26
27
|
throw new Error(`Unknown action: ${name}`);
|
27
28
|
}
|
28
29
|
targets = Array.isArray(targets) ? targets : [targets];
|
29
30
|
|
30
|
-
await performAction(action, targets);
|
31
|
-
}
|
31
|
+
await performAction({ ...action, ...options }, targets);
|
32
|
+
},
|
33
|
+
|
34
|
+
batchActions: actions.filter(a => a.batch)
|
32
35
|
};
|
33
36
|
}
|
34
37
|
|