diff --git a/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/dto/pua/PuaMetadataDetails.java b/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/dto/pua/PuaMetadataDetails.java index 2214356dc005d0b1bbd1fb90f72ed0fbcb767f4a..d6416c80ab77a2010a4e22199f5ebdfee79189a4 100644 --- a/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/dto/pua/PuaMetadataDetails.java +++ b/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/dto/pua/PuaMetadataDetails.java @@ -56,4 +56,5 @@ public class PuaMetadataDetails { List required; PuaMetadata items; List enums; + String pattern; } diff --git a/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/service/PuaPastisValidator.java b/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/service/PuaPastisValidator.java index 14ffa73541cdd0a3cec4a487d7f53ecfcd4edbd2..7b542a5c552515d93edb9d878aa99b2dc58d17c4 100644 --- a/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/service/PuaPastisValidator.java +++ b/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/service/PuaPastisValidator.java @@ -619,6 +619,9 @@ public class PuaPastisValidator { puaMetadataDetails.setMinItems(0); puaMetadataDetails.setMaxItems(1); } + if(!sedaElement.getElement().equals(COMPLEX) && el.getPuaData() != null && el.getPuaData().getPattern() != null){ + puaMetadataDetails.setPattern(el.getPuaData().getPattern()); + } if(el.getPuaData() != null && el.getPuaData().getEnum() != null){ puaMetadataDetails.setEnums(el.getPuaData().getEnum()); }else{ diff --git a/ui/ui-frontend/projects/pastis/src/app/models/file-node.ts b/ui/ui-frontend/projects/pastis/src/app/models/file-node.ts index 991d519500d8cfd9ae926ef697ddabe1b0631d48..a76ba6d088674a5f5b10c7a48ff44cea8b34e2f8 100644 --- a/ui/ui-frontend/projects/pastis/src/app/models/file-node.ts +++ b/ui/ui-frontend/projects/pastis/src/app/models/file-node.ts @@ -93,6 +93,12 @@ export enum ValueOrDataConstants { undefined = 'undefined' } +export enum DateFormatType { + dateType = 'DateType', + date = 'date', + dateTime = "dateTime" +} + export interface FileNode { additionalProperties:boolean; id: number; diff --git a/ui/ui-frontend/projects/pastis/src/app/models/models.ts b/ui/ui-frontend/projects/pastis/src/app/models/models.ts index a1ee346b63b235001200b00fabb8243cdec70f9d..de36c60f2742cc1aec7ab1a77df98d77913353c3 100644 --- a/ui/ui-frontend/projects/pastis/src/app/models/models.ts +++ b/ui/ui-frontend/projects/pastis/src/app/models/models.ts @@ -49,4 +49,4 @@ export interface MetadataHeaders { cardinalite: string[]; commentaire: string; enumeration: string[]; - } + } \ No newline at end of file diff --git a/ui/ui-frontend/projects/pastis/src/app/models/pua-data.ts b/ui/ui-frontend/projects/pastis/src/app/models/pua-data.ts index 62508789f5776c58c651794845858409adedba1f..760e95db544b05f8abf93a109ac594747c7be2e2 100644 --- a/ui/ui-frontend/projects/pastis/src/app/models/pua-data.ts +++ b/ui/ui-frontend/projects/pastis/src/app/models/pua-data.ts @@ -1,12 +1,12 @@ export interface PuaData { - additionalProperties: boolean; - Enum: string[]; - pattern: string; - minLenght: number; - maxLenght: number; - minimum: number; - maximum: number; - exclusiveMinimum: boolean; - exclusiveMaximum: boolean; + additionalProperties?: boolean; + enum?: string[]; + pattern?: string; + minLenght?: number; + maxLenght?: number; + minimum?: number; + maximum?: number; + exclusiveMinimum?: boolean; + exclusiveMaximum?: boolean; } 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 cc502bb8bfda223bdb766ec6c1c340823589215c..bbcf815bf7cfc70bab2a0706041ab6976610dbfe 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 @@ -234,11 +234,11 @@ - - + - - - - {{country.label}} - - -
- keyboard_arrow_up - keyboard_arrow_down +
+
+ + + + {{element}} + + +
+ keyboard_arrow_up + keyboard_arrow_down +
+
+ + + + +
+
+
+
+
+ + {{item}} + + + ×
- - +
- +
+ + + +
+
+
+ + {{'PROFILE.EDIT_PROFILE.FILE_TREE_METADATA.FORMATAGE_PREDEFINI' | + translate}}: + +
+
+ + + + + + {{predefiniElement.label}} + + + + + + + {{predefiniElement.label}} + + + +
+ keyboard_arrow_up + keyboard_arrow_down +
+
+
- +
- -
- - - - -
+
+
+
+ + +
+
+ + +
+
+ +
+
+ + +
+ +
+ diff --git a/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree-metadata/file-tree-metadata.component.scss b/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree-metadata/file-tree-metadata.component.scss index b1d677d4d349ad209bb4b03c4e7637ec51368b9f..9485371fcd1edfc88410b62b37d6f0d63b1283af 100644 --- a/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree-metadata/file-tree-metadata.component.scss +++ b/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree-metadata/file-tree-metadata.component.scss @@ -9,8 +9,16 @@ @import '~ui-frontend-common/sass/icons/vitamui-icons'; @import '~ui-frontend-common/sass/variables/colors'; @import '~ui-frontend-common/sass/editable-field'; +@import '../../../user-actions/add-metadata/add-metadata.component.scss'; +.pastis-container-selected-items{ + margin-left: 50px; +} +.pastis-container-button-submit-controls{ + margin-left: 50px; +} + td { padding-right: 20px !important; } @@ -157,6 +165,7 @@ td { } + .commentaire-pastis { .editable-field { min-height: 50px !important; @@ -210,7 +219,6 @@ td { margin: 5px; } - table { width: 100%; @include mat-table-columns(( 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 03e824f5f087557635d67462a5012da65851ba4a..0144270b8df65ac9c458a649816adb1080631168 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 @@ -38,12 +38,23 @@ knowledge of the CeCILL-C license and that you accept its terms. import {CdkTextareaAutosize} from '@angular/cdk/text-field'; import {Component, EventEmitter, Output, ViewChild, ViewEncapsulation} from '@angular/core'; import {FormBuilder, FormControl, FormGroup, Validators} from '@angular/forms'; +import {MatCheckboxChange} from '@angular/material/checkbox'; import {MatTableDataSource} from '@angular/material/table'; +import {Router} from '@angular/router'; +import {LangChangeEvent, TranslateService} from '@ngx-translate/core'; +import {environment} from 'projects/pastis/src/environments/environment'; +import {Subscription} from 'rxjs'; +import {StartupService} from 'ui-frontend-common'; import {FileService} from '../../../core/services/file.service'; +import {NotificationService} from '../../../core/services/notification.service'; +import {ProfileService} from '../../../core/services/profile.service'; import {SedaService} from '../../../core/services/seda.service'; +import {BreadcrumbDataMetadata, BreadcrumbDataTop} from '../../../models/breadcrumb'; +import {AttributeData} from '../../../models/edit-attribute-models'; import { CardinalityConstants, DataTypeConstants, + DateFormatType, FileNode, FileNodeInsertAttributeParams, FileNodeInsertParams, @@ -51,27 +62,19 @@ import { TypeConstants, ValueOrDataConstants } from '../../../models/file-node'; +import {CardinalityValues, MetadataHeaders} from '../../../models/models'; import {SedaData, SedaElementConstants} from '../../../models/seda-data'; -import {FileTreeMetadataService} from './file-tree-metadata.service'; -import {AttributesPopupComponent} from './attributes/attributes.component'; -import {AttributeData} from '../../../models/edit-attribute-models'; -import {ProfileService} from '../../../core/services/profile.service'; -import {BreadcrumbDataMetadata, BreadcrumbDataTop} from '../../../models/breadcrumb'; -import {StartupService} from 'ui-frontend-common'; -import {Router} from '@angular/router'; -import {Subscription} from "rxjs"; -import {MatCheckboxChange} from "@angular/material/checkbox"; +import {PastisDialogData} from '../../../shared/pastis-dialog/classes/pastis-dialog-data'; import {PastisPopupMetadataLanguageService} from '../../../shared/pastis-popup-metadata-language/pastis-popup-metadata-language.service'; import {FileTreeService} from '../file-tree/file-tree.service'; -import {LangChangeEvent, TranslateService} from "@ngx-translate/core"; -import {CardinalityValues, MetadataHeaders} from '../../../models/models'; -import {NotificationService} from '../../../core/services/notification.service'; -import {PastisDialogData} from '../../../shared/pastis-dialog/classes/pastis-dialog-data'; -import {environment} from 'projects/pastis/src/environments/environment'; -import {UserActionAddPuaControlComponent} from "../../../user-actions/add-pua-control/add-pua-control.component"; +import {UserActionAddPuaControlComponent} from '../../../user-actions/add-pua-control/add-pua-control.component'; +import {AttributesPopupComponent} from './attributes/attributes.component'; +import {FileTreeMetadataService} from './file-tree-metadata.service'; +import {PuaData} from '../../../models/pua-data'; 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'); @@ -80,6 +83,9 @@ 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'); + this.popupControlSubTitleDialog = this.translated('.POPUP_CONTROL_SUB_TITLE_DIALOG'); + this.popupControlTitleDialog = this.translated('.POPUP_CONTROL_TITLE_DIALOG'); } @Component({ @@ -106,6 +112,8 @@ export class FileTreeMetadataComponent { displayedColumns: string[] = ['nomDuChamp', 'valeurFixe', 'cardinalite', 'commentaire', 'menuoption']; + selectedRegex: string = ""; + clickedNode: FileNode = {} as FileNode; sedaData: SedaData = {} as SedaData; @@ -131,6 +139,29 @@ export class FileTreeMetadataComponent { isStandalone: boolean = environment.standalone; + enumerationControl: boolean; + valueControl: boolean; + lengthControl: boolean; + expressionControl: boolean; + arrayControl: string[]; + clickedControl: FileNode; + enumerationsSedaControl: string[]; + enumsControlSeleted: string[] = []; + editedEnumControl: string[]; + openControls: boolean; + + radioExpressionReguliere: string = "select"; + regex: string; + customRegex: string; + formatagePredefini: Array<{label: string, value: string}> = + [ + { label: 'AAAA-MM-JJ', value: '[0-9]{4}-[0-9]{2}-[0-9]{2}' }, + { label: 'AAAA-MM-JJTHH:MM:SS', value: '[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}' }, + { label: 'AAAA', value: '[0-9]{4}' }, + { label: 'AAAA-MM', value: '[0-9]{4}-[0-9]{2}' }, + { label: 'Adresse mail', value: '[a-z0-9._%+-]+@[a-z0-9.-]+\\.[a-z]{2,4}' } + ]; + public breadcrumbDataTop: Array; public breadcrumbDataMetadata: Array; @@ -145,6 +176,9 @@ export class FileTreeMetadataComponent { popupSousTitre: string; popupValider: string; popupAnnuler: string; + popupControlTitleDialog: string; + popupControlSubTitleDialog: string; + popupControlOkLabel: string; @Output() public insertItem: EventEmitter = new EventEmitter(); @@ -218,6 +252,9 @@ export class FileTreeMetadataComponent { this.popupSousTitre = 'Edition des attributs de'; this.popupValider = 'Valider'; this.popupAnnuler = 'Annuler'; + this.popupControlTitleDialog = "Veuillez séléctionner un ou plusieurs contrôles"; + this.popupControlSubTitleDialog = "Ajouter des contrôles supplémentaires à"; + this.popupControlOkLabel = 'AJOUTER LES CONTROLES'; } this.additionalProperties = false; @@ -432,6 +469,13 @@ export class FileTreeMetadataComponent { } } + isAloneAndSimple(metadatas: MatTableDataSource): boolean { + if (metadatas.data.length === 1 && !this.isElementComplex(metadatas.data[0].nomDuChamp)) { + return true; + } + return false; + } + onAddNode() { if (this.clickedNode.name === 'DescriptiveMetadata') { console.log('Yes'); @@ -527,22 +571,72 @@ export class FileTreeMetadataComponent { } async onEditControlClick(fileNodeId: number) { - alert(fileNodeId) let popData = {} as PastisDialogData; - if (fileNodeId) { + if (fileNodeId && fileNodeId === this.clickedNode.id) { + this.resetContols(); popData.fileNode = this.fileService.findChildById(fileNodeId, this.clickedNode); - popData.titleDialog = "Veuillez séléctionner un ou plusieurs contrôles"; - popData.subTitleDialog = "Ajouter des contrôles supplémentaires à Title"; - popData.width = '1120px'; - popData.component = UserActionAddPuaControlComponent - popData.okLabel = 'AJOUTER LES CONTROLES' - popData.cancelLabel = this.popupAnnuler + popData.titleDialog = this.popupControlTitleDialog; + popData.subTitleDialog = this.popupControlSubTitleDialog + ' "' + popData.fileNode.name + '"'; + this.clickedControl = popData.fileNode; + popData.width = '800px'; + popData.component = UserActionAddPuaControlComponent; + popData.okLabel = this.popupControlOkLabel; + popData.cancelLabel = this.popupAnnuler; - let popUpAnswer = await this.fileService.openPopup(popData); - console.log("The answer for edit attributte was ", popUpAnswer); + let popUpAnswer = await this.fileService.openPopup(popData); + console.log("The answer for arrays control was ", popUpAnswer); + if(popUpAnswer){ + this.arrayControl = popUpAnswer; + this.setControlsVues(this.arrayControl, popData.fileNode.name) + this.openControls = true; + } } } + resetContols(){ + this.arrayControl = []; + this.enumerationControl = false; + this.expressionControl = false; + this.lengthControl = false; + this.valueControl = false; + this.enumsControlSeleted = []; + this.editedEnumControl = []; + this.openControls = false; + } + + setControlsVues(elements: string[], sedaName: string){ + if((this.isStandalone && elements.includes("Enumération")) || elements.includes(this.translated(ADD_PUA_CONTROL_TRANSLATE_PATH + '.ENUMERATIONS_LABEL'))){ + this.enumerationControl = true; + this.enumerationsSedaControl = this.sedaService.findSedaChildByName(sedaName, this.selectedSedaNode).Enumeration; + } + if((this.isStandalone && elements.includes("Expression régulière")) || elements.includes(this.translated(ADD_PUA_CONTROL_TRANSLATE_PATH + '.EXPRESSION_REGULIERE_LABEL'))){ + this.expressionControl = true; + let type: string = this.sedaService.findSedaChildByName(sedaName, this.selectedSedaNode).Type; + switch (type) { + case DateFormatType.date: + this.formatagePredefini = this.formatagePredefini.filter(e => e.label === 'AAAA-MM-JJ'); + break; + case DateFormatType.dateTime: + this.formatagePredefini = this.formatagePredefini.filter(e => e.label === 'AAAA-MM-JJTHH:MM:SS'); + break; + case DateFormatType.dateType: + this.formatagePredefini.pop(); + break; + default: + this.formatagePredefini = this.formatagePredefini.filter(e => e.label === 'AAAA-MM-JJ' || e.label === 'AAAA' || e.label === 'Adresse mail'); + break; + } + this.regex = this.formatagePredefini[0].value; + } + 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((this.isStandalone && elements.includes("Valeur Min/Max")) || elements.includes(this.translated(ADD_PUA_CONTROL_TRANSLATE_PATH + '.VALUE_MIN_MAX_LABEL'))){ + this.valueControl = true; + } + + } + onDeleteNode(nodeId: number) { const nodeToDelete = this.fileService.getFileNodeById(this.fileService.nodeChange.getValue(), nodeId); this.removeNode.emit(nodeToDelete); @@ -711,6 +805,65 @@ export class FileTreeMetadataComponent { return this.sedaService.isDuplicated(nomDuChamp, this.selectedSedaNode); } + isEmptyEnumeration(enumerations: string[]): boolean{ + return enumerations.length === 0; + } + + setPatternExpressionReguliere() { + if(!this.clickedControl.puaData){ + this.clickedControl.puaData = {} as PuaData; + } + + this.clickedControl.puaData.pattern = (this.radioExpressionReguliere === 'select') ? this.regex : this.customRegex; + console.log(this.clickedControl) + } + + onSubmitControls(){ + if(this.enumerationControl && this.enumsControlSeleted.length > 0){ + if(this.clickedNode.puaData){ + this.clickedNode.puaData.enum = this.enumsControlSeleted; + }else{ + this.clickedNode.puaData = { + enum: this.enumsControlSeleted + } + } + + } + if(this.expressionControl){ + this.setPatternExpressionReguliere(); + } + this.resetContols() + } + + onRemoveEnumsControl(element: string) { + let indexOfElement = this.enumsControlSeleted.indexOf(element) + if (indexOfElement >= 0) { + this.enumsControlSeleted.splice(indexOfElement, 1)[0]; + this.editedEnumControl = [] + this.enumsControlSeleted.forEach( e => { + this.editedEnumControl.push(e) + }) + } + + if(this.editedEnumControl.includes(element)){ + indexOfElement = this.editedEnumControl.indexOf(element) + this.editedEnumControl.splice(indexOfElement, 1)[0]; + } + if(this.enumsControlSeleted.length === 0) this.editedEnumControl = null; + } + + addEnumsControl(element: string){ + this.enumsControlSeleted.push(element); + } + addEnumsControlList(elements: string[]){ + this.enumsControlSeleted = elements; + } + + closeControlsVue(){ + this.openControls = false; + this.resetContols(); + } + changeStatusAditionalProperties($event: boolean) { this.additionalProperties = $event; } @@ -736,4 +889,5 @@ export class FileTreeMetadataComponent { } } + } 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 f847c09e850e072ac6855a6a39bdc3f872620760..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 @@ - + @@ -40,9 +40,4 @@ - - - - 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 92bece8b2c1341d7fb821adf6faf11652a8257b5..5897e77ffe2b86671cf71c942fb6496b62227ab8 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,26 @@ 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 { 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'; +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', @@ -55,45 +64,30 @@ import { PastisPopupMetadataLanguageService } from '../../shared/pastis-popup-me export class UserActionAddPuaControlComponent implements OnInit { btnIsDisabled: boolean; - - sedaData: SedaData; - allowedChildren: string[] = [ - "Enumération", - "Expression régulière", - "Longueur Min/Max", - "Valeur Min/Max" - ] - namesFiltered: any = []; - sedaNodeFound: SedaData; - selectedSedaNode: SedaData; + enumerationsLabel: string = "Enumération"; + 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[]; addedItems: string[] = []; dialogData: PastisDialogData; atLeastOneIsSelected: boolean; - customTemplate: TemplateRef - fileNode: FileNode; - sedaLanguage: boolean; - sedaLanguageSub: Subscription; + isStandalone: boolean = environment.standalone; constructor(public dialogRef: MatDialogRef, - private fileService: FileService, private sedaService: SedaService, - private popUpService: PopupService, private sedaLanguageService: PastisPopupMetadataLanguageService) { } - - ngOnInit() { - this.sedaLanguageSub = this.sedaLanguageService.sedaLanguage.subscribe( - (value: boolean) => { - this.sedaLanguage = value; - }, - (error) => { - console.log(error) + private popUpService: PopupService, private translateService: TranslateService) { + if(!this.isStandalone){ + constantToTranslate.call(this); + this.translatedOnChange(); } - ); - this.fileService.nodeChange.subscribe(fileNode => { this.fileNode = fileNode }) - this.sedaData = this.sedaService.sedaRules[0]; - - this.sedaNodeFound = this.fileNode.sedaData; + this.refreshAllowedChildren(); + } + ngOnInit() { // Subscribe observer to button status and // set the inital state of the ok button to disabled this.popUpService.btnYesShoudBeDisabled.subscribe(status => { @@ -101,28 +95,26 @@ export class UserActionAddPuaControlComponent implements OnInit { }) } - - isElementSelected(element: string) { - if (this.addedItems) { - return this.addedItems.includes(element); - } - } - onRemoveSelectedElement(element: string) { - let indexOfElement = this.addedItems.indexOf(element) - console.log(indexOfElement) - if (indexOfElement >= 0) { - this.allowedChildren.push(this.addedItems.splice(indexOfElement, 1)[0]) + if(this.isExclusive(element)){ + this.refreshAllowedChildren(); + }else{ + let indexOfElement = this.addedItems.indexOf(element) + 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(); } onAddSelectedElement(element: string) { this.addedItems.push(element); - - this.allowedChildren = this.allowedChildren.filter(e => e != element); + if(this.isExclusive(element)){ + this.refreshAllowedChildren(element); + }else{ + this.allowedChildren = this.allowedChildren.filter(e => e != element); + } this.addedItems.length > 0 ? this.atLeastOneIsSelected = true : this.atLeastOneIsSelected = false this.upateButtonStatusAndDataToSend(); } @@ -132,43 +124,44 @@ 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 + } + if(element === this.expressionReguliereLabel){ + return this.expressionReguliereDefinition } + return ''; } - getDefinition(element: SedaData): string { - return element ? element.Definition : ''; + isExclusive(element: string): boolean{ + return element === this.valueMinMaxLabel || element === this.enumerationsLabel; } - onYesClick(): void { - console.log("Clicked ok on dialog : %o", this.selectedSedaNode); - - } - onNoClick(): void { - this.dialogRef.close(); + refreshAllowedChildren(element?: string){ + + if(element){ + this.addedItems = [element]; + this.allowedChildren = []; + }else{ + this.allowedChildren = [ + this.enumerationsLabel, + this.expressionReguliereLabel + ]; + this.addedItems = []; + } } - onResolveName(element: SedaData): string { - if (this.sedaLanguage) { - return element.Name; - } - else { - if (element.NameFr) { - return element.NameFr; - } - } - return element.Name; + translatedOnChange(): void { + this.translateService.onLangChange + .subscribe((event: LangChangeEvent) => { + constantToTranslate.call(this); + console.log(event.lang); + }); } - ngOnDestroy(): void { - if (this.sedaLanguageSub != null) { - this.sedaLanguageSub.unsubscribe(); - } + + translated(nameOfFieldToTranslate: string): string { + return this.translateService.instant(ADD_PUA_CONTROL_TRANSLATE_PATH + nameOfFieldToTranslate); } } diff --git a/ui/ui-frontend/projects/pastis/src/app/user-actions/user-actions.module.ts b/ui/ui-frontend/projects/pastis/src/app/user-actions/user-actions.module.ts index f754fa0994f2cc77f1f7a7a9d7ec01abe9c23828..9916aea465114342bac2d6ec92bb829f4cce643f 100644 --- a/ui/ui-frontend/projects/pastis/src/app/user-actions/user-actions.module.ts +++ b/ui/ui-frontend/projects/pastis/src/app/user-actions/user-actions.module.ts @@ -35,18 +35,17 @@ 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 {NgModule} from '@angular/core'; import {CommonModule} from '@angular/common'; +import {NgModule} from '@angular/core'; import {FileUploadModule} from 'ng2-file-upload'; -import {UserActionUploadProfileComponent} from './upload-profile/upload-profile.component'; -import {SharedModule} from '../shared/shared.module' -import {FilterByNamePipe} from './add-metadata/add-metadata.component'; -import {UserActionSaveProfileComponent} from './save-profile/save-profile.component'; import {PastisMaterialModule} from '../material.module'; +import {SharedModule} from '../shared/shared.module'; +import {FilterByNamePipe} from './add-metadata/add-metadata.component'; import {UserActionsDownloadDocComponent} from './download-doc/download-doc.component'; import {DuplicateMetadataComponent} from './duplicate-metadata/duplicate-metadata.component'; import {UserActionAddPuaControlComponent} from './add-pua-control/add-pua-control.component'; - +import {UserActionSaveProfileComponent} from './save-profile/save-profile.component'; +import {UserActionUploadProfileComponent} from './upload-profile/upload-profile.component'; import {FormsModule, ReactiveFormsModule} from '@angular/forms'; import {MatFormFieldModule} from '@angular/material/form-field'; import {MatInputModule} from '@angular/material/input'; @@ -55,7 +54,6 @@ import {VitamUIInputModule} from 'vitamui-library'; import {CoreModule} from '../core/core.module'; import {CreateNoticeComponent} from './create-notice/create-notice.component'; import {SaveProfileOptionsComponent} from './save-profile-options/save-profile-options.component'; -import {AllowAdditionalPropertiesComponent} from './allow-additional-properties/allow-additional-properties.component'; @NgModule({ diff --git a/ui/ui-frontend/projects/pastis/src/assets/i18n-old/en.json b/ui/ui-frontend/projects/pastis/src/assets/i18n-old/en.json index 2f3e41d73112570d951c1a3f90bcacfdbd38c012..f2176a459711743bab1d9438741ca0ac88cdf807 100644 --- a/ui/ui-frontend/projects/pastis/src/assets/i18n-old/en.json +++ b/ui/ui-frontend/projects/pastis/src/assets/i18n-old/en.json @@ -87,6 +87,7 @@ "DUPLIQUER": "Duplicate", "CONTROLE_METADONNEE": "Metadata control", "ATTRIBUT_METADONNEE": "Metadata attributes", + "INFO_EXPRESSION": "List to perform predefined checks for certain values (e.g. date or email address)", "SUPPRIMER": "Remove", "MESSAGE_METADONNEE_SANS_FILLES": { "PARTIEUN": "The metadata", diff --git a/ui/ui-frontend/projects/pastis/src/assets/i18n-old/fr.json b/ui/ui-frontend/projects/pastis/src/assets/i18n-old/fr.json index e202c3ff4a81a63627c6b44a16c90f904fd3c6d6..aaf5aab7fc494a06982b26708d2e678ab3c1c9d2 100644 --- a/ui/ui-frontend/projects/pastis/src/assets/i18n-old/fr.json +++ b/ui/ui-frontend/projects/pastis/src/assets/i18n-old/fr.json @@ -84,6 +84,7 @@ "DUPLIQUER": "Dupliquer", "CONTROLE_METADONNEE": "Contrôle de métadonnée", "ATTRIBUT_METADONNEE": "Attributs de métadonnée", + "INFO_EXPRESSION": "Liste permettant d'effectuer des contrôles prédéfinis pour certaines valeurs (par ex. une date ou une adresse email)", "SUPPRIMER": "Supprimer", "MESSAGE_METADONNEE_SANS_FILLES": { "PARTIEUN": "La métadonnée", 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 813d70729e59bf8a6f37d6396c52c4a021583ddc..08ff2cf7b74d0dae75e92aba2ea48db7f71b1500 100644 --- a/ui/ui-frontend/projects/pastis/src/assets/i18n/en.json +++ b/ui/ui-frontend/projects/pastis/src/assets/i18n/en.json @@ -184,7 +184,10 @@ "NOM_ATTRIBUT": "Attribute name", "VALEUR_FIXE": "Fixed value", "COMMENTAIRE": "Comment" - } + }, + "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": { @@ -216,6 +219,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 2931434883e79d3c5cf65b1ebffa682317249475..0713d3956d610e1e9b49e499075b98e4a9a1c8e7 100644 --- a/ui/ui-frontend/projects/pastis/src/assets/i18n/fr.json +++ b/ui/ui-frontend/projects/pastis/src/assets/i18n/fr.json @@ -184,7 +184,10 @@ "NOM_ATTRIBUT": "Nom de l'attribut", "VALEUR_FIXE": "Valeur fixe", "COMMENTAIRE": "Commentaire" - } + }, + "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": { @@ -216,6 +219,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": { diff --git a/ui/ui-frontend/projects/pastis/src/assets/seda.json b/ui/ui-frontend/projects/pastis/src/assets/seda.json index ca12001dd927e2a8fafcf6127ccdba6feedaa896..0dab491dc2e8e57f6a5e39ce2bb9761bf926dd72 100644 --- a/ui/ui-frontend/projects/pastis/src/assets/seda.json +++ b/ui/ui-frontend/projects/pastis/src/assets/seda.json @@ -7248,7 +7248,7 @@ "NameFr": "Date de naissance", "Element": "Simple", "Cardinality": "0-1", - "Type": "token", + "Type": "date", "Choice": "no", "Extensible": "no", "Enumeration": [], @@ -7353,7 +7353,7 @@ "NameFr": "Date de décès", "Element": "Simple", "Cardinality": "0-1", - "Type": "token", + "Type": "date", "Choice": "no", "Extensible": "no", "Enumeration": [], @@ -10571,7 +10571,7 @@ "NameFr": "Date de création", "Element": "Simple", "Cardinality": "0-1", - "Type": "token", + "Type": "DateType", "Choice": "no", "Extensible": "no", "Enumeration": [], @@ -10584,7 +10584,7 @@ "NameFr": "Date de la transaction", "Element": "Simple", "Cardinality": "0-1", - "Type": "token", + "Type": "DateType", "Choice": "no", "Extensible": "no", "Enumeration": [], @@ -10597,7 +10597,7 @@ "NameFr": "Date de numérisation", "Element": "Simple", "Cardinality": "0-1", - "Type": "token", + "Type": "DateType", "Choice": "no", "Extensible": "no", "Enumeration": [], @@ -10610,7 +10610,7 @@ "NameFr": "Date d’envoi", "Element": "Simple", "Cardinality": "0-1", - "Type": "token", + "Type": "DateType", "Choice": "no", "Extensible": "no", "Enumeration": [], @@ -10623,7 +10623,7 @@ "NameFr": "Date de réception", "Element": "Simple", "Cardinality": "0-1", - "Type": "token", + "Type": "DateType", "Choice": "no", "Extensible": "no", "Enumeration": [], @@ -10636,7 +10636,7 @@ "NameFr": "Date d’enregistrement", "Element": "Simple", "Cardinality": "0-1", - "Type": "token", + "Type": "DateType", "Choice": "no", "Extensible": "no", "Enumeration": [], @@ -10649,7 +10649,7 @@ "NameFr": "Date de début", "Element": "Simple", "Cardinality": "0-1", - "Type": "token", + "Type": "DateType", "Choice": "no", "Extensible": "no", "Enumeration": [], @@ -10662,7 +10662,7 @@ "NameFr": "Date de fin", "Element": "Simple", "Cardinality": "0-1", - "Type": "token", + "Type": "DateType", "Choice": "no", "Extensible": "no", "Enumeration": [], @@ -10726,7 +10726,7 @@ "NameFr": "Date et heure de l'événement", "Element": "Simple", "Cardinality": "1", - "Type": "token", + "Type": "DateType", "Choice": "no", "Extensible": "no", "Enumeration": [], @@ -11158,7 +11158,7 @@ "NameFr": "Date de signature", "Element": "Simple", "Cardinality": "1", - "Type": "token", + "Type": "dateTime", "Choice": "no", "Extensible": "no", "Enumeration": [], @@ -11634,7 +11634,7 @@ "NameFr": "Date de la validation de la signature", "Element": "Simple", "Cardinality": "1", - "Type": "token", + "Type": "dateTime", "Choice": "no", "Extensible": "no", "Enumeration": [],