more ui changes

This commit is contained in:
Diamantis Tziotzios 2024-01-31 11:36:12 +02:00
parent 5377b1db18
commit 4c1372257a
11 changed files with 120 additions and 53 deletions

View File

@ -1,5 +0,0 @@
export enum DescriptionTemplateFieldDataInternalDmpEntryType {
Researchers = 'researchers',
Dmps = 'dmps',
Datasets = 'datasets'
}

View File

@ -33,6 +33,7 @@ import { NotificationNotifyState } from '@app/core/common/enum/notification-noti
import { NotificationTrackingState } from '@app/core/common/enum/notification-tracking-state'; import { NotificationTrackingState } from '@app/core/common/enum/notification-tracking-state';
import { NotificationTrackingProcess } from '@app/core/common/enum/notification-tracking-process'; import { NotificationTrackingProcess } from '@app/core/common/enum/notification-tracking-process';
import { DmpAccessType } from '@app/core/common/enum/dmp-access-type'; import { DmpAccessType } from '@app/core/common/enum/dmp-access-type';
import { DescriptionTemplateFieldDataExternalDatasetType } from '@app/core/common/enum/description-template-field-data-external-dataset-type';
@Injectable() @Injectable()
export class EnumUtils { export class EnumUtils {
@ -386,4 +387,14 @@ export class EnumUtils {
} }
} }
public toDescriptionTemplateFieldDataExternalDatasetTypeString(value: DescriptionTemplateFieldDataExternalDatasetType): string {
switch (value) {
case DescriptionTemplateFieldDataExternalDatasetType.ReusedDataset: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-FIELD-EXTERNAL-DATASET-TYPE.REUSED');
case DescriptionTemplateFieldDataExternalDatasetType.ProducedDataset: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-FIELD-EXTERNAL-DATASET-TYPE.PRODUCED');
case DescriptionTemplateFieldDataExternalDatasetType.Other: return this.language.instant('TYPES.DESCRIPTION-TEMPLATE-FIELD-EXTERNAL-DATASET-TYPE.OTHER');
}
}
} }

View File

@ -28,6 +28,7 @@ import { DescriptionTemplateListingComponent } from './listing/description-templ
import { DescriptionTemplateListingFiltersComponent } from "./listing/filters/description-template-listing-filters.component"; import { DescriptionTemplateListingFiltersComponent } from "./listing/filters/description-template-listing-filters.component";
import { ImportDescriptionTemplateDialogComponent } from './listing/import-description-template/import-description-template.dialog.component'; import { ImportDescriptionTemplateDialogComponent } from './listing/import-description-template/import-description-template.dialog.component';
import { DescriptionTemplateEditorRadioBoxFieldComponent } from './editor/components/field-type/radio-box/description-template-editor-radio-box-field.component'; import { DescriptionTemplateEditorRadioBoxFieldComponent } from './editor/components/field-type/radio-box/description-template-editor-radio-box-field.component';
import { DescriptionTemplateEditorExternalDatasetsFieldComponent } from './editor/components/field-type/external-datasets/description-template-editor-external-datasets-field.component';
@NgModule({ @NgModule({
imports: [ imports: [
@ -70,7 +71,8 @@ import { DescriptionTemplateEditorRadioBoxFieldComponent } from './editor/compon
DescriptionTemplateEditorSelectFieldComponent, DescriptionTemplateEditorSelectFieldComponent,
DescriptionTemplateEditorPlaceholderFieldComponent, DescriptionTemplateEditorPlaceholderFieldComponent,
DescriptionTemplateEditorMultiplicityFieldComponent, DescriptionTemplateEditorMultiplicityFieldComponent,
DescriptionTemplateEditorRadioBoxFieldComponent DescriptionTemplateEditorRadioBoxFieldComponent,
DescriptionTemplateEditorExternalDatasetsFieldComponent
] ]
}) })
export class DescriptionTemplateModule { } export class DescriptionTemplateModule { }

View File

