tnx-shared 5.1.154 → 5.1.158

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.
Files changed (28) hide show
  1. package/bundles/tnx-shared.umd.js +229 -106
  2. package/bundles/tnx-shared.umd.js.map +1 -1
  3. package/bundles/tnx-shared.umd.min.js +1 -1
  4. package/bundles/tnx-shared.umd.min.js.map +1 -1
  5. package/components/common-app-component/common-app-component.d.ts.map +1 -1
  6. package/components/crud/crud-list/crud-list.component.d.ts +1 -0
  7. package/components/crud/crud-list/crud-list.component.d.ts.map +1 -1
  8. package/components/workflow/services/workflow-settings.service.d.ts +4 -0
  9. package/components/workflow/services/workflow-settings.service.d.ts.map +1 -1
  10. package/components/workflow/workflow-history-new/workflow-history-new.component.d.ts +5 -4
  11. package/components/workflow/workflow-history-new/workflow-history-new.component.d.ts.map +1 -1
  12. package/configs/component-context.constant.d.ts +6 -0
  13. package/configs/component-context.constant.d.ts.map +1 -1
  14. package/esm2015/components/common-app-component/common-app-component.js +10 -9
  15. package/esm2015/components/crud/crud-list/crud-list.component.js +6 -1
  16. package/esm2015/components/workflow/services/workflow-settings.service.js +45 -11
  17. package/esm2015/components/workflow/workflow-history-new/workflow-history-new.component.js +45 -9
  18. package/esm2015/configs/component-context.constant.js +7 -1
  19. package/esm2015/services/permission.service.js +15 -2
  20. package/esm2015/services/user.service.js +13 -2
  21. package/fesm2015/tnx-shared.js +134 -28
  22. package/fesm2015/tnx-shared.js.map +1 -1
  23. package/package.json +2 -2
  24. package/services/permission.service.d.ts +2 -1
  25. package/services/permission.service.d.ts.map +1 -1
  26. package/services/user.service.d.ts +1 -0
  27. package/services/user.service.d.ts.map +1 -1
  28. package/tnx-shared.metadata.json +1 -1
@@ -345,6 +345,7 @@
345
345
  USER_READY: 'USER_READY',
346
346
  USER_LOADED: 'USER_LOADED',
347
347
  USER_INFO_CHANGED: 'USER_INFO_CHANGED',
348
+ NEED_CLEAR_PERMISSION_CACHE: 'CLEAR_PERMISSION_CACHE',
348
349
  ADVANCE_SEARCH_TOGGLE_BOX: 'ADVANCE_SEARCH_TOGGLE_BOX',
349
350
  ADVANCE_SEARCH_HIDE_BOX: 'ADVANCE_SEARCH_HIDE_BOX',
350
351
  ADVANCE_SEARCH_INIT: 'ADVANCE_SEARCH_INIT',
@@ -515,6 +516,11 @@
515
516
  DE_TAI: 15,
516
517
  BIEU_MAU: 16,
517
518
  TEACHERFULL: 17,
519
+ };
520
+ ComCtxConstants.PERMISSION = {
521
+ REFRESH_PERMISSION: 'REFRESH_PERMISSION',
522
+ SELECTED_OBJECT_CHANGED: 'SELECTED_OBJECT_CHANGED',
523
+ REFRESH_USER_PERMISSION: 'REFRESH_USER_PERMISSION',
518
524
  };
519
525
 
520
526
  // ctr.prototype[propertyKey] = function (...args) {
@@ -9224,6 +9230,11 @@
9224
9230
  }
9225
9231
  return false;
9226
9232
  };
9233
+ UserService.prototype.getFullCanBoLabel = function (item) {
9234
+ var label = this.getUserName(item);
9235
+ label = (item.maChucVu ? item.maChucVu + ". " : '') + ("" + label) + (item.tenDonVi ? " - " + item.tenDonVi : '');
9236
+ return label;
9237
+ };
9227
9238
  UserService.prototype.getAllWithInfo = function (filters) {
9228
9239
  return this.getDataCustomRoute('WithInfo', filters);
9229
9240
  };
@@ -9280,6 +9291,7 @@
9280
9291
  }
