@senior-gestao-pessoas/hcm-advanced-filter-general 4.1.2 → 4.2.0-develop-00ecdb10

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 (22) hide show
  1. package/bundles/senior-gestao-pessoas-hcm-advanced-filter-general.umd.js +97 -40
  2. package/bundles/senior-gestao-pessoas-hcm-advanced-filter-general.umd.js.map +1 -1
  3. package/bundles/senior-gestao-pessoas-hcm-advanced-filter-general.umd.min.js +1 -1
  4. package/bundles/senior-gestao-pessoas-hcm-advanced-filter-general.umd.min.js.map +1 -1
  5. package/esm2015/lib/advanced-filter/advanced-filter.component.js +36 -20
  6. package/esm2015/lib/advanced-filter-fields/advanced-filter-fields.component.js +20 -20
  7. package/esm2015/lib/filter-container/filter-container.component.js +6 -1
  8. package/esm2015/shared/storage/storage.service.js +7 -1
  9. package/esm5/lib/advanced-filter/advanced-filter.component.js +63 -22
  10. package/esm5/lib/advanced-filter-fields/advanced-filter-fields.component.js +21 -21
  11. package/esm5/lib/filter-container/filter-container.component.js +6 -1
  12. package/esm5/shared/storage/storage.service.js +12 -1
  13. package/fesm2015/senior-gestao-pessoas-hcm-advanced-filter-general.js +65 -38
  14. package/fesm2015/senior-gestao-pessoas-hcm-advanced-filter-general.js.map +1 -1
  15. package/fesm5/senior-gestao-pessoas-hcm-advanced-filter-general.js +98 -41
  16. package/fesm5/senior-gestao-pessoas-hcm-advanced-filter-general.js.map +1 -1
  17. package/lib/advanced-filter/advanced-filter.component.d.ts +3 -2
  18. package/lib/advanced-filter-fields/advanced-filter-fields.component.d.ts +1 -0
  19. package/lib/filter-container/filter-container.component.d.ts +1 -0
  20. package/package.json +1 -1
  21. package/senior-gestao-pessoas-hcm-advanced-filter-general.metadata.json +1 -1
  22. package/shared/storage/storage.service.d.ts +2 -0
@@ -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,18 +738,20 @@
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
- field.gridClass = ["ui-g-12"];
745
- field.label = "";
746
- field.name = name;
747
- field.entityName = entityName;
748
- if (name === "equals") {
749
- field.multiple = true;
750
- }
748
+ var modifiedField = __assign(__assign({}, field), { label: "", name: name,
749
+ entityName: entityName, gridClass: ["ui-g-12"], multiple: name === "equals" ? true : field.multiple });
751
750
  if (this.fieldListAdvancedFilter[index].filterFormFields) {
752
- field.searchFields = this.fieldListAdvancedFilter[index].filterFormFields;
753
- field.searchGridFields = this.fieldListAdvancedFilter[index].filterFormFields;
751
+ modifiedField.searchFields = this.fieldListAdvancedFilter[index].filterFormFields;
752
+ modifiedField.searchGridFields = this.fieldListAdvancedFilter[index].filterFormFields;
754
753
  }
754
+ return modifiedField;
755
755
  };
756
756
  AdvancedFilterFieldsComponent.prototype.createFormAndDynamicFormByList = function () {
757
757
  var _this = this;
@@ -790,12 +790,12 @@
790
790
  return null;
791
791
  }
792
792
  var entityName = (_b = this.fieldListAdvancedFilter[index]) === null || _b === void 0 ? void 0 : _b.entityName;
793
- var equals = this.getDynamicFormField(this.fieldListAdvancedFilter[index]);
794
- this.changeDefaultFieldInformation(equals, "equals", index, entityName);
795
- var startRange = this.getDynamicFormField(this.fieldListAdvancedFilter[index]);
796
- this.changeDefaultFieldInformation(startRange, "startRange", index, entityName);
797
- var endRange = this.getDynamicFormField(this.fieldListAdvancedFilter[index]);
798
- this.changeDefaultFieldInformation(endRange, "endRange", index, entityName);
793
+ var equalsField = this.getDynamicFormField(this.fieldListAdvancedFilter[index]);
794
+ var equals = this.changeDefaultFieldInformation(equalsField, "equals", index, entityName);
795
+ var startRangeField = this.getDynamicFormField(this.fieldListAdvancedFilter[index]);
796
+ var startRange = this.changeDefaultFieldInformation(startRangeField, "startRange", index, entityName);
797
+ var endRangeField = this.getDynamicFormField(this.fieldListAdvancedFilter[index]);
798
+ var endRange = this.changeDefaultFieldInformation(endRangeField, "endRange", index, entityName);
799
799
  return {
800
800
  equals: [equals],
801
801
  startRange: [startRange],
@@ -952,7 +952,18 @@
952
952
  var StorageService = /** @class */ (function () {
953
953
  function StorageService() {
954
954
  this.GET_USER_ID = seniorPlatformData.user.getUserData().then(function (user) { return user.id; });
955
+ 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
956
  }
957
+ StorageService.prototype.getUser = function () {
958
+ return __awaiter(this, void 0, void 0, function () {
959
+ return __generator(this, function (_a) {
960
+ switch (_a.label) {
961
+ case 0: return [4 /*yield*/, this.GET_USERNAME];
962
+ case 1: return [2 /*return*/, _a.sent()];
963
+ }
964
+ });
965
+ });
966
+ };
956
967
  StorageService.prototype.store = function (key, value) {
957
968
  return __awaiter(this, void 0, void 0, function () {
958
969
  var _a, _b;
@@ -1585,18 +1596,30 @@
1585
1596
  });
1586
1597
  };
1587
1598
  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;
1599
+ return __awaiter(this, void 0, void 0, function () {
1600
+ var first, rows, multiSortMeta, filterData, page, sort, filterQuery;
1601
+ var _this = this;
1602
+ return __generator(this, function (_a) {
1603
+ switch (_a.label) {
1604
+ case 0:
1605
+ first = event.first, rows = event.rows, multiSortMeta = event.multiSortMeta, filterData = event.filterData;
1606
+ page = first / rows;
1607
+ sort = multiSortMeta;
1608
+ filterQuery = createSearchRequestFilter(filterData, this.getAdvancedFilterFields());
1609
+ return [4 /*yield*/, this.buildFilterByUsername(filterQuery)];
1610
+ case 1:
1611
+ filterQuery = _a.sent();
1612
+ this.advancedFilterService
1613
+ .list({ page: page, sort: sort, filterQuery: filterQuery })
1614
+ .pipe(operators.takeUntil(this.ngUnsubscribe))
1615
+ .pipe(operators.map(function (list) { return _this.mapToComponent(list); }))
1616
+ .subscribe(function (list) {
1617
+ _this.advancedFilterSearchGridData = list.contents;
1618
+ _this.advancedFilterSearchTotalRecords = list.totalElements;
1619
+ });
1620
+ return [2 /*return*/];
1621
+ }
1622
+ });
1600
1623
  });
1601
1624
  };
1602
1625
  AdvancedFilterComponent.prototype.mapToComponent = function (list) {
@@ -1645,15 +1668,27 @@
1645
1668
  }, function () { return _this.loading = false; });
1646
1669
  };