@ -1,41 +0,0 @@
import { Component, Input, OnInit } from '@angular/core';
import { UntypedFormGroup } from '@angular/forms';
import { DatePickerDataEditorModel } from '../../../../admin/field-data/date-picker-data-editor-models';
import { ExternalDatasetsDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/external-datasets-data-editor-models';
import { ExternalDatasetTypeEnum } from '@app/core/common/enum/external-dataset-type-enum';
@Component({
selector: 'app-dataset-profile-editor-external-datasets-field-component',
styleUrls: ['./dataset-profile-editor-external-datasets-field.component.scss'],
templateUrl: './dataset-profile-editor-external-datasets-field.component.html'
})
export class DatasetProfileEditorExternalDatasetsFieldComponent implements OnInit {
@Input() form: UntypedFormGroup;
private data: ExternalDatasetsDataEditorModel = new ExternalDatasetsDataEditorModel();
externalDatasetTypes = [
... Object.keys(ExternalDatasetTypeEnum).map(key=>{
return {
label: this.parseExtrernalDatasetTypeKey(key),
value: ExternalDatasetTypeEnum[key]
};
})
];
ngOnInit() {
if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); }
}
parseExtrernalDatasetTypeKey(key: string): string{
if(ExternalDatasetTypeEnum[key] === ExternalDatasetTypeEnum.ProducedDataset){
return 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.EXTERNAL-DATASET-TYPES.PRODUCED';
}
if(ExternalDatasetTypeEnum[key] === ExternalDatasetTypeEnum.ReusedDataset){
return 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.EXTERNAL-DATASET-TYPES.REUSED';
}
if(ExternalDatasetTypeEnum[key] === ExternalDatasetTypeEnum.Other){
return 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.EXTERNAL-DATASET-TYPES.OTHER';
}
return key;
}
}

View File

@ -10,13 +10,13 @@
<input matInput type="string"[formControl]="form.get('data').get('label')"> <input matInput type="string"[formControl]="form.get('data').get('label')">
<mat-error *ngIf="form.get('data').get('label').hasError('backendError')">{{form.get('data').get('label').getError('backendError').message}}</mat-error> <mat-error *ngIf="form.get('data').get('label').hasError('backendError')">{{form.get('data').get('label').getError('backendError').message}}</mat-error>
</mat-form-field> </mat-form-field>
<mat-form-field class="col-6"> <!-- <mat-form-field class="col-6">
<mat-label> <mat-label>
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.EXTERNAL-DATASET-TYPE-NAME' | translate}} {{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.EXTERNAL-DATASET-TYPE-NAME' | translate}}
</mat-label> </mat-label>
<mat-select [formControl]="form.get('data').get('type')"> <mat-select [formControl]="form.get('data').get('type')">
<mat-option *ngFor="let type of externalDatasetTypes" [value]="type.value">{{type.label | translate}}</mat-option> <mat-option *ngFor="let type of externalDatasetTypeEnumValues" [value]="type">{{enumUtils.toDescriptionTemplateFieldDataExternalDatasetTypeString(type)}}</mat-option>
</mat-select> </mat-select>
<mat-error *ngIf="form.get('data').get('type').hasError('backendError')">{{form.get('data').get('type').getError('backendError').message}}</mat-error> <mat-error *ngIf="form.get('data').get('type').hasError('backendError')">{{form.get('data').get('type').getError('backendError').message}}</mat-error>
</mat-form-field> </mat-form-field> -->
</div> </div>

View File

@ -0,0 +1,22 @@
import { Component, Input, OnInit } from '@angular/core';
import { UntypedFormGroup } from '@angular/forms';
import { DescriptionTemplateFieldDataExternalDatasetType } from '@app/core/common/enum/description-template-field-data-external-dataset-type';
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
@Component({
selector: 'app-description-template-editor-external-datasets-field-component',
styleUrls: ['./description-template-editor-external-datasets-field.component.scss'],
templateUrl: './description-template-editor-external-datasets-field.component.html'
})
export class DescriptionTemplateEditorExternalDatasetsFieldComponent implements OnInit {
@Input() form: UntypedFormGroup;
externalDatasetTypeEnumValues = this.enumUtils.getEnumValues<DescriptionTemplateFieldDataExternalDatasetType>(DescriptionTemplateFieldDataExternalDatasetType);
constructor(
private enumUtils: EnumUtils
) {}
ngOnInit() {
}
}

View File

