adminforth 1.2.33 → 1.2.35
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/dataConnectors/clickhouse.ts +3 -1
- package/dist/dataConnectors/clickhouse.js +1 -1
- package/dist/modules/configValidator.js +11 -0
- package/dist/spa/spa/src/components/CustomDatePicker.vue +3 -3
- package/dist/spa/spa/src/components/CustomRangePicker.vue +1 -1
- package/modules/configValidator.ts +33 -13
- package/package.json +1 -1
- package/spa/src/components/CustomDatePicker.vue +3 -3
- package/spa/src/components/CustomRangePicker.vue +1 -1
- package/types/AdminForthConfig.ts +1 -1
|
@@ -190,7 +190,9 @@ class ClickhouseConnector extends AdminForthBaseConnector implements IAdminForth
|
|
|
190
190
|
let field = f.field;
|
|
191
191
|
let operator = this.OperatorsMap[f.operator];
|
|
192
192
|
if (f.operator == AdminForthFilterOperators.IN || f.operator == AdminForthFilterOperators.NIN) {
|
|
193
|
-
placeholder = `(${f.value.map((_, j) => `p${i}_${j}
|
|
193
|
+
placeholder = `(${f.value.map((_, j) => `{p${i}_${j}:${
|
|
194
|
+
column._underlineType
|
|
195
|
+
}}`).join(', ')})`;
|
|
194
196
|
}
|
|
195
197
|
|
|
196
198
|
return `${field} ${operator} ${placeholder}`
|
|
@@ -194,7 +194,7 @@ class ClickhouseConnector extends AdminForthBaseConnector {
|
|
|
194
194
|
let field = f.field;
|
|
195
195
|
let operator = this.OperatorsMap[f.operator];
|
|
196
196
|
if (f.operator == AdminForthFilterOperators.IN || f.operator == AdminForthFilterOperators.NIN) {
|
|
197
|
-
placeholder = `(${f.value.map((_, j) => `p${i}_${j}`).join(', ')})`;
|
|
197
|
+
placeholder = `(${f.value.map((_, j) => `{p${i}_${j}:${column._underlineType}}`).join(', ')})`;
|
|
198
198
|
}
|
|
199
199
|
return `${field} ${operator} ${placeholder}`;
|
|
200
200
|
}).join(' AND ')}` : '';
|
|
@@ -248,14 +248,25 @@ export default class ConfigValidator {
|
|
|
248
248
|
allowed: (_b) => __awaiter(this, [_b], void 0, function* ({ resource, adminUser, allowedActions }) { return allowedActions.delete; }),
|
|
249
249
|
action: (_c) => __awaiter(this, [_c], void 0, function* ({ selectedIds, adminUser }) {
|
|
250
250
|
const connector = this.adminforth.connectors[res.dataSource];
|
|
251
|
+
let error = null;
|
|
251
252
|
yield Promise.all(selectedIds.map((recordId) => __awaiter(this, void 0, void 0, function* () {
|
|
252
253
|
const record = yield connector.getRecordByPrimaryKey(res, recordId);
|
|
254
|
+
yield Promise.all(res.hooks.delete.beforeSave.map((hook) => __awaiter(this, void 0, void 0, function* () {
|
|
255
|
+
const resp = yield hook({ resource: res, record, adminUser });
|
|
256
|
+
if (!error && resp.error) {
|
|
257
|
+
error = resp.error;
|
|
258
|
+
}
|
|
259
|
+
})));
|
|
253
260
|
yield connector.deleteRecord({ resource: res, recordId });
|
|
254
261
|
// call afterDelete hook
|
|
255
262
|
yield Promise.all(res.hooks.delete.afterSave.map((hook) => __awaiter(this, void 0, void 0, function* () {
|
|
256
263
|
yield hook({ resource: res, record, adminUser });
|
|
257
264
|
})));
|
|
258
265
|
})));
|
|
266
|
+
if (error) {
|
|
267
|
+
return { error, ok: false };
|
|
268
|
+
}
|
|
269
|
+
return { ok: true };
|
|
259
270
|
})
|
|
260
271
|
});
|
|
261
272
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div>
|
|
3
|
-
<div class="
|
|
3
|
+
<div class="grid w-40 gap-4 mb-2">
|
|
4
4
|
<div>
|
|
5
5
|
<label for="start-time" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">{{ label }}</label>
|
|
6
6
|
|
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
|
|
12
12
|
<input ref="datepickerStartEl" type="text"
|
|
13
13
|
class="bg-gray-50 border leading-none border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
|
14
|
-
placeholder="
|
|
14
|
+
placeholder="Select date">
|
|
15
15
|
</div>
|
|
16
16
|
</div>
|
|
17
17
|
</div>
|
|
18
18
|
|
|
19
19
|
<div>
|
|
20
|
-
<div class="
|
|
20
|
+
<div class="grid w-40 gap-4 mb-2" :class="{hidden: !showTimeInputs}">
|
|
21
21
|
<div>
|
|
22
22
|
<div class="relative">
|
|
23
23
|
<div class="absolute inset-y-0 end-0 top-0 flex items-center pe-3.5 pointer-events-none">
|
|
@@ -269,20 +269,40 @@ export default class ConfigValidator implements IConfigValidator {
|
|
|
269
269
|
allowed: async ({ resource, adminUser, allowedActions }) => { return allowedActions.delete },
|
|
270
270
|
action: async ({ selectedIds, adminUser }) => {
|
|
271
271
|
const connector = this.adminforth.connectors[res.dataSource];
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
272
|
+
let error = null;
|
|
273
|
+
|
|
274
|
+
await Promise.all(
|
|
275
|
+
selectedIds.map(async (recordId) => {
|
|
276
|
+
const record = await connector.getRecordByPrimaryKey(res, recordId);
|
|
277
|
+
|
|
278
|
+
await Promise.all(
|
|
279
|
+
(res.hooks.delete.beforeSave as AfterSaveFunction[]).map(
|
|
280
|
+
async (hook) => {
|
|
281
|
+
const resp = await hook({ resource: res, record, adminUser });
|
|
282
|
+
if (!error && resp.error) {
|
|
283
|
+
error = resp.error;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
)
|
|
282
287
|
)
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
288
|
+
|
|
289
|
+
await connector.deleteRecord({ resource: res, recordId });
|
|
290
|
+
// call afterDelete hook
|
|
291
|
+
await Promise.all(
|
|
292
|
+
(res.hooks.delete.afterSave as AfterSaveFunction[]).map(
|
|
293
|
+
async (hook) => {
|
|
294
|
+
await hook({ resource: res, record, adminUser });
|
|
295
|
+
}
|
|
296
|
+
)
|
|
297
|
+
)
|
|
298
|
+
|
|
299
|
+
})
|
|
300
|
+
);
|
|
301
|
+
|
|
302
|
+
if (error) {
|
|
303
|
+
return { error, ok: false };
|
|
304
|
+
}
|
|
305
|
+
return { ok: true };
|
|
286
306
|
}
|
|
287
307
|
});
|
|
288
308
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div>
|
|
3
|
-
<div class="
|
|
3
|
+
<div class="grid w-40 gap-4 mb-2">
|
|
4
4
|
<div>
|
|
5
5
|
<label for="start-time" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">{{ label }}</label>
|
|
6
6
|
|
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
|
|
12
12
|
<input ref="datepickerStartEl" type="text"
|
|
13
13
|
class="bg-gray-50 border leading-none border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
|
14
|
-
placeholder="
|
|
14
|
+
placeholder="Select date">
|
|
15
15
|
</div>
|
|
16
16
|
</div>
|
|
17
17
|
</div>
|
|
18
18
|
|
|
19
19
|
<div>
|
|
20
|
-
<div class="
|
|
20
|
+
<div class="grid w-40 gap-4 mb-2" :class="{hidden: !showTimeInputs}">
|
|
21
21
|
<div>
|
|
22
22
|
<div class="relative">
|
|
23
23
|
<div class="absolute inset-y-0 end-0 top-0 flex items-center pe-3.5 pointer-events-none">
|
|
@@ -680,7 +680,7 @@ export type AdminForthBulkAction = {
|
|
|
680
680
|
* Callback which will be called on backend when user clicks on action button.
|
|
681
681
|
* It should return Promise which will be resolved when action is done.
|
|
682
682
|
*/
|
|
683
|
-
action: ({ resource, selectedIds, adminUser }: { resource: AdminForthResource, selectedIds: Array<any>, adminUser: AdminUser }) => Promise<
|
|
683
|
+
action: ({ resource, selectedIds, adminUser }: { resource: AdminForthResource, selectedIds: Array<any>, adminUser: AdminUser }) => Promise<{ ok: boolean, error?: string }>,
|
|
684
684
|
|
|
685
685
|
/**
|
|
686
686
|
* Confirmation message which will be displayed to user before action is executed.
|