Add a placeholder field in multiplicity. (BackEnd)
Add a placeholder input in editor for multiplicity add new field button.
This commit is contained in:
parent
a9e7ef1798
commit
ade9b42d12
|
@ -120,6 +120,7 @@ public class ExportXmlBuilderDatasetProfile {
|
|||
Element multiplicity = element.createElement("multiplicity");
|
||||
multiplicity.setAttribute("max", "" + field.getMultiplicity().getMax());
|
||||
multiplicity.setAttribute("min", "" + field.getMultiplicity().getMin());
|
||||
multiplicity.setAttribute("placeholder", field.getMultiplicity().getPlaceholder());
|
||||
composite.appendChild(multiplicity);
|
||||
}
|
||||
if (field.getTitle() != null && !field.getTitle().isEmpty()) {
|
||||
|
|
|
@ -8,6 +8,7 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||
public class Multiplicity {
|
||||
private int max;
|
||||
private int min;
|
||||
private String placeholder;
|
||||
|
||||
@XmlAttribute(name = "max")
|
||||
public int getMax() {
|
||||
|
@ -27,10 +28,20 @@ public class Multiplicity {
|
|||
this.min = min;
|
||||
}
|
||||
|
||||
@XmlAttribute(name = "placeholder")
|
||||
public String getPlaceholder() {
|
||||
return placeholder;
|
||||
}
|
||||
|
||||
public void setPlaceholder(String placeholder) {
|
||||
this.placeholder = placeholder;
|
||||
}
|
||||
|
||||
public eu.eudat.models.data.components.commons.Multiplicity toAdminCompositeModelSection() {
|
||||
eu.eudat.models.data.components.commons.Multiplicity multiplicityEntity = new eu.eudat.models.data.components.commons.Multiplicity();
|
||||
multiplicityEntity.setMax(max);
|
||||
multiplicityEntity.setMin(min);
|
||||
multiplicityEntity.setPlaceholder(placeholder);
|
||||
return multiplicityEntity;
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ public class Multiplicity {
|
|||
|
||||
private int min;
|
||||
private int max;
|
||||
private String placeholder;
|
||||
|
||||
public int getMin() {
|
||||
return min;
|
||||
|
@ -21,5 +22,11 @@ public class Multiplicity {
|
|||
this.max = max;
|
||||
}
|
||||
|
||||
public String getPlaceholder() {
|
||||
return placeholder;
|
||||
}
|
||||
|
||||
public void setPlaceholder(String placeholder) {
|
||||
this.placeholder = placeholder;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,6 +121,7 @@ public class FieldSet implements DatabaseViewStyleDefinition, XmlSerializable<Fi
|
|||
Element multiplicity = doc.createElement("multiplicity");
|
||||
multiplicity.setAttribute("min", "" + this.multiplicity.getMin());
|
||||
multiplicity.setAttribute("max", "" + this.multiplicity.getMax());
|
||||
multiplicity.setAttribute("placeholder", this.multiplicity.getPlaceholder());
|
||||
|
||||
Element commentField = doc.createElement("commentField");
|
||||
commentField.setAttribute("hasCommentField", "" + this.hasCommentField);
|
||||
|
@ -183,6 +184,7 @@ public class FieldSet implements DatabaseViewStyleDefinition, XmlSerializable<Fi
|
|||
|
||||
this.multiplicity.setMin(Integer.parseInt(multiplicity.getAttribute("min")));
|
||||
this.multiplicity.setMax(Integer.parseInt(multiplicity.getAttribute("max")));
|
||||
this.multiplicity.setPlaceholder(multiplicity.getAttribute("placeholder"));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ export interface FieldSet {
|
|||
export interface Multiplicity {
|
||||
min: number;
|
||||
max: number;
|
||||
placeholder: string;
|
||||
}
|
||||
|
||||
export interface Field {
|
||||
|
|
|
@ -3,5 +3,6 @@
|
|||
export interface Multiplicity {
|
||||
min: number;
|
||||
max: number;
|
||||
placeholder: string;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,22 +1,27 @@
|
|||
import { FormGroup } from '@angular/forms';
|
||||
import { Multiplicity } from '../../../../core/model/admin/dataset-profile/dataset-profile';
|
||||
import { BaseFormModel } from '../../../../core/model/base-form-model';
|
||||
import {FormGroup} from '@angular/forms';
|
||||
import {Multiplicity} from '../../../../core/model/admin/dataset-profile/dataset-profile';
|
||||
import {BaseFormModel} from '../../../../core/model/base-form-model';
|
||||
|
||||
export class MultiplicityEditorModel extends BaseFormModel {
|
||||
public min: number;
|
||||
public max: number;
|
||||
public placeholder: string;
|
||||
|
||||
fromModel(item: Multiplicity): MultiplicityEditorModel {
|
||||
this.min = item.min;
|
||||
this.max = item.max;
|
||||
this.placeholder = item.placeholder;
|
||||
return this;
|
||||
}
|
||||
|
||||
buildForm(disabled: boolean = false, skipDisable: Array<String> = []): FormGroup {
|
||||
const formGroup = this.formBuilder.group({
|
||||
min: [{ value: this.min, disabled: (disabled && !skipDisable.includes('MultiplicityEditorModel.min')) }],
|
||||
max: [{ value: this.max, disabled: (disabled && !skipDisable.includes('MultiplicityEditorModel.max')) }]
|
||||
return this.formBuilder.group({
|
||||
min: [{value: this.min, disabled: (disabled && !skipDisable.includes('MultiplicityEditorModel.min'))}],
|
||||
max: [{value: this.max, disabled: (disabled && !skipDisable.includes('MultiplicityEditorModel.max'))}],
|
||||
placeholder: [{
|
||||
value: this.placeholder,
|
||||
disabled: (disabled && !skipDisable.includes('MultiplicityEditorModel.placeholder'))
|
||||
}]
|
||||
});
|
||||
return formGroup;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,6 +111,12 @@
|
|||
</mat-error>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="row">
|
||||
<mat-form-field *ngIf="isMultiplicityEnabled" class="col pl-0 underline-line-field" appearance="legacy">
|
||||
<input matInput placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-PLACEHOLDER' | translate}}"
|
||||
type="text" [formControl]="form.get('multiplicity').get('placeholder')">
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ export class DatasetProfileEditorCompositeFieldComponent extends BaseComponent i
|
|||
|
||||
try{
|
||||
const multiplicity = this.form.get('multiplicity').value;
|
||||
this.isMultiplicityEnabled = multiplicity.min > 0 || multiplicity.max >0;
|
||||
this.isMultiplicityEnabled = multiplicity.min > 0 || multiplicity.max >0;
|
||||
} catch{
|
||||
this.isMultiplicityEnabled = false;
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ export class DatasetProfileEditorCompositeFieldComponent extends BaseComponent i
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ngOnInit() {
|
||||
|
@ -255,7 +255,7 @@ export class DatasetProfileEditorCompositeFieldComponent extends BaseComponent i
|
|||
description: formValue.description,
|
||||
hasCommentField: formValue.hasCommentField,
|
||||
commentFieldValue: '',
|
||||
multiplicity: {max:formValue.multiplicity.max, min : formValue.multiplicity.min},
|
||||
multiplicity: {max: formValue.multiplicity.max, min: formValue.multiplicity.min, placeholder: formValue.multiplicity.placeholder},
|
||||
multiplicityItems:null,
|
||||
fields: fields.map(editorField=>{
|
||||
const model = new DatasetDescriptionFieldEditorModel().fromModel(editorField);
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
<ng-container *ngIf="form">
|
||||
<div *ngFor="let compositeFieldFormGroup of form.get('compositeFields')['controls']; let i = index;" class="col-12">
|
||||
|
||||
|
||||
<div class="row" *ngIf="this.visibilityRulesService.checkElementVisibility(compositeFieldFormGroup.get('id').value) && this.visibilityRulesService.scanIfChildsOfCompositeFieldHasVisibleItems(compositeFieldFormGroup)">
|
||||
|
||||
|
||||
<div class="col-12">
|
||||
<div class="row">
|
||||
<app-form-composite-field class="align-self-center col" [form]="compositeFieldFormGroup" [datasetProfileId]="datasetProfileId"
|
||||
[isChild]="false" [showDelete]="(compositeFieldFormGroup.get('multiplicityItems').length) > 0"></app-form-composite-field>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div *ngIf="compositeFieldFormGroup" class="col-12">
|
||||
<div class="row">
|
||||
<div class="col-12" *ngFor="let multipleCompositeFieldFormGroup of compositeFieldFormGroup.get('multiplicityItems')['controls']; let j = index">
|
||||
|
@ -19,10 +19,14 @@
|
|||
</div>
|
||||
</div>
|
||||
<div *ngIf="(compositeFieldFormGroup.get('multiplicity').value.max - 1) > (compositeFieldFormGroup.get('multiplicityItems').length)"
|
||||
class="col-12 ml-0 mr-0 addOneFieldButton">
|
||||
<button mat-icon-button color="primary" (click)="addMultipleField(i)" [disabled]="compositeFieldFormGroup.disabled" matTooltip="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-ADD-ONE-FIELD' | translate}}">
|
||||
<mat-icon>add_circle</mat-icon>
|
||||
</button>
|
||||
class="col-12 mt-1 ml-0 mr-0 addOneFieldButton">
|
||||
<span matTooltip="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-ADD-ONE-FIELD' | translate}}"
|
||||
class="pointer d-inline-flex align-items-center">
|
||||
<button mat-icon-button color="primary" (click)="addMultipleField(i)" [disabled]="compositeFieldFormGroup.disabled">
|
||||
<mat-icon>add_circle</mat-icon>
|
||||
</button>
|
||||
<span class="mt-1" *ngIf="compositeFieldFormGroup.get('multiplicity').value.placeholder">{{compositeFieldFormGroup.get('multiplicity').value.placeholder}}</span>
|
||||
</span>
|
||||
</div>
|
||||
<mat-form-field *ngIf="compositeFieldFormGroup.get('hasCommentField').value" class="col-12 mb-2" [formGroup]="compositeFieldFormGroup">
|
||||
<input matInput formControlName="commentFieldValue" placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.COMMENT-PLACEHOLDER' | translate}}">
|
||||
|
@ -36,4 +40,4 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
</ng-container>
|
||||
|
|
|
@ -31,10 +31,14 @@
|
|||
</div>
|
||||
</div>
|
||||
<div *ngIf="(compositeFieldFormGroup.get('multiplicity').value.max - 1) > (compositeFieldFormGroup.get('multiplicityItems').length)"
|
||||
class="col-12 addOneFieldButton">
|
||||
<button mat-icon-button type="button" color="primary" (click)="addMultipleField(i)" [disabled]="compositeFieldFormGroup.disabled" matTooltip="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-ADD-ONE-FIELD' | translate}}">
|
||||
<mat-icon>add_circle</mat-icon>
|
||||
</button>
|
||||
class="col-12 mt-1 ml-0 mr-0 addOneFieldButton">
|
||||
<span matTooltip="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-ADD-ONE-FIELD' | translate}}"
|
||||
class="pointer d-inline-flex align-items-center">
|
||||
<button mat-icon-button color="primary" (click)="addMultipleField(i)" [disabled]="compositeFieldFormGroup.disabled">
|
||||
<mat-icon>add_circle</mat-icon>
|
||||
</button>
|
||||
<span class="mt-1" *ngIf="compositeFieldFormGroup.get('multiplicity').value.placeholder">{{compositeFieldFormGroup.get('multiplicity').value.placeholder}}</span>
|
||||
</span>
|
||||
</div>
|
||||
<mat-form-field *ngIf="compositeFieldFormGroup.get('hasCommentField').value" class="col-12 mb-2" [formGroup]="compositeFieldFormGroup">
|
||||
<input matInput formControlName="commentFieldValue" placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.COMMENT-PLACEHOLDER' | translate}}">
|
||||
|
@ -79,14 +83,14 @@
|
|||
<!-- <div *ngIf="isElementVisible(compositeField)" class="row"> -->
|
||||
<!-- *ngIf="this.visibilityRulesService.checkElementVisibility(compositeFieldFormGroup.get('id').value)" -->
|
||||
<div class="row" *ngIf="(this.visibilityRulesService.checkElementVisibility(fieldsetEntry.form.get('id').value) && this.visibilityRulesService.scanIfChildsOfCompositeFieldHasVisibleItems(fieldsetEntry.form)) && !hiddenEntriesIds.includes(fieldsetEntry.id)">
|
||||
|
||||
|
||||
<div class="col-12">
|
||||
<div class="row">
|
||||
<app-form-composite-field [tocentry]="fieldsetEntry" class="align-self-center col" [form]="fieldsetEntry.form" [datasetProfileId]="datasetProfileId"
|
||||
[isChild]="false" [showDelete]="(fieldsetEntry.form.get('multiplicityItems').length) > 0"></app-form-composite-field>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div *ngIf="fieldsetEntry.form" class="col-12">
|
||||
<div class="row">
|
||||
<div class="col-12" *ngFor="let multipleCompositeFieldFormGroup of fieldsetEntry.form.get('multiplicityItems')['controls']; let j = index">
|
||||
|
@ -96,10 +100,14 @@
|
|||
</div>
|
||||
</div>
|
||||
<div *ngIf="(fieldsetEntry.form.get('multiplicity').value.max - 1) > (fieldsetEntry.form.get('multiplicityItems').length)"
|
||||
class="col-12 addOneFieldButton">
|
||||
<button mat-icon-button type="button" color="primary" (click)="addMultipleField(i)" [disabled]="fieldsetEntry.form.disabled" matTooltip="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-ADD-ONE-FIELD' | translate}}">
|
||||
<mat-icon>add_circle</mat-icon>
|
||||
</button>
|
||||
class="col-12 mt-1 ml-0 mr-0 addOneFieldButton">
|
||||
<span matTooltip="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.MULTIPLICITY-ADD-ONE-FIELD' | translate}}"
|
||||
class="pointer d-inline-flex align-items-center">
|
||||
<button mat-icon-button color="primary" (click)="addMultipleField(i)" [disabled]="fieldsetEntry.form.disabled">
|
||||
<mat-icon>add_circle</mat-icon>
|
||||
</button>
|
||||
<span class="mt-1" *ngIf="fieldsetEntry.form.get('multiplicity').value.placeholder">{{fieldsetEntry.form.get('multiplicity').value.placeholder}}</span>
|
||||
</span>
|
||||
</div>
|
||||
<mat-form-field *ngIf="fieldsetEntry.form.get('hasCommentField').value" class="col-12 mb-2" [formGroup]="fieldsetEntry.form">
|
||||
<input matInput formControlName="commentFieldValue" placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.COMPOSITE-FIELD.FIELDS.COMMENT-PLACEHOLDER' | translate}}">
|
||||
|
@ -111,12 +119,12 @@
|
|||
</button> -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</ng-container>
|
||||
|
||||
|
||||
<ng-container *ngSwitchCase="tocentriesType.Section">
|
||||
<!-- SECTION CASE -->
|
||||
|
||||
|
@ -132,7 +140,7 @@
|
|||
</ng-container>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
|
||||
</ng-container>
|
||||
|
||||
</ng-template>
|
||||
|
|
|
@ -318,17 +318,20 @@ export class DatasetDescriptionFieldEditorModel extends BaseFormModel {
|
|||
export class DatasetDescriptionMultiplicityEditorModel extends BaseFormModel {
|
||||
public min: number;
|
||||
public max: number;
|
||||
public placeholder: string;
|
||||
|
||||
fromModel(item: Multiplicity): DatasetDescriptionMultiplicityEditorModel {
|
||||
this.min = item.min;
|
||||
this.max = item.max;
|
||||
this.placeholder = item.placeholder;
|
||||
return this;
|
||||
}
|
||||
|
||||
buildForm(): FormGroup {
|
||||
const formGroup = this.formBuilder.group({
|
||||
min: [this.min],
|
||||
max: [this.max]
|
||||
max: [this.max],
|
||||
placeholder: [this.placeholder]
|
||||
});
|
||||
return formGroup;
|
||||
}
|
||||
|
|
|
@ -367,6 +367,7 @@
|
|||
"ADDITIONAL-INFORMATION": "Additional Information",
|
||||
"MULTIPLICITY-MIN": "Multiplicity Min",
|
||||
"MULTIPLICITY-MAX": "Multiplicity Max",
|
||||
"MULTIPLICITY-PLACEHOLDER": "Multiplicity Placeholder Text",
|
||||
"MULTIPLICITY-ADD-ONE-FIELD": "Add one more fieldset",
|
||||
"ORDER": "Order",
|
||||
"COMMENT-PLACEHOLDER": "Please Specify",
|
||||
|
@ -385,6 +386,7 @@
|
|||
"VIEW-STYLE": "Type",
|
||||
"MULTIPLICITY-MIN": "Multiplicity Min",
|
||||
"MULTIPLICITY-MAX": "Multiplicity Max",
|
||||
"MULTIPLICITY-PLACEHOLDER": "Multiplicity Placeholder Text",
|
||||
"ORDER": "Order",
|
||||
"DEFAULT-VALUE": "Default Value",
|
||||
"VALIDATION": "Validation",
|
||||
|
|
Loading…
Reference in New Issue