-
diff --git a/src/app/reports/run-report/table-and-sms/table-and-sms.component.ts b/src/app/reports/run-report/table-and-sms/table-and-sms.component.ts
index f37d5e08f..86d26117a 100644
--- a/src/app/reports/run-report/table-and-sms/table-and-sms.component.ts
+++ b/src/app/reports/run-report/table-and-sms/table-and-sms.component.ts
@@ -6,6 +6,13 @@ import { DecimalPipe, NumberSymbol, getLocaleNumberSymbol } from '@angular/commo
/** Custom Servies */
import { ReportsService } from '../../reports.service';
+import { MatDialog } from '@angular/material/dialog';
+import { FormfieldBase } from 'app/shared/form-dialog/formfield/model/formfield-base';
+import { SelectBase } from 'app/shared/form-dialog/formfield/model/select-base';
+import { InputBase } from 'app/shared/form-dialog/formfield/model/input-base';
+import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.component';
+import { Dates } from 'app/core/utils/dates';
+import { environment } from 'environments/environment';
/**
* Table and SMS Component
@@ -41,7 +48,9 @@ export class TableAndSmsComponent implements OnChanges {
* @param {DecimalPipe} decimalPipe Decimal Pipe
*/
constructor(private reportsService: ReportsService,
- private decimalPipe: DecimalPipe ) { }
+ public dialog: MatDialog,
+ private decimalPipe: DecimalPipe,
+ private dateUtils: Dates) { }
/**
* Fetches run report data post changes in run report form.
@@ -85,19 +94,57 @@ export class TableAndSmsComponent implements OnChanges {
/**
* Generates the CSV file dynamically for run report data.
*/
- downloadCSV() {
- const userLang = navigator.language;
+ exportFile() {
+ const delimiterOptions: any[] = [
+ {name: 'Comma (,)', char: ','},
+ {name: 'Colon (:)', char: ':'},
+ {name: 'SemiColon (;)', char: ';'},
+ {name: 'Pipe (|)', char: '|'},
+ {name: 'Space ( )', char: ' '},
+ ];
+ const fileName = `${this.dataObject.report.name}.csv`;
+ const formfields: FormfieldBase[] = [
+ new SelectBase({
+ controlName: 'delimiter',
+ label: 'Delimiter',
+ value: environment.defaultCharDelimiter,
+ options: { label: 'name', value: 'char', data: delimiterOptions },
+ required: true,
+ order: 1
+ }),
+ new InputBase({
+ controlName: 'fileName',
+ label: 'File Name',
+ value: fileName,
+ type: 'text',
+ required: true,
+ order: 2
+ })
+ ];
+ const data = {
+ title: 'Export data to File',
+ layout: { addButtonText: 'Export to File' },
+ formfields: formfields
+ };
+ const exportDialogRef = this.dialog.open(FormDialogComponent, { data });
+ exportDialogRef.afterClosed().subscribe((response: { data: any }) => {
+ if (response.data) {
+ this.downloadCSV(response.data.value.fileName, response.data.value.delimiter);
+ }
+ });
+ }
+
+ /**
+ * Generates the CSV file dynamically for run report data.
+ */
+ downloadCSV(fileName: string, delimiter: string) {
const headers = this.displayedColumns;
- let delimiter = ',';
- if (getLocaleNumberSymbol(userLang, NumberSymbol.CurrencyDecimal) !== '.') {
- delimiter = ';';
- }
let csv = this.csvData.map((object: any) => object.row.join(delimiter));
csv.unshift(`data:text/csv;charset=utf-8,${headers.join(delimiter)}`);
csv = csv.join('\r\n');
const link = document.createElement('a');
link.setAttribute('href', encodeURI(csv));
- link.setAttribute('download', `${this.dataObject.report.name}.csv`);
+ link.setAttribute('download', fileName);
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
diff --git a/src/app/shared/confirmation-dialog/confirmation-dialog.component.ts b/src/app/shared/confirmation-dialog/confirmation-dialog.component.ts
index 88cca2ab3..e2f38868e 100644
--- a/src/app/shared/confirmation-dialog/confirmation-dialog.component.ts
+++ b/src/app/shared/confirmation-dialog/confirmation-dialog.component.ts
@@ -1,6 +1,8 @@
/** Angular Imports */
import { Component, OnInit, Inject } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
+import { DialogData } from 'app/core/dialogs/dialog-data.model';
+import { Dialogs } from 'app/core/dialogs/dialogs';
/**
* Delete dialog component.
@@ -18,27 +20,15 @@ export class ConfirmationDialogComponent implements OnInit {
* @param {any} data Provides a deleteContext.
*/
constructor(public dialogRef: MatDialogRef,
- @Inject(MAT_DIALOG_DATA) public data: any) { }
+ private dialogs: Dialogs,
+ @Inject(MAT_DIALOG_DATA) public data: DialogData) { }
ngOnInit() {
this.setColor();
}
setColor() {
- switch (this.data.type) {
- case 'Basic':
- this.color = 'primary';
- break;
- case 'Mild':
- this.color = 'primary';
- break;
- case 'Strong':
- this.color = 'warn';
- break;
- default:
- this.color = 'warn';
- }
+ this.color = this.dialogs.setColor(this.data.type);
}
-
}
diff --git a/src/app/shared/form-dialog/form-dialog.component.html b/src/app/shared/form-dialog/form-dialog.component.html
index c8e52a410..8afc04dfa 100644
--- a/src/app/shared/form-dialog/form-dialog.component.html
+++ b/src/app/shared/form-dialog/form-dialog.component.html
@@ -10,5 +10,5 @@
-
+
diff --git a/src/app/shared/tabs/entity-datatable-tab/datatable-single-row/datatable-single-row.component.ts b/src/app/shared/tabs/entity-datatable-tab/datatable-single-row/datatable-single-row.component.ts
index 908f95cff..b5aaff0bd 100644
--- a/src/app/shared/tabs/entity-datatable-tab/datatable-single-row/datatable-single-row.component.ts
+++ b/src/app/shared/tabs/entity-datatable-tab/datatable-single-row/datatable-single-row.component.ts
@@ -8,7 +8,6 @@ import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.co
import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.component';
import { FormfieldBase } from 'app/shared/form-dialog/formfield/model/formfield-base';
import { SystemService } from 'app/system/system.service';
-import { TouchSequence } from 'selenium-webdriver';
@Component({
selector: 'mifosx-datatable-single-row',
diff --git a/src/assets/env.js b/src/assets/env.js
index b6356d4ff..1172c592f 100644
--- a/src/assets/env.js
+++ b/src/assets/env.js
@@ -16,4 +16,7 @@
window["env"]["supportedLanguages"] = '';
window['env']['preloadClients'] = '';
+
+ // Char delimiter to Export CSV options: ',' ';' '|' ' '
+ window['env']['defaultCharDelimiter'] = ',';
})(this);
diff --git a/src/assets/env.template.js b/src/assets/env.template.js
index e011ea700..2949dfb95 100644
--- a/src/assets/env.template.js
+++ b/src/assets/env.template.js
@@ -16,4 +16,7 @@
window["env"]["supportedLanguages"] = '$MIFOS_SUPPORTED_LANGUAGES';
window['env']['preloadClients'] = '$MIFOS_PRELOAD_CLIENTS';
+
+ // Char delimiter to Export CSV options: ',' ';' '|' ' '
+ window['env']['defaultCharDelimiter'] = '$MIFOS_DEFAULT_CHAR_DELIMITER';
})(this);
diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts
index 9436d0a6c..7ff66f180 100644
--- a/src/environments/environment.prod.ts
+++ b/src/environments/environment.prod.ts
@@ -10,7 +10,7 @@ export const environment = {
fineractPlatformTenantIds: window['env']['fineractPlatformTenantIds'] || 'default',
// For connecting to others servers running elsewhere update the base API URL
baseApiUrls: window['env']['fineractApiUrls'] ||
- 'https://dev.mifos.io,https://demo.mifos.io,https://qa.mifos.io,https://staging.mifos.io,https://mobile.mifos.io,https://demo.fineract.dev,https://localhost:8443',
+ 'https://dev.mifos.io,https://demo.mifos.io,https://qa.mifos.io,https://staging.mifos.io,https://mobile.mifos.io,https://demo.fineract.dev,https://localhost:8443',
// For connecting to server running elsewhere set the base API URL
baseApiUrl: window['env']['fineractApiUrl'] || 'https://demo.fineract.dev',
allowServerSwitch: env.allow_switching_backend_instance,
@@ -23,7 +23,9 @@ export const environment = {
},
defaultLanguage: window['env']['defaultLanguage'] || 'en-US',
supportedLanguages: window['env']['supportedLanguages'] || 'en-US,es-MX,fr-FR',
- preloadClients: window['env']['preloadClients'] || true
+ preloadClients: window['env']['preloadClients'] || true,
+
+ defaultCharDelimiter: window['env']['defaultCharDelimiter'] || ','
};
// Server URL
diff --git a/src/environments/environment.ts b/src/environments/environment.ts
index 28061dfda..34a4a5ae7 100644
--- a/src/environments/environment.ts
+++ b/src/environments/environment.ts
@@ -28,7 +28,9 @@ export const environment = {
},
defaultLanguage: window['env']['defaultLanguage'] || 'en-US',
supportedLanguages: window['env']['supportedLanguages'] || 'en-US,es-MX,fr-FR',
- preloadClients: window['env']['preloadClients'] || true
+ preloadClients: window['env']['preloadClients'] || true,
+
+ defaultCharDelimiter: window['env']['defaultCharDelimiter'] || ','
};
// Server URL