From 8d897161d07bc77e1dde59d638a684096e016e22 Mon Sep 17 00:00:00 2001 From: Baptiste Toulemonde Date: Mon, 7 Mar 2022 15:12:52 +0100 Subject: [PATCH 01/16] change css --- .../file-tree-metadata.component.html | 47 +++++++++++-------- .../file-tree-metadata.component.ts | 7 +++ 2 files changed, 35 insertions(+), 19 deletions(-) diff --git a/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree-metadata/file-tree-metadata.component.html b/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree-metadata/file-tree-metadata.component.html index a941f1fdc..830e7fdc1 100644 --- a/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree-metadata/file-tree-metadata.component.html +++ b/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree-metadata/file-tree-metadata.component.html @@ -224,7 +224,7 @@ -
+
- + 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 bce846d08..d9b7dd20e 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 - fileNode: FileNode; - sedaLanguage: boolean; - sedaLanguageSub: Subscription; constructor(public dialogRef: MatDialogRef, - 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{ -- GitLab From 2927d17bed217f056a9f5eeee9d573e1bbfd6a13 Mon Sep 17 00:00:00 2001 From: naji Date: Wed, 9 Mar 2022 08:36:52 +0100 Subject: [PATCH 04/16] traduction --- .../file-tree-metadata.component.ts | 1 + .../add-pua-control.component.ts | 40 +++++++++++++++---- .../projects/pastis/src/assets/i18n/en.json | 11 ++++- .../projects/pastis/src/assets/i18n/fr.json | 11 ++++- 4 files changed, 54 insertions(+), 9 deletions(-) diff --git a/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree-metadata/file-tree-metadata.component.ts b/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree-metadata/file-tree-metadata.component.ts index 8615a9632..ed6fdfbaf 100644 --- a/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree-metadata/file-tree-metadata.component.ts +++ b/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree-metadata/file-tree-metadata.component.ts @@ -80,6 +80,7 @@ function constantToTranslate() { this.popupSousTitre = this.translated('.POPUP_SOUS_TITRE'); this.popupValider = this.translated('.POPUP_VALIDER'); this.popupAnnuler = this.translated('.POPUP_ANNULER'); + this.popupControlOkLabel = this.translated('.POPUP_CONTROL_OK_BUTTON_LABEL'); } @Component({ 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 d9b7dd20e..ca81db210 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 @@ -36,11 +36,25 @@ 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 } 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 { environment } from 'projects/pastis/src/environments/environment'; +import { LangChangeEvent, TranslateService } from '@ngx-translate/core'; + + +const ADD_PUA_CONTROL_TRANSLATE_PATH = 'USER_ACTION.ADD_PUA_CONTROL'; + +function constantToTranslate() { + this.enumerationsLabel = this.translated('.ENUMERATIONS_LABEL'); + this.expressionReguliereLabel = this.translated('.EXPRESSION_REGULIERE_LABEL'); + this.lengthMinMaxLabel = this.translated('.LENGTH_MIN_MAX_LABEL'); + this.valueMinMaxLabel = this.translated('.VALUE_MIN_MAX_LABEL'); + this.enumerationsDefinition = this.translated('.ENUMERATIONS_DEFINITION'); + this.expressionReguliereDefinition = this.translated('.EXPRESSION_REGULIERE_DEFINITION'); +} + @Component({ selector: 'pastis-user-action-add-metadata', @@ -50,8 +64,6 @@ import { PopupService } from '../../core/services/popup.service'; export class UserActionAddPuaControlComponent implements OnInit { btnIsDisabled: boolean; - - sedaData: SedaData; enumerationsLabel: string = "Enumération"; expressionReguliereLabel: string = "Expression régulière"; lengthMinMaxLabel: string = "Longueur Min/Max"; @@ -63,10 +75,15 @@ export class UserActionAddPuaControlComponent implements OnInit { dialogData: PastisDialogData; atLeastOneIsSelected: boolean; + isStandalone: boolean = environment.standalone; constructor(public dialogRef: MatDialogRef, - private popUpService: PopupService) { + private popUpService: PopupService, private translateService: TranslateService) { + if(!this.isStandalone){ + constantToTranslate.call(this); + this.translatedOnChange(); + } this.refreshAllowedChildren(); } @@ -117,9 +134,6 @@ export class UserActionAddPuaControlComponent implements OnInit { return ''; } - ngOnDestroy(): void { - } - isExclusive(element: string): boolean{ return element === this.valueMinMaxLabel || element === this.enumerationsLabel; } @@ -140,4 +154,16 @@ export class UserActionAddPuaControlComponent implements OnInit { } } + translatedOnChange(): void { + this.translateService.onLangChange + .subscribe((event: LangChangeEvent) => { + constantToTranslate.call(this); + console.log(event.lang); + }); + } + + translated(nameOfFieldToTranslate: string): string { + return this.translateService.instant(ADD_PUA_CONTROL_TRANSLATE_PATH + nameOfFieldToTranslate); + } + } diff --git a/ui/ui-frontend/projects/pastis/src/assets/i18n/en.json b/ui/ui-frontend/projects/pastis/src/assets/i18n/en.json index 7d701f8c2..a10de77cc 100644 --- a/ui/ui-frontend/projects/pastis/src/assets/i18n/en.json +++ b/ui/ui-frontend/projects/pastis/src/assets/i18n/en.json @@ -182,7 +182,8 @@ "NOM_ATTRIBUT": "Attribute name", "VALEUR_FIXE": "Fixed value", "COMMENTAIRE": "Comment" - } + }, + "POPUP_CONTROL_OK_BUTTON_LABEL": "ADD CONTROLS" } }, "LIST_PROFILE": { @@ -214,6 +215,14 @@ "METADATA_ADD": "The metadata to add", "BOUTON_AJOUTER": "Add", "MESSAGE_PLUS_METADONNEE": "There is no more metadata to add" + }, + "ADD_PUA_CONTROL": { + "ENUMERATIONS_LABEL": "Enumeration", + "EXPRESSION_REGULIERE_LABEL": "Regular expression", + "LENGTH_MIN_MAX_LABEL": "Length Min/Max", + "VALUE_MIN_MAX_LABEL": "Value Min/Max", + "ENUMERATIONS_DEFINITION": "Report allowed values", + "EXPRESSION_REGULIERE_DEFINITION": "Define a regular expression for the metadata value" } }, "COMMON": { diff --git a/ui/ui-frontend/projects/pastis/src/assets/i18n/fr.json b/ui/ui-frontend/projects/pastis/src/assets/i18n/fr.json index 03151e5ae..490100c5a 100644 --- a/ui/ui-frontend/projects/pastis/src/assets/i18n/fr.json +++ b/ui/ui-frontend/projects/pastis/src/assets/i18n/fr.json @@ -182,7 +182,8 @@ "NOM_ATTRIBUT": "Nom de l'attribut", "VALEUR_FIXE": "Valeur fixe", "COMMENTAIRE": "Commentaire" - } + }, + "POPUP_CONTROL_OK_BUTTON_LABEL": "AJOUTER LES CONTROLES" } }, "LIST_PROFILE": { @@ -214,6 +215,14 @@ "METADATA_ADD": "Les métadonnées à ajouter", "BOUTON_AJOUTER": "Ajouter", "MESSAGE_PLUS_METADONNEE": "Il n'y a plus de métadonnées à ajouter" + }, + "ADD_PUA_CONTROL": { + "ENUMERATIONS_LABEL": "Enumération", + "EXPRESSION_REGULIERE_LABEL": "Expression régulière", + "LENGTH_MIN_MAX_LABEL": "Longueur Min/Max", + "VALUE_MIN_MAX_LABEL": "Valeur Min/Max", + "ENUMERATIONS_DEFINITION": "Signaler les valeurs autorisées", + "EXPRESSION_REGULIERE_DEFINITION": "Définir une expression régulière pour la valeur de la métadonnée" } }, "COMMON": { -- GitLab From 42a5d927986c0b8a6904835ff0a672021dddc750 Mon Sep 17 00:00:00 2001 From: naji Date: Wed, 9 Mar 2022 09:16:03 +0100 Subject: [PATCH 05/16] fix: traduction pour version vitamui --- .../file-tree-metadata.component.ts | 11 +++++++---- .../projects/pastis/src/assets/i18n/en.json | 4 +++- .../projects/pastis/src/assets/i18n/fr.json | 4 +++- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree-metadata/file-tree-metadata.component.ts b/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree-metadata/file-tree-metadata.component.ts index ed6fdfbaf..c64ffc128 100644 --- a/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree-metadata/file-tree-metadata.component.ts +++ b/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree-metadata/file-tree-metadata.component.ts @@ -72,6 +72,7 @@ import {UserActionAddPuaControlComponent} from '../../../user-actions/add-pua-co const FILE_TREE_METADATA_TRANSLATE_PATH = 'PROFILE.EDIT_PROFILE.FILE_TREE_METADATA'; +const ADD_PUA_CONTROL_TRANSLATE_PATH = 'USER_ACTION.ADD_PUA_CONTROL'; function constantToTranslate() { this.notificationAjoutMetadonnee = this.translated('.NOTIFICATION_AJOUT_METADONNEE'); @@ -81,6 +82,8 @@ function constantToTranslate() { this.popupValider = this.translated('.POPUP_VALIDER'); this.popupAnnuler = this.translated('.POPUP_ANNULER'); this.popupControlOkLabel = this.translated('.POPUP_CONTROL_OK_BUTTON_LABEL'); + this.popupControlSubTitleDialog = this.translated('.POPUP_CONTROL_SUB_TITLE_DIALOG'); + this.popupControlTitleDialog = this.translated('.POPUP_CONTROL_TITLE_DIALOG'); } @Component({ @@ -566,16 +569,16 @@ export class FileTreeMetadataComponent { } setControlsVues(elements: string[]){ - if(elements.includes("Enumération")){ + if((this.isStandalone && elements.includes("Enumération")) || elements.includes(this.translated(ADD_PUA_CONTROL_TRANSLATE_PATH + '.ENUMERATIONS_LABEL'))){ this.enumerationControl = true; } - if(elements.includes("Expression régulière")){ + if((this.isStandalone && elements.includes("Expression régulière")) || elements.includes(this.translated(ADD_PUA_CONTROL_TRANSLATE_PATH + '.EXPRESSION_REGULIERE_LABEL'))){ this.expressionControl = true; } - if(elements.includes("Longueur Min/Max")){ + if((this.isStandalone && elements.includes("Longueur Min/Max")) || elements.includes(this.translated(ADD_PUA_CONTROL_TRANSLATE_PATH + '.LENGTH_MIN_MAX_LABEL'))){ this.lengthControl = true; } - if(elements.includes("Valeur Min/Max")){ + if((this.isStandalone && elements.includes("Valeur Min/Max")) || elements.includes(this.translated(ADD_PUA_CONTROL_TRANSLATE_PATH + '.VALUE_MIN_MAX_LABEL'))){ this.valueControl = true; } diff --git a/ui/ui-frontend/projects/pastis/src/assets/i18n/en.json b/ui/ui-frontend/projects/pastis/src/assets/i18n/en.json index a10de77cc..d80d2fc91 100644 --- a/ui/ui-frontend/projects/pastis/src/assets/i18n/en.json +++ b/ui/ui-frontend/projects/pastis/src/assets/i18n/en.json @@ -183,7 +183,9 @@ "VALEUR_FIXE": "Fixed value", "COMMENTAIRE": "Comment" }, - "POPUP_CONTROL_OK_BUTTON_LABEL": "ADD CONTROLS" + "POPUP_CONTROL_OK_BUTTON_LABEL": "ADD CONTROLS", + "POPUP_CONTROL_SUB_TITLE_DIALOG": "Add additional controls to", + "POPUP_CONTROL_TITLE_DIALOG": "Please select one or more controls" } }, "LIST_PROFILE": { diff --git a/ui/ui-frontend/projects/pastis/src/assets/i18n/fr.json b/ui/ui-frontend/projects/pastis/src/assets/i18n/fr.json index 490100c5a..916462a4e 100644 --- a/ui/ui-frontend/projects/pastis/src/assets/i18n/fr.json +++ b/ui/ui-frontend/projects/pastis/src/assets/i18n/fr.json @@ -183,7 +183,9 @@ "VALEUR_FIXE": "Valeur fixe", "COMMENTAIRE": "Commentaire" }, - "POPUP_CONTROL_OK_BUTTON_LABEL": "AJOUTER LES CONTROLES" + "POPUP_CONTROL_OK_BUTTON_LABEL": "AJOUTER LES CONTROLES", + "POPUP_CONTROL_SUB_TITLE_DIALOG": "Ajouter des contrôles supplémentaires à", + "POPUP_CONTROL_TITLE_DIALOG": "Veuillez séléctionner un ou plusieurs contrôles" } }, "LIST_PROFILE": { -- GitLab From 6e435400255fa92c89fe33f88b6a22e1b1b4ed6f Mon Sep 17 00:00:00 2001 From: naji Date: Wed, 9 Mar 2022 09:30:32 +0100 Subject: [PATCH 06/16] feat: display only regularExpression and enumeration control --- .../user-actions/add-pua-control/add-pua-control.component.ts | 2 -- 1 file changed, 2 deletions(-) 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 ca81db210..5897e77ff 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 @@ -146,8 +146,6 @@ export class UserActionAddPuaControlComponent implements OnInit { }else{ this.allowedChildren = [ this.enumerationsLabel, - this.valueMinMaxLabel, - this.lengthMinMaxLabel, this.expressionReguliereLabel ]; this.addedItems = []; -- GitLab From 54b1de5e2789982a31865ea3bfc24a60691bf913 Mon Sep 17 00:00:00 2001 From: Baptiste Toulemonde Date: Wed, 9 Mar 2022 09:41:18 +0100 Subject: [PATCH 07/16] test 201 fonctionelle wip --- .../file-tree-metadata.component.html | 66 ++++++++++++------- .../file-tree-metadata.component.ts | 7 +- 2 files changed, 50 insertions(+), 23 deletions(-) diff --git a/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree-metadata/file-tree-metadata.component.html b/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree-metadata/file-tree-metadata.component.html index 8502d8c50..1dd928dc9 100644 --- a/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree-metadata/file-tree-metadata.component.html +++ b/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree-metadata/file-tree-metadata.component.html @@ -203,11 +203,11 @@ - -
-
-