@churchillliving/se-ui-toolkit 6.53.476 → 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
  ;
@@ -5048,12 +5048,14 @@
5048
5048
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
5049
5049
  delete selectedRow[column.field + '-data'];
5050
5050
  delete selectedRow[column.field + '_secondType'];
5051
- if (column.type === exports.EGridColumnType.LOOKUP_INPUT && ((_a = selectedRow[column.field + '_obj']) === null || _a === void 0 ? void 0 : _a.text) &&
5051
+ if (column.type === exports.EGridColumnType.LOOKUP_INPUT &&
5052
5052
  (column.allowSave === true || column.allowSave === undefined)) {
5053
5053
  if (typeof (selectedRow[column.field]) === 'object') {
5054
- selectedRow[column.field] = (_b = selectedRow[column.field]) === null || _b === void 0 ? void 0 : _b.value;
5054
+ selectedRow[column.field] = (_a = selectedRow[column.field]) === null || _a === void 0 ? void 0 : _a.value;
5055
+ }
5056
+ if ((_b = selectedRow[column.field + '_obj']) === null || _b === void 0 ? void 0 : _b.text) {
5057
+ lookupInfo[column.field] = selectedRow[column.field + '_obj'].text;
5055
5058
  }
5056
- lookupInfo[column.field] = selectedRow[column.field + '_obj'].text;
5057
5059
  }
5058
5060
  if (column.formatter) {
5059
5061
  var value = selectedRow[column.field];
@@ -5781,6 +5783,7 @@
5781
5783
  };
5782
5784
  // Check calender value is changed or not
5783
5785
  GridComponent.prototype.calenderChangeEvent = function (column, row) {
5786
+ var _this = this;
5784
5787
  var valueChange = false;
5785
5788
  if (column.timeOnly &&
5786
5789
  this.datePipe.transform(row[column.field], 'hh:mm') !==
@@ -5799,7 +5802,9 @@
5799
5802
  if (valueChange) {
5800
5803
  this.browserCloseEvent(true);
5801
5804
  this.generateRowsDataCopy = false;
5802
- this.rowsChange.emit(this.rowsData);
5805
+ setTimeout(function () {
5806
+ _this.rowsChange.emit(_this.rowsData);
5807
+ }, 250);
5803
5808
  if (column.onChange) {
5804
5809
  column.onChange(row);
5805
5810
  }
@@ -5955,30 +5960,29 @@
5955
5960
  };
5956
5961
  // Invoke onClick Event.
5957
5962
  GridComponent.prototype.onClickEvent = function (column, row) {
5958
- var _a, _b, _c, _d;
5959
- if (column.type === exports.EGridColumnType.LINK && (column.editLink === false || column.editLink === undefined) && column.editable !== true && column.disabled !== true) {
5960
- 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) {
5961
- column.onClick(row);
5962
- }
5963
- else {
5964
- var a = document.createElement('a');
5965
- a.href = (_c = row[column.field + '_obj']) === null || _c === void 0 ? void 0 : _c.hyperlink;
5966
- a.target = column.target ? column.target : '_blank',
5967
- a.click();
5968
- }
5969
- }
5970
- if (column.type === exports.EGridColumnType.DATE && row[column.field]) {
5971
- this.calenderPreviousValue = row[column.field];
5972
- }
5973
- else if (!row[column.field] &&
5974
- column.type === exports.EGridColumnType.DATE &&
5975
- (column.showTime || column.timeOnly) &&
5976
- column.minutesInterval) {
5977
- this.defaultDate = new Date(setMinutesInterval(new Date()));
5978
- }
5979
- if (column && column.onClick && column.disabled !== true && ((_d = row[column.field + '_obj']) === null || _d === void 0 ? void 0 : _d.disabled) !== true) {
5980
- column.onClick(row);
5981
- }
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
+ // }
5982
5986
  };
5983
5987
  // set the select value of multi-select
5984
5988
  GridComponent.prototype.showOption = function (column, row) {
@@ -8373,7 +8377,6 @@
8373
8377
  ESidebarAction["NAVIGATION"] = "navigation";
8374
8378
  ESidebarAction["OPENDIALOG"] = "dialog";
8375
8379
  ESidebarAction["IFRAME"] = "_iframe";
8376
- ESidebarAction["REPORT"] = "report";
8377
8380
  })(exports.ESidebarAction || (exports.ESidebarAction = {}));
8378
8381
 
8379
8382
  var SideBarService = /** @class */ (function () {
@@ -8465,493 +8468,189 @@
8465
8468
  { type: i0.ApplicationRef }
8466
8469
  ]; };
8467
8470
 
8468
- var ReportFilterComponent = /** @class */ (function () {
8469
- function ReportFilterComponent(config, requestService, formService, alertService) {
8470
- this.config = config;
8471
- this.requestService = requestService;
8472
- this.formService = formService;
8473
- this.alertService = alertService;
8474
- 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;
8475
8489
  }
8476
- ReportFilterComponent.prototype.ngOnInit = function () {
8477
- this.createDynamicFields();
8478
- };
8479
- ReportFilterComponent.prototype.initializeForm = function () {
8480
- 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 () {
8481
8501
  var _a, _b;
8482
- this.dynamicForm = {
8483
- formSections: [
8484
- {
8485
- fields: __spreadArray(__spreadArray([], __read(this.formFields)), [
8486
- {
8487
- label: 'Download Report',
8488
- control: exports.EFormControl.ADD_BUTTON,
8489
- hidden: (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.hideGenerateReportBtn,
8490
- onClick: function () {
8491
- _this.downloadReport();
8492
- },
8493
- }
8494
- ])
8495
- }
8496
- ]
8497
- };
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
+ }
8498
8511
  };
8499
- ReportFilterComponent.prototype.createDynamicFields = function () {
8512
+ SidebarComponent.prototype.openDynamicComponetonLoad = function () {
8500
8513
  var _this = this;
8501
8514
  var _a;
8502
- this.requestService.getOne('/ReportConfig/ById', (_a = this.config.data) === null || _a === void 0 ? void 0 : _a.Id).subscribe(function (data) {
8503
- var reportJson = JSON.parse(data === null || data === void 0 ? void 0 : data.report);
8504
- _this.formFields = reportJson === null || reportJson === void 0 ? void 0 : reportJson.FormFields;
8505
- _this.setParamFieldValue();
8506
- _this.initializeForm();
8507
- // set dropdown data based on matched field.
8508
- _this.setDropDownData(reportJson);
8509
- }, function (error) {
8510
- _this.initializeForm();
8511
- _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
+ }
8512
8519
  });
8513
8520
  };
8514
- ReportFilterComponent.prototype.setParamFieldValue = function () {
8521
+ SidebarComponent.prototype.initializeSideBar = function () {
8515
8522
  var _this = this;
8516
- var _a;
8517
- if (this.config.data && ((_a = this.config.data.param) === null || _a === void 0 ? void 0 : _a.length) > 0) {
8518
- this.config.data.param.forEach(function (param) {
8519
- _this.formFields.forEach(function (field) {
8520
- var _a;
8521
- 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()); });
8522
- if (matchKey && matchKey.length > 0) {
8523
- 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);
8524
8543
  }
8525
- });
8526
- });
8527
- }
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
+ }); });
8528
8563
  };