9281
9292
  else {
9282
9293
  this._applicationContext.getRootContext().replaySubscribeOnce(ComCtxConstants.ROOT.USER_READY, function (rs) {
9294
+ var firstTimeLogin = rs !== null && rs !== void 0 ? rs : false;
9283
9295
  var accessToken = _this._oauthService.getAccessToken();
9284
9296
  var decoded = JWT.default(accessToken);
9285
9297
  // Chuyển đổi sang dùng instanceId nếu đăng nhập bằng identityv4 nhưng phải sử dụng base userOrgv5
@@ -9321,7 +9333,12 @@
9321
9333
  localStorage.setItem(_this.CURRENT_USER_KEY, JSON.stringify(user));
9322
9334
  }
9323
9335
  _this._applicationContext.getRootContext().data.currentUser = user;
9324
- _this._applicationContext.getRootContext().fireReplayEvent(ComCtxConstants.ROOT.USER_LOADED, true);
9336
+ if (firstTimeLogin) {
9337
+ _this._applicationContext.getRootContext().fireEvent(ComCtxConstants.ROOT.NEED_CLEAR_PERMISSION_CACHE);
9338
+ }
9339
+ else {
9340
+ _this._applicationContext.getRootContext().fireReplayEvent(ComCtxConstants.ROOT.USER_LOADED, true);
9341
+ }
9325
9342
  }, function (err) {
9326
9343
  });
9327
9344
  });
@@ -9910,7 +9927,20 @@
9910
9927
  _this.appCode = _this._moduleConfigService.getConfig().appCode;
9911
9928
  return _this;
9912
9929
  }
