fix multiplicity issue
This commit is contained in:
parent
eba6aba19a
commit
3b426db49c
|
@ -8,27 +8,27 @@ import jakarta.xml.bind.annotation.XmlAttribute;
|
||||||
public class MultiplicityEntity {
|
public class MultiplicityEntity {
|
||||||
|
|
||||||
@XmlAttribute(name="min")
|
@XmlAttribute(name="min")
|
||||||
private int min;
|
private Integer min;
|
||||||
@XmlAttribute(name="max")
|
@XmlAttribute(name="max")
|
||||||
private int max;
|
private Integer max;
|
||||||
@XmlAttribute(name="placeholder")
|
@XmlAttribute(name="placeholder")
|
||||||
private String placeholder;
|
private String placeholder;
|
||||||
@XmlAttribute(name="tableView")
|
@XmlAttribute(name="tableView")
|
||||||
private boolean tableView;
|
private boolean tableView;
|
||||||
|
|
||||||
public int getMin() {
|
public Integer getMin() {
|
||||||
return min;
|
return min;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMin(int min) {
|
public void setMin(Integer min) {
|
||||||
this.min = min;
|
this.min = min;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMax() {
|
public Integer getMax() {
|
||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMax(int max) {
|
public void setMax(Integer max) {
|
||||||
this.max = max;
|
this.max = max;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class MultiplicityPersist {
|
||||||
.failOn(MultiplicityPersist._min).failWith(messageSource.getMessage("Validation_UnexpectedValue", new Object[]{MultiplicityPersist._min}, LocaleContextHolder.getLocale())),
|
.failOn(MultiplicityPersist._min).failWith(messageSource.getMessage("Validation_UnexpectedValue", new Object[]{MultiplicityPersist._min}, LocaleContextHolder.getLocale())),
|
||||||
this.spec()
|
this.spec()
|
||||||
.iff(() -> !this.isNull(item.getMax()))
|
.iff(() -> !this.isNull(item.getMax()))
|
||||||
.must(() -> item.getMax() >= 0)
|
.must(() -> item.getMax() > 0)
|
||||||
.failOn(MultiplicityPersist._max).failWith(messageSource.getMessage("Validation_UnexpectedValue", new Object[]{MultiplicityPersist._max}, LocaleContextHolder.getLocale())),
|
.failOn(MultiplicityPersist._max).failWith(messageSource.getMessage("Validation_UnexpectedValue", new Object[]{MultiplicityPersist._max}, LocaleContextHolder.getLocale())),
|
||||||
this.spec()
|
this.spec()
|
||||||
.iff(() -> !this.isNull(item.getMax()))
|
.iff(() -> !this.isNull(item.getMax()))
|
||||||
|
|
|
@ -354,10 +354,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
data.setHasMultiplicity(persist.getHasMultiplicity());
|
data.setHasMultiplicity(persist.getHasMultiplicity());
|
||||||
data.setAdditionalInformation(persist.getAdditionalInformation());
|
data.setAdditionalInformation(persist.getAdditionalInformation());
|
||||||
data.setExtendedDescription(persist.getExtendedDescription());
|
data.setExtendedDescription(persist.getExtendedDescription());
|
||||||
if (persist.getMultiplicity() != null && persist.getHasMultiplicity() && (
|
if (persist.getMultiplicity() != null && persist.getHasMultiplicity()) {
|
||||||
(persist.getMultiplicity().getMin() != null && persist.getMultiplicity().getMin() != 0)
|
|
||||||
|| (persist.getMultiplicity().getMax() != null && persist.getMultiplicity().getMax() != 0)
|
|
||||||
)) {
|
|
||||||
data.setMultiplicity(this.buildMultiplicityEntity(persist.getMultiplicity()));
|
data.setMultiplicity(this.buildMultiplicityEntity(persist.getMultiplicity()));
|
||||||
}
|
}
|
||||||
data.setHasCommentField(persist.getHasCommentField());
|
data.setHasCommentField(persist.getHasCommentField());
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="fieldSet.hasMultiplicity && (fieldSet?.multiplicity?.max) > (propertiesFormGroup.get('items').length)" class="col-12 mt-1 ml-0 mr-0 addOneFieldButton">
|
<div *ngIf="canAddMultiplicityField()" class="col-12 mt-1 ml-0 mr-0 addOneFieldButton">
|
||||||
<mat-error *ngIf="fieldSet.hasMultiplicity && fieldSet?.multiplicity?.min && propertiesFormGroup.get('items').hasError('minlength')">{{'GENERAL.VALIDATION.MULTIPLICITY.MIN' | translate: { min: fieldSet.multiplicity.min} }}</mat-error>
|
<mat-error *ngIf="fieldSet.hasMultiplicity && fieldSet?.multiplicity?.min && propertiesFormGroup.get('items').hasError('minlength')">{{'GENERAL.VALIDATION.MULTIPLICITY.MIN' | translate: { min: fieldSet.multiplicity.min} }}</mat-error>
|
||||||
<mat-error *ngIf="fieldSet.hasMultiplicity && fieldSet?.multiplicity?.max && propertiesFormGroup.get('items').hasError('maxlength')">{{'GENERAL.VALIDATION,MULTIPLICITY.MAX' | translate: { max: fieldSet.multiplicity.max} }}</mat-error>
|
<mat-error *ngIf="fieldSet.hasMultiplicity && fieldSet?.multiplicity?.max && propertiesFormGroup.get('items').hasError('maxlength')">{{'GENERAL.VALIDATION,MULTIPLICITY.MAX' | translate: { max: fieldSet.multiplicity.max} }}</mat-error>
|
||||||
<span class="d-inline-flex align-items-center" [ngClass]="propertiesFormGroup.disabled ? '' : 'pointer'" (click)="addMultiplicityField()">
|
<span class="d-inline-flex align-items-center" [ngClass]="propertiesFormGroup.disabled ? '' : 'pointer'" (click)="addMultiplicityField()">
|
||||||
|
@ -40,7 +40,7 @@
|
||||||
<mat-icon>add_circle</mat-icon>
|
<mat-icon>add_circle</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
<span class="mt-1" *ngIf="fieldSet?.multiplicity?.placeholder">{{fieldSet.multiplicity.placeholder}}</span>
|
<span class="mt-1" *ngIf="fieldSet?.multiplicity?.placeholder">{{fieldSet.multiplicity.placeholder}}</span>
|
||||||
<span class="mt-1" *ngIf="!fieldSet?.multiplicity?.placeholder">{{('DESCRIPTION-EDITOR.ACTIONS.MULTIPLICITY-ADD-ONE-FIELD' + (fieldSet.multiplicity.tableView?'-TABLEVIEW':'')) | translate}}</span>
|
<span class="mt-1" *ngIf="!fieldSet?.multiplicity?.placeholder">{{('DESCRIPTION-EDITOR.ACTIONS.MULTIPLICITY-ADD-ONE-FIELD' + (fieldSet.multiplicity?.tableView?'-TABLEVIEW':'')) | translate}}</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -70,7 +70,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<tr *ngIf="fieldSet.hasMultiplicity && (fieldSet.multiplicity.max - 1) > propertiesFormGroup?.get('items')?.controls.length">
|
<tr *ngIf="canAddMultiplicityField()">
|
||||||
<td [colSpan]="fieldSet.fields.length + 1" class="text-center">
|
<td [colSpan]="fieldSet.fields.length + 1" class="text-center">
|
||||||
<mat-error *ngIf="fieldSet.hasMultiplicity && fieldSet?.multiplicity?.min && propertiesFormGroup.get('items').hasError('minlength')">{{'GENERAL.VALIDATION.MULTIPLICITY.MIN' | translate: { min: fieldSet.multiplicity.min} }}</mat-error>
|
<mat-error *ngIf="fieldSet.hasMultiplicity && fieldSet?.multiplicity?.min && propertiesFormGroup.get('items').hasError('minlength')">{{'GENERAL.VALIDATION.MULTIPLICITY.MIN' | translate: { min: fieldSet.multiplicity.min} }}</mat-error>
|
||||||
<mat-error *ngIf="fieldSet.hasMultiplicity && fieldSet?.multiplicity?.max && propertiesFormGroup.get('items').hasError('maxlength')">{{'GENERAL.VALIDATION,MULTIPLICITY.MAX' | translate: { max: fieldSet.multiplicity.max} }}</mat-error>
|
<mat-error *ngIf="fieldSet.hasMultiplicity && fieldSet?.multiplicity?.max && propertiesFormGroup.get('items').hasError('maxlength')">{{'GENERAL.VALIDATION,MULTIPLICITY.MAX' | translate: { max: fieldSet.multiplicity.max} }}</mat-error>
|
||||||
|
|
|
@ -71,6 +71,12 @@ export class DescriptionFormFieldSetComponent extends BaseComponent {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
canAddMultiplicityField(): boolean{
|
||||||
|
if (!this.fieldSet.hasMultiplicity) return false;
|
||||||
|
if (this.fieldSet?.multiplicity?.max) return this.fieldSet.multiplicity.max > (this.propertiesFormGroup.get('items') as UntypedFormArray).length;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
addMultiplicityField() {
|
addMultiplicityField() {
|
||||||
const formArray = this.propertiesFormGroup?.get('items') as UntypedFormArray;
|
const formArray = this.propertiesFormGroup?.get('items') as UntypedFormArray;
|
||||||
if (formArray.disabled) {
|
if (formArray.disabled) {
|
||||||
|
|
Loading…
Reference in New Issue