qms-angular 1.1.41 → 1.1.42

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.
@@ -30430,25 +30430,26 @@ class SelectDepartmentTreeComponent {
30430
30430
  const treeNodes = this.treeDepartmentService.convertToTreeData(this.config.selectedList.map(x => (Object.assign(Object.assign({}, x), { parentId: x.groupId }))));
30431
30431
  this.execWithoutEmitNodeChangeEvent(() => {
30432
30432
  const selectedItems = [];
30433
- const reMapTreeNode = (item) => {
30433
+ const reMapTreeNode = (item, clearGroupId = false) => {
30434
30434
  var _a;
30435
30435
  const node = this.treeControl.dataNodes.find(x => x.id == item.id);
30436
30436
  const nestedNode = this.convertToNestedNode(node);
30437
30437
  node.groupId = item.groupId;
30438
30438
  node.isGroup = item.isGroup;
30439
30439
  this.checkListSelection.select(node);
30440
- return Object.assign(Object.assign({}, nestedNode), { groupId: item.groupId, isGroup: item.isGroup, childCount: (_a = nestedNode.childCount) !== null && _a !== void 0 ? _a : this.getListChildrenOfNode(node).length, children: [] });
30440
+ return Object.assign(Object.assign({}, nestedNode), { groupId: clearGroupId ? null : item.groupId, isGroup: item.isGroup, childCount: (_a = nestedNode.childCount) !== null && _a !== void 0 ? _a : this.getListChildrenOfNode(node).length, children: [] });
30441
30441
  };
30442
30442
  treeNodes.forEach(item => {
30443
30443
  const node = this.treeControl.dataNodes.find(x => x.id == item.id);
30444
30444
  if (!node)
30445
30445
  return;
30446
30446
  const nestedNode = this.convertToNestedNode(node);
30447
- selectedItems.push(Object.assign(Object.assign({}, reMapTreeNode(item)), { children: item.children.map(x => reMapTreeNode(x)) }));
30447
+ selectedItems.push(Object.assign(Object.assign({}, reMapTreeNode(item, true)), { children: item.children.map(x => reMapTreeNode(x)) }));
30448
30448
  });
30449
30449
  this.resultSelected.push(...selectedItems);
30450
30450
  });
30451
30451
  this.onValueChangeEvent.emit(this.resultSelected);
30452
+ this._onSelectionNodeChangeEvent('added', this.resultSelected);
30452
30453
  this.cdRef.detectChanges();
30453
30454
  }
30454
30455
  _initListSelected() {
@@ -32024,6 +32025,9 @@ class QMSSelectAccessDialogComponent {
32024
32025
  return userGroups.data || [];
32025
32026
  }
32026
32027
  ;
32028
+ ngAfterContentChecked() {
32029
+ this.cdRef.detectChanges();
32030
+ }
32027
32031
  ngAfterContentInit() {
32028
32032
  this.cdRef.detectChanges();
32029
32033
  }
@@ -32081,8 +32085,23 @@ class QMSSelectAccessDialogComponent {
32081
32085
  this.resultAccess = _.cloneDeep(Object.assign(Object.assign({}, this.dialogData.data.selectedData), { departments: [] }));
32082
32086
  // init group selected department
32083
32087
  this._departmentSelected = _.cloneDeep(this.dialogData.data.selectedData.departments);
32084
- const groups = this._departmentSelected.filter(x => x.isGroup) || [];
32085
- const singleItem = this._departmentSelected.filter(x => !x.isGroup && !x.groupId);
32088
+ const groups = [];
32089
+ const singleItem = [];
32090
+ this._departmentSelected.forEach(item => {
32091
+ if (item.isGroup) {
32092
+ groups.push(item);
32093
+ return;
32094
+ }
32095
+ if (!item.groupId) {
32096
+ singleItem.push(item);
32097
+ return;
32098
+ }
32099
+ if (!this._departmentSelected.some(x => x.id == item.groupId)) {
32100
+ item.groupId = null;
32101
+ singleItem.push(item);
32102
+ return;
32103
+ }
32104
+ });
32086
32105
  groups.forEach(group => {
32087
32106
  const child = this._departmentSelected.filter(item => item.groupId == group.id);
32088
32107
  group.children = child;
@@ -32372,9 +32391,11 @@ class QMSSelectAccessDialogComponent {
32372
32391
  this.resultAccess.departments.splice(index, 1);
32373
32392
  });
32374
32393
  });
32394
+ this.cdRef.detectChanges();
32375
32395
  }
32376
32396
  this.resultAccess.departments.forEach(item => {
32377
- item.children = item.children.filter((x, index) => index === item.children.findIndex(_x => x.id === _x.id));
32397
+ if (!!item.children)
32398
+ item.children = item.children.filter((x, index) => index === item.children.findIndex(_x => x.id === _x.id));
32378
32399
  });
32379
32400
  this._departmentSelected = _.cloneDeep(this.resultAccess.departments);
32380
32401
  this.cdRef.detectChanges();