tnx-shared 5.3.188 → 5.3.189

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.
@@ -1128,6 +1128,7 @@
1128
1128
  this.showHistory = false;
1129
1129
  this.colorFilterField = '';
1130
1130
  this.colorFilterTable = [];
1131
+ this.buttonsPermissionCustom = [];
1131
1132
  this.entityMetadataSetting = new CrudFormSetting();
1132
1133
  this.fieldSearchText = [];
1133
1134
  this.function = new CrudListCustomFunction();
@@ -25231,7 +25232,7 @@
25231
25232
  if (!buttonText || lstBtnAction.some(function (p) { return p.rawText === buttonText; })) {
25232
25233
  return "continue";
25233
25234
  }
25234
- this_5.addButtonAction(lstBtnAction, this_5.authorizeButtonKey, buttonText);
25235
+ this_5.addButtonAction(lstBtnAction, buttonText);
25235
25236
  };
25236
25237
  this_5 = this;
25237
25238
  try {
@@ -25251,7 +25252,10 @@
25251
25252
  case 1:
25252
25253
  lstMenuButtons = (_e = _h.sent()) !== null && _e !== void 0 ? _e : [];
25253
25254
  if (lstMenuButtons.length) {
25254
- lstMenuButtons.forEach(function (item) { return _this.addButtonAction(lstBtnAction, _this.authorizeButtonKey, item.label); });
25255
+ lstMenuButtons.forEach(function (item) { return _this.addButtonAction(lstBtnAction, item.label); });
25256
+ }
25257
+ if (this.setting.buttonsPermissionCustom.length) {
25258
+ lstBtnAction.push.apply(lstBtnAction, __spreadArray([], __read(this.setting.buttonsPermissionCustom)));
25255
25259
  }
25256
25260
  buttonSetting = JSON.parse(sessionStorage.getItem(ComCtxConstants.LOCALSTORAGE_KEY.BUTTON_AUTHORIZE) || '{}');
25257
25261
  ((_f = buttonSetting[this.authorizeButtonKey]) === null || _f === void 0 ? void 0 : _f.length) && buttonSetting[this.authorizeButtonKey].forEach(function (item) {
@@ -25284,13 +25288,13 @@
25284
25288
  ListComponentBase.prototype.setBtnReady = function (isReady) {
25285
25289
  this.isBtnReady = isReady;
25286
25290
  };
25287
- ListComponentBase.prototype.addButtonAction = function (lstBtnAction, key, rawText, id) {
25291
+ ListComponentBase.prototype.addButtonAction = function (lstBtnAction, rawText, id) {
25288
25292
  id !== null && id !== void 0 ? id : (id = this._commonService.guid());
25289
25293
  var permissionCode = this._commonService.convertStringToUnSign(rawText).replace(/ /g, '_').toUpperCase();
25290
25294
  lstBtnAction.push(new ButtonAction({
25291
25295
  id: id,
25292
25296
  rawText: rawText,
25293
- permissionCode: "[" + key + "]_[" + permissionCode + "]"
25297
+ permissionCode: "[" + this.authorizeButtonKey + "]_[" + permissionCode + "]"
25294
25298
  }));
25295
25299
  };
25296
25300
  ListComponentBase.prototype.setAuthorizeButton = function (lstButtonTemplate) {
@@ -25325,7 +25329,7 @@
25325
25329
  this.isBtnReady = true;
25326
25330
  return [2 /*return*/];
25327
25331
  }
25328
- lstMenuButtons.forEach(function (item) { return _this.addButtonAction(lstMenuButton, _this.authorizeButtonKey, item.label); });
25332
+ lstMenuButtons.forEach(function (item) { return _this.addButtonAction(lstMenuButton, item.label); });
25329
25333
  buttonSetting[this.authorizeButtonKey].forEach(function (item) {
25330
25334
  var itemBtnMenu = lstMenuButton.find(function (p) { return p.permissionCode == item.code; });
25331
25335
  if (itemBtnMenu) {
@@ -25964,6 +25968,7 @@
25964
25968
  _this._workflowPermissionDetailService = _this._injector.get(WorkflowPermissionDetailService);
25965
25969
  _this._stateMachinesService = _this._injector.get(StateMachinesService);
25966
25970
  _this._congViecServiceInBase = _this._injector.get(CongViecService);
25971
+ _this._permissionService = _this._injector.get(PermissionService);
25967
25972
  _this._loggerService = _this._injector.get(LoggerService);
25968
25973
  _this.setting.key = _this._commonService.guid();
25969
25974
  return _this;
@@ -26418,11 +26423,65 @@
26418
26423
  });
26419
26424
  });
26420
26425
  };
26426
+ ListBase.prototype.getMenuButtonCustomAuthorized = function (menuButtons) {
26427
+ return __awaiter(this, void 0, void 0, function () {
26428
+ var buttonSetting, authorizeButtonKey, serviceCode, lstButtonAuthorize, promises, authorizedButtons, _loop_1, this_1, menuButtons_1, menuButtons_1_1, item;
26429
+ var e_2, _a;
26430
+ return __generator(this, function (_b) {
26431
+ switch (_b.label) {
26432
+ case 0:
26433
+ buttonSetting = JSON.parse(sessionStorage.getItem(ComCtxConstants.LOCALSTORAGE_KEY.BUTTON_AUTHORIZE) || '{}');
26434
+ authorizeButtonKey = window.location.pathname.substring(1).toUpperCase().replace(/\//g, '_');
26435
+ serviceCode = this.setting.baseService.serviceCode.toUpperCase();
26436
+ if (i0.isDevMode()) {
26437
+ authorizeButtonKey = serviceCode + "_" + window.location.pathname.substring(1).toUpperCase();
26438
+ }
26439
+ lstButtonAuthorize = buttonSetting[authorizeButtonKey];
26440
+ if (!(lstButtonAuthorize === null || lstButtonAuthorize === void 0 ? void 0 : lstButtonAuthorize.length)) {
26441
+ return [2 /*return*/, menuButtons];
26442
+ }
26443
+ promises = [];
26444
+ authorizedButtons = [];
26445
+ _loop_1 = function (item) {
26446
+ var permission = lstButtonAuthorize.find(function (p) { return p.code == item.authorizationPermission; });
26447
+ if (!item.authorizationPermission || !permission) {
26448
+ authorizedButtons.push(item);
26449
+ return "continue";
26450
+ }
26451
+ promises.push(this_1._permissionService.isAuthorized(item.authorizationServiceCode || serviceCode, permission ? permission.code : item.authorizationPermission, true).then(function (authorized) {
26452
+ if (authorized !== true) {
26453
+ return;
26454
+ }
26455
+ authorizedButtons.push(item);
26456
+ }));
26457
+ };
26458
+ this_1 = this;
26459
+ try {
26460
+ for (menuButtons_1 = __values(menuButtons), menuButtons_1_1 = menuButtons_1.next(); !menuButtons_1_1.done; menuButtons_1_1 = menuButtons_1.next()) {
26461
+ item = menuButtons_1_1.value;
26462
+ _loop_1(item);
26463
+ }
26464
+ }
26465
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
26466
+ finally {
26467
+ try {
26468
+ if (menuButtons_1_1 && !menuButtons_1_1.done && (_a = menuButtons_1.return)) _a.call(menuButtons_1);
26469
+ }
26470
+ finally { if (e_2) throw e_2.error; }
26471
+ }
26472
+ return [4 /*yield*/, Promise.all(promises)];
26473
+ case 1:
26474
+ _b.sent();
26475
+ return [2 /*return*/, authorizedButtons];
26476
+ }
26477
+ });
26478
+ });
26479
+ };
26421
26480
  ListBase.prototype.beforeRenderDataSource = function (datasource) {
26422
26481
  return datasource;
26423
26482
  };
26424
26483
  ListBase.prototype.mergeRefFields = function (dataSource) {
26425
- var e_2, _a, e_3, _b;
26484
+ var e_3, _a, e_4, _b;
26426
26485
  var schemas = this.setting.cols.filter(function (p) { return p.isForeignField && !!p.displayFieldInGrid && !p.field.startsWith('str'); });
26427
26486
  if (!schemas.length)
26428
26487
  return;
@@ -26430,35 +26489,35 @@
26430
26489
  for (var dataSource_1 = __values(dataSource), dataSource_1_1 = dataSource_1.next(); !dataSource_1_1.done; dataSource_1_1 = dataSource_1.next()) {
26431
26490
  var rowData = dataSource_1_1.value;
26432
26491
  try {
26433
- for (var schemas_1 = (e_3 = void 0, __values(schemas)), schemas_1_1 = schemas_1.next(); !schemas_1_1.done; schemas_1_1 = schemas_1.next()) {
26492
+ for (var schemas_1 = (e_4 = void 0, __values(schemas)), schemas_1_1 = schemas_1.next(); !schemas_1_1.done; schemas_1_1 = schemas_1.next()) {
26434
26493
  var schema = schemas_1_1.value;
26435
26494
  rowData['str' + schema.field] = rowData[schema.displayFieldInGrid];
26436
26495
  }
26437
26496
  }
26438
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
26497
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
26439
26498
  finally {
26440
26499
  try {
26441
26500
  if (schemas_1_1 && !schemas_1_1.done && (_b = schemas_1.return)) _b.call(schemas_1);
26442
26501
  }
26443
- finally { if (e_3) throw e_3.error; }
26502
+ finally { if (e_4) throw e_4.error; }
26444
26503
  }
26445
26504
  }
26446
26505
  }
26447
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
26506
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
26448
26507
  finally {
26449
26508
  try {
26450
26509
  if (dataSource_1_1 && !dataSource_1_1.done && (_a = dataSource_1.return)) _a.call(dataSource_1);
26451
26510
  }
26452
- finally { if (e_2) throw e_2.error; }
26511
+ finally { if (e_3) throw e_3.error; }
26453
26512
  }
26454
26513
  };
26455
26514
  ListBase.prototype.calculateRowSpan = function (dataSource, fields, funcNext) {
26456
- var e_4, _a;
26515
+ var e_5, _a;
26457
26516
  for (var i = 0; i < dataSource.length - 1; i++) {
26458
26517
  if (funcNext && funcNext(dataSource[i]) != funcNext(dataSource[i + 1]))
26459
26518
  continue;
26460
26519
  try {
26461
- for (var fields_1 = (e_4 = void 0, __values(fields)), fields_1_1 = fields_1.next(); !fields_1_1.done; fields_1_1 = fields_1.next()) {
26520
+ for (var fields_1 = (e_5 = void 0, __values(fields)), fields_1_1 = fields_1.next(); !fields_1_1.done; fields_1_1 = fields_1.next()) {
26462
26521
  var element = fields_1_1.value;
26463
26522
  var field = element.field;
26464
26523
  var fieldRootIndex = "rootIndex_" + field;
@@ -26487,12 +26546,12 @@
26487
26546
  }
26488
26547
  }
26489
26548
  }
26490
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
26549
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
26491
26550
  finally {
26492
26551
  try {
26493
26552
  if (fields_1_1 && !fields_1_1.done && (_a = fields_1.return)) _a.call(fields_1);
26494
26553
  }
26495
- finally { if (e_4) throw e_4.error; }
26554
+ finally { if (e_5) throw e_5.error; }
26496
26555
  }
26497
26556
  }
26498
26557
  };
@@ -26517,32 +26576,32 @@
26517
26576
  * @param refFields
26518
26577
  */
26519
26578
  ListBase.prototype.addRefFields = function (refFields) {
26520
- var e_5, _a;
26579
+ var e_6, _a;
26521
26580
  if (this.setting.fieldNeedGetRef == null || this.setting.fieldNeedGetRef.length === 0) {
26522
26581
  this.setting.fieldNeedGetRef = __spreadArray([], __read(refFields));
26523
26582
  return;
26524
26583
  }
26525
- var _loop_1 = function (refField) {
26526
- var oldRefIndex = this_1.setting.fieldNeedGetRef.findIndex(function (x) { return x.field == refField.field; });
26584
+ var _loop_2 = function (refField) {
26585
+ var oldRefIndex = this_2.setting.fieldNeedGetRef.findIndex(function (x) { return x.field == refField.field; });
26527
26586
  if (oldRefIndex === -1) {
26528
- this_1.setting.fieldNeedGetRef.push(refField);
26587
+ this_2.setting.fieldNeedGetRef.push(refField);
26529
26588
  return "continue";
26530
26589
  }
26531
- this_1.setting.fieldNeedGetRef[oldRefIndex] = refField;
26590
+ this_2.setting.fieldNeedGetRef[oldRefIndex] = refField;
26532
26591
  };
26533
- var this_1 = this;
26592
+ var this_2 = this;
26534
26593
  try {
26535
26594
  for (var refFields_1 = __values(refFields), refFields_1_1 = refFields_1.next(); !refFields_1_1.done; refFields_1_1 = refFields_1.next()) {
26536
26595
  var refField = refFields_1_1.value;
26537
- _loop_1(refField);
26596
+ _loop_2(refField);
26538
26597
  }
26539
26598
  }
26540
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
26599
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
26541
26600
  finally {
26542
26601
  try {
26543
26602
  if (refFields_1_1 && !refFields_1_1.done && (_a = refFields_1.return)) _a.call(refFields_1);
26544
26603
  }
26545
- finally { if (e_5) throw e_5.error; }
26604
+ finally { if (e_6) throw e_6.error; }
26546
26605
  }
26547
26606
  };
26548
26607
  ListBase.prototype.groupInClient = function (dataSource) {
@@ -26938,8 +26997,8 @@
26938
26997
  };
26939
26998
  ListBase.prototype._copyLinkMultiple = function () {
26940
26999
  return __awaiter(this, void 0, void 0, function () {
26941
- var paths, _a, _b, item, _c, _d, e_6_1;
26942
- var e_6, _e;
27000
+ var paths, _a, _b, item, _c, _d, e_7_1;
27001
+ var e_7, _e;
26943
27002
  return __generator(this, function (_f) {
26944
27003
  switch (_f.label) {
26945
27004
  case 0:
@@ -26962,14 +27021,14 @@
26962
27021
  return [3 /*break*/, 2];
26963
27022
  case 5: return [3 /*break*/, 8];
26964
27023
  case 6:
26965
- e_6_1 = _f.sent();
26966
- e_6 = { error: e_6_1 };
27024
+ e_7_1 = _f.sent();
27025
+ e_7 = { error: e_7_1 };
26967
27026
  return [3 /*break*/, 8];
26968
27027
  case 7:
26969
27028
  try {
26970
27029
  if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
26971
27030
  }
26972
- finally { if (e_6) throw e_6.error; }
27031
+ finally { if (e_7) throw e_7.error; }
26973
27032
  return [7 /*endfinally*/];
26974
27033
  case 8:
26975
27034
  this._commonService.copyByStorage(paths.join('\r\n'));
@@ -31655,7 +31714,6 @@
31655
31714
  return _this;
31656
31715
  }
31657
31716
  CommonSearchFormComponent.prototype.ngOnInit = function () {
31658
- var _this = this;
31659
31717
  this.mdWidth = this.parentSetting.mdWidthCommonSearch;
31660
31718
  this.setting.baseService = this.parentSetting.baseService;
31661
31719
  this.isCustomGenerateSearch = this.parentSetting.commonSchemas.length > 0;
@@ -31674,34 +31732,8 @@
31674
31732
  this.searchBoxTooltip += "" + (lstTextSearchControl.map(function (x) { return x.label; })).join(', ');
31675
31733
  this._index = 2;
31676
31734
  }
31677
- var totalControlPerRow = 12 / this.mdWidth;
31678
31735
  if (this.isCustomGenerateSearch) {
31679
- this.parentSetting.commonSchemas.forEach(function (column) {
31680
- column.showLabel = false;
31681
- column.mdWidth = _this.mdWidth;
31682
- column['placeholder'] = column.label;
31683
- if (!(column instanceof TextControlSchema) || column instanceof NumberRangeControlSchema || column instanceof DropdownControlSchema) {
31684
- column.onAfterChanged = function (evt) {
31685
- _this.handleSearch(null, evt.control.field);
31686
- };
31687
- }
31688
- if (column instanceof NumberRangeControlSchema) {
31689
- _this.lstNumberRangeControl.push(column.field);
31690
- }
31691
- if (column.hasOwnProperty('defaultValue') && (column instanceof DropdownControlSchema || column instanceof DateTimeControlSchema)) {
31692
- _this.defaultValues[column.field] = column.defaultValue;
31693
- }
31694
- if (column.addToGridInfo) {
31695
- _this.lstControlAddToGridInfo.push(column.field);
31696
- }
31697
- column.isLazyLoad = !_this.parentSetting.disableLazyLoadCommonSearch && _this._index > totalControlPerRow
31698
- && column instanceof DropdownControlSchema && !!column.baseService && !(column.baseService instanceof MasterDataService);
31699
- if (column.isLazyLoad) {
31700
- _this.lstControlLazyLoad.push(column.field);
31701
- }
31702
- _this._index++;
31703
- });
31704
- this.setting.schema = this.addSearchBox(this.parentSetting.commonSchemas.sort(function (prev, next) { return prev.order - next.order; }));
31736
+ this.getFormSchemaCustom();
31705
31737
  }
31706
31738
  else {
31707
31739
  this.setting.schema = this.genFormSchema(columnFilters);
@@ -31712,6 +31744,36 @@
31712
31744
  this.handleSearch();
31713
31745
  }
31714
31746
  };
31747
+ CommonSearchFormComponent.prototype.getFormSchemaCustom = function () {
31748
+ var _this = this;
31749
+ var totalControlPerRow = 12 / this.mdWidth;
31750
+ this.parentSetting.commonSchemas.forEach(function (column) {
31751
+ column.showLabel = false;
31752
+ column.mdWidth = _this.mdWidth;
31753
+ column['placeholder'] = column.label;
31754
+ if (!(column instanceof TextControlSchema) || column instanceof NumberRangeControlSchema || column instanceof DropdownControlSchema) {
31755
+ column.onAfterChanged = function (evt) {
31756
+ _this.handleSearch(null, evt.control.field);
31757
+ };
31758
+ }
31759
+ if (column instanceof NumberRangeControlSchema) {
31760
+ _this.lstNumberRangeControl.push(column.field);
31761
+ }
31762
+ if (column.hasOwnProperty('defaultValue') && (column instanceof DropdownControlSchema || column instanceof DateTimeControlSchema)) {
31763
+ _this.defaultValues[column.field] = column.defaultValue;
31764
+ }
31765
+ if (column.addToGridInfo) {
31766
+ _this.lstControlAddToGridInfo.push(column.field);
31767
+ }
31768
+ column.isLazyLoad = !_this.parentSetting.disableLazyLoadCommonSearch && _this._index > totalControlPerRow
31769
+ && column instanceof DropdownControlSchema && !!column.baseService && !(column.baseService instanceof MasterDataService);
31770
+ if (column.isLazyLoad) {
31771
+ _this.lstControlLazyLoad.push(column.field);
31772
+ }
31773
+ _this._index++;
31774
+ });
31775
+ this.setting.schema = this.addSearchBox(this.parentSetting.commonSchemas.sort(function (prev, next) { return prev.order - next.order; }));
31776
+ };
31715
31777
  CommonSearchFormComponent.prototype.genFormSchema = function (columns) {
31716
31778
  var _this = this;
31717
31779
  var result = [];
@@ -46959,7 +47021,7 @@
46959
47021
  selector: 'equation-editor',
46960
47022
  template: "<div class=\"ui-fluid\">\n <textarea #textarea class=\"latexContent\" placeholder=\"G\u00F5 c\u00F4ng th\u1EE9c to\u00E1n h\u1ECDc t\u1EA1i \u0111\u00E2y...\" rows=\"6\" pInputTextarea\n (ngModelChange)=\"onModelChange($event)\" [(ngModel)]=\"equationLatex\"></textarea>\n</div>\n<div class=\"preview\">\n <img #preview latex=\"true\" *ngIf=\"imageSrc\" [attr.height]=\"data.height != 0 ? data.height : null\"\n class=\"latex\" [style]=\"data.style | safeStyle\" [src]=\"imageSrc\" [alt]=\"equationLatex\" />\n</div>",
46961
47023
  providers: [ComponentContextService],
46962
- styles: [".btn-equation{width:30xp;height:30px;cursor:pointer}.preview{text-align:center;margin-top:10px;padding:0 10px}.latexContent{resize:none;border-radius:0}"]
47024
+ styles: [".btn-equation{width:30px;height:30px;cursor:pointer}.preview{text-align:center;margin-top:10px;padding:0 10px}.latexContent{resize:none;border-radius:0}"]
46963
47025
  },] }
46964
47026
  ];
46965
47027
  EquationEditorComponent.ctorParameters = function () { return [
@@ -50150,7 +50212,7 @@
50150
50212
  ];
50151
50213
  this.setting.cols = [
50152
50214
  new ColumnSchemaBase({ field: 'permissionCode', sort: false, showEditLink: false }),
50153
- new ColumnSchemaBase({ field: 'rawText', width: '230px', sort: false }),
50215
+ new ColumnSchemaBase({ field: 'rawText', width: '300px', sort: false }),
50154
50216
  new ColumnSchemaBase({ field: 'isAuthorize', dataType: exports.DataType.boolean, width: '100px', sort: false }),
50155
50217
  ];
50156
50218
  _super.prototype.ngOnInit.call(this);