build: Use prettier for typescript
Stop ignoring .ts files in prettier and fix existing issues.
This commit is contained in:
@@ -13,7 +13,6 @@ import { SystemService } from '../system.service';
|
||||
*/
|
||||
@Injectable()
|
||||
export class CodeResolver implements Resolve<Object> {
|
||||
|
||||
/**
|
||||
* @param {SystemService} systemService System service.
|
||||
*/
|
||||
@@ -27,5 +26,4 @@ export class CodeResolver implements Resolve<Object> {
|
||||
const id = route.paramMap.get('id');
|
||||
return this.systemService.getCode(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,9 +8,8 @@ describe('CodesComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ CodesComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [CodesComponent]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -15,11 +15,13 @@ import { ConfigurationWizardService } from '../../configuration-wizard/configura
|
||||
styleUrls: ['./codes.component.scss']
|
||||
})
|
||||
export class CodesComponent implements OnInit, AfterViewInit {
|
||||
|
||||
/** Codes data. */
|
||||
codesData: any;
|
||||
/** Columns to be displayed in codes table. */
|
||||
displayedColumns: string[] = ['name', 'systemDefined'];
|
||||
displayedColumns: string[] = [
|
||||
'name',
|
||||
'systemDefined'
|
||||
];
|
||||
/** Data source for codes table. */
|
||||
dataSource: MatTableDataSource<any>;
|
||||
|
||||
@@ -44,11 +46,13 @@ export class CodesComponent 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: { codes: any }) => {
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private configurationWizardService: ConfigurationWizardService,
|
||||
private popoverService: PopoverService
|
||||
) {
|
||||
this.route.data.subscribe((data: { codes: any }) => {
|
||||
this.codesData = data.codes;
|
||||
});
|
||||
}
|
||||
@@ -84,7 +88,12 @@ export class CodesComponent 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);
|
||||
}
|
||||
|
||||
@@ -123,5 +132,4 @@ export class CodesComponent implements OnInit, AfterViewInit {
|
||||
this.configurationWizardService.showSystemCodes = true;
|
||||
this.router.navigate(['/system']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import { SystemService } from '../system.service';
|
||||
*/
|
||||
@Injectable()
|
||||
export class CodesResolver implements Resolve<Object> {
|
||||
|
||||
/**
|
||||
* @param {SystemService} systemService System service.
|
||||
*/
|
||||
@@ -26,5 +25,4 @@ export class CodesResolver implements Resolve<Object> {
|
||||
resolve(): Observable<any> {
|
||||
return this.systemService.getCodes();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,9 +8,8 @@ describe('CreateCodeComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ CreateCodeComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [CreateCodeComponent]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/** Angular Imports */
|
||||
import { Component, OnInit, TemplateRef, ElementRef, ViewChild, AfterViewInit } from '@angular/core';
|
||||
import { Component, OnInit, TemplateRef, ElementRef, ViewChild, AfterViewInit } from '@angular/core';
|
||||
import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms';
|
||||
import { Router, ActivatedRoute } from '@angular/router';
|
||||
|
||||
@@ -15,7 +15,6 @@ import { ConfigurationWizardService } from '../../../configuration-wizard/config
|
||||
styleUrls: ['./create-code.component.scss']
|
||||
})
|
||||
export class CreateCodeComponent implements OnInit, AfterViewInit {
|
||||
|
||||
/** Code form. */
|
||||
codeForm: UntypedFormGroup;
|
||||
|
||||
@@ -32,12 +31,14 @@ export class CreateCodeComponent implements OnInit, AfterViewInit {
|
||||
* @param {ConfigurationWizardService} configurationWizardService ConfigurationWizard Service.
|
||||
* @param {PopoverService} popoverService PopoverService.
|
||||
*/
|
||||
constructor(private formBuilder: UntypedFormBuilder,
|
||||
private systemService: SystemService,
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private configurationWizardService: ConfigurationWizardService,
|
||||
private popoverService: PopoverService) { }
|
||||
constructor(
|
||||
private formBuilder: UntypedFormBuilder,
|
||||
private systemService: SystemService,
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private configurationWizardService: ConfigurationWizardService,
|
||||
private popoverService: PopoverService
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Creates the code form.
|
||||
@@ -51,7 +52,10 @@ export class CreateCodeComponent implements OnInit, AfterViewInit {
|
||||
*/
|
||||
createCodeForm() {
|
||||
this.codeForm = this.formBuilder.group({
|
||||
'name': ['', Validators.required]
|
||||
name: [
|
||||
'',
|
||||
Validators.required
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -60,15 +64,20 @@ export class CreateCodeComponent implements OnInit, AfterViewInit {
|
||||
* if successful redirects to view created code.
|
||||
*/
|
||||
submit() {
|
||||
this.systemService.createCode(this.codeForm.value)
|
||||
.subscribe((response: any) => {
|
||||
if (this.configurationWizardService.showSystemCodesForm === true) {
|
||||
this.configurationWizardService.showSystemCodesForm = false;
|
||||
this.configurationWizardService.showRolesandPermission = true;
|
||||
this.router.navigate(['/system']);
|
||||
} else {
|
||||
this.router.navigate(['../', response.resourceId], { relativeTo: this.route });
|
||||
}
|
||||
this.systemService.createCode(this.codeForm.value).subscribe((response: any) => {
|
||||
if (this.configurationWizardService.showSystemCodesForm === true) {
|
||||
this.configurationWizardService.showSystemCodesForm = false;
|
||||
this.configurationWizardService.showRolesandPermission = true;
|
||||
this.router.navigate(['/system']);
|
||||
} else {
|
||||
this.router.navigate(
|
||||
[
|
||||
'../',
|
||||
response.resourceId
|
||||
],
|
||||
{ relativeTo: this.route }
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -79,7 +88,12 @@ export class CreateCodeComponent 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,9 +8,8 @@ describe('EditCodeComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ EditCodeComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [EditCodeComponent]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -15,7 +15,6 @@ import { SystemService } from '../../system.service';
|
||||
styleUrls: ['./edit-code.component.scss']
|
||||
})
|
||||
export class EditCodeComponent implements OnInit {
|
||||
|
||||
/** Code Form */
|
||||
codeForm: UntypedFormGroup;
|
||||
/** Code Data */
|
||||
@@ -28,10 +27,12 @@ export class EditCodeComponent implements OnInit {
|
||||
* @param {ActivatedRoute} route Activated Route.
|
||||
* @param {Router} router Router for navigation.
|
||||
*/
|
||||
constructor(private formBuilder: UntypedFormBuilder,
|
||||
private systemService: SystemService,
|
||||
private route: ActivatedRoute,
|
||||
private router: Router) {
|
||||
constructor(
|
||||
private formBuilder: UntypedFormBuilder,
|
||||
private systemService: SystemService,
|
||||
private route: ActivatedRoute,
|
||||
private router: Router
|
||||
) {
|
||||
this.route.data.subscribe((data: { code: any }) => {
|
||||
this.codeData = data.code;
|
||||
});
|
||||
@@ -49,7 +50,10 @@ export class EditCodeComponent implements OnInit {
|
||||
*/
|
||||
createCodeForm() {
|
||||
this.codeForm = this.formBuilder.group({
|
||||
'name': [this.codeData.name, Validators.required]
|
||||
name: [
|
||||
this.codeData.name,
|
||||
Validators.required
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -58,10 +62,14 @@ export class EditCodeComponent implements OnInit {
|
||||
* if successful redirects to view updated code.
|
||||
*/
|
||||
submit() {
|
||||
this.systemService.updateCode(this.codeForm.value, this.codeData.id)
|
||||
.subscribe((response: any) => {
|
||||
this.router.navigate(['../../', response.resourceId], { relativeTo: this.route });
|
||||
});
|
||||
this.systemService.updateCode(this.codeForm.value, this.codeData.id).subscribe((response: any) => {
|
||||
this.router.navigate(
|
||||
[
|
||||
'../../',
|
||||
response.resourceId
|
||||
],
|
||||
{ relativeTo: this.route }
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import { SystemService } from '../../system.service';
|
||||
*/
|
||||
@Injectable()
|
||||
export class CodeValuesResolver implements Resolve<Object> {
|
||||
|
||||
/**
|
||||
* @param {SystemService} systemService System service.
|
||||
*/
|
||||
@@ -27,5 +26,4 @@ export class CodeValuesResolver implements Resolve<Object> {
|
||||
const codeId = route.paramMap.get('id');
|
||||
return this.systemService.getCodeValues(codeId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,9 +8,8 @@ describe('ViewCodeComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ ViewCodeComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [ViewCodeComponent]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -20,7 +20,6 @@ import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.co
|
||||
styleUrls: ['./view-code.component.scss']
|
||||
})
|
||||
export class ViewCodeComponent implements OnInit {
|
||||
|
||||
/** Code Data */
|
||||
codeData: any;
|
||||
/** Code Values Data */
|
||||
@@ -39,13 +38,15 @@ export class ViewCodeComponent implements OnInit {
|
||||
* @param {MatDialog} dialog Dialog reference.
|
||||
* @param {TranslateService} translateService Translate Service.
|
||||
*/
|
||||
constructor(private route: ActivatedRoute,
|
||||
private systemService: SystemService,
|
||||
private router: Router,
|
||||
private formBuilder: UntypedFormBuilder,
|
||||
private dialog: MatDialog,
|
||||
private translateService: TranslateService) {
|
||||
this.route.data.subscribe((data: { code: any, codeValues: any }) => {
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private systemService: SystemService,
|
||||
private router: Router,
|
||||
private formBuilder: UntypedFormBuilder,
|
||||
private dialog: MatDialog,
|
||||
private translateService: TranslateService
|
||||
) {
|
||||
this.route.data.subscribe((data: { code: any; codeValues: any }) => {
|
||||
this.codeData = data.code;
|
||||
this.codeValuesData = data.codeValues;
|
||||
});
|
||||
@@ -82,7 +83,7 @@ export class ViewCodeComponent implements OnInit {
|
||||
*/
|
||||
createCodeValuesForm() {
|
||||
this.codeValuesForm = this.formBuilder.group({
|
||||
'codeValues': this.formBuilder.array([])
|
||||
codeValues: this.formBuilder.array([])
|
||||
});
|
||||
}
|
||||
|
||||
@@ -101,10 +102,16 @@ export class ViewCodeComponent implements OnInit {
|
||||
*/
|
||||
createCodeValuesRow(codeValue?: any): UntypedFormGroup {
|
||||
return this.formBuilder.group({
|
||||
'name': [{ value: codeValue ? codeValue.name : '', disabled: true }, Validators.required],
|
||||
'description': [{ value: codeValue ? codeValue.description : '', disabled: true }],
|
||||
'position': [{ value: codeValue ? codeValue.position : 0, disabled: true }, Validators.required],
|
||||
'isActive': [{ value: codeValue ? codeValue.active : false, disabled: true }]
|
||||
name: [
|
||||
{ value: codeValue ? codeValue.name : '', disabled: true },
|
||||
Validators.required
|
||||
],
|
||||
description: [{ value: codeValue ? codeValue.description : '', disabled: true }],
|
||||
position: [
|
||||
{ value: codeValue ? codeValue.position : 0, disabled: true },
|
||||
Validators.required
|
||||
],
|
||||
isActive: [{ value: codeValue ? codeValue.active : false, disabled: true }]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -114,12 +121,11 @@ export class ViewCodeComponent implements OnInit {
|
||||
*/
|
||||
deleteCodeValue(index: number) {
|
||||
const codeValueId = this.codeValuesData[index].id;
|
||||
this.systemService.deleteCodeValue(this.codeData.id, codeValueId)
|
||||
.subscribe((response: any) => {
|
||||
this.codeValuesData.splice(index, 1);
|
||||
this.codeValues.removeAt(index);
|
||||
this.codeValueRowStatus.splice(index, 1);
|
||||
});
|
||||
this.systemService.deleteCodeValue(this.codeData.id, codeValueId).subscribe((response: any) => {
|
||||
this.codeValuesData.splice(index, 1);
|
||||
this.codeValues.removeAt(index);
|
||||
this.codeValueRowStatus.splice(index, 1);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,8 +142,10 @@ export class ViewCodeComponent implements OnInit {
|
||||
* @param {number} index Index of the row.
|
||||
*/
|
||||
updateCodeValue(index: number) {
|
||||
const updatedCodeValue: { name: string, description: string, position: number, isActive: boolean } = this.codeValues.at(index).value;
|
||||
this.systemService.updateCodeValue(this.codeData.id, this.codeValuesData[index].id, updatedCodeValue)
|
||||
const updatedCodeValue: { name: string; description: string; position: number; isActive: boolean } =
|
||||
this.codeValues.at(index).value;
|
||||
this.systemService
|
||||
.updateCodeValue(this.codeData.id, this.codeValuesData[index].id, updatedCodeValue)
|
||||
.subscribe((response: any) => {
|
||||
this.codeValues.at(index).disable();
|
||||
this.codeValueRowStatus[index] = 'disabled';
|
||||
@@ -150,14 +158,13 @@ export class ViewCodeComponent implements OnInit {
|
||||
*/
|
||||
delete() {
|
||||
const deleteCodeDialogRef = this.dialog.open(DeleteDialogComponent, {
|
||||
data: { deleteContext: this.translateService.instant('labels.inputs.Code') + ' ' + this.codeData.name}
|
||||
data: { deleteContext: this.translateService.instant('labels.inputs.Code') + ' ' + this.codeData.name }
|
||||
});
|
||||
deleteCodeDialogRef.afterClosed().subscribe((response: any) => {
|
||||
if (response.delete) {
|
||||
this.systemService.deleteCode(this.codeData.id)
|
||||
.subscribe(() => {
|
||||
this.router.navigate(['/system/codes']);
|
||||
});
|
||||
this.systemService.deleteCode(this.codeData.id).subscribe(() => {
|
||||
this.router.navigate(['/system/codes']);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -181,20 +188,20 @@ export class ViewCodeComponent implements OnInit {
|
||||
* @param {number} index Index of the row.
|
||||
*/
|
||||
addCodeValue(index: number) {
|
||||
const newCodeValue: { name: string, description: string, position: string, isActive: boolean } = this.codeValues.at(index).value;
|
||||
this.systemService.createCodeValue(this.codeData.id, newCodeValue)
|
||||
.subscribe((response: any) => {
|
||||
this.codeValues.at(index).disable();
|
||||
this.codeValueRowStatus[index] = 'disabled';
|
||||
this.codeValuesData.push({
|
||||
id: response.subResourceId,
|
||||
name: this.codeValues.at(index).get('name').value,
|
||||
description: this.codeValues.at(index).get('description').value,
|
||||
position: this.codeValues.at(index).get('position').value,
|
||||
isActive: this.codeValues.at(index).get('isActive').value
|
||||
});
|
||||
this.codeValues.at(index).markAsPristine();
|
||||
const newCodeValue: { name: string; description: string; position: string; isActive: boolean } =
|
||||
this.codeValues.at(index).value;
|
||||
this.systemService.createCodeValue(this.codeData.id, newCodeValue).subscribe((response: any) => {
|
||||
this.codeValues.at(index).disable();
|
||||
this.codeValueRowStatus[index] = 'disabled';
|
||||
this.codeValuesData.push({
|
||||
id: response.subResourceId,
|
||||
name: this.codeValues.at(index).get('name').value,
|
||||
description: this.codeValues.at(index).get('description').value,
|
||||
position: this.codeValues.at(index).get('position').value,
|
||||
isActive: this.codeValues.at(index).get('isActive').value
|
||||
});
|
||||
this.codeValues.at(index).markAsPristine();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -205,5 +212,4 @@ export class ViewCodeComponent implements OnInit {
|
||||
this.codeValues.at(index).enable();
|
||||
this.codeValueRowStatus[index] = 'edit';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user