@seniorsistemas/platform-components 5.3.1 → 5.3.2

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.
@@ -553,6 +553,7 @@
553
553
  var GET_FILTERS_URL = URL_PREFIX + "/queries/getFilters";
554
554
  var SAVE_FILTERS_URL = URL_PREFIX + "/actions/saveUserFilters";
555
555
  var SAVE_TICKED_FILTER_URL = URL_PREFIX + "/actions/setTicketFilters";
556
+ var GET_FILTERS_BY_TICKET = URL_PREFIX + "/queries/getFiltersByTicket";
556
557
 
557
558
  var searchDisplayName = '$$__displayValue__';
558
559
  var searchKeyName = '$$__keyValue__';
@@ -1100,6 +1101,7 @@
1100
1101
  };
1101
1102
  this.showMessages = true;
1102
1103
  this.isModal = false;
1104
+ this.contextId = '';
1103
1105
  this.totalFiltersActiveOutput = new core.EventEmitter();
1104
1106
  this.errorOutput = new core.EventEmitter();
1105
1107
  this.showDialogOutput = new core.EventEmitter();
@@ -1200,17 +1202,20 @@
1200
1202
  }, '*');
1201
1203
  }
1202
1204
  };
1203
- FormFilterComponent.prototype.saveFilters = function () {
1205
+ FormFilterComponent.prototype.saveFilters = function (forceSave) {
1204
1206
  var _this = this;
1207
+ if (forceSave === void 0) { forceSave = false; }
1205
1208
  var filters = this.parseToUserFilters(this.formFilters);
1206
1209
  var savedFilterSuccess = function () {
1207
- var message = {
1208
- key: 'filterServiceToastKey',
1209
- severity: 'info',
1210
- life: TOAST_LIFE,
1211
- detail: _this.translate.instant(TRANSLATE_PREFIX$1 + ".saved_filters_success", { activeFilters: _this.totalFiltersActive })
1212
- };
1213
- _this.sendMessage(message);
1210
+ if (!forceSave) {
1211
+ var message = {
1212
+ key: 'filterServiceToastKey',
1213
+ severity: 'info',
1214
+ life: TOAST_LIFE,
1215
+ detail: _this.translate.instant(TRANSLATE_PREFIX$1 + ".saved_filters_success", { activeFilters: _this.totalFiltersActive })
1216
+ };
1217
+ _this.sendMessage(message);
1218
+ }
1214
1219
  _this.counterUpdate();
1215
1220
  };
1216
1221
  var savedFiltersError = function () {
@@ -1223,9 +1228,15 @@
1223
1228
  _this.sendMessage(message);
1224
1229
  };
1225
1230
  this.filterService
1226
- .saveFilters(filters) //
1231
+ .saveFilters(filters)
1227
1232
  .subscribe(savedFilterSuccess, savedFiltersError);
1228
1233
  };
1234
+ FormFilterComponent.prototype.saveFiltersWithCallbackFunction = function (callbackFunction) {
1235
+ var filters = this.parseToUserFilters(this.formFilters);
1236
+ this.filterService
1237
+ .saveFilters(filters)
1238
+ .subscribe(callbackFunction);
1239
+ };
1229
1240
  FormFilterComponent.prototype.counterUpdate = function () {
1230
1241
  this.totalFiltersActive = this.countActiveFilters(this.tabs);
1231
1242
  this.totalFiltersActiveOutput.emit(this.totalFiltersActive);
@@ -1277,23 +1288,26 @@
1277
1288
  var _this = this;
1278
1289
  var filtersObserver = this.filterService.filtersObserver;
1279
1290
  filtersObserver
1280
- .pipe(operators.takeUntil(this.destroy$)) //
1291
+ .pipe(operators.takeUntil(this.destroy$))
1281
1292
  .subscribe(function (_a) {
1282
1293
  var filters = _a.filters, applyFilter = _a.applyFilter, error = _a.error, message = _a.message;
1283
1294
  _this.errorOutput.emit(error);
1284
1295
  _this.error = error;
1285
1296
  _this.errorState = message;
1286
1297
  if (!error) {
1287
- _this.tabs = _this.createTabs(filters);
1288
- _this.counterUpdate();
1289
- _this.setDependencies(_this.formFilters);
1290
- _this.createChildArray();
1291
- if (filters.length > 0 && applyFilter) {
1292
- _this.applyFilters();
1293
- }
1298
+ _this.createForm(filters, applyFilter);
1294
1299
  }
1295
1300
  });
1296
1301
  };
1302
+ FormFilterComponent.prototype.createForm = function (filters, applyFilter) {
1303
+ this.tabs = this.createTabs(filters);
1304
+ this.counterUpdate();
1305
+ this.setDependencies(this.formFilters);
1306
+ this.createChildArray();
1307
+ if (filters.length > 0 && applyFilter) {
1308
+ this.applyFilters();
1309
+ }
1310
+ };
1297
1311
  FormFilterComponent.prototype.setDependencies = function (filters) {
1298
1312
  var _this = this;
1299
1313
  var names = Object.keys(filters);
@@ -1352,7 +1366,7 @@
1352
1366
  var controlName = getFilterId(domain, name);
1353
1367
  var fieldControl = createFormControl(filter);
1354
1368
  fieldControl.valueChanges
1355
- .pipe(operators.takeUntil(this.destroy$), operators.map(function (v) { return parseFilterValue(v, type); }), operators.tap(function (value) { return (_this.formFilters[controlName].value = value); })) //
1369
+ .pipe(operators.takeUntil(this.destroy$), operators.map(function (v) { return parseFilterValue(v, type); }), operators.tap(function (value) { return (_this.formFilters[controlName].value = value); }))
1356
1370
  .subscribe(function (val) {
1357
1371
  return _this.tabs.forEach(function (tab) {
1358
1372
  var control = tab.form.controls[name];
@@ -1382,6 +1396,7 @@
1382
1396
  /**
1383
1397
  *
1384
1398
  * @todo Refatorar. O método possui muitas responsabilidades
1399
+ *
1385
1400
  */
1386
1401
  FormFilterComponent.prototype.createTabs = function (filters) {
1387
1402
  var _this = this;
@@ -1407,21 +1422,23 @@
1407
1422
  _this.addGeneralField(filter);
1408
1423
  }
1409
1424
  contexts.forEach(function (contextId) {
1410
- var tabId = getTabId(domain, contextId);
1411
- var fieldControl = createFormControl(filter);
1412
- if (!tabs.has(tabId)) {
1413
- var contextLabel = _this.contexts.find(function (context) { return context.contextId === contextId; }).contextLabel;
1414
- var tab = new ContextTab({ domain: domain, name: contextLabel });
1415
- tabs.set(tabId, tab);
1416
- }
1417
- fieldControl.valueChanges
1418
- .pipe(operators.takeUntil(_this.destroy$)) //
1419
- .subscribe(function (val) { return _this.updateFilterValue(tabId, name, val, domain, type); });
1420
- var contextTab = tabs.get(tabId);
1421
- contextTab.fields.push(field);
1422
- contextTab.form.addControl(filter.name, fieldControl);
1423
- if (!formFilter.filterControl) {
1424
- formFilter.filterControl = fieldControl;
1425
+ if ((contextId === _this.contextId) || (_this.contextId === '')) {
1426
+ var tabId_1 = getTabId(domain, contextId);
1427
+ var fieldControl = createFormControl(filter);
1428
+ if (!tabs.has(tabId_1)) {
1429
+ var contextLabel = _this.contexts.find(function (context) { return context.contextId === contextId; }).contextLabel;
1430
+ var tab = new ContextTab({ domain: domain, name: contextLabel });
1431
+ tabs.set(tabId_1, tab);
1432
+ }
1433
+ fieldControl.valueChanges
1434
+ .pipe(operators.takeUntil(_this.destroy$))
1435
+ .subscribe(function (val) { return _this.updateFilterValue(tabId_1, name, val, domain, type); });
1436
+ var contextTab = tabs.get(tabId_1);
1437
+ contextTab.fields.push(field);
1438
+ contextTab.form.addControl(filter.name, fieldControl);
1439
+ if (!formFilter.filterControl) {
1440
+ formFilter.filterControl = fieldControl;
1441
+ }
1425
1442
  }
1426
1443
  });
1427
1444
  return tabs;
@@ -1638,6 +1655,9 @@
1638
1655
  __decorate([
1639
1656
  core.Input()
1640
1657
  ], FormFilterComponent.prototype, "isModal", void 0);
1658
+ __decorate([
1659
+ core.Input()
1660
+ ], FormFilterComponent.prototype, "contextId", void 0);
1641
1661
  __decorate([
1642
1662
  core.Output()
1643
1663
  ], FormFilterComponent.prototype, "totalFiltersActiveOutput", void 0);
@@ -1675,12 +1695,14 @@
1675
1695
  this.canOpenFilter = true;
1676
1696
  this.showActiveFiltersCountBadge = true;
1677
1697
  this.filterAndSave = false;
1698
+ this.contextId = '';
1678
1699
  this.subscriptions = [];
1679
1700
  this.isMobile = false;
1680
1701
  this.tabViewOrientation = 'left';
1681
1702
  this.totalFiltersActive = 0;
1682
1703
  this.showDialog = false;
1683
1704
  this.error = false;
1705
+ this.currentTicket = '';
1684
1706
  this.mobileButtonActions = [
1685
1707
  { id: 'save', label: this.translate.instant('save'), command: function () { return _this.modalComponent.saveFilters(); } },
1686
1708
  { id: 'clear', label: this.translate.instant('clear'), command: function () { return _this.modalComponent.clearFilters(); } }
@@ -1717,8 +1739,12 @@
1717
1739
  AdvancedFilterComponent.prototype.onError = function (event) {
1718
1740
  this.error = event;
1719
1741
  };
1720
- AdvancedFilterComponent.prototype.saveFilters = function () {
1721
- this.modalComponent.saveFilters();
1742
+ AdvancedFilterComponent.prototype.saveFilters = function (forceSave) {
1743
+ if (forceSave === void 0) { forceSave = false; }
1744
+ this.modalComponent.saveFilters(forceSave);
1745
+ };
1746
+ AdvancedFilterComponent.prototype.saveFiltersWithCallbackFunction = function (callbackFunction) {
1747
+ this.modalComponent.saveFiltersWithCallbackFunction(callbackFunction);
1722
1748
  };
1723
1749
  AdvancedFilterComponent.prototype.clearFilters = function () {
1724
1750
  this.modalComponent.clearFilters();
@@ -1775,6 +1801,9 @@
1775
1801
  __decorate([
1776
1802
  core.Input()
1777
1803
  ], AdvancedFilterComponent.prototype, "filterAndSave", void 0);
1804
+ __decorate([
1805
+ core.Input()
1806
+ ], AdvancedFilterComponent.prototype, "contextId", void 0);
1778
1807
  __decorate([
1779
1808
  core.ViewChild(FormFilterComponent)
1780
1809
  ], AdvancedFilterComponent.prototype, "modalComponent", void 0);
@@ -1784,7 +1813,7 @@
1784
1813
  AdvancedFilterComponent = __decorate([
1785
1814
  core.Component({
1786
1815
  selector: 's-advanced-filter',
1787
- template: "<s-button\n *ngIf=\"!onlyContent\"\n [id]=\"'filterButton'\"\n [disabled]=\"!canOpenFilter\"\n (click)=\"canOpenFilter ? toggleDialog() : ''\"\n iconClass=\"fa fa-filter\"\n priority=\"default\"\n [label]=\"labelButton\"\n [auxiliary]=\"true\"\n [tooltip]=\"appliedFiltersTooltip\"\n>\n <span *ngIf=\"totalFiltersActive && showActiveFiltersCountBadge\" class=\"sds-badge-number sds-color-primary custom-badge\">{{ totalFiltersActive }}</span>\n</s-button>\n\n<section *ngIf=\"onlyContent\">\n <div class=\"only-content-wrapper\">\n <div class=\"header\">\n <h3>{{ 'platform.filter_service.filters' | translate }}</h3>\n <span (click)=\"close()\" class=\"close_btn pi pi-times\"></span>\n </div>\n <div class=\"app-form-filter\">\n <s-app-form-filter\n [showMessages]=\"false\"\n (totalFiltersActiveOutput)=\"updateTotalFiltersActive($event)\"\n (closeModalOutput)=\"close()\"\n [isModal]=\"false\"\n ></s-app-form-filter>\n </div>\n <div class=\"filter-footer\" *ngIf=\"!error\">\n <s-button priority=\"link\" [label]=\"translate.instant('platform.filter_service.cancel')\" (click)=\"close()\"></s-button>\n <s-button\n *ngIf=\"isMobile\"\n priority=\"default\"\n [label]=\"translate.instant('platform.filter_service.actions')\"\n [auxiliary]=\"true\"\n [model]=\"mobileButtonActions\"\n ></s-button>\n <ng-container *ngIf=\"!isMobile\">\n <s-button priority=\"secondary\" [label]=\"translate.instant('platform.filter_service.clear')\" (click)=\"clearFilters()\"></s-button>\n <s-button priority=\"secondary\" [label]=\"translate.instant('platform.filter_service.save')\" (click)=\"saveFilters()\"></s-button>\n </ng-container>\n <s-button\n type=\"submit\"\n priority=\"primary\"\n [label]=\"translate.instant('platform.filter_service.filter')\"\n (click)=\"onApplyFilters()\"\n ></s-button>\n </div>\n </div>\n</section>\n\n<p-dialog\n *ngIf=\"!onlyContent\"\n appendTo=\"body\"\n styleClass=\"filter-dialog\"\n [draggable]=\"false\"\n [modal]=\"true\"\n [responsive]=\"true\"\n [(visible)]=\"showDialog\"\n blockScroll=\"true\"\n [closable]=\"false\"\n>\n <p-header>\n <div style=\"display: flex;\">\n {{ 'platform.filter_service.filters' | translate }}\n <span (click)=\"toggleDialog(); close()\" class=\"close_btn pi pi-times\"></span>\n </div>\n </p-header>\n\n <s-app-form-filter\n [showMessages]=\"true\"\n (errorOutput)=\"onError($event)\"\n (totalFiltersActiveOutput)=\"updateTotalFiltersActive($event)\"\n [isModal]=\"true\"\n ></s-app-form-filter>\n <p-footer *ngIf=\"!error && !hideButtons\">\n <s-button\n type=\"submit\"\n priority=\"primary\"\n [label]=\"translate.instant('platform.filter_service.filter')\"\n (click)=\"applyFilters()\"\n ></s-button>\n <ng-container *ngIf=\"!isMobile\">\n <s-button priority=\"secondary\" [label]=\"translate.instant('platform.filter_service.save')\" (click)=\"saveFilters()\"></s-button>\n <s-button priority=\"secondary\" [label]=\"translate.instant('platform.filter_service.clear')\" (click)=\"clearFilters()\"></s-button>\n </ng-container>\n <s-button\n *ngIf=\"isMobile\"\n priority=\"default\"\n [label]=\"translate.instant('platform.filter_service.actions')\"\n [auxiliary]=\"true\"\n [model]=\"mobileButtonActions\"\n ></s-button>\n <s-button priority=\"link\" [label]=\"translate.instant('platform.filter_service.cancel')\" (click)=\"toggleDialog(); close()\"></s-button>\n </p-footer>\n</p-dialog>\n\n<p-toast key=\"filterServiceToastKey\" [baseZIndex]=\"5000\"></p-toast>\n",
1816
+ template: "<s-button\n *ngIf=\"!onlyContent\"\n [id]=\"'filterButton'\"\n [disabled]=\"!canOpenFilter\"\n (click)=\"canOpenFilter ? toggleDialog() : ''\"\n iconClass=\"fa fa-filter\"\n priority=\"default\"\n [label]=\"labelButton\"\n [auxiliary]=\"true\"\n [tooltip]=\"appliedFiltersTooltip\"\n>\n <span\n *ngIf=\"totalFiltersActive && showActiveFiltersCountBadge\"\n class=\"sds-badge-number sds-color-primary custom-badge\"\n >{{ totalFiltersActive }}</span\n >\n</s-button>\n\n<section *ngIf=\"onlyContent\">\n <div class=\"only-content-wrapper\">\n <div class=\"header\">\n <h3>{{ 'platform.filter_service.filters' | translate }}</h3>\n <span (click)=\"close()\" class=\"close_btn pi pi-times\"></span>\n </div>\n <div class=\"app-form-filter\">\n <s-app-form-filter\n [showMessages]=\"false\"\n (totalFiltersActiveOutput)=\"updateTotalFiltersActive($event)\"\n (closeModalOutput)=\"close()\"\n [isModal]=\"false\"\n [contextId]=\"contextId\"\n ></s-app-form-filter>\n </div>\n <div class=\"filter-footer\" *ngIf=\"!error\">\n <s-button\n priority=\"link\"\n [label]=\"translate.instant('platform.filter_service.cancel')\"\n (click)=\"close()\"\n ></s-button>\n <s-button\n *ngIf=\"isMobile\"\n priority=\"default\"\n [label]=\"translate.instant('platform.filter_service.actions')\"\n [auxiliary]=\"true\"\n [model]=\"mobileButtonActions\"\n ></s-button>\n <ng-container *ngIf=\"!isMobile\">\n <s-button\n priority=\"secondary\"\n [label]=\"translate.instant('platform.filter_service.clear')\"\n (click)=\"clearFilters()\"\n ></s-button>\n <s-button\n priority=\"secondary\"\n [label]=\"translate.instant('platform.filter_service.save')\"\n (click)=\"saveFilters()\"\n ></s-button>\n </ng-container>\n <s-button\n type=\"submit\"\n priority=\"primary\"\n [label]=\"translate.instant('platform.filter_service.filter')\"\n (click)=\"onApplyFilters()\"\n ></s-button>\n </div>\n </div>\n</section>\n\n<p-dialog\n *ngIf=\"!onlyContent\"\n appendTo=\"body\"\n styleClass=\"filter-dialog\"\n [draggable]=\"false\"\n [modal]=\"true\"\n [responsive]=\"true\"\n [(visible)]=\"showDialog\"\n blockScroll=\"true\"\n [closable]=\"false\"\n>\n <p-header>\n <div style=\"display: flex\">\n {{ 'platform.filter_service.filters' | translate }}\n <span (click)=\"toggleDialog(); close()\" class=\"close_btn pi pi-times\"></span>\n </div>\n </p-header>\n\n <s-app-form-filter\n [showMessages]=\"true\"\n (errorOutput)=\"onError($event)\"\n (totalFiltersActiveOutput)=\"updateTotalFiltersActive($event)\"\n [isModal]=\"true\"\n [contextId]=\"contextId\"\n ></s-app-form-filter>\n <p-footer *ngIf=\"!error && !hideButtons\">\n <s-button\n type=\"submit\"\n priority=\"primary\"\n [label]=\"translate.instant('platform.filter_service.filter')\"\n (click)=\"applyFilters()\"\n ></s-button>\n <ng-container *ngIf=\"!isMobile\">\n <s-button\n priority=\"secondary\"\n [label]=\"translate.instant('platform.filter_service.save')\"\n (click)=\"saveFilters()\"\n ></s-button>\n <s-button\n priority=\"secondary\"\n [label]=\"translate.instant('platform.filter_service.clear')\"\n (click)=\"clearFilters()\"\n ></s-button>\n </ng-container>\n <s-button\n *ngIf=\"isMobile\"\n priority=\"default\"\n [label]=\"translate.instant('platform.filter_service.actions')\"\n [auxiliary]=\"true\"\n [model]=\"mobileButtonActions\"\n ></s-button>\n <s-button\n priority=\"link\"\n [label]=\"translate.instant('platform.filter_service.cancel')\"\n (click)=\"toggleDialog(); close()\"\n ></s-button>\n </p-footer>\n</p-dialog>\n\n<p-toast key=\"filterServiceToastKey\" [baseZIndex]=\"5000\"></p-toast>\n",
1788
1817
  encapsulation: core.ViewEncapsulation.None,
1789
1818
  styles: [".custom-badge{position:absolute!important;right:-4px;top:-10px;height:20px;vertical-align:middle;display:table;min-width:22px}.filter-button{position:relative;border:1px solid #000;border-radius:1.5rem;background:0 0;padding:.5rem 1rem;cursor:pointer}.filter-dialog .ui-dialog-title{display:block!important;padding-right:0!important}.filter-footer{text-align:end;border-top:1px solid #e5eaea;padding:13px}.filter-dialog>.ui-dialog-content{height:300px;padding:10px!important}.app-form-filter{height:335px;max-height:335px;overflow:auto}.only-content-wrapper{background-color:#fff}.close_btn{-ms-flex-line-pack:center;align-content:center;-ms-grid-column-align:right;justify-self:right;margin-left:auto}.close_btn:hover{cursor:pointer}.header{text-transform:uppercase;display:-ms-flexbox;display:flex;width:100%;border-bottom:1px solid #e5eaea;padding:15px;margin-left:0}@media (min-width:641px) and (max-width:1024px){.filter-dialog{width:75%}.filter-dialog>.ui-dialog-content{height:300px}}@media only screen and (min-device-width:481px) and (max-device-width:1024px) and (orientation:portrait){.filter-dialog{width:75%}.filter-dialog>.ui-dialog-content{height:90%}}@media (min-width:320px) and (max-width:640px){.filter-dialog{width:95%;left:0;top:0;opacity:1;margin:auto;height:93%}.filter-dialog>.ui-dialog-content{height:85%}}@media (min-width:320px) and (max-width:640px) and (max-width:360px){.filter-dialog button{padding:0!important}.filter-dialog>.ui-dialog-content{height:81%}}"]
1790
1819
  })