@churchillliving/se-ui-toolkit 6.53.477 → 6.53.478

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.
@@ -3542,7 +3542,7 @@
3542
3542
  row[fieldNameObj] = Object.assign(Object.assign({}, row[fieldNameObj]), (_g = { text: row[fieldName] }, _g[prop.propName] = prop.propValue, _g));
3543
3543
  }
3544
3544
  else {
3545
- row[fieldNameObj] = Object.assign(Object.assign({}, row[fieldName]), (_h = { text: row[fieldName] }, _h[prop.propName] = prop.propValue, _h));
3545
+ row[fieldNameObj] = (_h = { text: row[fieldName] }, _h[prop.propName] = prop.propValue, _h);
3546
3546
  }
3547
3547
  }
3548
3548
  else if (columns === null || columns === void 0 ? void 0 : columns.some(function (column) { var _a, _b; return ((_a = column.field) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === ((_b = prop === null || prop === void 0 ? void 0 : prop.field) === null || _b === void 0 ? void 0 : _b.toLowerCase()); })) {
@@ -3552,7 +3552,7 @@
3552
3552
  row[propFieldObj] = Object.assign(Object.assign({}, row[propFieldObj]), (_j = { text: row[prop.field] }, _j[prop.propName] = prop.propValue, _j));
3553
3553
  }
3554
3554
  else {
3555
- row[propFieldObj] = Object.assign(Object.assign({}, row[propField]), (_k = { text: row[prop.field] }, _k[prop.propName] = prop.propValue, _k));
3555
+ row[propFieldObj] = (_k = { text: row[prop.field] }, _k[prop.propName] = prop.propValue, _k);
3556
3556
  }
3557
3557
  }
3558
3558
  ;
@@ -5783,6 +5783,7 @@
5783
5783
  };
5784
5784
  // Check calender value is changed or not
