identity-admin 1.27.5 → 1.27.7
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.
|
@@ -31,6 +31,7 @@ export default class DashboardController {
|
|
|
31
31
|
[key: string]: any;
|
|
32
32
|
};
|
|
33
33
|
protected getVisibileExtraActions(currentUser: Document, record: any, resource: IResourceFile, repository: any, modelName: string): Promise<string[] | undefined>;
|
|
34
|
+
protected getHiddenActions(currentUser: Document, record: any, resource: IResourceFile, repository: any, modelName: string): Promise<string[] | undefined>;
|
|
34
35
|
private getModelConfiguration;
|
|
35
36
|
index(req: IRequest, res: Response): Promise<void | Response<any, Record<string, any>>>;
|
|
36
37
|
create(req: IRequest, res: Response): Promise<void>;
|
|
@@ -119,6 +119,34 @@ let DashboardController = DashboardController_1 = class DashboardController {
|
|
|
119
119
|
return extraActionsArray;
|
|
120
120
|
});
|
|
121
121
|
}
|
|
122
|
+
getHiddenActions(currentUser, record, resource, repository, modelName) {
|
|
123
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
124
|
+
const data = {
|
|
125
|
+
record: record.toObject(),
|
|
126
|
+
currentUser,
|
|
127
|
+
resource: {
|
|
128
|
+
name: modelName,
|
|
129
|
+
path: StringUtils_1.default.lowerCaseFirstLetter(modelName),
|
|
130
|
+
repository,
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
if (!resource.properties.actions) {
|
|
134
|
+
return undefined;
|
|
135
|
+
}
|
|
136
|
+
let actionsArray = [];
|
|
137
|
+
const actions = resource.properties.actions;
|
|
138
|
+
for (const [key, action] of Object.entries(actions)) {
|
|
139
|
+
if (!(action === null || action === void 0 ? void 0 : action.isVisible)) {
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
const isVisible = yield action.isVisible(data);
|
|
143
|
+
if (!isVisible) {
|
|
144
|
+
actionsArray.push(key);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return actionsArray;
|
|
148
|
+
});
|
|
149
|
+
}
|
|
122
150
|
getModelConfiguration(modelName) {
|
|
123
151
|
var _a, _b;
|
|
124
152
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -215,16 +243,20 @@ let DashboardController = DashboardController_1 = class DashboardController {
|
|
|
215
243
|
var documents = [];
|
|
216
244
|
for (var i = 0; i < records.length; i++) {
|
|
217
245
|
const record = records[i];
|
|
218
|
-
//let record: any = records[i]
|
|
219
|
-
//const recordFlatten = await ResourcesHelper.addExtraFields(modifiedResource.listProperties, modifiedResource.properties.model, record.toObject(), StringUtils.lowerCaseFirstLetter(modifiedResource.properties.modelName), resource)
|
|
220
246
|
const extraActionKeys = yield this.getVisibileExtraActions(currentUser, record, resource, repository, modifiedResource.properties.modelName);
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
documents.push(
|
|
247
|
+
const hiddenActionKeys = yield this.getHiddenActions(currentUser, record, resource, repository, modifiedResource.properties.modelName);
|
|
248
|
+
const recordFlatten = record.toObject();
|
|
249
|
+
if (!extraActionKeys && !hiddenActionKeys) {
|
|
250
|
+
documents.push(record);
|
|
225
251
|
}
|
|
226
252
|
else {
|
|
227
|
-
|
|
253
|
+
if (extraActionKeys) {
|
|
254
|
+
recordFlatten.extraActionKeys = extraActionKeys;
|
|
255
|
+
}
|
|
256
|
+
if (hiddenActionKeys) {
|
|
257
|
+
recordFlatten.hiddenActionKeys = hiddenActionKeys;
|
|
258
|
+
}
|
|
259
|
+
documents.push(recordFlatten);
|
|
228
260
|
}
|
|
229
261
|
}
|
|
230
262
|
if (crudOperations && crudOperations.index && crudOperations.index.after) {
|
|
@@ -529,8 +561,11 @@ let DashboardController = DashboardController_1 = class DashboardController {
|
|
|
529
561
|
return ResponseUtils_1.default.send(res, 404, 'record not found');
|
|
530
562
|
}
|
|
531
563
|
const recordPageResult = yield RecordsCounter_1.RecordsCounter.count(req, resource, repository, record, this.modelConfigurations);
|
|
564
|
+
const hiddenActionKeys = yield this.getHiddenActions(currentUser, record, resource, repository, modifiedResource.properties.modelName);
|
|
532
565
|
record = record.toObject();
|
|
533
|
-
|
|
566
|
+
if (hiddenActionKeys && record) {
|
|
567
|
+
record.hiddenActionKeys = hiddenActionKeys;
|
|
568
|
+
}
|
|
534
569
|
record = yield ResourceHelper_1.default.addExtraFields(modifiedResource.showProperties, modifiedResource.properties.model, record, StringUtils_1.default.lowerCaseFirstLetter(modifiedResource.properties.modelName), resource);
|
|
535
570
|
const afterMethod = (_e = (_d = resource.properties.crudOperations) === null || _d === void 0 ? void 0 : _d.show) === null || _e === void 0 ? void 0 : _e.after;
|
|
536
571
|
let extras = {};
|
|
@@ -62,6 +62,11 @@ interface Action {
|
|
|
62
62
|
* @default true for edit and show false for others
|
|
63
63
|
*/
|
|
64
64
|
isMainAction?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Specify if this action is visible or not per record.
|
|
67
|
+
* @default 'Same as isAccessible'
|
|
68
|
+
*/
|
|
69
|
+
isVisible?: (data: ActionData) => Promise<boolean>;
|
|
65
70
|
}
|
|
66
71
|
interface ICrudOperations {
|
|
67
72
|
index?: {
|
|
@@ -470,6 +475,11 @@ export interface ExtraAction {
|
|
|
470
475
|
* @default 'Action was executed successfully'
|
|
471
476
|
*/
|
|
472
477
|
message?: string;
|
|
478
|
+
/**
|
|
479
|
+
* Specify if you need the alert message to appear after executing this action
|
|
480
|
+
* @default 'true'
|
|
481
|
+
*/
|
|
482
|
+
showAlertMessage?: boolean;
|
|
473
483
|
/**
|
|
474
484
|
* The severity of the alert. This defines the color and icon used.
|
|
475
485
|
* @default 'success'
|