Commit 987761cc authored by naji's avatar naji
Browse files

Work in progress

	 - new dto puaData
	 - modification back pastis pour priorise les controls pua sur les enumeration
	 - maquette controle schemas non terminé
parent ec6884c8
......@@ -619,13 +619,17 @@ public class PuaPastisValidator {
puaMetadataDetails.setMinItems(0);
puaMetadataDetails.setMaxItems(1);
}
if (!sedaElement.getEnumeration().isEmpty() && el.getValue() == null) {
puaMetadataDetails.setEnums(sedaElement.getEnumeration());
}
if (el.getValue() != null) {
ArrayList<String> list = new ArrayList<>();
list.add(el.getValue());
puaMetadataDetails.setEnums(list);
if(el.getPuaData() != null && el.getPuaData().getEnum() != null){
puaMetadataDetails.setEnums(el.getPuaData().getEnum());
}else{
if (!sedaElement.getEnumeration().isEmpty() && el.getValue() == null) {
puaMetadataDetails.setEnums(sedaElement.getEnumeration());
}
if (el.getValue() != null) {
ArrayList<String> list = new ArrayList<>();
list.add(el.getValue());
puaMetadataDetails.setEnums(list);
}
}
}
......
......@@ -35,7 +35,7 @@ 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 { PUA } from './pua.model';
import { PuaData } from './pua-data';
import { SedaData } from './seda-data';
/**
......@@ -109,7 +109,7 @@ export interface FileNode {
children: FileNode[];
parent: FileNode;
sedaData: SedaData;
puaData?: PUA;
puaData?: PuaData;
}
export interface FileNodeInsertParams {
......
export interface PuaData {
additionalProperties: boolean;
Enum: string[];
pattern: string;
minLenght: number;
maxLenght: number;
minimum: number;
maximum: number;
exclusiveMinimum: boolean;
exclusiveMaximum: boolean;
}
......@@ -203,10 +203,11 @@
</button>
<!-- Contrôle de métadonées => PUA -->
<mat-divider *ngIf="this.profileService.profileMode === 'PUA' && !isElementComplex(element.nomDuChamp)"
<mat-divider
*ngIf="this.profileService.profileMode === 'PUA' && !isElementComplex(element.nomDuChamp)"
style="border-top-color:#E0E0E0;">
</mat-divider>
<button *ngIf="this.profileService.profileMode === 'PUA' && !isElementComplex(element.nomDuChamp)"
<button (click)="onEditControlClick(element.id)" *ngIf="this.profileService.profileMode === 'PUA' && !isElementComplex(element.nomDuChamp)"
mat-menu-item>
<mat-icon style="color:#757575"><i class="vitamui-icon vitamui-icon-ic24-PUA"></i></mat-icon>
<span class="text normal">{{'PROFILE.EDIT_PROFILE.FILE_TREE_METADATA.CONTROLE_METADONNEE' |
......@@ -299,4 +300,4 @@
</ng-template>
</mat-sidenav-content>
</mat-sidenav-container>
\ No newline at end of file
</mat-sidenav-container>
......@@ -68,6 +68,7 @@ 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';
const FILE_TREE_METADATA_TRANSLATE_PATH = 'PROFILE.EDIT_PROFILE.FILE_TREE_METADATA';
......@@ -191,7 +192,7 @@ export class FileTreeMetadataComponent {
constructor(private fileService: FileService, private fileMetadataService: FileTreeMetadataService,
private sedaService: SedaService, private fb: FormBuilder, private notificationService: NotificationService,
private router: Router, private startupService: StartupService, public profileService: ProfileService,
private router: Router, private startupService: StartupService, public profileService: ProfileService,
private fileTreeService:FileTreeService, private metadataLanguageService: PastisPopupMetadataLanguageService,
private translateService: TranslateService) {
......@@ -522,6 +523,23 @@ export class FileTreeMetadataComponent {
}
}
async onEditControlClick(fileNodeId: number) {
alert(fileNodeId)
let popData = {} as PastisDialogData;
if (fileNodeId) {
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
let popUpAnswer = <AttributeData[]>await this.fileService.openPopup(popData);
console.log("The answer for edit attributte was ", popUpAnswer);
}
}
onDeleteNode(nodeId: number) {
const nodeToDelete = this.fileService.getFileNodeById(this.fileService.nodeChange.getValue(), nodeId);
this.removeNode.emit(nodeToDelete)
......
<div>
<!-- The selected items -->
<div *ngIf="addedItems?.length > 0" class="pastis-container-selected-items">
<div *ngFor="let item of addedItems;let i =index" style="display: inline-flex">
<div class="selected-items-box">
<span style="padding: 12px;">
<span class="item-text">{{item}}</span>
</span>
<mat-divider class="selected-items-separator" vertical></mat-divider>
<span (click)="onRemoveSelectedElement(item)" class="selected-items-close">&times;</span>
</div>
</div>
</div>
<!-- The list of items to be selected-->
<mat-list *ngIf="allowedChildren?.length; else noItemsLeftToAdd" 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>
<i class="vitamui-icon vitamui-icon-chevron-down" style="margin-left: 20px; font-weight: bold;"></i>
</span>
<i class="vita"></i>
<mat-divider class="pastis-popup-separator"></mat-divider>
<mat-selection-list [disableRipple]="true"
[ngModel]="addedItems" class="list-box">
<mat-list *ngFor="let element of allowedChildren"
class="list-item">
<span class="list-box-content">
<span
[matTooltipShowDelay]="0"
class="text medium"
matTooltip={{getDefinition(element)}}
matTooltipClass="pastis-tooltip-class"
placement="right">{{element}}</span>
</span>
<span (click)="onAddSelectedElement(element)" class="ajouter">{{'USER_ACTION.ADD_METADATA.BOUTON_AJOUTER' | translate}}</span>
<mat-divider class="pastis-popup-separator"></mat-divider>
</mat-list>
</mat-selection-list>
</mat-list>
<ng-template #noItemsLeftToAdd>
<p class="paragraph-metadata-subtitle" style="margin-top: 40px;">
{{'USER_ACTION.ADD_METADATA.MESSAGE_PLUS_METADONNEE' | translate}}</p>
</ng-template>
</div>
@import '../add-metadata/add-metadata.component.scss';
.pastis-container-selected-items{
margin-top: 10px;
}
/*
Copyright © CINES - Centre Informatique National pour l'Enseignement Supérieur (2020)
[dad@cines.fr]
This software is a computer program whose purpose is to provide
a web application to create, edit, import and export archive
profiles based on the french SEDA standard
(https://redirect.francearchives.fr/seda/).
This software is governed by the CeCILL-C license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL-C
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited
liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
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 { 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',
templateUrl: './add-pua-control.component.html',
styleUrls: ['./add-pua-control.component.scss']
})
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;
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) { }
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 => {
this.btnIsDisabled = status;
})
}
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])
}
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);
this.addedItems.length > 0 ? this.atLeastOneIsSelected = true : this.atLeastOneIsSelected = false
this.upateButtonStatusAndDataToSend();
}
upateButtonStatusAndDataToSend() {
this.popUpService.setPopUpDataOnClose(this.addedItems);
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: SedaData): string {
return element ? element.Definition : '';
}
onYesClick(): void {
console.log("Clicked ok on dialog : %o", this.selectedSedaNode);
}
onNoClick(): void {
this.dialogRef.close();
}
onResolveName(element: SedaData): string {
if (this.sedaLanguage) {
return element.Name;
}
else {
if (element.NameFr) {
return element.NameFr;
}
}
return element.Name;
}
ngOnDestroy(): void {
if (this.sedaLanguageSub != null) {
this.sedaLanguageSub.unsubscribe();
}
}
}
......@@ -45,6 +45,7 @@ import {UserActionSaveProfileComponent} from './save-profile/save-profile.compon
import {PastisMaterialModule} from '../material.module';
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 {MatInputModule} from "@angular/material/input";
import {FormsModule, ReactiveFormsModule} from "@angular/forms";
......@@ -57,7 +58,7 @@ import {MatSlideToggleModule} from "@angular/material/slide-toggle";
@NgModule({
declarations: [UserActionUploadProfileComponent,FilterByNamePipe, UserActionSaveProfileComponent, UserActionsDownloadDocComponent, DuplicateMetadataComponent, CreateNoticeComponent, SaveProfileOptionsComponent],
declarations: [UserActionUploadProfileComponent,FilterByNamePipe, UserActionSaveProfileComponent, UserActionsDownloadDocComponent, DuplicateMetadataComponent, CreateNoticeComponent, SaveProfileOptionsComponent, UserActionAddPuaControlComponent],
imports: [
CommonModule,
PastisMaterialModule,
......@@ -71,7 +72,7 @@ import {MatSlideToggleModule} from "@angular/material/slide-toggle";
FormsModule,
MatSlideToggleModule
],
exports: [UserActionUploadProfileComponent, UserActionSaveProfileComponent,UserActionsDownloadDocComponent,FilterByNamePipe ],
exports: [UserActionUploadProfileComponent, UserActionSaveProfileComponent,UserActionsDownloadDocComponent,FilterByNamePipe,UserActionAddPuaControlComponent ],
})
export class UserActionsModule {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment