ps-toolkit-ui 0.0.129 → 0.0.133
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 +39 -15
- 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 +6 -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 +6 -5
- package/fesm2015/ps-toolkit-ui.js +40 -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,12 +2657,13 @@
|
|
|
2635
2657
|
opt.onClick = function (btn) {
|
|
2636
2658
|
var e_2, _a;
|
|
2637
2659
|
if (opt.modal.table) {
|
|
2660
|
+
console.log(_this.row.Options.filter(function (x) { return x.ParentId === option.Id; }), 'this.row.Options.filter(x => x.ParentId === option.Id)');
|
|
2638
2661
|
var p = new PermissionClass();
|
|
2639
2662
|
p.RelatedId = btn.row.Data.Id;
|
|
2640
2663
|
p.Area = _this.table.permissions.Area;
|
|
2641
2664
|
p.Controller = _this.table.permissions.Controller;
|
|
2642
2665
|
p.Action = option.Action;
|
|
2643
|
-
p.Accesses = option.
|
|
2666
|
+
p.Accesses = _this.row.Options.filter(function (x) { return x.ParentId === option.Id; });
|
|
2644
2667
|
opt.modal.table.permissions = p;
|
|
2645
2668
|
if (opt.modal.table.form) {
|
|
2646
2669
|
opt.modal.table.form.url = p.getUrl() + 'Insert';
|
|
@@ -2727,7 +2750,7 @@
|
|
|
2727
2750
|
};
|
|
2728
2751
|
var this_1 = this;
|
|
2729
2752
|
try {
|
|
2730
|
-
for (var _b = __values(this.row.Options), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
2753
|
+
for (var _b = __values(this.row.Options.filter(function (x) { return x.Type === exports.PermissionTypeEnum.Option; })), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
2731
2754
|
var option = _c.value;
|
|
2732
2755
|
_loop_1(option);
|
|
2733
2756
|
}
|
|
@@ -6513,7 +6536,7 @@
|
|
|
6513
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');
|
|
6514
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');
|
|
6515
6538
|
if (this.table.hasChildren) {
|
|
6516
|
-
if (this.table.permissions.hasAccess(
|
|
6539
|
+
if (this.table.permissions.hasAccess(exports.PermissionAccessTypeEnum.Insert)) {
|
|
6517
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');
|
|
6518
6541
|
this.addChildren.onClick = function () {
|
|
6519
6542
|
_this.table.form.url = _this.table.url + 'Insert';
|
|
@@ -7046,17 +7069,17 @@
|
|
|
7046
7069
|
return p.length > 0 ? this.getPermissionClass(p[0]) : null;
|
|
7047
7070
|
};
|
|
7048
7071
|
BaseComponent.prototype.getPermissionClass = function (p) {
|
|
7049
|
-
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));
|
|
7050
7073
|
};
|
|
7051
7074
|
BaseComponent.prototype.getPermissionAccessesClass = function (parentId) {
|
|
7052
7075
|
var _this = this;
|
|
7053
7076
|
return this.app.currentUser.Permissions.filter(function (x) { return x.ParentId === parentId; }).map(function (x) { return _this.getPermissionClass(x); });
|
|
7054
7077
|
};
|
|
7055
7078
|
BaseComponent.prototype.hasAccess = function (a) {
|
|
7056
|
-
return this.permissions ? this.permissions.
|
|
7079
|
+
return this.permissions ? this.permissions.hasAccessByName(a) : false;
|
|
7057
7080
|
};
|
|
7058
7081
|
BaseComponent.prototype.hasOption = function (a) {
|
|
7059
|
-
return this.permissions ? this.permissions.
|
|
7082
|
+
return this.permissions ? this.permissions.hasAccessByName(a) : false;
|
|
7060
7083
|
};
|
|
7061
7084
|
return BaseComponent;
|
|
7062
7085
|
}());
|
|
@@ -7184,7 +7207,7 @@
|
|
|
7184
7207
|
return this.url + 'List';
|
|
7185
7208
|
};
|
|
7186
7209
|
TableClass.prototype.showInsertModal = function () {
|
|
7187
|
-
var insertAccess = this.permissions.getAccess(
|
|
7210
|
+
var insertAccess = this.permissions.getAccess(exports.PermissionAccessTypeEnum.Insert);
|
|
7188
7211
|
this.form.url = this.form.baseUrl = this.url + 'Insert';
|
|
7189
7212
|
this.form.name = insertAccess.Name;
|
|
7190
7213
|
this.form.method = exports.Method.Post;
|
|
@@ -7198,7 +7221,7 @@
|
|
|
7198
7221
|
if (changeRows === void 0) { changeRows = null; }
|
|
7199
7222
|
this.permission = true;
|
|
7200
7223
|
if (this.permissions) {
|
|
7201
|
-
var listAccess = this.permissions.getAccess(
|
|
7224
|
+
var listAccess = this.permissions.getAccess(exports.PermissionAccessTypeEnum.List);
|
|
7202
7225
|
if (listAccess !== null) {
|
|
7203
7226
|
this.title = listAccess.Name;
|
|
7204
7227
|
this.url = this.permissions.getUrl();
|
|
@@ -7265,7 +7288,8 @@
|
|
|
7265
7288
|
}
|
|
7266
7289
|
finally { if (e_2) throw e_2.error; }
|
|
7267
7290
|
}
|
|
7268
|
-
if ((this.permissions.hasAccess(
|
|
7291
|
+
if ((this.permissions.hasAccess(exports.PermissionAccessTypeEnum.Insert) ||
|
|
7292
|
+
this.permissions.hasOption(exports.PermissionAccessTypeEnum.Update)) && this.form) {
|
|
7269
7293
|
this.form.addButtons('Save', 'green', true, this.permissions.Type === exports.PermissionTypeEnum.Form ? function (data) {
|
|
7270
7294
|
if (data.Id) {
|
|
7271
7295
|
var i = _this.rows.findIndex(function (x) { return x.Id === data.Id; });
|