diff --git a/ui/ui-frontend/projects/pastis/src/app/user-actions/add-pua-control/add-pua-control.component.html b/ui/ui-frontend/projects/pastis/src/app/user-actions/add-pua-control/add-pua-control.component.html index 779edab7f787cd23c9fdbde08b714b1fc1723e68..8fd573863765111bb64d13b5c8170d27f775a7e9 100644 --- a/ui/ui-frontend/projects/pastis/src/app/user-actions/add-pua-control/add-pua-control.component.html +++ b/ui/ui-frontend/projects/pastis/src/app/user-actions/add-pua-control/add-pua-control.component.html @@ -13,7 +13,7 @@ </div> <!-- The list of items to be selected--> - <mat-list *ngIf="allowedChildren?.length; else noItemsLeftToAdd" class="list-box-head"> + <mat-list *ngIf="allowedChildren?.length" class="list-box-head"> <span class="list-box-content-title"> <span [ngStyle]="{'margin-top': atLeastOneIsSelected ? '40px' : '0px'}" class="paragraph-metadata-subtitle">Les contrôles à ajouter</span> diff --git a/ui/ui-frontend/projects/pastis/src/app/user-actions/add-pua-control/add-pua-control.component.ts b/ui/ui-frontend/projects/pastis/src/app/user-actions/add-pua-control/add-pua-control.component.ts index bce846d08b0c4c5541f8bc296465b989767cfdc8..d9b7dd20e731620b5c148b87cd0a96b57b74c42b 100644 --- a/ui/ui-frontend/projects/pastis/src/app/user-actions/add-pua-control/add-pua-control.component.ts +++ b/ui/ui-frontend/projects/pastis/src/app/user-actions/add-pua-control/add-pua-control.component.ts @@ -35,17 +35,12 @@ same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL-C license and that you accept its terms. */ -import { Component, OnInit, TemplateRef } from '@angular/core'; -import { SedaData, SedaElementConstants } from '../../models/seda-data'; -import { FileNode } from '../../models/file-node'; -import { FileService } from '../../core/services/file.service'; -import { SedaService } from '../../core/services/seda.service'; +import { Component, OnInit } from '@angular/core'; +import { SedaData } from '../../models/seda-data'; import { MatDialogRef } from '@angular/material/dialog'; import { PastisDialogConfirmComponent } from '../../shared/pastis-dialog/pastis-dialog-confirm/pastis-dialog-confirm.component'; import { PastisDialogData } from '../../shared/pastis-dialog/classes/pastis-dialog-data'; import { PopupService } from '../../core/services/popup.service'; -import { Subscription } from 'rxjs'; -import { PastisPopupMetadataLanguageService } from '../../shared/pastis-popup-metadata-language/pastis-popup-metadata-language.service'; @Component({ selector: 'pastis-user-action-add-metadata', @@ -61,40 +56,21 @@ export class UserActionAddPuaControlComponent implements OnInit { expressionReguliereLabel: string = "Expression régulière"; lengthMinMaxLabel: string = "Longueur Min/Max"; valueMinMaxLabel: string = "Valeur Min/Max"; + enumerationsDefinition: string = "Signaler les valeurs autorisées"; + expressionReguliereDefinition: string = "Définir une expression régulière pour la valeur de la métadonnée"; allowedChildren: string[]; - namesFiltered: any = []; - sedaNodeFound: SedaData; - selectedSedaNode: SedaData; addedItems: string[] = []; dialogData: PastisDialogData; atLeastOneIsSelected: boolean; - customTemplate: TemplateRef<any> - fileNode: FileNode; - sedaLanguage: boolean; - sedaLanguageSub: Subscription; constructor(public dialogRef: MatDialogRef<PastisDialogConfirmComponent>, - private fileService: FileService, private sedaService: SedaService, - private popUpService: PopupService, private sedaLanguageService: PastisPopupMetadataLanguageService) { + private popUpService: PopupService) { this.refreshAllowedChildren(); } ngOnInit() { - this.sedaLanguageSub = this.sedaLanguageService.sedaLanguage.subscribe( - (value: boolean) => { - this.sedaLanguage = value; - }, - (error) => { - console.log(error) - } - ); - this.fileService.nodeChange.subscribe(fileNode => { this.fileNode = fileNode }) - this.sedaData = this.sedaService.sedaRules[0]; - - this.sedaNodeFound = this.fileNode.sedaData; - // Subscribe observer to button status and // set the inital state of the ok button to disabled this.popUpService.btnYesShoudBeDisabled.subscribe(status => { @@ -102,24 +78,15 @@ export class UserActionAddPuaControlComponent implements OnInit { }) } - - isElementSelected(element: string) { - if (this.addedItems) { - return this.addedItems.includes(element); - } - } - onRemoveSelectedElement(element: string) { if(this.isExclusive(element)){ this.refreshAllowedChildren(); }else{ let indexOfElement = this.addedItems.indexOf(element) - console.log(indexOfElement) if (indexOfElement >= 0) { this.allowedChildren.push(this.addedItems.splice(indexOfElement, 1)[0]) } } - console.error(this.allowedChildren) this.addedItems.length > 0 ? this.atLeastOneIsSelected = true : this.atLeastOneIsSelected = false this.upateButtonStatusAndDataToSend(); } @@ -140,32 +107,17 @@ export class UserActionAddPuaControlComponent implements OnInit { this.popUpService.disableYesButton(!this.atLeastOneIsSelected) } - onAllItemsAdded() { - return this.allowedChildren.length === this.addedItems.length; - } - - isElementComplex(element: SedaData) { - if (element) { - return element.Element === SedaElementConstants.complex; + getDefinition(element: string): string { + if(element === this.enumerationsLabel){ + return this.enumerationsDefinition } - } - - getDefinition(element: SedaData): string { - return element ? element.Definition : ''; - } - - onYesClick(): void { - console.log("Clicked ok on dialog : %o", this.selectedSedaNode); - - } - onNoClick(): void { - this.dialogRef.close(); + if(element === this.expressionReguliereLabel){ + return this.expressionReguliereDefinition + } + return ''; } ngOnDestroy(): void { - if (this.sedaLanguageSub != null) { - this.sedaLanguageSub.unsubscribe(); - } } isExclusive(element: string): boolean{