9913
- PermissionService.prototype.cleanPermissionCache = function (lstModule) {
9930
+ PermissionService.prototype.clearPermissionCacheAll = function () {
9931
+ var _a, _b, _c;
9932
+ var lstAppCodes = (_c = (_b = (_a = this._moduleConfigService.getConfig().environment.appMetadata) === null || _a === void 0 ? void 0 : _a.appSwitcher) === null || _b === void 0 ? void 0 : _b.map(function (app) { return app.code; })) !== null && _c !== void 0 ? _c : [];
9933
+ var lstApiEndpoint = [];
9934
+ var apiDomain = this._moduleConfigService.getConfig().environment.apiDomain;
9935
+ for (var domainName in apiDomain) {
9936
+ if (domainName.startsWith('-') || domainName.startsWith('1') || domainName == 'gateway')
9937
+ continue;
9938
+ var realDomainName = domainName.split('Endpoint') ? domainName.split('Endpoint')[0] : domainName;
9939
+ lstApiEndpoint.push(realDomainName.toUpperCase());
9940
+ }
9941
+ return this.clearPermissionCache(__spread(lstAppCodes, lstApiEndpoint));
9942
+ };
9943
+ PermissionService.prototype.clearPermissionCache = function (lstModule) {
9914
9944
  var url = this.serviceUri + "/ClearPermissionCache";
9915
9945
  return this.defaultPost(url, lstModule);
9916
9946
  };
@@ -9927,12 +9957,12 @@
9927
9957
  var _this = this;
9928
9958
  return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
9929
9959
  var user, result, lstPermissionCode_1, lstPermissionCode_1_1, item, e_1_1;
9930
- var e_1, _a;
9931
- return __generator(this, function (_b) {
9932
- switch (_b.label) {
9960
+ var e_1, _d;
9961
+ return __generator(this, function (_e) {
9962
+ switch (_e.label) {
9933
9963
  case 0: return [4 /*yield*/, this._userService.getCurrentUser()];
9934
9964
  case 1:
9935
- user = (_b.sent());
9965
+ user = (_e.sent());
9936
9966
  if (user && user.issuperuser.toLowerCase() == 'true') {
9937
9967
  resolve(lstPermissionCode);
9938
9968
  return [2 /*return*/];
@@ -9942,31 +9972,31 @@
9942
9972
  return [2 /*return*/];
9943
9973
  }
9944
9974
  result = [];
9945
- _b.label = 2;
9975
+ _e.label = 2;
9946
9976
  case 2:
9947
- _b.trys.push([2, 7, 8, 9]);
9977
+ _e.trys.push([2, 7, 8, 9]);
9948
9978
  lstPermissionCode_1 = __values(lstPermissionCode), lstPermissionCode_1_1 = lstPermissionCode_1.next();
9949
- _b.label = 3;
9979
+ _e.label = 3;
9950
9980
  case 3:
9951
9981
  if (!!lstPermissionCode_1_1.done) return [3 /*break*/, 6];
9952
9982
  item = lstPermissionCode_1_1.value;
9953
9983
  return [4 /*yield*/, this.isAuthorizedPermission(item)];
9954
9984
  case 4:
9955
- if (_b.sent()) {
9985
+ if (_e.sent()) {
9956
9986
  result.push(item);
9957
9987
  }
9958
- _b.label = 5;
9988
+ _e.label = 5;
9959
9989
  case 5:
9960
9990
  lstPermissionCode_1_1 = lstPermissionCode_1.next();
9961
9991
  return [3 /*break*/, 3];
9962
9992
  case 6: return [3 /*break*/, 9];
9963
9993
  case 7:
9964
- e_1_1 = _b.sent();
9994
+ e_1_1 = _e.sent();
9965
9995
  e_1 = { error: e_1_1 };
9966
9996
  return [3 /*break*/, 9];
9967
9997
  case 8:
9968
9998
  try {
9969
- if (lstPermissionCode_1_1 && !lstPermissionCode_1_1.done && (_a = lstPermissionCode_1.return)) _a.call(lstPermissionCode_1);
9999
+ if (lstPermissionCode_1_1 && !lstPermissionCode_1_1.done && (_d = lstPermissionCode_1.return)) _d.call(lstPermissionCode_1);
9970
10000
  }
9971
10001
  finally { if (e_1) throw e_1.error; }
9972
10002
  return [7 /*endfinally*/];
@@ -9981,16 +10011,16 @@
9981
10011
  var _this = this;
9982
10012
  return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
9983
10013
  var retryCount;
9984
- return __generator(this, function (_a) {
9985
- switch (_a.label) {
10014
+ return __generator(this, function (_d) {
10015
+ switch (_d.label) {
9986
10016
  case 0:
9987
10017
  retryCount = 0;
9988
- _a.label = 1;
10018
+ _d.label = 1;
9989
10019
  case 1:
9990
10020
  if (!!this._oauthService.hasValidAccessToken()) return [3 /*break*/, 3];
9991
10021
  return [4 /*yield*/, this._commonService.delay(100)];
9992
10022
  case 2:
9993
- _a.sent();
10023
+ _d.sent();
9994
10024
  retryCount++;
9995
10025
  if (retryCount > 50) {
9996
10026
  return [3 /*break*/, 3];
@@ -9998,7 +10028,7 @@
9998
10028
  return [3 /*break*/, 1];
9999
10029
  case 3: return [4 /*yield*/, this.checkPermission(this.appCode, permission, resolve, reject)];
10000
10030
  case 4:
10001
- _a.sent();
10031
+ _d.sent();
10002
10032
  return [2 /*return*/];
10003
10033
  }
10004
10034
  });
@@ -10010,16 +10040,16 @@
10010
10040
  this.root = this._appContext.getRootContext();
10011
10041
  return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
10012
10042
  var retryCount;
10013
- return __generator(this, function (_a) {
10014
- switch (_a.label) {
10043
+ return __generator(this, function (_d) {
10044
+ switch (_d.label) {
10015
10045
  case 0:
10016
10046
  retryCount = 0;
10017
- _a.label = 1;
10047
+ _d.label = 1;
10018
10048
  case 1:
10019
10049
  if (!!this._oauthService.hasValidAccessToken()) return [3 /*break*/, 3];
10020
10050
  return [4 /*yield*/, this._commonService.delay(100)];
10021
10051
  case 2:
10022
- _a.sent();
10052
+ _d.sent();
10023
10053
  retryCount++;
10024
10054
  if (retryCount > 50) {
10025
10055
  return [3 /*break*/, 3];
@@ -10027,7 +10057,7 @@
10027
10057
  return [3 /*break*/, 1];
10028
10058
  case 3: return [4 /*yield*/, this.checkPermission(service, permission, resolve, reject)];
10029
10059
  case 4:
10030
- _a.sent();
10060
+ _d.sent();
10031
10061
  return [2 /*return*/];
10032
10062
  }
10033
10063
  });
@@ -10036,11 +10066,11 @@
10036
10066
  PermissionService.prototype.checkPermission = function (service, permission, resolve, reject) {
10037
10067
  return __awaiter(this, void 0, void 0, function () {
10038
10068
  var user;
10039
- return __generator(this, function (_a) {
10040
- switch (_a.label) {
10069
+ return __generator(this, function (_d) {
10070
+ switch (_d.label) {
10041
10071
  case 0: return [4 /*yield*/, this._userService.getCurrentUser()];
10042
10072
  case 1:
10043
- user = (_a.sent());
10073
+ user = (_d.sent());
10044
10074
  if (user && user.issuperuser && user.issuperuser.toLowerCase() == 'true') {
10045
10075
  resolve(true);
10046
10076
  return [2 /*return*/];
@@ -10073,11 +10103,11 @@
10073
10103
  return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
10074
10104
  var user, isAuthorized;
10075
10105
  var _this = this;
10076
- return __generator(this, function (_a) {
10077
- switch (_a.label) {
10106
+ return __generator(this, function (_d) {
10107
+ switch (_d.label) {
10078
10108
  case 0: return [4 /*yield*/, this._userService.getCurrentUser()];
10079
10109
  case 1:
10080
- user = (_a.sent());
10110
+ user = (_d.sent());
10081
10111
  if (user && user.issuperuser.toLowerCase() == 'true') {
10082
10112
  resolve(true);
10083
10113
  return [2 /*return*/];
@@ -10109,7 +10139,7 @@
10109
10139
  });
10110
10140
  })];
10111
10141
  case 2:
10112
- _a.sent();
10142
+ _d.sent();
10113
10143
  resolve(isAuthorized);
10114
10144
  return [2 /*return*/];
10115
10145
  }
@@ -21954,6 +21984,11 @@
21954
21984
  }
21955
21985
  return !this.buttonPermissionMap.get(this.setting.baseService.serviceCode + "/" + this.setting.baseService.entityName + "/" + buttonPermissionCode);
21956
21986
  };
21987
+ CrudListComponent.prototype.setDropdownDatasource = function (field, dataSource) {
21988
+ if (this.filterSchema.dropdown[field]) {
21989
+ this.filterSchema.dropdown[field].dataSource = dataSource;
21990
+ }
21991
+ };
21957
21992
  return CrudListComponent;
21958
21993
  }(ComponentBase));
21959
21994
  CrudListComponent.decorators = [
@@ -22117,7 +22152,6 @@
22117
22152
  this.serviceUri = this.getEndpointByService(service) + "/WorkflowSetting";
22118
22153
  };
22119
22154
  WorkflowSettingsService.prototype.renderDataSourceActionWorkflow = function (workflowSchema) {
22120
- var _this = this;
22121
22155
  var dataSourceAction = [];
22122
22156
  var dicSameName = {};
22123
22157
  workflowSchema.connections.sort(multipleSort('soThuTu')).forEach(function (action) {
@@ -22148,6 +22182,51 @@
22148
22182
  dataSourceAction.push(itemAdd_1);
22149
22183
  }
22150
22184
  });
22185
+ this.makeUniqueName(dicSameName);
22186
+ return dataSourceAction;
22187
+ };
22188
+ WorkflowSettingsService.prototype.generateTenWithCode = function (item) {
22189
+ item.ten = item.name + " - " + item.rawCode;
22190
+ };
22191
+ WorkflowSettingsService.prototype.generateTenWithSource = function (item) {
22192
+ item.ten = item.name + " (" + item.sourceName + " - " + item.sourceCode + ")";
22193
+ };
22194
+ WorkflowSettingsService.prototype.generateTenFull = function (item) {
22195
+ item.ten = item.name + " - " + item.rawCode + " (" + item.sourceName + " - " + item.sourceCode + ")";
22196
+ };
22197
+ WorkflowSettingsService.prototype.minimizeDatasourceAction = function (actions, lstWorkflowHistory) {
22198
+ var dataSourceAction = [];
22199
+ var dicSameName = {};
22200
+ actions.forEach(function (action) {
22201
+ if (action.buildIn) {
22202
+ dataSourceAction.push(action);
22203
+ return;
22204
+ }
22205
+ action.ten = action.shortTen;
22206
+ if (lstWorkflowHistory) {
22207
+ if (!lstWorkflowHistory.some(function (q) { return q.sourceStatusCode == action.sourceCode && q.actionCode == action.rawCode; })) {
22208
+ return;
22209
+ }
22210
+ }
22211
+ var itemExist = dataSourceAction.find(function (q) { return q.nameLower == action.nameLower; });
22212
+ if (itemExist) {
22213
+ if (!dicSameName[action.nameLower]) {
22214
+ dicSameName[action.nameLower] = [];
22215
+ }
22216
+ if (dicSameName[action.nameLower].indexOf(itemExist) == -1) {
22217
+ dicSameName[action.nameLower].push(itemExist);
22218
+ }
22219
+ if (dicSameName[action.nameLower].indexOf(action) == -1) {
22220
+ dicSameName[action.nameLower].push(action);
22221
+ }
22222
+ }
22223
+ dataSourceAction.push(action);
22224
+ });
22225
+ this.makeUniqueName(dicSameName);
22226
+ return dataSourceAction;
22227
+ };
22228
+ WorkflowSettingsService.prototype.makeUniqueName = function (dicSameName) {
22229
+ var _this = this;
22151
22230
  Object.values(dicSameName).forEach(function (lstItem) {
22152
22231
  var arrTen = [];
22153
22232
  var error = false;
@@ -22179,16 +22258,6 @@
22179
22258
  _this.generateTenFull(lstItem[i]);
22180
22259
  }
22181
22260
  });
22182
- return dataSourceAction;
22183
- };
22184
- WorkflowSettingsService.prototype.generateTenWithCode = function (item) {
22185
- item.ten = item.name + " - " + item.rawCode;
22186
- };
22187
- WorkflowSettingsService.prototype.generateTenWithSource = function (item) {
22188
- item.ten = item.name + " (" + item.sourceName + " - " + item.sourceCode + ")";
22189
- };
22190
- WorkflowSettingsService.prototype.generateTenFull = function (item) {
22191
- item.ten = item.name + " - " + item.rawCode + " (" + item.sourceName + " - " + item.sourceCode + ")";
22192
22261
  };
22193
22262
  return WorkflowSettingsService;
22194
22263
  }(BaseService));
@@ -30611,60 +30680,56 @@
30611
30680
  this._componentContextService.data.personalize = {};
30612
30681
  }
30613
30682
  this._componentContextService.replaySubscribe(ComCtxConstants.ROOT.USER_LOADED, function (rs) { return __awaiter(_this, void 0, void 0, function () {
30614
- var lstAppCodes, oldUrl;
30683
+ var oldUrl;
30615
30684
  var _this = this;
30616
30685
  return __generator(this, function (_a) {
30617
- switch (_a.label) {
30618
- case 0:
30619
- this._entityMetadataService.setupSyncCacheEntityMetadata();
30620
- this._router.config
30621
- .forEach(function (route) { return _this.addGuard(route); });
30622
- if (!this.firstTimeLogin) return [3 /*break*/, 2];
30623
- lstAppCodes = this.environment.appMetadata.appSwitcher.map(function (app) { return app.code; });
30624
- return [4 /*yield*/, this._permissionService.cleanPermissionCache(lstAppCodes)];
30625
- case 1:
30626
- _a.sent();
30627
- // Thêm vào để đánh dấu lần dầu login => để xử lý
30628
- // UserA đag ở màn hình 1 => đăng xuất => đăng nhập vào tài khoản UserB không có quyền màn hình 1 => redirect về "/"
30629
- this._storageService.removeItem('current_user_info');
30630
- this._storageService.setItem('firstTimeLogin', true);
30631
- oldUrl = this._storageService.getItem('currentUrl');
30632
- if (oldUrl && oldUrl != top.location.href + '') {
30633
- this._storageService.removeItem('currentUrl');
30634
- top.location.href = "" + oldUrl;
30635
- }
30636
- else {
30637
- this.firstTimeLogin = false;
30638
- this._storageService.removeItem('currentUrl');
30639
- this.pageLoaded = true;
30640
- this.onlyShowMainContent = true;
30641
- }
30642
- return [3 /*break*/, 3];
30643
- case 2:
30644
- this.defaultRedirect();
30645
- _a.label = 3;
30646
- case 3:
30647
- // var versionDeploy = this._storageService.getItem('versionDeploy');
30648
- // let versionFromApplication = this.rootVersionDeploy;
30649
- // if (versionFromApplication && versionDeploy && (+versionDeploy) < (+versionFromApplication)) {
30650
- // this._storageService.setItem('versionDeploy', versionFromApplication);
30651
- // this._authenService.logout();
30652
- // }
30653
- this.getPinnedNotes();
30654
- try {
30655
- this._signalRService.init().then(function () {
30656
- _this._signalRService.start('ConsistencyHub', 'BroadcastMessage', _this.clearAuthorizeCache.bind(_this));
30657
- _this._signalRService.start('NotificationHub', 'RefreshForUpdate', function (data) {
30658
- if (data.appCodes && data.appCodes.some(function (x) { return x.toUpperCase() == _this.appCode.toUpperCase(); })) {
30659
- _this._componentContextService.fireEvent(ComCtxConstants.COMMON.FORCE_RELOAD);
30660
- }
30661
- });
30662
- });
30663
- }
30664
- catch (e) {
30665
- }
30666
- return [2 /*return*/];
30686
+ this._entityMetadataService.setupSyncCacheEntityMetadata();
30687
+ this._router.config
30688
+ .forEach(function (route) { return _this.addGuard(route); });
30689
+ if (this.firstTimeLogin) {
30690
+ // lần đầu đăng nhập thì vào trang mặc định
30691
+ // if (this.rootVersionDeploy) {
30692
+ // this._storageService.setItem('versionDeploy', this.rootVersionDeploy);
30693
+ // }
30694
+ // Thêm vào để đánh dấu lần dầu login => để xử lý
30695
+ // UserA đag ở màn hình 1 => đăng xuất => đăng nhập vào tài khoản UserB không có quyền màn hình 1 => redirect về "/"
30696
+ this._storageService.removeItem('current_user_info');
30697
+ this._storageService.setItem('firstTimeLogin', true);
30698
+ oldUrl = this._storageService.getItem('currentUrl');
30699
+ if (oldUrl && oldUrl != top.location.href + '') {
30700
+ this._storageService.removeItem('currentUrl');
30701
+ top.location.href = "" + oldUrl;
30702
+ }
30703
+ else {
30704
+ this.firstTimeLogin = false;
30705
+ this._storageService.removeItem('currentUrl');
30706
+ this.pageLoaded = true;
30707
+ this.onlyShowMainContent = true;
30708
+ }
30709
+ }
30710
+ else {
30711
+ this.defaultRedirect();
30712
+ }
30713
+ // var versionDeploy = this._storageService.getItem('versionDeploy');
30714
+ // let versionFromApplication = this.rootVersionDeploy;
30715
+ // if (versionFromApplication && versionDeploy && (+versionDeploy) < (+versionFromApplication)) {
30716
+ // this._storageService.setItem('versionDeploy', versionFromApplication);
30717
+ // this._authenService.logout();
30718
+ // }
30719
+ this.getPinnedNotes();
30720
+ try {
30721
+ this._signalRService.init().then(function () {
30722
+ _this._signalRService.start('ConsistencyHub', 'BroadcastMessage', _this.clearAuthorizeCache.bind(_this));
30723
+ _this._signalRService.start('NotificationHub', 'RefreshForUpdate', function (data) {
30724
+ if (data.appCodes && data.appCodes.some(function (x) { return x.toUpperCase() == _this.appCode.toUpperCase(); })) {
30725
+ _this._componentContextService.fireEvent(ComCtxConstants.COMMON.FORCE_RELOAD);
30726
+ }
30727
+ });
30728
+ });
30729
+ }
30730
+ catch (e) {
30667
30731
  }
30732
+ return [2 /*return*/];
30668
30733
  });
30669
30734
  }); });
30670
30735
  var defaultModulePages = this._componentContextService.data.personalize.defaultModulePages;
@@ -30710,6 +30775,21 @@
30710
30775
  root.data.allowAnonymous = this.allowAnonymous;
30711
30776
  // get current User
30712
30777
  this._userService.populateCurrentUser();
30778
+ this._componentContextService.subscribe(ComCtxConstants.ROOT.NEED_CLEAR_PERMISSION_CACHE, function () { return __awaiter(_this, void 0, void 0, function () {
30779
+ var res;
30780
+ return __generator(this, function (_a) {
30781
+ switch (_a.label) {
30782
+ case 0: return [4 /*yield*/, this._permissionService.clearPermissionCacheAll()];
30783
+ case 1:
30784
+ res = _a.sent();
30785
+ if (!res.success) {
30786
+ this._notifierService.showWarning('Có lỗi trong lúc clear cache phân quyền');
30787
+ }
30788
+ this._applicationContext.getRootContext().fireReplayEvent(ComCtxConstants.ROOT.USER_LOADED);
30789
+ return [2 /*return*/];
30790
+ }
30791
+ });
30792
+ }); });
30713
30793
  this._componentContextService.subscribe(ComCtxConstants.ROOT.KEY_DOWN_ARROWLEFT, function (e) {
30714
30794
  if (document.activeElement === _this.cancelButton.nativeElement) {
30715
30795
  _this.okButton.nativeElement.focus();
@@ -30943,7 +31023,7 @@
30943
31023
  _this._authenService.cleanupLocalStorage();
30944
31024
  _this._authenService.cleanupSessionStorage();
30945
31025
  _this._storageUpdatedService.cleanupStorageService();
30946
- _this._componentContextService.fireReplayEvent(ComCtxConstants.ROOT.USER_READY, true);
31026
+ _this._componentContextService.fireReplayEvent(ComCtxConstants.ROOT.USER_READY, _this.firstTimeLogin);
30947
31027
  }
30948
31028
  else if (evt.type === 'token_expires') {
30949
31029
  _this._oauthService.tryLogin();
@@ -30969,12 +31049,8 @@
30969
31049
  }
30970
31050
  });
30971
31051
  this._oauthService.loadDiscoveryDocument();
30972
- if (this.firstTimeLogin) {
30973
- var lstPhanHeCode = this.environment.appMetadata.appSwitcher.map(function (phanHe) { return phanHe.code; });
30974
- this._permissionService.cleanPermissionCache(lstPhanHeCode);
30975
- }
30976
31052
  if (this._oauthService.hasValidAccessToken()) {
30977
- this._componentContextService.fireReplayEvent(ComCtxConstants.ROOT.USER_READY, true);
31053
+ this._componentContextService.fireReplayEvent(ComCtxConstants.ROOT.USER_READY, this.firstTimeLogin);
30978
31054
  this._oauthService.setupAutomaticSilentRefresh();
30979
31055
  }
30980
31056
  else {
@@ -48059,6 +48135,8 @@
48059
48135
  StraightConnection: true,
48060
48136
  CenterConnectionLabel: true
48061
48137
  });
48138
+ _this.generated = false;
48139
+ _this.dataSourceAction = [];
48062
48140
  _this.stateDistance = 350;
48063
48141
  _this.topDistance = 80;
48064
48142
  _this.fileDataService = _fileDataService;
@@ -48112,7 +48190,6 @@
48112
48190
  };
48113
48191
  WorkflowHistoryNewComponent.prototype.init = function () {
48114
48192
  this.machineCodeKetThucs = this.currentWorkflow.data.machines.filter(function (q) { return q.type == exports.EnumStateType.STOP; }).map(function (q) { return q.code; });
48115
- var datasourceAction = this.createDatasourceAction();
48116
48193
  this.setting.modelSchemas = [
48117
48194
  new ModelSchema({ field: 'userIdCreated', name: 'Người gửi', fullName: 'Người gửi', description: '' }),
48118
48195
  new ModelSchema({ field: 'actionCode', name: 'Thao tác', fullName: 'Thao tác', description: '' }),
@@ -48127,6 +48204,7 @@
48127
48204
  new ModelSchema({ field: 'roleViewIds', name: 'Chức vụ theo dõi', fullName: 'Chức vụ theo dõi', description: '' }),
48128
48205
  new ModelSchema({ field: 'note', name: 'Ý kiến', fullName: 'Ý kiến', description: '' })
48129
48206
  ];
48207
+ this.dataSourceAction = this.createDatasourceAction();
48130
48208
  this.setting.cols = [
48131
48209
  new ColumnSchemaBase({
48132
48210
  field: 'userIdCreated',
@@ -48136,9 +48214,10 @@
48136
48214
  }),
48137
48215
  new ColumnSchemaBase({
48138
48216
  field: 'fullActionCode',
48217
+ fieldFilter: 'actionCode',
48139
48218
  label: 'Hành động',
48140
48219
  width: '9%',
48141
- dataSource: datasourceAction,
48220
+ dataSource: this.dataSourceAction,
48142
48221
  displayFieldInGrid: 'shortTen',
48143
48222
  valueField: 'code'
48144
48223
  }),
@@ -48246,6 +48325,7 @@
48246
48325
  })
48247
48326
  ];
48248
48327
  this.model.ready = true;
48328
+ this.minimizeDatasourceAction();
48249
48329
  _super.prototype.ngOnInit.call(this);
48250
48330
  };
48251
48331
  WorkflowHistoryNewComponent.prototype.findLastHistoryAndGetData = function () {
@@ -48403,18 +48483,52 @@
48403
48483
  WorkflowHistoryNewComponent.prototype.cloneConnection = function (connection, sourceState, targetState) {
48404
48484
  return Object.assign(Object.assign({}, connection), { source: sourceState.id, target: targetState.id });
48405
48485
  };
48486
+ WorkflowHistoryNewComponent.prototype.minimizeDatasourceAction = function () {
48487
+ return __awaiter(this, void 0, void 0, function () {
48488
+ var lstWorkflowHistory, dataSource;
48489
+ return __generator(this, function (_a) {
48490
+ switch (_a.label) {
48491
+ case 0: return [4 /*yield*/, this._workflowHistoryService.getAll(this.getDefaultFilter(), 'sourceStatusCode,actionCode')];
48492
+ case 1:
48493
+ lstWorkflowHistory = (_a.sent()).data;
48494
+ dataSource = this._workflowSettingService.minimizeDatasourceAction(this.dataSourceAction, lstWorkflowHistory);
48495
+ this.crudList.setDropdownDatasource('fullActionCode', dataSource);
48496
+ return [2 /*return*/];
48497
+ }
48498
+ });
48499
+ });
48500
+ };
48406
48501
  WorkflowHistoryNewComponent.prototype.createDatasourceAction = function () {
48407
48502
  var result = [
48408
- { code: MaActionBatDauQuyTrinh, ten: 'Bắt đầu quy trình' }
48503
+ { code: MaActionBatDauQuyTrinh, ten: 'Bắt đầu quy trình', buildIn: true }
48409
48504
  ];
48410
48505
  result.push.apply(result, __spread(this._workflowSettingService.renderDataSourceActionWorkflow(this.currentWorkflow.data)));
48411
- result.push({ code: ActionUpdateModel, ten: 'Chỉnh sửa' }, { code: ActionChoYKienBase, ten: 'Cho ý kiến' }, { code: ActionThuHoiBase, ten: 'Thu hồi thao tác' });
48506
+ result.push({ code: ActionUpdateModel, ten: 'Chỉnh sửa', buildIn: true }, { code: ActionChoYKienBase, ten: 'Cho ý kiến', buildIn: true }, { code: ActionThuHoiBase, ten: 'Thu hồi thao tác', buildIn: true });
48507
+ result.filter(function (q) { return q.buildIn; }).forEach(function (item) {
48508
+ item.rawCode = item.code;
48509
+ item.shortTen = item.ten;
48510
+ });
48412
48511
  return result;
48413
48512
  };
48513
+ WorkflowHistoryNewComponent.prototype.getDefaultFilter = function () {
48514
+ return [
48515
+ this.newFilter('tableName', exports.Operator.equal, this.tableName),
48516
+ this.newFilter('itemId', exports.Operator.equal, this.item.id),
48517
+ this.newFilter('workflowCode', exports.Operator.equal, this.item.__workflowCode)
48518
+ ];
48519
+ };
48414
48520
  WorkflowHistoryNewComponent.prototype.modifyGridInfo = function (gridInfo) {
48415
48521
  return __awaiter(this, void 0, void 0, function () {
48416
- return __generator(this, function (_a) {
48417
- gridInfo.filters.unshift(this.newFilter('tableName', exports.Operator.equal, this.tableName), this.newFilter('itemId', exports.Operator.equal, this.item.id), this.newFilter('workflowCode', exports.Operator.equal, this.item.__workflowCode));
48522
+ var filterByActionCode, arrValue_1, arrActionCode;
48523
+ var _a;
48524
+ return __generator(this, function (_b) {
48525
+ filterByActionCode = gridInfo.filters.find(function (q) { return q.field == 'actionCode'; });
48526
+ if (filterByActionCode) {
48527
+ arrValue_1 = JSON.parse(filterByActionCode.value);
48528
+ arrActionCode = this.dataSourceAction.filter(function (q) { return arrValue_1.some(function (x) { return x == q.code; }); }).map(function (x) { return x.rawCode; });
48529
+ filterByActionCode.value = JSON.stringify(arrActionCode);
48530
+ }
48531
+ (_a = gridInfo.filters).unshift.apply(_a, __spread(this.getDefaultFilter()));
48418
48532
  gridInfo.sorts.unshift(this.newSort('created', -1));
48419
48533
  return [2 /*return*/];
48420
48534
  });
@@ -48426,7 +48540,13 @@
48426
48540
  return __generator(this, function (_a) {
48427
48541
  // Duyệt từng history để chỉ hiển thị luồng hiện tại của quy trình. k hiển thị các bước thừa
48428
48542
  dataSource.forEach(function (item) {
48429
- item.fullActionCode = item.sourceStatusCode + "___" + item.actionCode;
48543
+ item.fullActionCode = item.actionCode;
48544
+ if (item.actionCode != MaActionBatDauQuyTrinh
48545
+ && item.actionCode != ActionUpdateModel
48546
+ && item.actionCode != ActionChoYKienBase
48547
+ && item.actionCode != ActionThuHoiBase) {
48548
+ item.fullActionCode = item.sourceStatusCode + "___" + item.actionCode;
48549
+ }
48430
48550
  _this.splitList(item, 'userIds');
48431
48551
  _this.splitList(item, 'userViewIds');
48432
48552
  _this.splitList(item, 'donViIds');
@@ -48465,7 +48585,10 @@
48465
48585
  WorkflowHistoryNewComponent.prototype.afterGetData = function () {
48466
48586
  return __awaiter(this, void 0, void 0, function () {
48467
48587
  return __generator(this, function (_a) {
48468
- this.regenerateMachineData();
48588
+ if (!this.generated) {
48589
+ this.generated = true;
48590
+ this.regenerateMachineData();
48591
+ }
48469
48592
  return [2 /*return*/];
48470
48593
  });
48471
48594
  });