@headless-adminapp/app 0.0.17-alpha.20 → 0.0.17-alpha.22

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.
@@ -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 { EntityFormCommandContext, EntityMainFormCommandItemExperience } from '@headless-adminapp/core/experience/form';
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 | ((context: EntityFormCommandContext) => DeleteRecordCommandStringSet);
39
- localizedStringSet?: Localized<DeleteRecordCommandStringSet | ((context: EntityFormCommandContext) => 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,13 +118,14 @@ var FormCommandBuilder;
117
118
  if (!recordId) {
118
119
  return;
119
120
  }
120
- if (typeof stringSet === 'function') {
121
- stringSet = stringSet(context);
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: stringSet.confirmation.title,
126
- text: stringSet.confirmation.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
  });
@@ -133,8 +135,8 @@ var FormCommandBuilder;
133
135
  context.utility.showProgressIndicator(stringSet.status.deleting + '...');
134
136
  yield context.dataService.deleteRecord(context.primaryControl.logicalName, recordId);
135
137
  context.utility.showNotification({
136
- title: stringSet.successNotification.title,
137
- text: stringSet.successNotification.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
- export function createNewRecordCommand({ Icon, text, localizedTexts, }: {
6
+ function createNewRecordCommand({ Icon, text, localizedTexts, }: {
6
7
  Icon: Icon;
7
8
  text: string;
8
9
  localizedTexts?: Record<string, string>;
9
10
  }): SubGridCommandItemExperience;
10
- export function createEditRecordCommand({ Icon, text, localizedTexts, }: {
11
+ function createEditRecordCommand({ Icon, text, localizedTexts, }: {
11
12
  Icon: Icon;
12
13
  text: string;
13
14
  localizedTexts?: Record<string, string>;
14
15
  }): 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, }: {
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
- export function createRefreshCommand({ Icon, localizedTexts, text, }: {
23
+ function createRefreshCommand({ Icon, localizedTexts, text, }: {
42
24
  Icon: Icon;
43
25
  text: string;
44
26
  localizedTexts?: Record<string, string>;
45
27
  }): SubGridCommandItemExperience;
46
- export function createExportCommand({ button, csv, excel, }: {
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) {
@@ -92,28 +93,7 @@ var SubgridCommandBuilder;
92
93
  msg = msg.replace('{count}', count.toString());
93
94
  return msg;
94
95
  }
95
- SubgridCommandBuilder.defaultDeleteRecordStringSet = {
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,
@@ -146,7 +126,7 @@ var SubgridCommandBuilder;
146
126
  text: plurialize(recordIds.length, localizeSelector((s) => s.successNotification.text)),
147
127
  type: 'success',
148
128
  });
149
- yield context.primaryControl.refresh();
129
+ context.secondaryControl.refresh();
150
130
  }
151
131
  catch (error) {
152
132
  context.utility.showNotification({
@@ -312,6 +312,11 @@ exports.generateAttributeValidationSchema = (0, lodash_1.memoize)(function gener
312
312
  case 'number':
313
313
  validationSchema = yup.number().nullable();
314
314
  break;
315
+ case 'attachments':
316
+ case 'choices':
317
+ case 'lookups':
318
+ validationSchema = yup.array().nullable();
319
+ break;
315
320
  default:
316
321
  validationSchema = yup.mixed().nullable();
317
322
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@headless-adminapp/app",
3
- "version": "0.0.17-alpha.20",
3
+ "version": "0.0.17-alpha.22",
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": "bcc1bcddef884731f72e5e4fedb0d78ad64afbd0"
42
+ "gitHead": "a6d5c09c93ce38a63c40db11e217000bb2276c99"
43
43
  }