8529
- 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) {
8530
8566
  var _this = this;
8531
- var _a;
8532
- (_a = reportJson.Parameters) === null || _a === void 0 ? void 0 : _a.forEach(function (record) {
8533
- if (record.isuniquekey) {
8534
- _this.requestService.get('/Data/Fetch', {
8535
- uniqueKey: record.isuniquekey,
8536
- filters: []
8537
- }).subscribe(function (response) {
8538
- _this.formService.setFormFieldProp(_this.dynamicForm, record.paramname, [
8539
- { name: 'data', value: response.records },
8540
- ]);
8541
- }, function (error) {
8542
- _this.alertService.apiError(error);
8543
- });
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
+ }
8544
8580
  }
8545
- });
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
+ }
8546
8591
  };
8547
- ReportFilterComponent.prototype.getFilters = function () {
8548
- var _a, _b;
8549
- var filters = [];
8550
- (_b = (_a = this.dynamicForm) === null || _a === void 0 ? void 0 : _a.formSections) === null || _b === void 0 ? void 0 : _b.forEach(function (section) {
8551
- var _a;
8552
- (_a = section.fields) === null || _a === void 0 ? void 0 : _a.forEach(function (field) {
8553
- if (field && field.value) {
8554
- 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);
8555
8609
  }
8556
- ;
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 },
8557
8636
  });
8558
- });
8559
- 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
+ }
8560
8647
  };
