quasar-ui-danx 0.4.42 → 0.4.45
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/danx.es.js +6587 -6321
- package/dist/danx.es.js.map +1 -1
- package/dist/danx.umd.js +85 -85
- package/dist/danx.umd.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/components/ActionTable/Layouts/ActionTableLayout.vue +4 -1
- package/src/components/ActionTable/controls.ts +2 -2
- package/src/components/PanelsDrawer/PanelsDrawer.vue +15 -4
- package/src/components/Utility/Buttons/ActionButton.vue +6 -3
- package/src/components/Utility/Buttons/ShowHideButton.vue +1 -1
- package/src/components/Utility/Files/FilePreview.vue +9 -3
- package/src/components/Utility/Layouts/CollapsableSidebar.vue +41 -51
- package/src/components/Utility/Widgets/LabelPillWidget.vue +40 -0
- package/src/components/Utility/Widgets/LabelValuePillWidget.vue +26 -0
- package/src/components/Utility/Widgets/index.ts +2 -0
- package/src/components/Utility/index.ts +1 -0
- package/src/helpers/actions.ts +15 -2
- package/src/helpers/array.ts +15 -15
- package/src/helpers/objectStore.ts +40 -21
- package/src/helpers/request.ts +18 -8
- package/src/helpers/routes.ts +76 -13
- package/src/helpers/utils.ts +3 -0
- package/src/types/actions.d.ts +1 -0
- package/src/types/controls.d.ts +10 -4
- package/src/types/index.d.ts +1 -0
- package/src/types/requests.d.ts +1 -0
- package/src/types/widgets.d.ts +5 -0
package/src/helpers/routes.ts
CHANGED
@@ -1,36 +1,99 @@
|
|
1
|
-
import { storeObject } from "../helpers";
|
2
|
-
import { ListControlsRoutes } from "../types";
|
1
|
+
import { storeObject, storeObjects } from "../helpers";
|
2
|
+
import { ActionTargetItem, ApplyActionResponse, ListControlsRoutes, PagedItems } from "../types";
|
3
3
|
import { downloadFile } from "./downloadPdf";
|
4
4
|
import { request } from "./request";
|
5
5
|
|
6
6
|
export function useActionRoutes(baseUrl: string, extend?: object): ListControlsRoutes {
|
7
7
|
return {
|
8
|
-
|
9
|
-
|
8
|
+
/**
|
9
|
+
* Loads a paged item list from the server
|
10
|
+
*/
|
11
|
+
async list(pager?, options?) {
|
12
|
+
options = {
|
13
|
+
...options,
|
14
|
+
ignoreAbort: true
|
15
|
+
};
|
16
|
+
const response = await request.post(`${baseUrl}/list`, pager, options) as PagedItems;
|
17
|
+
|
18
|
+
if (response.data) {
|
19
|
+
response.data = storeObjects(response.data);
|
20
|
+
}
|
21
|
+
|
22
|
+
return response;
|
10
23
|
},
|
24
|
+
/**
|
25
|
+
* Loads a summary from the server
|
26
|
+
*/
|
11
27
|
summary(filter, options?) {
|
28
|
+
options = {
|
29
|
+
...options,
|
30
|
+
ignoreAbort: true
|
31
|
+
};
|
12
32
|
return request.post(`${baseUrl}/summary`, { filter }, options);
|
13
33
|
},
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
34
|
+
/**
|
35
|
+
* Loads a single item from the server.
|
36
|
+
* Optionally pass in the desired fields to load (otherwise it will load all default fields)
|
37
|
+
*/
|
38
|
+
async details(target, fields, options?) {
|
39
|
+
options = {
|
40
|
+
...options,
|
41
|
+
ignoreAbort: true
|
42
|
+
};
|
21
43
|
fields && (options.params = { fields });
|
22
44
|
const item = await request.get(`${baseUrl}/${target.id}/details`, options);
|
23
45
|
return storeObject(item);
|
24
46
|
},
|
47
|
+
/**
|
48
|
+
* Loads field options from the server
|
49
|
+
*/
|
25
50
|
fieldOptions(options?) {
|
26
51
|
return request.get(`${baseUrl}/field-options`, options);
|
27
52
|
},
|
28
|
-
|
29
|
-
|
53
|
+
/**
|
54
|
+
* Applies an action to a target item on the server to save to the DB and return the updated result
|
55
|
+
*/
|
56
|
+
async applyAction(action, target, data, options?) {
|
57
|
+
options = {
|
58
|
+
...options,
|
59
|
+
ignoreAbort: true,
|
60
|
+
headers: {
|
61
|
+
...options?.headers,
|
62
|
+
// @ts-expect-error This header is fine
|
63
|
+
"X-Timestamp": Date.now()
|
64
|
+
}
|
65
|
+
};
|
66
|
+
data = data || {};
|
67
|
+
const response = await request.post(`${baseUrl}/${target ? target.id : "new"}/apply-action`, {
|
68
|
+
action,
|
69
|
+
data
|
70
|
+
}, options) as ApplyActionResponse;
|
71
|
+
|
72
|
+
// Store the response item in the reactive store if it is set
|
73
|
+
if (response.item) {
|
74
|
+
response.item = storeObject(response.item);
|
75
|
+
}
|
76
|
+
|
77
|
+
// Store the result item in the reactive store if it is set as an ActionTargetItem
|
78
|
+
if (response.result?.__type && response.result?.id) {
|
79
|
+
response.result = storeObject(response.result as ActionTargetItem);
|
80
|
+
}
|
81
|
+
|
82
|
+
return response;
|
30
83
|
},
|
84
|
+
/**
|
85
|
+
* Applies an action to multiple target items on the server to save to the DB and return the updated result
|
86
|
+
*/
|
31
87
|
batchAction(action, targets, data, options?) {
|
88
|
+
options = {
|
89
|
+
...options,
|
90
|
+
ignoreAbort: true
|
91
|
+
};
|
32
92
|
return request.post(`${baseUrl}/batch-action`, { action, filter: { id: targets.map(r => r.id) }, data }, options);
|
33
93
|
},
|
94
|
+
/**
|
95
|
+
* Exports a list of items to a CSV file
|
96
|
+
*/
|
34
97
|
export(filter, name) {
|
35
98
|
return downloadFile(`${baseUrl}/export`, name || "export.csv", { filter });
|
36
99
|
},
|
package/src/helpers/utils.ts
CHANGED
@@ -33,6 +33,9 @@ export async function pollUntil(callback: () => any, interval = 1000) {
|
|
33
33
|
*/
|
34
34
|
export function waitForRef(ref: Ref, value: any) {
|
35
35
|
return new Promise<void>((resolve) => {
|
36
|
+
if (ref.value === value) {
|
37
|
+
resolve();
|
38
|
+
}
|
36
39
|
watch(ref, (newValue) => {
|
37
40
|
if (newValue === value) {
|
38
41
|
resolve();
|
package/src/types/actions.d.ts
CHANGED
@@ -34,6 +34,7 @@ export interface ActionOptions<T = ActionTargetItem> {
|
|
34
34
|
debounce?: number;
|
35
35
|
useInputFromConfirm?: boolean;
|
36
36
|
optimistic?: boolean | ((action: ActionOptions<T>, target: T | null, input: any) => void);
|
37
|
+
optimisticDelete?: boolean;
|
37
38
|
vnode?: (target: ActionTarget<T>, data: any) => VNode | any;
|
38
39
|
enabled?: (target: ActionTarget<T>) => boolean;
|
39
40
|
batchEnabled?: (targets: T[]) => boolean;
|
package/src/types/controls.d.ts
CHANGED
@@ -27,13 +27,11 @@ export interface ListControlsRoutes<T = ActionTargetItem> {
|
|
27
27
|
|
28
28
|
details?(target: T, fields?: ControlsFieldsList, options?: RequestCallOptions): Promise<T>;
|
29
29
|
|
30
|
-
detailsAndStore?(target: T, fields?: ControlsFieldsList, options?: RequestCallOptions): Promise<T>;
|
31
|
-
|
32
30
|
more?(pager: ListControlsPagination, options?: RequestCallOptions): Promise<T[]>;
|
33
31
|
|
34
|
-
fieldOptions?(
|
32
|
+
fieldOptions?(options?: RequestCallOptions): Promise<AnyObject>;
|
35
33
|
|
36
|
-
applyAction?(action: string | ResourceAction | ActionOptions, target: T | null, data?: object, options?: RequestCallOptions): Promise<
|
34
|
+
applyAction?(action: string | ResourceAction | ActionOptions, target: T | null, data?: object, options?: RequestCallOptions): Promise<ApplyActionResponse>;
|
37
35
|
|
38
36
|
batchAction?(action: string | ResourceAction | ActionOptions, targets: T[], data: object, options?: RequestCallOptions): Promise<AnyObject>;
|
39
37
|
|
@@ -121,3 +119,11 @@ export interface ListController<T = ActionTargetItem> {
|
|
121
119
|
applyFilterFromUrl: (url: string, filters?: Ref<FilterGroup[]> | null) => void;
|
122
120
|
getFieldOptions: (field: string) => any[];
|
123
121
|
}
|
122
|
+
|
123
|
+
export interface ApplyActionResponse<T = ActionTargetItem> {
|
124
|
+
item?: T;
|
125
|
+
result?: T | AnyObject;
|
126
|
+
success?: boolean;
|
127
|
+
error?: boolean;
|
128
|
+
message?: string;
|
129
|
+
}
|
package/src/types/index.d.ts
CHANGED
package/src/types/requests.d.ts
CHANGED