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
@@ -8,9 +8,8 @@ describe('CreateUserComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ CreateUserComponent ]
})
.compileComponents();
declarations: [CreateUserComponent]
}).compileComponents();
}));
beforeEach(() => {
@@ -1,6 +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 { UntypedFormGroup, UntypedFormBuilder, UntypedFormControl, Validators } from '@angular/forms';
import { Router, ActivatedRoute } from '@angular/router';
import { MatDialog } from '@angular/material/dialog';
@@ -24,7 +23,6 @@ import { ContinueSetupDialogComponent } from 'app/configuration-wizard/continue-
styleUrls: ['./create-user.component.scss']
})
export class CreateUserComponent implements OnInit, AfterViewInit {
/** User form. */
userForm: UntypedFormGroup;
/** Offices data. */
@@ -48,20 +46,20 @@ export class CreateUserComponent implements OnInit, AfterViewInit {
* @param {ConfigurationWizardService} configurationWizardService ConfigurationWizard Service.
* @param {PopoverService} popoverService PopoverService.
*/
constructor(private formBuilder: UntypedFormBuilder,
private usersService: UsersService,
private route: ActivatedRoute,
private router: Router,
private popoverService: PopoverService,
private configurationWizardService: ConfigurationWizardService,
private dialog: MatDialog,
private passwordsUtility: PasswordsUtility) {
this.route.data.subscribe((data: {
usersTemplate: any
}) => {
this.officesData = data.usersTemplate.allowedOffices;
this.rolesData = data.usersTemplate.availableRoles;
});
constructor(
private formBuilder: UntypedFormBuilder,
private usersService: UsersService,
private route: ActivatedRoute,
private router: Router,
private popoverService: PopoverService,
private configurationWizardService: ConfigurationWizardService,
private dialog: MatDialog,
private passwordsUtility: PasswordsUtility
) {
this.route.data.subscribe((data: { usersTemplate: any }) => {
this.officesData = data.usersTemplate.allowedOffices;
this.rolesData = data.usersTemplate.availableRoles;
});
}
/**
@@ -77,17 +75,45 @@ export class CreateUserComponent implements OnInit, AfterViewInit {
* Creates the user form.
*/
createUserForm() {
this.userForm = this.formBuilder.group({
'username': ['', Validators.required],
'email': ['', [Validators.required, Validators.email]],
'firstname': ['', [Validators.required, Validators.pattern('(^[A-z]).*')]],
'lastname': ['', [Validators.required, Validators.pattern('(^[A-z]).*')]],
'sendPasswordToEmail': [true],
'passwordNeverExpires': [false],
'officeId': ['', Validators.required],
'staffId': [''],
'roles': ['', Validators.required]
}, { validator: confirmPasswordValidator });
this.userForm = this.formBuilder.group(
{
username: [
'',
Validators.required
],
email: [
'',
[
Validators.required,
Validators.email
]
],
firstname: [
'',
[
Validators.required,
Validators.pattern('(^[A-z]).*')]
],
lastname: [
'',
[
Validators.required,
Validators.pattern('(^[A-z]).*')]
],
sendPasswordToEmail: [true],
passwordNeverExpires: [false],
officeId: [
'',
Validators.required
],
staffId: [''],
roles: [
'',
Validators.required
]
},
{ validator: confirmPasswordValidator }
);
}
/**
@@ -110,10 +136,18 @@ export class CreateUserComponent implements OnInit, AfterViewInit {
if (sendPasswordToEmail) {
this.userForm.removeControl('password');
this.userForm.removeControl('repeatPassword');
this.userForm.get('email').setValidators([Validators.required, Validators.email]);
this.userForm.get('email').setValidators([
Validators.required,
Validators.email
]);
} else {
this.userForm.addControl('password', new UntypedFormControl('', this.passwordsUtility.getPasswordValidators()));
this.userForm.addControl('repeatPassword', new UntypedFormControl('', [Validators.required, this.passwordsUtility.confirmPassword('password')]));
this.userForm.addControl(
'repeatPassword',
new UntypedFormControl('', [
Validators.required,
this.passwordsUtility.confirmPassword('password')])
);
this.userForm.get('email').setValidators([Validators.email]);
}
this.userForm.get('email').updateValueAndValidity();
@@ -134,7 +168,13 @@ export class CreateUserComponent implements OnInit, AfterViewInit {
this.configurationWizardService.showUsersForm = false;
this.openDialog();
} else {
this.router.navigate(['../', response.resourceId], { relativeTo: this.route });
this.router.navigate(
[
'../',
response.resourceId
],
{ relativeTo: this.route }
);
}
});
}
@@ -146,7 +186,12 @@ export class CreateUserComponent 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);
}
@@ -155,9 +200,9 @@ export class CreateUserComponent implements OnInit, AfterViewInit {
*/
ngAfterViewInit() {
if (this.configurationWizardService.showUsersForm === true) {
setTimeout(() => {
setTimeout(() => {
this.showPopover(this.templateUserFormRef, this.userFormRef.nativeElement, 'top', true);
});
});
}
}
@@ -186,22 +231,22 @@ export class CreateUserComponent implements OnInit, AfterViewInit {
const continueSetupDialogRef = this.dialog.open(ContinueSetupDialogComponent, {
data: {
stepName: 'user'
},
}
});
continueSetupDialogRef.afterClosed().subscribe((response: { step: number }) => {
if (response.step === 1) {
this.configurationWizardService.showUsersForm = false;
this.router.navigate(['../'], { relativeTo: this.route });
} else if (response.step === 2) {
this.configurationWizardService.showUsersForm = true;
this.router.routeReuseStrategy.shouldReuseRoute = () => false;
this.router.onSameUrlNavigation = 'reload';
this.router.navigate(['/organization/users/create']);
} else if (response.step === 3) {
this.configurationWizardService.showUsersForm = false;
this.configurationWizardService.showMakerCheckerTable = true;
this.router.navigate(['/system']);
}
this.configurationWizardService.showUsersForm = false;
this.router.navigate(['../'], { relativeTo: this.route });
} else if (response.step === 2) {
this.configurationWizardService.showUsersForm = true;
this.router.routeReuseStrategy.shouldReuseRoute = () => false;
this.router.onSameUrlNavigation = 'reload';
this.router.navigate(['/organization/users/create']);
} else if (response.step === 3) {
this.configurationWizardService.showUsersForm = false;
this.configurationWizardService.showMakerCheckerTable = true;
this.router.navigate(['/system']);
}
});
}
}
@@ -8,9 +8,8 @@ describe('EditUserComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ EditUserComponent ]
})
.compileComponents();
declarations: [EditUserComponent]
}).compileComponents();
}));
beforeEach(() => {
+50 -19
View File
@@ -10,12 +10,11 @@ import { UsersService } from '../users.service';
* Edit User Component.
*/
@Component({
selector: 'mifosx-edit-user',
templateUrl: './edit-user.component.html',
styleUrls: ['./edit-user.component.scss']
selector: 'mifosx-edit-user',
templateUrl: './edit-user.component.html',
styleUrls: ['./edit-user.component.scss']
})
export class EditUserComponent implements OnInit {
/** User Data */
userData: any;
/** Offices Data */
@@ -34,11 +33,13 @@ export class EditUserComponent implements OnInit {
* @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation.
*/
constructor(private formBuilder: UntypedFormBuilder,
private usersService: UsersService,
private route: ActivatedRoute,
private router: Router) {
this.route.data.subscribe((data: { user: any, usersTemplate: any }) => {
constructor(
private formBuilder: UntypedFormBuilder,
private usersService: UsersService,
private route: ActivatedRoute,
private router: Router
) {
this.route.data.subscribe((data: { user: any; usersTemplate: any }) => {
this.userData = data.user;
this.officesData = data.usersTemplate.allowedOffices;
this.rolesData = data.usersTemplate.availableRoles;
@@ -56,14 +57,39 @@ export class EditUserComponent implements OnInit {
createEditUserForm() {
const staffId = this.userData.staff ? this.userData.staff.id : null;
this.editUserForm = this.formBuilder.group({
'username': [this.userData.username, Validators.required],
'email': [this.userData.email, [Validators.required, Validators.email]],
'firstname': [this.userData.firstname, [Validators.required, Validators.pattern('(^[A-z]).*')]],
'lastname': [this.userData.lastname, [Validators.required, Validators.pattern('(^[A-z]).*')]],
'passwordNeverExpires': [this.userData.passwordNeverExpires],
'officeId': [this.userData.officeId, Validators.required],
'staffId': [staffId],
'roles': [this.userData.selectedRoles.map((role: any) => role.id), Validators.required]
username: [
this.userData.username,
Validators.required
],
email: [
this.userData.email,
[
Validators.required,
Validators.email
]
],
firstname: [
this.userData.firstname,
[
Validators.required,
Validators.pattern('(^[A-z]).*')]
],
lastname: [
this.userData.lastname,
[
Validators.required,
Validators.pattern('(^[A-z]).*')]
],
passwordNeverExpires: [this.userData.passwordNeverExpires],
officeId: [
this.userData.officeId,
Validators.required
],
staffId: [staffId],
roles: [
this.userData.selectedRoles.map((role: any) => role.id),
Validators.required
]
});
}
@@ -85,8 +111,13 @@ export class EditUserComponent implements OnInit {
submit() {
const editedUser = this.editUserForm.value;
this.usersService.editUser(this.userData.id, editedUser).subscribe((response: any) => {
this.router.navigate(['../../', response.resourceId], { relativeTo: this.route });
this.router.navigate(
[
'../../',
response.resourceId
],
{ relativeTo: this.route }
);
});
}
}
-1
View File
@@ -13,7 +13,6 @@ import { UsersService } from './users.service';
*/
@Injectable()
export class UserResolver implements Resolve<Object> {
/**
* @param {UsersService} usersService Users service.
*/
+2 -1
View File
@@ -63,6 +63,7 @@ const routes: Routes = [
]
}
])
];
/**
@@ -79,4 +80,4 @@ const routes: Routes = [
UserResolver
]
})
export class UsersRoutingModule { }
export class UsersRoutingModule {}
-2
View File
@@ -13,7 +13,6 @@ import { UsersService } from './users.service';
*/
@Injectable()
export class UsersTemplateResolver implements Resolve<Object> {
/**
* @param {UsersService} usersService Users service.
*/
@@ -26,5 +25,4 @@ export class UsersTemplateResolver implements Resolve<Object> {
resolve(): Observable<any> {
return this.usersService.getUsersTemplate();
}
}
+2 -3
View File
@@ -8,9 +8,8 @@ describe('UsersComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ UsersComponent ]
})
.compileComponents();
declarations: [UsersComponent]
}).compileComponents();
}));
beforeEach(() => {
+20 -10
View File
@@ -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 { ActivatedRoute, Router } from '@angular/router';
import { MatPaginator } from '@angular/material/paginator';
import { MatSort } from '@angular/material/sort';
@@ -21,11 +21,15 @@ import { ConfigurationWizardService } from '../configuration-wizard/configuratio
styleUrls: ['./users.component.scss']
})
export class UsersComponent implements OnInit, AfterViewInit {
/** Users data. */
usersData: any;
/** Columns to be displayed in users table. */
displayedColumns: string[] = ['firstname', 'lastname', 'email', 'officeName'];
displayedColumns: string[] = [
'firstname',
'lastname',
'email',
'officeName'
];
/** Data source for users table. */
dataSource: MatTableDataSource<any>;
@@ -50,11 +54,13 @@ export class UsersComponent 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: { users: any }) => {
constructor(
private route: ActivatedRoute,
private router: Router,
private configurationWizardService: ConfigurationWizardService,
private popoverService: PopoverService
) {
this.route.data.subscribe((data: { users: any }) => {
this.usersData = data.users;
});
}
@@ -90,7 +96,12 @@ export class UsersComponent 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);
}
@@ -130,5 +141,4 @@ export class UsersComponent implements OnInit, AfterViewInit {
this.configurationWizardService.showRolesandPermissionList = true;
this.router.navigate(['/system/roles-and-permissions']);
}
}
+1 -1
View File
@@ -28,4 +28,4 @@ import { EditUserComponent } from './edit-user/edit-user.component';
EditUserComponent
]
})
export class UsersModule { }
export class UsersModule {}
-2
View File
@@ -13,7 +13,6 @@ import { UsersService } from './users.service';
*/
@Injectable()
export class UsersResolver implements Resolve<Object> {
/**
* @param {UsersService} usersService Users service.
*/
@@ -26,5 +25,4 @@ export class UsersResolver implements Resolve<Object> {
resolve(): Observable<any> {
return this.usersService.getUsers();
}
}
+2 -6
View File
@@ -12,11 +12,10 @@ import { Observable } from 'rxjs';
providedIn: 'root'
})
export class UsersService {
/**
* @param {HttpClient} http Http Client to send requests.
*/
constructor(private http: HttpClient) { }
constructor(private http: HttpClient) {}
/**
* @returns {Observable<any>} Users data
@@ -80,10 +79,7 @@ export class UsersService {
* @returns {Observable<any>} Staff data.
*/
getStaff(officeId: any): Observable<any> {
const httpParams = new HttpParams()
.set('officeId', officeId.toString())
.set('status', 'all');
const httpParams = new HttpParams().set('officeId', officeId.toString()).set('status', 'all');
return this.http.get('/staff', { params: httpParams });
}
}
@@ -8,9 +8,8 @@ describe('ViewUserComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ViewUserComponent ]
})
.compileComponents();
declarations: [ViewUserComponent]
}).compileComponents();
}));
beforeEach(() => {
+10 -11
View File
@@ -19,7 +19,6 @@ import { ChangePasswordDialogComponent } from 'app/shared/change-password-dialog
styleUrls: ['./view-user.component.scss']
})
export class ViewUserComponent {
/** User Data. */
userData: any;
@@ -30,10 +29,12 @@ export class ViewUserComponent {
* @param {Router} router Router for navigation.
* @param {MatDialog} dialog Dialog reference.
*/
constructor(private usersService: UsersService,
private route: ActivatedRoute,
private router: Router,
private dialog: MatDialog) {
constructor(
private usersService: UsersService,
private route: ActivatedRoute,
private router: Router,
private dialog: MatDialog
) {
this.route.data.subscribe((data: { user: any }) => {
this.userData = data.user;
});
@@ -48,10 +49,9 @@ export class ViewUserComponent {
});
deleteUserDialogRef.afterClosed().subscribe((response: any) => {
if (response.delete) {
this.usersService.deleteUser(this.userData.id)
.subscribe(() => {
this.router.navigate(['/appusers']);
});
this.usersService.deleteUser(this.userData.id).subscribe(() => {
this.router.navigate(['/appusers']);
});
}
});
}
@@ -69,12 +69,11 @@ export class ViewUserComponent {
const password = response.password;
const repeatPassword = response.repeatPassword;
const firstname = this.userData.firstname;
const data = {password: password, repeatPassword: repeatPassword, firstname: firstname};
const data = { password: password, repeatPassword: repeatPassword, firstname: firstname };
this.usersService.changePassword(this.userData.id, data).subscribe(() => {
this.router.navigate(['/appusers']);
});
}
});
}
}