Commit 9670cc26 authored by Baptiste Toulemonde's avatar Baptiste Toulemonde
Browse files

fix enumeration control & type title et description

parent 80821d0e
......@@ -231,11 +231,11 @@ public class PuaPastisValidator {
}
if (sedaElementType.equals("Simple") &&
(sedaCardinality.equals("0-1") || sedaCardinality.equals("1"))) {
(sedaCardinality.equals("0-1") || sedaCardinality.equals("1") || sedaName.equals("Title") || sedaName.equals("Description"))) {
return "string";
}
if ((sedaElement.getElement().equals(COMPLEX) &&
(sedaCardinality.equals("0-1") || sedaCardinality.equals("1"))) || sedaName.equals("Title") ||
(sedaCardinality.equals("0-1") || sedaCardinality.equals("1"))) ||
sedaName.equals("Description")) {
return "object";
}
......
......@@ -75,7 +75,7 @@
"rxjs": "^6.5.5",
"serialize-javascript": "^5.0.1",
"tslib": "^2.0.3",
"ui-frontend-common": "file:../ui-frontend-common/ui-frontend-common-2.1.30.tgz",
"ui-frontend-common": "file:../ui-frontend-common/ui-frontend-common-2.1.32.tgz",
"underscore": "^1.13.1",
"utf-8-validate": "^5.0.2",
"uuid": "^7.0.2",
......
......@@ -35,22 +35,22 @@ 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 { 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 {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,
......@@ -62,16 +62,18 @@ 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 { PastisPopupMetadataLanguageService } from '../../../shared/pastis-popup-metadata-language/pastis-popup-metadata-language.service';
import { FileTreeService } from '../file-tree/file-tree.service';
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';
import { FileTreeComponent } from '../file-tree/file-tree.component';
import {CardinalityValues, MetadataHeaders} from '../../../models/models';
import {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 {FileTreeService} from '../file-tree/file-tree.service';
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';
import {FileTreeComponent} from '../file-tree/file-tree.component';
const FILE_TREE_METADATA_TRANSLATE_PATH = 'PROFILE.EDIT_PROFILE.FILE_TREE_METADATA';
......@@ -109,7 +111,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'];
......@@ -150,16 +152,17 @@ export class FileTreeMetadataComponent {
enumsControlSeleted: string[] = [];
editedEnumControl: string[];
openControls: boolean;
originalEnumMap: Map<string, string[]> = new Map<string, string[]>();
radioExpressionReguliere: string;
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: '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}'}
];
availableRegex: Array<{ label: string, value: string }>;
......@@ -277,18 +280,21 @@ export class FileTreeMetadataComponent {
this.fileService.tabRootNode.subscribe(tabRootNode => {
if (tabRootNode) {
const tabLabel = (nodeNameToLabel as any)[tabRootNode.name];
this.breadcrumbDataMetadata = [{ label: tabLabel, node: tabRootNode }];
this.breadcrumbDataMetadata = [{label: tabLabel, node: tabRootNode}];
if (tabRootNode.name !== breadCrumbNodeLabel) {
if (node.parent) {
if (node.parent.name !== tabRootNode.name) {
if (node.parent.parent) {
if (node.parent.parent.name !== tabRootNode.name) {
this.breadcrumbDataMetadata = this.breadcrumbDataMetadata.concat([{ label: '...' }]);
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 }]);
this.breadcrumbDataMetadata = this.breadcrumbDataMetadata.concat([{label: breadCrumbNodeLabel, node}]);
}
}
}
......@@ -297,7 +303,11 @@ export class FileTreeMetadataComponent {
});
// BreadCrump Top for navigation
this.profileModeLabel = this.profileService.profileMode === 'PUA' ? 'PROFILE.EDIT_PROFILE.FILE_TREE_METADATA.PUA' : 'PROFILE.EDIT_PROFILE.FILE_TREE_METADATA.PA';
this.breadcrumbDataTop = [{ label: 'PROFILE.EDIT_PROFILE.BREADCRUMB.PORTAIL', url: this.startupService.getPortalUrl(), external: true }, { label: 'PROFILE.EDIT_PROFILE.BREADCRUMB.CREER_ET_GERER_PROFIL', url: '/' }, { label: this.profileModeLabel }];
this.breadcrumbDataTop = [{
label: 'PROFILE.EDIT_PROFILE.BREADCRUMB.PORTAIL',
url: this.startupService.getPortalUrl(),
external: true
}, {label: 'PROFILE.EDIT_PROFILE.BREADCRUMB.CREER_ET_GERER_PROFIL', url: '/'}, {label: this.profileModeLabel}];
this._fileServiceSubscription = this.fileService.currentTree.subscribe(fileTree => {
if (fileTree) {
......@@ -340,7 +350,7 @@ export class FileTreeMetadataComponent {
if (d.external) {
window.location.assign(d.url);
} else {
this.router.navigate([d.url], { skipLocationChange: false });
this.router.navigate([d.url], {skipLocationChange: false});
}
}
......@@ -596,7 +606,7 @@ export class FileTreeMetadataComponent {
this.resetContols();
const fileNode = this.fileService.findChildById(fileNodeId, this.clickedNode);
this.clickedControl = fileNode;
if (fileNode.puaData && fileNode.puaData.enum && fileNode.puaData.enum.length > 0) {
if (fileNode.puaData && fileNode.puaData.enum) {
this.enumerationsSedaControl = this.sedaService.findSedaChildByName(fileNode.name, this.selectedSedaNode).Enumeration;
this.enumerationControl = true;
this.editedEnumControl = [];
......@@ -613,11 +623,11 @@ export class FileTreeMetadataComponent {
const actualPattern = fileNode.puaData.pattern;
this.openControls = true;
this.expressionControl = true;
if (this.formatagePredefini.map( e => e.value).includes(actualPattern)) {
if (this.formatagePredefini.map(e => e.value).includes(actualPattern)) {
const sedaName = this.fileService.findChildById(fileNodeId, this.clickedNode);
const type: string = this.sedaService.findSedaChildByName(sedaName.name, this.selectedSedaNode).Type;
this.setAvailableRegex(type);
this.regex = this.availableRegex.filter(e => e.value === actualPattern).map( e => e.value)[0];
this.regex = this.availableRegex.filter(e => e.value === actualPattern).map(e => e.value)[0];
this.radioExpressionReguliere = 'select';
} else {
this.customRegex = actualPattern;
......@@ -630,13 +640,16 @@ export class FileTreeMetadataComponent {
isAppliedControl(fileNodeId: number): boolean {
const fileNode = this.fileService.findChildById(fileNodeId, this.clickedNode);
if (fileNode.puaData && fileNode.puaData.enum) { return true; }
if (fileNode.puaData && fileNode.puaData.pattern) { return true; }
if (fileNode.puaData && fileNode.puaData.enum) {
return true;
}
if (fileNode.puaData && fileNode.puaData.pattern) {
return true;
}
return false;
}
resetContols() {
this.arrayControl = [];
this.enumerationControl = false;
......@@ -676,16 +689,21 @@ export class FileTreeMetadataComponent {
setControlsVues(elements: string[], sedaName: string) {
if ((elements.includes('Enumération'))
|| elements.includes(this.translated(ADD_PUA_CONTROL_TRANSLATE_PATH + '.ENUMERATIONS_LABEL'))) {
|| 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.originalEnumMap.get(sedaName)){
this.originalEnumMap.set(sedaName, this.enumerationsSedaControl);
}
this.editedEnumControl = this.enumerationsSedaControl;
this.enumsControlSeleted = this.enumerationsSedaControl;
const type: string = this.sedaService.findSedaChildByName(sedaName, this.selectedSedaNode).Type;
this.setAvailableRegex(type);
}
if (( elements.includes('Expression régulière'))
|| elements.includes(this.translated(ADD_PUA_CONTROL_TRANSLATE_PATH + '.EXPRESSION_REGULIERE_LABEL'))) {
if ((elements.includes('Expression régulière'))
|| elements.includes(this.translated(ADD_PUA_CONTROL_TRANSLATE_PATH + '.EXPRESSION_REGULIERE_LABEL'))) {
this.radioExpressionReguliere = 'select';
this.expressionControl = true;
this.customRegex = '';
......@@ -694,11 +712,11 @@ export class FileTreeMetadataComponent {
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'))) {
|| 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'))) {
|| elements.includes(this.translated(ADD_PUA_CONTROL_TRANSLATE_PATH + '.VALUE_MIN_MAX_LABEL'))) {
this.valueControl = true;
}
......@@ -822,7 +840,7 @@ export class FileTreeMetadataComponent {
}
goBack() {
this.router.navigate(['/'], { skipLocationChange: false });
this.router.navigate(['/'], {skipLocationChange: false});
}
ngOnDestroy() {
......@@ -850,10 +868,9 @@ export class FileTreeMetadataComponent {
}
onChangeSelected(element: any, value: any) {
if(value === undefined){
this.setOrigineNodeValue(element,value)
}
else {
if (value === undefined) {
this.setOrigineNodeValue(element, value)
} else {
console.log(value + " Valeur On Change Selected")
this.setNodeValue(element, value);
}
......@@ -863,14 +880,14 @@ export class FileTreeMetadataComponent {
private setOrigineNodeValue(metadata: any, newValue: any) {
console.log(metadata.cardinalite + 'new Value ' + newValue);
if (this.clickedNode.name === metadata.nomDuChamp) {
this.clickedNode.value = null;
} else if (this.clickedNode.children.length > 0) {
const childNode = this.fileService.getFileNodeById(this.clickedNode, metadata.id);
if (childNode) {
childNode.value = null;
}
this.clickedNode.value = null;
} else if (this.clickedNode.children.length > 0) {
const childNode = this.fileService.getFileNodeById(this.clickedNode, metadata.id);
if (childNode) {
childNode.value = null;
}
}
}
changeSedaLanguage() {
this.metadataLanguageService.sedaLanguage.subscribe(
......@@ -892,12 +909,15 @@ export class FileTreeMetadataComponent {
}
isElementEdit(node: MetadataHeaders): boolean {
if (this.profileService.profileMode === 'PUA') { return false; }
if (this.profileService.profileMode === 'PUA') {
return false;
}
if (node.nomDuChampEdit) {
return true;
}
return false;
}
isEmptyEnumeration(enumerations: string[]): boolean {
return enumerations ? enumerations.length === 0 : false;
}
......@@ -912,28 +932,30 @@ export class FileTreeMetadataComponent {
onDeleteControls() {
if (this.enumerationControl) {
this.sedaService.selectedSedaNode.getValue().Enumeration
this.sedaService.getSedaNode(this.sedaService.selectedSedaNode.getValue(), this.clickedControl.name)
this.clickedNode.puaData.enum = null;
}
if (this.expressionControl) {
this.clickedNode.puaData.pattern = null;
}
this.clickedNode.sedaData.Enumeration = this.originalEnumMap.get(this.clickedControl.name);
this.resetContols();
}
onSubmitControls() {
if (this.enumerationControl) {
if (this.enumsControlSeleted.length > 0) {
if (this.clickedNode.puaData) {
this.clickedNode.puaData.enum = this.enumsControlSeleted;
} else {
this.clickedNode.puaData = {
enum: this.enumsControlSeleted
};
}
this.clickedNode.sedaData.Enumeration = [];
if (this.clickedNode.puaData) {
this.clickedNode.puaData.enum = this.enumsControlSeleted;
} else {
this.clickedNode.puaData.enum = null;
this.clickedNode.puaData = {
enum: this.enumsControlSeleted
};
}
//this.clickedNode.sedaData.Enumeration = [];
}
if (this.expressionControl) {
this.setPatternExpressionReguliere();
......@@ -944,7 +966,7 @@ export class FileTreeMetadataComponent {
onRemoveEnumsControl(element: string) {
let indexOfElement = this.enumsControlSeleted.indexOf(element);
if (indexOfElement >= 0) {
this.enumsControlSeleted.splice(indexOfElement, 1)[0];
this.enumsControlSeleted.splice(indexOfElement, 1);
this.editedEnumControl = [];
this.enumsControlSeleted.forEach(e => {
this.editedEnumControl.push(e);
......@@ -955,12 +977,15 @@ export class FileTreeMetadataComponent {
indexOfElement = this.editedEnumControl.indexOf(element);
this.editedEnumControl.splice(indexOfElement, 1)[0];
}
if (this.enumsControlSeleted.length === 0) { this.editedEnumControl = null; }
if (this.enumsControlSeleted.length === 0) {
this.editedEnumControl = null;
}
}
addEnumsControl(element: string) {
this.enumsControlSeleted.push(element);
}
addEnumsControlList(elements: string[]) {
this.enumsControlSeleted = elements;
}
......@@ -1006,5 +1031,4 @@ export class FileTreeMetadataComponent {
}
}
......@@ -94,7 +94,7 @@ export class UserActionAddPuaControlComponent implements OnInit {
this.popUpService.btnYesShoudBeDisabled.subscribe(status => {
this.btnIsDisabled = status;
});
}
onRemoveSelectedElement(element: string) {
......@@ -144,7 +144,7 @@ export class UserActionAddPuaControlComponent implements OnInit {
if (element) {
this.addedItems = [element];
this.allowedChildren = [];
} else if (this.dialogData.fileNode.sedaData.Enumeration.length > 0) {
} else if (this.dialogData.fileNode.sedaData.Enumeration) {
this.allowedChildren = [
this.enumerationsLabel
];
......
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