@dashadmin/dash-auto-admin 1.3.24 → 1.3.26
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/DashAutoAdminComponentRegistry.js +64 -1
- package/dist/DashAutoAdminForm.js +137 -1
- package/dist/DashAutoAdminResizableDrawer.js +63 -1
- package/dist/DashAutoAdminSaveButton.js +57 -1
- package/dist/DashAutoCreate.js +102 -1
- package/dist/DashAutoDrawer.js +256 -1
- package/dist/DashAutoEdit.js +99 -1
- package/dist/DashAutoFiltersGenerator.js +193 -1
- package/dist/DashAutoFormGroups.js +118 -1
- package/dist/DashAutoFormLayout.js +68 -1
- package/dist/DashAutoFormMuiTabs.js +291 -1
- package/dist/DashAutoFormTabs.js +132 -1
- package/dist/DashAutoGroup.js +27 -1
- package/dist/DashAutoLayout.js +31 -1
- package/dist/DashAutoList.js +218 -1
- package/dist/DashAutoPostFilterForm.js +47 -1
- package/dist/DashAutoReferenceTab.js +10 -1
- package/dist/DashAutoResource.js +77 -1
- package/dist/DashAutoResourceLayout.js +16 -1
- package/dist/DashAutoShow.js +195 -1
- package/dist/DashAutoTabbedForm.js +244 -1
- package/dist/DashAutoTabbedForm.review.js +221 -1
- package/dist/DashAutoTabs.js +11 -1
- package/dist/DashFilterWrapper.js +62 -1
- package/dist/DashRedirect.js +56 -1
- package/dist/TabbedLayout.js +38 -1
- package/dist/common/DashAutoTitle.js +33 -1
- package/dist/common/components/FabButton.js +59 -1
- package/dist/common/components/TranslatedLabel.js +60 -1
- package/dist/common/settings/Settings.js +196 -1
- package/dist/common/settings/SettingsBarIcons.js +61 -1
- package/dist/context/DashAutoAdminFormContext.js +15 -1
- package/dist/hooks/useAutoAdminLoadingStateMediator.js +36 -1
- package/dist/hooks/useAutoAdminTranslate.js +61 -1
- package/dist/hooks/useHash.js +24 -1
- package/dist/hooks/useLogger.js +20 -1
- package/dist/hooks/useRoutePathPattern.js +20 -1
- package/dist/hooks/useVirtualHash.js +28 -1
- package/dist/index.js +77 -3406
- package/dist/list/DashAutoListActions.js +57 -1
- package/dist/list/DashAutoListDatagridWrapper.js +68 -1
- package/dist/list/DashAutoListDefaultActionsWrapper.js +14 -1
- package/dist/list/DashAutoListFilterFormWithButton.js +80 -1
- package/dist/list/DashAutoListTopToolbar.js +180 -1
- package/dist/mui/AttributeToField.js +576 -1
- package/dist/mui/AttributeToInput.js +630 -1
- package/dist/mui/AutoAdminResizableDrawer.js +63 -1
- package/dist/mui/AutoDataGrid.js +120 -1
- package/dist/mui/AutoReferenceFormTab.js +53 -1
- package/dist/mui/AutoReferenceTab.js +46 -1
- package/dist/mui/AutoTabs.js +19 -1
- package/dist/mui/components/ExtendedPagination.js +34 -1
- package/dist/mui/components/ListStringField.js +25 -1
- package/dist/providers/DashAuthProvider.js +215 -1
- package/dist/providers/DashDataProvider.js +310 -1
- package/dist/providers/index.js +10 -1
- package/dist/react-admin.d.js +0 -0
- package/dist/toolbar/buttons/BottomToolbarButtons.js +65 -1
- package/dist/toolbar/buttons/DashResourceButton.js +181 -1
- package/dist/toolbar/buttons/ListButtons.js +80 -1
- package/dist/toolbar/buttons/ToolbarButtons.js +135 -1
- package/dist/types/ActionCallback.d.js +0 -0
- package/dist/utils/SimpleLogger.js +52 -1
- package/dist/utils/enumToChoices.js +5 -1
- package/dist/utils/evalActionPermission.js +11 -1
- package/dist/utils/groupByTabs.js +21 -1
- package/dist/utils/hashedGroupByTabs.js +12 -1
- package/dist/utils/invertMap.js +12 -1
- package/dist/utils/isClassComponent.js +7 -1
- package/dist/utils/isComponent.js +29 -1
- package/dist/utils/isEnum.js +5 -1
- package/dist/utils/isFC.js +8 -1
- package/dist/utils/replaceParams.js +9 -1
- package/dist/utils/validate.js +19 -1
- package/dist/wrappers/UserAction.js +60 -1
- package/dist/wrappers/index.js +4 -1
- package/package.json +135 -120
- package/src/DashAutoAdminComponentRegistry.tsx +75 -0
- package/src/DashAutoAdminForm.tsx +155 -0
- package/src/DashAutoAdminResizableDrawer.tsx +69 -0
- package/src/DashAutoAdminSaveButton.tsx +116 -0
- package/src/DashAutoCreate.tsx +118 -0
- package/src/DashAutoDrawer.tsx +288 -0
- package/src/DashAutoEdit.tsx +109 -0
- package/src/DashAutoFiltersGenerator.tsx +208 -0
- package/src/DashAutoFormGroups.tsx +146 -0
- package/src/DashAutoFormLayout.tsx.review +113 -0
- package/src/DashAutoFormMuiTabs.tsx +368 -0
- package/src/DashAutoFormTabs.tsx +177 -0
- package/src/DashAutoGroup.tsx +42 -0
- package/src/DashAutoLayout.tsx +57 -0
- package/src/DashAutoList.tsx +237 -0
- package/src/DashAutoPostFilterForm.tsx +35 -0
- package/src/DashAutoReferenceTab.tsx +9 -0
- package/src/DashAutoResource.tsx +85 -0
- package/src/DashAutoResourceLayout.tsx +50 -0
- package/src/DashAutoShow.tsx +200 -0
- package/src/DashAutoTabbedForm.review.tsx +262 -0
- package/src/DashAutoTabbedForm.tsx +324 -0
- package/src/DashAutoTabs.tsx +19 -0
- package/src/DashFilterWrapper.tsx +43 -0
- package/src/DashRedirect.tsx +46 -0
- package/src/TabbedLayout.tsx +29 -0
- package/src/common/DashAutoTitle.tsx +24 -0
- package/src/common/components/FabButton.tsx +40 -0
- package/src/common/components/TranslatedLabel.tsx +81 -0
- package/src/common/settings/Settings.tsx +236 -0
- package/src/common/settings/SettingsBarIcons.tsx +72 -0
- package/src/context/DashAutoAdminFormContext.tsx +31 -0
- package/src/hooks/useAutoAdminLoadingStateMediator.tsx +42 -0
- package/src/hooks/useAutoAdminTranslate.tsx +106 -0
- package/src/hooks/useHash.tsx +27 -0
- package/src/hooks/useLogger.tsx +23 -0
- package/src/hooks/useRoutePathPattern.tsx +24 -0
- package/src/hooks/useVirtualHash.tsx +34 -0
- package/src/index.ts +85 -0
- package/src/interfaces/ICustomResourceSubComponent.ts +11 -0
- package/src/interfaces/IDashApplicationLayoutMainAction.ts +37 -0
- package/src/interfaces/IDashApplicationLayoutMenuItem.ts +24 -0
- package/src/interfaces/IDashAutoAdminAttribute.ts +104 -0
- package/src/interfaces/IDashAutoAdminCustomFieldComponent.ts +18 -0
- package/src/interfaces/IDashAutoAdminFormOptions.ts +22 -0
- package/src/interfaces/IDashAutoAdminListActions.ts +13 -0
- package/src/interfaces/IDashAutoAdminReference.ts +16 -0
- package/src/interfaces/IDashAutoAdminResourceConfig.ts +360 -0
- package/src/interfaces/IDashAutoForm.ts +24 -0
- package/src/interfaces/IDashAutoGridButton.ts +35 -0
- package/src/interfaces/IDashAutoShow.ts +12 -0
- package/src/interfaces/IGroupExtraData.ts +8 -0
- package/src/interfaces/IRecord.ts +7 -0
- package/src/interfaces/IReferenceFilter.ts +55 -0
- package/src/interfaces/IResourceComponent.ts +8 -0
- package/src/interfaces/IToolbarButton.ts +11 -0
- package/src/list/DashAutoListActions.tsx +88 -0
- package/src/list/DashAutoListDatagridWrapper.tsx +74 -0
- package/src/list/DashAutoListDefaultActionsWrapper.tsx +31 -0
- package/src/list/DashAutoListFilterFormWithButton.tsx +93 -0
- package/src/list/DashAutoListTopToolbar.tsx +240 -0
- package/src/mui/AttributeToField.tsx +657 -0
- package/src/mui/AttributeToInput.tsx +728 -0
- package/src/mui/AutoAdminResizableDrawer.tsx +69 -0
- package/src/mui/AutoDataGrid.tsx +127 -0
- package/src/mui/AutoReferenceFormTab.tsx +51 -0
- package/src/mui/AutoReferenceTab.tsx +45 -0
- package/src/mui/AutoTabs.tsx +32 -0
- package/src/mui/components/ExtendedPagination.tsx +23 -0
- package/src/mui/components/ListStringField.tsx +32 -0
- package/src/providers/DashAuthProvider.ts +341 -0
- package/src/providers/DashDataProvider.ts +466 -0
- package/src/providers/index.ts +17 -0
- package/src/toolbar/buttons/BottomToolbarButtons.tsx +59 -0
- package/src/toolbar/buttons/DashResourceButton.tsx +223 -0
- package/src/toolbar/buttons/ListButtons.tsx +137 -0
- package/src/toolbar/buttons/ToolbarButtons.tsx +186 -0
- package/src/utils/SimpleLogger.tsx +46 -0
- package/src/utils/enumToChoices.tsx +3 -0
- package/src/utils/evalActionPermission.tsx +14 -0
- package/src/utils/groupByTabs.tsx +23 -0
- package/src/utils/hashedGroupByTabs.tsx +16 -0
- package/src/utils/invertMap.tsx +10 -0
- package/src/utils/isClassComponent.tsx +9 -0
- package/src/utils/isComponent.tsx +45 -0
- package/src/utils/isEnum.tsx +3 -0
- package/src/utils/isFC.tsx +6 -0
- package/src/utils/replaceParams.tsx +6 -0
- package/src/utils/validate.tsx +24 -0
- package/src/wrappers/UserAction.tsx +67 -0
- package/src/wrappers/index.tsx +1 -0
- /package/{dist → src}/DashAutoAdminSaveButton.tsx.bkup +0 -0
- /package/{dist/DashAutoFormLayout.tsx.review → src/DashAutoFormLayout.tsx} +0 -0
- /package/{dist → src}/DashAutoFormTabs.review +0 -0
- /package/{dist → src}/DashAutoFormTabs.tsx.formcontext.wip +0 -0
- /package/{dist → src}/mui/AttributeToField.tsx.review +0 -0
- /package/{dist → src}/mui/AttributeToInput.tsx.review +0 -0
- /package/{dist → src}/react-admin.d.ts +0 -0
- /package/{dist → src}/types/ActionCallback.d.ts +0 -0
|
@@ -1 +1,310 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __async = (__this, __arguments, generator) => {
|
|
21
|
+
return new Promise((resolve, reject) => {
|
|
22
|
+
var fulfilled = (value) => {
|
|
23
|
+
try {
|
|
24
|
+
step(generator.next(value));
|
|
25
|
+
} catch (e) {
|
|
26
|
+
reject(e);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var rejected = (value) => {
|
|
30
|
+
try {
|
|
31
|
+
step(generator.throw(value));
|
|
32
|
+
} catch (e) {
|
|
33
|
+
reject(e);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
37
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
import queryString from "query-string";
|
|
41
|
+
const defaultProcessPostData = (resource, data, operation) => data;
|
|
42
|
+
const defaultProcessFormData = (resource, data) => {
|
|
43
|
+
const formData = new FormData();
|
|
44
|
+
Object.keys(data).forEach((key) => {
|
|
45
|
+
if (data[key] !== void 0 && data[key] !== null) {
|
|
46
|
+
if (data[key] instanceof File) {
|
|
47
|
+
formData.append(key, data[key]);
|
|
48
|
+
} else if (typeof data[key] === "object") {
|
|
49
|
+
formData.append(key, JSON.stringify(data[key]));
|
|
50
|
+
} else {
|
|
51
|
+
formData.append(key, String(data[key]));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
return formData;
|
|
56
|
+
};
|
|
57
|
+
const createDashDataProvider = (config, overrides = {}) => {
|
|
58
|
+
const {
|
|
59
|
+
useAxios,
|
|
60
|
+
storage,
|
|
61
|
+
getCacheHash = () => null,
|
|
62
|
+
getResourceConfig = () => void 0,
|
|
63
|
+
processPostData = defaultProcessPostData,
|
|
64
|
+
processFormData = defaultProcessFormData,
|
|
65
|
+
processAxiosError = (error) => {
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
} = config;
|
|
69
|
+
const defaultProvider = {
|
|
70
|
+
getList: (resource, params) => __async(null, null, function* () {
|
|
71
|
+
var _a, _b, _c, _d;
|
|
72
|
+
const tenant_id = storage.getItem("tenant_id");
|
|
73
|
+
const axios = useAxios();
|
|
74
|
+
let payload = processPostData(
|
|
75
|
+
resource,
|
|
76
|
+
__spreadProps(__spreadValues({}, params.filter), { tenant_id }),
|
|
77
|
+
"getList"
|
|
78
|
+
);
|
|
79
|
+
const pagination = params.filter && !!params.filter.pagination ? params.filter.pagination : params.pagination ? params.pagination : false;
|
|
80
|
+
if (pagination) {
|
|
81
|
+
payload = __spreadValues(__spreadProps(__spreadValues({}, payload), { pagination: true }), pagination);
|
|
82
|
+
} else {
|
|
83
|
+
payload = __spreadProps(__spreadValues({}, payload), { pagination: false });
|
|
84
|
+
}
|
|
85
|
+
payload = __spreadValues(__spreadValues({}, payload), params.meta);
|
|
86
|
+
const hasSort = params.sort && params.sort.field && params.sort.order;
|
|
87
|
+
if (hasSort && !((_a = params.meta) == null ? void 0 : _a.removeSortFilters)) {
|
|
88
|
+
payload = __spreadValues(__spreadValues({}, payload), __spreadProps(__spreadValues({}, params.sort), { order: params.sort.order.toLowerCase() }));
|
|
89
|
+
}
|
|
90
|
+
const hash = getCacheHash(resource);
|
|
91
|
+
if (hash) {
|
|
92
|
+
payload = __spreadProps(__spreadValues({}, payload), { hash });
|
|
93
|
+
}
|
|
94
|
+
const processedQuery = queryString.stringify(payload, { arrayFormat: "bracket" });
|
|
95
|
+
let url = `${resource}?${processedQuery}`;
|
|
96
|
+
const origin = url.includes("forSelect") ? "forSelect" : url.includes("getMany") ? "getMany" : "getList";
|
|
97
|
+
window.dispatchEvent(
|
|
98
|
+
new MessageEvent("auto-admin-loading-state", {
|
|
99
|
+
data: true,
|
|
100
|
+
origin,
|
|
101
|
+
lastEventId: url
|
|
102
|
+
})
|
|
103
|
+
);
|
|
104
|
+
try {
|
|
105
|
+
const response = yield axios.get(url);
|
|
106
|
+
let results;
|
|
107
|
+
if (typeof ((_c = (_b = response.data) == null ? void 0 : _b.data) == null ? void 0 : _c.total) !== "undefined") {
|
|
108
|
+
results = response.data.data;
|
|
109
|
+
} else if (((_d = response == null ? void 0 : response.data) == null ? void 0 : _d.data) && Array.isArray(response.data.data)) {
|
|
110
|
+
results = { data: response.data.data, total: response.data.total || response.data.data.length };
|
|
111
|
+
} else if ((response == null ? void 0 : response.data) && Array.isArray(response.data)) {
|
|
112
|
+
results = { data: response.data, total: response.data.length };
|
|
113
|
+
} else {
|
|
114
|
+
results = { data: [], total: 0 };
|
|
115
|
+
}
|
|
116
|
+
window.dispatchEvent(
|
|
117
|
+
new MessageEvent("auto-admin-loading-state", {
|
|
118
|
+
data: false,
|
|
119
|
+
origin,
|
|
120
|
+
lastEventId: url
|
|
121
|
+
})
|
|
122
|
+
);
|
|
123
|
+
return results;
|
|
124
|
+
} catch (e) {
|
|
125
|
+
window.dispatchEvent(new MessageEvent("DASHGlobalError", { data: { error: e, config: { dialog: true } } }));
|
|
126
|
+
return { data: [], total: 0 };
|
|
127
|
+
} finally {
|
|
128
|
+
window.dispatchEvent(
|
|
129
|
+
new MessageEvent("auto-admin-loading-state", {
|
|
130
|
+
data: false,
|
|
131
|
+
origin,
|
|
132
|
+
lastEventId: url
|
|
133
|
+
})
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
}),
|
|
137
|
+
getOne: (resource, params) => __async(null, null, function* () {
|
|
138
|
+
const axios = useAxios();
|
|
139
|
+
try {
|
|
140
|
+
const response = yield axios.get(
|
|
141
|
+
`${resource}/${params.id}`,
|
|
142
|
+
params.meta ? { params: params.meta } : {}
|
|
143
|
+
);
|
|
144
|
+
return { data: response.data };
|
|
145
|
+
} catch (e) {
|
|
146
|
+
throw e;
|
|
147
|
+
}
|
|
148
|
+
}),
|
|
149
|
+
getMany: (resource, params) => __async(null, null, function* () {
|
|
150
|
+
var _a;
|
|
151
|
+
const axios = useAxios();
|
|
152
|
+
const paramsIds = Array.isArray(params.ids) && params.ids.length > 0 && Array.isArray(params.ids[0]) ? params.ids[0] : params.ids;
|
|
153
|
+
let query = {
|
|
154
|
+
ids: Array.isArray(paramsIds) && paramsIds.length > 0 && ((_a = paramsIds[0]) == null ? void 0 : _a.id) ? paramsIds.map((object) => object.id) : paramsIds
|
|
155
|
+
};
|
|
156
|
+
query = __spreadProps(__spreadValues({}, query), { pagination: false });
|
|
157
|
+
const hash = getCacheHash(resource);
|
|
158
|
+
if (hash) {
|
|
159
|
+
query = __spreadProps(__spreadValues({}, query), { hash });
|
|
160
|
+
}
|
|
161
|
+
const _query = queryString.stringify(query, { arrayFormat: "bracket" });
|
|
162
|
+
const url = `${resource}/getMany?${_query}`;
|
|
163
|
+
try {
|
|
164
|
+
const response = yield axios.get(url);
|
|
165
|
+
const results = response.data;
|
|
166
|
+
return {
|
|
167
|
+
data: results.data,
|
|
168
|
+
total: results.data && results.data.total ? results.data.total : parseInt(response.headers["content-range"]) || 0
|
|
169
|
+
};
|
|
170
|
+
} catch (e) {
|
|
171
|
+
throw e;
|
|
172
|
+
}
|
|
173
|
+
}),
|
|
174
|
+
getManyReference: (resource, params) => __async(null, null, function* () {
|
|
175
|
+
const tenant_id = storage.getItem("tenant_id");
|
|
176
|
+
const axios = useAxios();
|
|
177
|
+
const pagination = params.filter && params.filter.pagination ? params.filter.pagination : false;
|
|
178
|
+
let query = __spreadProps(__spreadValues({}, params.filter), {
|
|
179
|
+
[params.target]: params.id,
|
|
180
|
+
tenant_id
|
|
181
|
+
});
|
|
182
|
+
if (pagination) {
|
|
183
|
+
query = __spreadValues(__spreadProps(__spreadValues({}, query), { pagination: true }), pagination);
|
|
184
|
+
} else {
|
|
185
|
+
query = __spreadProps(__spreadValues({}, query), { pagination: false });
|
|
186
|
+
}
|
|
187
|
+
const url = `${resource}/getManyReference?${queryString.stringify(query, { arrayFormat: "bracket" })}`;
|
|
188
|
+
try {
|
|
189
|
+
const response = yield axios.get(url);
|
|
190
|
+
const results = response.data;
|
|
191
|
+
return {
|
|
192
|
+
data: results,
|
|
193
|
+
total: results.data && results.data.total ? results.data.total : parseInt(response.headers["content-range"]) || 0
|
|
194
|
+
};
|
|
195
|
+
} catch (e) {
|
|
196
|
+
throw e;
|
|
197
|
+
}
|
|
198
|
+
}),
|
|
199
|
+
update: (resource, params) => __async(null, null, function* () {
|
|
200
|
+
var _a, _b, _c;
|
|
201
|
+
const axios = useAxios();
|
|
202
|
+
const resourceConfig = getResourceConfig(resource);
|
|
203
|
+
const isFormData = (resourceConfig == null ? void 0 : resourceConfig.isFormData) === true || ((_a = params.data) == null ? void 0 : _a.isFormData) === true || ((_b = params.meta) == null ? void 0 : _b.isFormData) === true;
|
|
204
|
+
const tenant_id = params && params.data && params.data.tenant_id ? params.data.tenant_id : storage.getItem("tenant_id");
|
|
205
|
+
const resourcePath = /\/\d+(?:\/[^\/]*)?$/.test(resource) ? resource : params.id ? `${resource}/${params.id}` : resource;
|
|
206
|
+
const postData = processPostData(
|
|
207
|
+
resourcePath,
|
|
208
|
+
__spreadValues(__spreadValues({}, params.data), { tenant_id }),
|
|
209
|
+
"update"
|
|
210
|
+
);
|
|
211
|
+
let method = ((_c = params.meta) == null ? void 0 : _c.method) || "PUT";
|
|
212
|
+
method = (postData == null ? void 0 : postData.axiosMethod) || method;
|
|
213
|
+
delete postData.axiosMethod;
|
|
214
|
+
if (method === "PUT") {
|
|
215
|
+
postData._method = "PUT";
|
|
216
|
+
}
|
|
217
|
+
try {
|
|
218
|
+
if (isFormData) {
|
|
219
|
+
const form = processFormData(resource, postData);
|
|
220
|
+
const response2 = yield axios.post(resourcePath, form, {
|
|
221
|
+
headers: { "Content-Type": "multipart/form-data" }
|
|
222
|
+
});
|
|
223
|
+
return response2;
|
|
224
|
+
}
|
|
225
|
+
const response = yield axios.post(resourcePath, postData);
|
|
226
|
+
return response;
|
|
227
|
+
} catch (e) {
|
|
228
|
+
throw processAxiosError(e, resource, "update");
|
|
229
|
+
}
|
|
230
|
+
}),
|
|
231
|
+
create: (resource, params) => __async(null, null, function* () {
|
|
232
|
+
var _a, _b, _c, _d, _e;
|
|
233
|
+
const axios = useAxios();
|
|
234
|
+
const resourceConfig = getResourceConfig(resource);
|
|
235
|
+
const isFormData = (resourceConfig == null ? void 0 : resourceConfig.isFormData) === true || ((_a = params.data) == null ? void 0 : _a.isFormData) === true || ((_b = params.meta) == null ? void 0 : _b.isFormData) === true;
|
|
236
|
+
const resourcePath = /\/[\w-]+$/.test(resource) ? resource : ((_c = params.meta) == null ? void 0 : _c.id) ? `${resource}/${params.meta.id}` : resource;
|
|
237
|
+
let tenant_id = (_d = params.data) == null ? void 0 : _d.tenant_id;
|
|
238
|
+
if (resource !== "system/user" && !tenant_id) {
|
|
239
|
+
tenant_id = storage.getItem("tenant_id");
|
|
240
|
+
}
|
|
241
|
+
const method = ((_e = params.meta) == null ? void 0 : _e.method) || "POST";
|
|
242
|
+
const action = method === "POST" ? axios.post : axios.put;
|
|
243
|
+
const postData = processPostData(
|
|
244
|
+
resourcePath,
|
|
245
|
+
__spreadValues(__spreadValues({}, params.data), tenant_id ? { tenant_id } : {}),
|
|
246
|
+
"create"
|
|
247
|
+
);
|
|
248
|
+
try {
|
|
249
|
+
if (isFormData) {
|
|
250
|
+
const form = processFormData(resource, postData);
|
|
251
|
+
return yield action(resourcePath, form, {
|
|
252
|
+
headers: { "Content-Type": "multipart/form-data" }
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
return yield action(resourcePath, postData);
|
|
256
|
+
} catch (e) {
|
|
257
|
+
throw processAxiosError(e, resource, "create");
|
|
258
|
+
}
|
|
259
|
+
}),
|
|
260
|
+
updateMany: (resource, params) => __async(null, null, function* () {
|
|
261
|
+
var _a;
|
|
262
|
+
const tenant_id = storage.getItem("tenant_id");
|
|
263
|
+
const axios = useAxios();
|
|
264
|
+
const query = {
|
|
265
|
+
filter: JSON.stringify({ ids: params.ids }),
|
|
266
|
+
tenant_id
|
|
267
|
+
};
|
|
268
|
+
const method = ((_a = params.meta) == null ? void 0 : _a.method) || "POST";
|
|
269
|
+
const action = method === "POST" ? axios.post : axios.put;
|
|
270
|
+
try {
|
|
271
|
+
const response = yield action(
|
|
272
|
+
`${resource}/updateMany?${queryString.stringify(query, { arrayFormat: "bracket" })}`,
|
|
273
|
+
params.data
|
|
274
|
+
);
|
|
275
|
+
return response;
|
|
276
|
+
} catch (e) {
|
|
277
|
+
window.dispatchEvent(
|
|
278
|
+
new MessageEvent("dash-global-loader", { data: false })
|
|
279
|
+
);
|
|
280
|
+
throw e;
|
|
281
|
+
}
|
|
282
|
+
}),
|
|
283
|
+
delete: (resource, params) => __async(null, null, function* () {
|
|
284
|
+
const tenant_id = storage.getItem("tenant_id");
|
|
285
|
+
const axios = useAxios();
|
|
286
|
+
const { data } = yield axios.delete(`${resource}/${params.id}`, {
|
|
287
|
+
data: { tenant_id }
|
|
288
|
+
});
|
|
289
|
+
return { data };
|
|
290
|
+
}),
|
|
291
|
+
deleteMany: (resource, params) => __async(null, null, function* () {
|
|
292
|
+
const tenant_id = storage.getItem("tenant_id");
|
|
293
|
+
const axios = useAxios();
|
|
294
|
+
const query = {
|
|
295
|
+
ids: params.ids || [],
|
|
296
|
+
tenant_id
|
|
297
|
+
};
|
|
298
|
+
const data = yield axios.post(
|
|
299
|
+
`${resource}/deleteMany?${queryString.stringify(query, { arrayFormat: "bracket" })}`
|
|
300
|
+
);
|
|
301
|
+
return data;
|
|
302
|
+
})
|
|
303
|
+
};
|
|
304
|
+
return __spreadValues(__spreadValues({}, defaultProvider), overrides);
|
|
305
|
+
};
|
|
306
|
+
var DashDataProvider_default = createDashDataProvider;
|
|
307
|
+
export {
|
|
308
|
+
createDashDataProvider,
|
|
309
|
+
DashDataProvider_default as default
|
|
310
|
+
};
|
package/dist/providers/index.js
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
createDashAuthProvider
|
|
3
|
+
} from "./DashAuthProvider";
|
|
4
|
+
import {
|
|
5
|
+
createDashDataProvider
|
|
6
|
+
} from "./DashDataProvider";
|
|
7
|
+
export {
|
|
8
|
+
createDashAuthProvider,
|
|
9
|
+
createDashDataProvider
|
|
10
|
+
};
|
|
File without changes
|
|
@@ -1 +1,65 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import { jsx } from "react/jsx-runtime";
|
|
21
|
+
import { DeleteButton } from "react-admin";
|
|
22
|
+
import DashAutoAdminSaveButton from "../../DashAutoAdminSaveButton";
|
|
23
|
+
import { DeleteWithConfirmButton } from "react-admin";
|
|
24
|
+
import { WithRecord } from "react-admin";
|
|
25
|
+
const BottomToolbarSaveButton = (props) => {
|
|
26
|
+
var _a, _b, _c;
|
|
27
|
+
const { resourceConfig } = props;
|
|
28
|
+
if (!resourceConfig) return /* @__PURE__ */ jsx(DashAutoAdminSaveButton, { resourceConfig });
|
|
29
|
+
if (resourceConfig.bottomToolbarSaveButton) {
|
|
30
|
+
if ((_a = resourceConfig.bottomToolbarSaveButton) == null ? void 0 : _a.enabled) {
|
|
31
|
+
const buttonProps = __spreadProps(__spreadValues({
|
|
32
|
+
resourceConfig
|
|
33
|
+
}, ((_b = resourceConfig.bottomToolbarSaveButton) == null ? void 0 : _b.props) || {}), {
|
|
34
|
+
alwaysEnable: (resourceConfig == null ? void 0 : resourceConfig.saveButtonAlwaysEnabled) === true ? true : false
|
|
35
|
+
});
|
|
36
|
+
return ((_c = resourceConfig.bottomToolbarSaveButton) == null ? void 0 : _c.component) ? /* @__PURE__ */ jsx(resourceConfig.bottomToolbarSaveButton.component, __spreadValues({}, buttonProps)) : /* @__PURE__ */ jsx(DashAutoAdminSaveButton, __spreadValues({}, buttonProps));
|
|
37
|
+
} else {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return /* @__PURE__ */ jsx(DashAutoAdminSaveButton, { resourceConfig });
|
|
42
|
+
};
|
|
43
|
+
const BottomToolbarDeleteButton = (props) => {
|
|
44
|
+
var _a, _b, _c, _d, _e;
|
|
45
|
+
const { resourceConfig } = props;
|
|
46
|
+
if (!resourceConfig) return /* @__PURE__ */ jsx(DeleteButton, {});
|
|
47
|
+
if (!!((resourceConfig == null ? void 0 : resourceConfig.delete) !== false) && !!(resourceConfig == null ? void 0 : resourceConfig.bottomToolbarDeleteButton)) {
|
|
48
|
+
return /* @__PURE__ */ jsx(DeleteButton, {});
|
|
49
|
+
} else if (!!(resourceConfig == null ? void 0 : resourceConfig.bottomToolbarDeleteButton) && !!((resourceConfig == null ? void 0 : resourceConfig.bottomToolbarDeleteButton.enabled) !== false)) {
|
|
50
|
+
if (!!((_a = resourceConfig.bottomToolbarDeleteButton) == null ? void 0 : _a.props) && ((_b = resourceConfig.bottomToolbarDeleteButton.props) == null ? void 0 : _b.confirm)) {
|
|
51
|
+
return /* @__PURE__ */ jsx(
|
|
52
|
+
WithRecord,
|
|
53
|
+
{
|
|
54
|
+
render: (record) => /* @__PURE__ */ jsx(DeleteWithConfirmButton, { record })
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
return ((_c = resourceConfig.bottomToolbarDeleteButton) == null ? void 0 : _c.component) ? /* @__PURE__ */ jsx(resourceConfig.bottomToolbarDeleteButton.component, __spreadValues({}, ((_d = resourceConfig.bottomToolbarDeleteButton) == null ? void 0 : _d.props) || {})) : /* @__PURE__ */ jsx(DeleteButton, __spreadValues({}, ((_e = resourceConfig.bottomToolbarDeleteButton) == null ? void 0 : _e.props) || {}));
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
};
|
|
62
|
+
export {
|
|
63
|
+
BottomToolbarDeleteButton,
|
|
64
|
+
BottomToolbarSaveButton
|
|
65
|
+
};
|
|
@@ -1 +1,181 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
import { jsx } from "react/jsx-runtime";
|
|
33
|
+
import * as React from "react";
|
|
34
|
+
import { memo } from "react";
|
|
35
|
+
import PropTypes from "prop-types";
|
|
36
|
+
import { DASHAppConstants } from "dash-constants";
|
|
37
|
+
import {
|
|
38
|
+
useResourceContext,
|
|
39
|
+
useRecordContext,
|
|
40
|
+
useRedirect
|
|
41
|
+
} from "react-admin";
|
|
42
|
+
import useVirtualHash from "../../hooks/useVirtualHash";
|
|
43
|
+
import { IconButton, Tooltip } from "@mui/material";
|
|
44
|
+
import { Add, Edit, Visibility } from "@mui/icons-material";
|
|
45
|
+
import { DeleteWithConfirmButton } from "react-admin";
|
|
46
|
+
const URL_PREFIX = DASHAppConstants.system.URL_PREFIX;
|
|
47
|
+
const scrollStates = {
|
|
48
|
+
true: { _scrollToTop: true },
|
|
49
|
+
false: {}
|
|
50
|
+
};
|
|
51
|
+
const inferModeFromUrl = (url) => {
|
|
52
|
+
if (url.includes("create")) return "create";
|
|
53
|
+
if (url.includes("edit")) return "edit";
|
|
54
|
+
return "show";
|
|
55
|
+
};
|
|
56
|
+
const DashResourceButton = (props) => {
|
|
57
|
+
var _a, _b, _d, _e, _f;
|
|
58
|
+
const redirect = useRedirect();
|
|
59
|
+
const ComponentType = ((_a = props.children) == null ? void 0 : _a.type) || IconButton;
|
|
60
|
+
const componentProps = __spreadValues(__spreadValues({}, props), (_b = props.children) == null ? void 0 : _b.props);
|
|
61
|
+
let _c = componentProps, {
|
|
62
|
+
navigate,
|
|
63
|
+
scrollToTop,
|
|
64
|
+
mode,
|
|
65
|
+
size,
|
|
66
|
+
navigation,
|
|
67
|
+
resourceConfig,
|
|
68
|
+
record: _inputRecord,
|
|
69
|
+
resource: _inputResource,
|
|
70
|
+
showIcon = true,
|
|
71
|
+
title,
|
|
72
|
+
icon
|
|
73
|
+
} = _c, rest = __objRest(_c, [
|
|
74
|
+
"navigate",
|
|
75
|
+
"scrollToTop",
|
|
76
|
+
"mode",
|
|
77
|
+
"size",
|
|
78
|
+
"navigation",
|
|
79
|
+
"resourceConfig",
|
|
80
|
+
"record",
|
|
81
|
+
"resource",
|
|
82
|
+
"showIcon",
|
|
83
|
+
"title",
|
|
84
|
+
"icon"
|
|
85
|
+
]);
|
|
86
|
+
const resource = _inputResource || useResourceContext();
|
|
87
|
+
const record = _inputRecord || useRecordContext();
|
|
88
|
+
if (!size) {
|
|
89
|
+
size = "small";
|
|
90
|
+
}
|
|
91
|
+
if (!navigation) {
|
|
92
|
+
navigation = (resourceConfig == null ? void 0 : resourceConfig.drawer) ? mode === "edit" && ((_d = resourceConfig.drawerOptions) == null ? void 0 : _d.edit) === false ? "redirect" : mode === "show" && ((_e = resourceConfig.drawerOptions) == null ? void 0 : _e.show) === false ? "redirect" : mode === "create" && ((_f = resourceConfig.drawerOptions) == null ? void 0 : _f.create) === false ? "redirect" : "virtualhash" : "redirect";
|
|
93
|
+
}
|
|
94
|
+
if (!navigate) {
|
|
95
|
+
navigate = (_record) => {
|
|
96
|
+
const url = `${URL_PREFIX}${resource}/${navigation === "virtualhash" ? "inline" : ""}${mode === "edit" ? "/" + _record.id + "/edit" : mode === "show" ? "/" + _record.id + "/show" : mode === "create" ? "/create" : ""}`;
|
|
97
|
+
return url;
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
const { setVirtualHash } = useVirtualHash();
|
|
101
|
+
const handleOnClick = (e) => {
|
|
102
|
+
e.preventDefault();
|
|
103
|
+
e.stopPropagation();
|
|
104
|
+
if (componentProps.onClick) {
|
|
105
|
+
componentProps.onClick(e);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (navigation === "virtualhash") {
|
|
109
|
+
const vhash = navigate(record);
|
|
110
|
+
setVirtualHash(vhash);
|
|
111
|
+
}
|
|
112
|
+
if (navigation === "redirect") {
|
|
113
|
+
if (mode === "create") {
|
|
114
|
+
redirect(mode, resource);
|
|
115
|
+
} else {
|
|
116
|
+
redirect(mode, resource, record.id);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
const _styles = size === "small" ? {
|
|
121
|
+
"& .MuiButton-startIcon": { margin: 0 },
|
|
122
|
+
"& .MuiButton-text": { paddingLeft: "4px" },
|
|
123
|
+
borderRadius: "50% !important",
|
|
124
|
+
padding: 0,
|
|
125
|
+
minWidth: "30px",
|
|
126
|
+
width: "30px",
|
|
127
|
+
height: "30px",
|
|
128
|
+
overflow: "hidden"
|
|
129
|
+
} : {};
|
|
130
|
+
const _label = size === "small" ? "" : props == null ? void 0 : props.label;
|
|
131
|
+
if (mode === "destroy") {
|
|
132
|
+
return /* @__PURE__ */ jsx(Tooltip, { title: props == null ? void 0 : props.label, children: /* @__PURE__ */ jsx(DeleteWithConfirmButton, { label: _label, sx: __spreadValues({}, _styles), size, record }) });
|
|
133
|
+
} else if (mode === "custom") {
|
|
134
|
+
const _g = rest, { title: title2 } = _g, restWithoutTitle = __objRest(_g, ["title"]);
|
|
135
|
+
return /* @__PURE__ */ jsx(Tooltip, { title: props == null ? void 0 : props.label, children: /* @__PURE__ */ jsx(
|
|
136
|
+
ComponentType,
|
|
137
|
+
__spreadValues({
|
|
138
|
+
onClick: (e) => handleOnClick(e),
|
|
139
|
+
state: scrollStates[String(scrollToTop)],
|
|
140
|
+
size
|
|
141
|
+
}, restWithoutTitle)
|
|
142
|
+
) });
|
|
143
|
+
} else {
|
|
144
|
+
if (!showIcon && props.children) {
|
|
145
|
+
return React.cloneElement(props.children, __spreadValues({
|
|
146
|
+
onClick: (e) => handleOnClick(e)
|
|
147
|
+
}, props.children.props));
|
|
148
|
+
}
|
|
149
|
+
const _h = rest, { title: title2 } = _h, restWithoutTitle = __objRest(_h, ["title"]);
|
|
150
|
+
const button = /* @__PURE__ */ jsx(
|
|
151
|
+
ComponentType,
|
|
152
|
+
__spreadProps(__spreadValues({
|
|
153
|
+
onClick: (e) => handleOnClick(e),
|
|
154
|
+
state: scrollStates[String(scrollToTop)],
|
|
155
|
+
size,
|
|
156
|
+
title: props.children ? void 0 : title2
|
|
157
|
+
}, restWithoutTitle), {
|
|
158
|
+
children: showIcon && (icon ? icon : mode === "edit" ? /* @__PURE__ */ jsx(Edit, {}) : mode === "show" ? /* @__PURE__ */ jsx(Visibility, {}) : mode === "create" ? /* @__PURE__ */ jsx(Add, {}) : mode)
|
|
159
|
+
})
|
|
160
|
+
);
|
|
161
|
+
return /* @__PURE__ */ jsx(Tooltip, { title: (props == null ? void 0 : props.label) || "", children: button });
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
DashResourceButton.propTypes = {
|
|
165
|
+
icon: PropTypes.element,
|
|
166
|
+
label: PropTypes.string,
|
|
167
|
+
record: PropTypes.any,
|
|
168
|
+
scrollToTop: PropTypes.bool,
|
|
169
|
+
navigate: PropTypes.func,
|
|
170
|
+
navigation: PropTypes.string,
|
|
171
|
+
children: PropTypes.element,
|
|
172
|
+
showIcon: PropTypes.bool
|
|
173
|
+
};
|
|
174
|
+
var DashResourceButton_default = memo(
|
|
175
|
+
DashResourceButton,
|
|
176
|
+
(props, nextProps) => props.resource === nextProps.resource && (props.record && nextProps.record ? props.record.id === nextProps.record.id : props.record == nextProps.record) && // eslint-disable-line eqeqeq
|
|
177
|
+
props.label === nextProps.label && props.showIcon === nextProps.showIcon && props.icon === nextProps.icon
|
|
178
|
+
);
|
|
179
|
+
export {
|
|
180
|
+
DashResourceButton_default as default
|
|
181
|
+
};
|
|
@@ -1 +1,80 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
21
|
+
import { EditButton } from "react-admin";
|
|
22
|
+
import { DeleteButton } from "react-admin";
|
|
23
|
+
import { ShowButton } from "react-admin";
|
|
24
|
+
import DashResourceButton from "./DashResourceButton";
|
|
25
|
+
const ListViewButton = (props) => {
|
|
26
|
+
var _a, _b, _c;
|
|
27
|
+
const { resourceConfig } = props;
|
|
28
|
+
let Component = ShowButton;
|
|
29
|
+
if (!resourceConfig) return /* @__PURE__ */ jsx(Component, {});
|
|
30
|
+
if (resourceConfig.listViewButton) {
|
|
31
|
+
if (resourceConfig.listViewButton.component) Component = resourceConfig.listViewButton.component;
|
|
32
|
+
if (resourceConfig.listViewButton.enabled === false || (resourceConfig == null ? void 0 : resourceConfig.view) === false) return /* @__PURE__ */ jsx(Fragment, {});
|
|
33
|
+
if (!((_a = resourceConfig.listViewButton) == null ? void 0 : _a.size)) {
|
|
34
|
+
resourceConfig.listViewButton.size = "small";
|
|
35
|
+
}
|
|
36
|
+
;
|
|
37
|
+
}
|
|
38
|
+
const btnProps = __spreadValues({
|
|
39
|
+
mode: "show",
|
|
40
|
+
resourceConfig
|
|
41
|
+
}, ((_b = resourceConfig.listViewButton) == null ? void 0 : _b.props) || {});
|
|
42
|
+
return /* @__PURE__ */ jsx(DashResourceButton, __spreadValues(__spreadProps(__spreadValues({}, btnProps), { resourceConfig }), ((_c = resourceConfig.listDeleteButton) == null ? void 0 : _c.props) || {}));
|
|
43
|
+
};
|
|
44
|
+
const ListEditButton = (props) => {
|
|
45
|
+
var _a, _b;
|
|
46
|
+
const { resourceConfig } = props;
|
|
47
|
+
let Component = EditButton;
|
|
48
|
+
if (!resourceConfig) {
|
|
49
|
+
return /* @__PURE__ */ jsx(Component, {});
|
|
50
|
+
}
|
|
51
|
+
if (resourceConfig.listEditButton) {
|
|
52
|
+
if (resourceConfig.listEditButton.component) Component = resourceConfig.listEditButton.component;
|
|
53
|
+
if (resourceConfig.listEditButton.enabled === false || (resourceConfig == null ? void 0 : resourceConfig.edit) === false) return /* @__PURE__ */ jsx(Fragment, {});
|
|
54
|
+
if (resourceConfig.listViewButton && !((_a = resourceConfig.listViewButton) == null ? void 0 : _a.size)) {
|
|
55
|
+
resourceConfig.listViewButton.size = "small";
|
|
56
|
+
}
|
|
57
|
+
;
|
|
58
|
+
}
|
|
59
|
+
return /* @__PURE__ */ jsx(DashResourceButton, __spreadValues({ mode: "edit", resourceConfig }, ((_b = resourceConfig.listViewButton) == null ? void 0 : _b.props) || {}));
|
|
60
|
+
};
|
|
61
|
+
const ListDeleteButton = (props) => {
|
|
62
|
+
var _a, _b;
|
|
63
|
+
const { resourceConfig } = props;
|
|
64
|
+
let Component = DeleteButton;
|
|
65
|
+
if (!resourceConfig) return /* @__PURE__ */ jsx(Component, {});
|
|
66
|
+
if (resourceConfig.listDeleteButton) {
|
|
67
|
+
if (resourceConfig.listDeleteButton.component) Component = resourceConfig.listDeleteButton.component;
|
|
68
|
+
if (resourceConfig.listDeleteButton.enabled === false || (resourceConfig == null ? void 0 : resourceConfig.delete) === false) return /* @__PURE__ */ jsx(Fragment, {});
|
|
69
|
+
if (!((_a = resourceConfig.listViewButton) == null ? void 0 : _a.size)) {
|
|
70
|
+
resourceConfig.listViewButton.size = "small";
|
|
71
|
+
}
|
|
72
|
+
;
|
|
73
|
+
}
|
|
74
|
+
return /* @__PURE__ */ jsx(DashResourceButton, __spreadValues({ mode: "destroy", resourceConfig }, ((_b = resourceConfig.listDeleteButton) == null ? void 0 : _b.props) || {}));
|
|
75
|
+
};
|
|
76
|
+
export {
|
|
77
|
+
ListDeleteButton,
|
|
78
|
+
ListEditButton,
|
|
79
|
+
ListViewButton
|
|
80
|
+
};
|