build: Use prettier for typescript
Stop ignoring .ts files in prettier and fix existing issues.
This commit is contained in:
@@ -8,9 +8,8 @@ describe('AddRoleComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ AddRoleComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [AddRoleComponent]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -15,7 +15,6 @@ import { SystemService } from '../../system.service';
|
||||
styleUrls: ['./add-role.component.scss']
|
||||
})
|
||||
export class AddRoleComponent implements OnInit {
|
||||
|
||||
/** Role form. */
|
||||
roleForm: UntypedFormGroup;
|
||||
|
||||
@@ -25,10 +24,12 @@ export class AddRoleComponent 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
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Creates the role form.
|
||||
@@ -42,8 +43,14 @@ export class AddRoleComponent implements OnInit {
|
||||
*/
|
||||
createRoleForm() {
|
||||
this.roleForm = this.formBuilder.group({
|
||||
'name': ['', Validators.required],
|
||||
'description': ['', Validators.required]
|
||||
name: [
|
||||
'',
|
||||
Validators.required
|
||||
],
|
||||
description: [
|
||||
'',
|
||||
Validators.required
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -52,10 +59,8 @@ export class AddRoleComponent implements OnInit {
|
||||
* if successful redirects back to roles and permission.
|
||||
*/
|
||||
submit() {
|
||||
this.systemService.createRole(this.roleForm.value)
|
||||
.subscribe((response: any) => {
|
||||
this.router.navigate(['../'], { relativeTo: this.route });
|
||||
this.systemService.createRole(this.roleForm.value).subscribe((response: any) => {
|
||||
this.router.navigate(['../'], { relativeTo: this.route });
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,9 +8,8 @@ describe('EditRoleComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ EditRoleComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [EditRoleComponent]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -12,7 +12,7 @@ import { SystemService } from '../../system.service';
|
||||
@Component({
|
||||
selector: 'mifosx-edit-role',
|
||||
templateUrl: './edit-role.component.html',
|
||||
styleUrls: ['./edit-role.component.scss'],
|
||||
styleUrls: ['./edit-role.component.scss']
|
||||
})
|
||||
export class EditRoleComponent implements OnInit {
|
||||
/** Role Form */
|
||||
@@ -50,8 +50,14 @@ export class EditRoleComponent implements OnInit {
|
||||
*/
|
||||
createRoleForm() {
|
||||
this.roleForm = this.formBuilder.group({
|
||||
name: [{ value: this.roleData.name, disabled: true }, Validators.required],
|
||||
description: [this.roleData.description, Validators.required],
|
||||
name: [
|
||||
{ value: this.roleData.name, disabled: true },
|
||||
Validators.required
|
||||
],
|
||||
description: [
|
||||
this.roleData.description,
|
||||
Validators.required
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -8,9 +8,8 @@ describe('RolesAndPermissionsComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ RolesAndPermissionsComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [RolesAndPermissionsComponent]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -21,11 +21,15 @@ import { ConfigurationWizardService } from '../../configuration-wizard/configura
|
||||
styleUrls: ['./roles-and-permissions.component.scss']
|
||||
})
|
||||
export class RolesAndPermissionsComponent implements OnInit, AfterViewInit {
|
||||
|
||||
/** Role data. */
|
||||
roleData: any;
|
||||
/** Columns to be displayed in roles and permissions table. */
|
||||
displayedColumns: string[] = ['name', 'description', 'disabled', 'actions'];
|
||||
displayedColumns: string[] = [
|
||||
'name',
|
||||
'description',
|
||||
'disabled',
|
||||
'actions'
|
||||
];
|
||||
/** Data source for roles and permissions table. */
|
||||
dataSource: MatTableDataSource<any>;
|
||||
|
||||
@@ -49,11 +53,13 @@ export class RolesAndPermissionsComponent 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: { roles: any }) => {
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private configurationWizardService: ConfigurationWizardService,
|
||||
private popoverService: PopoverService
|
||||
) {
|
||||
this.route.data.subscribe((data: { roles: any }) => {
|
||||
this.roleData = data.roles;
|
||||
});
|
||||
}
|
||||
@@ -97,7 +103,12 @@ export class RolesAndPermissionsComponent 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);
|
||||
}
|
||||
|
||||
@@ -112,7 +123,12 @@ export class RolesAndPermissionsComponent implements OnInit, AfterViewInit {
|
||||
}
|
||||
if (this.configurationWizardService.showRolesandPermissionList === true) {
|
||||
setTimeout(() => {
|
||||
this.showPopover(this.templateTableRolesandPermissions, this.tableRolesandPermissions.nativeElement, 'top', true);
|
||||
this.showPopover(
|
||||
this.templateTableRolesandPermissions,
|
||||
this.tableRolesandPermissions.nativeElement,
|
||||
'top',
|
||||
true
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -136,5 +152,4 @@ export class RolesAndPermissionsComponent implements OnInit, AfterViewInit {
|
||||
this.configurationWizardService.showRolesandPermission = true;
|
||||
this.router.navigate(['/system']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import { SystemService } from '../system.service';
|
||||
*/
|
||||
@Injectable()
|
||||
export class RolesAndPermissionsResolver implements Resolve<Object> {
|
||||
|
||||
/**
|
||||
* @param {SystemService} systemService System service.
|
||||
*/
|
||||
@@ -26,5 +25,4 @@ export class RolesAndPermissionsResolver implements Resolve<Object> {
|
||||
resolve(): Observable<any> {
|
||||
return this.systemService.getRoles();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,9 +8,8 @@ describe('ViewRoleComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ ViewRoleComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [ViewRoleComponent]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -21,7 +21,6 @@ import { EnableDialogComponent } from '../../../shared/enable-dialog/enable-dial
|
||||
styleUrls: ['./view-role.component.scss']
|
||||
})
|
||||
export class ViewRoleComponent implements OnInit {
|
||||
|
||||
/** Role Permissions Data */
|
||||
rolePermissionService: any;
|
||||
/** Stores the current grouping */
|
||||
@@ -46,11 +45,11 @@ export class ViewRoleComponent implements OnInit {
|
||||
backupform: UntypedFormGroup;
|
||||
/** Temporarily stores Permission data */
|
||||
tempPermissionUIData: {
|
||||
permissions: { code: string }[]
|
||||
permissions: { code: string }[];
|
||||
}[];
|
||||
/** Stores permissions */
|
||||
permissions: {
|
||||
permissions: { code: string, id: number }[]
|
||||
permissions: { code: string; id: number }[];
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -62,12 +61,14 @@ export class ViewRoleComponent implements OnInit {
|
||||
* @param {MatDialog} dialog Shared Dialog Boxes.
|
||||
* @param {TranslateService} translateService Translate Service.
|
||||
*/
|
||||
constructor(private route: ActivatedRoute,
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private systemService: SystemService,
|
||||
private router: Router,
|
||||
private formBuilder: UntypedFormBuilder,
|
||||
private translateService: TranslateService,
|
||||
public dialog: MatDialog) {
|
||||
public dialog: MatDialog
|
||||
) {
|
||||
this.route.data.subscribe((data: { roledetails: any }) => {
|
||||
this.rolePermissionService = data.roledetails;
|
||||
});
|
||||
@@ -94,17 +95,24 @@ export class ViewRoleComponent implements OnInit {
|
||||
*/
|
||||
createForm() {
|
||||
this.formGroup = this.formBuilder.group({
|
||||
roster: this.formBuilder.array(this.rolePermissionService.permissionUsageData.map((elem: any) => this.createMemberGroup(elem)))
|
||||
roster: this.formBuilder.array(
|
||||
this.rolePermissionService.permissionUsageData.map((elem: any) => this.createMemberGroup(elem))
|
||||
)
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
createMemberGroup(permission: any): UntypedFormGroup {
|
||||
return this.formBuilder.group({
|
||||
...permission,
|
||||
...{
|
||||
code: [permission.code, Validators.required],
|
||||
selected: [{ value: permission.selected, disabled: true }, Validators.required]
|
||||
code: [
|
||||
permission.code,
|
||||
Validators.required
|
||||
],
|
||||
selected: [
|
||||
{ value: permission.selected, disabled: true },
|
||||
Validators.required
|
||||
]
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -113,9 +121,11 @@ export class ViewRoleComponent implements OnInit {
|
||||
* Groups the permissions based on rules
|
||||
*/
|
||||
groupRules() {
|
||||
this.tempPermissionUIData = [{
|
||||
permissions: []
|
||||
}];
|
||||
this.tempPermissionUIData = [
|
||||
{
|
||||
permissions: []
|
||||
}
|
||||
];
|
||||
for (const i in this.rolePermissionService.permissionUsageData) {
|
||||
if (this.rolePermissionService.permissionUsageData[i]) {
|
||||
if (this.rolePermissionService.permissionUsageData[i].grouping !== this.currentGrouping) {
|
||||
@@ -123,7 +133,11 @@ export class ViewRoleComponent implements OnInit {
|
||||
this.groupings.push(this.currentGrouping);
|
||||
this.tempPermissionUIData[this.currentGrouping] = { permissions: [] };
|
||||
}
|
||||
const temp = { code: this.rolePermissionService.permissionUsageData[i].code, id: i, selected: this.rolePermissionService.permissionUsageData[i].selected };
|
||||
const temp = {
|
||||
code: this.rolePermissionService.permissionUsageData[i].code,
|
||||
id: i,
|
||||
selected: this.rolePermissionService.permissionUsageData[i].selected
|
||||
};
|
||||
this.tempPermissionUIData[this.currentGrouping].permissions.push(temp);
|
||||
}
|
||||
}
|
||||
@@ -210,7 +224,7 @@ export class ViewRoleComponent implements OnInit {
|
||||
const permissionData = {
|
||||
permissions: {}
|
||||
};
|
||||
for (let i = 0; i < value.length; i++ ) {
|
||||
for (let i = 0; i < value.length; i++) {
|
||||
data[value[i].code] = value[i].selected;
|
||||
}
|
||||
permissionData.permissions = data;
|
||||
@@ -253,12 +267,10 @@ export class ViewRoleComponent implements OnInit {
|
||||
});
|
||||
deleteRoleDialogRef.afterClosed().subscribe((response: any) => {
|
||||
if (response.delete) {
|
||||
this.systemService.deleteRole(this.roleId)
|
||||
.subscribe(() => {
|
||||
this.router.navigate(['/system/roles-and-permissions']);
|
||||
});
|
||||
this.systemService.deleteRole(this.roleId).subscribe(() => {
|
||||
this.router.navigate(['/system/roles-and-permissions']);
|
||||
});
|
||||
} else {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -272,12 +284,10 @@ export class ViewRoleComponent implements OnInit {
|
||||
});
|
||||
enableRoleDialogRef.afterClosed().subscribe((response: any) => {
|
||||
if (response.enable) {
|
||||
this.systemService.enableRole(this.roleId)
|
||||
.subscribe(() => {
|
||||
this.router.navigate(['/system/roles-and-permissions']);
|
||||
});
|
||||
this.systemService.enableRole(this.roleId).subscribe(() => {
|
||||
this.router.navigate(['/system/roles-and-permissions']);
|
||||
});
|
||||
} else {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -291,14 +301,11 @@ export class ViewRoleComponent implements OnInit {
|
||||
});
|
||||
deleteRoleDialogRef.afterClosed().subscribe((response: any) => {
|
||||
if (response.disable) {
|
||||
this.systemService.disableRole(this.roleId)
|
||||
.subscribe(() => {
|
||||
this.router.navigate(['/system/roles-and-permissions']);
|
||||
});
|
||||
this.systemService.disableRole(this.roleId).subscribe(() => {
|
||||
this.router.navigate(['/system/roles-and-permissions']);
|
||||
});
|
||||
} else {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,19 +13,17 @@ import { SystemService } from '../../system.service';
|
||||
*/
|
||||
@Injectable()
|
||||
export class ViewRoleResolver implements Resolve<Object> {
|
||||
/**
|
||||
* @param {SystemService} systemService System service.
|
||||
*/
|
||||
constructor(private systemService: SystemService) {}
|
||||
|
||||
/**
|
||||
* @param {SystemService} systemService System service.
|
||||
*/
|
||||
constructor(private systemService: SystemService) { }
|
||||
|
||||
/**
|
||||
* Returns the roles and permissions data.
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
resolve(route: ActivatedRouteSnapshot): Observable<any> {
|
||||
const id = route.paramMap.get('id');
|
||||
return this.systemService.getRole(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the roles and permissions data.
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
resolve(route: ActivatedRouteSnapshot): Observable<any> {
|
||||
const id = route.paramMap.get('id');
|
||||
return this.systemService.getRole(id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user