Add a placeholder field in multiplicity. (BackEnd)

Add a placeholder input in editor for multiplicity add new field button.
This commit is contained in:
Konstantinos Triantafyllou 2021-12-15 16:26:06 +02:00
parent a9e7ef1798
commit ade9b42d12
13 changed files with 83 additions and 32 deletions

View File

@ -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()) {

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}

View File

@ -44,6 +44,7 @@ export interface FieldSet {
export interface Multiplicity {
min: number;
max: number;
placeholder: string;
}
export interface Field {

View File

@ -3,5 +3,6 @@
export interface Multiplicity {
min: number;
max: number;
placeholder: string;
}

View File

@ -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;
}
}

View File

@ -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>

View File

@ -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);

View File

@ -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}}">

View File

@ -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}}">
@ -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}}">

View File

@ -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;
}

View File

@ -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",