Merge branch 'dmp-refactoring' of https://code-repo.d4science.org/MaDgiK-CITE/argos into dmp-refactoring
This commit is contained in:
commit
1d2858dd42
|
@ -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());
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
|
|
||||||
<mat-divider *ngIf="formGroup.get('id').value && (!viewOnly || (!isLocked && !viewOnly) || isLocked || (hasReversableStatus() && !isLocked))" [vertical]="true" class="ml-2 mr-2"></mat-divider>
|
<mat-divider *ngIf="formGroup.get('id').value && (!viewOnly || (!isLocked && !viewOnly) || isLocked || (hasReversableStatus() && !isLocked))" [vertical]="true" class="ml-2 mr-2"></mat-divider>
|
||||||
|
|
||||||
<div *ngIf="isDirty() && !viewOnly" class="col-auto d-flex align-items-center pr-0">
|
<div *ngIf="!isPristine() && !viewOnly" class="col-auto d-flex align-items-center pr-0">
|
||||||
<button [disabled]="saving" type="button" mat-raised-button class="description-discard-btn" (click)="discardChanges()">
|
<button [disabled]="saving" type="button" mat-raised-button class="description-discard-btn" (click)="discardChanges()">
|
||||||
{{'DESCRIPTION-EDITOR.ACTIONS.DISCARD.DISCARD' | translate}}
|
{{'DESCRIPTION-EDITOR.ACTIONS.DISCARD.DISCARD' | translate}}
|
||||||
</button>
|
</button>
|
||||||
|
|
|
@ -533,6 +533,10 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
|
||||||
return this.formGroup.dirty; //TODO: check if needed //&& this.hasChanges; // do we need this.formGroup.dirty
|
return this.formGroup.dirty; //TODO: check if needed //&& this.hasChanges; // do we need this.formGroup.dirty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isPristine() {
|
||||||
|
return this.formGroup.pristine; //use for discard
|
||||||
|
}
|
||||||
|
|
||||||
hasReversableStatus(): boolean {
|
hasReversableStatus(): boolean {
|
||||||
if (this.item?.dmp) {
|
if (this.item?.dmp) {
|
||||||
return (this.item.dmp.status == DmpStatus.Draft && this.isFinalized);
|
return (this.item.dmp.status == DmpStatus.Draft && this.isFinalized);
|
||||||
|
@ -768,5 +772,6 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
|
||||||
this.formService.removeAllBackEndErrors(this.formGroup);
|
this.formService.removeAllBackEndErrors(this.formGroup);
|
||||||
this.formService.validateAllFormFields(this.formGroup);
|
this.formService.validateAllFormFields(this.formGroup);
|
||||||
this.descriptionFormService.detectChanges(true);
|
this.descriptionFormService.detectChanges(true);
|
||||||
|
this.formGroup.markAsPristine();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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