@senior-gestao-pessoas/hcm-advanced-filter-general 4.1.2 → 4.1.3

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.
@@ -727,10 +727,8 @@
727
727
  return currentEntity !== nextEntity;
728
728
  };
729
729
  AdvancedFilterFieldsComponent.prototype.getConditionType = function (index) {
730
- var _a, _b, _c;
731
- if (((_a = this.fieldListAdvancedFilter[index]) === null || _a === void 0 ? void 0 : _a.entityName) !== FilterFieldType.SALARY_TYPE
732
- && ((_b = this.fieldListAdvancedFilter[index]) === null || _b === void 0 ? void 0 : _b.entityName) !== FilterFieldType.TIME_SHIFT_TYPE
733
- && ((_c = this.fieldListAdvancedFilter[index]) === null || _c === void 0 ? void 0 : _c.entityName) !== FilterFieldType.COST_CENTER) {
730
+ var _a;
731
+ if (this.lookupsWithOneFilterType((_a = this.fieldListAdvancedFilter[index]) === null || _a === void 0 ? void 0 : _a.entityName)) {
734
732
  return this.conditionType;
735
733
  }
736
734
  else {
@@ -740,6 +738,12 @@
740
738
  }];
741
739
  }
742
740
  };
741
+ AdvancedFilterFieldsComponent.prototype.lookupsWithOneFilterType = function (entityName) {
742
+ return entityName !== FilterFieldType.SALARY_TYPE
743
+ && entityName !== FilterFieldType.TIME_SHIFT_TYPE
744
+ && entityName !== FilterFieldType.COST_CENTER
745
+ && entityName !== FilterFieldType.EMPLOYMENT_RELATIONSHIP;
746
+ };
743
747
  AdvancedFilterFieldsComponent.prototype.changeDefaultFieldInformation = function (field, name, index, entityName) {
744
748
  field.gridClass = ["ui-g-12"];
745
749
  field.label = "";
@@ -952,7 +956,18 @@
952
956
  var StorageService = /** @class */ (function () {
953
957
  function StorageService() {
954
958
  this.GET_USER_ID = seniorPlatformData.user.getUserData().then(function (user) { return user.id; });
959
+ this.GET_USERNAME = seniorPlatformData.user.getUserData().then(function (user) { return (user === null || user === void 0 ? void 0 : user.username) + "@" + (user === null || user === void 0 ? void 0 : user.tenantDomain); });
955
960
  }
961
+ StorageService.prototype.getUser = function () {
962
+ return __awaiter(this, void 0, void 0, function () {
963
+ return __generator(this, function (_a) {
964
+ switch (_a.label) {
965
+ case 0: return [4 /*yield*/, this.GET_USERNAME];
966
+ case 1: return [2 /*return*/, _a.sent()];
967
+ }
968
+ });
969
+ });
970
+ };
956
971
  StorageService.prototype.store = function (key, value) {
957
972
  return __awaiter(this, void 0, void 0, function () {
958
973
  var _a, _b;
@@ -1585,18 +1600,30 @@
1585
1600
  });
1586
1601
  };
1587
1602
  AdvancedFilterComponent.prototype.onAdvancedFilterSearchRequest = function (event) {
1588
- var _this = this;
1589
- var first = event.first, rows = event.rows, multiSortMeta = event.multiSortMeta, filterData = event.filterData;
1590
- var page = first / rows;
1591
- var sort = multiSortMeta;
1592
- var filterQuery = createSearchRequestFilter(filterData, this.getAdvancedFilterFields());
1593
- this.advancedFilterService
1594
- .list({ page: page, sort: sort, filterQuery: filterQuery })
1595
- .pipe(operators.takeUntil(this.ngUnsubscribe))
1596
- .pipe(operators.map(function (list) { return _this.mapToComponent(list); }))
1597
- .subscribe(function (list) {
1598
- _this.advancedFilterSearchGridData = list.contents;
1599
- _this.advancedFilterSearchTotalRecords = list.totalElements;
1603
+ return __awaiter(this, void 0, void 0, function () {
1604
+ var first, rows, multiSortMeta, filterData, page, sort, filterQuery;
1605
+ var _this = this;
1606
+ return __generator(this, function (_a) {
1607
+ switch (_a.label) {
1608
+ case 0:
1609
+ first = event.first, rows = event.rows, multiSortMeta = event.multiSortMeta, filterData = event.filterData;
1610
+ page = first / rows;
1611
+ sort = multiSortMeta;
1612
+ filterQuery = createSearchRequestFilter(filterData, this.getAdvancedFilterFields());
1613
+ return [4 /*yield*/, this.buildFilterByUsername(filterQuery)];
1614
+ case 1:
1615
+ filterQuery = _a.sent();
1616
+ this.advancedFilterService
1617
+ .list({ page: page, sort: sort, filterQuery: filterQuery })
1618
+ .pipe(operators.takeUntil(this.ngUnsubscribe))
1619
+ .pipe(operators.map(function (list) { return _this.mapToComponent(list); }))
1620
+ .subscribe(function (list) {
1621
+ _this.advancedFilterSearchGridData = list.contents;
1622
+ _this.advancedFilterSearchTotalRecords = list.totalElements;
1623
+ });
1624
+ return [2 /*return*/];
1625
+ }
1626
+ });
1600
1627
  });
1601
1628
  };
1602
1629
  AdvancedFilterComponent.prototype.mapToComponent = function (list) {
@@ -1645,15 +1672,27 @@
1645
1672
  }, function () { return _this.loading = false; });
1646
1673
  };
1647
1674
  AdvancedFilterComponent.prototype.onAdvancedFilterLookupRequest = function (value) {
1648
- var _this = this;
1649
- var sort = this.advancedFilterLookupDisplayFields.map(function (field) { return ({ field: field, order: 1 }); });
1650
- var filterQuery = createLookupRequestFilter(value, this.getAdvancedFilterFields());
1651
- this.advancedFilterService
1652
- .list({ sort: sort, filterQuery: filterQuery })
1653
- .pipe(operators.takeUntil(this.ngUnsubscribe))
1654
- .pipe(operators.map(function (list) { return _this.mapToComponent(list); }))
1655
- .subscribe(function (list) {
1656
- _this.advancedFilterLookupSuggestions = list.contents;
1675
+ return __awaiter(this, void 0, void 0, function () {
1676
+ var sort, filterQuery;
1677
+ var _this = this;
1678
+ return __generator(this, function (_a) {
1679
+ switch (_a.label) {
1680
+ case 0:
1681
+ sort = this.advancedFilterLookupDisplayFields.map(function (field) { return ({ field: field, order: 1 }); });
1682
+ filterQuery = createLookupRequestFilter(value, this.getAdvancedFilterFields());
1683
+ return [4 /*yield*/, this.buildFilterByUsername(filterQuery)];
1684
+ case 1:
1685
+ filterQuery = _a.sent();
1686
+ this.advancedFilterService
1687
+ .list({ sort: sort, filterQuery: filterQuery })
1688
+ .pipe(operators.takeUntil(this.ngUnsubscribe))
1689
+ .pipe(operators.map(function (list) { return _this.mapToComponent(list); }))
1690
+ .subscribe(function (list) {
1691
+ _this.advancedFilterLookupSuggestions = list.contents;
1692
+ });
1693
+ return [2 /*return*/];
1694
+ }
1695
+ });
1657
1696
  });
1658
1697
  };
1659
1698
  AdvancedFilterComponent.prototype.getAdvancedFilterFields = function () {
@@ -1665,6 +1704,23 @@
1665
1704
  }),
1666
1705
  ];
1667
1706
  };
1707
+ AdvancedFilterComponent.prototype.buildFilterByUsername = function (filterQuery) {
1708
+ return __awaiter(this, void 0, void 0, function () {
1709
+ var user, filterString;
1710
+ return __generator(this, function (_a) {
1711
+ switch (_a.label) {
1712
+ case 0: return [4 /*yield*/, this.filtersStorageService.getUser()];
1713
+ case 1:
1714
+ user = _a.sent();
1715
+ if (user) {
1716
+ filterString = "username eq '" + user + "'";
1717
+ filterQuery = filterQuery ? filterQuery + " and (" + filterString + ")" : filterString;
1718
+ }
1719
+ return [2 /*return*/, filterQuery];
1720
+ }
1721
+ });
1722
+ });
1723
+ };
1668
1724
  AdvancedFilterComponent.prototype.validateFieldsSaveAndApply = function () {
1669
1725
  var arrFormGroup = this.formGroup.get("advancedFilterFields");
1670
1726
  var rowInvalid = false;