8561
- ReportFilterComponent.prototype.downloadReport = function () {
8562
- var _this = this;
8563
- var _a, _b;
8564
- var filters = this.getFilters();
8565
- 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 })
8566
- .subscribe(function (response) {
8567
- var _a, _b, _c, _d;
8568
- var newBlob = new Blob([response.body], { type: 'application/pdf' });
8569
- var data = window.URL.createObjectURL(newBlob);
8570
- var a = document.createElement('a');
8571
- a.href = data;
8572
- var header = (_a = response === null || response === void 0 ? void 0 : response.headers) === null || _a === void 0 ? void 0 : _a.get('Content-Disposition');
8573
- 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, '');
8574
- a.download = fileName;
8575
- document.body.appendChild(a);
8576
- a.click();
8577
- document.body.removeChild(a);
8578
- }, function (error) {
8579
- _this.alertService.apiError(error);
8580
- });
8581
- };
8582
- return ReportFilterComponent;
8583
- }());
8584
- ReportFilterComponent.decorators = [
8585
- { type: i0.Component, args: [{
8586
- selector: 'se-report-filter',
8587
- template: "<se-form \n*ngIf=\"dynamicForm\"\n[form]=\"dynamicForm\"\n[hideSaveButton]=\"true\"\n[hideCancelButton]=\"true\"\n>\n</se-form>\n",
8588
- styles: [""]
8589
- },] }
8590
- ];
8591
- /** @nocollapse */
8592
- ReportFilterComponent.ctorParameters = function () { return [
8593
- { type: i1.DynamicDialogConfig, decorators: [{ type: i0.Optional }] },
8594
- { type: RequestService },
8595
- { type: FormService },
8596
- { type: AlertService }
8597
- ]; };
8598
-
8599
- var ReportService = /** @class */ (function () {
8600
- function ReportService(dialogService, requestService, alertService) {
8601
- this.dialogService = dialogService;
8602
- this.requestService = requestService;
8603
- this.alertService = alertService;
8604
- this.formFields = [];
8605
- this.paramsCopy = [];
8606
- }
8607
- ReportService.prototype.downloadReport = function (repId, params, showDialog, form) {
8608
- var _this = this;
8609
- if (showDialog === void 0) { showDialog = false; }
8610
- if (form === void 0) { form = {}; }
8611
- params === null || params === void 0 ? void 0 : params.forEach(function (p) {
8612
- _this.paramsCopy.push(Object.assign({}, p));
8613
- });
8614
- this.createDynamicFields(repId, params, showDialog, form);
8615
- };
8616
- ReportService.prototype.createDynamicFields = function (repId, params, showDialog, form) {
8617
- var _this = this;
8618
- this.requestService
8619
- .getOne('/ReportConfig/ById', repId)
8620
- .subscribe(function (data) {
8621
- if (data) {
8622
- var reportJson = JSON.parse(data === null || data === void 0 ? void 0 : data.report);
8623
- _this.formFields = reportJson === null || reportJson === void 0 ? void 0 : reportJson.FormFields;
8624
- }
8625
- _this.generateReport(repId, params, showDialog, form);
8626
- }, function (error) {
8627
- _this.alertService.error(error);
8628
- });
8629
- };
8630
- ReportService.prototype.generateReport = function (repId, params, showDialog, form) {
8631
- if (showDialog === void 0) { showDialog = false; }
8632
- if (form === void 0) { form = {}; }
8633
- this.getFormFieldValues(form, params);
8634
- if ((this.formFields.some(function (field) { return !field.hidden; }) &&
8635
- showDialog === undefined) ||
8636
- showDialog === true) {
8637
- this.dialogService.open(ReportFilterComponent, {
8638
- width: '80%',
8639
- height: '100%',
8640
- header: 'Generate Report',
8641
- style: { background: '#fff' },
8642
- data: { Id: repId, param: params },
8643
- });
8644
- }
8645
- else {
8646
- this.downloadQuickReport(params, repId);
8647
- }
8648
- };
8649
- ReportService.prototype.getFormFieldValues = function (form, params) {
8650
- var _a;
8651
- if (((_a = this.paramsCopy) === null || _a === void 0 ? void 0 : _a.length) > 0) {
8652
- this.paramsCopy.forEach(function (paramCopy) {
8653
- var _a, _b;
8654
- var key = Object.keys(paramCopy)[0];
8655
- if (paramCopy[key] === '' || !paramCopy[key]) {
8656
- (_a = form === null || form === void 0 ? void 0 : form.formSections) === null || _a === void 0 ? void 0 : _a.forEach(function (section) {
8657
- section.fields.forEach(function (field) {
8658
- var _a;
8659
- if (key.toString().toLowerCase() === ((_a = field.field) === null || _a === void 0 ? void 0 : _a.toLowerCase())) {
8660
- params.forEach(function (origParam) {
8661
- var origKey = Object.keys(origParam)[0];
8662
- if (origKey == key) {
8663
- //origParam[origKey] = field.value;
8664
- if (field.control == exports.EFormControl.CALENDAR) {
8665
- origParam[origKey] = field.value ? field.value.toLocaleDateString() : null;
8666
- }
8667
- else {
8668
- origParam[origKey] = field.value;
8669
- }
8670
- }
8671
- });
8672
- }
8673
- });
8674
- });
8675
- }
8676
- else if (paramCopy[key].toString().includes('{') &&
8677
- paramCopy[key].toString().includes('}')) {
8678
- var newValue = paramCopy[key].replace('{', '').replace('}', '');
8679
- (_b = form === null || form === void 0 ? void 0 : form.formSections) === null || _b === void 0 ? void 0 : _b.forEach(function (section) {
8680
- section.fields.forEach(function (field) {
8681
- var _a;
8682
- if (newValue.toString().toLowerCase() === ((_a = field.field) === null || _a === void 0 ? void 0 : _a.toLowerCase())) {
8683
- params.forEach(function (origParam) {
8684
- var origKey = Object.keys(origParam)[0];
8685
- if (origKey == key) {
8686
- if (field.control == exports.EFormControl.CALENDAR) {
8687
- origParam[origKey] = field.value ? field.value.toLocaleDateString() : null;
8688
- }
8689
- else {
8690
- origParam[origKey] = field.value;
8691
- }
8692
- }
8693
- });
8694
- }
8695
- });
8696
- });
8697
- }
8698
- });
8699
- }
8700
- };
8701
- ReportService.prototype.downloadQuickReport = function (params, repId) {
8702
- var _this = this;
8703
- var filters = [];
8704
- if (params && params.length > 0) {
8705
- params.forEach(function (param) {
8706
- Object.keys(param).map(function (key) { return filters.push({
8707
- field: key,
8708
- matchMode: 'equal',
8709
- operator: 'and',
8710
- value: param[key],
8711
- }); });
8712
- });
8713
- }
8714
- else {
8715
- filters = this.getFilters();
8716
- }
8717
- this.requestService
8718
- .download('/Report/Generate', { Id: repId, filters: filters })
8719
- .subscribe(function (response) {
8720
- var _a, _b, _c, _d;
8721
- var newBlob = new Blob([response.body], { type: 'application/pdf' });
8722
- var data = window.URL.createObjectURL(newBlob);
8723
- var a = document.createElement('a');
8724
- a.href = data;
8725
- var header = (_a = response === null || response === void 0 ? void 0 : response.headers) === null || _a === void 0 ? void 0 : _a.get('Content-Disposition');
8726
- 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, '');
8727
- a.download = fileName;
8728
- document.body.appendChild(a);
8729
- a.click();
8730
- document.body.removeChild(a);
8731
- }, function (error) {
8732
- _this.alertService.apiError(error);
8733
- });
8734
- };
8735
- ReportService.prototype.getFilters = function () {
8736
- var filters = [];
8737
- this.formFields.forEach(function (field) {
8738
- var _a, _b;
8739
- if (field && ((_b = (_a = field.value) === null || _a === void 0 ? void 0 : _a.toString()) === null || _b === void 0 ? void 0 : _b.length) > 0) {
8740
- filters.push({
8741
- field: field.field,
8742
- matchMode: 'equal',
8743
- operator: 'and',
8744
- value: field.value,
8745
- });
8746
- }
8747
- });
8748
- return filters;
8749
- };
8750
- return ReportService;
8751
- }());
8752
- /** @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" });
8753
- ReportService.decorators = [
8754
- { type: i0.Injectable, args: [{
8755
- providedIn: 'root'
8756
- },] }
8757
- ];
8758
- /** @nocollapse */
8759
- ReportService.ctorParameters = function () { return [
8760
- { type: i1.DialogService },
8761
- { type: RequestService },
8762
- { type: AlertService }
8763
- ]; };
8764
-
8765
- var SidebarComponent = /** @class */ (function () {
8766
- function SidebarComponent(instance, authService, dialogService, reportService, router, pageLoggerService, hyperlinkService, sidebarService) {
8767
- this.instance = instance;
8768
- this.authService = authService;
8769
- this.dialogService = dialogService;
8770
- this.reportService = reportService;
8771
- this.router = router;
8772
- this.pageLoggerService = pageLoggerService;
8773
- this.hyperlinkService = hyperlinkService;
8774
- this.sidebarService = sidebarService;
8775
- this.toggleMenu = false;
8776
- this.loadComponentName = '';
8777
- this.openDialogs = [];
8778
- this.navHidden = false;
8779
- this.collapseSidebar = false;
8780
- this.sidebarItemsList = [];
8781
- this.menuItems = [];
8782
- this.roles = [];
8783
- this.isSidebarHidden = false;
8784
- }
8785
- Object.defineProperty(SidebarComponent.prototype, "sidebarItems", {
8786
- set: function (newSidebarItems) {
8787
- if (newSidebarItems) {
8788
- this.sidebarItemsList = newSidebarItems;
8789
- this.initializeSideBar();
8790
- }
8791
- },
8792
- enumerable: false,
8793
- configurable: true
8794
- });
8795
- SidebarComponent.prototype.ngOnInit = function () {
8796
- var _a, _b;
8797
- if ((_a = this.router.url.toString()) === null || _a === void 0 ? void 0 : _a.includes('component=')) {
8798
- var componentName = (_b = this.router.url) === null || _b === void 0 ? void 0 : _b.split('component=')[1];
8799
- if (componentName) {
8800
- this.loadComponentName = componentName;
8801
- }
8802
- }
8803
- if (this.loadComponentName) {
8804
- this.openDynamicComponetonLoad();
8805
- }
8806
- };
8807
- SidebarComponent.prototype.openDynamicComponetonLoad = function () {
8808
- var _this = this;
8809
- var _a;
8810
- (_a = this.sidebarItemsList) === null || _a === void 0 ? void 0 : _a.forEach(function (item) {
8811
- if (item.action === exports.ESidebarAction.OPENDIALOG && exports.ESidebarTarget.BLANK && item.component.name === _this.loadComponentName) {
8812
- _this.navigateComponentToNewTab(item, false);
8813
- }
8814
- });
8815
- };
8816
- SidebarComponent.prototype.initializeSideBar = function () {
8817
- var _this = this;
8818
- this.roles = this.authService.getUserRoles();
8819
- // apply user role permissions
8820
- this.applyUserPermissions();
8821
- this.menuItems = this.sidebarItemsList.map(function (x) { return ({
8822
- label: x.label,
8823
- icon: x.icon,
8824
- id: x.id,
8825
- section: x.section,
8826
- expanded: x.expanded,
8827
- action: x.action,
8828
- items: x.items && x.items.length > 0 ? _this.setMenuItems(x) : [],
8829
- title: _this.setMenuTitle(x),
8830
- command: function (_e) {
8831
- var item = _e.item;
8832
- if (x.action && x.action === exports.ESidebarAction.NAVIGATION) {
8833
- _this.navigateToSection(x, item);
8834
- }
8835
- else if (x.action && x.action === exports.ESidebarAction.OPENDIALOG) {
8836
- if (x.target && x.target === exports.ESidebarTarget.BLANK) {
8837
- _this.navigateComponentToNewTab(x);
8838
- }
8839
- else {
8840
- _this.openDialog(x, item);
8841
- }
8842
- }
8843
- else if (x.action && x.action === exports.ESidebarAction.IFRAME) {
8844
- _this.loadIFrame(x, item);
8845
- }
8846
- else if (x.action && x.action === exports.ESidebarAction.REPORT) {
8847
- _this.downloadReport(x);
8848
- }
8849
- else {
8850
- _this.handleActiveItem(item);
8851
- }
8852
- },
8853
- style: {
8854
- borderBottom: '',
8855
- display: x.hidden ? 'none' : '',
8856
- },
8857
- onClick: x.onClick,
8858
- onReturn: x.onReturn,
8859
- disabled: x.disabled,
8860
- }); });
8861
- };
8862
- //ref link: https://medium.com/@saranya.thangaraj/open-angular-component-in-a-new-tab-without-bootstrapping-the-whole-app-again-e329af460e92
8863
- SidebarComponent.prototype.navigateComponentToNewTab = function (menu, onNewTab) {
8864
- var _this = this;
8865
- if (onNewTab === void 0) { onNewTab = true; }
8866
- var _a, _b;
8867
- var windowRef = window;
8868
- var winRef;
8869
- if (onNewTab) {
8870
- winRef = window.open();
8871
- if (winRef.location.href === 'about:blank') {
8872
- 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('?'))) {
8873
- winRef.location.href = this.router.url + '&&component=' + menu.component.name;
8874
- }
8875
- else {
8876
- winRef.location.href = this.router.url + "?component=" + menu.component.name;
8877
- }
8878
- }
8879
- }
8880
- // Wait for window instance to be created
8881
- if (onNewTab) {
8882
- setTimeout(function () {
8883
- _this.sidebarService.createWindowInstance(menu, winRef);
8884
- }, 900);
8885
- }
8886
- else {
8887
- this.sidebarService.createWindowInstance(menu, windowRef);
8888
- }
8889
- };
8890
- SidebarComponent.prototype.setMenuTitle = function (x) {
8891
- return x.tooltip ? x.tooltip : !x.label ? x.section : '';
8892
- };
8893
- SidebarComponent.prototype.setMenuItems = function (x) {
8894
- var _this = this;
8895
- return x.items.map(function (menu) { return ({
8896
- label: menu.label,
8897
- icon: menu.icon,
8898
- id: menu.id,
8899
- section: menu.section,
8900
- expanded: menu.expanded,
8901
- action: menu.action,
8902
- title: _this.setMenuTitle(x),
8903
- command: function (_e) {
8904
- var item = _e.item;
8905
- if (x.action && x.action === exports.ESidebarAction.NAVIGATION) {
8906
- _this.navigateToSection(menu, item);
8907
- }
8908
- else if (menu.action && menu.action === exports.ESidebarAction.OPENDIALOG) {
8909
- _this.openDialog(menu, item);
8910
- }
8911
- else if (menu.action && menu.action === exports.ESidebarAction.IFRAME) {
8912
- _this.loadIFrame(menu, x);
8913
- }
8914
- _this.handleActiveItem(item);
8915
- },
8916
- style: {
8917
- borderBottom: '',
8918
- display: menu.hidden ? 'none' : '',
8919
- },
8920
- onClick: menu.onClick,
8921
- onReturn: menu.onReturn,
8922
- disabled: menu.disabled,
8923
- }); });
8924
- };
8925
- SidebarComponent.prototype.downloadReport = function (menu) {
8926
- this.reportService.downloadReport(menu.reportId, menu.params, menu.showDialog);
8927
- };
8928
- SidebarComponent.prototype.loadIFrame = function (menu, item) {
8929
- var _this = this;
8930
- var _a, _b, _c, _d;
8931
- if (menu) {
8932
- var dialogRef = this.dialogService.open(IframeComponent, {
8933
- header: menu.section,
8934
- width: ((_a = menu.iFrame) === null || _a === void 0 ? void 0 : _a.width) ? menu.iFrame.width : '90%',
8935
- height: ((_b = menu.iFrame) === null || _b === void 0 ? void 0 : _b.height) ? menu.iFrame.height : '80%',
8936
- data: { value: (_c = menu.iFrame) === null || _c === void 0 ? void 0 : _c.link, iFrameId: menu.section },
8937
- });
8938
- this.pageLoggerService.savePageLoggerInfo((_d = this.router.url) === null || _d === void 0 ? void 0 : _d.substring(1), 'IframeComponent');
8939
- this.handleActiveItem(item);
8940
- draggableDialog(menu.label);
8941
- dialogRef.onClose.subscribe(function (data) {
8942
- _this.handleActiveItem(item, false);
8943
- if (data && menu.onReturn) {
8944
- menu.onReturn(data);
8945
- }
8946
- });
8947
- }
8948
- };
8949
- SidebarComponent.prototype.toggleSidebar = function () {
8950
- this.toggleMenu = !this.toggleMenu;
8951
- localStorage.setItem('toggleMenu', JSON.stringify(this.toggleMenu));
8952
- };
8953
- // apply user role permissions
8954
- 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 () {
8955
8654
  var _this = this;
8956
8655
  if (this.sidebarItemsList) {
8957
8656
  var totalItems_1 = 0;
@@ -9097,7 +8796,6 @@
9097
8796
  { type: i0.Renderer2 },
9098
8797
  { type: AuthenticationService },
9099
8798
  { type: i1.DialogService },
9100
- { type: ReportService },
9101
8799
  { type: router.Router },
9102
8800
  { type: PageLoggerService },
9103
8801
  { type: HyperlinkService },
@@ -9571,126 +9269,423 @@
9571
9269
  { type: GridService },
9572
9270
  { type: api.ConfirmationService }
9573
9271
  ]; };
