identity-admin 1.28.14 → 1.28.16

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.
@@ -1,6 +1,6 @@
1
- import { Document } from "mongoose";
2
- import { IResourceFile } from "../types/IResourceFile";
3
- import { IModelConfigurationDocument } from "../models/modelConfiguration/IModelConfigurations";
1
+ import { Document } from 'mongoose';
2
+ import { IResourceFile } from '../types/IResourceFile';
3
+ import { IModelConfigurationDocument } from '../models/modelConfiguration/IModelConfigurations';
4
4
  export default class ActionsGenerator {
5
5
  static generateActions(actionsCheck: any, resource: IResourceFile, currentUser: Document, configuration?: IModelConfigurationDocument): {
6
6
  [key: string]: any;
@@ -29,15 +29,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
29
29
  const i18n_1 = __importStar(require("i18n"));
30
30
  const helpers_1 = require("../types/helpers");
31
31
  const ResourceHelper_1 = __importDefault(require("./ResourceHelper"));
32
- var pluralize = require("pluralize");
32
+ var pluralize = require('pluralize');
33
33
  class ActionsGenerator {
34
34
  static generateActions(actionsCheck, resource, currentUser, configuration) {
35
35
  const actions = this.getActions(actionsCheck ? resource.properties.actions : undefined, currentUser, configuration); //resource.properties.actions? ResourcesHelper.getActions(JSON.parse(JSON.stringify(resource.properties.actions))): ResourcesHelper.getActions(undefined)
36
36
  for (const key in actions) {
37
- if (key === "extras") {
38
- actions.extras = actions.extras
39
- ? this.addExtraActions(JSON.parse(JSON.stringify(resource.properties.actions.extras)))
40
- : actions.extras;
37
+ if (key === 'extras') {
38
+ actions.extras = actions.extras ? this.addExtraActions(JSON.parse(JSON.stringify(resource.properties.actions.extras))) : actions.extras;
41
39
  continue;
42
40
  }
43
41
  const translation = ResourceHelper_1.default.checkActionTranslation(resource, key);
@@ -53,30 +51,20 @@ class ActionsGenerator {
53
51
  extraActions.forEach((action) => {
54
52
  action.keys = action.isVisible ? Object.keys(action.isVisible) : [];
55
53
  action.name = (0, i18n_1.__)({ phrase: action.name, locale: i18n_1.default.getLocale() });
56
- action.guardTitle = action.guardTitle
57
- ? (0, i18n_1.__)({ phrase: action.guardTitle, locale: i18n_1.default.getLocale() })
58
- : undefined;
59
- action.guard = action.guard
60
- ? (0, i18n_1.__)({ phrase: action.guard, locale: i18n_1.default.getLocale() })
61
- : undefined;
62
- action.message = action.message
63
- ? (0, i18n_1.__)({ phrase: action.message, locale: i18n_1.default.getLocale() })
64
- : undefined;
65
- action.handlerStrategy = action.handlerStrategy
66
- ? action.handlerStrategy
67
- : helpers_1.HandlerStrategy.NORMAL;
68
- action.actionType
69
- ? (extraActionsObject[action.actionType][action.key] = action)
70
- : "";
54
+ action.guardTitle = action.guardTitle ? (0, i18n_1.__)({ phrase: action.guardTitle, locale: i18n_1.default.getLocale() }) : undefined;
55
+ action.guard = action.guard ? (0, i18n_1.__)({ phrase: action.guard, locale: i18n_1.default.getLocale() }) : undefined;
56
+ action.message = action.message ? (0, i18n_1.__)({ phrase: action.message, locale: i18n_1.default.getLocale() }) : undefined;
57
+ action.handlerStrategy = action.handlerStrategy ? action.handlerStrategy : helpers_1.HandlerStrategy.NORMAL;
58
+ action.actionType ? (extraActionsObject[action.actionType][action.key] = action) : '';
71
59
  });
72
60
  return extraActionsObject;
73
61
  }
74
62
  static getActions(actions, currentUser, configuration) {
75
- var _a, _b, _c, _d, _e, _f, _g, _h;
63
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
76
64
  var actionObject = {
77
65
  show: {
78
66
  isAccessible: ((_a = configuration === null || configuration === void 0 ? void 0 : configuration.actions) === null || _a === void 0 ? void 0 : _a.show) === false ? false : true,
79
- isMainAction: true
67
+ isMainAction: true,
80
68
  },
81
69
  new: {
82
70
  isAccessible: ((_b = configuration === null || configuration === void 0 ? void 0 : configuration.actions) === null || _b === void 0 ? void 0 : _b.new) === false ? false : true,
@@ -86,97 +74,90 @@ class ActionsGenerator {
86
74
  },
87
75
  edit: {
88
76
  isAccessible: ((_d = configuration === null || configuration === void 0 ? void 0 : configuration.actions) === null || _d === void 0 ? void 0 : _d.edit) === false ? false : true,
89
- isMainAction: true
77
+ isMainAction: true,
90
78
  },
91
79
  delete: {
92
80
  isAccessible: ((_e = configuration === null || configuration === void 0 ? void 0 : configuration.actions) === null || _e === void 0 ? void 0 : _e.delete) === false ? false : true,
93
81
  },
82
+ import: {
83
+ isAccessible: ((_f = configuration === null || configuration === void 0 ? void 0 : configuration.actions) === null || _f === void 0 ? void 0 : _f.import) === true ? true : false,
84
+ },
94
85
  bulkDelete: {
95
- isAccessible: ((_f = configuration === null || configuration === void 0 ? void 0 : configuration.actions) === null || _f === void 0 ? void 0 : _f.bulkDelete) === true ? true : false,
86
+ isAccessible: ((_g = configuration === null || configuration === void 0 ? void 0 : configuration.actions) === null || _g === void 0 ? void 0 : _g.bulkDelete) === true ? true : false,
96
87
  },
97
88
  };
98
89
  if (!actions || Object.keys(actions).length === 0) {
99
90
  return actionObject;
100
91
  }
101
92
  for (const key in actions) {
102
- if (actions[key].hasOwnProperty("isAccessible") && key !== "extras") {
93
+ if (actions[key].hasOwnProperty('isAccessible') && key !== 'extras') {
103
94
  actionObject[key] = actions[key];
104
95
  }
105
- else if (actions[key].isAllowed && key !== "extras") {
96
+ else if (actions[key].isAllowed && key !== 'extras') {
106
97
  actionObject[key] = {
107
98
  isAccessible: actions[key].isAllowed(currentUser),
108
99
  };
109
100
  }
110
- else if (key === "extras") {
101
+ else if (key === 'extras') {
111
102
  actionObject[key] = actions[key];
112
103
  }
113
- actionObject[key].reloadAfterAction = (_g = actions[key]) === null || _g === void 0 ? void 0 : _g.reloadAfterAction;
114
- actionObject[key].isMainAction =
115
- (_h = actions[key].isMainAction) !== null && _h !== void 0 ? _h : (key === "edit" || key === "show");
104
+ actionObject[key].reloadAfterAction = (_h = actions[key]) === null || _h === void 0 ? void 0 : _h.reloadAfterAction;
105
+ actionObject[key].isMainAction = (_j = actions[key].isMainAction) !== null && _j !== void 0 ? _j : (key === 'edit' || key === 'show');
116
106
  }
117
107
  return actionObject;
118
108
  }
119
109
  static appendActionValues(action, actionObject, translation) {
120
110
  switch (action) {
121
- case "new":
122
- actionObject.value = translation
123
- ? translation
124
- : (0, i18n_1.__)({ phrase: "actions_new", locale: i18n_1.default.getLocale() });
111
+ case 'new':
112
+ actionObject.value = translation ? translation : (0, i18n_1.__)({ phrase: 'actions_new', locale: i18n_1.default.getLocale() });
113
+ break;
114
+ case 'duplicate':
115
+ actionObject.value = translation ? translation : (0, i18n_1.__)({ phrase: 'actions_duplicate', locale: i18n_1.default.getLocale() });
125
116
  break;
126
- case "duplicate":
127
- actionObject.value = translation
128
- ? translation
129
- : (0, i18n_1.__)({ phrase: "actions_duplicate", locale: i18n_1.default.getLocale() });
117
+ case 'edit':
118
+ actionObject.value = translation ? translation : (0, i18n_1.__)({ phrase: 'actions_edit', locale: i18n_1.default.getLocale() });
130
119
  break;
131
- case "edit":
132
- actionObject.value = translation
133
- ? translation
134
- : (0, i18n_1.__)({ phrase: "actions_edit", locale: i18n_1.default.getLocale() });
120
+ case 'show':
121
+ actionObject.value = translation ? translation : (0, i18n_1.__)({ phrase: 'actions_show', locale: i18n_1.default.getLocale() });
135
122
  break;
136
- case "show":
137
- actionObject.value = translation
138
- ? translation
139
- : (0, i18n_1.__)({ phrase: "actions_show", locale: i18n_1.default.getLocale() });
123
+ case 'import':
124
+ actionObject.value = translation ? translation : (0, i18n_1.__)({ phrase: 'actions_import', locale: i18n_1.default.getLocale() });
140
125
  break;
141
- case "delete":
142
- actionObject.value = translation
143
- ? translation
144
- : (0, i18n_1.__)({ phrase: "actions_delete", locale: i18n_1.default.getLocale() });
126
+ case 'delete':
127
+ actionObject.value = translation ? translation : (0, i18n_1.__)({ phrase: 'actions_delete', locale: i18n_1.default.getLocale() });
145
128
  actionObject.confirmationMessageTitle = (0, i18n_1.__)({
146
- phrase: "actions_delete_confirmMessage_title",
129
+ phrase: 'actions_delete_confirmMessage_title',
147
130
  locale: i18n_1.default.getLocale(),
148
131
  });
149
132
  actionObject.confirmationMessageBody = (0, i18n_1.__)({
150
- phrase: "actions_delete_confirmMessage_body",
133
+ phrase: 'actions_delete_confirmMessage_body',
151
134
  locale: i18n_1.default.getLocale(),
152
135
  });
153
136
  actionObject.confirmDeleteOption = (0, i18n_1.__)({
154
- phrase: "actions_delete_options_yes",
137
+ phrase: 'actions_delete_options_yes',
155
138
  locale: i18n_1.default.getLocale(),
156
139
  });
157
140
  actionObject.cancelDeleteOption = (0, i18n_1.__)({
158
- phrase: "actions_delete_options_no",
141
+ phrase: 'actions_delete_options_no',
159
142
  locale: i18n_1.default.getLocale(),
160
143
  });
161
144
  break;
162
- case "bulkDelete":
163
- actionObject.value = translation
164
- ? translation
165
- : (0, i18n_1.__)({ phrase: "actions_delete", locale: i18n_1.default.getLocale() });
145
+ case 'bulkDelete':
146
+ actionObject.value = translation ? translation : (0, i18n_1.__)({ phrase: 'actions_delete', locale: i18n_1.default.getLocale() });
166
147
  actionObject.confirmationMessageTitle = (0, i18n_1.__)({
167
- phrase: "actions_bulkDelete_confirmMessage_title",
148
+ phrase: 'actions_bulkDelete_confirmMessage_title',
168
149
  locale: i18n_1.default.getLocale(),
169
150
  });
170
151
  actionObject.confirmationMessageBody = (0, i18n_1.__)({
171
- phrase: "actions_bulkDelete_confirmMessage_body",
152
+ phrase: 'actions_bulkDelete_confirmMessage_body',
172
153
  locale: i18n_1.default.getLocale(),
173
154
  });
174
155
  actionObject.confirmDeleteOption = (0, i18n_1.__)({
175
- phrase: "actions_delete_options_yes",
156
+ phrase: 'actions_delete_options_yes',
176
157
  locale: i18n_1.default.getLocale(),
177
158
  });
178
159
  actionObject.cancelDeleteOption = (0, i18n_1.__)({
179
- phrase: "actions_delete_options_no",
160
+ phrase: 'actions_delete_options_no',
180
161
  locale: i18n_1.default.getLocale(),
181
162
  });
182
163
  break;
@@ -4,6 +4,8 @@ export interface ILocationProps {
4
4
  address?: string;
5
5
  latitude?: number;
6
6
  longitude?: number;
7
+ city?: string;
8
+ neighborhood?: string;
7
9
  }
8
10
  export interface ILocationDocument extends ILocationProps, Document {
9
11
  _id: Types.ObjectId;
@@ -16,6 +16,14 @@ function getLocationSchema(schemaOptions) {
16
16
  type: Number,
17
17
  required: false,
18
18
  },
19
+ city: {
20
+ type: String,
21
+ required: false,
22
+ },
23
+ neighborhood: {
24
+ type: String,
25
+ required: false,
26
+ }
19
27
  }, schemaOptions);
20
28
  }
21
29
  exports.getLocationSchema = getLocationSchema;
@@ -6,6 +6,7 @@ export interface IModelConfigurationActions {
6
6
  show?: boolean;
7
7
  delete?: boolean;
8
8
  bulkDelete?: boolean;
9
+ import?: boolean;
9
10
  }
10
11
  export interface IModelConfigurationProps {
11
12
  _id?: Types.ObjectId;
@@ -32,6 +32,10 @@ const ActionSchema = new mongoose_1.Schema({
32
32
  type: Boolean,
33
33
  required: false,
34
34
  },
35
+ import: {
36
+ type: Boolean,
37
+ required: false,
38
+ },
35
39
  bulkDelete: {
36
40
  type: Boolean,
37
41
  required: false,
@@ -377,13 +377,13 @@ export interface IFieldValue {
377
377
  */
378
378
  relatedFields?: string[];
379
379
  /**
380
- * Used to add the disableImageOptimization option in the field. Only used when the type of the field is image
381
- * @default false
382
- */
380
+ * Used to add the disableImageOptimization option in the field. Only used when the type of the field is image
381
+ * @default false
382
+ */
383
383
  disableImageOptimization?: boolean;
384
384
  /**
385
- * Only used if the field type is REFERENCE. Used to filter the list of referenced items.
386
- */
385
+ * Only used if the field type is REFERENCE. Used to filter the list of referenced items.
386
+ */
387
387
  filter?: {
388
388
  formList?: Record<string, any>;
389
389
  filterList?: Record<string, any>;
@@ -444,6 +444,7 @@ interface ActionOptions {
444
444
  new?: Action;
445
445
  edit?: Action;
446
446
  delete?: Action;
447
+ import?: Action;
447
448
  bulkDelete?: Action;
448
449
  /**
449
450
  * Any extra action to be added.
@@ -59,6 +59,7 @@ interface IAction {
59
59
  edit: IActionMin;
60
60
  new: IActionMin;
61
61
  show: IActionMin;
62
+ import: IActionMin;
62
63
  extras?: IExtras;
63
64
  }
64
65
  interface IExtras {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "identity-admin",
3
- "version": "1.28.14",
3
+ "version": "1.28.16",
4
4
  "description": "",
5
5
  "main": "lib/Dashboard.js",
6
6
  "types": "lib/Dashbord.d.ts",