identity-admin 1.0.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.
- package/README.md +127 -0
- package/lib/Dashboard.d.ts +14 -0
- package/lib/Dashboard.js +84 -0
- package/lib/container/helpers/HelperInversify.d.ts +6 -0
- package/lib/container/helpers/HelperInversify.js +10 -0
- package/lib/container/helpers/HelperTypes.d.ts +5 -0
- package/lib/container/helpers/HelperTypes.js +7 -0
- package/lib/container/index.d.ts +1 -0
- package/lib/container/index.js +14 -0
- package/lib/container/repositories/RepositoryInversify.d.ts +4 -0
- package/lib/container/repositories/RepositoryInversify.js +13 -0
- package/lib/container/repositories/RepositoryTypes.d.ts +4 -0
- package/lib/container/repositories/RepositoryTypes.js +6 -0
- package/lib/container/types.d.ts +8 -0
- package/lib/container/types.js +9 -0
- package/lib/controllers/ActionController.d.ts +8 -0
- package/lib/controllers/ActionController.js +74 -0
- package/lib/controllers/DashboardController.d.ts +36 -0
- package/lib/controllers/DashboardController.js +335 -0
- package/lib/controllers/ResourceController.d.ts +9 -0
- package/lib/controllers/ResourceController.js +95 -0
- package/lib/helpers/ActionsGenerator.d.ts +9 -0
- package/lib/helpers/ActionsGenerator.js +77 -0
- package/lib/helpers/LocalesHelper.d.ts +4 -0
- package/lib/helpers/LocalesHelper.js +73 -0
- package/lib/helpers/ResourceGenerator.d.ts +4 -0
- package/lib/helpers/ResourceGenerator.js +68 -0
- package/lib/helpers/ResourceHelper.d.ts +23 -0
- package/lib/helpers/ResourceHelper.js +274 -0
- package/lib/helpers/SchemaGenerator.d.ts +5 -0
- package/lib/helpers/SchemaGenerator.js +87 -0
- package/lib/helpers/SchemaHelper.d.ts +5 -0
- package/lib/helpers/SchemaHelper.js +21 -0
- package/lib/locales/en.json +11 -0
- package/lib/middlewares/isAuth.d.ts +13 -0
- package/lib/middlewares/isAuth.js +43 -0
- package/lib/models/ModelNames.d.ts +4 -0
- package/lib/models/ModelNames.js +7 -0
- package/lib/models/request-log/IRequestLog.d.ts +22 -0
- package/lib/models/request-log/IRequestLog.js +2 -0
- package/lib/models/request-log/RequestLog.d.ts +3 -0
- package/lib/models/request-log/RequestLog.js +51 -0
- package/lib/repositories/DashboardRepository.d.ts +5 -0
- package/lib/repositories/DashboardRepository.js +12 -0
- package/lib/repositories/Repository.d.ts +68 -0
- package/lib/repositories/Repository.js +212 -0
- package/lib/repositories/RequestLogRepository.d.ts +10 -0
- package/lib/repositories/RequestLogRepository.js +54 -0
- package/lib/repositories/SaveResult.d.ts +14 -0
- package/lib/repositories/SaveResult.js +18 -0
- package/lib/router/index.d.ts +8 -0
- package/lib/router/index.js +95 -0
- package/lib/types/DashbordConfig.d.ts +19 -0
- package/lib/types/DashbordConfig.js +2 -0
- package/lib/types/IResourceFile.d.ts +123 -0
- package/lib/types/IResourceFile.js +2 -0
- package/lib/types/helpers.d.ts +15 -0
- package/lib/types/helpers.js +21 -0
- package/lib/utils/ResourceUtils.d.ts +2 -0
- package/lib/utils/ResourceUtils.js +7 -0
- package/lib/utils/ResponseUtils.d.ts +12 -0
- package/lib/utils/ResponseUtils.js +72 -0
- package/lib/utils/StringUtils.d.ts +9 -0
- package/lib/utils/StringUtils.js +46 -0
- package/lib/view/_redirects +1 -0
- package/lib/view/asset-manifest.json +19 -0
- package/lib/view/assets/bg_card.png +0 -0
- package/lib/view/assets/bg_gradient.jpeg +0 -0
- package/lib/view/assets/icons/delete_icon.svg +3 -0
- package/lib/view/assets/icons/flags/ic_flag_cn.svg +10 -0
- package/lib/view/assets/icons/flags/ic_flag_de.svg +1 -0
- package/lib/view/assets/icons/flags/ic_flag_en.svg +1 -0
- package/lib/view/assets/icons/flags/ic_flag_fr.svg +1 -0
- package/lib/view/assets/icons/flags/ic_flag_kr.svg +1 -0
- package/lib/view/assets/icons/flags/ic_flag_sa.svg +10 -0
- package/lib/view/assets/icons/flags/ic_flag_us.svg +1 -0
- package/lib/view/assets/icons/flags/ic_flag_vn.svg +10 -0
- package/lib/view/assets/icons/info_icon.svg +3 -0
- package/lib/view/assets/icons/navbar/ic_analytics.svg +1 -0
- package/lib/view/assets/icons/navbar/ic_banking.svg +5 -0
- package/lib/view/assets/icons/navbar/ic_blog.svg +1 -0
- package/lib/view/assets/icons/navbar/ic_booking.svg +1 -0
- package/lib/view/assets/icons/navbar/ic_calendar.svg +1 -0
- package/lib/view/assets/icons/navbar/ic_cart.svg +1 -0
- package/lib/view/assets/icons/navbar/ic_chat.svg +1 -0
- package/lib/view/assets/icons/navbar/ic_dashboard.svg +1 -0
- package/lib/view/assets/icons/navbar/ic_ecommerce.svg +1 -0
- package/lib/view/assets/icons/navbar/ic_invoice.svg +4 -0
- package/lib/view/assets/icons/navbar/ic_kanban.svg +8 -0
- package/lib/view/assets/icons/navbar/ic_mail.svg +1 -0
- package/lib/view/assets/icons/navbar/ic_menu_item.svg +9 -0
- package/lib/view/assets/icons/navbar/ic_user.svg +1 -0
- package/lib/view/assets/icons/small_info_icon.svg +3 -0
- package/lib/view/assets/illustrations/Group 16.svg +4 -0
- package/lib/view/assets/illustrations/illustration_components.png +0 -0
- package/lib/view/assets/illustrations/illustration_dashboard.png +0 -0
- package/lib/view/assets/illustrations/illustration_empty_cart.svg +1 -0
- package/lib/view/assets/illustrations/illustration_empty_content.svg +1 -0
- package/lib/view/assets/illustrations/illustration_empty_mail.svg +1 -0
- package/lib/view/assets/illustrations/illustration_invite.png +0 -0
- package/lib/view/assets/illustrations/illustration_login.png +0 -0
- package/lib/view/assets/illustrations/illustration_register.png +0 -0
- package/lib/view/assets/illustrations/logo.svg +5 -0
- package/lib/view/assets/illustrations/welcome_image.png +0 -0
- package/lib/view/assets/overlay.svg +1 -0
- package/lib/view/assets/placeholder.svg +1 -0
- package/lib/view/favicon/android-chrome-192x192.png +0 -0
- package/lib/view/favicon/android-chrome-512x512.png +0 -0
- package/lib/view/favicon/apple-touch-icon-precomposed.png +0 -0
- package/lib/view/favicon/apple-touch-icon.png +0 -0
- package/lib/view/favicon/browserconfig.xml +9 -0
- package/lib/view/favicon/favicon-16x16.png +0 -0
- package/lib/view/favicon/favicon-32x32.png +0 -0
- package/lib/view/favicon/favicon.ico +0 -0
- package/lib/view/favicon/mstile-150x150.png +0 -0
- package/lib/view/favicon/safari-pinned-tab.svg +182 -0
- package/lib/view/favicon/site.webmanifest +19 -0
- package/lib/view/fonts/CircularStd-Bold.otf +0 -0
- package/lib/view/fonts/CircularStd-Book.otf +0 -0
- package/lib/view/fonts/CircularStd-Medium.otf +0 -0
- package/lib/view/fonts/Roboto-Bold.ttf +0 -0
- package/lib/view/fonts/Roboto-Regular.ttf +0 -0
- package/lib/view/fonts/index.css +18 -0
- package/lib/view/index.html +1 -0
- package/lib/view/logo/logo_full.jpg +0 -0
- package/lib/view/logo/logo_full.svg +1 -0
- package/lib/view/logo/logo_single.svg +1 -0
- package/lib/view/manifest.json +20 -0
- package/lib/view/robots.txt +3 -0
- package/lib/view/static/css/main.faf63983.css +2 -0
- package/lib/view/static/css/main.faf63983.css.map +1 -0
- package/lib/view/static/js/13.d8bc0c19.chunk.js +2 -0
- package/lib/view/static/js/13.d8bc0c19.chunk.js.map +1 -0
- package/lib/view/static/js/574.f1fff658.chunk.js +2 -0
- package/lib/view/static/js/574.f1fff658.chunk.js.map +1 -0
- package/lib/view/static/js/678.fddff388.chunk.js +2 -0
- package/lib/view/static/js/678.fddff388.chunk.js.map +1 -0
- package/lib/view/static/js/main.2a2ccfb1.js +3 -0
- package/lib/view/static/js/main.2a2ccfb1.js.LICENSE.txt +223 -0
- package/lib/view/static/js/main.2a2ccfb1.js.map +1 -0
- package/package.json +44 -0
- package/src/Dashboard.ts +74 -0
- package/src/controllers/ActionController.ts +64 -0
- package/src/controllers/DashboardController.ts +388 -0
- package/src/controllers/ResourceController.ts +62 -0
- package/src/helpers/ActionsGenerator.ts +106 -0
- package/src/helpers/ResourceGenerator.ts +90 -0
- package/src/helpers/ResourceHelper.ts +391 -0
- package/src/helpers/SchemaGenerator.ts +120 -0
- package/src/helpers/SchemaHelper.ts +27 -0
- package/src/locales/en.json +11 -0
- package/src/middlewares/isAuth.ts +46 -0
- package/src/models/ModelNames.ts +6 -0
- package/src/models/request-log/IRequestLog.ts +25 -0
- package/src/models/request-log/RequestLog.ts +52 -0
- package/src/repositories/DashboardRepository.ts +11 -0
- package/src/repositories/Repository.ts +269 -0
- package/src/repositories/RequestLogRepository.ts +40 -0
- package/src/repositories/SaveResult.ts +31 -0
- package/src/router/index.ts +91 -0
- package/src/types/DashbordConfig.ts +24 -0
- package/src/types/IResourceFile.ts +240 -0
- package/src/types/helpers.ts +17 -0
- package/src/utils/ResourceUtils.ts +5 -0
- package/src/utils/ResponseUtils.ts +68 -0
- package/src/utils/StringUtils.ts +63 -0
- package/tsconfig.json +17 -0
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
9
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
10
|
+
};
|
|
11
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
21
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
22
|
+
};
|
|
23
|
+
var DashboardController_1;
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
const inversify_express_utils_1 = require("inversify-express-utils");
|
|
26
|
+
const mongoose_1 = require("mongoose");
|
|
27
|
+
const ResponseUtils_1 = __importDefault(require("../utils/ResponseUtils"));
|
|
28
|
+
const express_validator_1 = require("express-validator");
|
|
29
|
+
const ResourceGenerator_1 = __importDefault(require("../helpers/ResourceGenerator"));
|
|
30
|
+
const ResourceHelper_1 = __importDefault(require("../helpers/ResourceHelper"));
|
|
31
|
+
const StringUtils_1 = __importDefault(require("../utils/StringUtils"));
|
|
32
|
+
const mongoose_2 = __importDefault(require("mongoose"));
|
|
33
|
+
const inversify_1 = require("inversify");
|
|
34
|
+
const Repository_1 = __importDefault(require("../repositories/Repository"));
|
|
35
|
+
const ResourceUtils_1 = require("../utils/ResourceUtils");
|
|
36
|
+
let DashboardController = DashboardController_1 = class DashboardController {
|
|
37
|
+
constructor(resource, repository, resources) {
|
|
38
|
+
this.resource = resource;
|
|
39
|
+
this.repository = repository;
|
|
40
|
+
this.resources = resources;
|
|
41
|
+
if (!repository && resource) {
|
|
42
|
+
this.repository = new Repository_1.default(resource.properties.resource);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
validateRequest(req, res) {
|
|
46
|
+
const errors = (0, express_validator_1.validationResult)(req);
|
|
47
|
+
if (!errors.isEmpty()) {
|
|
48
|
+
ResponseUtils_1.default.send(res, 422, errors.array()[0].msg, errors);
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
paginateParams(request) {
|
|
54
|
+
const page = request.query.page ? +request.query.page : DashboardController_1.DEFAULT_PAGE;
|
|
55
|
+
const perPage = request.query.perPage ? +request.query.perPage : DashboardController_1.DEFAULT_PER_PAGE;
|
|
56
|
+
return { page, perPage };
|
|
57
|
+
}
|
|
58
|
+
getSearchableSubStringFilter(resource, filter, subString) {
|
|
59
|
+
const schema = resource.properties.resource.schema.paths;
|
|
60
|
+
const searchBy = ResourceHelper_1.default.getSchemaTitle(schema, this.resource);
|
|
61
|
+
if (searchBy === '_id') {
|
|
62
|
+
if (!mongoose_2.default.isValidObjectId(subString.source)) {
|
|
63
|
+
return filter;
|
|
64
|
+
}
|
|
65
|
+
filter[searchBy] = subString.source;
|
|
66
|
+
return filter;
|
|
67
|
+
}
|
|
68
|
+
filter[searchBy] = subString;
|
|
69
|
+
return filter;
|
|
70
|
+
}
|
|
71
|
+
getScopeFilter(filter, scope) {
|
|
72
|
+
return {};
|
|
73
|
+
}
|
|
74
|
+
getVisibileExtrsActions(currentUser, record, resource, repository, modelName) {
|
|
75
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
const data = {
|
|
77
|
+
record: record.toObject(),
|
|
78
|
+
currentUser,
|
|
79
|
+
resource: {
|
|
80
|
+
name: modelName,
|
|
81
|
+
path: StringUtils_1.default.lowerCaseFirstLetter(modelName),
|
|
82
|
+
repository
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
if (!resource.properties.actions || !resource.properties.actions.extras) {
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
var extraActionsArray = [];
|
|
89
|
+
const extraActions = resource.properties.actions.extras;
|
|
90
|
+
for (var i = 0; i < extraActions.length; i++) {
|
|
91
|
+
const extraAction = extraActions[i];
|
|
92
|
+
if (!extraAction.isVisible) {
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
const isVisible = extraAction.isVisible(data);
|
|
96
|
+
if (isVisible) {
|
|
97
|
+
extraActionsArray.push(extraAction.key);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return extraActionsArray;
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
index(req, res) {
|
|
104
|
+
var _a, _b, _c;
|
|
105
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
106
|
+
if (!this.validateRequest(req, res)) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const paginateParams = this.paginateParams(req);
|
|
110
|
+
const searchableSubString = req.query.filter ? new RegExp(req.query.filter, 'i') : undefined;
|
|
111
|
+
const scope = req.query.scope;
|
|
112
|
+
const currentUser = req.user;
|
|
113
|
+
const modelName = req.params.resource;
|
|
114
|
+
const resource = (_a = this.resource) !== null && _a !== void 0 ? _a : (0, ResourceUtils_1.getResource)(modelName, (_b = this.resources) !== null && _b !== void 0 ? _b : []);
|
|
115
|
+
if (!resource) {
|
|
116
|
+
return ResponseUtils_1.default.notFound(res, 'Resource not found', []);
|
|
117
|
+
}
|
|
118
|
+
const repository = (_c = this.repository) !== null && _c !== void 0 ? _c : new Repository_1.default(resource.properties.resource);
|
|
119
|
+
const modifiedResource = ResourceGenerator_1.default.generate(resource);
|
|
120
|
+
const sort = req.query.order;
|
|
121
|
+
const sortBy = req.query.orderBy;
|
|
122
|
+
const sortQuery = {};
|
|
123
|
+
sortQuery[sortBy] = sort;
|
|
124
|
+
if (sortBy !== '_id') {
|
|
125
|
+
sortQuery._id = 'asc';
|
|
126
|
+
}
|
|
127
|
+
const populate = req.query.populate;
|
|
128
|
+
var filter = {};
|
|
129
|
+
const crudOperations = resource.properties.crudOperations;
|
|
130
|
+
if (crudOperations && crudOperations.index) {
|
|
131
|
+
filter = crudOperations.index.before(filter, currentUser);
|
|
132
|
+
}
|
|
133
|
+
if (scope) {
|
|
134
|
+
filter = this.getScopeFilter(filter, scope);
|
|
135
|
+
}
|
|
136
|
+
if (searchableSubString) {
|
|
137
|
+
filter = this.getSearchableSubStringFilter(resource, filter, searchableSubString);
|
|
138
|
+
}
|
|
139
|
+
var records = [];
|
|
140
|
+
var pageInfo = undefined;
|
|
141
|
+
if (!req.query.page && !req.query.perPage) {
|
|
142
|
+
records = yield repository.findMany({
|
|
143
|
+
sort: sortQuery,
|
|
144
|
+
filter,
|
|
145
|
+
populate: modifiedResource.properties.populatedString
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
const page = yield repository.paginate({
|
|
150
|
+
sort: sortQuery,
|
|
151
|
+
filter,
|
|
152
|
+
paginateParams: paginateParams,
|
|
153
|
+
populate: modifiedResource.properties.populatedString
|
|
154
|
+
});
|
|
155
|
+
records = page.records;
|
|
156
|
+
pageInfo = page.pageInfo;
|
|
157
|
+
}
|
|
158
|
+
var documents = [];
|
|
159
|
+
for (var i = 0; i < records.length; i++) {
|
|
160
|
+
const record = records[i];
|
|
161
|
+
const extraActionKeys = yield this.getVisibileExtrsActions(currentUser, record, resource, repository, modifiedResource.properties.modelName);
|
|
162
|
+
if (extraActionKeys) {
|
|
163
|
+
const recordFlatten = record.toObject();
|
|
164
|
+
recordFlatten.extraActionKeys = extraActionKeys;
|
|
165
|
+
documents.push(recordFlatten);
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
documents.push(record);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return ResponseUtils_1.default.send(res, 200, 'OK', {
|
|
172
|
+
records: documents,
|
|
173
|
+
pageInfo,
|
|
174
|
+
//options: modifiedResource
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
create(req, res) {
|
|
179
|
+
var _a, _b, _c;
|
|
180
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
181
|
+
if (!this.validateRequest(req, res)) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
const modelName = req.params.resource;
|
|
185
|
+
const resource = (_a = this.resource) !== null && _a !== void 0 ? _a : (0, ResourceUtils_1.getResource)(modelName, (_b = this.resources) !== null && _b !== void 0 ? _b : []);
|
|
186
|
+
if (!resource) {
|
|
187
|
+
return ResponseUtils_1.default.notFound(res, 'Resource not found', []);
|
|
188
|
+
}
|
|
189
|
+
const repository = (_c = this.repository) !== null && _c !== void 0 ? _c : new Repository_1.default(resource.properties.resource);
|
|
190
|
+
const modifiedResource = ResourceGenerator_1.default.generate(resource);
|
|
191
|
+
var recordParams = req.body;
|
|
192
|
+
const currentUser = req.user;
|
|
193
|
+
const crudOperations = resource.properties.crudOperations;
|
|
194
|
+
if (crudOperations && crudOperations.create) {
|
|
195
|
+
recordParams = crudOperations.create.before(recordParams, currentUser);
|
|
196
|
+
}
|
|
197
|
+
var record;
|
|
198
|
+
if (recordParams.password) {
|
|
199
|
+
const user = new mongoose_1.Mongoose.prototype.model(modifiedResource.properties.modelName)(recordParams);
|
|
200
|
+
const set = yield user.setPassword(recordParams.password);
|
|
201
|
+
record = yield repository.saveInstance(user);
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
record = yield repository.save(recordParams);
|
|
205
|
+
}
|
|
206
|
+
if (!record.isValid() || !record.document) {
|
|
207
|
+
return ResponseUtils_1.default.unprocessable(res, 'Invalid Data', record.getErrors());
|
|
208
|
+
}
|
|
209
|
+
return ResponseUtils_1.default.created(res, {
|
|
210
|
+
record
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
update(req, res) {
|
|
215
|
+
var _a, _b, _c;
|
|
216
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
217
|
+
if (!this.validateRequest(req, res)) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
const modelName = req.params.resource;
|
|
221
|
+
const resource = (_a = this.resource) !== null && _a !== void 0 ? _a : (0, ResourceUtils_1.getResource)(modelName, (_b = this.resources) !== null && _b !== void 0 ? _b : []);
|
|
222
|
+
if (!resource) {
|
|
223
|
+
return ResponseUtils_1.default.notFound(res, 'Resource not found', []);
|
|
224
|
+
}
|
|
225
|
+
const repository = (_c = this.repository) !== null && _c !== void 0 ? _c : new Repository_1.default(resource.properties.resource);
|
|
226
|
+
const recordId = req.params.id;
|
|
227
|
+
var recordParams = req.body;
|
|
228
|
+
var record = yield repository.findById(recordId);
|
|
229
|
+
if (!record) {
|
|
230
|
+
return ResponseUtils_1.default.send(res, 404, 'record Not Found');
|
|
231
|
+
}
|
|
232
|
+
const recordSaveResult = yield repository.update(record, recordParams);
|
|
233
|
+
if (!recordSaveResult.isValid()) {
|
|
234
|
+
return ResponseUtils_1.default.unprocessable(res, 'Invalid Data', recordSaveResult.getErrors());
|
|
235
|
+
}
|
|
236
|
+
// if (resource.properties.modelName === ModelNames.Settings) {
|
|
237
|
+
// await AppSettings.run()
|
|
238
|
+
// }
|
|
239
|
+
return ResponseUtils_1.default.ok(res, {
|
|
240
|
+
record: recordSaveResult
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
show(req, res) {
|
|
245
|
+
var _a, _b, _c;
|
|
246
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
247
|
+
if (!this.validateRequest(req, res)) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
const modelName = req.params.resource;
|
|
251
|
+
const recordId = req.params.id;
|
|
252
|
+
const resource = (_a = this.resource) !== null && _a !== void 0 ? _a : (0, ResourceUtils_1.getResource)(modelName, (_b = this.resources) !== null && _b !== void 0 ? _b : []);
|
|
253
|
+
if (!resource) {
|
|
254
|
+
return ResponseUtils_1.default.notFound(res, 'Resource not found', []);
|
|
255
|
+
}
|
|
256
|
+
const repository = (_c = this.repository) !== null && _c !== void 0 ? _c : new Repository_1.default(resource.properties.resource);
|
|
257
|
+
const modifiedResource = ResourceGenerator_1.default.generate(resource);
|
|
258
|
+
var record = yield repository.findOne({
|
|
259
|
+
filter: {
|
|
260
|
+
_id: recordId
|
|
261
|
+
},
|
|
262
|
+
populate: modifiedResource.properties.populatedString
|
|
263
|
+
});
|
|
264
|
+
if (!record) {
|
|
265
|
+
return ResponseUtils_1.default.send(res, 404, 'record not found');
|
|
266
|
+
}
|
|
267
|
+
record = record.toObject();
|
|
268
|
+
//record = await this.getExtras(record._id.toString(), record, this.getExtraRepository())
|
|
269
|
+
record = yield ResourceHelper_1.default.addExtraFields(modifiedResource.showProperties, modifiedResource.properties.model, record, StringUtils_1.default.lowerCaseFirstLetter(modifiedResource.properties.modelName), repository);
|
|
270
|
+
return ResponseUtils_1.default.ok(res, {
|
|
271
|
+
record: record ? record : null,
|
|
272
|
+
// options: modifiedResource
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
delete(req, res) {
|
|
277
|
+
var _a, _b, _c;
|
|
278
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
279
|
+
if (!this.validateRequest(req, res)) {
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
const modelName = req.params.resource;
|
|
283
|
+
const recordId = req.params.id;
|
|
284
|
+
const resource = (_a = this.resource) !== null && _a !== void 0 ? _a : (0, ResourceUtils_1.getResource)(modelName, (_b = this.resources) !== null && _b !== void 0 ? _b : []);
|
|
285
|
+
if (!resource) {
|
|
286
|
+
return ResponseUtils_1.default.notFound(res, 'Resource not found', []);
|
|
287
|
+
}
|
|
288
|
+
const repository = (_c = this.repository) !== null && _c !== void 0 ? _c : new Repository_1.default(resource.properties.resource);
|
|
289
|
+
const record = yield repository.findById(recordId);
|
|
290
|
+
if (!record) {
|
|
291
|
+
return ResponseUtils_1.default.send(res, 404, 'record Not Found');
|
|
292
|
+
}
|
|
293
|
+
yield repository.remove({ _id: record._id });
|
|
294
|
+
return ResponseUtils_1.default.send(res, 200, 'OK');
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
DashboardController.DEFAULT_PAGE = 1;
|
|
299
|
+
DashboardController.DEFAULT_PER_PAGE = 30;
|
|
300
|
+
__decorate([
|
|
301
|
+
__param(0, (0, inversify_express_utils_1.request)()),
|
|
302
|
+
__param(1, (0, inversify_express_utils_1.response)())
|
|
303
|
+
], DashboardController.prototype, "validateRequest", null);
|
|
304
|
+
__decorate([
|
|
305
|
+
(0, inversify_express_utils_1.httpGet)('/'),
|
|
306
|
+
__param(0, (0, inversify_express_utils_1.request)()),
|
|
307
|
+
__param(1, (0, inversify_express_utils_1.response)())
|
|
308
|
+
], DashboardController.prototype, "index", null);
|
|
309
|
+
__decorate([
|
|
310
|
+
(0, inversify_express_utils_1.httpPost)('/'),
|
|
311
|
+
__param(0, (0, inversify_express_utils_1.request)()),
|
|
312
|
+
__param(1, (0, inversify_express_utils_1.response)())
|
|
313
|
+
], DashboardController.prototype, "create", null);
|
|
314
|
+
__decorate([
|
|
315
|
+
(0, inversify_express_utils_1.httpPatch)('/:id'),
|
|
316
|
+
__param(0, (0, inversify_express_utils_1.request)()),
|
|
317
|
+
__param(1, (0, inversify_express_utils_1.response)())
|
|
318
|
+
], DashboardController.prototype, "update", null);
|
|
319
|
+
__decorate([
|
|
320
|
+
(0, inversify_express_utils_1.httpGet)('/:id'),
|
|
321
|
+
__param(0, (0, inversify_express_utils_1.request)()),
|
|
322
|
+
__param(1, (0, inversify_express_utils_1.response)())
|
|
323
|
+
], DashboardController.prototype, "show", null);
|
|
324
|
+
__decorate([
|
|
325
|
+
(0, inversify_express_utils_1.httpDelete)('/:id'),
|
|
326
|
+
__param(0, (0, inversify_express_utils_1.request)()),
|
|
327
|
+
__param(1, (0, inversify_express_utils_1.response)())
|
|
328
|
+
], DashboardController.prototype, "delete", null);
|
|
329
|
+
DashboardController = DashboardController_1 = __decorate([
|
|
330
|
+
(0, inversify_1.injectable)(),
|
|
331
|
+
__param(0, (0, inversify_1.unmanaged)()),
|
|
332
|
+
__param(1, (0, inversify_1.unmanaged)()),
|
|
333
|
+
__param(2, (0, inversify_1.unmanaged)())
|
|
334
|
+
], DashboardController);
|
|
335
|
+
exports.default = DashboardController;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Response } from 'express';
|
|
2
|
+
import { IResourceFile } from '../types/IResourceFile';
|
|
3
|
+
import { IRequest } from '../middlewares/isAuth';
|
|
4
|
+
export default class ResourceController {
|
|
5
|
+
private resourceFiles;
|
|
6
|
+
constructor(resourceFiles: IResourceFile[]);
|
|
7
|
+
index(req: IRequest, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
8
|
+
getOne(req: IRequest, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
15
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
16
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
17
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
18
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
19
|
+
};
|
|
20
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
21
|
+
if (mod && mod.__esModule) return mod;
|
|
22
|
+
var result = {};
|
|
23
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
24
|
+
__setModuleDefault(result, mod);
|
|
25
|
+
return result;
|
|
26
|
+
};
|
|
27
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
28
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
29
|
+
};
|
|
30
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
31
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
32
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
33
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
34
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
35
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
36
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
40
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
41
|
+
};
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
const inversify_express_utils_1 = require("inversify-express-utils");
|
|
44
|
+
const ResponseUtils_1 = __importDefault(require("../utils/ResponseUtils"));
|
|
45
|
+
const StringUtils_1 = __importDefault(require("../utils/StringUtils"));
|
|
46
|
+
const ResourceGenerator_1 = __importDefault(require("../helpers/ResourceGenerator"));
|
|
47
|
+
class ResourceController {
|
|
48
|
+
constructor(resourceFiles) {
|
|
49
|
+
this.resourceFiles = resourceFiles;
|
|
50
|
+
}
|
|
51
|
+
index(req, res) {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
var modifiedResource = {};
|
|
54
|
+
modifiedResource.modelParents = {};
|
|
55
|
+
for (var i = 0; i < this.resourceFiles.length; i++) {
|
|
56
|
+
const resource = this.resourceFiles[i];
|
|
57
|
+
const adaptedResource = ResourceGenerator_1.default.generate(resource);
|
|
58
|
+
const modelName = StringUtils_1.default.lowerCaseFirstLetter(adaptedResource.properties.modelName);
|
|
59
|
+
modifiedResource[modelName] = adaptedResource;
|
|
60
|
+
if (modifiedResource.modelParents[adaptedResource.properties.parent.name]) {
|
|
61
|
+
modifiedResource.modelParents[adaptedResource.properties.parent.name].push(modelName);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
modifiedResource.modelParents[adaptedResource.properties.parent.name] = [];
|
|
65
|
+
modifiedResource.modelParents[adaptedResource.properties.parent.name].push(modelName);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return ResponseUtils_1.default.send(res, 200, 'OK', {
|
|
69
|
+
resources: modifiedResource
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
getOne(req, res) {
|
|
74
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
const modelName = req.params.modelName;
|
|
76
|
+
const resourceName = modelName + 'Resource';
|
|
77
|
+
const resourceFilePath = '@pbb/materialUi/' + resourceName;
|
|
78
|
+
const resource = yield Promise.resolve().then(() => __importStar(require(resourceFilePath)));
|
|
79
|
+
return ResponseUtils_1.default.send(res, 200, 'OK', {
|
|
80
|
+
options: ResourceGenerator_1.default.generate(resource[resourceName])
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
__decorate([
|
|
86
|
+
(0, inversify_express_utils_1.httpGet)('/'),
|
|
87
|
+
__param(0, (0, inversify_express_utils_1.request)()),
|
|
88
|
+
__param(1, (0, inversify_express_utils_1.response)())
|
|
89
|
+
], ResourceController.prototype, "index", null);
|
|
90
|
+
__decorate([
|
|
91
|
+
(0, inversify_express_utils_1.httpGet)('/:modelName'),
|
|
92
|
+
__param(0, (0, inversify_express_utils_1.request)()),
|
|
93
|
+
__param(1, (0, inversify_express_utils_1.response)())
|
|
94
|
+
], ResourceController.prototype, "getOne", null);
|
|
95
|
+
exports.default = ResourceController;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IResourceFile } from "../types/IResourceFile";
|
|
2
|
+
export default class ActionsGenerator {
|
|
3
|
+
static generateActions(actionsCheck: any, resource: IResourceFile): {
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
};
|
|
6
|
+
private static addExtraActions;
|
|
7
|
+
private static getActions;
|
|
8
|
+
private static appendActionValues;
|
|
9
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const i18n_1 = require("i18n");
|
|
7
|
+
const ResourceHelper_1 = __importDefault(require("./ResourceHelper"));
|
|
8
|
+
var pluralize = require('pluralize');
|
|
9
|
+
class ActionsGenerator {
|
|
10
|
+
static generateActions(actionsCheck, resource) {
|
|
11
|
+
const actions = this.getActions(actionsCheck ? JSON.parse(JSON.stringify(resource.properties.actions)) : undefined); //resource.properties.actions? ResourcesHelper.getActions(JSON.parse(JSON.stringify(resource.properties.actions))): ResourcesHelper.getActions(undefined)
|
|
12
|
+
for (const key in actions) {
|
|
13
|
+
if (key === 'extras') {
|
|
14
|
+
actions.extras = actions.extras ? this.addExtraActions(JSON.parse(JSON.stringify(resource.properties.actions.extras))) : actions.extras;
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
const translation = ResourceHelper_1.default.checkActionTranslation(resource, key);
|
|
18
|
+
actions[key] = this.appendActionValues(key, actions[key], translation);
|
|
19
|
+
}
|
|
20
|
+
return actions;
|
|
21
|
+
}
|
|
22
|
+
static addExtraActions(extraActions) {
|
|
23
|
+
var extraActionsObject = {
|
|
24
|
+
record: {},
|
|
25
|
+
resource: {}
|
|
26
|
+
};
|
|
27
|
+
extraActions.forEach((action) => {
|
|
28
|
+
action.keys = action.isVisible ? Object.keys(action.isVisible) : [];
|
|
29
|
+
action.actionType ? extraActionsObject[action.actionType][action.key] = action : '';
|
|
30
|
+
});
|
|
31
|
+
return extraActionsObject;
|
|
32
|
+
}
|
|
33
|
+
static getActions(actions) {
|
|
34
|
+
var actionObject = {
|
|
35
|
+
show: { isAccessible: true },
|
|
36
|
+
new: { isAccessible: true },
|
|
37
|
+
edit: { isAccessible: true },
|
|
38
|
+
delete: { isAccessible: true },
|
|
39
|
+
bulkDelete: { isAccessible: false },
|
|
40
|
+
};
|
|
41
|
+
if (!actions || Object.keys(actions).length === 0) {
|
|
42
|
+
return actionObject;
|
|
43
|
+
}
|
|
44
|
+
for (const key in actions) {
|
|
45
|
+
if (actions[key].hasOwnProperty('isAccessible') || key === 'extras') {
|
|
46
|
+
actionObject[key] = actions[key];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return actionObject;
|
|
50
|
+
}
|
|
51
|
+
static appendActionValues(action, actionObject, translation) {
|
|
52
|
+
switch (action) {
|
|
53
|
+
case 'new':
|
|
54
|
+
actionObject.value = translation ? translation : (0, i18n_1.__)("actions_new");
|
|
55
|
+
break;
|
|
56
|
+
case 'edit':
|
|
57
|
+
actionObject.value = translation ? translation : (0, i18n_1.__)("actions_edit");
|
|
58
|
+
break;
|
|
59
|
+
case 'delete':
|
|
60
|
+
actionObject.value = translation ? translation : (0, i18n_1.__)("actions_delete");
|
|
61
|
+
actionObject.confirmationMessageTitle = (0, i18n_1.__)("actions_delete_confirmMessage_title");
|
|
62
|
+
actionObject.confirmationMessageBody = (0, i18n_1.__)("actions_delete_confirmMessage_body");
|
|
63
|
+
actionObject.confirmDeleteOption = (0, i18n_1.__)("actions_delete_options_yes");
|
|
64
|
+
actionObject.cancelDeleteOption = (0, i18n_1.__)("actions_delete_options_no");
|
|
65
|
+
break;
|
|
66
|
+
case 'bulkDelete':
|
|
67
|
+
actionObject.value = translation ? translation : (0, i18n_1.__)("actions_delete");
|
|
68
|
+
actionObject.confirmationMessageTitle = (0, i18n_1.__)("actions_bulkDelete_confirmMessage_title");
|
|
69
|
+
actionObject.confirmationMessageBody = (0, i18n_1.__)("actions_bulkDelete_confirmMessage_body");
|
|
70
|
+
actionObject.confirmDeleteOption = (0, i18n_1.__)("actions_delete_options_yes");
|
|
71
|
+
actionObject.cancelDeleteOption = (0, i18n_1.__)("actions_delete_options_no");
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
return actionObject;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.default = ActionsGenerator;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
// import { AdminParent, SetupParent } from "@pbb/materialUi/parents";
|
|
7
|
+
const StringUtils_1 = __importDefault(require("../utils/StringUtils"));
|
|
8
|
+
const ResourceHelper_1 = __importDefault(require("./ResourceHelper"));
|
|
9
|
+
var pluralize = require('pluralize');
|
|
10
|
+
class LocalesHelper {
|
|
11
|
+
static localizeResource(resource) {
|
|
12
|
+
var _a, _b, _c, _d, _e;
|
|
13
|
+
const modelName = resource.resource.modelName;
|
|
14
|
+
const modifiedResource = JSON.parse(JSON.stringify(resource));
|
|
15
|
+
const title = ResourceHelper_1.default.getSchemaTitle(modelName, resource);
|
|
16
|
+
const schema = resource.resource.schema.paths;
|
|
17
|
+
const recordFields = ResourceHelper_1.default.manageFields(schema, title, resource.properties.hiddenProperties);
|
|
18
|
+
const modelCheck = resource.properties.model ? JSON.parse(JSON.stringify(resource.properties.model)) : undefined;
|
|
19
|
+
const actionsCheck = resource.properties.actions;
|
|
20
|
+
const modelAndPopulatedString = ResourceHelper_1.default.setModelSchema(schema, modelCheck, modelName);
|
|
21
|
+
modifiedResource.properties.model = modelAndPopulatedString[0];
|
|
22
|
+
modifiedResource.properties.populatedString = modelAndPopulatedString[1];
|
|
23
|
+
const modifiedProperties = ResourceHelper_1.default.addVirtualFields(JSON.parse(JSON.stringify(recordFields)), modelCheck);
|
|
24
|
+
modifiedResource.properties.path = ResourceHelper_1.default.getModelPath(modelName);
|
|
25
|
+
const modifiedListProperties = modifiedProperties[0];
|
|
26
|
+
const modifiedShowProperties = modifiedProperties[1];
|
|
27
|
+
const modifiedFormProperties = modifiedProperties[2];
|
|
28
|
+
if (!resource.properties.parent) {
|
|
29
|
+
//modifiedResource.properties.parent = SetupParent
|
|
30
|
+
}
|
|
31
|
+
if (!resource.properties.name) {
|
|
32
|
+
modifiedResource.properties.name = StringUtils_1.default.convertCamelCaseToWord(modelName);
|
|
33
|
+
}
|
|
34
|
+
if (!resource.showProperties) {
|
|
35
|
+
modifiedResource.showProperties = modifiedShowProperties;
|
|
36
|
+
}
|
|
37
|
+
if (!resource.listProperties) {
|
|
38
|
+
modifiedResource.listProperties = ResourceHelper_1.default.exchangeFirstFieldWithTitle(JSON.parse(JSON.stringify(modifiedListProperties)), title);
|
|
39
|
+
}
|
|
40
|
+
if (!resource.formProperties) {
|
|
41
|
+
modifiedResource.formProperties = ResourceHelper_1.default.removeUnWantedFieldsFromCreateOrUpdate(JSON.parse(JSON.stringify(modifiedFormProperties)));
|
|
42
|
+
}
|
|
43
|
+
modifiedResource.properties.title = title;
|
|
44
|
+
if (!resource.properties.defaultOrderBy) {
|
|
45
|
+
modifiedResource.properties.defaultOrderBy = title;
|
|
46
|
+
}
|
|
47
|
+
if (!resource.properties.defaultOrder) {
|
|
48
|
+
modifiedResource.properties.defaultOrder = 'asc';
|
|
49
|
+
}
|
|
50
|
+
if (!resource.properties.defaultrowsPerPage) {
|
|
51
|
+
modifiedResource.properties.defaultrowsPerPage = 10;
|
|
52
|
+
}
|
|
53
|
+
modifiedResource.listProperties = ResourceHelper_1.default.prepareProperties(resource.listProperties ? resource.listProperties : modifiedResource.listProperties, modelName, modifiedResource.properties.model);
|
|
54
|
+
modifiedResource.showProperties = ResourceHelper_1.default.prepareProperties(resource.showProperties ? resource.showProperties : modifiedResource.showProperties, modelName, modifiedResource.properties.model);
|
|
55
|
+
modifiedResource.properties.filters = ResourceHelper_1.default.getFilters(resource.properties.filters ? JSON.parse(JSON.stringify(resource.properties.filters)) : undefined);
|
|
56
|
+
if (modifiedResource.properties.filters.scopes.isAccessible) {
|
|
57
|
+
const options = (_c = (_b = (_a = resource === null || resource === void 0 ? void 0 : resource.properties) === null || _a === void 0 ? void 0 : _a.filters) === null || _b === void 0 ? void 0 : _b.scopes) === null || _c === void 0 ? void 0 : _c.options;
|
|
58
|
+
modifiedResource.properties.filters.scopes.options = ResourceHelper_1.default.setScopeFilterOptions(modelName, options);
|
|
59
|
+
}
|
|
60
|
+
const actions = ResourceHelper_1.default.getActions(actionsCheck ? JSON.parse(JSON.stringify(resource.properties.actions)) : undefined); //resource.properties.actions? ResourcesHelper.getActions(JSON.parse(JSON.stringify(resource.properties.actions))): ResourcesHelper.getActions(undefined)
|
|
61
|
+
for (const key in actions) {
|
|
62
|
+
if (key === 'extras') {
|
|
63
|
+
actions.extras = actions.extras ? ResourceHelper_1.default.addExtraActions(JSON.parse(JSON.stringify((_e = (_d = resource === null || resource === void 0 ? void 0 : resource.properties) === null || _d === void 0 ? void 0 : _d.actions) === null || _e === void 0 ? void 0 : _e.extras))) : actions.extras;
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
const translation = ResourceHelper_1.default.checkActionTranslation(modelName, key);
|
|
67
|
+
actions[key] = ResourceHelper_1.default.appendActionValues(key, actions[key], translation);
|
|
68
|
+
}
|
|
69
|
+
modifiedResource.properties.actions = actions;
|
|
70
|
+
return modifiedResource;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.default = LocalesHelper;
|