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 (96)
Showing
with 723 additions and 151 deletions
...@@ -53,3 +53,7 @@ api/db.json ...@@ -53,3 +53,7 @@ api/db.json
# Documentation generated with compodoc # Documentation generated with compodoc
documentation documentation
CHANGELOG.md
package-lock.json
stages: stages:
- quality
- build - build
- quality
- deploy - deploy
default: default:
...@@ -77,7 +77,8 @@ deploy_dev: ...@@ -77,7 +77,8 @@ deploy_dev:
tags: tags:
- deploy - deploy
only: only:
- dev # - dev
- V2.0
script: script:
- cd /home/mps/ram - cd /home/mps/ram
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
...@@ -127,7 +128,6 @@ sonarqube: ...@@ -127,7 +128,6 @@ sonarqube:
-Dsonar.host.url=${SONAR_URL} -Dsonar.host.url=${SONAR_URL}
-Dsonar.projectKey=${SONAR_PROJECT_KEY} -Dsonar.projectKey=${SONAR_PROJECT_KEY}
-Dsonar.login=${SONAR_TOKEN} -Dsonar.login=${SONAR_TOKEN}
-Dsonar.cpd.exclusions=tests/**,src/**/*.spec.ts*
-Dsonar.qualitygate.wait=true -Dsonar.qualitygate.wait=true
sonarqube-mr: sonarqube-mr:
...@@ -152,5 +152,4 @@ sonarqube-mr: ...@@ -152,5 +152,4 @@ sonarqube-mr:
-Dsonar.host.url=${SONAR_URL} -Dsonar.host.url=${SONAR_URL}
-Dsonar.projectKey=${SONAR_PROJECT_KEY} -Dsonar.projectKey=${SONAR_PROJECT_KEY}
-Dsonar.login=${SONAR_MR_TOKEN} -Dsonar.login=${SONAR_MR_TOKEN}
-Dsonar.cpd.exclusions=tests/**,src/**/*.spec.ts*
-Dsonar.qualitygate.wait=true -Dsonar.qualitygate.wait=true
## 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_
This diff is collapsed.
# Based on Node.js
FROM node:12.16
WORKDIR /app
# Copy the package.json file first in order to cache the modules
COPY . .
# Install npm dependencies
RUN npm install
# expose port 3000
EXPOSE 3000
CMD ["npm", "start"]
{
"name": "pamn-mock-api",
"version": "0.1.0",
"scripts": {
"start": "node server.js"
},
"private": true,
"dependencies": {
"json-server": "^0.16.2"
}
}
const jsonServer = require('json-server');
const server = jsonServer.create();
const router = jsonServer.router('db.json');
const routes = {
'/api/*': '/$1',
};
const middlewares = [jsonServer.defaults(), jsonServer.rewriter(routes)];
// Set default middlewares (logger, static, cors and no-cache)
server.use(middlewares);
// Add custom routes before JSON Server router
server.get('/structures/count', (req, res) => {
let structureCountTab = [];
// Compétences de base
structureCountTab.push({ id: '260', count: 12 });
structureCountTab.push({ id: '259', count: 10 });
structureCountTab.push({ id: '261', count: 10 });
structureCountTab.push({ id: '249', count: 9 });
structureCountTab.push({ id: '222', count: 9 });
structureCountTab.push({ id: '212', count: 8 });
structureCountTab.push({ id: '186', count: 7 });
structureCountTab.push({ id: '183', count: 6 });
// Accès aux droits
structureCountTab.push({ id: '176', count: 6 });
structureCountTab.push({ id: '175', count: 1 });
structureCountTab.push({ id: '174', count: 2 });
structureCountTab.push({ id: '173', count: 2 });
structureCountTab.push({ id: '172', count: 2 });
structureCountTab.push({ id: '171', count: 4 });
structureCountTab.push({ id: '167', count: 3 });
structureCountTab.push({ id: '165', count: 2 });
// Insertion sociale et professionnelle
structureCountTab.push({ id: '254', count: 5 });
structureCountTab.push({ id: '240', count: 4 });
structureCountTab.push({ id: '194', count: 7 });
structureCountTab.push({ id: '193', count: 7 });
structureCountTab.push({ id: '192', count: 5 });
structureCountTab.push({ id: '191', count: 7 });
structureCountTab.push({ id: '262', count: 5 });
structureCountTab.push({ id: '263', count: 3 });
structureCountTab.push({ id: '3', count: 3 });
// Aide à la parentalité
structureCountTab.push({ id: '257', count: 4 });
structureCountTab.push({ id: '238', count: 1 });
structureCountTab.push({ id: '178', count: 4 });
structureCountTab.push({ id: '166', count: 2 });
// Culture et sécurité numérique
structureCountTab.push({ id: '264', count: 5 });
structureCountTab.push({ id: '255', count: 7 });
structureCountTab.push({ id: '265', count: 2 });
structureCountTab.push({ id: '232', count: 4 });
structureCountTab.push({ id: '225', count: 5 });
structureCountTab.push({ id: '221', count: 3 });
structureCountTab.push({ id: '218', count: 2 });
structureCountTab.push({ id: '209', count: 3 });
structureCountTab.push({ id: '208', count: 4 });
structureCountTab.push({ id: '206', count: 5 });
structureCountTab.push({ id: '195', count: 5 });
structureCountTab.push({ id: '164', count: 4 });
structureCountTab.push({ id: '163', count: 2 });
structureCountTab.push({ id: '162', count: 3 });
// Accompagnement des démarches
structureCountTab.push({ id: 'Accompagnant CAF', count: 7 });
structureCountTab.push({ id: 'Pôle Emploi', count: 9 });
structureCountTab.push({ id: 'CPAM', count: 7 });
structureCountTab.push({ id: 'Impôts', count: 6 });
structureCountTab.push({ id: 'Logement', count: 5 });
structureCountTab.push({ id: 'CARSAT', count: 5 });
structureCountTab.push({ id: 'Autres', count: 2 });
// Publics acceptés
structureCountTab.push({ id: 'Tout public', count: 7 });
structureCountTab.push({ id: 'Moins de 16 ans', count: 4 });
structureCountTab.push({ id: 'Jeunes (16-25 ans)', count: 6 });
structureCountTab.push({ id: 'Adultes', count: 9 });
structureCountTab.push({ id: 'Séniors (+ de 65 ans)', count: 1 });
// Labels et qualifications
structureCountTab.push({ id: 'Aidants Connect', count: 0 });
structureCountTab.push({ id: 'Espace public numérique (EPN)', count: 2 });
structureCountTab.push({ id: 'Fabrique de territoire', count: 3 });
structureCountTab.push({ id: 'Maison France Service', count: 0 });
structureCountTab.push({ id: 'Pass numérique', count: 4 });
// Modalités d'accès
structureCountTab.push({ id: 'Uniquement sur RDV', count: 13 });
structureCountTab.push({ id: 'Accès libre', count: 6 });
structureCountTab.push({ id: 'Téléphone / Visio', count: 6 });
// Accompagnement des publics
structureCountTab.push({ id: "Personnes en situation d'illetrisme", count: 0 });
structureCountTab.push({ id: 'Langue étrangère (anglais)', count: 0 });
structureCountTab.push({ id: 'Langues étrangères (autres)', count: 0 });
structureCountTab.push({ id: 'Surdité', count: 0 });
structureCountTab.push({ id: 'Déficience visuelle', count: 0 });
structureCountTab.push({ id: 'Handicap moteur', count: 0 });
// Équipements et services proposés
structureCountTab.push({ id: 'Wifi en accès libre', count: 6 });
structureCountTab.push({ id: 'Ordinateurs', count: 5 });
structureCountTab.push({ id: 'Tablettes', count: 1 });
structureCountTab.push({ id: 'Bornes numériques', count: 1 });
structureCountTab.push({ id: 'Imprimantes', count: 5 });
structureCountTab.push({ id: 'Prêt / don de matériels', count: 0 });
structureCountTab.push({ id: 'Reconditionnements de matériel', count: 0 });
structureCountTab.push({ id: 'Accès à des revues ou livres informatiques et numériques', count: 0 });
return res.status(200).jsonp(structureCountTab);
});
// Use default router
server.use(router);
server.listen(3000, () => {
console.log('JSON Server is running');
});
{ {
"name": "pamn", "name": "pamn",
"version": "1.17.2", "version": "2.0.0-beta2.1",
"scripts": { "scripts": {
"ng": "ng", "ng": "ng",
"start": "ng serve --configuration=fr --proxy-config proxy.conf.json", "start": "ng serve --configuration=fr --proxy-config proxy.conf.json",
...@@ -13,8 +13,7 @@ ...@@ -13,8 +13,7 @@
"lint": "ng lint", "lint": "ng lint",
"e2e": "ng e2e", "e2e": "ng e2e",
"release": "standard-version", "release": "standard-version",
"translate": "ng xi18n --ivy --output-path src/locale --out-file messages.en.xlf", "translate": "ng xi18n --ivy --output-path src/locale --out-file messages.en.xlf"
"api": "json-server api/db.json --routes api/routes.json --no-cors=true"
}, },
"private": true, "private": true,
"dependencies": { "dependencies": {
...@@ -33,11 +32,9 @@ ...@@ -33,11 +32,9 @@
"@ngx-translate/core": "^13.0.0", "@ngx-translate/core": "^13.0.0",
"ag-grid-angular": "^26.2.0", "ag-grid-angular": "^26.2.0",
"ag-grid-community": "^26.2.1", "ag-grid-community": "^26.2.1",
"ag-grid-enterprise": "^26.2.1",
"json-server": "^0.17.0",
"jwt-decode": "^3.1.2", "jwt-decode": "^3.1.2",
"leaflet": "^1.7.1", "leaflet": "^1.7.1",
"leaflet.locatecontrol": "^0.72.0", "leaflet.locatecontrol": "^0.76.0",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"luxon": "^1.25.0", "luxon": "^1.25.0",
"ngx-toastr": "^13.2.1", "ngx-toastr": "^13.2.1",
...@@ -51,14 +48,14 @@ ...@@ -51,14 +48,14 @@
"@angular/compiler-cli": "~13.1.1", "@angular/compiler-cli": "~13.1.1",
"@angular/localize": "^13.1.1", "@angular/localize": "^13.1.1",
"@compodoc/compodoc": "^1.1.16", "@compodoc/compodoc": "^1.1.16",
"@types/jasmine": "~3.5.0", "@types/jasmine": "~4.0.0",
"@types/jasminewd2": "~2.0.3", "@types/jasminewd2": "~2.0.3",
"@types/leaflet": "^1.5.17", "@types/leaflet": "^1.5.17",
"@types/leaflet.locatecontrol": "^0.60.7", "@types/leaflet.locatecontrol": "^0.60.7",
"@types/node": "^12.12.67", "@types/node": "^16.0.0",
"codelyzer": "^6.0.0", "codelyzer": "^6.0.0",
"http-server": "^14.1.0", "http-server": "^14.1.0",
"jasmine-core": "~3.6.0", "jasmine-core": "~4.1.0",
"jasmine-spec-reporter": "~5.0.0", "jasmine-spec-reporter": "~5.0.0",
"karma": "^6.3.9", "karma": "^6.3.9",
"karma-browserify": "^7.0.0", "karma-browserify": "^7.0.0",
......
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"local>systemes-dinformation/renovate/renovate-config"
]
}
...@@ -11,6 +11,16 @@ import { AdminRoutingModule } from './admin-routing.module'; ...@@ -11,6 +11,16 @@ import { AdminRoutingModule } from './admin-routing.module';
import { AgGridModule } from 'ag-grid-angular'; import { AgGridModule } from 'ag-grid-angular';
import { DeleteUserComponent } from './components/manage-users/delete-user/delete-user.component'; import { DeleteUserComponent } from './components/manage-users/delete-user/delete-user.component';
import { AdministredStructuresComponent } from './components/manage-users/administred-structures/administred-structures.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({ @NgModule({
declarations: [ declarations: [
...@@ -20,8 +30,18 @@ import { AdministredStructuresComponent } from './components/manage-users/admini ...@@ -20,8 +30,18 @@ import { AdministredStructuresComponent } from './components/manage-users/admini
AdminStructuresListComponent, AdminStructuresListComponent,
ManageLockdownInfoComponent, ManageLockdownInfoComponent,
ManageUsersComponent, ManageUsersComponent,
JobRenderer,
EmployerRenderer,
JobPersonalOffer,
ValidateJobComponent,
ValidateEmployerComponent,
DeleteUserComponent, DeleteUserComponent,
DeleteJobComponent,
DeleteEmployerComponent,
AdministredStructuresComponent, AdministredStructuresComponent,
AttachedUsersComponent,
ManageJobsComponent,
ManageEmployersComponent,
], ],
imports: [ imports: [
CommonModule, 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 { ManageEmployersComponent } from './manage-employers.component';
describe('ManageEmployersComponent', () => {
let component: ManageEmployersComponent;
let fixture: ComponentFixture<ManageEmployersComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ManageEmployersComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(ManageEmployersComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
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 { HttpClientTestingModule } from '@angular/common/http/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { UserVerificationComponent } from './user-verification.component'; import { ValidateEmployerComponent } from './validate-employer.component';
describe('UserVerificationComponent', () => { describe('ValidateEmployerComponent', () => {
let component: UserVerificationComponent; let component: ValidateEmployerComponent;
let fixture: ComponentFixture<UserVerificationComponent>; let fixture: ComponentFixture<ValidateEmployerComponent>;
beforeEach(async () => { beforeEach(async () => {
await TestBed.configureTestingModule({ await TestBed.configureTestingModule({
declarations: [UserVerificationComponent], declarations: [ValidateEmployerComponent],
imports: [RouterTestingModule, HttpClientTestingModule],
}).compileComponents(); }).compileComponents();
}); });
beforeEach(() => { beforeEach(() => {
fixture = TestBed.createComponent(UserVerificationComponent); fixture = TestBed.createComponent(ValidateEmployerComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
fixture.detectChanges(); fixture.detectChanges();
}); });
......
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);
}
}
}