identity-admin 1.17.0 → 1.19.0

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.
@@ -100,7 +100,8 @@ let DashboardController = DashboardController_1 = class DashboardController {
100
100
  for (var i = 0; i < extraActions.length; i++) {
101
101
  const extraAction = extraActions[i];
102
102
  if (!extraAction.isVisible) {
103
- break;
103
+ extraActionsArray.push(extraAction.key);
104
+ continue;
104
105
  }
105
106
  const isVisible = yield extraAction.isVisible(data);
106
107
  if (isVisible) {
@@ -64,17 +64,20 @@ let ResourceController = class ResourceController {
64
64
  }
65
65
  for (var i = 0; i < this.resourceFiles.length; i++) {
66
66
  const resource = this.resourceFiles[i];
67
- const visibiltyCheck = resource.properties.isAllowed ? yield resource.properties.isAllowed(currentUser) : true;
68
- if (visibiltyCheck) {
67
+ const isAllowed = resource.properties.isAllowed ? yield resource.properties.isAllowed(currentUser) : true;
68
+ const isVisibile = resource.properties.isVisible ? yield resource.properties.isVisible(currentUser) : true;
69
+ if (isAllowed) {
69
70
  const adaptedResource = ResourceGenerator_1.default.generate(resource, currentUser);
70
71
  const modelName = StringUtils_1.default.lowerCaseFirstLetter(adaptedResource.properties.modelName);
71
72
  modifiedResource[modelName] = adaptedResource;
72
- if (modifiedResource.modelParents[adaptedResource.properties.parent.name]) {
73
- modifiedResource.modelParents[adaptedResource.properties.parent.name].push(modelName);
74
- }
75
- else {
76
- modifiedResource.modelParents[adaptedResource.properties.parent.name] = [];
77
- modifiedResource.modelParents[adaptedResource.properties.parent.name].push(modelName);
73
+ if (isVisibile) {
74
+ if (modifiedResource.modelParents[adaptedResource.properties.parent.name]) {
75
+ modifiedResource.modelParents[adaptedResource.properties.parent.name].push(modelName);
76
+ }
77
+ else {
78
+ modifiedResource.modelParents[adaptedResource.properties.parent.name] = [];
79
+ modifiedResource.modelParents[adaptedResource.properties.parent.name].push(modelName);
80
+ }
78
81
  }
79
82
  }
80
83
  }
@@ -27,6 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  const i18n_1 = __importStar(require("i18n"));
30
+ const helpers_1 = require("../types/helpers");
30
31
  const ResourceHelper_1 = __importDefault(require("./ResourceHelper"));
31
32
  var pluralize = require('pluralize');
32
33
  class ActionsGenerator {
@@ -50,6 +51,7 @@ class ActionsGenerator {
50
51
  extraActions.forEach((action) => {
51
52
  action.keys = action.isVisible ? Object.keys(action.isVisible) : [];
52
53
  action.name = (0, i18n_1.__)({ phrase: action.name, locale: i18n_1.default.getLocale() });
54
+ action.handlerStrategy = action.handlerStrategy ? action.handlerStrategy : helpers_1.HandlerStrategy.NORMAL;
53
55
  action.actionType ? extraActionsObject[action.actionType][action.key] = action : '';
54
56
  });
55
57
  return extraActionsObject;
@@ -79,6 +79,9 @@ class ResourceGenerator {
79
79
  if (!resource.filterProperties) {
80
80
  modifiedResource.filterProperties = modifiedFilterProperties;
81
81
  }
82
+ if (!resource.quickFilterProperties) {
83
+ modifiedResource.quickFilterProperties = [];
84
+ }
82
85
  if (!resource.listProperties) {
83
86
  modifiedResource.listProperties = ResourceHelper_1.default.exchangeFirstFieldWithTitle(JSON.parse(JSON.stringify(modifiedListProperties)), title);
84
87
  }
@@ -98,6 +101,7 @@ class ResourceGenerator {
98
101
  modifiedResource.listProperties = ResourceHelper_1.default.prepareProperties(resource.listProperties ? resource.listProperties : modifiedResource.listProperties, modelName, modifiedResource.properties.model, resource);
99
102
  modifiedResource.showProperties = ResourceHelper_1.default.prepareProperties(resource.showProperties ? resource.showProperties : modifiedResource.showProperties, modelName, modifiedResource.properties.model, resource);
100
103
  modifiedResource.filterProperties = ResourceHelper_1.default.prepareFilterProperties(modifiedResource.filterProperties, modifiedResource.properties.model);
104
+ modifiedResource.quickFilterProperties = ResourceHelper_1.default.prepareFilterProperties(modifiedResource.quickFilterProperties, modifiedResource.properties.model);
101
105
  modifiedResource.properties.filters = ResourceHelper_1.default.getFilters(resource.properties.filters ? JSON.parse(JSON.stringify(resource.properties.filters)) : undefined);
102
106
  if (modifiedResource.properties.filters && modifiedResource.properties.filters.scopes && modifiedResource.properties.filters.scopes.isAccessible) {
103
107
  const options = ((_b = (_a = resource.properties.filters) === null || _a === void 0 ? void 0 : _a.scopes) === null || _b === void 0 ? void 0 : _b.auto) ? (_d = (_c = resource.properties.filters) === null || _c === void 0 ? void 0 : _c.scopes) === null || _d === void 0 ? void 0 : _d.auto.options : (_g = (_f = (_e = resource.properties.filters) === null || _e === void 0 ? void 0 : _e.scopes) === null || _f === void 0 ? void 0 : _f.manual) === null || _g === void 0 ? void 0 : _g.options;
@@ -1,11 +1,13 @@
1
- import { Request } from "express";
2
1
  import { Document, Model } from "mongoose";
3
2
  import { IRequest } from "../middlewares/isAuth";
4
3
  import { IRepository } from "../repositories/Repository";
5
- import { ActionNames, ActionTypes, FieldTypes, FileTypes, Virtuals } from "./helpers";
4
+ import { ActionNames, ActionTypes, FieldTypes, FileTypes, HandlerStrategy, Virtuals } from "./helpers";
6
5
  declare type orderTypes = 'asc' | 'desc';
7
6
  declare type VirtualFieldTypes = 'password' | 'ref' | 'Array';
8
7
  declare type Severity = 'success' | 'info' | 'warning' | 'error';
8
+ declare type ButtonColors = 'inherit' | 'primary' | 'secondary' | 'success' | 'error' | 'info' | 'warning';
9
+ declare type ButtonVariants = 'text' | 'outlined' | 'contained';
10
+ declare type ButtonSizes = 'small' | 'medium' | 'large';
9
11
  interface Parent {
10
12
  /**
11
13
  * Name of the parent
@@ -287,6 +289,22 @@ interface ExtraAction {
287
289
  * {@link https://mui.com/material-ui/material-icons/}
288
290
  */
289
291
  icon: string;
292
+ /**
293
+ * Color of the action button
294
+ * In case of bulk actions it is one of the button colors. @default inherit
295
+ * In case of record actions it is any color like red, green, ... @default black
296
+ */
297
+ color?: string | ButtonColors;
298
+ /**
299
+ * Size of the action button. Only used in case of bulk actions
300
+ * @default small
301
+ */
302
+ size?: ButtonSizes;
303
+ /**
304
+ * Variant of the action button. Only used in case of bulk actions
305
+ * @default contained
306
+ */
307
+ variant?: ButtonVariants;
290
308
  /**
291
309
  * Action type if it is record action or resource action.
292
310
  */
@@ -306,6 +324,11 @@ interface ExtraAction {
306
324
  * @default 'success'
307
325
  */
308
326
  severity?: Severity;
327
+ /**
328
+ * Specify if you need the dialog to be in full screen or not. Used only in case of custom component strategy
329
+ * @default 'false'
330
+ */
331
+ fullScreen?: boolean;
309
332
  /**
310
333
  * @returns boolean value.
311
334
  * This value Specifies to which records should this action appears.
@@ -315,7 +338,12 @@ interface ExtraAction {
315
338
  /**
316
339
  * Handler function that is executed after clicking the action.
317
340
  */
318
- handler: (req: Request, res: any, data: ActionData) => Promise<IActionHandlerResponse>;
341
+ handler: (req: IRequest, res: any, data: ActionData) => Promise<IActionHandlerResponse>;
342
+ /**
343
+ * Icon of this action.
344
+ * {@link https://mui.com/material-ui/material-icons/}
345
+ */
346
+ handlerStrategy?: HandlerStrategy;
319
347
  }
320
348
  export interface IActionHandlerResponse {
321
349
  /**
@@ -332,6 +360,10 @@ export interface IActionHandlerResponse {
332
360
  * Id of the record that is used in actions that needs record id like show or edit
333
361
  */
334
362
  recordId?: string;
363
+ /**
364
+ * Path of the uploaded file in case of file download handling strategy
365
+ */
366
+ filePath?: string;
335
367
  }
336
368
  export interface IResourceFile {
337
369
  properties: {
@@ -366,6 +398,11 @@ export interface IResourceFile {
366
398
  * @default true
367
399
  */
368
400
  isAllowed?: (currentUser: Document) => Promise<boolean>;
401
+ /**
402
+ * The property that controls the visibility of this resource in the nav bar
403
+ * @default true
404
+ */
405
+ isVisible?: (currentUser: Document) => Promise<boolean>;
369
406
  /**
370
407
  * The default order
371
408
  * @default asc
@@ -437,5 +474,10 @@ export interface IResourceFile {
437
474
  * @default 'The whole fields'
438
475
  */
439
476
  filterProperties?: string[];
477
+ /**
478
+ * Array of properties that should be appeared in the quick filters.
479
+ * @default 'Empty array'
480
+ */
481
+ quickFilterProperties?: string[];
440
482
  }
441
483
  export {};
@@ -43,3 +43,8 @@ export declare enum FileTypes {
43
43
  POWER_POINT = "POWER_POINT",
44
44
  AUDIO = "AUDIO"
45
45
  }
46
+ export declare enum HandlerStrategy {
47
+ NORMAL = "NORMAL",
48
+ FILE_DOWNLOAD = "FILE_DOWNLOAD",
49
+ CUSTOM_COMPONENT = "CUSTOM_COMPONENT"
50
+ }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FileTypes = exports.FieldTypes = exports.ActionTypes = exports.ActionNames = exports.Virtuals = void 0;
3
+ exports.HandlerStrategy = exports.FileTypes = exports.FieldTypes = exports.ActionTypes = exports.ActionNames = exports.Virtuals = void 0;
4
4
  var Virtuals;
5
5
  (function (Virtuals) {
6
6
  Virtuals["SHOW"] = "SHOW";
@@ -51,3 +51,9 @@ var FileTypes;
51
51
  FileTypes["POWER_POINT"] = "POWER_POINT";
52
52
  FileTypes["AUDIO"] = "AUDIO";
53
53
  })(FileTypes = exports.FileTypes || (exports.FileTypes = {}));
54
+ var HandlerStrategy;
55
+ (function (HandlerStrategy) {
56
+ HandlerStrategy["NORMAL"] = "NORMAL";
57
+ HandlerStrategy["FILE_DOWNLOAD"] = "FILE_DOWNLOAD";
58
+ HandlerStrategy["CUSTOM_COMPONENT"] = "CUSTOM_COMPONENT";
59
+ })(HandlerStrategy = exports.HandlerStrategy || (exports.HandlerStrategy = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "identity-admin",
3
- "version": "1.17.0",
3
+ "version": "1.19.0",
4
4
  "description": "",
5
5
  "main": "lib/Dashboard.js",
6
6
  "types": "lib/Dashbord.d.ts",