build: Use prettier for typescript

Stop ignoring .ts files in prettier and fix existing issues.
This commit is contained in:
Ralph Hopman
2025-01-15 11:59:30 +00:00
committed by Adam Saghy
parent 9d6cf1514a
commit cac1d11ad7
1812 changed files with 22516 additions and 16862 deletions
@@ -1,4 +1,4 @@
export const appTableData: { displayValue: string, value: string }[] = [
export const appTableData: { displayValue: string; value: string }[] = [
{ displayValue: 'Client', value: 'm_client' },
{ displayValue: 'Group', value: 'm_group' },
{ displayValue: 'Center', value: 'm_center' },
@@ -11,13 +11,13 @@ export const appTableData: { displayValue: string, value: string }[] = [
{ displayValue: 'Share Product', value: 'm_share_product' }
];
export const entitySubTypeData: { displayValue: string, value: string }[] = [
export const entitySubTypeData: { displayValue: string; value: string }[] = [
{ displayValue: 'Person', value: 'Person' },
{ displayValue: 'Entity', value: 'Entity' },
{ displayValue: 'Entity', value: 'Entity' }
];
export const savingsSubTypeData: { displayValue: string, value: string }[] = [
export const savingsSubTypeData: { displayValue: string; value: string }[] = [
{ displayValue: 'Savings Product', value: 'Savings Product' },
{ displayValue: 'Fixed Deposit', value: 'Fixed Deposit' },
{ displayValue: 'Recurring Deposit', value: 'Recurring Deposit' },
{ displayValue: 'Recurring Deposit', value: 'Recurring Deposit' }
];
@@ -8,9 +8,8 @@ describe('ColumnDialogComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ColumnDialogComponent ]
})
.compileComponents();
declarations: [ColumnDialogComponent]
}).compileComponents();
}));
beforeEach(() => {
@@ -15,7 +15,6 @@ import { columnTypeData } from '../column-type-data';
styleUrls: ['./column-dialog.component.scss']
})
export class ColumnDialogComponent implements OnInit {
/** Column Form. */
columnForm: UntypedFormGroup;
/** Column Type Data */
@@ -26,22 +25,53 @@ export class ColumnDialogComponent implements OnInit {
* @param {FormBuilder} formBuilder Form Builder.
* @param {any} data Provides the column codes and values for the form (if available).
*/
constructor(public dialogRef: MatDialogRef<ColumnDialogComponent>,
public formBuilder: UntypedFormBuilder,
@Inject(MAT_DIALOG_DATA) public data: any) { }
constructor(
public dialogRef: MatDialogRef<ColumnDialogComponent>,
public formBuilder: UntypedFormBuilder,
@Inject(MAT_DIALOG_DATA) public data: any
) {}
/**
* Creates the add column form.
*/
ngOnInit() {
this.columnForm = this.formBuilder.group({
'name': [this.data ? this.data.columnName : '', Validators.required],
'type': [{ value: this.data ? (this.data.columnDisplayType === '' ? '' : this.getColumnType(this.data.columnDisplayType)) : '', disabled: this.data.type === 'existing' }, Validators.required],
'length': [{ value: this.data ? + this.data.columnLength : '', disabled: this.getColumnType(this.data.columnDisplayType) !== 'String' || this.data.type === 'existing' }, Validators.required],
'mandatory': [{ value: this.data.isColumnNullable, disabled: this.data.type === 'existing' }],
'unique': [{ value: this.data.isColumnUnique, disabled: this.data.isColumnNullable || this.data.type === 'existing' }],
'indexed': [{ value: this.data.isColumnIndexed, disabled: this.data.type === 'existing' }],
'code': [{ value: this.data ? this.data.columnCode : '', disabled: this.getColumnType(this.data.columnDisplayType) !== 'Dropdown' || this.data.type === 'existing' }, Validators.required],
name: [
this.data ? this.data.columnName : '',
Validators.required
],
type: [
{
value: this.data
? this.data.columnDisplayType === ''
? ''
: this.getColumnType(this.data.columnDisplayType)
: '',
disabled: this.data.type === 'existing'
},
Validators.required
],
length: [
{
value: this.data ? +this.data.columnLength : '',
disabled: this.getColumnType(this.data.columnDisplayType) !== 'String' || this.data.type === 'existing'
},
Validators.required
],
mandatory: [{ value: this.data.isColumnNullable, disabled: this.data.type === 'existing' }],
unique: [
{ value: this.data.isColumnUnique, disabled: this.data.isColumnNullable || this.data.type === 'existing' }],
indexed: [{ value: this.data.isColumnIndexed, disabled: this.data.type === 'existing' }],
code: [
{
value: this.data ? this.data.columnCode : '',
disabled: this.getColumnType(this.data.columnDisplayType) !== 'Dropdown' || this.data.type === 'existing'
},
Validators.required
]
});
this.onColumnTypeChanges();
}
@@ -72,25 +102,24 @@ export class ColumnDialogComponent implements OnInit {
* Watches on Column Type field to enable/diable certain fields.
*/
onColumnTypeChanges() {
this.columnForm.get('type').valueChanges
.subscribe(type => {
switch (type) {
case 'String': {
this.columnForm.get('length').enable();
this.columnForm.get('code').disable();
break;
}
case 'Dropdown': {
this.columnForm.get('code').enable();
this.columnForm.get('length').disable();
break;
}
default: {
this.columnForm.get('code').disable();
this.columnForm.get('length').disable();
}
this.columnForm.get('type').valueChanges.subscribe((type) => {
switch (type) {
case 'String': {
this.columnForm.get('length').enable();
this.columnForm.get('code').disable();
break;
}
});
case 'Dropdown': {
this.columnForm.get('code').enable();
this.columnForm.get('length').disable();
break;
}
default: {
this.columnForm.get('code').disable();
this.columnForm.get('length').disable();
}
}
});
}
/**
@@ -99,5 +128,4 @@ export class ColumnDialogComponent implements OnInit {
submit() {
this.dialogRef.close(this.columnForm.value);
}
}
@@ -1,10 +1,10 @@
export const columnTypeData: { displayValue: string, value: string }[] = [
{ displayValue: 'Boolean', value: 'Boolean' },
{ displayValue: 'Date', value: 'Date' },
{ displayValue: 'Date and Time', value: 'Datetime' },
{ displayValue: 'Decimal', value: 'Decimal' },
{ displayValue: 'Dropdown', value: 'Dropdown' },
{ displayValue: 'Number', value: 'Number' },
{ displayValue: 'String', value: 'String' },
{ displayValue: 'Text', value: 'Text' }
];
export const columnTypeData: { displayValue: string; value: string }[] = [
{ displayValue: 'Boolean', value: 'Boolean' },
{ displayValue: 'Date', value: 'Date' },
{ displayValue: 'Date and Time', value: 'Datetime' },
{ displayValue: 'Decimal', value: 'Decimal' },
{ displayValue: 'Dropdown', value: 'Dropdown' },
{ displayValue: 'Number', value: 'Number' },
{ displayValue: 'String', value: 'String' },
{ displayValue: 'Text', value: 'Text' }
];
@@ -8,9 +8,8 @@ describe('CreateDataTableComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ CreateDataTableComponent ]
})
.compileComponents();
declarations: [CreateDataTableComponent]
}).compileComponents();
}));
beforeEach(() => {
@@ -33,7 +33,6 @@ import { DatatableColumn } from '../datatable-column.model';
styleUrls: ['./create-data-table.component.scss']
})
export class CreateDataTableComponent implements OnInit, AfterViewInit {
/** Data Table Form */
dataTableForm: UntypedFormGroup;
/** Application Table Data */
@@ -46,18 +45,27 @@ export class CreateDataTableComponent implements OnInit, AfterViewInit {
columnData: DatatableColumn[] = [];
/** Data passed to dialog. */
dataForDialog: DatatableColumn = {
columnName: undefined,
columnDisplayType: undefined,
isColumnNullable: undefined,
columnLength: undefined,
columnCode: undefined,
columnCodes: undefined,
type: undefined,
isColumnUnique: undefined,
isColumnIndexed: undefined
};
columnName: undefined,
columnDisplayType: undefined,
isColumnNullable: undefined,
columnLength: undefined,
columnCode: undefined,
columnCodes: undefined,
type: undefined,
isColumnUnique: undefined,
isColumnIndexed: undefined
};
/** Columns to be displayed in columns table. */
displayedColumns: string[] = ['name', 'type', 'length', 'code', 'mandatory', 'unique', 'indexed', 'actions'];
displayedColumns: string[] = [
'name',
'type',
'length',
'code',
'mandatory',
'unique',
'indexed',
'actions'
];
/** Data source for columns table. */
dataSource: MatTableDataSource<any>;
/** Paginator for columns table. */
@@ -81,14 +89,16 @@ export class CreateDataTableComponent implements OnInit, AfterViewInit {
* @param {PopoverService} popoverService PopoverService.
* @param {TranslateService} translateService Translate Service.
*/
constructor(private formBuilder: UntypedFormBuilder,
private systemService: SystemService,
private route: ActivatedRoute,
private router: Router,
private dialog: MatDialog,
private configurationWizardService: ConfigurationWizardService,
private popoverService: PopoverService,
private translateService: TranslateService) {
constructor(
private formBuilder: UntypedFormBuilder,
private systemService: SystemService,
private route: ActivatedRoute,
private router: Router,
private dialog: MatDialog,
private configurationWizardService: ConfigurationWizardService,
private popoverService: PopoverService,
private translateService: TranslateService
) {
this.route.data.subscribe((data: { columnCodes: any }) => {
this.dataForDialog.columnCodes = data.columnCodes;
});
@@ -101,8 +111,8 @@ export class CreateDataTableComponent implements OnInit, AfterViewInit {
this.createDataTableForm();
this.setColumns();
this.dataTableForm.controls.apptableName.valueChanges.subscribe((value: any) => {
this.showEntitySubType = (value === 'm_client');
this.showSavingsSubType = (value === 'm_savings_product');
this.showEntitySubType = value === 'm_client';
this.showSavingsSubType = value === 'm_savings_product';
});
}
@@ -120,10 +130,16 @@ export class CreateDataTableComponent implements OnInit, AfterViewInit {
*/
createDataTableForm() {
this.dataTableForm = this.formBuilder.group({
'datatableName': ['', Validators.required],
'apptableName': ['', Validators.required],
'multiRow': [false],
'entitySubType': ['']
datatableName: [
'',
Validators.required
],
apptableName: [
'',
Validators.required
],
multiRow: [false],
entitySubType: ['']
});
}
@@ -181,7 +197,7 @@ export class CreateDataTableComponent implements OnInit, AfterViewInit {
});
editColumnDialogRef.afterClosed().subscribe((response: any) => {
if (response !== '') {
this.columnData[this.columnData.findIndex(newColumn => newColumn.columnName === column.name)] = {
this.columnData[this.columnData.findIndex((newColumn) => newColumn.columnName === column.name)] = {
columnName: response.name,
columnDisplayType: response.type,
isColumnNullable: !response.mandatory,
@@ -202,7 +218,7 @@ export class CreateDataTableComponent implements OnInit, AfterViewInit {
*/
deleteColumn(column: any) {
const deleteColumnDialogRef = this.dialog.open(DeleteDialogComponent, {
data: { deleteContext: this.translateService.instant('labels.inputs.Column') + ' ' + column.name}
data: { deleteContext: this.translateService.instant('labels.inputs.Column') + ' ' + column.name }
});
deleteColumnDialogRef.afterClosed().subscribe((response: any) => {
if (response.delete) {
@@ -236,10 +252,16 @@ export class CreateDataTableComponent implements OnInit, AfterViewInit {
}
this.systemService.createDataTable(payload).subscribe((response: any) => {
if (this.configurationWizardService.showDatatablesForm === true) {
this.configurationWizardService.showDatatablesForm = false;
this.openDialog();
this.configurationWizardService.showDatatablesForm = false;
this.openDialog();
} else {
this.router.navigate(['../', response.resourceIdentifier], { relativeTo: this.route });
this.router.navigate(
[
'../',
response.resourceIdentifier
],
{ relativeTo: this.route }
);
}
});
}
@@ -251,7 +273,12 @@ export class CreateDataTableComponent implements OnInit, AfterViewInit {
* @param position String.
* @param backdrop Boolean.
*/
showPopover(template: TemplateRef<any>, target: HTMLElement | ElementRef<any>, position: string, backdrop: boolean): void {
showPopover(
template: TemplateRef<any>,
target: HTMLElement | ElementRef<any>,
position: string,
backdrop: boolean
): void {
setTimeout(() => this.popoverService.open(template, target, position, backdrop, {}), 200);
}
@@ -261,7 +288,7 @@ export class CreateDataTableComponent implements OnInit, AfterViewInit {
ngAfterViewInit() {
if (this.configurationWizardService.showDatatablesForm === true) {
setTimeout(() => {
this.showPopover(this.templateDataTableFormRef, this.dataTableFormRef.nativeElement, 'bottom', true);
this.showPopover(this.templateDataTableFormRef, this.dataTableFormRef.nativeElement, 'bottom', true);
});
}
}
@@ -291,22 +318,22 @@ export class CreateDataTableComponent implements OnInit, AfterViewInit {
const continueSetupDialogRef = this.dialog.open(ContinueSetupDialogComponent, {
data: {
stepName: 'data table'
},
}
});
continueSetupDialogRef.afterClosed().subscribe((response: { step: number }) => {
if (response.step === 1) {
this.configurationWizardService.showDatatablesForm = false;
this.router.navigate(['../'], { relativeTo: this.route });
} else if (response.step === 2) {
this.configurationWizardService.showDatatablesForm = true;
this.router.routeReuseStrategy.shouldReuseRoute = () => false;
this.router.onSameUrlNavigation = 'reload';
this.router.navigate(['/organization/data-tables/create']);
} else if (response.step === 3) {
this.configurationWizardService.showDatatablesForm = false;
this.configurationWizardService.showSystemCodes = true;
this.router.navigate(['/system']);
}
this.configurationWizardService.showDatatablesForm = false;
this.router.navigate(['../'], { relativeTo: this.route });
} else if (response.step === 2) {
this.configurationWizardService.showDatatablesForm = true;
this.router.routeReuseStrategy.shouldReuseRoute = () => false;
this.router.onSameUrlNavigation = 'reload';
this.router.navigate(['/organization/data-tables/create']);
} else if (response.step === 3) {
this.configurationWizardService.showDatatablesForm = false;
this.configurationWizardService.showSystemCodes = true;
this.router.navigate(['/system']);
}
});
}
}
@@ -13,7 +13,6 @@ import { SystemService } from '../system.service';
*/
@Injectable()
export class DataTableResolver implements Resolve<Object> {
/**
* @param {SystemService} systemService System service.
*/
@@ -28,6 +27,4 @@ export class DataTableResolver implements Resolve<Object> {
const dataTableName = route.paramMap.get('datatableName');
return this.systemService.getDataTable(dataTableName);
}
}
@@ -1,6 +1,4 @@
export interface DatatableColumn {
columnName: string;
columnDisplayType: string;
isColumnNullable: boolean;
@@ -10,5 +8,4 @@ export interface DatatableColumn {
type: string;
isColumnUnique: boolean;
isColumnIndexed: boolean;
}
@@ -8,9 +8,8 @@ describe('EditDataTableComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ EditDataTableComponent ]
})
.compileComponents();
declarations: [EditDataTableComponent]
}).compileComponents();
}));
beforeEach(() => {
@@ -28,7 +28,6 @@ import { DatatableColumn } from '../datatable-column.model';
styleUrls: ['./edit-data-table.component.scss']
})
export class EditDataTableComponent implements OnInit {
/** Data Table Form. */
dataTableForm: UntypedFormGroup;
/** Data Table Data. */
@@ -43,29 +42,58 @@ export class EditDataTableComponent implements OnInit {
isFormEdited = false;
/** Data Table Changes Data. */
dataTableChangesData: {
apptableName: string,
entitySubType: string,
dropColumns?: { name: string }[],
changeColumns: { name: string, newName?: string, code?: string, newCode?: string, mandatory: boolean, length?: number, unique?: boolean, indexed?: boolean }[],
addColumns?: { name?: string, type?: string, code?: string, mandatory?: boolean, length?: number, unique?: boolean, indexed?: boolean }[]
apptableName: string;
entitySubType: string;
dropColumns?: { name: string }[];
changeColumns: {
name: string;
newName?: string;
code?: string;
newCode?: string;
mandatory: boolean;
length?: number;
unique?: boolean;
indexed?: boolean;
}[];
addColumns?: {
name?: string;
type?: string;
code?: string;
mandatory?: boolean;
length?: number;
unique?: boolean;
indexed?: boolean;
}[];
} = {
apptableName: '', changeColumns: [], addColumns: [], dropColumns: [],
apptableName: '',
changeColumns: [],
addColumns: [],
dropColumns: [],
entitySubType: ''
};
/** Data passed to dialog. */
dataForDialog: DatatableColumn = {
columnName: undefined,
columnDisplayType: undefined,
isColumnNullable: undefined,
columnLength: undefined,
columnCode: undefined,
columnCodes: undefined,
type: undefined,
isColumnUnique: undefined,
isColumnIndexed: undefined
};
columnName: undefined,
columnDisplayType: undefined,
isColumnNullable: undefined,
columnLength: undefined,
columnCode: undefined,
columnCodes: undefined,
type: undefined,
isColumnUnique: undefined,
isColumnIndexed: undefined
};
/** Columns to be displayed in columns table. */
displayedColumns: string[] = ['name', 'type', 'length', 'code', 'mandatory', 'unique', 'indexed', 'actions'];
displayedColumns: string[] = [
'name',
'type',
'length',
'code',
'mandatory',
'unique',
'indexed',
'actions'
];
/** Data source for columns table. */
dataSource: MatTableDataSource<any>;
/** Paginator for columns table. */
@@ -81,16 +109,21 @@ export class EditDataTableComponent implements OnInit {
* @param {FormBuilder} formBuilder Form Builder.
* @param {MatDialog} dialog Dialog Reference.
*/
constructor(private systemService: SystemService,
private formBuilder: UntypedFormBuilder,
private route: ActivatedRoute,
private router: Router,
private dialog: MatDialog,
private translateService: TranslateService) {
this.route.data.subscribe((data: { dataTable: any, columnCodes: any }) => {
constructor(
private systemService: SystemService,
private formBuilder: UntypedFormBuilder,
private route: ActivatedRoute,
private router: Router,
private dialog: MatDialog,
private translateService: TranslateService
) {
this.route.data.subscribe((data: { dataTable: any; columnCodes: any }) => {
this.dataTableData = data.dataTable;
this.dataTableData.columnHeaderData.forEach((item: any) => {
item.system = ['created_at', 'updated_at'].includes(item.columnName);
item.system = [
'created_at',
'updated_at'
].includes(item.columnName);
});
this.columnData = this.dataTableData.columnHeaderData;
this.dataForDialog.columnCodes = data.columnCodes;
@@ -105,7 +138,7 @@ export class EditDataTableComponent implements OnInit {
this.createDataTableForm();
this.setColumns();
this.dataTableForm.controls.apptableName.valueChanges.subscribe((value: any) => {
this.showEntitySubType = (value === 'm_client');
this.showEntitySubType = value === 'm_client';
});
}
@@ -129,7 +162,7 @@ export class EditDataTableComponent implements OnInit {
this.columnData[index].columnDisplayType = this.getColumnType(this.columnData[index].columnDisplayType);
this.columnData[index].type = 'existing';
}
this.showEntitySubType = (this.dataTableData.applicationTableName === 'm_client');
this.showEntitySubType = this.dataTableData.applicationTableName === 'm_client';
}
/**
@@ -137,9 +170,15 @@ export class EditDataTableComponent implements OnInit {
*/
createDataTableForm() {
this.dataTableForm = this.formBuilder.group({
'datatableName': [{ value: this.dataTableData.registeredTableName, disabled: true }, Validators.required],
'apptableName': [{ value: this.dataTableData.applicationTableName, disabled: true }, Validators.required],
'entitySubType': [{ value: this.dataTableData.entitySubType, disabled: true }]
datatableName: [
{ value: this.dataTableData.registeredTableName, disabled: true },
Validators.required
],
apptableName: [
{ value: this.dataTableData.applicationTableName, disabled: true },
Validators.required
],
entitySubType: [{ value: this.dataTableData.entitySubType, disabled: true }]
});
}
@@ -175,11 +214,14 @@ export class EditDataTableComponent implements OnInit {
};
let alreadyExist = false;
this.columnData.forEach((column: DatatableColumn) => {
if ((newColumn.columnName === column.columnName) || (newColumn.columnName === column.columnName
&& newColumn.columnDisplayType === column.columnDisplayType
&& newColumn.isColumnNullable === column.isColumnNullable)) {
alreadyExist = true;
}
if (
newColumn.columnName === column.columnName ||
(newColumn.columnName === column.columnName &&
newColumn.columnDisplayType === column.columnDisplayType &&
newColumn.isColumnNullable === column.isColumnNullable)
) {
alreadyExist = true;
}
});
if (!alreadyExist) {
this.dataTableChangesData.addColumns.push({
@@ -220,10 +262,14 @@ export class EditDataTableComponent implements OnInit {
if (response !== '') {
this.isFormEdited = true;
if (column.type === 'new') {
this.dataTableChangesData.addColumns[this.dataTableChangesData.addColumns
.findIndex(newColumn => newColumn.name === column.columnName
&& newColumn.type === column.columnDisplayType
&& newColumn.mandatory === column.isColumnNullable)] = {
this.dataTableChangesData.addColumns[
this.dataTableChangesData.addColumns.findIndex(
(newColumn) =>
newColumn.name === column.columnName &&
newColumn.type === column.columnDisplayType &&
newColumn.mandatory === column.isColumnNullable
)
] = {
name: response.name,
type: response.type,
code: response.code,
@@ -252,7 +298,9 @@ export class EditDataTableComponent implements OnInit {
type: 'existing'
};
const index = this.dataTableChangesData.changeColumns.findIndex(newColumn => newColumn.newName === column.columnName);
const index = this.dataTableChangesData.changeColumns.findIndex(
(newColumn) => newColumn.newName === column.columnName
);
if (index === -1) {
this.dataTableChangesData.changeColumns.push({
name: column.columnName,
@@ -284,7 +332,7 @@ export class EditDataTableComponent implements OnInit {
*/
deleteColumn(column: any) {
const deleteColumnDialogRef = this.dialog.open(DeleteDialogComponent, {
data: { deleteContext: this.translateService.instant('labels.inputs.Column') + ' ' + column.columnName}
data: { deleteContext: this.translateService.instant('labels.inputs.Column') + ' ' + column.columnName }
});
deleteColumnDialogRef.afterClosed().subscribe((response: any) => {
if (response.delete) {
@@ -296,10 +344,15 @@ export class EditDataTableComponent implements OnInit {
name: column.columnName
});
} else if (column.type === 'new') {
this.dataTableChangesData.addColumns.splice(this.dataTableChangesData.addColumns
.findIndex(newColumn => newColumn.name === column.columnName
&& newColumn.type === column.columnDisplayType
&& newColumn.mandatory === column.isColumnNullable), 1);
this.dataTableChangesData.addColumns.splice(
this.dataTableChangesData.addColumns.findIndex(
(newColumn) =>
newColumn.name === column.columnName &&
newColumn.type === column.columnDisplayType &&
newColumn.mandatory === column.isColumnNullable
),
1
);
}
}
});
@@ -338,10 +391,10 @@ export class EditDataTableComponent implements OnInit {
if (!this.dataTableChangesData.dropColumns || this.dataTableChangesData.dropColumns.length === 0) {
this.dataTableChangesData.dropColumns = undefined;
}
this.systemService.updateDataTable(this.dataTableChangesData, this.dataTableData.registeredTableName)
this.systemService
.updateDataTable(this.dataTableChangesData, this.dataTableData.registeredTableName)
.subscribe((response: any) => {
this.router.navigate(['../'], { relativeTo: this.route });
});
}
}
@@ -8,9 +8,8 @@ describe('ManageDataTablesComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ManageDataTablesComponent ]
})
.compileComponents();
declarations: [ManageDataTablesComponent]
}).compileComponents();
}));
beforeEach(() => {
@@ -21,11 +21,14 @@ import { ConfigurationWizardService } from '../../configuration-wizard/configura
styleUrls: ['./manage-data-tables.component.scss']
})
export class ManageDataTablesComponent implements OnInit, AfterViewInit {
/** Data table data. */
dataTableData: any;
/** Columns to be displayed in manage data tables table. */
displayedColumns: string[] = ['registeredTableName', 'applicationTableName', 'entitySubType'];
displayedColumns: string[] = [
'registeredTableName',
'applicationTableName',
'entitySubType'
];
/** Data source for manage data tables table. */
dataSource: MatTableDataSource<any>;
@@ -50,11 +53,13 @@ export class ManageDataTablesComponent implements OnInit, AfterViewInit {
* @param {ConfigurationWizardService} configurationWizardService ConfigurationWizard Service.
* @param {PopoverService} popoverService PopoverService.
*/
constructor(private route: ActivatedRoute,
private router: Router,
private configurationWizardService: ConfigurationWizardService,
private popoverService: PopoverService) {
this.route.data.subscribe(( data: { dataTables: any }) => {
constructor(
private route: ActivatedRoute,
private router: Router,
private configurationWizardService: ConfigurationWizardService,
private popoverService: PopoverService
) {
this.route.data.subscribe((data: { dataTables: any }) => {
this.dataTableData = data.dataTables;
});
}
@@ -90,7 +95,12 @@ export class ManageDataTablesComponent implements OnInit, AfterViewInit {
* @param position String.
* @param backdrop Boolean.
*/
showPopover(template: TemplateRef<any>, target: HTMLElement | ElementRef<any>, position: string, backdrop: boolean): void {
showPopover(
template: TemplateRef<any>,
target: HTMLElement | ElementRef<any>,
position: string,
backdrop: boolean
): void {
setTimeout(() => this.popoverService.open(template, target, position, backdrop, {}), 200);
}
@@ -100,12 +110,12 @@ export class ManageDataTablesComponent implements OnInit, AfterViewInit {
ngAfterViewInit() {
if (this.configurationWizardService.showDatatablesPage === true) {
setTimeout(() => {
this.showPopover(this.templateCreateDatatableRef, this.createDatatableRef.nativeElement, 'bottom', true);
this.showPopover(this.templateCreateDatatableRef, this.createDatatableRef.nativeElement, 'bottom', true);
});
}
if (this.configurationWizardService.showDatatablesList === true) {
setTimeout(() => {
this.showPopover(this.templateDatatablesList, this.datatablesList.nativeElement, 'top', true);
this.showPopover(this.templateDatatablesList, this.datatablesList.nativeElement, 'top', true);
});
}
}
@@ -13,7 +13,6 @@ import { SystemService } from '../system.service';
*/
@Injectable()
export class ManageDataTablesResolver implements Resolve<Object> {
/**
* @param {SystemService} systemService System service.
*/
@@ -26,5 +25,4 @@ export class ManageDataTablesResolver implements Resolve<Object> {
resolve(): Observable<any> {
return this.systemService.getDataTables();
}
}
@@ -8,9 +8,8 @@ describe('ViewDataTableComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ViewDataTableComponent ]
})
.compileComponents();
declarations: [ViewDataTableComponent]
}).compileComponents();
}));
beforeEach(() => {
@@ -22,13 +22,20 @@ import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.co
styleUrls: ['./view-data-table.component.scss']
})
export class ViewDataTableComponent implements OnInit {
/** Data Table Data */
dataTableData: any;
/** Column Data */
columnsData: any;
/** Columns to be displayed in columns table. */
displayedColumns: string[] = ['columnName', 'columnDisplayType', 'columnLength', 'columnCode', 'isColumnNullable', 'isColumnUnique', 'isColumnIndexed'];
displayedColumns: string[] = [
'columnName',
'columnDisplayType',
'columnLength',
'columnCode',
'isColumnNullable',
'isColumnUnique',
'isColumnIndexed'
];
/** Data source for columns table. */
dataSource: MatTableDataSource<any>;
@@ -45,11 +52,13 @@ export class ViewDataTableComponent implements OnInit {
* @param {MatDialog} dialog Dialog reference.
* @param {TranslateService} translateService Translate Service.
*/
constructor(private route: ActivatedRoute,
private systemService: SystemService,
private router: Router,
private dialog: MatDialog,
private translateService: TranslateService) {
constructor(
private route: ActivatedRoute,
private systemService: SystemService,
private router: Router,
private dialog: MatDialog,
private translateService: TranslateService
) {
this.route.data.subscribe((data: { dataTable: any }) => {
this.dataTableData = data.dataTable;
this.columnsData = this.dataTableData.columnHeaderData;
@@ -79,16 +88,17 @@ export class ViewDataTableComponent implements OnInit {
*/
delete() {
const deleteDataTableDialogRef = this.dialog.open(DeleteDialogComponent, {
data: { deleteContext: this.translateService.instant('labels.inputs.Data Table') + ' ' + this.dataTableData.registeredTableName}
data: {
deleteContext:
this.translateService.instant('labels.inputs.Data Table') + ' ' + this.dataTableData.registeredTableName
}
});
deleteDataTableDialogRef.afterClosed().subscribe((response: any) => {
if (response.delete) {
this.systemService.deleteDataTable(this.dataTableData.registeredTableName)
.subscribe(() => {
this.router.navigate(['/system/data-tables'], { relativeTo: this.route });
});
this.systemService.deleteDataTable(this.dataTableData.registeredTableName).subscribe(() => {
this.router.navigate(['/system/data-tables'], { relativeTo: this.route });
});
}
});
}
}