small changes
This commit is contained in:
parent
384b9883a8
commit
6e443c69fa
|
@ -8,7 +8,7 @@ import java.util.Map;
|
||||||
public enum DmpBlueprintFieldCategory implements DatabaseEnum<Short> {
|
public enum DmpBlueprintFieldCategory implements DatabaseEnum<Short> {
|
||||||
System((short) 0),
|
System((short) 0),
|
||||||
Extra((short) 1),
|
Extra((short) 1),
|
||||||
ReferenceType((short) 1);
|
ReferenceType((short) 2);
|
||||||
|
|
||||||
public static class Names {
|
public static class Names {
|
||||||
public static final String System = "system";
|
public static final String System = "system";
|
||||||
|
|
|
@ -30,7 +30,7 @@ public enum FieldType implements DatabaseEnum<String> {
|
||||||
public static final String BooleanDecision = "booleanDecision";
|
public static final String BooleanDecision = "booleanDecision";
|
||||||
public static final String RadioBox = "radiobox";
|
public static final String RadioBox = "radiobox";
|
||||||
public static final String InternalDmpDmps = "internalDmpDmps";
|
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 CheckBox = "checkBox";
|
||||||
public static final String FreeText = "freetext";
|
public static final String FreeText = "freetext";
|
||||||
public static final String TextArea = "textarea";
|
public static final String TextArea = "textarea";
|
||||||
|
|
|
@ -28,7 +28,7 @@ import java.util.List;
|
||||||
@JsonSubTypes.Type(value = LabelDataPersist.class, name = FieldType.Names.DatePicker),
|
@JsonSubTypes.Type(value = LabelDataPersist.class, name = FieldType.Names.DatePicker),
|
||||||
@JsonSubTypes.Type(value = ExternalDatasetDataPersist.class, name = FieldType.Names.ExternalDatasets),
|
@JsonSubTypes.Type(value = ExternalDatasetDataPersist.class, name = FieldType.Names.ExternalDatasets),
|
||||||
@JsonSubTypes.Type(value = LabelDataPersist.class, name = FieldType.Names.FreeText),
|
@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 = RadioBoxDataPersist.class, name = FieldType.Names.RadioBox),
|
||||||
@JsonSubTypes.Type(value = LabelDataPersist.class, name = FieldType.Names.RichTextarea),
|
@JsonSubTypes.Type(value = LabelDataPersist.class, name = FieldType.Names.RichTextarea),
|
||||||
@JsonSubTypes.Type(value = LabelDataPersist.class, name = FieldType.Names.Tags),
|
@JsonSubTypes.Type(value = LabelDataPersist.class, name = FieldType.Names.Tags),
|
||||||
|
|
|
@ -22,7 +22,8 @@ import java.util.UUID;
|
||||||
visible = true)
|
visible = true)
|
||||||
@JsonSubTypes({
|
@JsonSubTypes({
|
||||||
@JsonSubTypes.Type(value = SystemFieldPersist.class, name = "0"),
|
@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 {
|
public abstract class FieldPersist {
|
||||||
|
|
||||||
|
|
|
@ -200,7 +200,7 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
|
||||||
}
|
}
|
||||||
|
|
||||||
persistEntity(onSuccess?: (response) => void): void {
|
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;
|
const formData = this.formService.getValue(this.formGroup.value) as DescriptionTemplatePersist;
|
||||||
|
|
||||||
this.descriptionTemplateService.persist(formData)
|
this.descriptionTemplateService.persist(formData)
|
||||||
|
@ -221,9 +221,9 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
|
||||||
|
|
||||||
formSubmit(): void {
|
formSubmit(): void {
|
||||||
this.formService.touchAllFormFields(this.formGroup);
|
this.formService.touchAllFormFields(this.formGroup);
|
||||||
// if (!this.isFormValid()) {
|
if (!this.isFormValid()) {
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
|
|
||||||
this.persistEntity();
|
this.persistEntity();
|
||||||
}
|
}
|
||||||
|
@ -263,17 +263,20 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
|
||||||
//
|
//
|
||||||
addUser(user: User) {
|
addUser(user: User) {
|
||||||
console.log(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.userId = user.id;
|
||||||
newUser.role = UserDescriptionTemplateRole.Owner;
|
newUser.role = UserDescriptionTemplateRole.Owner;
|
||||||
this.usersMap.set(user.id, user);
|
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();
|
this.userFormControl.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
removeUser(index: number) {
|
removeUser(index: number) {
|
||||||
(this.formGroup.get('users') as FormArray).controls.splice(index, 1);
|
(this.formGroup.get('users') as FormArray).controls.splice(index, 1);
|
||||||
this.formGroup.get('users').updateValueAndValidity();
|
this.formGroup.get('users').updateValueAndValidity();
|
||||||
|
this.reaplyValidators();
|
||||||
|
this.formGroup.get('users').markAsDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
verifyAndRemoveUser(index: number) {
|
verifyAndRemoveUser(index: number) {
|
||||||
|
|
|
@ -84,17 +84,6 @@ export class DescriptionTemplateEditorModel extends BaseEditorModel implements D
|
||||||
return baseContext;
|
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: {
|
static reApplyDefinitionValidators(params: {
|
||||||
formGroup: UntypedFormGroup,
|
formGroup: UntypedFormGroup,
|
||||||
|
|
|
@ -102,6 +102,8 @@
|
||||||
<mat-select [formControl]="field.get('category')" [disabled]="field.disabled" (selectionChange)="fieldCategoryChanged(sectionIndex, fieldIndex)">
|
<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-option *ngFor="let fieldCategory of dmpBlueprintFieldCategoryEnum" [value]="fieldCategory">{{enumUtils.toDmpBlueprintFieldCategoryString(fieldCategory)}}</mat-option>
|
||||||
</mat-select>
|
</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>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-auto" *ngIf="field.get('category').value === dmpBlueprintSectionFieldCategory.System">
|
<div class="col-auto" *ngIf="field.get('category').value === dmpBlueprintSectionFieldCategory.System">
|
||||||
|
@ -160,8 +162,8 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="col-auto" *ngIf="field.get('category').value != null">
|
<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-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('required').hasError('backendError')">{{field.get('required').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('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
</div>
|
</div>
|
||||||
<div [hidden]="viewOnly" class="col-auto">
|
<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">
|
<button mat-icon-button matTooltip="{{'DMP-BLUEPRINT-EDITOR.ACTIONS.REMOVE-FIELD' | translate}}" (click)="removeField(sectionIndex, fieldIndex)" [disabled]="formGroup.disabled">
|
||||||
|
|
|
@ -221,6 +221,7 @@ export class DmpBlueprintEditorComponent extends BaseEditor<DmpBlueprintEditorMo
|
||||||
|
|
||||||
formSubmit(): void {
|
formSubmit(): void {
|
||||||
this.formService.touchAllFormFields(this.formGroup);
|
this.formService.touchAllFormFields(this.formGroup);
|
||||||
|
console.log(this.formGroup);
|
||||||
if (!this.isFormValid()) {
|
if (!this.isFormValid()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -373,9 +373,9 @@ export class FieldInSectionEditorModel implements FieldInSectionPersist {
|
||||||
const baseValidationArray: Validation[] = new Array<Validation>();
|
const baseValidationArray: Validation[] = new Array<Validation>();
|
||||||
baseValidationArray.push({ key: 'id', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}id`)] });
|
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-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: 'placeholder', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}placeholder`)] });
|
||||||
baseValidationArray.push({ key: 'description', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}description`)] });
|
baseValidationArray.push({ key: 'description', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}description`)] });
|
||||||
baseValidationArray.push({ key: 'required', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}required`)] });
|
baseValidationArray.push({ key: 'required', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}required`)] });
|
||||||
|
|
|
@ -2224,7 +2224,6 @@
|
||||||
"SELECT": "Select",
|
"SELECT": "Select",
|
||||||
"BOOLEAN-DECISION": "Boolean Decision",
|
"BOOLEAN-DECISION": "Boolean Decision",
|
||||||
"RADIO-BOX": "Radio Box",
|
"RADIO-BOX": "Radio Box",
|
||||||
"INTERNAL-DMP-ENTITIES-RESEARCHERS": "Internal Researchers",
|
|
||||||
"INTERNAL-DMP-ENTITIES-DMPS": "Internal DMPs",
|
"INTERNAL-DMP-ENTITIES-DMPS": "Internal DMPs",
|
||||||
"INTERNAL-DMP-ENTITIES-DATASETS": "Internal Descriptions",
|
"INTERNAL-DMP-ENTITIES-DATASETS": "Internal Descriptions",
|
||||||
"CHECKBOX": "Checkbox",
|
"CHECKBOX": "Checkbox",
|
||||||
|
@ -2234,17 +2233,8 @@
|
||||||
"UPLOAD": "Upload",
|
"UPLOAD": "Upload",
|
||||||
"DATE-PICKER": "Date Picker",
|
"DATE-PICKER": "Date Picker",
|
||||||
"EXTERNAL-DATASETS": "External Datasets",
|
"EXTERNAL-DATASETS": "External Datasets",
|
||||||
"DATA-REPOSITORIES": "Data Repositories",
|
"REFERENCE-TYPES": "Reference Types",
|
||||||
"JOURNALS-REPOSITORIES": "Journals",
|
|
||||||
"PUB-REPOSITORIES": "Publication Repositories",
|
|
||||||
"LICENSES": "Licenses",
|
|
||||||
"TAXONOMIES": "Taxonomies",
|
|
||||||
"PUBLICATIONS": "Publications",
|
|
||||||
"REGISTRIES": "Metadata",
|
|
||||||
"SERVICES": "Services",
|
|
||||||
"TAGS": "Tags",
|
"TAGS": "Tags",
|
||||||
"RESEARCHERS": "Researchers",
|
|
||||||
"ORGANIZATIONS": "Organizations",
|
|
||||||
"DATASET-IDENTIFIER": "Dataset Identifier",
|
"DATASET-IDENTIFIER": "Dataset Identifier",
|
||||||
"CURRENCY": "Currency",
|
"CURRENCY": "Currency",
|
||||||
"VALIDATION": "Validator"
|
"VALIDATION": "Validator"
|
||||||
|
|
Loading…
Reference in New Issue