9574
- CardComponent.propDecorators = {
9575
- selectedCard: [{ type: i0.Output }],
9576
- data: [{ type: i0.Input }],
9577
- width: [{ type: i0.Input }],
9578
- height: [{ type: i0.Input }],
9579
- card: [{ type: i0.Input }],
9580
- setCardData: [{ type: i0.Input }]
9581
- };
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
+ ]; };
9582
9523
 
9583
- var fileComponent = /** @class */ (function () {
9584
- function fileComponent(confirmationService) {
9585
- this.confirmationService = confirmationService;
9586
- this.url = '';
9587
- this.caption = '';
9588
- this.width = '';
9589
- this.height = '200px';
9590
- this.onDeleteEvent = new i0.EventEmitter();
9591
- this.onSaveEvent = new i0.EventEmitter();
9592
- this.name = '';
9593
- this.allowDownloadFile = true;
9594
- this.allowEditableCaption = true;
9595
- this.allowDeleteFile = true;
9596
- 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 = [];
9597
9531
  }
9598
- fileComponent.prototype.ngOnInit = function () {
9599
- 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);
9600
9540
  };
9601
- fileComponent.prototype.checkFileExtension = function () {
9602
- switch (this.type) {
9603
- case 'png':
9604
- case 'jpeg':
9605
- case 'jfif':
9606
- case 'jpg': {
9607
- this.type = '.image';
9608
- break;
9609
- }
9610
- case 'xlsx':
9611
- case 'xls':
9612
- case 'xlsm':
9613
- case 'txt': {
9614
- this.type = exports.ESelectFileType.EXCEL;
9615
- break;
9616
- }
9617
- case 'pdf':
9618
- case 'html': {
9619
- this.type = exports.ESelectFileType.PDF;
9620
- break;
9621
- }
9622
- case 'doc':
9623
- case 'docx': {
9624
- this.type = exports.ESelectFileType.DOCUMENT;
9625
- 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;
9626
9549
  }
9627
- }
9628
- };
9629
- fileComponent.prototype.downloadFile = function (url) {
9630
- var link = document.createElement('a');
9631
- link.href = url;
9632
- link.target = '_blank';
9633
- link.click();
9550
+ _this.generateReport(repId, params, showDialog, form);
9551
+ }, function (error) {
9552
+ _this.alertService.error(error);
9553
+ });
9634
9554
  };
