ps-toolkit-ui 0.0.130 → 0.0.134
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/bundles/ps-toolkit-ui.umd.js +82 -51
- package/bundles/ps-toolkit-ui.umd.js.map +1 -1
- package/bundles/ps-toolkit-ui.umd.min.js +1 -1
- package/bundles/ps-toolkit-ui.umd.min.js.map +1 -1
- package/esm2015/lib/classes/enum.class.js +8 -1
- package/esm2015/lib/classes/permission.class.js +21 -6
- package/esm2015/lib/classes/table.class.js +10 -5
- package/esm2015/lib/components/base.component.js +4 -4
- package/esm2015/lib/components/table/report/table.report.component.js +3 -3
- package/esm2015/lib/components/table/row/table.row.component.js +5 -5
- package/fesm2015/ps-toolkit-ui.js +43 -16
- package/fesm2015/ps-toolkit-ui.js.map +1 -1
- package/lib/classes/enum.class.d.ts +6 -0
- package/lib/classes/permission.class.d.ts +11 -6
- package/package.json +1 -1
- package/ps-toolkit-ui.metadata.json +1 -1
|
@@ -809,6 +809,12 @@
|
|
|
809
809
|
PermissionTypeEnum[PermissionTypeEnum["Access"] = 1] = "Access";
|
|
810
810
|
PermissionTypeEnum[PermissionTypeEnum["Option"] = 2] = "Option";
|
|
811
811
|
})(exports.PermissionTypeEnum || (exports.PermissionTypeEnum = {}));
|
|
812
|
+
(function (PermissionAccessTypeEnum) {
|
|
813
|
+
PermissionAccessTypeEnum[PermissionAccessTypeEnum["List"] = 1] = "List";
|
|
814
|
+
PermissionAccessTypeEnum[PermissionAccessTypeEnum["Insert"] = 2] = "Insert";
|
|
815
|
+
PermissionAccessTypeEnum[PermissionAccessTypeEnum["Update"] = 3] = "Update";
|
|
816
|
+
PermissionAccessTypeEnum[PermissionAccessTypeEnum["Delete"] = 4] = "Delete";
|
|
817
|
+
})(exports.PermissionAccessTypeEnum || (exports.PermissionAccessTypeEnum = {}));
|
|
812
818
|
(function (PermissionInputActionEnum) {
|
|
813
819
|
PermissionInputActionEnum[PermissionInputActionEnum["None"] = 0] = "None";
|
|
814
820
|
PermissionInputActionEnum[PermissionInputActionEnum["Link"] = 1] = "Link";
|
|
@@ -2392,11 +2398,12 @@
|
|
|
2392
2398
|
};
|
|
2393
2399
|
|
|
2394
2400
|
var PermissionClass = /** @class */ (function () {
|
|
2395
|
-
function PermissionClass(Name, Icon, Type, InputType, InputAction, Area, Controller, Action, Condition, Accesses) {
|
|
2401
|
+
function PermissionClass(Name, Icon, Type, InputType, AccessType, InputAction, Area, Controller, Action, Condition, Accesses) {
|
|
2396
2402
|
if (Name === void 0) { Name = ''; }
|
|
2397
2403
|
if (Icon === void 0) { Icon = ''; }
|
|
2398
2404
|
if (Type === void 0) { Type = null; }
|
|
2399
2405
|
if (InputType === void 0) { InputType = null; }
|
|
2406
|
+
if (AccessType === void 0) { AccessType = null; }
|
|
2400
2407
|
if (InputAction === void 0) { InputAction = null; }
|
|
2401
2408
|
if (Area === void 0) { Area = ''; }
|
|
2402
2409
|
if (Controller === void 0) { Controller = ''; }
|
|
@@ -2407,6 +2414,7 @@
|
|
|
2407
2414
|
this.Icon = Icon;
|
|
2408
2415
|
this.Type = Type;
|
|
2409
2416
|
this.InputType = InputType;
|
|
2417
|
+
this.AccessType = AccessType;
|
|
2410
2418
|
this.InputAction = InputAction;
|
|
2411
2419
|
this.Area = Area;
|
|
2412
2420
|
this.Controller = Controller;
|
|
@@ -2416,29 +2424,43 @@
|
|
|
2416
2424
|
this.RelatedId = null;
|
|
2417
2425
|
this.OnClick = null;
|
|
2418
2426
|
}
|
|
2419
|
-
PermissionClass.prototype.
|
|
2427
|
+
PermissionClass.prototype.getAccessByName = function (a) {
|
|
2420
2428
|
var c = this.Accesses.filter(function (x) { return x.Action === a && x.Type === exports.PermissionTypeEnum.Access; });
|
|
2421
2429
|
return c.length > 0 ? c[0] : null;
|
|
2422
2430
|
};
|
|
2423
|
-
PermissionClass.prototype.
|
|
2431
|
+
PermissionClass.prototype.getAccess = function (at) {
|
|
2432
|
+
var c = this.Accesses.filter(function (x) { return x.AccessType === at && x.Type === exports.PermissionTypeEnum.Access; });
|
|
2433
|
+
return c.length > 0 ? c[0] : null;
|
|
2434
|
+
};
|
|
2435
|
+
PermissionClass.prototype.hasAccessByName = function (a) {
|
|
2424
2436
|
return this.Accesses.filter(function (x) { return x.Action === a && x.Type === exports.PermissionTypeEnum.Access; }).length > 0;
|
|
2425
2437
|
};
|
|
2438
|
+
PermissionClass.prototype.hasAccess = function (at) {
|
|
2439
|
+
return this.Accesses.filter(function (x) { return x.AccessType === at && x.Type === exports.PermissionTypeEnum.Access; }).length > 0;
|
|
2440
|
+
};
|
|
2426
2441
|
PermissionClass.prototype.getAccesses = function () {
|
|
2427
2442
|
return this.Accesses.filter(function (x) { return x.Type === exports.PermissionTypeEnum.Access; });
|
|
2428
2443
|
};
|
|
2429
2444
|
PermissionClass.prototype.delete = function (a) {
|
|
2430
2445
|
this.Accesses = this.Accesses.filter(function (x) { return x.Action !== a; });
|
|
2431
2446
|
};
|
|
2432
|
-
PermissionClass.prototype.
|
|
2447
|
+
PermissionClass.prototype.hasOptionByName = function (a) {
|
|
2433
2448
|
return this.Accesses.filter(function (x) { return x.Action === a && x.Type === exports.PermissionTypeEnum.Option; }).length > 0;
|
|
2434
2449
|
};
|
|
2450
|
+
PermissionClass.prototype.hasOption = function (at) {
|
|
2451
|
+
return this.Accesses.filter(function (x) { return x.AccessType === at && x.Type === exports.PermissionTypeEnum.Option; }).length > 0;
|
|
2452
|
+
};
|
|
2435
2453
|
PermissionClass.prototype.getOptions = function () {
|
|
2436
2454
|
return this.Accesses.filter(function (x) { return x.Type === exports.PermissionTypeEnum.Option; });
|
|
2437
2455
|
};
|
|
2438
|
-
PermissionClass.prototype.
|
|
2456
|
+
PermissionClass.prototype.getOptionByName = function (a) {
|
|
2439
2457
|
var c = this.Accesses.filter(function (x) { return x.Action === a && x.Type === exports.PermissionTypeEnum.Option; });
|
|
2440
2458
|
return c.length > 0 ? c[0] : null;
|
|
2441
2459
|
};
|
|
2460
|
+
PermissionClass.prototype.getOption = function (at) {
|
|
2461
|
+
var c = this.Accesses.filter(function (x) { return x.AccessType === at && x.Type === exports.PermissionTypeEnum.Option; });
|
|
2462
|
+
return c.length > 0 ? c[0] : null;
|
|
2463
|
+
};
|
|
2442
2464
|
PermissionClass.prototype.getUrl = function () {
|
|
2443
2465
|
return (this.Area ? '/' + this.Area : '') + '/' + this.Controller + '/' +
|
|
2444
2466
|
(this.RelatedId ? this.RelatedId + "/" : '') +
|
|
@@ -2478,7 +2500,7 @@
|
|
|
2478
2500
|
if (!this.table.childrenAutoLoad) {
|
|
2479
2501
|
this.children = this.getChildren();
|
|
2480
2502
|
}
|
|
2481
|
-
if (this.table.permissions.hasAccess(
|
|
2503
|
+
if (this.table.permissions.hasAccess(exports.PermissionAccessTypeEnum.Insert)) {
|
|
2482
2504
|
this.addChildren = new InputClass(this.table.environment, this.table.l, this.table.name + 'AddSubsetTitle', 'fad fa-plus fa-rotate-90', exports.InputType.Icon, 'green m-h-5 h-25 d-ib va-m f-u');
|
|
2483
2505
|
this.addChildren.onClick = function () {
|
|
2484
2506
|
_this.table.form.inputs.find(function (x) { return x.name === 'ParentId'; }).setValue(_this.row.Data.Id, false);
|
|
@@ -2635,13 +2657,13 @@
|
|
|
2635
2657
|
opt.onClick = function (btn) {
|
|
2636
2658
|
var e_2, _a;
|
|
2637
2659
|
if (opt.modal.table) {
|
|
2638
|
-
console.log(_this.
|
|
2660
|
+
console.log(_this.row.Options.filter(function (x) { return x.ParentId === option.Id; }), 'this.row.Options.filter(x => x.ParentId === option.Id)');
|
|
2639
2661
|
var p = new PermissionClass();
|
|
2640
2662
|
p.RelatedId = btn.row.Data.Id;
|
|
2641
2663
|
p.Area = _this.table.permissions.Area;
|
|
2642
2664
|
p.Controller = _this.table.permissions.Controller;
|
|
2643
2665
|
p.Action = option.Action;
|
|
2644
|
-
p.Accesses = option.
|
|
2666
|
+
p.Accesses = _this.row.Options.filter(function (x) { return x.ParentId === option.Id; });
|
|
2645
2667
|
opt.modal.table.permissions = p;
|
|
2646
2668
|
if (opt.modal.table.form) {
|
|
2647
2669
|
opt.modal.table.form.url = p.getUrl() + 'Insert';
|
|
@@ -6514,7 +6536,7 @@
|
|
|
6514
6536
|
this.optEdit = new InputClass(this.table.environment, this.table.l, this.table.name + 'Update', 'fad fa-pen', exports.InputType.Icon, 'blue h-25 m-h-5 d-ib va-m f-u');
|
|
6515
6537
|
this.optDelete = new InputClass(this.table.environment, this.table.l, this.table.name + 'Delete', 'fad fa-trash', exports.InputType.Icon, 'red h-25 m-h-5 d-ib va-m f-u');
|
|
6516
6538
|
if (this.table.hasChildren) {
|
|
6517
|
-
if (this.table.permissions.hasAccess(
|
|
6539
|
+
if (this.table.permissions.hasAccess(exports.PermissionAccessTypeEnum.Insert)) {
|
|
6518
6540
|
this.addChildren = new InputClass(this.table.environment, this.table.l, 'Add', 'fad fa-plus fa-rotate-90', exports.InputType.Icon, 'green m-h-5 h-25 d-ib va-m f-u');
|
|
6519
6541
|
this.addChildren.onClick = function () {
|
|
6520
6542
|
_this.table.form.url = _this.table.url + 'Insert';
|
|
@@ -7047,17 +7069,17 @@
|
|
|
7047
7069
|
return p.length > 0 ? this.getPermissionClass(p[0]) : null;
|
|
7048
7070
|
};
|
|
7049
7071
|
BaseComponent.prototype.getPermissionClass = function (p) {
|
|
7050
|
-
return new PermissionClass(p.Name, p.Icon, p.Type, p.InputType, p.InputAction, this.app.area, p.Controller, p.Action, p.Condition, this.getPermissionAccessesClass(p.Id));
|
|
7072
|
+
return new PermissionClass(p.Name, p.Icon, p.Type, p.InputType, p.AccessType, p.InputAction, this.app.area, p.Controller, p.Action, p.Condition, this.getPermissionAccessesClass(p.Id));
|
|
7051
7073
|
};
|
|
7052
7074
|
BaseComponent.prototype.getPermissionAccessesClass = function (parentId) {
|
|
7053
7075
|
var _this = this;
|
|
7054
7076
|
return this.app.currentUser.Permissions.filter(function (x) { return x.ParentId === parentId; }).map(function (x) { return _this.getPermissionClass(x); });
|
|
7055
7077
|
};
|
|
7056
7078
|
BaseComponent.prototype.hasAccess = function (a) {
|
|
7057
|
-
return this.permissions ? this.permissions.
|
|
7079
|
+
return this.permissions ? this.permissions.hasAccessByName(a) : false;
|
|
7058
7080
|
};
|
|
7059
7081
|
BaseComponent.prototype.hasOption = function (a) {
|
|
7060
|
-
return this.permissions ? this.permissions.
|
|
7082
|
+
return this.permissions ? this.permissions.hasAccessByName(a) : false;
|
|
7061
7083
|
};
|
|
7062
7084
|
return BaseComponent;
|
|
7063
7085
|
}());
|
|
@@ -7185,7 +7207,7 @@
|
|
|
7185
7207
|
return this.url + 'List';
|
|
7186
7208
|
};
|
|
7187
7209
|
TableClass.prototype.showInsertModal = function () {
|
|
7188
|
-
var insertAccess = this.permissions.getAccess(
|
|
7210
|
+
var insertAccess = this.permissions.getAccess(exports.PermissionAccessTypeEnum.Insert);
|
|
7189
7211
|
this.form.url = this.form.baseUrl = this.url + 'Insert';
|
|
7190
7212
|
this.form.name = insertAccess.Name;
|
|
7191
7213
|
this.form.method = exports.Method.Post;
|
|
@@ -7199,7 +7221,7 @@
|
|
|
7199
7221
|
if (changeRows === void 0) { changeRows = null; }
|
|
7200
7222
|
this.permission = true;
|
|
7201
7223
|
if (this.permissions) {
|
|
7202
|
-
var listAccess = this.permissions.getAccess(
|
|
7224
|
+
var listAccess = this.permissions.getAccess(exports.PermissionAccessTypeEnum.List);
|
|
7203
7225
|
if (listAccess !== null) {
|
|
7204
7226
|
this.title = listAccess.Name;
|
|
7205
7227
|
this.url = this.permissions.getUrl();
|
|
@@ -7215,48 +7237,56 @@
|
|
|
7215
7237
|
this.permission = false;
|
|
7216
7238
|
return;
|
|
7217
7239
|
}
|
|
7218
|
-
|
|
7219
|
-
|
|
7220
|
-
|
|
7221
|
-
|
|
7222
|
-
|
|
7223
|
-
|
|
7224
|
-
|
|
7225
|
-
|
|
7226
|
-
|
|
7227
|
-
|
|
7228
|
-
|
|
7229
|
-
|
|
7230
|
-
|
|
7231
|
-
|
|
7232
|
-
_this.showInsertModal();
|
|
7240
|
+
var _loop_1 = function (access) {
|
|
7241
|
+
if (this_1.buttons.filter(function (x) { return x.name === access.Name; })) {
|
|
7242
|
+
return "continue";
|
|
7243
|
+
}
|
|
7244
|
+
var accessInp = new InputClass(this_1.environment, this_1.l, access.Name, access.Icon, access.InputType === exports.PermissionInputTypeEnum.Button ? exports.InputType.Button : exports.InputType.Icon, 'blue w-u h-30');
|
|
7245
|
+
if (access.Action === 'Insert') {
|
|
7246
|
+
accessInp.class = accessInp.class.replace('blue', 'green');
|
|
7247
|
+
if (this_1.form) {
|
|
7248
|
+
this_1.form.url = this_1.form.baseUrl = this_1.url + 'Insert';
|
|
7249
|
+
if (!this_1.form.onTop) {
|
|
7250
|
+
accessInp.onClick = function () {
|
|
7251
|
+
_this.form.onSuccessBase = function () {
|
|
7252
|
+
_this.modal.hide();
|
|
7253
|
+
_this.load();
|
|
7233
7254
|
};
|
|
7234
|
-
|
|
7235
|
-
|
|
7236
|
-
this.form.displayLabel = false;
|
|
7237
|
-
}
|
|
7255
|
+
_this.showInsertModal();
|
|
7256
|
+
};
|
|
7238
7257
|
}
|
|
7239
7258
|
else {
|
|
7240
|
-
|
|
7241
|
-
|
|
7242
|
-
_this.modal.show();
|
|
7243
|
-
};
|
|
7244
|
-
}
|
|
7245
|
-
else {
|
|
7246
|
-
accessInp.url = this.url + 'Insert';
|
|
7247
|
-
}
|
|
7259
|
+
this_1.form.displayLabel = false;
|
|
7260
|
+
return "continue";
|
|
7248
7261
|
}
|
|
7249
7262
|
}
|
|
7250
|
-
else
|
|
7251
|
-
|
|
7252
|
-
|
|
7253
|
-
|
|
7254
|
-
|
|
7255
|
-
|
|
7256
|
-
|
|
7257
|
-
|
|
7263
|
+
else {
|
|
7264
|
+
if (this_1.modal) {
|
|
7265
|
+
accessInp.onClick = function () {
|
|
7266
|
+
_this.modal.show();
|
|
7267
|
+
};
|
|
7268
|
+
}
|
|
7269
|
+
else {
|
|
7270
|
+
accessInp.url = this_1.url + 'Insert';
|
|
7271
|
+
}
|
|
7258
7272
|
}
|
|
7259
|
-
|
|
7273
|
+
}
|
|
7274
|
+
else if (access.InputAction === exports.PermissionInputActionEnum.Report) {
|
|
7275
|
+
var p = new PermissionClass();
|
|
7276
|
+
p.RelatedId = 'Index';
|
|
7277
|
+
p.Area = this_1.permissions.Area;
|
|
7278
|
+
p.Controller = 'Print';
|
|
7279
|
+
p.Action = this_1.permissions.Controller;
|
|
7280
|
+
accessInp.url = '/Report' + p.getUrl();
|
|
7281
|
+
accessInp.urlNewTab = true;
|
|
7282
|
+
}
|
|
7283
|
+
this_1.buttons.push(accessInp);
|
|
7284
|
+
};
|
|
7285
|
+
var this_1 = this;
|
|
7286
|
+
try {
|
|
7287
|
+
for (var _b = __values(this.permissions.getAccesses().filter(function (x) { return x.InputAction !== exports.PermissionInputActionEnum.None; })), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
7288
|
+
var access = _c.value;
|
|
7289
|
+
_loop_1(access);
|
|
7260
7290
|
}
|
|
7261
7291
|
}
|
|
7262
7292
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
@@ -7266,7 +7296,8 @@
|
|
|
7266
7296
|
}
|
|
7267
7297
|
finally { if (e_2) throw e_2.error; }
|
|
7268
7298
|
}
|
|
7269
|
-
if ((this.permissions.hasAccess(
|
|
7299
|
+
if ((this.permissions.hasAccess(exports.PermissionAccessTypeEnum.Insert) ||
|
|
7300
|
+
this.permissions.hasOption(exports.PermissionAccessTypeEnum.Update)) && this.form) {
|
|
7270
7301
|
this.form.addButtons('Save', 'green', true, this.permissions.Type === exports.PermissionTypeEnum.Form ? function (data) {
|
|
7271
7302
|
if (data.Id) {
|
|
7272
7303
|
var i = _this.rows.findIndex(function (x) { return x.Id === data.Id; });
|