Skip to content
Snippets Groups Projects

Resolve "[Admin] - Gestion des utilisateurs : éviter que le premier item de la liste soit sélectionné quand on clique sur un champ employeur ou fonction"

Files
5
@@ -23,6 +23,7 @@ export class ManageJobsComponent implements OnInit {
public validatedJobs: Job[] = [];
public unvalidatedJobs: Job[] = [];
public jobsGroups: JobGroup[] = [];
public jobsGroupsList: JobGroup[] = [];
public deleteModalOpened = false;
public validatedJobsName: string[] = [];
public mergeJobModalOpened = false;
@@ -264,7 +265,7 @@ export class ManageJobsComponent implements OnInit {
if (arg.oldValue === arg.newValue) {
return;
} else {
this.adminService.editJob(arg.data._id, arg.data.name, arg.data.hasPersonalOffer).subscribe(() => {
this.adminService.updateJob(arg.data._id, arg.data).subscribe(() => {
this.notificationService.showSuccess("L'opération a réussie.", '');
this.findValidatedJobs();
this.findUnvalidatedJobs();
@@ -348,7 +349,8 @@ export class ManageJobsComponent implements OnInit {
this.jobsGroupsName = [];
this.adminService.getJobsGroupsWithJobs().subscribe((jobsGrps) => {
this.jobsGroups = jobsGrps;
jobsGrps.forEach((jobsGroup) => {
this.jobsGroupsList = [{ name: '' }, ...jobsGrps];
this.jobsGroupsList.forEach((jobsGroup) => {
this.jobsGroupsName.push(jobsGroup.name);
});
});
@@ -390,8 +392,7 @@ export class ManageJobsComponent implements OnInit {
public onJobsGroupChange(arg): void {
const selectedJob = this.validatedJobs.find((job) => job._id === arg.data._id);
const selectedJobsGroup = this.jobsGroups.find((jobsGroup) => jobsGroup.name === arg.newValue);
const selectedJobsGroup = this.jobsGroupsList.find((jobsGroup) => jobsGroup.name === arg.newValue);
// The column field is the jobsGroup.name text, we manually assign in selectedJob the full jobsGroup object to be consistent
selectedJob.jobsGroup = { ...selectedJobsGroup };
@@ -399,9 +400,13 @@ export class ManageJobsComponent implements OnInit {
this.getJobsGroupsWithJobs();
this.newJobsGroupForm.reset();
this.notificationService.showSuccess(
`Le groupe de fonctions ${selectedJobsGroup.name} a bien été attribuée à la fonction ${arg.data.name}.`
);
if (selectedJob.jobsGroup?.name === '') {
this.notificationService.showSuccess(`Le groupe de fonctions a bien été enlevé.`);
} else {
this.notificationService.showSuccess(
`Le groupe de fonctions ${selectedJobsGroup.name} a bien été attribuée à la fonction ${arg.data.name}.`
);
}
});
return;
Loading