@ -215,11 +215,11 @@
<app-description-template-editor-placeholder-field-component *ngSwitchCase="descriptionTemplateFieldTypeEnum.CURRENCY" class="col-12" [form]="form"></app-description-template-editor-placeholder-field-component> <app-description-template-editor-placeholder-field-component *ngSwitchCase="descriptionTemplateFieldTypeEnum.CURRENCY" class="col-12" [form]="form"></app-description-template-editor-placeholder-field-component>
<app-description-template-editor-placeholder-field-component *ngSwitchCase="descriptionTemplateFieldTypeEnum.VALIDATION" class="col-12" [form]="form"></app-description-template-editor-placeholder-field-component> <app-description-template-editor-placeholder-field-component *ngSwitchCase="descriptionTemplateFieldTypeEnum.VALIDATION" class="col-12" [form]="form"></app-description-template-editor-placeholder-field-component>
<app-description-template-editor-external-datasets-field-component *ngSwitchCase="descriptionTemplateFieldTypeEnum.EXTERNAL_DATASETS" class="col-12" [form]="form"></app-description-template-editor-external-datasets-field-component>
<app-description-template-editor-multiplicity-field-component *ngSwitchCase="descriptionTemplateFieldTypeEnum.INTERNAL_DMP_ENTRIES_RESEARCHERS" class="col-12" [form]="form"></app-description-template-editor-multiplicity-field-component> <app-description-template-editor-multiplicity-field-component *ngSwitchCase="descriptionTemplateFieldTypeEnum.INTERNAL_DMP_ENTRIES_RESEARCHERS" class="col-12" [form]="form"></app-description-template-editor-multiplicity-field-component>
<app-description-template-editor-multiplicity-field-component *ngSwitchCase="descriptionTemplateFieldTypeEnum.INTERNAL_DMP_ENTRIES_DMPS" class="col-12" [form]="form"></app-description-template-editor-multiplicity-field-component> <app-description-template-editor-multiplicity-field-component *ngSwitchCase="descriptionTemplateFieldTypeEnum.INTERNAL_DMP_ENTRIES_DMPS" class="col-12" [form]="form"></app-description-template-editor-multiplicity-field-component>
<app-description-template-editor-multiplicity-field-component *ngSwitchCase="descriptionTemplateFieldTypeEnum.INTERNAL_DMP_ENTRIES_DATASETS" class="col-12" [form]="form"></app-description-template-editor-multiplicity-field-component> <app-description-template-editor-multiplicity-field-component *ngSwitchCase="descriptionTemplateFieldTypeEnum.INTERNAL_DMP_ENTRIES_DATASETS" class="col-12" [form]="form"></app-description-template-editor-multiplicity-field-component>
<app-description-template-editor-multiplicity-field-component *ngSwitchCase="descriptionTemplateFieldTypeEnum.EXTERNAL_DATASETS" class="col-12" [form]="form"></app-description-template-editor-multiplicity-field-component>
<app-description-template-editor-multiplicity-field-component *ngSwitchCase="descriptionTemplateFieldTypeEnum.DATA_REPOSITORIES" class="col-12" [form]="form"></app-description-template-editor-multiplicity-field-component> <app-description-template-editor-multiplicity-field-component *ngSwitchCase="descriptionTemplateFieldTypeEnum.DATA_REPOSITORIES" class="col-12" [form]="form"></app-description-template-editor-multiplicity-field-component>
<app-description-template-editor-multiplicity-field-component *ngSwitchCase="descriptionTemplateFieldTypeEnum.JOURNAL_REPOSITORIES" class="col-12" [form]="form"></app-description-template-editor-multiplicity-field-component> <app-description-template-editor-multiplicity-field-component *ngSwitchCase="descriptionTemplateFieldTypeEnum.JOURNAL_REPOSITORIES" class="col-12" [form]="form"></app-description-template-editor-multiplicity-field-component>
<app-description-template-editor-multiplicity-field-component *ngSwitchCase="descriptionTemplateFieldTypeEnum.PUB_REPOSITORIES" class="col-12" [form]="form"></app-description-template-editor-multiplicity-field-component> <app-description-template-editor-multiplicity-field-component *ngSwitchCase="descriptionTemplateFieldTypeEnum.PUB_REPOSITORIES" class="col-12" [form]="form"></app-description-template-editor-multiplicity-field-component>

View File

@ -353,7 +353,7 @@ export class DescriptionTemplateEditorFieldComponent extends BaseComponent imple
const data: DescriptionTemplateResearcherAutoCompleteData = { const data: DescriptionTemplateResearcherAutoCompleteData = {
label: '', label: '',
multiAutoComplete: false, multiAutoComplete: false,
fieldType: DescriptionTemplateFieldType.INTERNAL_DMP_ENTRIES_RESEARCHERS fieldType: DescriptionTemplateFieldType.RESEARCHERS
} }
field.data = data; field.data = data;
break; break;

