@headless-adminapp/app 0.0.17-alpha.7 → 0.0.17-alpha.8
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/CommandBuilder.d.ts +10 -0
- package/builders/CommandBuilder/CommandBuilder.js +14 -0
- package/builders/CommandBuilder/DefaultCommandBuilder.d.ts +79 -0
- package/builders/CommandBuilder/DefaultCommandBuilder.js +173 -0
- package/builders/CommandBuilder/FormCommandBuilder.d.ts +45 -0
- package/builders/CommandBuilder/FormCommandBuilder.js +145 -0
- package/builders/CommandBuilder/SubgridCommandBuilder.d.ts +64 -0
- package/builders/CommandBuilder/SubgridCommandBuilder.js +170 -0
- package/builders/CommandBuilder/ViewCommandBuilder.d.ts +63 -0
- package/builders/CommandBuilder/ViewCommandBuilder.js +250 -0
- package/builders/CommandBuilder/index.d.ts +1 -0
- package/builders/CommandBuilder/index.js +5 -0
- package/builders/CommandBuilder/utils.d.ts +3 -0
- package/builders/CommandBuilder/utils.js +21 -0
- package/builders/SchemaExperienceBuilder.d.ts +2 -5
- package/builders/SchemaExperienceBuilder.js +16 -16
- package/builders/index.d.ts +1 -1
- package/builders/index.js +1 -2
- package/command/hooks/useCommands.d.ts +1 -1
- package/command/hooks/useCommands.js +1 -1
- package/dataform/hooks/useLoadFormGridPage.js +7 -1
- package/dataform/utils/index.js +19 -19
- package/datagrid/DataGridProvider/transformViewColumns.js +4 -4
- package/datagrid/context.d.ts +1 -1
- package/datagrid/hooks/useGridCommands.d.ts +3 -0
- package/datagrid/hooks/useGridCommands.js +3 -0
- package/datagrid/hooks/useMainGridCommands.js +12 -3
- package/datagrid/hooks/useSubGridCommands.js +12 -3
- package/locale/utils.d.ts +5 -0
- package/locale/utils.js +7 -0
- package/metadata/hooks/useExperienceViewCommands.d.ts +1 -1
- package/metadata/hooks/useExperienceViewCommands.js +7 -1
- package/metadata/hooks/useExperienceViewSubgridCommands.d.ts +1 -1
- package/metadata/hooks/useExperienceViewSubgridCommands.js +7 -1
- package/package.json +2 -2
- package/store/SchemaExperienceStore.d.ts +3 -3
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DefaultCommandBuilder } from './DefaultCommandBuilder';
|
|
2
|
+
import { FormCommandBuilder } from './FormCommandBuilder';
|
|
3
|
+
import { SubgridCommandBuilder } from './SubgridCommandBuilder';
|
|
4
|
+
import { ViewCommandBuilder } from './ViewCommandBuilder';
|
|
5
|
+
export declare namespace CommandBuilder {
|
|
6
|
+
const View: typeof ViewCommandBuilder;
|
|
7
|
+
const Form: typeof FormCommandBuilder;
|
|
8
|
+
const Subgrid: typeof SubgridCommandBuilder;
|
|
9
|
+
const Default: typeof DefaultCommandBuilder;
|
|
10
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CommandBuilder = void 0;
|
|
4
|
+
const DefaultCommandBuilder_1 = require("./DefaultCommandBuilder");
|
|
5
|
+
const FormCommandBuilder_1 = require("./FormCommandBuilder");
|
|
6
|
+
const SubgridCommandBuilder_1 = require("./SubgridCommandBuilder");
|
|
7
|
+
const ViewCommandBuilder_1 = require("./ViewCommandBuilder");
|
|
8
|
+
var CommandBuilder;
|
|
9
|
+
(function (CommandBuilder) {
|
|
10
|
+
CommandBuilder.View = ViewCommandBuilder_1.ViewCommandBuilder;
|
|
11
|
+
CommandBuilder.Form = FormCommandBuilder_1.FormCommandBuilder;
|
|
12
|
+
CommandBuilder.Subgrid = SubgridCommandBuilder_1.SubgridCommandBuilder;
|
|
13
|
+
CommandBuilder.Default = DefaultCommandBuilder_1.DefaultCommandBuilder;
|
|
14
|
+
})(CommandBuilder || (exports.CommandBuilder = CommandBuilder = {}));
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Localized } from '@headless-adminapp/core/types';
|
|
2
|
+
import { Icon } from '@headless-adminapp/icons';
|
|
3
|
+
import { ViewCommandBuilder } from './ViewCommandBuilder';
|
|
4
|
+
export declare namespace DefaultCommandBuilder {
|
|
5
|
+
interface CreateDefaultViewCommandStrings {
|
|
6
|
+
new: string;
|
|
7
|
+
edit: string;
|
|
8
|
+
delete: string;
|
|
9
|
+
refresh: string;
|
|
10
|
+
export: string;
|
|
11
|
+
exportCsv: string;
|
|
12
|
+
exportExcel: string;
|
|
13
|
+
deleteRecordCommandStringSet: ViewCommandBuilder.DeleteRecordCommandStringSet;
|
|
14
|
+
}
|
|
15
|
+
export const defaultViewCommandStrings: CreateDefaultViewCommandStrings;
|
|
16
|
+
interface CreateDefaultViewCommandOptions {
|
|
17
|
+
icons: {
|
|
18
|
+
New: Icon;
|
|
19
|
+
Edit: Icon;
|
|
20
|
+
Delete: Icon;
|
|
21
|
+
Refresh: Icon;
|
|
22
|
+
Export: Icon;
|
|
23
|
+
ExportCsv: Icon;
|
|
24
|
+
ExportExcel: Icon;
|
|
25
|
+
};
|
|
26
|
+
strings?: CreateDefaultViewCommandStrings;
|
|
27
|
+
localizedSrings?: Localized<CreateDefaultViewCommandStrings>;
|
|
28
|
+
}
|
|
29
|
+
export function createDefaultViewCommands({ icons, strings, localizedSrings, }: CreateDefaultViewCommandOptions): import("@headless-adminapp/core/experience/view").EntityMainGridCommandItemExperience[][];
|
|
30
|
+
interface CreateDefaultFormCommandStrings {
|
|
31
|
+
save: string;
|
|
32
|
+
saveAndClose: string;
|
|
33
|
+
refresh: string;
|
|
34
|
+
}
|
|
35
|
+
interface CreateDefaultFormCommandOptions {
|
|
36
|
+
icons: {
|
|
37
|
+
Save: Icon;
|
|
38
|
+
SaveAndClose: Icon;
|
|
39
|
+
Refresh: Icon;
|
|
40
|
+
};
|
|
41
|
+
strings?: CreateDefaultFormCommandStrings;
|
|
42
|
+
localizedSrings?: Localized<CreateDefaultFormCommandStrings>;
|
|
43
|
+
}
|
|
44
|
+
export const defaultFormCommandStrings: CreateDefaultFormCommandStrings;
|
|
45
|
+
export function createDefaultFormCommands({ icons, strings, localizedSrings, }: CreateDefaultFormCommandOptions): import("@headless-adminapp/core/experience/form").EntityMainFormCommandItemExperience[][];
|
|
46
|
+
interface CreateDefaultSubgridCommandStrings {
|
|
47
|
+
new: string;
|
|
48
|
+
edit: string;
|
|
49
|
+
refresh: string;
|
|
50
|
+
export: string;
|
|
51
|
+
exportCsv: string;
|
|
52
|
+
exportExcel: string;
|
|
53
|
+
}
|
|
54
|
+
interface CreateDefaultSubgridCommandOptions {
|
|
55
|
+
icons: {
|
|
56
|
+
New: Icon;
|
|
57
|
+
Edit: Icon;
|
|
58
|
+
Refresh: Icon;
|
|
59
|
+
Export: Icon;
|
|
60
|
+
ExportCsv: Icon;
|
|
61
|
+
ExportExcel: Icon;
|
|
62
|
+
};
|
|
63
|
+
strings?: CreateDefaultSubgridCommandStrings;
|
|
64
|
+
localizedSrings?: Localized<CreateDefaultSubgridCommandStrings>;
|
|
65
|
+
}
|
|
66
|
+
export function createDefaultSubgridCommands({ icons, strings, localizedSrings, }: CreateDefaultSubgridCommandOptions): (import("@headless-adminapp/core/experience/view").EntityMainGridCommandItemExperience[] | import("@headless-adminapp/core/experience/view").SubGridCommandItemExperience[])[];
|
|
67
|
+
type CreateDefaultCommandStrings = CreateDefaultViewCommandStrings & CreateDefaultFormCommandStrings & CreateDefaultSubgridCommandStrings;
|
|
68
|
+
interface CreateDefaultCommandOptions {
|
|
69
|
+
icons: CreateDefaultViewCommandOptions['icons'] & CreateDefaultFormCommandOptions['icons'] & CreateDefaultSubgridCommandOptions['icons'];
|
|
70
|
+
strings?: CreateDefaultCommandStrings;
|
|
71
|
+
localizedSrings?: Localized<CreateDefaultCommandStrings>;
|
|
72
|
+
}
|
|
73
|
+
export function createDefaultCommands({ icons, strings, localizedSrings, }: CreateDefaultCommandOptions): {
|
|
74
|
+
view: import("@headless-adminapp/core/experience/view").EntityMainGridCommandItemExperience[][];
|
|
75
|
+
form: import("@headless-adminapp/core/experience/form").EntityMainFormCommandItemExperience[][];
|
|
76
|
+
subgrid: (import("@headless-adminapp/core/experience/view").EntityMainGridCommandItemExperience[] | import("@headless-adminapp/core/experience/view").SubGridCommandItemExperience[])[];
|
|
77
|
+
};
|
|
78
|
+
export {};
|
|
79
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefaultCommandBuilder = void 0;
|
|
4
|
+
const FormCommandBuilder_1 = require("./FormCommandBuilder");
|
|
5
|
+
const SubgridCommandBuilder_1 = require("./SubgridCommandBuilder");
|
|
6
|
+
const ViewCommandBuilder_1 = require("./ViewCommandBuilder");
|
|
7
|
+
var DefaultCommandBuilder;
|
|
8
|
+
(function (DefaultCommandBuilder) {
|
|
9
|
+
DefaultCommandBuilder.defaultViewCommandStrings = {
|
|
10
|
+
new: 'New',
|
|
11
|
+
edit: 'Edit',
|
|
12
|
+
delete: 'Delete',
|
|
13
|
+
deleteRecordCommandStringSet: ViewCommandBuilder_1.ViewCommandBuilder.defaultDeleteRecordStringSet,
|
|
14
|
+
refresh: 'Refresh',
|
|
15
|
+
export: 'Export',
|
|
16
|
+
exportCsv: 'CSV',
|
|
17
|
+
exportExcel: 'Excel',
|
|
18
|
+
};
|
|
19
|
+
function extractLocalizedStrings(localizedStrings, selector) {
|
|
20
|
+
if (!localizedStrings) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
return Object.keys(localizedStrings).reduce((p, key) => {
|
|
24
|
+
p[key] = selector(localizedStrings[key]);
|
|
25
|
+
return p;
|
|
26
|
+
}, {});
|
|
27
|
+
}
|
|
28
|
+
function createDefaultViewCommands({ icons, strings = DefaultCommandBuilder.defaultViewCommandStrings, localizedSrings, }) {
|
|
29
|
+
return [
|
|
30
|
+
[
|
|
31
|
+
ViewCommandBuilder_1.ViewCommandBuilder.createNewRecordCommand({
|
|
32
|
+
Icon: icons.New,
|
|
33
|
+
text: strings.new,
|
|
34
|
+
localizedTexts: extractLocalizedStrings(localizedSrings, x => x.new),
|
|
35
|
+
}),
|
|
36
|
+
ViewCommandBuilder_1.ViewCommandBuilder.createEditRecordCommand({
|
|
37
|
+
Icon: icons.Edit,
|
|
38
|
+
text: strings.edit,
|
|
39
|
+
localizedTexts: extractLocalizedStrings(localizedSrings, x => x.edit),
|
|
40
|
+
}),
|
|
41
|
+
ViewCommandBuilder_1.ViewCommandBuilder.createDeleteRecordCommand({
|
|
42
|
+
Icon: icons.Delete,
|
|
43
|
+
text: strings.delete,
|
|
44
|
+
localizedText: extractLocalizedStrings(localizedSrings, x => x.delete),
|
|
45
|
+
stringSet: strings.deleteRecordCommandStringSet,
|
|
46
|
+
localizedStringSet: extractLocalizedStrings(localizedSrings, x => x.deleteRecordCommandStringSet),
|
|
47
|
+
}),
|
|
48
|
+
ViewCommandBuilder_1.ViewCommandBuilder.createRefreshCommand({
|
|
49
|
+
Icon: icons.Refresh,
|
|
50
|
+
text: strings.refresh,
|
|
51
|
+
localizedTexts: extractLocalizedStrings(localizedSrings, x => x.refresh),
|
|
52
|
+
}),
|
|
53
|
+
],
|
|
54
|
+
[
|
|
55
|
+
ViewCommandBuilder_1.ViewCommandBuilder.createExportCommand({
|
|
56
|
+
button: {
|
|
57
|
+
Icon: icons.Export,
|
|
58
|
+
text: strings.export,
|
|
59
|
+
localizedTexts: extractLocalizedStrings(localizedSrings, x => x.export),
|
|
60
|
+
},
|
|
61
|
+
csv: {
|
|
62
|
+
Icon: icons.ExportCsv,
|
|
63
|
+
text: strings.exportCsv,
|
|
64
|
+
localizedTexts: extractLocalizedStrings(localizedSrings, x => x.exportCsv),
|
|
65
|
+
},
|
|
66
|
+
excel: {
|
|
67
|
+
Icon: icons.ExportExcel,
|
|
68
|
+
text: strings.exportCsv,
|
|
69
|
+
localizedTexts: extractLocalizedStrings(localizedSrings, x => x.exportExcel),
|
|
70
|
+
},
|
|
71
|
+
}),
|
|
72
|
+
],
|
|
73
|
+
];
|
|
74
|
+
}
|
|
75
|
+
DefaultCommandBuilder.createDefaultViewCommands = createDefaultViewCommands;
|
|
76
|
+
DefaultCommandBuilder.defaultFormCommandStrings = {
|
|
77
|
+
save: 'Save',
|
|
78
|
+
saveAndClose: 'Save & Close',
|
|
79
|
+
refresh: 'Refresh',
|
|
80
|
+
};
|
|
81
|
+
function createDefaultFormCommands({ icons, strings = DefaultCommandBuilder.defaultFormCommandStrings, localizedSrings, }) {
|
|
82
|
+
return [
|
|
83
|
+
[
|
|
84
|
+
FormCommandBuilder_1.FormCommandBuilder.createSaveCommand({
|
|
85
|
+
Icon: icons.Save,
|
|
86
|
+
text: strings.save,
|
|
87
|
+
localizedTexts: extractLocalizedStrings(localizedSrings, x => x.save),
|
|
88
|
+
}),
|
|
89
|
+
FormCommandBuilder_1.FormCommandBuilder.createSaveAndCloseCommand({
|
|
90
|
+
Icon: icons.SaveAndClose,
|
|
91
|
+
text: strings.saveAndClose,
|
|
92
|
+
localizedTexts: extractLocalizedStrings(localizedSrings, x => x.saveAndClose),
|
|
93
|
+
}),
|
|
94
|
+
FormCommandBuilder_1.FormCommandBuilder.createRefreshCommand({
|
|
95
|
+
Icon: icons.Refresh,
|
|
96
|
+
text: strings.refresh,
|
|
97
|
+
localizedTexts: extractLocalizedStrings(localizedSrings, x => x.refresh),
|
|
98
|
+
}),
|
|
99
|
+
],
|
|
100
|
+
];
|
|
101
|
+
}
|
|
102
|
+
DefaultCommandBuilder.createDefaultFormCommands = createDefaultFormCommands;
|
|
103
|
+
const defaultSubgridCommandStrings = {
|
|
104
|
+
new: 'New',
|
|
105
|
+
edit: 'Edit',
|
|
106
|
+
refresh: 'Refresh',
|
|
107
|
+
export: 'Export',
|
|
108
|
+
exportCsv: 'CSV',
|
|
109
|
+
exportExcel: 'Excel',
|
|
110
|
+
};
|
|
111
|
+
function createDefaultSubgridCommands({ icons, strings = defaultSubgridCommandStrings, localizedSrings, }) {
|
|
112
|
+
return [
|
|
113
|
+
[
|
|
114
|
+
SubgridCommandBuilder_1.SubgridCommandBuilder.createNewRecordCommand({
|
|
115
|
+
Icon: icons.New,
|
|
116
|
+
text: strings.new,
|
|
117
|
+
localizedTexts: extractLocalizedStrings(localizedSrings, x => x.new),
|
|
118
|
+
}),
|
|
119
|
+
SubgridCommandBuilder_1.SubgridCommandBuilder.createEditRecordCommand({
|
|
120
|
+
Icon: icons.Edit,
|
|
121
|
+
text: strings.edit,
|
|
122
|
+
localizedTexts: extractLocalizedStrings(localizedSrings, x => x.edit),
|
|
123
|
+
}),
|
|
124
|
+
SubgridCommandBuilder_1.SubgridCommandBuilder.createRefreshCommand({
|
|
125
|
+
Icon: icons.Refresh,
|
|
126
|
+
text: strings.refresh,
|
|
127
|
+
localizedTexts: extractLocalizedStrings(localizedSrings, x => x.refresh),
|
|
128
|
+
}),
|
|
129
|
+
],
|
|
130
|
+
[
|
|
131
|
+
ViewCommandBuilder_1.ViewCommandBuilder.createExportCommand({
|
|
132
|
+
button: {
|
|
133
|
+
Icon: icons.Export,
|
|
134
|
+
text: strings.export,
|
|
135
|
+
localizedTexts: extractLocalizedStrings(localizedSrings, x => x.export),
|
|
136
|
+
},
|
|
137
|
+
csv: {
|
|
138
|
+
Icon: icons.ExportCsv,
|
|
139
|
+
text: strings.exportCsv,
|
|
140
|
+
localizedTexts: extractLocalizedStrings(localizedSrings, x => x.exportCsv),
|
|
141
|
+
},
|
|
142
|
+
excel: {
|
|
143
|
+
Icon: icons.ExportExcel,
|
|
144
|
+
text: strings.exportExcel,
|
|
145
|
+
localizedTexts: extractLocalizedStrings(localizedSrings, x => x.exportExcel),
|
|
146
|
+
},
|
|
147
|
+
}),
|
|
148
|
+
],
|
|
149
|
+
];
|
|
150
|
+
}
|
|
151
|
+
DefaultCommandBuilder.createDefaultSubgridCommands = createDefaultSubgridCommands;
|
|
152
|
+
const defaultCreateCommandStrings = Object.assign(Object.assign(Object.assign({}, DefaultCommandBuilder.defaultViewCommandStrings), DefaultCommandBuilder.defaultFormCommandStrings), defaultSubgridCommandStrings);
|
|
153
|
+
function createDefaultCommands({ icons, strings = defaultCreateCommandStrings, localizedSrings, }) {
|
|
154
|
+
return {
|
|
155
|
+
view: createDefaultViewCommands({
|
|
156
|
+
icons,
|
|
157
|
+
strings,
|
|
158
|
+
localizedSrings,
|
|
159
|
+
}),
|
|
160
|
+
form: createDefaultFormCommands({
|
|
161
|
+
icons,
|
|
162
|
+
strings,
|
|
163
|
+
localizedSrings,
|
|
164
|
+
}),
|
|
165
|
+
subgrid: createDefaultSubgridCommands({
|
|
166
|
+
icons,
|
|
167
|
+
strings,
|
|
168
|
+
localizedSrings,
|
|
169
|
+
}),
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
DefaultCommandBuilder.createDefaultCommands = createDefaultCommands;
|
|
173
|
+
})(DefaultCommandBuilder || (exports.DefaultCommandBuilder = DefaultCommandBuilder = {}));
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { EntityFormCommandContext, EntityMainFormCommandItemExperience } from '@headless-adminapp/core/experience/form';
|
|
2
|
+
import { Icon } from '@headless-adminapp/icons';
|
|
3
|
+
export declare namespace FormCommandBuilder {
|
|
4
|
+
export function createSaveCommand({ Icon, text, localizedTexts, }: {
|
|
5
|
+
Icon: Icon;
|
|
6
|
+
text: string;
|
|
7
|
+
localizedTexts?: Record<string, string>;
|
|
8
|
+
}): EntityMainFormCommandItemExperience;
|
|
9
|
+
export function createSaveAndCloseCommand({ Icon, text, localizedTexts, }: {
|
|
10
|
+
Icon: Icon;
|
|
11
|
+
text: string;
|
|
12
|
+
localizedTexts?: Record<string, string>;
|
|
13
|
+
}): EntityMainFormCommandItemExperience;
|
|
14
|
+
interface DeleteRecordCommandStringSet {
|
|
15
|
+
confirmation: {
|
|
16
|
+
title: string;
|
|
17
|
+
text: string;
|
|
18
|
+
buttonCancel: string;
|
|
19
|
+
buttonConfirm: string;
|
|
20
|
+
};
|
|
21
|
+
status: {
|
|
22
|
+
deleting: string;
|
|
23
|
+
};
|
|
24
|
+
successNotification: {
|
|
25
|
+
title: string;
|
|
26
|
+
text: string;
|
|
27
|
+
};
|
|
28
|
+
errorNotification: {
|
|
29
|
+
title: string;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export const defaultDeleteRecordStringSet: DeleteRecordCommandStringSet;
|
|
33
|
+
export function createDeleteCommand({ Icon, text, localizedTexts, stringSet, }: {
|
|
34
|
+
Icon: Icon;
|
|
35
|
+
text: string;
|
|
36
|
+
localizedTexts?: Record<string, string>;
|
|
37
|
+
stringSet: DeleteRecordCommandStringSet | ((context: EntityFormCommandContext) => DeleteRecordCommandStringSet);
|
|
38
|
+
}): EntityMainFormCommandItemExperience;
|
|
39
|
+
export function createRefreshCommand({ Icon, text, localizedTexts, }: {
|
|
40
|
+
Icon: Icon;
|
|
41
|
+
text: string;
|
|
42
|
+
localizedTexts?: Record<string, string>;
|
|
43
|
+
}): EntityMainFormCommandItemExperience;
|
|
44
|
+
export {};
|
|
45
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.FormCommandBuilder = void 0;
|
|
13
|
+
var FormCommandBuilder;
|
|
14
|
+
(function (FormCommandBuilder) {
|
|
15
|
+
function createSaveCommand({ Icon, text, localizedTexts, }) {
|
|
16
|
+
return {
|
|
17
|
+
type: 'button',
|
|
18
|
+
Icon,
|
|
19
|
+
text,
|
|
20
|
+
localizedText: localizedTexts,
|
|
21
|
+
isQuickAction: true,
|
|
22
|
+
onClick: (context) => __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
yield context.primaryControl.save('save');
|
|
24
|
+
}),
|
|
25
|
+
hidden: (context) => {
|
|
26
|
+
if (context.primaryControl.readonly) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
return false;
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
FormCommandBuilder.createSaveCommand = createSaveCommand;
|
|
34
|
+
function createSaveAndCloseCommand({ Icon, text, localizedTexts, }) {
|
|
35
|
+
return {
|
|
36
|
+
type: 'button',
|
|
37
|
+
Icon,
|
|
38
|
+
text,
|
|
39
|
+
localizedText: localizedTexts,
|
|
40
|
+
onClick: (context) => __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
yield context.primaryControl.save('saveandclose');
|
|
42
|
+
}),
|
|
43
|
+
hidden: (context) => {
|
|
44
|
+
if (context.primaryControl.readonly) {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
return false;
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
FormCommandBuilder.createSaveAndCloseCommand = createSaveAndCloseCommand;
|
|
52
|
+
FormCommandBuilder.defaultDeleteRecordStringSet = {
|
|
53
|
+
confirmation: {
|
|
54
|
+
text: 'Are you sure you want to delete this record?',
|
|
55
|
+
title: 'Delete record',
|
|
56
|
+
buttonConfirm: 'Delete',
|
|
57
|
+
buttonCancel: 'Cancel',
|
|
58
|
+
},
|
|
59
|
+
status: {
|
|
60
|
+
deleting: 'Deleting record',
|
|
61
|
+
},
|
|
62
|
+
successNotification: {
|
|
63
|
+
title: 'Record deleted',
|
|
64
|
+
text: 'Record deleted successfully',
|
|
65
|
+
},
|
|
66
|
+
errorNotification: {
|
|
67
|
+
title: 'Error',
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
function createDeleteCommand({ Icon, text, localizedTexts, stringSet, }) {
|
|
71
|
+
return {
|
|
72
|
+
Icon: Icon,
|
|
73
|
+
type: 'button',
|
|
74
|
+
text,
|
|
75
|
+
localizedText: localizedTexts,
|
|
76
|
+
danger: true,
|
|
77
|
+
hidden: (context) => {
|
|
78
|
+
var _a;
|
|
79
|
+
if (!context.primaryControl.recordId) {
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
if ((_a = context.primaryControl.schema.restrictions) === null || _a === void 0 ? void 0 : _a.disableDelete) {
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
return false;
|
|
86
|
+
},
|
|
87
|
+
onClick: (context) => __awaiter(this, void 0, void 0, function* () {
|
|
88
|
+
const recordId = context.primaryControl.recordId;
|
|
89
|
+
if (!recordId) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (typeof stringSet === 'function') {
|
|
93
|
+
stringSet = stringSet(context);
|
|
94
|
+
}
|
|
95
|
+
try {
|
|
96
|
+
const confirmResult = yield context.utility.openConfirmDialog({
|
|
97
|
+
title: stringSet.confirmation.title,
|
|
98
|
+
text: stringSet.confirmation.text,
|
|
99
|
+
cancelButtonLabel: stringSet.confirmation.buttonCancel,
|
|
100
|
+
confirmButtonLabel: stringSet.confirmation.buttonConfirm,
|
|
101
|
+
});
|
|
102
|
+
if (!(confirmResult === null || confirmResult === void 0 ? void 0 : confirmResult.confirmed)) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
context.utility.showProgressIndicator(stringSet.status.deleting + '...');
|
|
106
|
+
yield new Promise((resolve) => setTimeout(resolve, 2000));
|
|
107
|
+
// await context.dataService.deleteRecord(
|
|
108
|
+
// context.primaryControl.logicalName,
|
|
109
|
+
// recordId
|
|
110
|
+
// );
|
|
111
|
+
context.utility.showNotification({
|
|
112
|
+
title: stringSet.successNotification.title,
|
|
113
|
+
text: stringSet.successNotification.text,
|
|
114
|
+
type: 'success',
|
|
115
|
+
});
|
|
116
|
+
// context.primaryControl.close();
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
context.utility.showNotification({
|
|
120
|
+
title: stringSet.errorNotification.title,
|
|
121
|
+
text: error.message,
|
|
122
|
+
type: 'error',
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
finally {
|
|
126
|
+
context.utility.hideProgressIndicator();
|
|
127
|
+
}
|
|
128
|
+
}),
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
FormCommandBuilder.createDeleteCommand = createDeleteCommand;
|
|
132
|
+
function createRefreshCommand({ Icon, text, localizedTexts, }) {
|
|
133
|
+
return {
|
|
134
|
+
Icon,
|
|
135
|
+
type: 'button',
|
|
136
|
+
text,
|
|
137
|
+
localizedText: localizedTexts,
|
|
138
|
+
onClick: (context) => __awaiter(this, void 0, void 0, function* () {
|
|
139
|
+
yield context.primaryControl.refresh();
|
|
140
|
+
}),
|
|
141
|
+
hidden: (context) => !context.primaryControl.recordId,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
FormCommandBuilder.createRefreshCommand = createRefreshCommand;
|
|
145
|
+
})(FormCommandBuilder || (exports.FormCommandBuilder = FormCommandBuilder = {}));
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { SubGridCommandItemExperience } from '@headless-adminapp/core/experience/view';
|
|
2
|
+
import { Localized } from '@headless-adminapp/core/types';
|
|
3
|
+
import { Icon } from '@headless-adminapp/icons';
|
|
4
|
+
export declare namespace SubgridCommandBuilder {
|
|
5
|
+
export function createNewRecordCommand({ Icon, text, localizedTexts, }: {
|
|
6
|
+
Icon: Icon;
|
|
7
|
+
text: string;
|
|
8
|
+
localizedTexts?: Record<string, string>;
|
|
9
|
+
}): SubGridCommandItemExperience;
|
|
10
|
+
export function createEditRecordCommand({ Icon, text, localizedTexts, }: {
|
|
11
|
+
Icon: Icon;
|
|
12
|
+
text: string;
|
|
13
|
+
localizedTexts?: Record<string, string>;
|
|
14
|
+
}): SubGridCommandItemExperience;
|
|
15
|
+
interface DeleteRecordCommandStringSet {
|
|
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, }: {
|
|
35
|
+
Icon: Icon;
|
|
36
|
+
text: string;
|
|
37
|
+
localizedText?: Record<string, string>;
|
|
38
|
+
stringSet?: DeleteRecordCommandStringSet;
|
|
39
|
+
localizedStringSet?: Localized<DeleteRecordCommandStringSet>;
|
|
40
|
+
}): SubGridCommandItemExperience;
|
|
41
|
+
export function createRefreshCommand({ Icon, localizedTexts, text, }: {
|
|
42
|
+
Icon: Icon;
|
|
43
|
+
text: string;
|
|
44
|
+
localizedTexts?: Record<string, string>;
|
|
45
|
+
}): SubGridCommandItemExperience;
|
|
46
|
+
export function createExportCommand({ button, csv, excel, }: {
|
|
47
|
+
button: {
|
|
48
|
+
Icon: Icon;
|
|
49
|
+
text: string;
|
|
50
|
+
localizedTexts?: Record<string, string>;
|
|
51
|
+
};
|
|
52
|
+
excel: {
|
|
53
|
+
Icon: Icon;
|
|
54
|
+
text: string;
|
|
55
|
+
localizedTexts?: Record<string, string>;
|
|
56
|
+
};
|
|
57
|
+
csv: {
|
|
58
|
+
Icon: Icon;
|
|
59
|
+
text: string;
|
|
60
|
+
localizedTexts?: Record<string, string>;
|
|
61
|
+
};
|
|
62
|
+
}): SubGridCommandItemExperience;
|
|
63
|
+
export {};
|
|
64
|
+
}
|