Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • web-et-numerique/factory/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_client
1 result
Show changes
Commits on Source (16)
Showing
with 25902 additions and 61 deletions
......@@ -53,3 +53,7 @@ api/db.json
# Documentation generated with compodoc
documentation
CHANGELOG.md
package-lock.json
## Description du problème
_Donnez une briève description du problème_
## L'environnement
#### Utilisez vous l'application sur :
- [ ] Mobile
- [ ] Ordinateur
##### En cas de mobile
###### Quel type de mobile utilisez-vous?
- [ ] Android
- [ ] Iphone
###### Quel navigateur utilisez-vous?
- [ ] Chrome
- [ ] Safari
- [ ] Autre
##### En cas d'ordinateur
###### Quel navigateur utilisez-vous?
- [ ] Chrome
- [ ] Firefox
- [ ] Safari
- [ ] Autre
## Le bug
#### Quelles sont les étapes qui ont menées au problème?
_Donnez une description des étapes, il est fortemment conseillé de l'accompagner par des captures d'écran_
#### Quel est le comportement obtenu?
_Donnez une description du comportement obtenu, il est fortemment conseillé de l'accompagner par des captures d'écran_
#### Quel est le comportement attendu?
_Donnez une description du comportement attendu_
......@@ -48,8 +48,6 @@ All notable changes to this project will be documented in this file. See [standa
* **orientation:** issue on height ([87f8ea5](https://forge.grandlyon.com/web-et-numerique/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_client/commit/87f8ea5c59c2dbadb963d7e2fa5359375d47a2d7))
* **orientation:** map height ([cd75ee2](https://forge.grandlyon.com/web-et-numerique/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_client/commit/cd75ee22bee5e241624cd200b6e066794faa1634))
### [1.16.2](https://forge.grandlyon.com/web-et-numerique/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_client/compare/v1.16.1...v1.16.2) (2022-03-31)
### Bug Fixes
......
This diff is collapsed.
......@@ -18,3 +18,11 @@
.incomplete {
color: $red;
}
.isOutdated {
color: $red;
}
.structure-updated-at {
text-align: right;
}
......@@ -10,6 +10,16 @@ import { AdminRoutingModule } from './admin-routing.module';
import { AgGridModule } from 'ag-grid-angular';
import { DeleteUserComponent } from './components/manage-users/delete-user/delete-user.component';
import { AdministredStructuresComponent } from './components/manage-users/administred-structures/administred-structures.component';
import { ManageJobsComponent } from './components/manage-jobs/manage-jobs.component';
import { ManageEmployersComponent } from './components/manage-employers/manage-employers.component';
import { JobRenderer } from './components/manage-users/job-renderer/job-renderer.component';
import { EmployerRenderer } from './components/manage-users/employer-renderer/employer-renderer.component';
import { AttachedUsersComponent } from './components/manage-jobs/attached-users/attached-users.component';
import { DeleteJobComponent } from './components/manage-jobs/delete-job/delete-job.component';
import { DeleteEmployerComponent } from './components/manage-employers/delete-employer/delete-employer.component';
import { ValidateJobComponent } from './components/manage-jobs/validate-job/validate-job.component';
import { ValidateEmployerComponent } from './components/manage-employers/validate-employer/validate-employer.component';
import { JobPersonalOffer } from './components/manage-jobs/jobPersonalOffer/job-personal-offer';
@NgModule({
declarations: [
......@@ -18,8 +28,18 @@ import { AdministredStructuresComponent } from './components/manage-users/admini
NewsletterUsersComponent,
AdminStructuresListComponent,
ManageUsersComponent,
JobRenderer,
EmployerRenderer,
JobPersonalOffer,
ValidateJobComponent,
ValidateEmployerComponent,
DeleteUserComponent,
DeleteJobComponent,
DeleteEmployerComponent,
AdministredStructuresComponent,
AttachedUsersComponent,
ManageJobsComponent,
ManageEmployersComponent,
],
imports: [
CommonModule,
......
<button type="button" (click)="onClick()">{{ label }}</button>
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { DeleteEmployerComponent } from './delete-employer.component';
describe('DeleteUserComponent', () => {
let component: DeleteEmployerComponent;
let fixture: ComponentFixture<DeleteEmployerComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [DeleteEmployerComponent],
}).compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(DeleteEmployerComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component } from '@angular/core';
@Component({
selector: 'app-delete-employer',
templateUrl: './delete-employer.component.html',
})
export class DeleteEmployerComponent {
public params: any;
public label: string;
public agInit(params: any): void {
this.params = params;
this.label = this.params.label || null;
}
public onClick(): void {
if (this.params.onClick instanceof Function) {
this.params.onClick(this.params);
}
}
}
<div fxLayout="column" fxLayoutGap="5px" fxLayoutAlign="center center" class="userBlock">
<h3>
Gestion des employeurs
<span *ngIf="unvalidatedEmployers && validatedEmployers">
({{ unvalidatedEmployers.length + validatedEmployers.length }})
</span>
</h3>
</div>
<div class="tables-list">
<div>
<h3 class="title" *ngIf="unvalidatedEmployers">Employeurs non validées ({{ unvalidatedEmployers.length }})</h3>
<ag-grid-angular
*ngIf="unvalidatedEmployers"
class="ag-theme-alpine user-table"
[rowData]="unvalidatedEmployers"
[columnDefs]="unvalidEmployersColumnDefs"
rowSelection="multiple"
domLayout="autoHeight"
[getRowHeight]="getRowHeight"
[defaultColDef]="unvalidColDef"
[frameworkComponents]="frameworkComponents"
>
</ag-grid-angular>
</div>
<div>
<h3 class="title" *ngIf="validatedEmployers">Employeurs validées ({{ validatedEmployers.length }})</h3>
<ag-grid-angular
*ngIf="validatedEmployers"
class="ag-theme-alpine user-table"
[rowData]="validatedEmployers"
[columnDefs]="columnDefs"
rowSelection="multiple"
domLayout="autoHeight"
[getRowHeight]="getRowHeight"
[defaultColDef]="defaultColDef"
[frameworkComponents]="frameworkComponents"
>
</ag-grid-angular>
</div>
<div>
<h3 class="title" *ngIf="validatedEmployers">Créer un nouvel employeur</h3>
<form [formGroup]="newEmployerForm" (ngSubmit)="onSubmit()">
<input type="text" maxlength="100" formControlName="employer" class="form-input" />
<button type="submit" [ngClass]="{ invalid: !newEmployerForm.valid }">Créer</button>
</form>
</div>
</div>
<app-modal-confirmation
*ngIf="employerToDelete"
[openned]="deleteModalOpenned"
[content]="'Voulez-vous vraiment supprimer cet employeur&nbsp;? (' + employerToDelete.name + ')'"
(closed)="deleteEmployer(employerToDelete, $event)"
></app-modal-confirmation>
<app-modal-confirmation
*ngIf="mergeOpe.newEmployer"
[openned]="mergeEmployerModalOpenned"
[content]="'Voulez-vous vraiment fusionner cet employeur avec&nbsp;: ' + mergeOpe.newEmployer.name"
(closed)="mergeEmployer(mergeOpe.newEmployer._id, mergeOpe.formerId, $event, contextRow)"
></app-modal-confirmation>
@import '../../../../assets/scss/color';
.user-table {
width: 100%;
height: 100%;
text-overflow: clip;
}
.tables-list {
height: 100%;
width: 80%;
display: flex;
flex-direction: column;
margin-left: 10%;
margin-bottom: 2%;
}
app-delete-user {
text-align: center;
}
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { NavigationButtonsComponent } from './navigation-buttons.component';
import { ManageEmployersComponent } from './manage-employers.component';
describe('NavigationButtonsComponent', () => {
let component: NavigationButtonsComponent;
let fixture: ComponentFixture<NavigationButtonsComponent>;
describe('ManageEmployersComponent', () => {
let component: ManageEmployersComponent;
let fixture: ComponentFixture<ManageEmployersComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ NavigationButtonsComponent ]
declarations: [ ManageEmployersComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(NavigationButtonsComponent);
fixture = TestBed.createComponent(ManageEmployersComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
......
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Employer } from '../../../models/employer.model';
import { NotificationService } from '../../../services/notification.service';
import { AdminService } from '../../services/admin.service';
import { AttachedUsersComponent } from '../manage-jobs/attached-users/attached-users.component';
import { EmployerRenderer } from '../manage-users/employer-renderer/employer-renderer.component';
import { DeleteEmployerComponent } from './delete-employer/delete-employer.component';
import { ValidateEmployerComponent } from './validate-employer/validate-employer.component';
@Component({
selector: 'app-admin-manage-employers',
templateUrl: './manage-employers.component.html',
styleUrls: ['./manage-employers.component.scss'],
})
export class ManageEmployersComponent implements OnInit {
public newEmployerForm: FormGroup;
public validatedEmployers: Employer[] = [];
public unvalidatedEmployers: Employer[] = [];
public deleteModalOpenned = false;
public validatedEmployersName: String[] = [];
public mergeEmployerModalOpenned = false;
public employerToDelete: Employer = null;
public mergeOpe: any = {
newEmployer: {
name: null,
validated: false,
},
formerId: '',
};
public contextRow: any;
public columnDefs;
public unvalidEmployersColumnDefs;
public frameworkComponents;
public defaultColDef = {
editable: true,
sortable: true,
flex: 1,
minWidth: 100,
filter: true,
resizable: true,
};
public unvalidColDef = {
...this.defaultColDef,
cellStyle: {
color: '#da6c2e',
},
};
constructor(
private adminService: AdminService,
private notificationService: NotificationService,
private formBuilder: FormBuilder
) {
this.findValidatedEmployers();
this.findUnvalidatedEmployers();
this.unvalidEmployersColumnDefs = [
{
headerName: 'Employeur',
field: 'name',
editable: true,
onCellValueChanged: this.onChange.bind(this),
},
{
headerName: 'Acteurs rattachés',
cellRenderer: 'attachedUsersComponent',
cellRendererParams: {
users: 'users',
},
minWidth: 500,
},
{
headerName: 'Fusionner',
field: '_id',
cellRenderer: 'employerRenderer',
singleClickEdit: true,
cellEditor: 'agSelectCellEditor',
cellEditorParams: {
values: this.validatedEmployersName,
},
onCellValueChanged: this.onMerge.bind(this),
},
{
headerName: 'Valider',
editable: false,
minWidth: 100,
cellRenderer: 'validateEmployerComponent',
cellRendererParams: {
onClick: this.onValidateButtonClick.bind(this),
label: 'Valider',
},
},
];
this.columnDefs = [
{
headerName: 'Employeur',
field: 'name',
editable: true,
onCellValueChanged: this.onChange.bind(this),
},
{
headerName: 'Acteurs rattachés',
cellRenderer: 'attachedUsersComponent',
cellRendererParams: {
users: 'users',
},
minWidth: 500,
},
{
headerName: 'Suppression',
editable: false,
minWidth: 100,
cellRenderer: 'deleteEmployerComponent',
cellRendererParams: {
onClick: this.onDeleteButtonClick.bind(this),
label: 'Supprimer',
},
},
];
this.frameworkComponents = {
employerRenderer: EmployerRenderer,
deleteEmployerComponent: DeleteEmployerComponent,
attachedUsersComponent: AttachedUsersComponent,
validateEmployerComponent: ValidateEmployerComponent,
};
}
ngOnInit(): void {
this.newEmployerForm = this.formBuilder.group({
employer: ['', Validators.required],
});
}
public onDeleteButtonClick(arg): void {
this.deleteEmployer(arg.data, false);
}
public onSubmit(): void {
if (!this.newEmployerForm.valid) {
return;
}
const name: string = this.newEmployerForm.value.employer;
this.adminService.createEmployer(name).subscribe(
() => {
this.findValidatedEmployers();
this.newEmployerForm.reset();
this.notificationService.showSuccess('Votre employeur a bien été créée', '');
},
(err) => {
this.notificationService.showError(`${err.error.message}`, 'Une erreur est survenue');
}
);
}
public onValidateButtonClick(arg): void {
this.validateEmployer(arg.data._id);
}
public deleteEmployer(employer: Employer, shouldDelete: boolean): void {
this.toggleDeleteEmployerModal(employer);
if (shouldDelete) {
this.adminService.deleteEmployer(employer._id).subscribe(
(data) => {
this.validatedEmployers = this.validatedEmployers.filter((obj) => obj._id !== data._id);
this.notificationService.showSuccess("L'employeur a bien été supprimée.", '');
},
(err) => {
this.notificationService.showError(`${err.error.message}`, 'Une erreur est survenue');
}
);
}
}
public onChange(arg): void {
this.adminService.editEmployer(arg.data._id, arg.data.name).subscribe(() => {
this.notificationService.showSuccess("L'opération a réussie.", '');
this.findValidatedEmployers();
this.findUnvalidatedEmployers();
});
}
public onMerge(arg): void {
const selectedEmployer = this.validatedEmployers.find((employer) => employer.name === arg.newValue);
if (arg.oldValue === undefined) {
return;
}
if (selectedEmployer === arg.oldValue) {
return;
}
this.toggleMergeEmployerModal(selectedEmployer, arg.oldValue, arg);
}
public mergeEmployer(newEmployerId: string, formerId: string, shouldMerge: boolean, context?): void {
this.mergeEmployerModalOpenned = !this.mergeEmployerModalOpenned;
if (shouldMerge) {
this.adminService.mergeEmployer(formerId, newEmployerId).subscribe((data) => {
context.node.data[context.colDef.field] = data;
context.api.refreshCells({ rowNodes: [context.node], columns: [context.column.colId] });
this.findValidatedEmployers();
this.findUnvalidatedEmployers();
this.notificationService.showSuccess("L'opération a réussie.", '');
});
} else {
if (context.oldValue) {
context.node.data[context.colDef.field] = context.oldValue;
context.api.refreshCells({ rowNodes: [context.node], columns: [context.column.colId] });
}
}
}
public validateEmployer(employerId: string, context?): void {
this.adminService.validateEmployer(employerId).subscribe((data) => {
this.findValidatedEmployers();
this.findUnvalidatedEmployers();
});
}
public toggleDeleteEmployerModal(employerToDelete: Employer): void {
this.employerToDelete = employerToDelete;
this.deleteModalOpenned = !this.deleteModalOpenned;
}
public toggleMergeEmployerModal(employerToMerge: Employer, formerId: string, dataGrid): void {
this.mergeOpe.formerId = formerId;
this.mergeOpe.newEmployer = employerToMerge;
this.contextRow = dataGrid;
this.mergeEmployerModalOpenned = !this.mergeEmployerModalOpenned;
}
public findValidatedEmployers(): void {
this.validatedEmployersName = [];
this.adminService.getValidatedEmployers().subscribe((employers) => {
this.validatedEmployers = employers;
employers.map((employer) => {
this.validatedEmployersName.push(employer.name);
});
});
}
public findUnvalidatedEmployers(): void {
this.adminService.getUnvalidatedEmployers().subscribe((employers) => {
this.unvalidatedEmployers = employers;
});
}
public getRowHeight(params): number {
return params.data.users ? (params.data.users.length != 0 ? params.data.users.length * 40 : 40) : 40;
}
}
<button type="button" (click)="onClick()">{{ label }}</button>
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ValidateEmployerComponent } from './validate-employer.component';
describe('ValidateEmployerComponent', () => {
let component: ValidateEmployerComponent;
let fixture: ComponentFixture<ValidateEmployerComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ValidateEmployerComponent],
}).compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(ValidateEmployerComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component } from '@angular/core';
@Component({
selector: 'app-validate-employer',
templateUrl: './validate-employer.component.html',
})
export class ValidateEmployerComponent {
public params: any;
public label: string;
public agInit(params: any): void {
this.params = params;
this.label = this.params.label || null;
}
public onClick(): void {
if (this.params.onClick instanceof Function) {
this.params.onClick(this.params);
}
}
}
<div *ngIf="users.data.users && users.data.users.length != 0">
<p *ngFor="let user of users.data.users">
<span (click)="redirectTo(user)">{{ user.name }} {{ user.surname }} - {{ user.email }}</span>
</p>
</div>
p {
margin-top: 0px;
margin-bottom: 0px;
}
span:hover {
cursor: pointer;
text-decoration: underline;
}
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AdministredStructuresComponent } from './attached-users.component';
describe('AdministredStructuresComponent', () => {
let component: AdministredStructuresComponent;
let fixture: ComponentFixture<AdministredStructuresComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [AdministredStructuresComponent],
}).compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(AdministredStructuresComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});