Merge branch 'dmp-refactoring' of https://code-repo.d4science.org/MaDgiK-CITE/argos into dmp-refactoring

This commit is contained in:
amentis 2024-01-31 11:42:03 +02:00
commit f604eac172
11 changed files with 128 additions and 63 deletions

View File

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

View File

@ -1,16 +1,26 @@
import { Injectable } from '@angular/core';
import { DescriptionStatus } from '@app/core/common/enum/description-status';
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 { DescriptionTemplateStatus } from '@app/core/common/enum/description-template-status';
import { DescriptionTemplateTypeStatus } from '@app/core/common/enum/description-template-type-status';
import { DmpAccessType } from '@app/core/common/enum/dmp-access-type';
import { DmpBlueprintStatus } from '@app/core/common/enum/dmp-blueprint-status';
import { DmpBlueprintSystemFieldType } from '@app/core/common/enum/dmp-blueprint-system-field-type';
import { DmpContactType } from '@app/core/common/enum/dmp-contact-type';
import { DmpUserRole } from '@app/core/common/enum/dmp-user-role';
import { EmailOverrideMode } from '@app/core/common/enum/email-override-mode';
import { IsActive } from '@app/core/common/enum/is-active.enum';
import { NotificationContactType } from '@app/core/common/enum/notification-contact-type';
import { NotificationDataType } from '@app/core/common/enum/notification-data-type';
import { NotificationInAppTracking } from '@app/core/common/enum/notification-inapp-tracking.enum';
import { NotificationNotifyState } from '@app/core/common/enum/notification-notify-state';
import { NotificationTemplateChannel } from '@app/core/common/enum/notification-template-channel';
import { NotificationTemplateKind } from '@app/core/common/enum/notification-template-kind';
import { NotificationTrackingProcess } from '@app/core/common/enum/notification-tracking-process';
import { NotificationTrackingState } from '@app/core/common/enum/notification-tracking-state';
import { NotificationType } from '@app/core/common/enum/notification-type';
import { RecentActivityOrder } from '@app/core/common/enum/recent-activity-order';
import { ReferenceFieldDataType } from '@app/core/common/enum/reference-field-data-type';
import { ReferenceSourceType } from '@app/core/common/enum/reference-source-type';
import { ReferenceType } from '@app/core/common/enum/reference-type';
@ -25,15 +35,6 @@ import { DmpBlueprintExtraFieldDataType } from '../../common/enum/dmp-blueprint-
import { DmpBlueprintType } from '../../common/enum/dmp-blueprint-type';
import { DmpStatus } from '../../common/enum/dmp-status';
import { ValidationType } from '../../common/enum/validation-type';
import { RecentActivityOrder } from '@app/core/common/enum/recent-activity-order';
import { NotificationType } from '@app/core/common/enum/notification-type';
import { NotificationInAppTracking } from '@app/core/common/enum/notification-inapp-tracking.enum';
import { NotificationContactType } from '@app/core/common/enum/notification-contact-type';
import { NotificationNotifyState } from '@app/core/common/enum/notification-notify-state';
import { NotificationTrackingState } from '@app/core/common/enum/notification-tracking-state';
import { NotificationTrackingProcess } from '@app/core/common/enum/notification-tracking-process';
import { DmpAccessType } from '@app/core/common/enum/dmp-access-type';
import { DmpContactType } from '@app/core/common/enum/dmp-contact-type';
@Injectable()
export class EnumUtils {
@ -387,6 +388,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');
}
}
public toDmpContactTypeString(value: DmpContactType): string {
switch (value) {
case DmpContactType.Internal: return this.language.instant('TYPES.DMP-CONTACT-TYPE.INTERNAL');

View File

@ -28,6 +28,7 @@ import { DescriptionTemplateListingComponent } from './listing/description-templ
import { DescriptionTemplateListingFiltersComponent } from "./listing/filters/description-template-listing-filters.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 { DescriptionTemplateEditorExternalDatasetsFieldComponent } from './editor/components/field-type/external-datasets/description-template-editor-external-datasets-field.component';
@NgModule({
imports: [
@ -70,7 +71,8 @@ import { DescriptionTemplateEditorRadioBoxFieldComponent } from './editor/compon
DescriptionTemplateEditorSelectFieldComponent,
DescriptionTemplateEditorPlaceholderFieldComponent,
DescriptionTemplateEditorMultiplicityFieldComponent,
DescriptionTemplateEditorRadioBoxFieldComponent
DescriptionTemplateEditorRadioBoxFieldComponent,
DescriptionTemplateEditorExternalDatasetsFieldComponent
]
})
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')">
<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 class="col-6">
<!-- <mat-form-field class="col-6">
<mat-label>
{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.EXTERNAL-DATASET-TYPE-NAME' | translate}}
</mat-label>
<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-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>

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.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_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.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.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>

View File

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

View File

@ -1,11 +1,12 @@
import { FormArray, FormControl, UntypedFormArray, UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms";
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 { DescriptionTemplateFieldValidationType } from "@app/core/common/enum/description-template-field-validation-type";
import { DescriptionTemplateStatus } from "@app/core/common/enum/description-template-status";
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 { 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 { BackendErrorValidator } from "@common/forms/validation/custom-validator";
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.ORGANIZATIONS:
return new DescriptionTemplatePlaceholderAndMultiplicityFieldEditorModel(this.validationErrorModel);
case DescriptionTemplateFieldType.EXTERNAL_DATASETS:
return new DescriptionTemplateExternalDatasetFieldEditorModel(this.validationErrorModel);
case DescriptionTemplateFieldType.UPLOAD:
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

View File

@ -2416,6 +2416,11 @@
"PUBLIC": "Public",
"RESTRICTED": "Restricted Access"
},
"DESCRIPTION-TEMPLATE-FIELD-EXTERNAL-DATASET-TYPE": {
"PRODUCED": "Produced dataset",
"REUSED": "Reused dataset",
"OTHER": "Other"
},
"DMP-CONTACT-TYPE": {
"INTERNAL": "Internal",
"EXTERNAL": "External"