Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ export class MeasuresComponent implements OnInit, OnDestroy {
this.hideTextarea = this.measure.content?.length > 0;

this.elementId = 'pia-measure-content-' + this.id;

this.knowledgeBaseService.toHide.push(this.measure.title);
}

ngOnDestroy(): void {
Expand Down Expand Up @@ -216,7 +218,8 @@ export class MeasuresComponent implements OnInit, OnDestroy {
this.structure,
this.section.id,
this.item.id,
this.id
this.id,
this.measure.title
);
},
() => {
Expand Down
4 changes: 3 additions & 1 deletion src/app/modules/structure/structure.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class StructureComponent implements OnInit {
* @param {number} sectionId - The section id.
* @param {number} itemId - The item id.
*/
private getSectionAndItem(sectionId: number, itemId: number): void {
private async getSectionAndItem(sectionId: number, itemId: number) {
this.questions = [];

this.data = this.structure.data;
Expand All @@ -118,6 +118,8 @@ export class StructureComponent implements OnInit {
});
}

await this.globalEvaluationService.validate();

this.measureService.listMeasures(this.structure.id);
this.actionPlanService.data = this.data;
}
Expand Down
12 changes: 10 additions & 2 deletions src/app/services/answer-structure.service.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import { Injectable } from '@angular/core';
import { Structure } from '../models/structure.model';
import { StructureService } from './structure.service';
import { KnowledgeBaseService } from './knowledge-base.service';

@Injectable()
export class AnswerStructureService {
// measureToRemove = new Subject<number>();
// questionToRemove = new Subject<number>();

constructor(private structureService: StructureService) {}
constructor(
private structureService: StructureService,
private knowledgeBaseService?: KnowledgeBaseService
) {}

async addQuestion(
structure: Structure,
Expand Down Expand Up @@ -69,14 +73,18 @@ export class AnswerStructureService {
structure: Structure,
section_id: number,
item_id: number,
measure_id: number
measure_id: number,
measure_name: string
): void {
structure.data.sections
.filter(s => s.id === section_id)[0]
.items.filter(i => i.id === item_id)[0]
.answers.splice(measure_id, 1);
this.structureService.update(structure).then(() => {
// this.measureToRemove.next(measure_id);
this.knowledgeBaseService.toHide = this.knowledgeBaseService.toHide.filter(
item => item !== measure_name
);
});
}

Expand Down
14 changes: 11 additions & 3 deletions src/app/services/global-evaluation.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,11 @@ export class GlobalEvaluationService {
this.item.evaluation_mode === 'item' ||
this.item.evaluation_mode === 'question'
) {
await this.answersVerification();
await this.evaluationsVerification();
if (this.pia) {
// We apply this only to PIAs, not to Structures
await this.evaluationsVerification();
await this.answersVerification();
}
this.verification();
if (callSubject) {
this.setAnswerEditionEnabled();
Expand Down Expand Up @@ -747,7 +750,12 @@ export class GlobalEvaluationService {
* Set answer edition by status.
*/
setAnswerEditionEnabled(): void {
this.answerEditionEnabled = [0, 1, 2, 3].includes(this.status);
if (this.pia) {
this.answerEditionEnabled = [0, 1, 2, 3].includes(this.status);
} else {
// Structures
this.answerEditionEnabled = true;
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ export class KnowledgeBaseComponent implements OnInit, OnChanges, OnDestroy {
* @param event - Any kind of event.
*/
addNewMeasure(event): void {
const title = this.translateService.instant(event.name);
if (!this.knowledgeBaseService.toHide.includes(title)) {
this.knowledgeBaseService.toHide.push(title);
}
if (this.pia) {
this.measureService
.addNewMeasure(this.pia, event.name, event.placeholder)
Expand All @@ -177,7 +181,6 @@ export class KnowledgeBaseComponent implements OnInit, OnChanges, OnDestroy {
});
} else if (this.structure) {
this.structureService.find(this.structure.id).then(() => {
const title = this.translateService.instant(event.name);
const measure = {
title,
content: ''
Expand Down