View File

@ -1,11 +1,12 @@
import { FormArray, FormControl, UntypedFormArray, UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms"; import { FormArray, FormControl, UntypedFormArray, UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms";
import { DescriptionTemplateFieldAutocompleteType } from "@app/core/common/enum/description-template-field-autocomplete-type"; import { DescriptionTemplateFieldAutocompleteType } from "@app/core/common/enum/description-template-field-autocomplete-type";
import { DescriptionTemplateFieldDataExternalDatasetType } from "@app/core/common/enum/description-template-field-data-external-dataset-type";
import { DescriptionTemplateFieldType } from "@app/core/common/enum/description-template-field-type"; import { DescriptionTemplateFieldType } from "@app/core/common/enum/description-template-field-type";
import { DescriptionTemplateFieldValidationType } from "@app/core/common/enum/description-template-field-validation-type"; import { DescriptionTemplateFieldValidationType } from "@app/core/common/enum/description-template-field-validation-type";
import { DescriptionTemplateStatus } from "@app/core/common/enum/description-template-status"; import { DescriptionTemplateStatus } from "@app/core/common/enum/description-template-status";
import { UserDescriptionTemplateRole } from "@app/core/common/enum/user-description-template-role"; import { UserDescriptionTemplateRole } from "@app/core/common/enum/user-description-template-role";
import { DescriptionTemplate, DescriptionTemplateDefinition, DescriptionTemplateField, DescriptionTemplateFieldSet, DescriptionTemplateMultiplicity, DescriptionTemplatePage, DescriptionTemplateRule, DescriptionTemplateSection } from "@app/core/model/description-template/description-template"; import { DescriptionTemplate, DescriptionTemplateDefinition, DescriptionTemplateField, DescriptionTemplateFieldSet, DescriptionTemplateMultiplicity, DescriptionTemplatePage, DescriptionTemplateRule, DescriptionTemplateSection } from "@app/core/model/description-template/description-template";
import { DescriptionTemplateAuthAutoCompleteDataPersist, DescriptionTemplateAutoCompleteDataPersist, DescriptionTemplateAutoCompleteSingleDataPersist, DescriptionTemplateBaseFieldDataPersist, DescriptionTemplateComboBoxOptionPersist, DescriptionTemplateDefinitionPersist, DescriptionTemplateFieldPersist, DescriptionTemplateFieldSetPersist, DescriptionTemplateMultiplicityPersist, DescriptionTemplatePagePersist, DescriptionTemplatePersist, DescriptionTemplatePlaceholderAndMultiplicityDataPersist, DescriptionTemplateRadioBoxDataPersist, DescriptionTemplateRadioBoxOptionPersist, DescriptionTemplateRulePersist, DescriptionTemplateSectionPersist, DescriptionTemplateUploadDataPersist, DescriptionTemplateUploadOptionPersist, DescriptionTemplateSelectDataPersist, UserDescriptionTemplatePersist } from "@app/core/model/description-template/description-template-persist"; import { DescriptionTemplateAuthAutoCompleteDataPersist, DescriptionTemplateAutoCompleteDataPersist, DescriptionTemplateAutoCompleteSingleDataPersist, DescriptionTemplateBaseFieldDataPersist, DescriptionTemplateComboBoxOptionPersist, DescriptionTemplateDefinitionPersist, DescriptionTemplateFieldPersist, DescriptionTemplateFieldSetPersist, DescriptionTemplateMultiplicityPersist, DescriptionTemplatePagePersist, DescriptionTemplatePersist, DescriptionTemplatePlaceholderAndMultiplicityDataPersist, DescriptionTemplateRadioBoxDataPersist, DescriptionTemplateRadioBoxOptionPersist, DescriptionTemplateRulePersist, DescriptionTemplateSectionPersist, DescriptionTemplateUploadDataPersist, DescriptionTemplateUploadOptionPersist, DescriptionTemplateSelectDataPersist, UserDescriptionTemplatePersist, DescriptionTemplateExternalDatasetDataPersist } from "@app/core/model/description-template/description-template-persist";
import { BaseEditorModel } from "@common/base/base-form-editor-model"; import { BaseEditorModel } from "@common/base/base-form-editor-model";
import { BackendErrorValidator } from "@common/forms/validation/custom-validator"; import { BackendErrorValidator } from "@common/forms/validation/custom-validator";
import { ValidationErrorModel } from "@common/forms/validation/error-model/validation-error-model"; import { ValidationErrorModel } from "@common/forms/validation/error-model/validation-error-model";
@ -842,6 +843,8 @@ export class DescriptionTemplateFieldEditorModel implements DescriptionTemplateF
case DescriptionTemplateFieldType.RESEARCHERS: case DescriptionTemplateFieldType.RESEARCHERS:
case DescriptionTemplateFieldType.ORGANIZATIONS: case DescriptionTemplateFieldType.ORGANIZATIONS:
return new DescriptionTemplatePlaceholderAndMultiplicityFieldEditorModel(this.validationErrorModel); return new DescriptionTemplatePlaceholderAndMultiplicityFieldEditorModel(this.validationErrorModel);
case DescriptionTemplateFieldType.EXTERNAL_DATASETS:
return new DescriptionTemplateExternalDatasetFieldEditorModel(this.validationErrorModel);
case DescriptionTemplateFieldType.UPLOAD: case DescriptionTemplateFieldType.UPLOAD:
return new DescriptionTemplateUploadFieldEditorModel(this.validationErrorModel); return new DescriptionTemplateUploadFieldEditorModel(this.validationErrorModel);
} }
@ -1016,6 +1019,76 @@ export class DescriptionTemplatePlaceholderAndMultiplicityFieldEditorModel exten
} }
} }
//
//
// External Dataset Field
//
//
export class DescriptionTemplateExternalDatasetFieldEditorModel extends DescriptionTemplatePlaceholderAndMultiplicityFieldEditorModel implements DescriptionTemplateExternalDatasetDataPersist {
type: DescriptionTemplateFieldDataExternalDatasetType;
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
constructor(
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel()
) { super(validationErrorModel); }
fromModel(item: DescriptionTemplateExternalDatasetDataPersist): DescriptionTemplateExternalDatasetFieldEditorModel {
if (item) {
super.fromModel(item);
this.type = item.type;
}
return this;
}
buildForm(params?: {
context?: ValidationContext,
disabled?: boolean,
rootPath?: string
}): UntypedFormGroup {
let { context = null, disabled = false, rootPath } = params ?? {}
if (context == null) {
context = DescriptionTemplateExternalDatasetFieldEditorModel.createValidationContext({
validationErrorModel: this.validationErrorModel,
rootPath
});
}
const formGroup = super.buildForm({ context, disabled, rootPath });
formGroup.setControl('type', new FormControl({ value: this.type, disabled: disabled }, context.getValidation('type').validators));
return formGroup;
}
static createValidationContext(params: {
rootPath?: string,
validationErrorModel: ValidationErrorModel
}): ValidationContext {
const { rootPath = '', validationErrorModel } = params;
const baseContext: ValidationContext = super.createValidationContext({ rootPath, validationErrorModel });
baseContext.validation.push({ key: 'type', validators: [Validators.required, BackendErrorValidator(validationErrorModel, `${rootPath}type`)] });
return baseContext;
}
static reapplyValidators(params: {
formGroup: UntypedFormGroup,
validationErrorModel: ValidationErrorModel,
rootPath: string
}): void {
const { formGroup, rootPath, validationErrorModel } = params;
const context = DescriptionTemplateExternalDatasetFieldEditorModel.createValidationContext({
rootPath,
validationErrorModel
});
['type'].forEach(keyField => {
const control = formGroup?.get(keyField);
control?.clearValidators();
control?.addValidators(context.getValidation(keyField).validators);
})
}
}
// //
// //
// Autocomplete Field // Autocomplete Field

View File

@ -2410,6 +2410,11 @@
"DMP-ACCESS-TYPE": { "DMP-ACCESS-TYPE": {
"PUBLIC": "Public", "PUBLIC": "Public",
"RESTRICTED": "Restricted Access" "RESTRICTED": "Restricted Access"
},
"DESCRIPTION-TEMPLATE-FIELD-EXTERNAL-DATASET-TYPE": {
"PRODUCED": "Produced dataset",
"REUSED": "Reused dataset",
"OTHER": "Other"
} }
}, },
"ADDRESEARCHERS-EDITOR": { "ADDRESEARCHERS-EDITOR": {