build: Use prettier for typescript
Stop ignoring .ts files in prettier and fix existing issues.
This commit is contained in:
+2
-3
@@ -8,9 +8,8 @@ describe('DatatableMultiRowComponent', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ DatatableMultiRowComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [DatatableMultiRowComponent]
|
||||
}).compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
+32
-23
@@ -22,7 +22,6 @@ import * as _ from 'lodash';
|
||||
styleUrls: ['./datatable-multi-row.component.scss']
|
||||
})
|
||||
export class DatatableMultiRowComponent implements OnInit, OnDestroy, OnChanges {
|
||||
|
||||
SELECT_NAME_FIELD = 'select';
|
||||
/** Data Object */
|
||||
@Input() dataObject: any;
|
||||
@@ -55,15 +54,17 @@ export class DatatableMultiRowComponent implements OnInit, OnDestroy, OnChanges
|
||||
* @param {MatDialog} dialog Mat Dialog.
|
||||
* @param {Datatables} datatables Datatable utils
|
||||
*/
|
||||
constructor(private route: ActivatedRoute,
|
||||
private dateUtils: Dates,
|
||||
private systemService: SystemService,
|
||||
private settingsService: SettingsService,
|
||||
private dialog: MatDialog,
|
||||
private datatables: Datatables,
|
||||
private dateFormat: DateFormatPipe,
|
||||
private dateTimeFormat: DatetimeFormatPipe,
|
||||
private numberFormat: DecimalPipe) { }
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private dateUtils: Dates,
|
||||
private systemService: SystemService,
|
||||
private settingsService: SettingsService,
|
||||
private dialog: MatDialog,
|
||||
private datatables: Datatables,
|
||||
private dateFormat: DateFormatPipe,
|
||||
private dateTimeFormat: DatetimeFormatPipe,
|
||||
private numberFormat: DecimalPipe
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Fetches data table name from route params.
|
||||
@@ -117,7 +118,7 @@ export class DatatableMultiRowComponent implements OnInit, OnDestroy, OnChanges
|
||||
}
|
||||
this.isSelected = false;
|
||||
this.isLoading = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,7 +128,11 @@ export class DatatableMultiRowComponent implements OnInit, OnDestroy, OnChanges
|
||||
let dataTableEntryObject: any = { locale: this.settingsService.language.code };
|
||||
const dateTransformColumns: string[] = [];
|
||||
const columns = this.datatables.filterSystemColumns(this.dataObject.columnHeaders);
|
||||
const formfields: FormfieldBase[] = this.datatables.getFormfields(columns, dateTransformColumns, dataTableEntryObject);
|
||||
const formfields: FormfieldBase[] = this.datatables.getFormfields(
|
||||
columns,
|
||||
dateTransformColumns,
|
||||
dataTableEntryObject
|
||||
);
|
||||
const data = {
|
||||
title: 'Add ' + this.datatableName + ' for ' + this.entityType,
|
||||
formfields: formfields
|
||||
@@ -136,12 +141,17 @@ export class DatatableMultiRowComponent implements OnInit, OnDestroy, OnChanges
|
||||
addDialogRef.afterClosed().subscribe((response: any) => {
|
||||
if (response.data) {
|
||||
dateTransformColumns.forEach((column) => {
|
||||
response.data.value[column] = this.dateUtils.formatDate(response.data.value[column], dataTableEntryObject.dateFormat);
|
||||
response.data.value[column] = this.dateUtils.formatDate(
|
||||
response.data.value[column],
|
||||
dataTableEntryObject.dateFormat
|
||||
);
|
||||
});
|
||||
dataTableEntryObject = { ...response.data.value, ...dataTableEntryObject };
|
||||
this.systemService.addEntityDatatableEntry(this.entityId, this.datatableName, dataTableEntryObject).subscribe((result: any) => {
|
||||
this.getData();
|
||||
});
|
||||
this.systemService
|
||||
.addEntityDatatableEntry(this.entityId, this.datatableName, dataTableEntryObject)
|
||||
.subscribe((result: any) => {
|
||||
this.getData();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -179,14 +189,14 @@ export class DatatableMultiRowComponent implements OnInit, OnDestroy, OnChanges
|
||||
this.datatableData.splice(index, 1);
|
||||
this.dataTableRef.renderRows();
|
||||
this.selection = new SelectionModel(true, []);
|
||||
this.isSelected = (this.selection.selected.length > 0);
|
||||
this.isSelected = this.selection.selected.length > 0;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
} else {
|
||||
this.selection = new SelectionModel(true, []);
|
||||
this.isSelected = (this.selection.selected.length > 0);
|
||||
this.isSelected = this.selection.selected.length > 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -219,11 +229,11 @@ export class DatatableMultiRowComponent implements OnInit, OnDestroy, OnChanges
|
||||
/** Whether the number of selected elements matches the total number of rows. */
|
||||
isAllSelected() {
|
||||
const numSelected = this.selection.selected;
|
||||
return (this.datatableData.length === numSelected);
|
||||
return this.datatableData.length === numSelected;
|
||||
}
|
||||
|
||||
isAnySelected() {
|
||||
return (this.selection.selected && this.selection.selected.length > 0);
|
||||
return this.selection.selected && this.selection.selected.length > 0;
|
||||
}
|
||||
|
||||
/** Selects all rows if they are not all selected; otherwise clear selection. */
|
||||
@@ -233,12 +243,12 @@ export class DatatableMultiRowComponent implements OnInit, OnDestroy, OnChanges
|
||||
} else {
|
||||
this.selection = new SelectionModel(true, []);
|
||||
}
|
||||
this.isSelected = (this.selection.selected.length > 0);
|
||||
this.isSelected = this.selection.selected.length > 0;
|
||||
}
|
||||
|
||||
itemToggle(data: any): void {
|
||||
this.selection.toggle(data);
|
||||
this.isSelected = (this.selection.selected.length > 0);
|
||||
this.isSelected = this.selection.selected.length > 0;
|
||||
}
|
||||
|
||||
/** The label for the checkbox on the passed row */
|
||||
@@ -259,5 +269,4 @@ export class DatatableMultiRowComponent implements OnInit, OnDestroy, OnChanges
|
||||
getInputName(attr: string): string {
|
||||
return this.datatables.getName(attr);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-3
@@ -8,9 +8,8 @@ describe('DatatableSingleRowComponent', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ DatatableSingleRowComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [DatatableSingleRowComponent]
|
||||
}).compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
+49
-26
@@ -15,7 +15,6 @@ import { SystemService } from 'app/system/system.service';
|
||||
styleUrls: ['./datatable-single-row.component.scss']
|
||||
})
|
||||
export class DatatableSingleRowComponent implements OnInit {
|
||||
|
||||
@Input() dataObject: any;
|
||||
@Input() entityId: string;
|
||||
@Input() entityType: string;
|
||||
@@ -28,12 +27,14 @@ export class DatatableSingleRowComponent implements OnInit {
|
||||
* @param {SettingsService} settingsService Settings Service
|
||||
* @param {Datatables} datatables Datatable utils
|
||||
*/
|
||||
constructor(private route: ActivatedRoute,
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private dateUtils: Dates,
|
||||
private dialog: MatDialog,
|
||||
private settingsService: SettingsService,
|
||||
private datatables: Datatables,
|
||||
private systemService: SystemService) { }
|
||||
private systemService: SystemService
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.params.subscribe((routeParams: any) => {
|
||||
@@ -47,7 +48,11 @@ export class DatatableSingleRowComponent implements OnInit {
|
||||
};
|
||||
const dateTransformColumns: string[] = [];
|
||||
const columns = this.datatables.filterSystemColumns(this.dataObject.columnHeaders);
|
||||
const formfields: FormfieldBase[] = this.datatables.getFormfields(columns, dateTransformColumns, dataTableEntryObject);
|
||||
const formfields: FormfieldBase[] = this.datatables.getFormfields(
|
||||
columns,
|
||||
dateTransformColumns,
|
||||
dataTableEntryObject
|
||||
);
|
||||
const data = {
|
||||
title: 'Add ' + this.datatableName + ' for ' + this.entityType,
|
||||
formfields: formfields
|
||||
@@ -56,14 +61,19 @@ export class DatatableSingleRowComponent implements OnInit {
|
||||
addDialogRef.afterClosed().subscribe((response: any) => {
|
||||
if (response.data) {
|
||||
dateTransformColumns.forEach((column) => {
|
||||
response.data.value[column] = this.dateUtils.formatDate(response.data.value[column], dataTableEntryObject.dateFormat);
|
||||
response.data.value[column] = this.dateUtils.formatDate(
|
||||
response.data.value[column],
|
||||
dataTableEntryObject.dateFormat
|
||||
);
|
||||
});
|
||||
dataTableEntryObject = { ...response.data.value, ...dataTableEntryObject };
|
||||
this.systemService.addEntityDatatableEntry(this.entityId, this.datatableName, dataTableEntryObject).subscribe(() => {
|
||||
this.systemService.getEntityDatatable(this.entityId, this.datatableName).subscribe((dataObject: any) => {
|
||||
this.dataObject = dataObject;
|
||||
this.systemService
|
||||
.addEntityDatatableEntry(this.entityId, this.datatableName, dataTableEntryObject)
|
||||
.subscribe(() => {
|
||||
this.systemService.getEntityDatatable(this.entityId, this.datatableName).subscribe((dataObject: any) => {
|
||||
this.dataObject = dataObject;
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -74,34 +84,49 @@ export class DatatableSingleRowComponent implements OnInit {
|
||||
};
|
||||
const dateTransformColumns: string[] = [];
|
||||
const columns = this.datatables.filterSystemColumns(this.dataObject.columnHeaders);
|
||||
let formfields: FormfieldBase[] = this.datatables.getFormfields(columns, dateTransformColumns, dataTableEntryObject);
|
||||
let formfields: FormfieldBase[] = this.datatables.getFormfields(
|
||||
columns,
|
||||
dateTransformColumns,
|
||||
dataTableEntryObject
|
||||
);
|
||||
formfields = formfields.map((formfield: FormfieldBase, index: number) => {
|
||||
if (formfield.controlType === 'datepicker') {
|
||||
formfield.value = (this.dataObject.data[0].row[columns[index].idx]) ? this.dateUtils.parseDate(this.dataObject.data[0].row[columns[index].idx]) : '';
|
||||
formfield.value = this.dataObject.data[0].row[columns[index].idx]
|
||||
? this.dateUtils.parseDate(this.dataObject.data[0].row[columns[index].idx])
|
||||
: '';
|
||||
} else if (formfield.controlType === 'datetimepicker') {
|
||||
formfield.value = (this.dataObject.data[0].row[columns[index].idx]) ? this.dateUtils.parseDatetime(this.dataObject.data[0].row[columns[index].idx]) : '';
|
||||
formfield.value = this.dataObject.data[0].row[columns[index].idx]
|
||||
? this.dateUtils.parseDatetime(this.dataObject.data[0].row[columns[index].idx])
|
||||
: '';
|
||||
} else {
|
||||
formfield.value = (this.dataObject.data[0].row[columns[index].idx]) ? this.dataObject.data[0].row[columns[index].idx] : '';
|
||||
formfield.value = this.dataObject.data[0].row[columns[index].idx]
|
||||
? this.dataObject.data[0].row[columns[index].idx]
|
||||
: '';
|
||||
}
|
||||
return formfield;
|
||||
});
|
||||
const data = {
|
||||
title: 'Edit ' + this.datatableName + ' for ' + this.entityType,
|
||||
formfields: formfields,
|
||||
layout: {addButtonText: 'Save'}
|
||||
layout: { addButtonText: 'Save' }
|
||||
};
|
||||
const editDialogRef = this.dialog.open(FormDialogComponent, { data, width: '50rem' });
|
||||
editDialogRef.afterClosed().subscribe((response: any) => {
|
||||
if (response.data) {
|
||||
dateTransformColumns.forEach((column) => {
|
||||
response.data.value[column] = this.dateUtils.formatDate(response.data.value[column], dataTableEntryObject.dateFormat);
|
||||
response.data.value[column] = this.dateUtils.formatDate(
|
||||
response.data.value[column],
|
||||
dataTableEntryObject.dateFormat
|
||||
);
|
||||
});
|
||||
dataTableEntryObject = { ...response.data.value, ...dataTableEntryObject };
|
||||
this.systemService.editEntityDatatableEntry(this.entityId, this.datatableName, dataTableEntryObject).subscribe(() => {
|
||||
this.systemService.getEntityDatatable(this.entityId, this.datatableName).subscribe((dataObject: any) => {
|
||||
this.dataObject = dataObject;
|
||||
this.systemService
|
||||
.editEntityDatatableEntry(this.entityId, this.datatableName, dataTableEntryObject)
|
||||
.subscribe(() => {
|
||||
this.systemService.getEntityDatatable(this.entityId, this.datatableName).subscribe((dataObject: any) => {
|
||||
this.dataObject = dataObject;
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -112,13 +137,12 @@ export class DatatableSingleRowComponent implements OnInit {
|
||||
});
|
||||
deleteDataTableDialogRef.afterClosed().subscribe((response: any) => {
|
||||
if (response.delete) {
|
||||
this.systemService.deleteDatatableContent(this.entityId, this.datatableName)
|
||||
.subscribe(() => {
|
||||
this.systemService.getEntityDatatable(this.entityId, this.datatableName).subscribe((dataObject: any) => {
|
||||
this.dataObject = dataObject;
|
||||
});
|
||||
this.systemService.deleteDatatableContent(this.entityId, this.datatableName).subscribe(() => {
|
||||
this.systemService.getEntityDatatable(this.entityId, this.datatableName).subscribe((dataObject: any) => {
|
||||
this.dataObject = dataObject;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -167,5 +191,4 @@ export class DatatableSingleRowComponent implements OnInit {
|
||||
openSite(siteUrl: string) {
|
||||
window.open(siteUrl, '_blank');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,9 +8,8 @@ describe('EntityDatatableTabComponent', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ EntityDatatableTabComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [EntityDatatableTabComponent]
|
||||
}).compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -6,12 +6,10 @@ import { Component, Input } from '@angular/core';
|
||||
styleUrls: ['./entity-datatable-tab.component.scss']
|
||||
})
|
||||
export class EntityDatatableTabComponent {
|
||||
|
||||
@Input() multiRowDatatableFlag = false;
|
||||
@Input() entityDatatable: any;
|
||||
@Input() entityType: string;
|
||||
@Input() entityId: string;
|
||||
|
||||
constructor() { }
|
||||
|
||||
constructor() {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user