9635
- fileComponent.prototype.captionClickEvent = function () {
9636
- if (this.allowEditableCaption) {
9637
- 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);
9638
9572
  }
9639
9573
  };
9640
- fileComponent.prototype.captionSave = function (id, name, url, type, caption) {
9641
- var obj = {
9642
- id: id,
9643
- name: name,
9644
- blobfileurl: url,
9645
- type: type,
9646
- caption: caption,
9647
- };
9648
- if (caption !== null) {
9649
- this.caption = caption;
9650
- this.editableCaption = false;
9651
- 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
+ });
9652
9624
  }
9653
9625
  };
9654
- fileComponent.prototype.onDeleteFile = function (id, name, url, type, caption) {
9655
- var obj = {
9656
- id: id,
9657
- name: name,
9658
- blobfileurl: url,
9659
- type: type,
9660
- caption: caption,
9661
- };
9662
- 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
+ });
9663
9659
  };
9664
- fileComponent.prototype.cancel = function () {
9665
- 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;
9666
9674
  };
9667
- return fileComponent;
9675
+ return ReportService;
9668
9676
  }());
9669
- fileComponent.decorators = [
9670
- { type: i0.Component, args: [{
9671
- selector: 'se-file',
9672
- 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",
9673
- 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'
9674
9681
  },] }
9675
9682
  ];
9676
9683
  /** @nocollapse */
9677
- fileComponent.ctorParameters = function () { return [
9678
- { type: api.ConfirmationService }
9684
+ ReportService.ctorParameters = function () { return [
9685
+ { type: i1.DialogService },
9686
+ { type: RequestService },
9687
+ { type: AlertService }
9679
9688
  ]; };
9680
- fileComponent.propDecorators = {
9681
- url: [{ type: i0.Input }],
9682
- caption: [{ type: i0.Input }],
9683
- width: [{ type: i0.Input }],
9684
- height: [{ type: i0.Input }],
9685
- onDeleteEvent: [{ type: i0.Output }],
9686
- onSaveEvent: [{ type: i0.Output }],
9687
- id: [{ type: i0.Input }],
9688
- name: [{ type: i0.Input }],
9689
- type: [{ type: i0.Input }],
9690
- allowDownloadFile: [{ type: i0.Input }],
9691
- allowEditableCaption: [{ type: i0.Input }],
9692
- allowDeleteFile: [{ type: i0.Input }]
9693
- };
9694
9689
 
9695
9690
  var GenerateReportBtnComponent = /** @class */ (function () {
9696
9691
  function GenerateReportBtnComponent(reportService) {