Skip to content
Snippets Groups Projects
Commit e0a3476b authored by Hugo SUBTIL's avatar Hugo SUBTIL
Browse files

feat(structure-details): add service details

parent 60d1522b
No related branches found
No related tags found
1 merge request!31Recette
......@@ -35,6 +35,8 @@ export class Structure {
public hours: Week;
public isOpen: boolean;
public openedOn: OpeningDay;
public lesCompetencesDeBase: string[];
public accesAuxDroits: string[];
public distance?: number;
public address?: string;
......
......@@ -65,11 +65,13 @@
<h2>Services</h2>
</div>
<div fxLayout="row" class="w-100">
<div fxFlex="50%">
<div fxFlex="50%" *ngIf="baseSkills && baseSkills[0] !== undefined">
<h3 class="subtitle">Compétences de base</h3>
<p *ngFor="let skill of baseSkills">{{ skill.text }}</p>
</div>
<div fxFlex="50%">
<div fxFlex="50%" *ngIf="accessRights && accessRights[0] !== undefined">
<h3 class="subtitle">Accès au droits</h3>
<p *ngFor="let rights of accessRights">{{ rights.text }}</p>
</div>
</div>
</div>
......
......@@ -55,7 +55,6 @@ h4 {
p,
a {
@include cn-regular-16;
// margin-left: 30px;
margin-top: 9px;
margin-bottom: 9px;
}
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { Structure } from '../../../models/structure.model';
import { Module } from '../../models/module.model';
import { Category } from '../../models/category.model';
import { AccessModality } from '../../enum/access-modality.enum';
import { SearchService } from '../../services/search.service';
import * as _ from 'lodash';
@Component({
selector: 'app-structure-details',
templateUrl: './structure-details.component.html',
......@@ -11,9 +15,25 @@ export class StructureDetailsComponent implements OnInit {
@Output() public closeDetails: EventEmitter<boolean> = new EventEmitter<boolean>();
public accessModality = AccessModality;
constructor() {}
public baseSkillssReferentiel: Category;
public accessRightsReferentiel: Category;
public baseSkills: Module[];
public accessRights: Module[];
ngOnInit(): void {}
constructor(private searchService: SearchService) {}
ngOnInit(): void {
this.searchService.getCategoriesTraining().subscribe((referentiels) => {
referentiels.forEach((referentiel) => {
if (referentiel.isBaseSkills()) {
this.baseSkillssReferentiel = referentiel;
} else if (referentiel.isRigthtsAccess()) {
this.accessRightsReferentiel = referentiel;
}
});
this.setServiceCategories();
});
}
public close(): void {
this.closeDetails.emit(true);
......@@ -28,9 +48,23 @@ export class StructureDetailsComponent implements OnInit {
case AccessModality.numeric:
return 'tel';
default:
throw new Error(`${accessModality} is not handled by getAccessIcon`);
return null;
}
}
public setServiceCategories(): void {
this.baseSkills = this.toNumbers(this.structure.lesCompetencesDeBase).map((skill) =>
_.find(this.baseSkillssReferentiel.modules, { id: skill })
);
this.accessRights = this.toNumbers(this.structure.accesAuxDroits).map((rights) =>
_.find(this.accessRightsReferentiel.modules, { id: rights })
);
console.log(this.baseSkills);
console.log(this.accessRights);
}
public keepOriginalOrder = (a, b) => a.key;
public toNumbers = (arr) => arr.map(Number);
}
......@@ -9,4 +9,12 @@ export class Category {
modules: obj && obj.modules ? obj.modules.map((module) => new Module(module.id, module.text)) : null,
});
}
public isBaseSkills(): boolean {
return this.name === 'Les compétences de base';
}
public isRigthtsAccess(): boolean {
return this.name === 'Accès aux droits';
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment