small changes

This commit is contained in:
amentis 2024-02-13 18:26:26 +02:00
parent 384b9883a8
commit 6e443c69fa
10 changed files with 24 additions and 38 deletions

View File

@ -8,7 +8,7 @@ import java.util.Map;
public enum DmpBlueprintFieldCategory implements DatabaseEnum<Short> {
System((short) 0),
Extra((short) 1),
ReferenceType((short) 1);
ReferenceType((short) 2);
public static class Names {
public static final String System = "system";

View File

@ -30,7 +30,7 @@ public enum FieldType implements DatabaseEnum<String> {
public static final String BooleanDecision = "booleanDecision";
public static final String RadioBox = "radiobox";
public static final String InternalDmpDmps = "internalDmpDmps";
public static final String InternalDmpDescriptions = "internalDmpDatasets";
public static final String InternalDmpDescriptions = "internalDmpDescriptions";
public static final String CheckBox = "checkBox";
public static final String FreeText = "freetext";
public static final String TextArea = "textarea";

View File

@ -28,7 +28,7 @@ import java.util.List;
@JsonSubTypes.Type(value = LabelDataPersist.class, name = FieldType.Names.DatePicker),
@JsonSubTypes.Type(value = ExternalDatasetDataPersist.class, name = FieldType.Names.ExternalDatasets),
@JsonSubTypes.Type(value = LabelDataPersist.class, name = FieldType.Names.FreeText),
@JsonSubTypes.Type(value = LabelAndMultiplicityDataPersist.class, name = FieldType.Names.ReferenceTypes),
@JsonSubTypes.Type(value = ReferenceTypeDataPersist.class, name = FieldType.Names.ReferenceTypes),
@JsonSubTypes.Type(value = RadioBoxDataPersist.class, name = FieldType.Names.RadioBox),
@JsonSubTypes.Type(value = LabelDataPersist.class, name = FieldType.Names.RichTextarea),
@JsonSubTypes.Type(value = LabelDataPersist.class, name = FieldType.Names.Tags),

View File

@ -22,7 +22,8 @@ import java.util.UUID;
visible = true)
@JsonSubTypes({
@JsonSubTypes.Type(value = SystemFieldPersist.class, name = "0"),
@JsonSubTypes.Type(value = ExtraFieldPersist.class, name = "1")
@JsonSubTypes.Type(value = ExtraFieldPersist.class, name = "1"),
@JsonSubTypes.Type(value = ReferenceTypeFieldPersist.class, name = "2")
})
public abstract class FieldPersist {

View File

@ -200,7 +200,7 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
}
persistEntity(onSuccess?: (response) => void): void {
if (this.isNew && !this.isClone && !this.isNewVersion){
if (!this.isClone && !this.isNewVersion){
const formData = this.formService.getValue(this.formGroup.value) as DescriptionTemplatePersist;
this.descriptionTemplateService.persist(formData)
@ -208,7 +208,7 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
complete => onSuccess ? onSuccess(complete) : this.onCallbackSuccess(complete),
error => this.onCallbackError(error)
);
} else if (this.isNewVersion && !this.isNew && !this.isClone) {
} else if (this.isNewVersion && !this.isNew && !this.isClone) {
const formData = this.formService.getValue(this.formGroup.value) as NewVersionDescriptionTemplatePersist;
this.descriptionTemplateService.newVersion(formData)
@ -216,14 +216,14 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
complete => onSuccess ? onSuccess(complete) : this.onCallbackSuccess(complete),
error => this.onCallbackError(error)
);
}
}
}
formSubmit(): void {
this.formService.touchAllFormFields(this.formGroup);
// if (!this.isFormValid()) {
// return;
// }
if (!this.isFormValid()) {
return;
}
this.persistEntity();
}
@ -263,17 +263,20 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
//
addUser(user: User) {
console.log(user);
const newUser: UserDescriptionTemplateEditorModel = new UserDescriptionTemplateEditorModel();
const userArray = (this.formGroup.get('users') as FormArray)
const newUser: UserDescriptionTemplateEditorModel = new UserDescriptionTemplateEditorModel(this.editorModel.validationErrorModel);
newUser.userId = user.id;
newUser.role = UserDescriptionTemplateRole.Owner;
this.usersMap.set(user.id, user);
(this.formGroup.get('users') as FormArray).push(newUser.buildForm());
(this.formGroup.get('users') as FormArray).push(newUser.buildForm({ rootPath: 'users[' + userArray.length + '].' }));
this.userFormControl.reset();
}
removeUser(index: number) {
(this.formGroup.get('users') as FormArray).controls.splice(index, 1);
this.formGroup.get('users').updateValueAndValidity();
this.reaplyValidators();
this.formGroup.get('users').markAsDirty();
}
verifyAndRemoveUser(index: number) {

View File

@ -84,17 +84,6 @@ export class DescriptionTemplateEditorModel extends BaseEditorModel implements D
return baseContext;
}
createChildPage(index: number, id: string): UntypedFormGroup {
const page: DescriptionTemplatePageEditorModel = new DescriptionTemplatePageEditorModel(this.validationErrorModel);
page.id = id;
if (isNaN(index)) { page.ordinal = 0; } else { page.ordinal = index; }
return page.buildForm({ rootPath: 'definition.pages[' + index + '].' });
}
createChildSection(index: number): UntypedFormGroup {
const section: DescriptionTemplateSectionEditorModel = new DescriptionTemplateSectionEditorModel(this.validationErrorModel);
return section.buildForm({ rootPath: 'definition.sections[' + index + '].' });
}
static reApplyDefinitionValidators(params: {
formGroup: UntypedFormGroup,

View File

@ -102,6 +102,8 @@
<mat-select [formControl]="field.get('category')" [disabled]="field.disabled" (selectionChange)="fieldCategoryChanged(sectionIndex, fieldIndex)">
<mat-option *ngFor="let fieldCategory of dmpBlueprintFieldCategoryEnum" [value]="fieldCategory">{{enumUtils.toDmpBlueprintFieldCategoryString(fieldCategory)}}</mat-option>
</mat-select>
<mat-error *ngIf="field.get('category').hasError('backendError')">{{field.get('category').getError('backendError').message}}</mat-error>
<mat-error *ngIf="field.get('category').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="col-auto" *ngIf="field.get('category').value === dmpBlueprintSectionFieldCategory.System">
@ -160,8 +162,8 @@
</div>
<div class="col-auto" *ngIf="field.get('category').value != null">
<mat-checkbox [disabled]="field.get('systemFieldType')?.value === dmpBlueprintSystemFieldType.Title || field.get('systemFieldType')?.value === dmpBlueprintSystemFieldType.Description" [formControl]="field.get('required')"><span>{{'DMP-BLUEPRINT-EDITOR.FIELDS.FIELD-REQUIRED' | translate}}</span></mat-checkbox>
<mat-error *ngIf="field.get('systemFieldType').hasError('backendError')">{{field.get('systemFieldType').getError('backendError').message}}</mat-error>
<mat-error *ngIf="field.get('systemFieldType').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
<mat-error *ngIf="field.get('required').hasError('backendError')">{{field.get('required').getError('backendError').message}}</mat-error>
<mat-error *ngIf="field.get('required').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</div>
<div [hidden]="viewOnly" class="col-auto">
<button mat-icon-button matTooltip="{{'DMP-BLUEPRINT-EDITOR.ACTIONS.REMOVE-FIELD' | translate}}" (click)="removeField(sectionIndex, fieldIndex)" [disabled]="formGroup.disabled">

View File

@ -221,6 +221,7 @@ export class DmpBlueprintEditorComponent extends BaseEditor<DmpBlueprintEditorMo
formSubmit(): void {
this.formService.touchAllFormFields(this.formGroup);
console.log(this.formGroup);
if (!this.isFormValid()) {
return;
}

View File

@ -373,9 +373,9 @@ export class FieldInSectionEditorModel implements FieldInSectionPersist {
const baseValidationArray: Validation[] = new Array<Validation>();
baseValidationArray.push({ key: 'id', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}id`)] });
baseValidationArray.push({ key: 'category', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}category`)] });
baseValidationArray.push({ key: 'category', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}category`)] });
baseValidationArray.push({ key: 'label-system', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}label`)] });
baseValidationArray.push({ key: 'label-extra', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}label`)] });
baseValidationArray.push({ key: 'label-extra', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}label`)] });
baseValidationArray.push({ key: 'placeholder', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}placeholder`)] });
baseValidationArray.push({ key: 'description', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}description`)] });
baseValidationArray.push({ key: 'required', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}required`)] });

View File

@ -2224,7 +2224,6 @@
"SELECT": "Select",
"BOOLEAN-DECISION": "Boolean Decision",
"RADIO-BOX": "Radio Box",
"INTERNAL-DMP-ENTITIES-RESEARCHERS": "Internal Researchers",
"INTERNAL-DMP-ENTITIES-DMPS": "Internal DMPs",
"INTERNAL-DMP-ENTITIES-DATASETS": "Internal Descriptions",
"CHECKBOX": "Checkbox",
@ -2234,17 +2233,8 @@
"UPLOAD": "Upload",
"DATE-PICKER": "Date Picker",
"EXTERNAL-DATASETS": "External Datasets",
"DATA-REPOSITORIES": "Data Repositories",
"JOURNALS-REPOSITORIES": "Journals",
"PUB-REPOSITORIES": "Publication Repositories",
"LICENSES": "Licenses",
"TAXONOMIES": "Taxonomies",
"PUBLICATIONS": "Publications",
"REGISTRIES": "Metadata",
"SERVICES": "Services",
"REFERENCE-TYPES": "Reference Types",
"TAGS": "Tags",
"RESEARCHERS": "Researchers",
"ORGANIZATIONS": "Organizations",
"DATASET-IDENTIFIER": "Dataset Identifier",
"CURRENCY": "Currency",
"VALIDATION": "Validator"