Commit 9a8695e9 authored by descamps's avatar descamps
Browse files

Merge branch 'develop' into feature/us217

parents 12437639 fba533b4
......@@ -51,6 +51,7 @@ import java.util.stream.Stream;
@NoArgsConstructor
public class ElementProperties {
private String additionalProperties;
private String name;
private String type;
private String cardinality;
......
......@@ -53,9 +53,8 @@ public class PuaFromJSON {
private static final String SCHEMA = "http://json-schema.org/draft-04/schema";
private static final String TYPE = "object";
private static final Boolean ADDITIONALPROPERTIES = false;
private final PuaPastisValidator puaPastisValidator;
private final PuaPastisValidator puaPastisValidator;
@Autowired
public PuaFromJSON(final PuaPastisValidator puaPastisValidator){
this.puaPastisValidator = puaPastisValidator;
......@@ -64,13 +63,14 @@ public class PuaFromJSON {
public String getControlSchemaFromElementProperties(ElementProperties elementProperties) throws IOException {
// We use a JSONObject instead of POJO, since Jackson and Gson will add unnecessary
// backslashes during mapping string object values back to string
JSONObject controlSchema = puaPastisValidator.sortedJSON();
// 1. Add Schema
controlSchema.put("$schema", SCHEMA);
// 2. Add type
controlSchema.put("type", TYPE);
// 3. Add additionProperties
controlSchema.put("additionalProperties", ADDITIONALPROPERTIES);
controlSchema.put("additionalProperties", elementProperties.getAdditionalProperties());
// 4. Check if tree contains Management metadata
addPatternProperties(elementProperties, controlSchema);
List<ElementProperties> elementsForTree = puaPastisValidator.ignoreMetadata(elementProperties);
......
......@@ -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';
/**
......@@ -94,6 +94,7 @@ export enum ValueOrDataConstants {
}
export interface FileNode {
additionalProperties:boolean;
id: number;
parentId: number;
name: string;
......@@ -109,7 +110,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;
}
......@@ -4,7 +4,7 @@ import { PuaProperties } from './pua.propreties.model';
export class PUA {
'$schema': string;
'type': 'object';
'additionalProperties': false;
'additionalProperties': boolean;
'definitions': PuaDefinitions;
'properties': PuaProperties;
}
......@@ -59,6 +59,9 @@ td {
margin: 0px -10px 0px 0px !important;
}
.pastis-table-container {
margin-bottom: 60px ;
}
.pastis-table-container .mat-select-value-text {
@extend .text-text-normal;
color: var(--vitamui-grey-600);
......@@ -179,7 +182,7 @@ td {
font-style: normal;
font-weight: 400;
line-height: 24px;
letter-spacing: 0px;
letter-spacing: 0;
text-align: left;
}
@extend .editable-field-control;
......@@ -298,7 +301,14 @@ tr:hover .pastis-btn-appear {
height: 50px;
display: inline-block;
}
.pastis-panel-metadata-control {
@extend .pastis-panel-radius-5;
margin-left: 74px;
margin-right: 120px;
height: fit-content;
background-color: #FAFAFA;
padding-bottom: 30px
}
.pastis-metadata-option-container {
@extend .pastis-panel-radius-10;
@extend .pastis-panel-shadow;
......@@ -310,11 +320,12 @@ tr:hover .pastis-btn-appear {
}
.pastis-metadata-option-entete-1 {
position: relative;
position: absolute;
height: 117px;
float: left;
padding-left: 35px;
padding-top: 20px;
width: 50%;
float: right;
left: 35px;
top: 20px;
}
.pastis-metadata-option-entete-1 .vitamui-icon-dossier-physique {
......@@ -325,11 +336,11 @@ tr:hover .pastis-btn-appear {
}
.pastis-metadata-option-entete-2 {
position: relative;
position: absolute;
height: 117px;
width: 172px;
display: inline-flex;
float: right;
right: 20px;
top: 5px;
}
......@@ -368,7 +379,7 @@ dp-date-picker {
dp-day-calendar .dp-day-calendar-container {
border-radius: 20px !important;
box-shadow: 0px 11px 15px rgba(0, 0, 0, 0.1), 0px 9px 46px rgba(0, 0, 0, 0.06), 0px 24px 38px rgba(0, 0, 0, 0.07) !important;
box-shadow: 0 11px 15px rgba(0, 0, 0, 0.1), 0 9px 46px rgba(0, 0, 0, 0.06), 0 24px 38px rgba(0, 0, 0, 0.07) !important;
}
.dp-selected {
......@@ -448,3 +459,45 @@ dp-day-calendar .dp-day-calendar-container {
overflow: visible;
z-index: 999;
}
.allow_presence_text{
font-size: 11px !important;
font-family: 'Mulish', sans-serif !important;
color: #212121 !important;
font-weight: 400;
}
.placement-tooltip{
position: absolute;
left: 13em;
top: 1em;
}
.pastis-dialog-config-title {
bottom: 10px;
position: relative;
padding-top: 20px
}
.pastis-dialog-title {
@extend .pastis-font-popup-title;
/* Positioning */
position: relative;
margin-left: 5%;
margin-right: 40px;
margin-top: 10px;
font-family: Mulish;
font-style: normal;
font-weight: bold;
font-size: 14px;
line-height: 28px;
display: flex;
align-items: center;
color: var(--vitamui-grey-900);
}
.pastis-icon-primary {
color: var(--vitamui-primary-700) !important;
margin-left: 10px !important;
}
......@@ -38,19 +38,9 @@ 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,
......@@ -61,13 +51,24 @@ import {
TypeConstants,
ValueOrDataConstants
} from '../../../models/file-node';
import {CardinalityValues, MetadataHeaders} from '../../../models/models';
import {SedaData, SedaElementConstants} from '../../../models/seda-data';
import {PastisDialogData} from '../../../shared/pastis-dialog/classes/pastis-dialog-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 {PastisPopupMetadataLanguageService} from '../../../shared/pastis-popup-metadata-language/pastis-popup-metadata-language.service';
import {FileTreeService} from '../file-tree/file-tree.service';
import {AttributesPopupComponent} from './attributes/attributes.component';
import {FileTreeMetadataService} from './file-tree-metadata.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";
const FILE_TREE_METADATA_TRANSLATE_PATH = 'PROFILE.EDIT_PROFILE.FILE_TREE_METADATA';
......@@ -101,7 +102,7 @@ export class FileTreeMetadataComponent {
// Mat table
matDataSource: MatTableDataSource<MetadataHeaders>;
@ViewChild('autosize', {static: false}) autosize: CdkTextareaAutosize;
@ViewChild('autosize', { static: false }) autosize: CdkTextareaAutosize;
displayedColumns: string[] = ['nomDuChamp', 'valeurFixe', 'cardinalite', 'commentaire', 'menuoption'];
......@@ -188,6 +189,8 @@ export class FileTreeMetadataComponent {
cardinalite: string[];
commentaire: string;
enumeration: string[];
additionalProperties: boolean;
additionalPropertiesMetadonnee: boolean;
constructor(private fileService: FileService, private fileMetadataService: FileTreeMetadataService,
private sedaService: SedaService, private fb: FormBuilder, private notificationService: NotificationService,
......@@ -217,7 +220,8 @@ export class FileTreeMetadataComponent {
this.popupAnnuler = 'Annuler';
}
this.additionalProperties = false;
this.additionalPropertiesMetadonnee = false;
this.docPath = this.isStandalone ? 'assets/doc/Standalone - Documentation APP - PASTIS.pdf' : 'assets/doc/VITAM UI - Documentation APP - PASTIS.pdf';
this.languagePopup = false;
this._sedalanguageSub = this.metadataLanguageService.sedaLanguage.subscribe(
......@@ -245,7 +249,7 @@ export class FileTreeMetadataComponent {
this.breadcrumbDataMetadata = this.breadcrumbDataMetadata.concat([ { label: '...' } ]);
}
}
this.breadcrumbDataMetadata = this.breadcrumbDataMetadata.concat([ { label: node.parent.name, node: node.parent } ]);
this.breadcrumbDataMetadata = this.breadcrumbDataMetadata.concat([{ label: node.parent.name, node: node.parent }]);
}
this.breadcrumbDataMetadata = this.breadcrumbDataMetadata.concat([ { label: breadCrumbNodeLabel, node } ]);
}
......@@ -522,6 +526,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);
......@@ -635,7 +656,7 @@ export class FileTreeMetadataComponent {
}
goBack() {
this.router.navigate(['/'], {skipLocationChange: false});
this.router.navigate(['/'], { skipLocationChange: false });
}
ngOnDestroy() {
......@@ -690,4 +711,29 @@ export class FileTreeMetadataComponent {
return this.sedaService.isDuplicated(nomDuChamp, this.selectedSedaNode);
}
changeStatusAditionalProperties($event: boolean) {
this.additionalProperties = $event;
}
isElementNameNotContentManagement(nomDuChamp: string) {
return !(nomDuChamp == "Content" || nomDuChamp == "Management");
}
changeAutorisation($event: MatCheckboxChange, element: any) {
console.log($event.checked + "test" + element.nomDuChamp);
this.additionalPropertiesMetadonnee = $event.checked;
this.setNodeAdditionalPropertiesChange(this.additionalPropertiesMetadonnee, element)
}
private setNodeAdditionalPropertiesChange(additionalPropertiesMetadonnee: boolean, element: MetadataHeaders) {
for (let node of this.clickedNode.children) {
if (node.name === element.nomDuChamp && node.id === element.id) {
node.puaData.additionalProperties = additionalPropertiesMetadonnee;
}
}
}
}
......@@ -36,23 +36,24 @@ 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 {CdkTextareaAutosize} from '@angular/cdk/text-field';
import {Component, Input, OnDestroy, ViewChild, } from '@angular/core';
import {Component, Input, OnDestroy, ViewChild,} from '@angular/core';
import {LangChangeEvent, TranslateService} from '@ngx-translate/core';
import {BehaviorSubject, Subscription, throwError} from 'rxjs';
import {environment} from '../../../../environments/environment';
import {FileService} from '../../../core/services/file.service';
import {NotificationService} from '../../../core/services/notification.service';
import { ProfileService } from '../../../core/services/profile.service';
import {ProfileService} from '../../../core/services/profile.service';
import {SedaService} from '../../../core/services/seda.service';
import {CardinalityConstants, DataTypeConstants, FileNode, TypeConstants} from '../../../models/file-node';
import {SedaCardinalityConstants, SedaData, SedaElementConstants} from '../../../models/seda-data';
import {PastisDialogData} from '../../../shared/pastis-dialog/classes/pastis-dialog-data';
import { PastisPopupMetadataLanguageService } from '../../../shared/pastis-popup-metadata-language/pastis-popup-metadata-language.service';
import {PastisPopupMetadataLanguageService} from '../../../shared/pastis-popup-metadata-language/pastis-popup-metadata-language.service';
import {UserActionAddMetadataComponent} from '../../../user-actions/add-metadata/add-metadata.component';
import {DuplicateMetadataComponent} from '../../../user-actions/duplicate-metadata/duplicate-metadata.component';
import {UserActionRemoveMetadataComponent} from '../../../user-actions/remove-metadata/remove-metadata.component';
import {FileTreeMetadataService} from '../file-tree-metadata/file-tree-metadata.service';
import { FileTreeService } from './file-tree.service';
import {FileTreeService} from './file-tree.service';
import {PuaData} from '../../../models/pua-data';
const FILE_TREE_TRANSLATE_PATH = 'PROFILE.EDIT_PROFILE.FILE_TREE';
......@@ -258,7 +259,7 @@ export class FileTreeComponent implements OnDestroy {
async addNewItem(node: FileNode) {
const dataToSendToPopUp = {} as PastisDialogData;
dataToSendToPopUp.titleDialog = this.popupAddTitleDialog;
dataToSendToPopUp.subTitleDialog = this.popupAddSubTitleDialog + ` "${node.name}"`, node.name;
dataToSendToPopUp.subTitleDialog = `${this.popupAddSubTitleDialog} ${node.name}`, node.name;
dataToSendToPopUp.fileNode = node;
dataToSendToPopUp.width = '800px';
dataToSendToPopUp.okLabel = this.popupAddOkLabel;
......@@ -279,6 +280,7 @@ export class FileTreeComponent implements OnDestroy {
/** Add an item (or a list of items) in the Tree */
insertItem(parent: FileNode, elementsToAdd: string[], node?: FileNode, insertItemDuplicate?: boolean) {
console.log('After data is : %o', this.fileTreeService.nestedDataSource.data);
console.log("element to add : %o",elementsToAdd)
const elementsToAddFromSeda: SedaData[] = [];
for (const element of elementsToAdd) {
parent.sedaData.Children.forEach((child) => {
......@@ -316,6 +318,10 @@ export class FileTreeComponent implements OnDestroy {
newNode.parent = parent;
newNode.children = [];
newNode.sedaData = sedaChild;
if (this.isElementComplex(newNode)) {
newNode.puaData = {} as PuaData;
newNode.puaData.additionalProperties = false;
}
console.log('Parent node name: ' + parent.name);
console.log('New node : ', newNode);
......
......@@ -46,6 +46,7 @@ import { SedaCardinalityConstants, SedaData, SedaElementConstants } from '../../
import { PastisDialogData } from '../../shared/pastis-dialog/classes/pastis-dialog-data';
import { PastisDialogConfirmComponent } from '../../shared/pastis-dialog/pastis-dialog-confirm/pastis-dialog-confirm.component';
import { PastisPopupMetadataLanguageService } from '../../shared/pastis-popup-metadata-language/pastis-popup-metadata-language.service';
import { ProfileService } from '../../core/services/profile.service';
@Component({
selector: 'pastis-user-action-add-metadata',
......@@ -74,7 +75,7 @@ export class UserActionAddMetadataComponent implements OnInit {
constructor(public dialogRef: MatDialogRef<PastisDialogConfirmComponent>,
private fileService: FileService, private sedaService: SedaService,
private popUpService: PopupService, private sedaLanguageService: PastisPopupMetadataLanguageService) { }
private popUpService: PopupService, private sedaLanguageService: PastisPopupMetadataLanguageService, private profileService: ProfileService) { }
ngOnInit() {
this.sedaLanguageSub = this.sedaLanguageService.sedaLanguage.subscribe(
......@@ -89,9 +90,18 @@ export class UserActionAddMetadataComponent implements OnInit {
this.sedaData = this.sedaService.sedaRules[0];
this.sedaNodeFound = this.fileNode.sedaData;
this.allowedChildren = this.sedaService.findSelectableElementList(this.sedaNodeFound, this.fileNode)
.filter(e => e.Element !== SedaElementConstants.attribute);
if (this.profileService.profileMode === "PA") {
this.allowedChildren = this.sedaService.findSelectableElementList(this.sedaNodeFound, this.fileNode)
.filter(e => e.Element !== SedaElementConstants.attribute);
} else if (this.profileService.profileMode === "PUA" ) {
if ( this.sedaNodeFound.Name === "ArchiveUnit"){
this.allowedChildren = this.sedaNodeFound.Children
.filter(e => e.Name === "Management" || e.Name === "ArchiveUnitProfile");
} else {
this.allowedChildren = this.sedaNodeFound.Children
}
}
// Subscribe observer to button status and
// set the inital state of the ok button to disabled
this.popUpService.btnYesShoudBeDisabled.subscribe(status => {
......
<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