5785
5785
  GridComponent.prototype.calenderChangeEvent = function (column, row) {
5786
+ var _this = this;
5786
5787
  var valueChange = false;
5787
5788
  if (column.timeOnly &&
5788
5789
  this.datePipe.transform(row[column.field], 'hh:mm') !==
@@ -5801,7 +5802,9 @@
5801
5802
  if (valueChange) {
5802
5803
  this.browserCloseEvent(true);
5803
5804
  this.generateRowsDataCopy = false;
5804
- this.rowsChange.emit(this.rowsData);
5805
+ setTimeout(function () {
5806
+ _this.rowsChange.emit(_this.rowsData);
5807
+ }, 250);
5805
5808
  if (column.onChange) {
5806
5809
  column.onChange(row);
5807
5810
  }
@@ -5957,30 +5960,29 @@
5957
5960
  };
5958
5961
  // Invoke onClick Event.
5959
5962
  GridComponent.prototype.onClickEvent = function (column, row) {
5960
- var _a, _b, _c, _d;
5961
- if (column.type === exports.EGridColumnType.LINK && (column.editLink === false || column.editLink === undefined) && column.editable !== true && column.disabled !== true) {
5962
- if (column && column.onClick && column.disabled !== true && ((_b = (_a = row[column.field + '_obj']) === null || _a === void 0 ? void 0 : _a.action) === null || _b === void 0 ? void 0 : _b.disabled) !== true) {
5963
- column.onClick(row);
5964
- }
5965
- else {
5966
- var a = document.createElement('a');
5967
- a.href = (_c = row[column.field + '_obj']) === null || _c === void 0 ? void 0 : _c.hyperlink;
5968
- a.target = column.target ? column.target : '_blank',
5969
- a.click();
5970
- }
5971
- }
5972
- if (column.type === exports.EGridColumnType.DATE && row[column.field]) {
5973
- this.calenderPreviousValue = row[column.field];
5974
- }
5975
- else if (!row[column.field] &&
5976
- column.type === exports.EGridColumnType.DATE &&
5977
- (column.showTime || column.timeOnly) &&
5978
- column.minutesInterval) {
5979
- this.defaultDate = new Date(setMinutesInterval(new Date()));
5980
- }
5981
- if (column && column.onClick && column.disabled !== true && ((_d = row[column.field + '_obj']) === null || _d === void 0 ? void 0 : _d.disabled) !== true) {
5982
- column.onClick(row);
5983
- }
5963
+ // if (column.type === EGridColumnType.LINK && (column.editLink === false || column.editLink === undefined) && column.editable !== true && column.disabled !== true) {
5964
+ // if (column && column.onClick && column.disabled !== true && row[column.field + '_obj']?.action?.disabled !== true) {
5965
+ // column.onClick(row);
5966
+ // } else {
5967
+ // let a = document.createElement('a');
5968
+ // a.href = row[column.field + '_obj']?.hyperlink;
5969
+ // a.target = column.target ? column.target : '_blank',
5970
+ // a.click();
5971
+ // }
5972
+ // }
5973
+ // if (column.type === EGridColumnType.DATE && row[column.field]) {
5974
+ // this.calenderPreviousValue = row[column.field];
5975
+ // } else if (
5976
+ // !row[column.field] &&
5977
+ // column.type === EGridColumnType.DATE &&
5978
+ // (column.showTime || column.timeOnly) &&
5979
+ // column.minutesInterval
5980
+ // ) {
5981
+ // this.defaultDate = new Date(utilities.setMinutesInterval(new Date()));
5982
+ // }
5983
+ // if (column && column.onClick && column.disabled !== true && row[column.field + '_obj']?.disabled !== true) {
5984
+ // column.onClick(row);
5985
+ // }
5984
5986
  };
5985
5987
  // set the select value of multi-select
5986
5988
  GridComponent.prototype.showOption = function (column, row) {
@@ -8375,7 +8377,6 @@
8375
8377
  ESidebarAction["NAVIGATION"] = "navigation";
8376
8378
  ESidebarAction["OPENDIALOG"] = "dialog";
8377
8379
  ESidebarAction["IFRAME"] = "_iframe";
8378
- ESidebarAction["REPORT"] = "report";
8379
8380
  })(exports.ESidebarAction || (exports.ESidebarAction = {}));
8380
8381
 
8381
8382
  var SideBarService = /** @class */ (function () {
@@ -8467,493 +8468,189 @@
8467
8468
  { type: i0.ApplicationRef }
8468
8469
  ]; };
8469
8470
 
8470
- var ReportFilterComponent = /** @class */ (function () {
8471
- function ReportFilterComponent(config, requestService, formService, alertService) {
8472
- this.config = config;
8473
- this.requestService = requestService;
8474
- this.formService = formService;
8475
- this.alertService = alertService;
8476
- this.formFields = [];
8471
+ var SidebarComponent = /** @class */ (function () {
8472
+ function SidebarComponent(instance, authService, dialogService, router, pageLoggerService, hyperlinkService, sidebarService) {
8473
+ this.instance = instance;
8474
+ this.authService = authService;
8475
+ this.dialogService = dialogService;
8476
+ this.router = router;
8477
+ this.pageLoggerService = pageLoggerService;
8478
+ this.hyperlinkService = hyperlinkService;
8479
+ this.sidebarService = sidebarService;
8480
+ this.toggleMenu = false;
8481
+ this.loadComponentName = '';
8482
+ this.openDialogs = [];
8483
+ this.navHidden = false;
8484
+ this.collapseSidebar = false;
8485
+ this.sidebarItemsList = [];
8486
+ this.menuItems = [];
8487
+ this.roles = [];
8488
+ this.isSidebarHidden = false;
8477
8489
  }
8478
- ReportFilterComponent.prototype.ngOnInit = function () {
8479
- this.createDynamicFields();
8480
- };
8481
- ReportFilterComponent.prototype.initializeForm = function () {
8482
- var _this = this;
8490
+ Object.defineProperty(SidebarComponent.prototype, "sidebarItems", {
8491
+ set: function (newSidebarItems) {
8492
+ if (newSidebarItems) {
8493
+ this.sidebarItemsList = newSidebarItems;
8494
+ this.initializeSideBar();
8495
+ }
8496
+ },
8497
+ enumerable: false,
8498
+ configurable: true
8499
+ });
8500
+ SidebarComponent.prototype.ngOnInit = function () {
8483
8501
  var _a, _b;
8484
- this.dynamicForm = {
8485
- formSections: [
8486
- {
8487
- fields: __spreadArray(__spreadArray([], __read(this.formFields)), [
8488
- {
8489
- label: 'Download Report',
8490
- control: exports.EFormControl.ADD_BUTTON,
8491
- hidden: (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.hideGenerateReportBtn,
8492
- onClick: function () {
8493
- _this.downloadReport();
8494
- },
8495
- }
8496
- ])
8497
- }
8498
- ]
8499
- };
8502
+ if ((_a = this.router.url.toString()) === null || _a === void 0 ? void 0 : _a.includes('component=')) {
8503
+ var componentName = (_b = this.router.url) === null || _b === void 0 ? void 0 : _b.split('component=')[1];
8504
+ if (componentName) {
8505
+ this.loadComponentName = componentName;
8506
+ }
8507
+ }
8508
+ if (this.loadComponentName) {
8509
+ this.openDynamicComponetonLoad();
8510
+ }
8500
8511
  };
8501
- ReportFilterComponent.prototype.createDynamicFields = function () {
8512
+ SidebarComponent.prototype.openDynamicComponetonLoad = function () {
8502
8513
  var _this = this;
8503
8514
  var _a;
8504
- this.requestService.getOne('/ReportConfig/ById', (_a = this.config.data) === null || _a === void 0 ? void 0 : _a.Id).subscribe(function (data) {
8505
- var reportJson = JSON.parse(data === null || data === void 0 ? void 0 : data.report);
8506
- _this.formFields = reportJson === null || reportJson === void 0 ? void 0 : reportJson.FormFields;
8507
- _this.setParamFieldValue();
8508
- _this.initializeForm();
8509
- // set dropdown data based on matched field.
8510
- _this.setDropDownData(reportJson);
8511
- }, function (error) {
8512
- _this.initializeForm();
8513
- _this.alertService.error(error);
8515
+ (_a = this.sidebarItemsList) === null || _a === void 0 ? void 0 : _a.forEach(function (item) {
8516
+ if (item.action === exports.ESidebarAction.OPENDIALOG && exports.ESidebarTarget.BLANK && item.component.name === _this.loadComponentName) {
8517
+ _this.navigateComponentToNewTab(item, false);
8518
+ }
8514
8519
  });
8515
8520
  };
8516
- ReportFilterComponent.prototype.setParamFieldValue = function () {
8521
+ SidebarComponent.prototype.initializeSideBar = function () {
8517
8522
  var _this = this;
8518
- var _a;
8519
- if (this.config.data && ((_a = this.config.data.param) === null || _a === void 0 ? void 0 : _a.length) > 0) {
8520
- this.config.data.param.forEach(function (param) {
8521
- _this.formFields.forEach(function (field) {
8522
- var _a;
8523
- var matchKey = (_a = Object.keys(param)) === null || _a === void 0 ? void 0 : _a.find(function (key) { var _a; return (key === null || key === void 0 ? void 0 : key.toLowerCase()) === ((_a = field.field) === null || _a === void 0 ? void 0 : _a.toLowerCase()); });
8524
- if (matchKey && matchKey.length > 0) {
8525
- field.value = param[matchKey];
8523
+ this.roles = this.authService.getUserRoles();
8524
+ // apply user role permissions
8525
+ this.applyUserPermissions();
8526
+ this.menuItems = this.sidebarItemsList.map(function (x) { return ({
8527
+ label: x.label,
8528
+ icon: x.icon,
8529
+ id: x.id,
8530
+ section: x.section,
8531
+ expanded: x.expanded,
8532
+ action: x.action,
8533
+ items: x.items && x.items.length > 0 ? _this.setMenuItems(x) : [],
8534
+ title: _this.setMenuTitle(x),
8535
+ command: function (_e) {
8536
+ var item = _e.item;
8537
+ if (x.action && x.action === exports.ESidebarAction.NAVIGATION) {
8538
+ _this.navigateToSection(x, item);
8539
+ }
8540
+ else if (x.action && x.action === exports.ESidebarAction.OPENDIALOG) {
8541
+ if (x.target && x.target === exports.ESidebarTarget.BLANK) {
8542
+ _this.navigateComponentToNewTab(x);
8526
8543
  }
8527
- });
8528
- });
8529
- }
8544
+ else {
8545
+ _this.openDialog(x, item);
8546
+ }
8547
+ }
8548
+ else if (x.action && x.action === exports.ESidebarAction.IFRAME) {
8549
+ _this.loadIFrame(x, item);
8550
+ }
8551
+ else {
8552
+ _this.handleActiveItem(item);
8553
+ }
8554
+ },
8555
+ style: {
8556
+ borderBottom: '',
8557
+ display: x.hidden ? 'none' : '',
8558
+ },
8559
+ onClick: x.onClick,
8560
+ onReturn: x.onReturn,
8561
+ disabled: x.disabled,
8562
+ }); });
8530
8563
  };
8531
- ReportFilterComponent.prototype.setDropDownData = function (reportJson) {
8564
+ //ref link: https://medium.com/@saranya.thangaraj/open-angular-component-in-a-new-tab-without-bootstrapping-the-whole-app-again-e329af460e92
8565
+ SidebarComponent.prototype.navigateComponentToNewTab = function (menu, onNewTab) {
8532
8566
  var _this = this;
8533
- var _a;
8534
- (_a = reportJson.Parameters) === null || _a === void 0 ? void 0 : _a.forEach(function (record) {
8535
- if (record.isuniquekey) {
8536
- _this.requestService.get('/Data/Fetch', {
8537
- uniqueKey: record.isuniquekey,
8538
- filters: []
8539
- }).subscribe(function (response) {
8540
- _this.formService.setFormFieldProp(_this.dynamicForm, record.paramname, [
8541
- { name: 'data', value: response.records },
8542
- ]);
8543
- }, function (error) {
8544
- _this.alertService.apiError(error);
8545
- });
8567
+ if (onNewTab === void 0) { onNewTab = true; }
8568
+ var _a, _b;
8569
+ var windowRef = window;
8570
+ var winRef;
8571
+ if (onNewTab) {
8572
+ winRef = window.open();
8573
+ if (winRef.location.href === 'about:blank') {
8574
+ if (this.router.url && ((_b = (_a = this.router.url) === null || _a === void 0 ? void 0 : _a.toString()) === null || _b === void 0 ? void 0 : _b.includes('?'))) {
8575
+ winRef.location.href = this.router.url + '&&component=' + menu.component.name;
8576
+ }
8577
+ else {
8578
+ winRef.location.href = this.router.url + "?component=" + menu.component.name;
8579
+ }
8546
8580
  }
8547
- });
8581
+ }
8582
+ // Wait for window instance to be created
8583
+ if (onNewTab) {
8584
+ setTimeout(function () {
8585
+ _this.sidebarService.createWindowInstance(menu, winRef);
8586
+ }, 900);
8587
+ }
8588
+ else {
8589
+ this.sidebarService.createWindowInstance(menu, windowRef);
8590
+ }
8548
8591
  };
8549
- ReportFilterComponent.prototype.getFilters = function () {
8550
- var _a, _b;
8551
- var filters = [];
8552
- (_b = (_a = this.dynamicForm) === null || _a === void 0 ? void 0 : _a.formSections) === null || _b === void 0 ? void 0 : _b.forEach(function (section) {
8553
- var _a;
8554
- (_a = section.fields) === null || _a === void 0 ? void 0 : _a.forEach(function (field) {
8555
- if (field && field.value) {
8556
- filters.push({ field: field.field, matchMode: 'equal', operator: 'and', value: field.value });
8592
+ SidebarComponent.prototype.setMenuTitle = function (x) {
8593
+ return x.tooltip ? x.tooltip : !x.label ? x.section : '';
8594
+ };
8595
+ SidebarComponent.prototype.setMenuItems = function (x) {
8596
+ var _this = this;
8597
+ return x.items.map(function (menu) { return ({
8598
+ label: menu.label,
8599
+ icon: menu.icon,
8600
+ id: menu.id,
8601
+ section: menu.section,
8602
+ expanded: menu.expanded,
8603
+ action: menu.action,
8604
+ title: _this.setMenuTitle(x),
8605
+ command: function (_e) {
8606
+ var item = _e.item;
8607
+ if (x.action && x.action === exports.ESidebarAction.NAVIGATION) {
8608
+ _this.navigateToSection(menu, item);
8557
8609
  }
8558
- ;
8610
+ else if (menu.action && menu.action === exports.ESidebarAction.OPENDIALOG) {
8611
+ _this.openDialog(menu, item);
8612
+ }
8613
+ else if (menu.action && menu.action === exports.ESidebarAction.IFRAME) {
8614
+ _this.loadIFrame(menu, x);
8615
+ }
8616
+ _this.handleActiveItem(item);
8617
+ },
8618
+ style: {
8619
+ borderBottom: '',
8620
+ display: menu.hidden ? 'none' : '',
8621
+ },
8622
+ onClick: menu.onClick,
8623
+ onReturn: menu.onReturn,
8624
+ disabled: menu.disabled,
8625
+ }); });
8626
+ };
8627
+ SidebarComponent.prototype.loadIFrame = function (menu, item) {
8628
+ var _this = this;
8629
+ var _a, _b, _c, _d;
8630
+ if (menu) {
8631
+ var dialogRef = this.dialogService.open(IframeComponent, {
8632
+ header: menu.section,
8633
+ width: ((_a = menu.iFrame) === null || _a === void 0 ? void 0 : _a.width) ? menu.iFrame.width : '90%',
8634
+ height: ((_b = menu.iFrame) === null || _b === void 0 ? void 0 : _b.height) ? menu.iFrame.height : '80%',
8635
+ data: { value: (_c = menu.iFrame) === null || _c === void 0 ? void 0 : _c.link, iFrameId: menu.section },
8559
8636
  });
8560
- });
8561
- return filters;
8637
+ this.pageLoggerService.savePageLoggerInfo((_d = this.router.url) === null || _d === void 0 ? void 0 : _d.substring(1), 'IframeComponent');
8638
+ this.handleActiveItem(item);
8639
+ draggableDialog(menu.label);
8640
+ dialogRef.onClose.subscribe(function (data) {
8641
+ _this.handleActiveItem(item, false);
8642
+ if (data && menu.onReturn) {
8643
+ menu.onReturn(data);
8644
+ }
8645
+ });
8646
+ }
8562
8647
  };
8563
- ReportFilterComponent.prototype.downloadReport = function () {
8564
- var _this = this;
8565
- var _a, _b;
8566
- var filters = this.getFilters();
8567
- this.requestService.download('/Report/Generate', { Id: (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.Id, filters: filters })
8568
- .subscribe(function (response) {
8569
- var _a, _b, _c, _d;
8570
- var newBlob = new Blob([response.body], { type: 'application/pdf' });
8571
- var data = window.URL.createObjectURL(newBlob);
8572
- var a = document.createElement('a');
8573
- a.href = data;
8574
- var header = (_a = response === null || response === void 0 ? void 0 : response.headers) === null || _a === void 0 ? void 0 : _a.get('Content-Disposition');
8575
- var fileName = (_d = (_c = (_b = header === null || header === void 0 ? void 0 : header.split('filename=')) === null || _b === void 0 ? void 0 : _b[1]) === null || _c === void 0 ? void 0 : _c.split(";")[0]) === null || _d === void 0 ? void 0 : _d.replaceAll(/\"/g, '');
8576
- a.download = fileName;
8577
- document.body.appendChild(a);
8578
- a.click();
8579
- document.body.removeChild(a);
8580
- }, function (error) {
8581
- _this.alertService.apiError(error);
8582
- });
8583
- };
8584
- return ReportFilterComponent;
8585
- }());
8586
- ReportFilterComponent.decorators = [
8587
- { type: i0.Component, args: [{
8588
- selector: 'se-report-filter',
8589
- template: "<se-form \n*ngIf=\"dynamicForm\"\n[form]=\"dynamicForm\"\n[hideSaveButton]=\"true\"\n[hideCancelButton]=\"true\"\n>\n</se-form>\n",
8590
- styles: [""]
8591
- },] }
8592
- ];
8593
- /** @nocollapse */
8594
- ReportFilterComponent.ctorParameters = function () { return [
8595
- { type: i1.DynamicDialogConfig, decorators: [{ type: i0.Optional }] },
8596
- { type: RequestService },
8597
- { type: FormService },
8598
- { type: AlertService }
8599
- ]; };
8600
-
8601
- var ReportService = /** @class */ (function () {
8602
- function ReportService(dialogService, requestService, alertService) {
8603
- this.dialogService = dialogService;
8604
- this.requestService = requestService;
8605
- this.alertService = alertService;
8606
- this.formFields = [];
8607
- this.paramsCopy = [];
8608
- }
8609
- ReportService.prototype.downloadReport = function (repId, params, showDialog, form) {
8610
- var _this = this;
8611
- if (showDialog === void 0) { showDialog = false; }
8612
- if (form === void 0) { form = {}; }
8613
- params === null || params === void 0 ? void 0 : params.forEach(function (p) {
8614
- _this.paramsCopy.push(Object.assign({}, p));
8615
- });
8616
- this.createDynamicFields(repId, params, showDialog, form);
8617
- };
8618
- ReportService.prototype.createDynamicFields = function (repId, params, showDialog, form) {
8619
- var _this = this;
8620
- this.requestService
8621
- .getOne('/ReportConfig/ById', repId)
8622
- .subscribe(function (data) {
8623
- if (data) {
8624
- var reportJson = JSON.parse(data === null || data === void 0 ? void 0 : data.report);
8625
- _this.formFields = reportJson === null || reportJson === void 0 ? void 0 : reportJson.FormFields;
8626
- }
8627
- _this.generateReport(repId, params, showDialog, form);
8628
- }, function (error) {
8629
- _this.alertService.error(error);
8630
- });
8631
- };
8632
- ReportService.prototype.generateReport = function (repId, params, showDialog, form) {
8633
- if (showDialog === void 0) { showDialog = false; }
8634
- if (form === void 0) { form = {}; }
8635
- this.getFormFieldValues(form, params);
8636
- if ((this.formFields.some(function (field) { return !field.hidden; }) &&
8637
- showDialog === undefined) ||
8638
- showDialog === true) {
8639
- this.dialogService.open(ReportFilterComponent, {
8640
- width: '80%',
8641
- height: '100%',
8642
- header: 'Generate Report',
8643
- style: { background: '#fff' },
8644
- data: { Id: repId, param: params },
8645
- });
8646
- }
8647
- else {
8648
- this.downloadQuickReport(params, repId);
8649
- }
8650
- };
8651
- ReportService.prototype.getFormFieldValues = function (form, params) {
8652
- var _a;
8653
- if (((_a = this.paramsCopy) === null || _a === void 0 ? void 0 : _a.length) > 0) {
8654
- this.paramsCopy.forEach(function (paramCopy) {
8655
- var _a, _b;
8656
- var key = Object.keys(paramCopy)[0];
8657
- if (paramCopy[key] === '' || !paramCopy[key]) {
8658
- (_a = form === null || form === void 0 ? void 0 : form.formSections) === null || _a === void 0 ? void 0 : _a.forEach(function (section) {
8659
- section.fields.forEach(function (field) {
8660
- var _a;
8661
- if (key.toString().toLowerCase() === ((_a = field.field) === null || _a === void 0 ? void 0 : _a.toLowerCase())) {
8662
- params.forEach(function (origParam) {
8663
- var origKey = Object.keys(origParam)[0];
8664
- if (origKey == key) {
8665
- //origParam[origKey] = field.value;
8666
- if (field.control == exports.EFormControl.CALENDAR) {
8667
- origParam[origKey] = field.value ? field.value.toLocaleDateString() : null;
8668
- }
8669
- else {
8670
- origParam[origKey] = field.value;
8671
- }
8672
- }
8673
- });
8674
- }
8675
- });
8676
- });
8677
- }
8678
- else if (paramCopy[key].toString().includes('{') &&
8679
- paramCopy[key].toString().includes('}')) {
8680
- var newValue = paramCopy[key].replace('{', '').replace('}', '');
8681
- (_b = form === null || form === void 0 ? void 0 : form.formSections) === null || _b === void 0 ? void 0 : _b.forEach(function (section) {
8682
- section.fields.forEach(function (field) {
8683
- var _a;
8684
- if (newValue.toString().toLowerCase() === ((_a = field.field) === null || _a === void 0 ? void 0 : _a.toLowerCase())) {
8685
- params.forEach(function (origParam) {
8686
- var origKey = Object.keys(origParam)[0];
8687
- if (origKey == key) {
8688
- if (field.control == exports.EFormControl.CALENDAR) {
8689
- origParam[origKey] = field.value ? field.value.toLocaleDateString() : null;
8690
- }
8691
- else {
8692
- origParam[origKey] = field.value;
8693
- }
8694
- }
8695
- });
8696
- }
8697
- });
8698
- });
8699
- }
8700
- });
8701
- }
8702
- };
8703
- ReportService.prototype.downloadQuickReport = function (params, repId) {
8704
- var _this = this;
8705
- var filters = [];
8706
- if (params && params.length > 0) {
8707
- params.forEach(function (param) {
8708
- Object.keys(param).map(function (key) { return filters.push({
8709
- field: key,
8710
- matchMode: 'equal',
8711
- operator: 'and',
8712
- value: param[key],
8713
- }); });
8714
- });
8715
- }
8716
- else {
8717
- filters = this.getFilters();
8718
- }
8719
- this.requestService
8720
- .download('/Report/Generate', { Id: repId, filters: filters })
8721
- .subscribe(function (response) {
8722
- var _a, _b, _c, _d;
8723
- var newBlob = new Blob([response.body], { type: 'application/pdf' });
8724
- var data = window.URL.createObjectURL(newBlob);
8725
- var a = document.createElement('a');
8726
- a.href = data;
8727
- var header = (_a = response === null || response === void 0 ? void 0 : response.headers) === null || _a === void 0 ? void 0 : _a.get('Content-Disposition');
8728
- var fileName = (_d = (_c = (_b = header === null || header === void 0 ? void 0 : header.split('filename=')) === null || _b === void 0 ? void 0 : _b[1]) === null || _c === void 0 ? void 0 : _c.split(';')[0]) === null || _d === void 0 ? void 0 : _d.replaceAll(/\"/g, '');
8729
- a.download = fileName;
8730
- document.body.appendChild(a);
8731
- a.click();
8732
- document.body.removeChild(a);
8733
- }, function (error) {
8734
- _this.alertService.apiError(error);
8735
- });
8736
- };
8737
- ReportService.prototype.getFilters = function () {
8738
- var filters = [];
8739
- this.formFields.forEach(function (field) {
8740
- var _a, _b;
8741
- if (field && ((_b = (_a = field.value) === null || _a === void 0 ? void 0 : _a.toString()) === null || _b === void 0 ? void 0 : _b.length) > 0) {
8742
- filters.push({
8743
- field: field.field,
8744
- matchMode: 'equal',
8745
- operator: 'and',
8746
- value: field.value,
8747
- });
8748
- }
8749
- });
8750
- return filters;
8751
- };
8752
- return ReportService;
8753
- }());
8754
- /** @nocollapse */ ReportService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function ReportService_Factory() { return new ReportService(i0__namespace.ɵɵinject(i1__namespace$2.DialogService), i0__namespace.ɵɵinject(RequestService), i0__namespace.ɵɵinject(AlertService)); }, token: ReportService, providedIn: "root" });
8755
- ReportService.decorators = [
8756
- { type: i0.Injectable, args: [{
8757
- providedIn: 'root'
8758
- },] }
8759
- ];
8760
- /** @nocollapse */
8761
- ReportService.ctorParameters = function () { return [
8762
- { type: i1.DialogService },
8763
- { type: RequestService },
8764
- { type: AlertService }
8765
- ]; };
8766
-
8767
- var SidebarComponent = /** @class */ (function () {
8768
- function SidebarComponent(instance, authService, dialogService, reportService, router, pageLoggerService, hyperlinkService, sidebarService) {
8769
- this.instance = instance;
8770
- this.authService = authService;
8771
- this.dialogService = dialogService;
8772
- this.reportService = reportService;
8773
- this.router = router;
8774
- this.pageLoggerService = pageLoggerService;
8775
- this.hyperlinkService = hyperlinkService;
8776
- this.sidebarService = sidebarService;
8777
- this.toggleMenu = false;
8778
- this.loadComponentName = '';
8779
- this.openDialogs = [];
8780
- this.navHidden = false;
8781
- this.collapseSidebar = false;
8782
- this.sidebarItemsList = [];
8783
- this.menuItems = [];
8784
- this.roles = [];
8785
- this.isSidebarHidden = false;
8786
- }
8787
- Object.defineProperty(SidebarComponent.prototype, "sidebarItems", {
8788
- set: function (newSidebarItems) {
8789
- if (newSidebarItems) {
8790
- this.sidebarItemsList = newSidebarItems;
8791
- this.initializeSideBar();
8792
- }
8793
- },
8794
- enumerable: false,
8795
- configurable: true
8796
- });
8797
- SidebarComponent.prototype.ngOnInit = function () {
8798
- var _a, _b;
8799
- if ((_a = this.router.url.toString()) === null || _a === void 0 ? void 0 : _a.includes('component=')) {
8800
- var componentName = (_b = this.router.url) === null || _b === void 0 ? void 0 : _b.split('component=')[1];
8801
- if (componentName) {
8802
- this.loadComponentName = componentName;
8803
- }
8804
- }
8805
- if (this.loadComponentName) {
8806
- this.openDynamicComponetonLoad();
8807
- }
8808
- };
8809
- SidebarComponent.prototype.openDynamicComponetonLoad = function () {
8810
- var _this = this;
8811
- var _a;
8812
- (_a = this.sidebarItemsList) === null || _a === void 0 ? void 0 : _a.forEach(function (item) {
8813
- if (item.action === exports.ESidebarAction.OPENDIALOG && exports.ESidebarTarget.BLANK && item.component.name === _this.loadComponentName) {
8814
- _this.navigateComponentToNewTab(item, false);
8815
- }
8816
- });
8817
- };
8818
- SidebarComponent.prototype.initializeSideBar = function () {
8819
- var _this = this;
8820
- this.roles = this.authService.getUserRoles();
8821
- // apply user role permissions
8822
- this.applyUserPermissions();
8823
- this.menuItems = this.sidebarItemsList.map(function (x) { return ({
8824
- label: x.label,
8825
- icon: x.icon,
8826
- id: x.id,
8827
- section: x.section,
8828
- expanded: x.expanded,
8829
- action: x.action,
8830
- items: x.items && x.items.length > 0 ? _this.setMenuItems(x) : [],
8831
- title: _this.setMenuTitle(x),
8832
- command: function (_e) {
8833
- var item = _e.item;
8834
- if (x.action && x.action === exports.ESidebarAction.NAVIGATION) {
8835
- _this.navigateToSection(x, item);
8836
- }
8837
- else if (x.action && x.action === exports.ESidebarAction.OPENDIALOG) {
8838
- if (x.target && x.target === exports.ESidebarTarget.BLANK) {
8839
- _this.navigateComponentToNewTab(x);
8840
- }
8841
- else {
8842
- _this.openDialog(x, item);
8843
- }
8844
- }
8845
- else if (x.action && x.action === exports.ESidebarAction.IFRAME) {
8846
- _this.loadIFrame(x, item);
8847
- }
8848
- else if (x.action && x.action === exports.ESidebarAction.REPORT) {
8849
- _this.downloadReport(x);
8850
- }
8851
- else {
8852
- _this.handleActiveItem(item);
8853
- }
8854
- },
8855
- style: {
8856
- borderBottom: '',
8857
- display: x.hidden ? 'none' : '',
8858
- },
8859
- onClick: x.onClick,
8860
- onReturn: x.onReturn,
8861
- disabled: x.disabled,
8862
- }); });
8863
- };
8864
- //ref link: https://medium.com/@saranya.thangaraj/open-angular-component-in-a-new-tab-without-bootstrapping-the-whole-app-again-e329af460e92
8865
- SidebarComponent.prototype.navigateComponentToNewTab = function (menu, onNewTab) {
8866
- var _this = this;
8867
- if (onNewTab === void 0) { onNewTab = true; }
8868
- var _a, _b;
8869
- var windowRef = window;
8870
- var winRef;
8871
- if (onNewTab) {
8872
- winRef = window.open();
8873
- if (winRef.location.href === 'about:blank') {
8874
- if (this.router.url && ((_b = (_a = this.router.url) === null || _a === void 0 ? void 0 : _a.toString()) === null || _b === void 0 ? void 0 : _b.includes('?'))) {
8875
- winRef.location.href = this.router.url + '&&component=' + menu.component.name;
8876
- }
8877
- else {
8878
- winRef.location.href = this.router.url + "?component=" + menu.component.name;
8879
- }
8880
- }
8881
- }
8882
- // Wait for window instance to be created
8883
- if (onNewTab) {
8884
- setTimeout(function () {
8885
- _this.sidebarService.createWindowInstance(menu, winRef);
8886
- }, 900);
8887
- }
8888
- else {
8889
- this.sidebarService.createWindowInstance(menu, windowRef);
8890
- }
8891
- };
8892
- SidebarComponent.prototype.setMenuTitle = function (x) {
8893
- return x.tooltip ? x.tooltip : !x.label ? x.section : '';
8894
- };
8895
- SidebarComponent.prototype.setMenuItems = function (x) {
8896
- var _this = this;
8897
- return x.items.map(function (menu) { return ({
8898
- label: menu.label,
8899
- icon: menu.icon,
8900
- id: menu.id,
8901
- section: menu.section,
8902
- expanded: menu.expanded,
8903
- action: menu.action,
8904
- title: _this.setMenuTitle(x),
8905
- command: function (_e) {
8906
- var item = _e.item;
8907
- if (x.action && x.action === exports.ESidebarAction.NAVIGATION) {
8908
- _this.navigateToSection(menu, item);
8909
- }
8910
- else if (menu.action && menu.action === exports.ESidebarAction.OPENDIALOG) {
8911
- _this.openDialog(menu, item);
8912
- }
8913
- else if (menu.action && menu.action === exports.ESidebarAction.IFRAME) {
8914
- _this.loadIFrame(menu, x);
8915
- }
8916
- _this.handleActiveItem(item);
8917
- },
8918
- style: {
8919
- borderBottom: '',
8920
- display: menu.hidden ? 'none' : '',
8921
- },
8922
- onClick: menu.onClick,
8923
- onReturn: menu.onReturn,
8924
- disabled: menu.disabled,
8925
- }); });
8926
- };
8927
- SidebarComponent.prototype.downloadReport = function (menu) {
8928
- this.reportService.downloadReport(menu.reportId, menu.params, menu.showDialog);
8929
- };
8930
- SidebarComponent.prototype.loadIFrame = function (menu, item) {
8931
- var _this = this;
8932
- var _a, _b, _c, _d;
8933
- if (menu) {
8934
- var dialogRef = this.dialogService.open(IframeComponent, {
8935
- header: menu.section,
8936
- width: ((_a = menu.iFrame) === null || _a === void 0 ? void 0 : _a.width) ? menu.iFrame.width : '90%',
8937
- height: ((_b = menu.iFrame) === null || _b === void 0 ? void 0 : _b.height) ? menu.iFrame.height : '80%',
8938
- data: { value: (_c = menu.iFrame) === null || _c === void 0 ? void 0 : _c.link, iFrameId: menu.section },
8939
- });
8940
- this.pageLoggerService.savePageLoggerInfo((_d = this.router.url) === null || _d === void 0 ? void 0 : _d.substring(1), 'IframeComponent');
8941
- this.handleActiveItem(item);
8942
- draggableDialog(menu.label);
8943
- dialogRef.onClose.subscribe(function (data) {
8944
- _this.handleActiveItem(item, false);
8945
- if (data && menu.onReturn) {
8946
- menu.onReturn(data);
8947
- }
8948
- });
8949
- }
8950
- };
8951
- SidebarComponent.prototype.toggleSidebar = function () {
8952
- this.toggleMenu = !this.toggleMenu;
8953
- localStorage.setItem('toggleMenu', JSON.stringify(this.toggleMenu));
8954
- };
8955
- // apply user role permissions
8956
- SidebarComponent.prototype.applyUserPermissions = function () {
8648
+ SidebarComponent.prototype.toggleSidebar = function () {
8649
+ this.toggleMenu = !this.toggleMenu;
8650
+ localStorage.setItem('toggleMenu', JSON.stringify(this.toggleMenu));
8651
+ };
8652
+ // apply user role permissions
8653
+ SidebarComponent.prototype.applyUserPermissions = function () {
8957
8654
  var _this = this;
8958
8655
  if (this.sidebarItemsList) {
8959
8656
  var totalItems_1 = 0;
@@ -9099,7 +8796,6 @@
9099
8796
  { type: i0.Renderer2 },
9100
8797
  { type: AuthenticationService },
9101
8798
  { type: i1.DialogService },
9102
- { type: ReportService },
9103
8799
  { type: router.Router },
9104
8800
  { type: PageLoggerService },
9105
8801
  { type: HyperlinkService },
@@ -9573,126 +9269,423 @@
9573
9269
  { type: GridService },
9574
9270
  { type: api.ConfirmationService }
9575
9271
  ]; };
9576
- CardComponent.propDecorators = {
9577
- selectedCard: [{ type: i0.Output }],
9578
- data: [{ type: i0.Input }],
9579
- width: [{ type: i0.Input }],
9580
- height: [{ type: i0.Input }],
9581
- card: [{ type: i0.Input }],
9582
- setCardData: [{ type: i0.Input }]
9583
- };
9272
+ CardComponent.propDecorators = {
9273
+ selectedCard: [{ type: i0.Output }],
9274
+ data: [{ type: i0.Input }],
9275
+ width: [{ type: i0.Input }],
9276
+ height: [{ type: i0.Input }],
9277
+ card: [{ type: i0.Input }],
9278
+ setCardData: [{ type: i0.Input }]
9279
+ };
9280
+
9281
+ var fileComponent = /** @class */ (function () {
9282
+ function fileComponent(confirmationService) {
9283
+ this.confirmationService = confirmationService;
9284
+ this.url = '';
9285
+ this.caption = '';
9286
+ this.width = '';
9287
+ this.height = '200px';
9288
+ this.onDeleteEvent = new i0.EventEmitter();
9289
+ this.onSaveEvent = new i0.EventEmitter();
9290
+ this.name = '';
9291
+ this.allowDownloadFile = true;
9292
+ this.allowEditableCaption = true;
9293
+ this.allowDeleteFile = true;
9294
+ this.editableCaption = false;
9295
+ }
9296
+ fileComponent.prototype.ngOnInit = function () {
9297
+ this.checkFileExtension();
9298
+ };
9299
+ fileComponent.prototype.checkFileExtension = function () {
9300
+ switch (this.type) {
9301
+ case 'png':
9302
+ case 'jpeg':
9303
+ case 'jfif':
9304
+ case 'jpg': {
9305
+ this.type = '.image';
9306
+ break;
9307
+ }
9308
+ case 'xlsx':
9309
+ case 'xls':
9310
+ case 'xlsm':
9311
+ case 'txt': {
9312
+ this.type = exports.ESelectFileType.EXCEL;
9313
+ break;
9314
+ }
9315
+ case 'pdf':
9316
+ case 'html': {
9317
+ this.type = exports.ESelectFileType.PDF;
9318
+ break;
9319
+ }
9320
+ case 'doc':
9321
+ case 'docx': {
9322
+ this.type = exports.ESelectFileType.DOCUMENT;
9323
+ break;
9324
+ }
9325
+ }
9326
+ };
9327
+ fileComponent.prototype.downloadFile = function (url) {
9328
+ var link = document.createElement('a');
9329
+ link.href = url;
9330
+ link.target = '_blank';
9331
+ link.click();
9332
+ };
9333
+ fileComponent.prototype.captionClickEvent = function () {
9334
+ if (this.allowEditableCaption) {
9335
+ this.editableCaption = true;
9336
+ }
9337
+ };
9338
+ fileComponent.prototype.captionSave = function (id, name, url, type, caption) {
9339
+ var obj = {
9340
+ id: id,
9341
+ name: name,
9342
+ blobfileurl: url,
9343
+ type: type,
9344
+ caption: caption,
9345
+ };
9346
+ if (caption !== null) {
9347
+ this.caption = caption;
9348
+ this.editableCaption = false;
9349
+ this.onSaveEvent.emit(obj);
9350
+ }
9351
+ };
9352
+ fileComponent.prototype.onDeleteFile = function (id, name, url, type, caption) {
9353
+ var obj = {
9354
+ id: id,
9355
+ name: name,
9356
+ blobfileurl: url,
9357
+ type: type,
9358
+ caption: caption,
9359
+ };
9360
+ this.onDeleteEvent.emit(obj);
9361
+ };
9362
+ fileComponent.prototype.cancel = function () {
9363
+ this.editableCaption = false;
9364
+ };
9365
+ return fileComponent;
9366
+ }());
9367
+ fileComponent.decorators = [
9368
+ { type: i0.Component, args: [{
9369
+ selector: 'se-file',
9370
+ template: "<div class=\"p-d-flex cards-wrapper\">\n <div\n class=\"example-box\"\n [class]=\"width && width.length > 0 ? 'p-col-' + width : 'p-col-12'\"\n >\n <p-card class=\"custom-card\">\n <div class=\"image-wrapper\">\n <!-- Start image file type cases -->\n <div [ngSwitch]=\"type\">\n <img\n alt=\"ImageCard\"\n [src]=\"url\"\n [name]=\"name\"\n [id]=\"id\"\n *ngSwitchCase=\"'.image'\"\n [ngStyle]=\"{ height: height }\"\n />\n\n <img\n alt=\"ImageCard\"\n src=\"../../../../assets/images/pdf-file.png\"\n [name]=\"name\"\n [id]=\"id\"\n *ngSwitchCase=\"'.pdf'\"\n [ngStyle]=\"{ height: height }\"\n />\n <img\n alt=\"ImageCard\"\n src=\"../../../../assets/images/xls.png\"\n [name]=\"name\"\n [id]=\"id\"\n *ngSwitchCase=\"'.excel'\"\n [ngStyle]=\"{ height: height }\"\n />\n <img\n alt=\"ImageCard\"\n src=\"../../../../assets/images/doc.png\"\n [name]=\"name\"\n [id]=\"id\"\n *ngSwitchCase=\"'.document'\"\n [ngStyle]=\"{ height: height }\"\n />\n </div>\n <!-- End image file type cases -->\n\n <!-- start caption functionality-->\n <div class=\"edit-caption\">\n <h4\n class=\"example-box\"\n (click)=\"captionClickEvent()\"\n [title]=\"caption\"\n *ngIf=\"!editableCaption\"\n >\n {{ caption }}\n </h4>\n <div\n class=\"p-d-flex p-flex-column p-ai-end\" \n *ngIf=\"editableCaption && allowEditableCaption\"\n >\n <input\n type=\"text\"\n name=\"caption\"\n [(ngModel)]=\"caption\"\n pInputText\n (blur)=\"captionSave(id, name, url, type, caption)\"\n />\n <div class=\"icons\">\n <i\n class=\"pi pi-check\"\n (click)=\"captionSave(id, name, url, type, caption)\"\n ></i>\n <i class=\"pi pi-times\" (click)=\"cancel()\"></i>\n </div>\n </div>\n <!-- End caption functionality-->\n\n <!-- start header action button functionality -->\n <div class=\"action-buttons\">\n <button\n pButton\n type=\"button\"\n icon=\"pi pi-arrow-circle-down\"\n (click)=\"downloadFile(url)\"\n class=\"p-button-rounded p-button-text\"\n *ngIf=\"allowDownloadFile\"\n ></button>\n <button\n pButton\n type=\"button\"\n icon=\"pi pi-trash\"\n (click)=\"onDeleteFile(id, name, url, type, caption)\"\n class=\"p-button-rounded p-button-text\"\n *ngIf=\"allowDeleteFile\"\n ></button>\n </div>\n <!-- End header action button functionality -->\n </div>\n </div>\n </p-card>\n </div>\n</div>\n",
9371
+ styles: [":host ::ng-deep .custom-card .action-buttons{visibility:hidden}:host ::ng-deep .custom-card .image-wrapper:hover .action-buttons{visibility:visible}.cdk-drag-placeholder{opacity:0}.cdk-drag-animating{transition:transform .25s cubic-bezier(0,0,.2,1)}.example-list.cdk-drop-list-dragging .example-box:not(.cdk-drag-placeholder){transition:transform .25s cubic-bezier(0,0,.2,1)}\n"]
9372
+ },] }
9373
+ ];
9374
+ /** @nocollapse */
9375
+ fileComponent.ctorParameters = function () { return [
9376
+ { type: api.ConfirmationService }
9377
+ ]; };
9378
+ fileComponent.propDecorators = {
9379
+ url: [{ type: i0.Input }],
9380
+ caption: [{ type: i0.Input }],
9381
+ width: [{ type: i0.Input }],
9382
+ height: [{ type: i0.Input }],
9383
+ onDeleteEvent: [{ type: i0.Output }],
9384
+ onSaveEvent: [{ type: i0.Output }],
9385
+ id: [{ type: i0.Input }],
9386
+ name: [{ type: i0.Input }],
9387
+ type: [{ type: i0.Input }],
9388
+ allowDownloadFile: [{ type: i0.Input }],
9389
+ allowEditableCaption: [{ type: i0.Input }],
9390
+ allowDeleteFile: [{ type: i0.Input }]
9391
+ };
9392
+
9393
+ var ReportFilterComponent = /** @class */ (function () {
9394
+ function ReportFilterComponent(config, requestService, formService, alertService) {
9395
+ this.config = config;
9396
+ this.requestService = requestService;
9397
+ this.formService = formService;
9398
+ this.alertService = alertService;
9399
+ this.formFields = [];
9400
+ }
9401
+ ReportFilterComponent.prototype.ngOnInit = function () {
9402
+ this.createDynamicFields();
9403
+ };
9404
+ ReportFilterComponent.prototype.initializeForm = function () {
9405
+ var _this = this;
9406
+ var _a, _b;
9407
+ this.dynamicForm = {
9408
+ formSections: [
9409
+ {
9410
+ fields: __spreadArray(__spreadArray([], __read(this.formFields)), [
9411
+ {
9412
+ label: 'Download Report',
9413
+ control: exports.EFormControl.ADD_BUTTON,
9414
+ hidden: (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.hideGenerateReportBtn,
9415
+ onClick: function () {
9416
+ _this.downloadReport();
9417
+ },
9418
+ }
9419
+ ])
9420
+ }
9421
+ ]
9422
+ };
9423
+ };
9424
+ ReportFilterComponent.prototype.createDynamicFields = function () {
9425
+ var _this = this;
9426
+ var _a;
9427
+ this.requestService.getOne('/ReportConfig/ById', (_a = this.config.data) === null || _a === void 0 ? void 0 : _a.Id).subscribe(function (data) {
9428
+ var reportJson = JSON.parse(data === null || data === void 0 ? void 0 : data.report);
9429
+ _this.formFields = reportJson === null || reportJson === void 0 ? void 0 : reportJson.FormFields;
9430
+ _this.setParamFieldValue();
9431
+ _this.initializeForm();
9432
+ // set dropdown data based on matched field.
9433
+ _this.setDropDownData(reportJson);
9434
+ }, function (error) {
9435
+ _this.initializeForm();
9436
+ _this.alertService.error(error);
9437
+ });
9438
+ };
9439
+ ReportFilterComponent.prototype.setParamFieldValue = function () {
9440
+ var _this = this;
9441
+ var _a;
9442
+ if (this.config.data && ((_a = this.config.data.param) === null || _a === void 0 ? void 0 : _a.length) > 0) {
9443
+ this.config.data.param.forEach(function (param) {
9444
+ _this.formFields.forEach(function (field) {
9445
+ var _a;
9446
+ var matchKey = (_a = Object.keys(param)) === null || _a === void 0 ? void 0 : _a.find(function (key) { var _a; return (key === null || key === void 0 ? void 0 : key.toLowerCase()) === ((_a = field.field) === null || _a === void 0 ? void 0 : _a.toLowerCase()); });
9447
+ if (matchKey && matchKey.length > 0) {
9448
+ field.value = param[matchKey];
9449
+ }
9450
+ });
9451
+ });
9452
+ }
9453
+ };
9454
+ ReportFilterComponent.prototype.setDropDownData = function (reportJson) {
9455
+ var _this = this;
9456
+ var _a;
9457
+ (_a = reportJson.Parameters) === null || _a === void 0 ? void 0 : _a.forEach(function (record) {
9458
+ if (record.isuniquekey) {
9459
+ _this.requestService.get('/Data/Fetch', {
9460
+ uniqueKey: record.isuniquekey,
9461
+ filters: []
9462
+ }).subscribe(function (response) {
9463
+ _this.formService.setFormFieldProp(_this.dynamicForm, record.paramname, [
9464
+ { name: 'data', value: response.records },
9465
+ ]);
9466
+ }, function (error) {
9467
+ _this.alertService.apiError(error);
9468
+ });
9469
+ }
9470
+ });
9471
+ };
9472
+ ReportFilterComponent.prototype.getFilters = function () {
9473
+ var _a, _b;
9474
+ var filters = [];
9475
+ (_b = (_a = this.dynamicForm) === null || _a === void 0 ? void 0 : _a.formSections) === null || _b === void 0 ? void 0 : _b.forEach(function (section) {
9476
+ var _a;
9477
+ (_a = section.fields) === null || _a === void 0 ? void 0 : _a.forEach(function (field) {
9478
+ if (field && field.value) {
9479
+ filters.push({ field: field.field, matchMode: 'equal', operator: 'and', value: field.value });
9480
+ }
9481
+ ;
9482
+ });
9483
+ });
9484
+ return filters;
9485
+ };
9486
+ ReportFilterComponent.prototype.downloadReport = function () {
9487
+ var _this = this;
9488
+ var _a, _b;
9489
+ var filters = this.getFilters();
9490
+ this.requestService.download('/Report/Generate', { Id: (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.Id, filters: filters })
9491
+ .subscribe(function (response) {
9492
+ var _a, _b, _c, _d;
9493
+ var newBlob = new Blob([response.body], { type: 'application/pdf' });
9494
+ var data = window.URL.createObjectURL(newBlob);
9495
+ var a = document.createElement('a');
9496
+ a.href = data;
9497
+ var header = (_a = response === null || response === void 0 ? void 0 : response.headers) === null || _a === void 0 ? void 0 : _a.get('Content-Disposition');
9498
+ var fileName = (_d = (_c = (_b = header === null || header === void 0 ? void 0 : header.split('filename=')) === null || _b === void 0 ? void 0 : _b[1]) === null || _c === void 0 ? void 0 : _c.split(";")[0]) === null || _d === void 0 ? void 0 : _d.replaceAll(/\"/g, '');
9499
+ a.download = fileName;
9500
+ document.body.appendChild(a);
9501
+ a.click();
9502
+ document.body.removeChild(a);
9503
+ }, function (error) {
9504
+ _this.alertService.apiError(error);
9505
+ });
9506
+ };
9507
+ return ReportFilterComponent;
9508
+ }());
9509
+ ReportFilterComponent.decorators = [
9510
+ { type: i0.Component, args: [{
9511
+ selector: 'se-report-filter',
9512
+ template: "<se-form \n*ngIf=\"dynamicForm\"\n[form]=\"dynamicForm\"\n[hideSaveButton]=\"true\"\n[hideCancelButton]=\"true\"\n>\n</se-form>\n",
9513
+ styles: [""]
9514
+ },] }
9515
+ ];
9516
+ /** @nocollapse */
9517
+ ReportFilterComponent.ctorParameters = function () { return [
9518
+ { type: i1.DynamicDialogConfig, decorators: [{ type: i0.Optional }] },
9519
+ { type: RequestService },
9520
+ { type: FormService },
9521
+ { type: AlertService }
9522
+ ]; };
9584
9523
 
9585
- var fileComponent = /** @class */ (function () {
9586
- function fileComponent(confirmationService) {
9587
- this.confirmationService = confirmationService;
9588
- this.url = '';
9589
- this.caption = '';
9590
- this.width = '';
9591
- this.height = '200px';
9592
- this.onDeleteEvent = new i0.EventEmitter();
9593
- this.onSaveEvent = new i0.EventEmitter();
9594
- this.name = '';
9595
- this.allowDownloadFile = true;
9596
- this.allowEditableCaption = true;
9597
- this.allowDeleteFile = true;
9598
- this.editableCaption = false;
9524
+ var ReportService = /** @class */ (function () {
9525
+ function ReportService(dialogService, requestService, alertService) {
9526
+ this.dialogService = dialogService;
9527
+ this.requestService = requestService;
9528
+ this.alertService = alertService;
9529
+ this.formFields = [];
9530
+ this.paramsCopy = [];
9599
9531
  }
9600
- fileComponent.prototype.ngOnInit = function () {
9601
- this.checkFileExtension();
9532
+ ReportService.prototype.downloadReport = function (repId, params, showDialog, form) {
9533
+ var _this = this;
9534
+ if (showDialog === void 0) { showDialog = false; }
9535
+ if (form === void 0) { form = {}; }
9536
+ params === null || params === void 0 ? void 0 : params.forEach(function (p) {
9537
+ _this.paramsCopy.push(Object.assign({}, p));
9538
+ });
9539
+ this.createDynamicFields(repId, params, showDialog, form);
9602
9540
  };
9603
- fileComponent.prototype.checkFileExtension = function () {
9604
- switch (this.type) {
9605
- case 'png':
9606
- case 'jpeg':
9607
- case 'jfif':
9608
- case 'jpg': {
9609
- this.type = '.image';
9610
- break;
9611
- }
9612
- case 'xlsx':
9613
- case 'xls':
9614
- case 'xlsm':
9615
- case 'txt': {
9616
- this.type = exports.ESelectFileType.EXCEL;
9617
- break;
9618
- }
9619
- case 'pdf':
9620
- case 'html': {
9621
- this.type = exports.ESelectFileType.PDF;
9622
- break;
9623
- }
9624
- case 'doc':
9625
- case 'docx': {
9626
- this.type = exports.ESelectFileType.DOCUMENT;
9627
- break;
9541
+ ReportService.prototype.createDynamicFields = function (repId, params, showDialog, form) {
9542
+ var _this = this;
9543
+ this.requestService
9544
+ .getOne('/ReportConfig/ById', repId)
9545
+ .subscribe(function (data) {
9546
+ if (data) {
9547
+ var reportJson = JSON.parse(data === null || data === void 0 ? void 0 : data.report);
9548
+ _this.formFields = reportJson === null || reportJson === void 0 ? void 0 : reportJson.FormFields;
9628
9549
  }
9629
- }
9630
- };
9631
- fileComponent.prototype.downloadFile = function (url) {
9632
- var link = document.createElement('a');
9633
- link.href = url;
9634
- link.target = '_blank';
9635
- link.click();
9550
+ _this.generateReport(repId, params, showDialog, form);
9551
+ }, function (error) {
9552
+ _this.alertService.error(error);
9553
+ });
9636
9554
  };
9637
- fileComponent.prototype.captionClickEvent = function () {
9638
- if (this.allowEditableCaption) {
9639
- this.editableCaption = true;
9555
+ ReportService.prototype.generateReport = function (repId, params, showDialog, form) {
9556
+ if (showDialog === void 0) { showDialog = false; }
9557
+ if (form === void 0) { form = {}; }
9558
+ this.getFormFieldValues(form, params);
9559
+ if ((this.formFields.some(function (field) { return !field.hidden; }) &&
9560
+ showDialog === undefined) ||
9561
+ showDialog === true) {
9562
+ this.dialogService.open(ReportFilterComponent, {
9563
+ width: '80%',
9564
+ height: '100%',
9565
+ header: 'Generate Report',
9566
+ style: { background: '#fff' },
9567
+ data: { Id: repId, param: params },
9568
+ });
9569
+ }
9570
+ else {
9571
+ this.downloadQuickReport(params, repId);
9640
9572
  }
9641
9573
  };
9642
- fileComponent.prototype.captionSave = function (id, name, url, type, caption) {
9643
- var obj = {
9644
- id: id,
9645
- name: name,
9646
- blobfileurl: url,
9647
- type: type,
9648
- caption: caption,
9649
- };
9650
- if (caption !== null) {
9651
- this.caption = caption;
9652
- this.editableCaption = false;
9653
- this.onSaveEvent.emit(obj);
9574
+ ReportService.prototype.getFormFieldValues = function (form, params) {
9575
+ var _a;
9576
+ if (((_a = this.paramsCopy) === null || _a === void 0 ? void 0 : _a.length) > 0) {
9577
+ this.paramsCopy.forEach(function (paramCopy) {
9578
+ var _a, _b;
9579
+ var key = Object.keys(paramCopy)[0];
9580
+ if (paramCopy[key] === '' || !paramCopy[key]) {
9581
+ (_a = form === null || form === void 0 ? void 0 : form.formSections) === null || _a === void 0 ? void 0 : _a.forEach(function (section) {
9582
+ section.fields.forEach(function (field) {
9583
+ var _a;
9584
+ if (key.toString().toLowerCase() === ((_a = field.field) === null || _a === void 0 ? void 0 : _a.toLowerCase())) {
9585
+ params.forEach(function (origParam) {
9586
+ var origKey = Object.keys(origParam)[0];
9587
+ if (origKey == key) {
9588
+ //origParam[origKey] = field.value;
9589
+ if (field.control == exports.EFormControl.CALENDAR) {
9590
+ origParam[origKey] = field.value ? field.value.toLocaleDateString() : null;
9591
+ }
9592
+ else {
9593
+ origParam[origKey] = field.value;
9594
+ }
9595
+ }
9596
+ });
9597
+ }
9598
+ });
9599
+ });
9600
+ }
9601
+ else if (paramCopy[key].toString().includes('{') &&
9602
+ paramCopy[key].toString().includes('}')) {
9603
+ var newValue = paramCopy[key].replace('{', '').replace('}', '');
9604
+ (_b = form === null || form === void 0 ? void 0 : form.formSections) === null || _b === void 0 ? void 0 : _b.forEach(function (section) {
9605
+ section.fields.forEach(function (field) {
9606
+ var _a;
9607
+ if (newValue.toString().toLowerCase() === ((_a = field.field) === null || _a === void 0 ? void 0 : _a.toLowerCase())) {
9608
+ params.forEach(function (origParam) {
9609
+ var origKey = Object.keys(origParam)[0];
9610
+ if (origKey == key) {
9611
+ if (field.control == exports.EFormControl.CALENDAR) {
9612
+ origParam[origKey] = field.value ? field.value.toLocaleDateString() : null;
9613
+ }
9614
+ else {
9615
+ origParam[origKey] = field.value;
9616
+ }
9617
+ }
9618
+ });
9619
+ }
9620
+ });
9621
+ });
9622
+ }
9623
+ });
9654
9624
  }
9655
9625
  };
9656
- fileComponent.prototype.onDeleteFile = function (id, name, url, type, caption) {
9657
- var obj = {
9658
- id: id,
9659
- name: name,
9660
- blobfileurl: url,
9661
- type: type,
9662
- caption: caption,
9663
- };
9664
- this.onDeleteEvent.emit(obj);
9626
+ ReportService.prototype.downloadQuickReport = function (params, repId) {
9627
+ var _this = this;
9628
+ var filters = [];
9629
+ if (params && params.length > 0) {
9630
+ params.forEach(function (param) {
9631
+ Object.keys(param).map(function (key) { return filters.push({
9632
+ field: key,
9633
+ matchMode: 'equal',
9634
+ operator: 'and',
9635
+ value: param[key],
9636
+ }); });
9637
+ });
9638
+ }
9639
+ else {
9640
+ filters = this.getFilters();
9641
+ }
9642
+ this.requestService
9643
+ .download('/Report/Generate', { Id: repId, filters: filters })
9644
+ .subscribe(function (response) {
9645
+ var _a, _b, _c, _d;
9646
+ var newBlob = new Blob([response.body], { type: 'application/pdf' });
9647
+ var data = window.URL.createObjectURL(newBlob);
9648
+ var a = document.createElement('a');
9649
+ a.href = data;
9650
+ var header = (_a = response === null || response === void 0 ? void 0 : response.headers) === null || _a === void 0 ? void 0 : _a.get('Content-Disposition');
9651
+ var fileName = (_d = (_c = (_b = header === null || header === void 0 ? void 0 : header.split('filename=')) === null || _b === void 0 ? void 0 : _b[1]) === null || _c === void 0 ? void 0 : _c.split(';')[0]) === null || _d === void 0 ? void 0 : _d.replaceAll(/\"/g, '');
9652
+ a.download = fileName;
9653
+ document.body.appendChild(a);
9654
+ a.click();
9655
+ document.body.removeChild(a);
9656
+ }, function (error) {
9657
+ _this.alertService.apiError(error);
9658
+ });
9665
9659
  };
9666
- fileComponent.prototype.cancel = function () {
9667
- this.editableCaption = false;
9660
+ ReportService.prototype.getFilters = function () {
9661
+ var filters = [];
9662
+ this.formFields.forEach(function (field) {
9663
+ var _a, _b;
9664
+ if (field && ((_b = (_a = field.value) === null || _a === void 0 ? void 0 : _a.toString()) === null || _b === void 0 ? void 0 : _b.length) > 0) {
9665
+ filters.push({
9666
+ field: field.field,
9667
+ matchMode: 'equal',
9668
+ operator: 'and',
9669
+ value: field.value,
9670
+ });
9671
+ }
9672
+ });
9673
+ return filters;
9668
9674
  };
9669
- return fileComponent;
9675
+ return ReportService;
9670
9676
  }());
9671
- fileComponent.decorators = [
9672
- { type: i0.Component, args: [{
9673
- selector: 'se-file',
9674
- template: "<div class=\"p-d-flex cards-wrapper\">\n <div\n class=\"example-box\"\n [class]=\"width && width.length > 0 ? 'p-col-' + width : 'p-col-12'\"\n >\n <p-card class=\"custom-card\">\n <div class=\"image-wrapper\">\n <!-- Start image file type cases -->\n <div [ngSwitch]=\"type\">\n <img\n alt=\"ImageCard\"\n [src]=\"url\"\n [name]=\"name\"\n [id]=\"id\"\n *ngSwitchCase=\"'.image'\"\n [ngStyle]=\"{ height: height }\"\n />\n\n <img\n alt=\"ImageCard\"\n src=\"../../../../assets/images/pdf-file.png\"\n [name]=\"name\"\n [id]=\"id\"\n *ngSwitchCase=\"'.pdf'\"\n [ngStyle]=\"{ height: height }\"\n />\n <img\n alt=\"ImageCard\"\n src=\"../../../../assets/images/xls.png\"\n [name]=\"name\"\n [id]=\"id\"\n *ngSwitchCase=\"'.excel'\"\n [ngStyle]=\"{ height: height }\"\n />\n <img\n alt=\"ImageCard\"\n src=\"../../../../assets/images/doc.png\"\n [name]=\"name\"\n [id]=\"id\"\n *ngSwitchCase=\"'.document'\"\n [ngStyle]=\"{ height: height }\"\n />\n </div>\n <!-- End image file type cases -->\n\n <!-- start caption functionality-->\n <div class=\"edit-caption\">\n <h4\n class=\"example-box\"\n (click)=\"captionClickEvent()\"\n [title]=\"caption\"\n *ngIf=\"!editableCaption\"\n >\n {{ caption }}\n </h4>\n <div\n class=\"p-d-flex p-flex-column p-ai-end\" \n *ngIf=\"editableCaption && allowEditableCaption\"\n >\n <input\n type=\"text\"\n name=\"caption\"\n [(ngModel)]=\"caption\"\n pInputText\n (blur)=\"captionSave(id, name, url, type, caption)\"\n />\n <div class=\"icons\">\n <i\n class=\"pi pi-check\"\n (click)=\"captionSave(id, name, url, type, caption)\"\n ></i>\n <i class=\"pi pi-times\" (click)=\"cancel()\"></i>\n </div>\n </div>\n <!-- End caption functionality-->\n\n <!-- start header action button functionality -->\n <div class=\"action-buttons\">\n <button\n pButton\n type=\"button\"\n icon=\"pi pi-arrow-circle-down\"\n (click)=\"downloadFile(url)\"\n class=\"p-button-rounded p-button-text\"\n *ngIf=\"allowDownloadFile\"\n ></button>\n <button\n pButton\n type=\"button\"\n icon=\"pi pi-trash\"\n (click)=\"onDeleteFile(id, name, url, type, caption)\"\n class=\"p-button-rounded p-button-text\"\n *ngIf=\"allowDeleteFile\"\n ></button>\n </div>\n <!-- End header action button functionality -->\n </div>\n </div>\n </p-card>\n </div>\n</div>\n",
9675
- styles: [":host ::ng-deep .custom-card .action-buttons{visibility:hidden}:host ::ng-deep .custom-card .image-wrapper:hover .action-buttons{visibility:visible}.cdk-drag-placeholder{opacity:0}.cdk-drag-animating{transition:transform .25s cubic-bezier(0,0,.2,1)}.example-list.cdk-drop-list-dragging .example-box:not(.cdk-drag-placeholder){transition:transform .25s cubic-bezier(0,0,.2,1)}\n"]
9677
+ /** @nocollapse */ ReportService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function ReportService_Factory() { return new ReportService(i0__namespace.ɵɵinject(i1__namespace$2.DialogService), i0__namespace.ɵɵinject(RequestService), i0__namespace.ɵɵinject(AlertService)); }, token: ReportService, providedIn: "root" });
9678
+ ReportService.decorators = [
9679
+ { type: i0.Injectable, args: [{
9680
+ providedIn: 'root'
9676
9681
  },] }
9677
9682
  ];
9678
9683
  /** @nocollapse */
9679
- fileComponent.ctorParameters = function () { return [
9680
- { type: api.ConfirmationService }
9684
+ ReportService.ctorParameters = function () { return [
9685
+ { type: i1.DialogService },
9686
+ { type: RequestService },
9687
+ { type: AlertService }
9681
9688
  ]; };
9682
- fileComponent.propDecorators = {
9683
- url: [{ type: i0.Input }],
9684
- caption: [{ type: i0.Input }],
9685
- width: [{ type: i0.Input }],
9686
- height: [{ type: i0.Input }],
9687
- onDeleteEvent: [{ type: i0.Output }],
9688
- onSaveEvent: [{ type: i0.Output }],
9689
- id: [{ type: i0.Input }],
9690
- name: [{ type: i0.Input }],
9691
- type: [{ type: i0.Input }],
9692
- allowDownloadFile: [{ type: i0.Input }],
9693
- allowEditableCaption: [{ type: i0.Input }],
9694
- allowDeleteFile: [{ type: i0.Input }]
9695
- };
9696
9689
 
9697
9690
  var GenerateReportBtnComponent = /** @class */ (function () {
9698
9691
  function GenerateReportBtnComponent(reportService) {