Skip to content

Commit

Permalink
Merge pull request #699 from LINCnil/feat/hide-btn-to-non-role-user
Browse files Browse the repository at this point in the history
feat: hide btn in stead disabled
  • Loading branch information
kevin-atnos authored Jan 30, 2023
2 parents 9287f54 + a2a97d6 commit e28b9d2
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 31 deletions.
5 changes: 5 additions & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ Cypress.Commands.add("test_add_tags", () => {
cy.get("[aria-label='Click here to select controls which address the risk.']")
.type("Measure")
.then(() => {
cy.wait(500);
cy.get(".ng2-menu-item")
.first()
.click({ force: true });
Expand All @@ -209,27 +210,31 @@ Cypress.Commands.add("test_add_tags_next", () => {
cy.get("[aria-label='Enter the potential impacts']")
.type("Tag")
.then(() => {
cy.wait(500);
cy.get(".ng2-menu-item")
.first()
.click({ force: true });
});
cy.get("[aria-label='Enter the threats']")
.type("Tag")
.then(() => {
cy.wait(500);
cy.get(".ng2-menu-item")
.first()
.click({ force: true });
});
cy.get("[aria-label='Enter the risk sources']")
.type("Tag")
.then(() => {
cy.wait(500);
cy.get(".ng2-menu-item")
.first()
.click({ force: true });
});
cy.get("[aria-label='Click here to select controls which address the risk.']")
.type("Measure")
.then(() => {
cy.wait(500);
cy.get(".ng2-menu-item")
.first()
.click({ force: true });
Expand Down
33 changes: 16 additions & 17 deletions src/app/modules/pia/content/content.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -213,19 +213,17 @@ <h4 *ngIf="item.short_help">{{ item.short_help | translate }}</h4>
class="btn btn-green"
(click)="prepareForEvaluation()"
*ngIf="
globalEvaluationService.status === 1 ||
globalEvaluationService.status === 2 ||
globalEvaluationService.status === 3
(globalEvaluationService.status === 1 ||
globalEvaluationService.status === 2 ||
globalEvaluationService.status === 3) &&
(editMode.includes('author') || editMode === 'local')
"
[ngClass]="{
'btn-active':
globalEvaluationService.status === 2 ||
globalEvaluationService.status === 3
}"
[disabled]="
globalEvaluationService.status === 1 ||
!(editMode.includes('author') || editMode === 'local')
"
[disabled]="globalEvaluationService.status === 1"
>
{{ "pia.footer.ask_evaluation" | translate }}
</button>
Expand All @@ -234,14 +232,12 @@ <h4 *ngIf="item.short_help">{{ item.short_help | translate }}</h4>
class="btn btn-green"
(click)="validateEvaluation()"
*ngIf="
globalEvaluationService.status === 5 ||
globalEvaluationService.status === 6
(globalEvaluationService.status === 5 ||
globalEvaluationService.status === 6) &&
(editMode.includes('evaluator') || editMode === 'local')
"
[ngClass]="{ 'btn-active': globalEvaluationService.status === 6 }"
[disabled]="
globalEvaluationService.status === 5 ||
(!editMode.includes('evaluator') && editMode !== 'local')
"
[disabled]="globalEvaluationService.status === 5"
>
{{ "pia.footer.validate_evaluation" | translate }}
</button>
Expand All @@ -265,8 +261,11 @@ <h4 *ngIf="item.short_help">{{ item.short_help | translate }}</h4>
<button
class="btn pia-cancelBtn"
(click)="cancelAskForEvaluation()"
*ngIf="pia.is_example !== 1 && globalEvaluationService.status === 4"
[disabled]="!editMode.includes('author') && editMode !== 'local'"
*ngIf="
pia.is_example !== 1 &&
globalEvaluationService.status === 4 &&
(editMode.includes('author') || editMode === 'local')
"
>
{{ "pia.sections.status.evaluation.cancel_button" | translate }}
</button>
Expand All @@ -277,9 +276,9 @@ <h4 *ngIf="item.short_help">{{ item.short_help | translate }}</h4>
*ngIf="
pia.is_example !== 1 &&
globalEvaluationService.status === 7 &&
!(section.id == 4 && item.id == 3)
!(section.id == 4 && item.id == 3) &&
(editMode.includes('evaluator') || editMode === 'local')
"
[disabled]="!editMode.includes('evaluator') && editMode != 'local'"
>
{{ "pia.sections.status.validation.cancel_button" | translate }}
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ export class DPOPeopleOpinionsComponent implements OnInit {
ngOnInit(): void {
// DPO Form init
this.DPOForm = new FormGroup({
DPOStatus: new FormControl(
this.pia.dpo_status != null && this.pia.dpos_names
? this.pia.dpo_status
: null
),
DPOStatus: new FormControl(this.pia.dpo_status),
DPOOpinion: new FormControl(this.pia.dpo_opinion),
DPONames: new FormControl(this.pia.dpos_names)
});
Expand All @@ -47,14 +43,10 @@ export class DPOPeopleOpinionsComponent implements OnInit {

// Searched opinions form init
this.searchedOpinionsForm = new FormGroup({
searchStatus: new FormControl(
this.pia.concerned_people_searched_opinion != null &&
this.pia.dpos_names
? this.pia.concerned_people_searched_opinion
: null
),
searchStatus: new FormControl(this.pia.concerned_people_searched_opinion),
searchContent: new FormControl(this.pia.concerned_people_searched_content)
});

if (this.pia.concerned_people_searched_opinion !== undefined) {
this.displayPeopleOpinions = this.pia.concerned_people_searched_opinion;
this.displayPeopleSearchContent = !this.pia
Expand Down Expand Up @@ -109,7 +101,6 @@ export class DPOPeopleOpinionsComponent implements OnInit {

// Check user role
if (!this.editMode.includes('validator') && this.editMode != 'local') {
this.DPOForm.disable();
this.searchedOpinionsForm.disable();
this.peopleForm.disable();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,10 @@ export class EvaluationsComponent
const content = this.el.nativeElement.querySelector(
'.pia-evaluationBlock-content'
);
content.classList.remove('hide');

if (content) {
content.classList.remove('hide');
}
});
})
.finally(() => {
Expand Down Expand Up @@ -380,7 +383,6 @@ export class EvaluationsComponent
* Executes actions when losing focus from evaluation comment.
*/
evaluationCommentFocusOut(): void {
console.log('évaluationf focus out');
this.knowledgeBaseService.placeholder = null;
this.editorEvaluationComment = false;
let userText = this.evaluationForm.controls['evaluationComment'].value;
Expand Down

0 comments on commit e28b9d2

Please sign in to comment.