Skip to content
Snippets Groups Projects
Commit 8d1495bc authored by Maël AUDEON's avatar Maël AUDEON
Browse files

[TECH] Improve code quality

parent 25aae93d
No related branches found
No related tags found
1 merge request!1Feature/design/1
...@@ -5,8 +5,7 @@ ...@@ -5,8 +5,7 @@
<div class="header-informations"> <div class="header-informations">
<div class="controls"> <div class="controls">
<vitamui-common-search-bar <vitamui-common-search-bar
name="group-attribution-search" placeholder="Filtrer par nom ou description"
placeholder="Filtrer par nom ..."
i18-placeholder="Filter group filter@@filterGroup" i18-placeholder="Filter group filter@@filterGroup"
(search)="onSearch($event)"> (search)="onSearch($event)">
</vitamui-common-search-bar> </vitamui-common-search-bar>
......
...@@ -72,7 +72,7 @@ export class GroupAttributionComponent implements OnInit { ...@@ -72,7 +72,7 @@ export class GroupAttributionComponent implements OnInit {
selectedGroupName: string; selectedGroupName: string;
CUSTOMER_ACTIVE_PROFILE_GROUPS_INDEX = 2; CUSTOMER_ACTIVE_PROFILE_GROUPS_INDEX = 2;
profileGroupChange(event: Group) { public profileGroupChange(event: Group): void {
this.user.groupId = event.id; this.user.groupId = event.id;
this.selectedGroupName = event.name; this.selectedGroupName = event.name;
} }
...@@ -82,15 +82,14 @@ export class GroupAttributionComponent implements OnInit { ...@@ -82,15 +82,14 @@ export class GroupAttributionComponent implements OnInit {
public dialogRef: MatDialogRef<GroupAttributionComponent>, public dialogRef: MatDialogRef<GroupAttributionComponent>,
@Inject(MAT_DIALOG_DATA) public data: any) { } @Inject(MAT_DIALOG_DATA) public data: any) { }
ngOnInit() { public ngOnInit(): void {
this.user = this.data[0]; this.user = this.data[0];
this.resetActiveGroups(); this.resetActiveGroups();
} }
resetActiveGroups() { public resetActiveGroups(): void {
this.activeGroups = this.data[this.CUSTOMER_ACTIVE_PROFILE_GROUPS_INDEX]; this.activeGroups = this.data[this.CUSTOMER_ACTIVE_PROFILE_GROUPS_INDEX];
this.activeGroups.sort((a, b) => a.name.toUpperCase() < b.name.toUpperCase() ? -1 : this.activeGroups.sort((a, b) => a.name.toUpperCase() < b.name.toUpperCase() ? -1 : 1);
a.name.toUpperCase() > b.name.toUpperCase() ? 1 : 0);
if (this.data[1]) { if (this.data[1]) {
this.selectedGroupName = this.data[1].name; this.selectedGroupName = this.data[1].name;
const selectedGroup = this.activeGroups.find((group) => group.id === this.data[1].id); const selectedGroup = this.activeGroups.find((group) => group.id === this.data[1].id);
...@@ -100,13 +99,13 @@ export class GroupAttributionComponent implements OnInit { ...@@ -100,13 +99,13 @@ export class GroupAttributionComponent implements OnInit {
} }
} }
removeGroup() { public removeGroup(): void {
this.selectedGroupName = null; this.selectedGroupName = null;
this.user.groupId = null; this.user.groupId = null;
this.unselectAllProfileGroups(); this.unselectAllProfileGroups();
} }
updateGroup(groupId: string, groupName: string, groupLevel: string, collapseDirective: CollapseDirective) { public updateGroup(groupId: string, groupName: string, groupLevel: string, collapseDirective: CollapseDirective): void {
this.selectedGroupName = groupName; this.selectedGroupName = groupName;
this.user.groupId = groupId; this.user.groupId = groupId;
this.user.level = groupLevel; this.user.level = groupLevel;
...@@ -118,11 +117,11 @@ export class GroupAttributionComponent implements OnInit { ...@@ -118,11 +117,11 @@ export class GroupAttributionComponent implements OnInit {
} }
} }
unselectAllProfileGroups() { public unselectAllProfileGroups(): void {
this.activeGroups.forEach((group) => group.selected = false); this.activeGroups.forEach((group) => group.selected = false);
} }
saveUserUpdate() { public saveUserUpdate(): void {
this.userService.patch({ id: this.user.id, groupId: this.user.groupId }) this.userService.patch({ id: this.user.id, groupId: this.user.groupId })
.subscribe( .subscribe(
() => this.dialogRef.close(true), () => this.dialogRef.close(true),
...@@ -131,12 +130,12 @@ export class GroupAttributionComponent implements OnInit { ...@@ -131,12 +130,12 @@ export class GroupAttributionComponent implements OnInit {
}); });
} }
onCancel() { public onCancel(): void {
this.unselectAllProfileGroups(); this.unselectAllProfileGroups();
this.dialogRef.close(); this.dialogRef.close();
} }
onSearch(text?: string) { public onSearch(text?: string): void {
this.resetActiveGroups(); this.resetActiveGroups();
if (text !== null && text.length > 0) { if (text !== null && text.length > 0) {
this.activeGroups = this.activeGroups.filter((group) => group.name.includes(text) || group.description.includes(text)); this.activeGroups = this.activeGroups.filter((group) => group.name.includes(text) || group.description.includes(text));
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment