@headless-adminapp/app 0.0.17-alpha.21 → 0.0.17-alpha.23
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/builders/CommandBuilder/DefaultCommandBuilder.d.ts +3 -0
- package/builders/CommandBuilder/DefaultCommandBuilder.js +9 -0
- package/builders/CommandBuilder/FormCommandBuilder.d.ts +9 -9
- package/builders/CommandBuilder/FormCommandBuilder.js +11 -9
- package/builders/CommandBuilder/SubgridCommandBuilder.d.ts +8 -27
- package/builders/CommandBuilder/SubgridCommandBuilder.js +6 -26
- package/dataform/hooks/useMainFormCommands.d.ts +1 -12
- package/dataform/hooks/useMainFormCommands.js +9 -1
- package/package.json +2 -2
|
@@ -52,15 +52,18 @@ export declare namespace DefaultCommandBuilder {
|
|
|
52
52
|
interface CreateDefaultSubgridCommandStrings {
|
|
53
53
|
new: string;
|
|
54
54
|
edit: string;
|
|
55
|
+
delete: string;
|
|
55
56
|
refresh: string;
|
|
56
57
|
export: string;
|
|
57
58
|
exportCsv: string;
|
|
58
59
|
exportExcel: string;
|
|
60
|
+
deleteRecordCommandStringSet: ViewCommandBuilder.DeleteRecordCommandStringSet;
|
|
59
61
|
}
|
|
60
62
|
interface CreateDefaultSubgridCommandOptions {
|
|
61
63
|
icons: {
|
|
62
64
|
New: Icon;
|
|
63
65
|
Edit: Icon;
|
|
66
|
+
Delete: Icon;
|
|
64
67
|
Refresh: Icon;
|
|
65
68
|
Export: Icon;
|
|
66
69
|
ExportCsv: Icon;
|
|
@@ -112,10 +112,12 @@ var DefaultCommandBuilder;
|
|
|
112
112
|
const defaultSubgridCommandStrings = {
|
|
113
113
|
new: 'New',
|
|
114
114
|
edit: 'Edit',
|
|
115
|
+
delete: 'Delete',
|
|
115
116
|
refresh: 'Refresh',
|
|
116
117
|
export: 'Export',
|
|
117
118
|
exportCsv: 'CSV',
|
|
118
119
|
exportExcel: 'Excel',
|
|
120
|
+
deleteRecordCommandStringSet: ViewCommandBuilder_1.ViewCommandBuilder.defaultDeleteRecordStringSet,
|
|
119
121
|
};
|
|
120
122
|
function createDefaultSubgridCommands({ icons, strings = defaultSubgridCommandStrings, localizedSrings, }) {
|
|
121
123
|
return [
|
|
@@ -130,6 +132,13 @@ var DefaultCommandBuilder;
|
|
|
130
132
|
text: strings.edit,
|
|
131
133
|
localizedTexts: extractLocalizedStrings(localizedSrings, (x) => x.edit),
|
|
132
134
|
}),
|
|
135
|
+
SubgridCommandBuilder_1.SubgridCommandBuilder.createDeleteRecordCommand({
|
|
136
|
+
Icon: icons.Delete,
|
|
137
|
+
text: strings.delete,
|
|
138
|
+
localizedText: extractLocalizedStrings(localizedSrings, (x) => x.delete),
|
|
139
|
+
stringSet: strings.deleteRecordCommandStringSet,
|
|
140
|
+
localizedStringSet: extractLocalizedStrings(localizedSrings, (x) => x.deleteRecordCommandStringSet),
|
|
141
|
+
}),
|
|
133
142
|
SubgridCommandBuilder_1.SubgridCommandBuilder.createRefreshCommand({
|
|
134
143
|
Icon: icons.Refresh,
|
|
135
144
|
text: strings.refresh,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EntityMainFormCommandItemExperience } from '@headless-adminapp/core/experience/form';
|
|
2
2
|
import { Localized } from '@headless-adminapp/core/types';
|
|
3
3
|
import { Icon } from '@headless-adminapp/icons';
|
|
4
4
|
export declare namespace FormCommandBuilder {
|
|
@@ -14,29 +14,29 @@ export declare namespace FormCommandBuilder {
|
|
|
14
14
|
}): EntityMainFormCommandItemExperience;
|
|
15
15
|
interface DeleteRecordCommandStringSet {
|
|
16
16
|
confirmation: {
|
|
17
|
-
title: string;
|
|
18
|
-
text: string;
|
|
17
|
+
title: string | [string, string];
|
|
18
|
+
text: string | [string, string];
|
|
19
19
|
buttonCancel: string;
|
|
20
20
|
buttonConfirm: string;
|
|
21
21
|
};
|
|
22
22
|
status: {
|
|
23
|
-
deleting: string;
|
|
23
|
+
deleting: string | [string, string];
|
|
24
24
|
};
|
|
25
25
|
successNotification: {
|
|
26
|
-
title: string;
|
|
27
|
-
text: string;
|
|
26
|
+
title: string | [string, string];
|
|
27
|
+
text: string | [string, string];
|
|
28
28
|
};
|
|
29
29
|
errorNotification: {
|
|
30
30
|
title: string;
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
const defaultDeleteRecordStringSet: DeleteRecordCommandStringSet;
|
|
34
|
-
function createDeleteCommand({ Icon, text, localizedTexts, stringSet, }: {
|
|
34
|
+
function createDeleteCommand({ Icon, text, localizedTexts, stringSet, localizedStringSet, }: {
|
|
35
35
|
Icon: Icon;
|
|
36
36
|
text: string;
|
|
37
37
|
localizedTexts?: Record<string, string>;
|
|
38
|
-
stringSet: DeleteRecordCommandStringSet
|
|
39
|
-
localizedStringSet?: Localized<DeleteRecordCommandStringSet
|
|
38
|
+
stringSet: DeleteRecordCommandStringSet;
|
|
39
|
+
localizedStringSet?: Localized<DeleteRecordCommandStringSet>;
|
|
40
40
|
}): EntityMainFormCommandItemExperience;
|
|
41
41
|
function createRefreshCommand({ Icon, text, localizedTexts, }: {
|
|
42
42
|
Icon: Icon;
|
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.FormCommandBuilder = void 0;
|
|
13
|
+
const utils_1 = require("./utils");
|
|
13
14
|
var EnabledRules;
|
|
14
15
|
(function (EnabledRules) {
|
|
15
16
|
function HasCreatePermisssion(context) {
|
|
@@ -99,7 +100,7 @@ var FormCommandBuilder;
|
|
|
99
100
|
title: 'Error',
|
|
100
101
|
},
|
|
101
102
|
};
|
|
102
|
-
function createDeleteCommand({ Icon, text, localizedTexts, stringSet, }) {
|
|
103
|
+
function createDeleteCommand({ Icon, text, localizedTexts, stringSet, localizedStringSet, }) {
|
|
103
104
|
return {
|
|
104
105
|
Icon: Icon,
|
|
105
106
|
type: 'button',
|
|
@@ -117,24 +118,25 @@ var FormCommandBuilder;
|
|
|
117
118
|
if (!recordId) {
|
|
118
119
|
return;
|
|
119
120
|
}
|
|
120
|
-
if (typeof stringSet === 'function') {
|
|
121
|
-
|
|
122
|
-
}
|
|
121
|
+
// if (typeof stringSet === 'function') {
|
|
122
|
+
// stringSet = stringSet(context);
|
|
123
|
+
// }
|
|
124
|
+
const localizeSelector = (0, utils_1.createLocalizedSelector)(stringSet, localizedStringSet, context.locale.language);
|
|
123
125
|
try {
|
|
124
126
|
const confirmResult = yield context.utility.openConfirmDialog({
|
|
125
|
-
title:
|
|
126
|
-
text:
|
|
127
|
+
title: (0, utils_1.plurialize)(1, localizeSelector((s) => s.confirmation.title)),
|
|
128
|
+
text: (0, utils_1.plurialize)(1, localizeSelector((s) => s.confirmation.text)),
|
|
127
129
|
cancelButtonLabel: stringSet.confirmation.buttonCancel,
|
|
128
130
|
confirmButtonLabel: stringSet.confirmation.buttonConfirm,
|
|
129
131
|
});
|
|
130
132
|
if (!(confirmResult === null || confirmResult === void 0 ? void 0 : confirmResult.confirmed)) {
|
|
131
133
|
return;
|
|
132
134
|
}
|
|
133
|
-
context.utility.showProgressIndicator(
|
|
135
|
+
context.utility.showProgressIndicator((0, utils_1.plurialize)(1, localizeSelector((s) => s.status.deleting)) + '...');
|
|
134
136
|
yield context.dataService.deleteRecord(context.primaryControl.logicalName, recordId);
|
|
135
137
|
context.utility.showNotification({
|
|
136
|
-
title:
|
|
137
|
-
text:
|
|
138
|
+
title: (0, utils_1.plurialize)(1, localizeSelector((s) => s.successNotification.title)),
|
|
139
|
+
text: (0, utils_1.plurialize)(1, localizeSelector((s) => s.successNotification.text)),
|
|
138
140
|
type: 'success',
|
|
139
141
|
});
|
|
140
142
|
context.primaryControl.close();
|
|
@@ -1,49 +1,31 @@
|
|
|
1
1
|
import { SubGridCommandItemExperience } from '@headless-adminapp/core/experience/view';
|
|
2
2
|
import { Localized } from '@headless-adminapp/core/types';
|
|
3
3
|
import { Icon } from '@headless-adminapp/icons';
|
|
4
|
+
import { ViewCommandBuilder } from './ViewCommandBuilder';
|
|
4
5
|
export declare namespace SubgridCommandBuilder {
|
|
5
|
-
|
|
6
|
+
function createNewRecordCommand({ Icon, text, localizedTexts, }: {
|
|
6
7
|
Icon: Icon;
|
|
7
8
|
text: string;
|
|
8
9
|
localizedTexts?: Record<string, string>;
|
|
9
10
|
}): SubGridCommandItemExperience;
|
|
10
|
-
|
|
11
|
+
function createEditRecordCommand({ Icon, text, localizedTexts, }: {
|
|
11
12
|
Icon: Icon;
|
|
12
13
|
text: string;
|
|
13
14
|
localizedTexts?: Record<string, string>;
|
|
14
15
|
}): SubGridCommandItemExperience;
|
|
15
|
-
|
|
16
|
-
confirmation: {
|
|
17
|
-
title: string | string[];
|
|
18
|
-
text: string | string[];
|
|
19
|
-
buttonCancel: string;
|
|
20
|
-
buttonConfirm: string;
|
|
21
|
-
};
|
|
22
|
-
status: {
|
|
23
|
-
deleting: string | string[];
|
|
24
|
-
};
|
|
25
|
-
successNotification: {
|
|
26
|
-
title: string | string[];
|
|
27
|
-
text: string | string[];
|
|
28
|
-
};
|
|
29
|
-
errorNotification: {
|
|
30
|
-
title: string;
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
export const defaultDeleteRecordStringSet: DeleteRecordCommandStringSet;
|
|
34
|
-
export function createDeleteRecordCommand({ Icon, localizedText, text, stringSet, localizedStringSet, }: {
|
|
16
|
+
function createDeleteRecordCommand({ Icon, localizedText, text, stringSet, localizedStringSet, }: {
|
|
35
17
|
Icon: Icon;
|
|
36
18
|
text: string;
|
|
37
19
|
localizedText?: Record<string, string>;
|
|
38
|
-
stringSet?: DeleteRecordCommandStringSet;
|
|
39
|
-
localizedStringSet?: Localized<DeleteRecordCommandStringSet>;
|
|
20
|
+
stringSet?: ViewCommandBuilder.DeleteRecordCommandStringSet;
|
|
21
|
+
localizedStringSet?: Localized<ViewCommandBuilder.DeleteRecordCommandStringSet>;
|
|
40
22
|
}): SubGridCommandItemExperience;
|
|
41
|
-
|
|
23
|
+
function createRefreshCommand({ Icon, localizedTexts, text, }: {
|
|
42
24
|
Icon: Icon;
|
|
43
25
|
text: string;
|
|
44
26
|
localizedTexts?: Record<string, string>;
|
|
45
27
|
}): SubGridCommandItemExperience;
|
|
46
|
-
|
|
28
|
+
function createExportCommand({ button, csv, excel, }: {
|
|
47
29
|
button: {
|
|
48
30
|
Icon: Icon;
|
|
49
31
|
text: string;
|
|
@@ -60,5 +42,4 @@ export declare namespace SubgridCommandBuilder {
|
|
|
60
42
|
localizedTexts?: Record<string, string>;
|
|
61
43
|
};
|
|
62
44
|
}): SubGridCommandItemExperience;
|
|
63
|
-
export {};
|
|
64
45
|
}
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.SubgridCommandBuilder = void 0;
|
|
13
13
|
const utils_1 = require("../utils");
|
|
14
14
|
const utils_2 = require("./utils");
|
|
15
|
+
const ViewCommandBuilder_1 = require("./ViewCommandBuilder");
|
|
15
16
|
var EnabledRules;
|
|
16
17
|
(function (EnabledRules) {
|
|
17
18
|
function HasCreatePermisssion(context) {
|
|
@@ -49,7 +50,7 @@ var SubgridCommandBuilder;
|
|
|
49
50
|
onClick: (context) => {
|
|
50
51
|
if (context.secondaryControl.associated) {
|
|
51
52
|
context.navigation.openForm({
|
|
52
|
-
logicalName: context.
|
|
53
|
+
logicalName: context.secondaryControl.schema.logicalName,
|
|
53
54
|
parameters: {
|
|
54
55
|
[context.secondaryControl.associated.refAttributeName]: {
|
|
55
56
|
id: context.secondaryControl.associated.id,
|
|
@@ -61,7 +62,7 @@ var SubgridCommandBuilder;
|
|
|
61
62
|
}
|
|
62
63
|
else {
|
|
63
64
|
context.navigation.openForm({
|
|
64
|
-
logicalName: context.
|
|
65
|
+
logicalName: context.secondaryControl.schema.logicalName,
|
|
65
66
|
});
|
|
66
67
|
}
|
|
67
68
|
},
|
|
@@ -92,28 +93,7 @@ var SubgridCommandBuilder;
|
|
|
92
93
|
msg = msg.replace('{count}', count.toString());
|
|
93
94
|
return msg;
|
|
94
95
|
}
|
|
95
|
-
|
|
96
|
-
confirmation: {
|
|
97
|
-
text: [
|
|
98
|
-
'Are you sure you want to delete this record?',
|
|
99
|
-
'Are you sure you want to delete selected records?',
|
|
100
|
-
],
|
|
101
|
-
title: ['Delete record', 'Delete records'],
|
|
102
|
-
buttonConfirm: 'Delete',
|
|
103
|
-
buttonCancel: 'Cancel',
|
|
104
|
-
},
|
|
105
|
-
status: {
|
|
106
|
-
deleting: ['Deleting record', 'Deleting records'],
|
|
107
|
-
},
|
|
108
|
-
successNotification: {
|
|
109
|
-
title: ['Record deleted', 'Records deleted'],
|
|
110
|
-
text: ['Record deleted successfully', 'Records deleted successfully'],
|
|
111
|
-
},
|
|
112
|
-
errorNotification: {
|
|
113
|
-
title: 'Error',
|
|
114
|
-
},
|
|
115
|
-
};
|
|
116
|
-
function createDeleteRecordCommand({ Icon, localizedText, text, stringSet = SubgridCommandBuilder.defaultDeleteRecordStringSet, localizedStringSet, }) {
|
|
96
|
+
function createDeleteRecordCommand({ Icon, localizedText, text, stringSet = ViewCommandBuilder_1.ViewCommandBuilder.defaultDeleteRecordStringSet, localizedStringSet, }) {
|
|
117
97
|
return {
|
|
118
98
|
type: 'button',
|
|
119
99
|
Icon,
|
|
@@ -139,14 +119,14 @@ var SubgridCommandBuilder;
|
|
|
139
119
|
}
|
|
140
120
|
context.utility.showProgressIndicator(plurialize(recordIds.length, localizeSelector((s) => s.status.deleting)) + '...');
|
|
141
121
|
for (const recordId of recordIds) {
|
|
142
|
-
yield context.dataService.deleteRecord(context.
|
|
122
|
+
yield context.dataService.deleteRecord(context.secondaryControl.logicalName, recordId);
|
|
143
123
|
}
|
|
144
124
|
context.utility.showNotification({
|
|
145
125
|
title: plurialize(recordIds.length, localizeSelector((s) => s.successNotification.title)),
|
|
146
126
|
text: plurialize(recordIds.length, localizeSelector((s) => s.successNotification.text)),
|
|
147
127
|
type: 'success',
|
|
148
128
|
});
|
|
149
|
-
|
|
129
|
+
context.secondaryControl.refresh();
|
|
150
130
|
}
|
|
151
131
|
catch (error) {
|
|
152
132
|
context.utility.showNotification({
|
|
@@ -1,16 +1,5 @@
|
|
|
1
1
|
import { EntityFormCommandContext } from '@headless-adminapp/core/experience/form';
|
|
2
2
|
import { CommandItemState } from '../../command';
|
|
3
|
-
export declare function useFormControlContext():
|
|
4
|
-
data: any;
|
|
5
|
-
logicalName: string;
|
|
6
|
-
schema: import("@headless-adminapp/core/schema").Schema<import("@headless-adminapp/core/schema").SchemaAttributes>;
|
|
7
|
-
form: import("@headless-adminapp/core/experience/form").Form<import("@headless-adminapp/core/schema").SchemaAttributes>;
|
|
8
|
-
formId: string;
|
|
9
|
-
originalData: import("@headless-adminapp/core/transport").Data<import("@headless-adminapp/core/schema").InferredSchemaType<import("@headless-adminapp/core/schema").SchemaAttributes>> | null;
|
|
10
|
-
recordId: string | number;
|
|
11
|
-
refresh: () => Promise<void>;
|
|
12
|
-
save: (mode?: import("@headless-adminapp/core/experience/form").SaveMode) => Promise<void>;
|
|
13
|
-
readonly: boolean | undefined;
|
|
14
|
-
};
|
|
3
|
+
export declare function useFormControlContext(): EntityFormCommandContext['primaryControl'];
|
|
15
4
|
export declare function useMainFormCommandHandlerContext(): EntityFormCommandContext;
|
|
16
5
|
export declare function useMainFormCommands(): CommandItemState[][];
|
|
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useFormControlContext = useFormControlContext;
|
|
4
4
|
exports.useMainFormCommandHandlerContext = useMainFormCommandHandlerContext;
|
|
5
5
|
exports.useMainFormCommands = useMainFormCommands;
|
|
6
|
+
const route_1 = require("@headless-adminapp/app/route");
|
|
7
|
+
const react_1 = require("react");
|
|
6
8
|
const command_1 = require("../../command");
|
|
7
9
|
const context_1 = require("../../mutable/context");
|
|
8
10
|
const context_2 = require("../context");
|
|
@@ -13,6 +15,7 @@ const useFormSave_1 = require("./useFormSave");
|
|
|
13
15
|
const useFormSchema_1 = require("./useFormSchema");
|
|
14
16
|
const useRecordId_1 = require("./useRecordId");
|
|
15
17
|
function useFormControlContext() {
|
|
18
|
+
var _a;
|
|
16
19
|
const schema = (0, useFormSchema_1.useDataFormSchema)();
|
|
17
20
|
const form = (0, context_1.useContextSelector)(context_2.DataFormContext, (state) => state.form);
|
|
18
21
|
const originalData = (0, useFormRecord_1.useFormRecord)();
|
|
@@ -20,8 +23,12 @@ function useFormControlContext() {
|
|
|
20
23
|
const save = (0, useFormSave_1.useFormSave)();
|
|
21
24
|
const refresh = (0, context_1.useContextSelector)(context_2.DataFormContext, (state) => state.refresh);
|
|
22
25
|
const formInstance = (0, useFormInstance_1.useFormInstance)();
|
|
23
|
-
const readonly = (0, useFormIsReadonly_1.useFormIsReadonly)();
|
|
26
|
+
const readonly = (_a = (0, useFormIsReadonly_1.useFormIsReadonly)()) !== null && _a !== void 0 ? _a : false;
|
|
24
27
|
const data = formInstance.watch();
|
|
28
|
+
const router = (0, route_1.useRouter)();
|
|
29
|
+
const close = (0, react_1.useCallback)(() => {
|
|
30
|
+
router.back();
|
|
31
|
+
}, [router]);
|
|
25
32
|
return {
|
|
26
33
|
data,
|
|
27
34
|
logicalName: schema.logicalName,
|
|
@@ -33,6 +40,7 @@ function useFormControlContext() {
|
|
|
33
40
|
refresh,
|
|
34
41
|
save,
|
|
35
42
|
readonly,
|
|
43
|
+
close,
|
|
36
44
|
};
|
|
37
45
|
}
|
|
38
46
|
function useMainFormCommandHandlerContext() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@headless-adminapp/app",
|
|
3
|
-
"version": "0.0.17-alpha.
|
|
3
|
+
"version": "0.0.17-alpha.23",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"react-hook-form": "7.52.2",
|
|
40
40
|
"yup": "^1.4.0"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "ff177d1491eff81fa8ab0cdfc7e5e1d1b3edc18b"
|
|
43
43
|
}
|