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

This commit is contained in:
Efstratios Giannopoulos 2024-04-26 18:10:31 +03:00
commit e073fc718c
8 changed files with 54 additions and 24 deletions

View File

@ -94,10 +94,7 @@ public class CloneDmpPersist {
.failOn(CloneDmpPersist._label).failWith(messageSource.getMessage("Validation_Required", new Object[]{CloneDmpPersist._label}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isEmpty(item.getDescription()))
.failOn(CloneDmpPersist._description).failWith(messageSource.getMessage("Validation_Required", new Object[]{CloneDmpPersist._description}, LocaleContextHolder.getLocale())),
this.spec()
.must(() -> !this.isNull(item.getDescriptions()))
.failOn(CloneDmpPersist._descriptions).failWith(messageSource.getMessage("Validation_Required", new Object[]{CloneDmpPersist._descriptions}, LocaleContextHolder.getLocale()))
.failOn(CloneDmpPersist._description).failWith(messageSource.getMessage("Validation_Required", new Object[]{CloneDmpPersist._description}, LocaleContextHolder.getLocale()))
);
}
}

View File

@ -580,6 +580,11 @@ public class DmpServiceImpl implements DmpService {
this.annotationEntityTouchedIntegrationEventHandler.handleDmp(newDmp.getId());
DmpEntity resultingDmpEntity = this.queryFactory.query(DmpQuery.class).ids(newDmp.getId()).firstAs(fields);
if (!this.conventionService.isListNullOrEmpty(model.getDescriptions())){
for (UUID description: model.getDescriptions()) {
descriptionService.clone(newDmp.getId(), description);
}
}
return this.builderFactory.builder(DmpBuilder.class).build(fields, resultingDmpEntity);
}

View File

@ -628,7 +628,6 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
refreshData(): void {
this.getItem(this.editorModel.id, (data: Description) => this.prepareForm(data));
this.tocValidationService.validateForm();
}
refreshOnNavigateToData(id?: Guid): void {
@ -649,7 +648,8 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
this.descriptionService.persist(formData)
.pipe(takeUntil(this._destroyed)).subscribe(
complete => {
onSuccess ? onSuccess(complete) : this.onCallbackSuccess(complete);
onSuccess ? onSuccess(complete) : this.onCallbackSuccess(complete, this.isNew);
this.tocValidationService.validateForm();
this.descriptionIsOnceSaved = true;
if (this.formGroup.get('status').value == DescriptionStatus.Finalized) this.isFinalized = true;
},
@ -1099,10 +1099,11 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
page.sections?.forEach((section: DescriptionTemplateSection) => {
let fieldsets = this.getNestedSectionFieldsets(section);
let sectionIds = this.getNestedSectionIds(section);
let fieldsBySection: DescriptionFieldIndicator[] = fieldsets?.flatMap((fieldset: DescriptionTemplateFieldSet) =>
fieldset.fields?.flatMap((field: DescriptionTemplateField) =>
new DescriptionFieldIndicator(page.id, sectionIds, fieldset.id, field.id, field.data.fieldType, field.data.multipleSelect)
fieldset.fields?.flatMap((field: DescriptionTemplateField) => {
let sectionIds = this.getNestedSectionIdsByField(section, fieldset.id);
return new DescriptionFieldIndicator(page.id, sectionIds, fieldset.id, field.id, field.data.fieldType, field.data.multipleSelect)
}
));
fieldsByPage.push(...fieldsBySection);
@ -1119,12 +1120,14 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
else return section.fieldSets;
}
getNestedSectionIds(section: DescriptionTemplateSection): string[] {
getNestedSectionIdsByField(section: DescriptionTemplateSection, fieldSetId: string): string[] {
if (section.sections) {
return [section.id, ...section.sections.flatMap((subsection: DescriptionTemplateSection) => this.getNestedSectionIds(subsection))];
return [section.id, ...section.sections.flatMap((subsection: DescriptionTemplateSection) => this.getNestedSectionIdsByField(subsection, fieldSetId))];
}
else return [section.id];
else if (section.fieldSets.find(fieldSet => fieldSet.id == fieldSetId)) return [section.id];
else return [];
}
// // this._listenersSubscription.add(dmpSubscription);

View File

@ -36,7 +36,7 @@ export class DescriptionEditorModel extends BaseEditorModel implements Descripti
this.descriptionTemplateId = item.descriptionTemplate?.id;
this.status = item.status ?? DescriptionStatus.Draft;
this.description = item.description;
this.tags = item.descriptionTags?.map(x => x.tag?.label);
this.tags = item.descriptionTags?.filter(x => x.isActive === IsActive.Active).map(x => x.tag?.label);
this.properties = new DescriptionPropertyDefinitionEditorModel(this.validationErrorModel).fromModel(item.properties, descriptionTemplate, item.descriptionReferences);
}
return this;

View File

@ -75,6 +75,7 @@ export class DescriptionEditorResolver extends BaseEditorResolver {
[nameof<Description>(x => x.descriptionTags), nameof<DescriptionTag>(x => x.id),].join('.'),
[nameof<Description>(x => x.descriptionTags), nameof<DescriptionTag>(x => x.tag), nameof<Tag>(x => x.label)].join('.'),
[nameof<Description>(x => x.descriptionTags), nameof<DescriptionTag>(x => x.tag), nameof<Tag>(x => x.isActive)].join('.'),
[nameof<Description>(x => x.descriptionReferences), nameof<DescriptionReference>(x => x.data), nameof<DescriptionReferenceData>(x => x.fieldId)].join('.'),
[nameof<Description>(x => x.descriptionReferences), nameof<DescriptionReference>(x => x.reference), nameof<Reference>(x => x.id)].join('.'),

View File

@ -1,16 +1,39 @@
.percentage {
color: #212121;
opacity: 0.7;
font-weight: 400;
font-size: 0.875rem;
}
// .percentage {
// color: #212121;
// opacity: 0.7;
// font-weight: 400;
// font-size: 0.875rem;
// }
// .progress-bar {
// border-radius: 20px;
// height: 11px;
// }
// ::ng-deep .mat-progress-bar .mat-progress-bar-fill::after {
// border-radius: 20px !important;
// }
// Bar container
.progress-bar {
--mdc-linear-progress-active-indicator-height: 11px !important;
border-radius: 20px;
height: 11px;
}
::ng-deep .mat-progress-bar .mat-progress-bar-fill::after {
//Progress bar
::ng-deep .mdc-linear-progress__bar-inner {
--mdc-linear-progress-active-indicator-color: var(--primary-color) !important;
border-radius: 20px !important;
}
// Buffer bar
::ng-deep .mdc-linear-progress__buffer {
--mdc-linear-progress-track-height: 11px !important;
--mdc-linear-progress-active-indicator-color: var(--secondary-color) !important;
}
::ng-deep .mdc-linear-progress__buffer-bar {
--mdc-linear-progress-track-color: var(--secondary-color) !important;
}

View File

@ -63,6 +63,7 @@ export class TagsComponent extends BaseComponent implements OnInit {
if (index >= 0) {
this.tags.splice(index, 1);
this.form.setValue(this.tags);
}
}

View File

@ -109,12 +109,12 @@ export abstract class BaseEditor<EditorModelType extends BaseEditorModel, Entity
onCallbackSuccess(data?: any): void {
onCallbackSuccess(data?: any, refresh: boolean = true): void {
console.log("Success:", data);
this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
this.refreshOnNavigateToData(data ? data.id : null);
if (refresh) this.refreshOnNavigateToData(data ? data.id : null);
}
onCallbackDeleteSuccess(data?: any): void {