1647
1670
  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;
1671
+ return __awaiter(this, void 0, void 0, function () {
1672
+ var sort, filterQuery;
1673
+ var _this = this;
1674
+ return __generator(this, function (_a) {
1675
+ switch (_a.label) {
1676
+ case 0:
1677
+ sort = this.advancedFilterLookupDisplayFields.map(function (field) { return ({ field: field, order: 1 }); });
1678
+ filterQuery = createLookupRequestFilter(value, this.getAdvancedFilterFields());
1679
+ return [4 /*yield*/, this.buildFilterByUsername(filterQuery)];
1680
+ case 1:
1681
+ filterQuery = _a.sent();
1682
+ this.advancedFilterService
1683
+ .list({ sort: sort, filterQuery: filterQuery })
1684
+ .pipe(operators.takeUntil(this.ngUnsubscribe))
1685
+ .pipe(operators.map(function (list) { return _this.mapToComponent(list); }))
1686
+ .subscribe(function (list) {
1687
+ _this.advancedFilterLookupSuggestions = list.contents;
1688
+ });
1689
+ return [2 /*return*/];
1690
+ }
1691
+ });
1657
1692
  });
1658
1693
  };
1659
1694
  AdvancedFilterComponent.prototype.getAdvancedFilterFields = function () {
@@ -1665,6 +1700,23 @@
1665
1700
  }),
1666
1701
  ];
1667
1702
  };
1703
+ AdvancedFilterComponent.prototype.buildFilterByUsername = function (filterQuery) {
1704
+ return __awaiter(this, void 0, void 0, function () {
1705
+ var user, filterString;
1706
+ return __generator(this, function (_a) {
1707
+ switch (_a.label) {
1708
+ case 0: return [4 /*yield*/, this.filtersStorageService.getUser()];
1709
+ case 1:
1710
+ user = _a.sent();
1711
+ if (user) {
1712
+ filterString = "username eq '" + user + "'";
1713
+ filterQuery = filterQuery ? filterQuery + " and (" + filterString + ")" : filterString;
1714
+ }
1715
+ return [2 /*return*/, filterQuery];
1716
+ }
1717
+ });
1718
+ });
1719
+ };
1668
1720
  AdvancedFilterComponent.prototype.validateFieldsSaveAndApply = function () {
1669
1721
  var arrFormGroup = this.formGroup.get("advancedFilterFields");
1670
1722
  var rowInvalid = false;
@@ -2378,6 +2430,7 @@
2378
2430
  this.tokens = [];
2379
2431
  this.KEY_STORAGE = "AdvancedFilterComponent";
2380
2432
  this.filterTypeChanged = new core.EventEmitter();
2433
+ this.advancedFilterEvent = new core.EventEmitter();
2381
2434
  this.loadFilterFieldsOnInit = true;
2382
2435
  this.filterOptions = [
2383
2436
  {
@@ -2439,6 +2492,7 @@
2439
2492
  var advancedFilterControls = this.filterControls.ADVANCED_FILTER;
2440
2493
  advancedFilterControls.forEach(function (control) { return _this.formGroup.get(control).setValue(data); });
2441
2494
  FormUtils.updateAndValidateControlValues(this.formGroup, false);
2495
+ this.advancedFilterEvent.emit($event);
2442
2496
  };
2443
2497
  FilterContainerComponent.prototype.setSelectedFilter = function (tokens) {
2444
2498
  var _a, _b;
@@ -2597,6 +2651,9 @@
2597
2651
  __decorate([
2598
2652
  core.Output()
2599
2653
  ], FilterContainerComponent.prototype, "filterTypeChanged", void 0);
2654
+ __decorate([
2655
+ core.Output()
2656
+ ], FilterContainerComponent.prototype, "advancedFilterEvent", void 0);
2600
2657
  __decorate([
2601
2658
  core.Input()
2602
2659
  ], FilterContainerComponent.prototype, "filterType", void 0);