Merge branch 'dmp-refactoring' of https://code-repo.d4science.org/MaDgiK-CITE/argos into dmp-refactoring
# Conflicts: # frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.html # frontend/src/app/ui/admin/description-template/editor/description-template-editor.component.ts # frontend/src/app/ui/admin/description-template/editor/description-template-editor.model.ts
This commit is contained in:
commit
15ec93a069
|
@ -123,7 +123,7 @@
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="row justify-content-end">
|
<div class="row justify-content-end">
|
||||||
<div class="col-12 col-lg-4 d-flex justify-content-end" style="overflow: hidden;">
|
<div class="col-12 col-lg-4 d-flex justify-content-end" style="overflow: hidden;">
|
||||||
<mat-form-field class="full-width basic-info-input" *ngIf="!formGroup.disabled">
|
<mat-form-field class="full-width basic-info-input" *ngIf="!viewOnly">
|
||||||
<mat-label>{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.GENERAL-INFO.DESCRIPTION-TEMPLATE-USERS' | translate}}</mat-label>
|
<mat-label>{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.GENERAL-INFO.DESCRIPTION-TEMPLATE-USERS' | translate}}</mat-label>
|
||||||
<app-single-auto-complete [required]="false" [formControl]="userFormControl" (optionSelected)="addUser($event)" placeholder="{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.GENERAL-INFO.DESCRIPTION-TEMPLATE-USERS' | translate}}" [configuration]="userService.singleAutocompleteConfiguration">
|
<app-single-auto-complete [required]="false" [formControl]="userFormControl" (optionSelected)="addUser($event)" placeholder="{{'DESCRIPTION-TEMPLATE-EDITOR.STEPS.GENERAL-INFO.DESCRIPTION-TEMPLATE-USERS' | translate}}" [configuration]="userService.singleAutocompleteConfiguration">
|
||||||
</app-single-auto-complete>
|
</app-single-auto-complete>
|
||||||
|
@ -197,7 +197,7 @@
|
||||||
<div class="col-12" *ngIf="(selectedTocEntry.type === tocEntryEnumValues.Section) || (selectedTocEntry.type === tocEntryEnumValues.FieldSet)">
|
<div class="col-12" *ngIf="(selectedTocEntry.type === tocEntryEnumValues.Section) || (selectedTocEntry.type === tocEntryEnumValues.FieldSet)">
|
||||||
<app-description-template-editor-section-fieldset-component
|
<app-description-template-editor-section-fieldset-component
|
||||||
[tocentry]="selectedTocEntry"
|
[tocentry]="selectedTocEntry"
|
||||||
[viewOnly]="formGroup.disabled"
|
[viewOnly]="viewOnly"
|
||||||
[descriptionTemplateId]="descriptionTemplateId"
|
[descriptionTemplateId]="descriptionTemplateId"
|
||||||
[validationErrorModel]="editorModel.validationErrorModel"
|
[validationErrorModel]="editorModel.validationErrorModel"
|
||||||
[validationRootPath]="selectedTocEntry.validationRootPath"
|
[validationRootPath]="selectedTocEntry.validationRootPath"
|
||||||
|
|
|
@ -27,7 +27,6 @@ import { AnalyticsService } from '@app/core/services/matomo/analytics-service';
|
||||||
import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service';
|
import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service';
|
||||||
import { UserService } from '@app/core/services/user/user.service';
|
import { UserService } from '@app/core/services/user/user.service';
|
||||||
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
|
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
|
||||||
import { FileUtils } from '@app/core/services/utilities/file-utils.service';
|
|
||||||
import { QueryParamsService } from '@app/core/services/utilities/query-params.service';
|
import { QueryParamsService } from '@app/core/services/utilities/query-params.service';
|
||||||
import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration';
|
import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration';
|
||||||
import { BaseEditor } from '@common/base/base-editor';
|
import { BaseEditor } from '@common/base/base-editor';
|
||||||
|
@ -60,8 +59,6 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
|
||||||
|
|
||||||
@ViewChild('stepper') stepper: MatStepper;
|
@ViewChild('stepper') stepper: MatStepper;
|
||||||
|
|
||||||
isNew = true;
|
|
||||||
isDeleted = false;
|
|
||||||
formGroup: UntypedFormGroup = null;
|
formGroup: UntypedFormGroup = null;
|
||||||
item: DescriptionTemplate;
|
item: DescriptionTemplate;
|
||||||
showInactiveDetails = false;
|
showInactiveDetails = false;
|
||||||
|
@ -69,8 +66,6 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
|
||||||
|
|
||||||
availableLanguages: LanguageInfo[] = this.languageInfoService.getLanguageInfoValues();
|
availableLanguages: LanguageInfo[] = this.languageInfoService.getLanguageInfoValues();
|
||||||
|
|
||||||
isNewVersion = false;
|
|
||||||
isClone = false;
|
|
||||||
showErrors: boolean = false;
|
showErrors: boolean = false;
|
||||||
steps: QueryList<CdkStep>;
|
steps: QueryList<CdkStep>;
|
||||||
toCEntries: ToCEntry[];
|
toCEntries: ToCEntry[];
|
||||||
|
@ -83,6 +78,10 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
|
||||||
|
|
||||||
singleAutocompleteDescriptionTemplateTypeConfiguration: SingleAutoCompleteConfiguration;
|
singleAutocompleteDescriptionTemplateTypeConfiguration: SingleAutoCompleteConfiguration;
|
||||||
|
|
||||||
|
isNew = true;
|
||||||
|
isClone = false;
|
||||||
|
isNewVersion = false;
|
||||||
|
isDeleted = false;
|
||||||
|
|
||||||
//Preview
|
//Preview
|
||||||
previewFieldSet: DescriptionTemplate = null;
|
previewFieldSet: DescriptionTemplate = null;
|
||||||
|
@ -152,7 +151,6 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
|
||||||
public descriptionTemplateTypeService: DescriptionTemplateTypeService,
|
public descriptionTemplateTypeService: DescriptionTemplateTypeService,
|
||||||
private logger: LoggingService,
|
private logger: LoggingService,
|
||||||
private descriptionTemplateEditorService: DescriptionTemplateEditorService,
|
private descriptionTemplateEditorService: DescriptionTemplateEditorService,
|
||||||
private fileUtils: FileUtils,
|
|
||||||
private languageInfoService: LanguageInfoService,
|
private languageInfoService: LanguageInfoService,
|
||||||
public userService: UserService,
|
public userService: UserService,
|
||||||
public titleService: Title,
|
public titleService: Title,
|
||||||
|
@ -202,7 +200,13 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
|
||||||
|
|
||||||
prepareForm(data: DescriptionTemplate) {
|
prepareForm(data: DescriptionTemplate) {
|
||||||
try {
|
try {
|
||||||
this.editorModel = data ? new DescriptionTemplateEditorModel().fromModel(data) : new DescriptionTemplateEditorModel();
|
|
||||||
|
const dataCopy = data ? JSON.parse(JSON.stringify(data)) : null;
|
||||||
|
if(dataCopy && this.isClone) {
|
||||||
|
dataCopy.belongsToCurrentTenant = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.editorModel = dataCopy ? new DescriptionTemplateEditorModel().fromModel(dataCopy) : new DescriptionTemplateEditorModel();
|
||||||
this.item = data;
|
this.item = data;
|
||||||
// Add user info to Map, to present them.
|
// Add user info to Map, to present them.
|
||||||
(this.item?.users ?? []).forEach(obj => { this.usersMap.set(obj.user.id, obj.user); });
|
(this.item?.users ?? []).forEach(obj => { this.usersMap.set(obj.user.id, obj.user); });
|
||||||
|
@ -229,7 +233,6 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
|
||||||
|
|
||||||
const action = this.route.snapshot.data['action'];
|
const action = this.route.snapshot.data['action'];
|
||||||
if (action && action == 'new-version') {
|
if (action && action == 'new-version') {
|
||||||
this.formGroup.enable();
|
|
||||||
this.formGroup.get('code').disable();
|
this.formGroup.get('code').disable();
|
||||||
this.formGroup.get('status').setValue(DescriptionTemplateStatus.Draft);
|
this.formGroup.get('status').setValue(DescriptionTemplateStatus.Draft);
|
||||||
}
|
}
|
||||||
|
@ -256,7 +259,7 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
|
||||||
}
|
}
|
||||||
|
|
||||||
persistEntity(onSuccess?: (response) => void): void {
|
persistEntity(onSuccess?: (response) => void): void {
|
||||||
if (this.isNewVersion == false) {
|
if (!this.isNewVersion) {
|
||||||
const formData = this.formService.getValue(this.formGroup.value) as DescriptionTemplatePersist;
|
const formData = this.formService.getValue(this.formGroup.value) as DescriptionTemplatePersist;
|
||||||
formData.code = this.formGroup.get('code').getRawValue();
|
formData.code = this.formGroup.get('code').getRawValue();
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,8 @@ export class DescriptionTemplateEditorModel extends BaseEditorModel implements D
|
||||||
type: [{ value: this.type, disabled }, context.getValidation('type').validators],
|
type: [{ value: this.type, disabled }, context.getValidation('type').validators],
|
||||||
status: [{ value: this.status, disabled }, context.getValidation('status').validators],
|
status: [{ value: this.status, disabled }, context.getValidation('status').validators],
|
||||||
definition: this.definition.buildForm({
|
definition: this.definition.buildForm({
|
||||||
rootPath: `definition.`
|
rootPath: `definition.`,
|
||||||
|
disabled
|
||||||
}),
|
}),
|
||||||
users: this.formBuilder.array(
|
users: this.formBuilder.array(
|
||||||
(this.users ?? []).map(
|
(this.users ?? []).map(
|
||||||
|
@ -219,7 +220,8 @@ export class DescriptionTemplateDefinitionEditorModel implements DescriptionTemp
|
||||||
pages: this.formBuilder.array(
|
pages: this.formBuilder.array(
|
||||||
(this.pages ?? []).map(
|
(this.pages ?? []).map(
|
||||||
(item, index) => item.buildForm({
|
(item, index) => item.buildForm({
|
||||||
rootPath: `${rootPath}pages[${index}].`
|
rootPath: `${rootPath}pages[${index}].`,
|
||||||
|
disabled
|
||||||
})
|
})
|
||||||
), context.getValidation('pages').validators
|
), context.getValidation('pages').validators
|
||||||
),
|
),
|
||||||
|
@ -299,7 +301,8 @@ export class DescriptionTemplatePageEditorModel implements DescriptionTemplatePa
|
||||||
sections: this.formBuilder.array(
|
sections: this.formBuilder.array(
|
||||||
(this.sections ?? []).map(
|
(this.sections ?? []).map(
|
||||||
(item, index) => item.buildForm({
|
(item, index) => item.buildForm({
|
||||||
rootPath: `${rootPath}sections[${index}].`
|
rootPath: `${rootPath}sections[${index}].`,
|
||||||
|
disabled
|
||||||
})
|
})
|
||||||
), context.getValidation('sections').validators
|
), context.getValidation('sections').validators
|
||||||
),
|
),
|
||||||
|
@ -408,14 +411,16 @@ export class DescriptionTemplateSectionEditorModel implements DescriptionTemplat
|
||||||
sections: this.formBuilder.array(
|
sections: this.formBuilder.array(
|
||||||
(this.sections ?? []).map(
|
(this.sections ?? []).map(
|
||||||
(item, index) => item.buildForm({
|
(item, index) => item.buildForm({
|
||||||
rootPath: `${rootPath}sections[${index}].`
|
rootPath: `${rootPath}sections[${index}].`,
|
||||||
|
disabled
|
||||||
})
|
})
|
||||||
), context.getValidation('sections').validators
|
), context.getValidation('sections').validators
|
||||||
),
|
),
|
||||||
fieldSets: this.formBuilder.array(
|
fieldSets: this.formBuilder.array(
|
||||||
(this.fieldSets ?? []).map(
|
(this.fieldSets ?? []).map(
|
||||||
(item, index) => item.buildForm({
|
(item, index) => item.buildForm({
|
||||||
rootPath: `${rootPath}fieldSets[${index}].`
|
rootPath: `${rootPath}fieldSets[${index}].`,
|
||||||
|
disabled
|
||||||
})
|
})
|
||||||
), context.getValidation('fieldSets').validators
|
), context.getValidation('fieldSets').validators
|
||||||
)
|
)
|
||||||
|
@ -540,12 +545,14 @@ export class DescriptionTemplateFieldSetEditorModel implements DescriptionTempla
|
||||||
hasCommentField: [{ value: this.hasCommentField, disabled: disabled }, context.getValidation('hasCommentField').validators],
|
hasCommentField: [{ value: this.hasCommentField, disabled: disabled }, context.getValidation('hasCommentField').validators],
|
||||||
hasMultiplicity: [{ value: this.hasMultiplicity, disabled: disabled }, context.getValidation('hasMultiplicity').validators],
|
hasMultiplicity: [{ value: this.hasMultiplicity, disabled: disabled }, context.getValidation('hasMultiplicity').validators],
|
||||||
multiplicity: this.multiplicity.buildForm({
|
multiplicity: this.multiplicity.buildForm({
|
||||||
rootPath: `${rootPath}multiplicity.`
|
rootPath: `${rootPath}multiplicity.`,
|
||||||
|
disabled
|
||||||
}),
|
}),
|
||||||
fields: this.formBuilder.array(
|
fields: this.formBuilder.array(
|
||||||
(this.fields ?? []).map(
|
(this.fields ?? []).map(
|
||||||
(item, index) => item.buildForm({
|
(item, index) => item.buildForm({
|
||||||
rootPath: `${rootPath}fields[${index}].`
|
rootPath: `${rootPath}fields[${index}].`,
|
||||||
|
disabled
|
||||||
})
|
})
|
||||||
), context.getValidation('fields').validators
|
), context.getValidation('fields').validators
|
||||||
)
|
)
|
||||||
|
@ -745,15 +752,18 @@ export class DescriptionTemplateFieldEditorModel implements DescriptionTemplateF
|
||||||
validations: [{ value: this.validations, disabled: disabled }, context.getValidation('validations').validators],
|
validations: [{ value: this.validations, disabled: disabled }, context.getValidation('validations').validators],
|
||||||
includeInExport: [{ value: this.includeInExport, disabled: disabled }, context.getValidation('includeInExport').validators],
|
includeInExport: [{ value: this.includeInExport, disabled: disabled }, context.getValidation('includeInExport').validators],
|
||||||
data: this.data.buildForm({
|
data: this.data.buildForm({
|
||||||
rootPath: `${rootPath}data.`
|
rootPath: `${rootPath}data.`,
|
||||||
|
disabled
|
||||||
}),
|
}),
|
||||||
defaultValue: this.defaultValue.buildForm({
|
defaultValue: this.defaultValue.buildForm({
|
||||||
rootPath: `${rootPath}defaultValue.`
|
rootPath: `${rootPath}defaultValue.`,
|
||||||
|
disabled
|
||||||
}),
|
}),
|
||||||
visibilityRules: this.formBuilder.array(
|
visibilityRules: this.formBuilder.array(
|
||||||
(this.visibilityRules ?? []).map(
|
(this.visibilityRules ?? []).map(
|
||||||
(item, index) => item.buildForm({
|
(item, index) => item.buildForm({
|
||||||
rootPath: `${rootPath}visibilityRules[${index}].`
|
rootPath: `${rootPath}visibilityRules[${index}].`,
|
||||||
|
disabled
|
||||||
})
|
})
|
||||||
), context.getValidation('visibilityRules').validators
|
), context.getValidation('visibilityRules').validators
|
||||||
)
|
)
|
||||||
|
@ -1350,7 +1360,8 @@ export class DescriptionTemplateRadioBoxDataEditorModel extends DescriptionTempl
|
||||||
formGroup.setControl('options', this.formBuilder.array(
|
formGroup.setControl('options', this.formBuilder.array(
|
||||||
(this.options ?? []).map(
|
(this.options ?? []).map(
|
||||||
(item, index) => item.buildForm({
|
(item, index) => item.buildForm({
|
||||||
rootPath: `${rootPath}options[${index}].`
|
rootPath: `${rootPath}options[${index}].`,
|
||||||
|
disabled
|
||||||
})
|
})
|
||||||
), context.getValidation('options').validators
|
), context.getValidation('options').validators
|
||||||
));
|
));
|
||||||
|
@ -1495,7 +1506,8 @@ export class DescriptionTemplateSelectDataEditorModel extends DescriptionTemplat
|
||||||
formGroup.setControl('options', this.formBuilder.array(
|
formGroup.setControl('options', this.formBuilder.array(
|
||||||
(this.options ?? []).map(
|
(this.options ?? []).map(
|
||||||
(item, index) => item.buildForm({
|
(item, index) => item.buildForm({
|
||||||
rootPath: `${rootPath}options[${index}].`
|
rootPath: `${rootPath}options[${index}].`,
|
||||||
|
disabled
|
||||||
})
|
})
|
||||||
), context.getValidation('options').validators
|
), context.getValidation('options').validators
|
||||||
));
|
));
|
||||||
|
@ -1654,7 +1666,8 @@ export class DescriptionTemplateUploadDataEditorModel extends DescriptionTemplat
|
||||||
formGroup.setControl('types', this.formBuilder.array(
|
formGroup.setControl('types', this.formBuilder.array(
|
||||||
(this.types ?? []).map(
|
(this.types ?? []).map(
|
||||||
(item, index) => item.buildForm({
|
(item, index) => item.buildForm({
|
||||||
rootPath: `${rootPath}types[${index}].`
|
rootPath: `${rootPath}types[${index}].`,
|
||||||
|
disabled
|
||||||
})
|
})
|
||||||
), context.getValidation('types').validators
|
), context.getValidation('types').validators
|
||||||
));
|
));
|
||||||
|
|
Loading…
Reference in New Issue