mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
ensure submissionsection state also contains all metadata after a save
This commit is contained in:
@@ -144,7 +144,7 @@ export class SubmissionResponseParsingService extends BaseResponseParsingService
|
|||||||
if (item instanceof WorkspaceItem
|
if (item instanceof WorkspaceItem
|
||||||
|| item instanceof WorkflowItem) {
|
|| item instanceof WorkflowItem) {
|
||||||
if (item.sections) {
|
if (item.sections) {
|
||||||
const sectionConfigs = (item.submissionDefinition as SubmissionDefinitionsModel).sections.page;
|
const sectionConfigs = item.sections.page ? (item.submissionDefinition as SubmissionDefinitionsModel).sections.page : [];
|
||||||
const precessedSection = Object.create({});
|
const precessedSection = Object.create({});
|
||||||
// Iterate over all workspaceitem's sections
|
// Iterate over all workspaceitem's sections
|
||||||
Object.keys(item.sections)
|
Object.keys(item.sections)
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
[ngClass]="[getClass('element', 'label'), getClass('grid', 'label')]"></label>
|
[ngClass]="[getClass('element', 'label'), getClass('grid', 'label')]"></label>
|
||||||
<ng-container *ngTemplateOutlet="startTemplate?.templateRef; context: model"></ng-container>
|
<ng-container *ngTemplateOutlet="startTemplate?.templateRef; context: model"></ng-container>
|
||||||
<!-- Should be *ngIf instead of class d-none, but that breaks the #componentViewContainer reference-->
|
<!-- Should be *ngIf instead of class d-none, but that breaks the #componentViewContainer reference-->
|
||||||
<div [ngClass]="{'form-row': model.hasLanguages || isRelationship, 'd-none': value?.isVirtual}">
|
<div [ngClass]="{'form-row': model.hasLanguages || isRelationship, 'd-none': model.hasSelectableMetadata && value?.isVirtual}">
|
||||||
<div [ngClass]="getClass('grid', 'control')">
|
<div [ngClass]="getClass('grid', 'control')">
|
||||||
<ng-container #componentViewContainer></ng-container>
|
<ng-container #componentViewContainer></ng-container>
|
||||||
<small *ngIf="hasHint && context?.index === 0 && (!showErrorMessages || errorMessages.length === 0)"
|
<small *ngIf="hasHint && context?.index === 0 && (!showErrorMessages || errorMessages.length === 0)"
|
||||||
|
@@ -244,34 +244,22 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo
|
|||||||
*/
|
*/
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.isRelationship = hasValue(this.model.relationship);
|
this.isRelationship = hasValue(this.model.relationship);
|
||||||
if (this.isRelationship) {
|
const isWrapperAroundRelationshipList = hasValue(this.model.relationshipConfig);
|
||||||
this.listId = 'list-' + this.model.relationship.relationshipType;
|
|
||||||
this.setItem();
|
if(this.isRelationship) {
|
||||||
this.value = Object.assign(new MetadataValue(), this.model.value);
|
console.log('isRelationship', this.model, this.model.value);
|
||||||
if (hasValue(this.value) && this.value.isVirtual) {
|
|
||||||
const relationship$ = this.relationshipService.findById(this.value.virtualValue, followLink('leftItem'), followLink('rightItem'), followLink('relationshipType'))
|
|
||||||
.pipe(
|
|
||||||
getAllSucceededRemoteData(),
|
|
||||||
getRemoteDataPayload());
|
|
||||||
this.relationshipValue$ = observableCombineLatest([this.item$.pipe(take(1)), relationship$]).pipe(
|
|
||||||
switchMap(([item, relationship]: [Item, Relationship]) =>
|
|
||||||
relationship.leftItem.pipe(
|
|
||||||
getAllSucceededRemoteData(),
|
|
||||||
getRemoteDataPayload(),
|
|
||||||
map((leftItem: Item) => {
|
|
||||||
return new ReorderableRelationship(relationship, leftItem.uuid !== item.uuid, this.relationshipService, this.store, this.model.submissionId)
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
),
|
|
||||||
startWith(undefined)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
if (isWrapperAroundRelationshipList) {
|
||||||
|
console.log('isWrapperAroundRelationshipList', this.model, this.model.value)
|
||||||
}
|
}
|
||||||
if (this.model.relationshipConfig || (this.isRelationship && !this.model.repeatable)) {
|
|
||||||
|
if (this.isRelationship || isWrapperAroundRelationshipList) {
|
||||||
const config = this.model.relationshipConfig || this.model.relationship;
|
const config = this.model.relationshipConfig || this.model.relationship;
|
||||||
const relationshipOptions = Object.assign(new RelationshipOptions(), config);
|
const relationshipOptions = Object.assign(new RelationshipOptions(), config);
|
||||||
this.listId = 'list-' + relationshipOptions.relationshipType;
|
this.listId = 'list-' + relationshipOptions.relationshipType;
|
||||||
this.setItem();
|
this.setItem();
|
||||||
|
|
||||||
|
if (isWrapperAroundRelationshipList || !this.model.repeatable) {
|
||||||
const subscription = this.selectableListService.getSelectableList(this.listId).pipe(
|
const subscription = this.selectableListService.getSelectableList(this.listId).pipe(
|
||||||
find((list: SelectableListState) => hasNoValue(list)),
|
find((list: SelectableListState) => hasNoValue(list)),
|
||||||
switchMap(() => this.item$.pipe(take(1))),
|
switchMap(() => this.item$.pipe(take(1))),
|
||||||
@@ -307,6 +295,28 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo
|
|||||||
).subscribe((relatedItems: Array<SearchResult<Item>>) => this.selectableListService.select(this.listId, relatedItems));
|
).subscribe((relatedItems: Array<SearchResult<Item>>) => this.selectableListService.select(this.listId, relatedItems));
|
||||||
this.subs.push(subscription);
|
this.subs.push(subscription);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.value = Object.assign(new MetadataValue(), this.model.value);
|
||||||
|
if (hasValue(this.value) && this.value.isVirtual) {
|
||||||
|
const relationship$ = this.relationshipService.findById(this.value.virtualValue, followLink('leftItem'), followLink('rightItem'), followLink('relationshipType'))
|
||||||
|
.pipe(
|
||||||
|
getAllSucceededRemoteData(),
|
||||||
|
getRemoteDataPayload());
|
||||||
|
this.relationshipValue$ = observableCombineLatest([this.item$.pipe(take(1)), relationship$]).pipe(
|
||||||
|
tap((v) => console.log('tapvamu', v)),
|
||||||
|
switchMap(([item, relationship]: [Item, Relationship]) =>
|
||||||
|
relationship.leftItem.pipe(
|
||||||
|
getAllSucceededRemoteData(),
|
||||||
|
getRemoteDataPayload(),
|
||||||
|
map((leftItem: Item) => {
|
||||||
|
return new ReorderableRelationship(relationship, leftItem.uuid !== item.uuid, this.relationshipService, this.store, this.model.submissionId)
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
),
|
||||||
|
startWith(undefined)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges) {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
<div class="d-flex">
|
<div class="d-flex mt-2">
|
||||||
<span class="mr-auto text-contents">
|
<span class="mr-auto text-contents">
|
||||||
<ng-container *ngIf="!relatedItem">
|
<ng-container *ngIf="!relatedItem">
|
||||||
<ds-loading [showMessage]="false"></ds-loading>
|
<ds-loading [showMessage]="false"></ds-loading>
|
||||||
|
@@ -134,6 +134,7 @@ export class ExistingRelationListElementComponent implements OnInit, OnChanges,
|
|||||||
*/
|
*/
|
||||||
ngOnChanges() {
|
ngOnChanges() {
|
||||||
if (hasValue(this.reoRel)) {
|
if (hasValue(this.reoRel)) {
|
||||||
|
console.log('onChanges', this.reoRel.useLeftItem ? this.reoRel.relationship._links.leftItem.href : this.reoRel.relationship._links.rightItem.href);
|
||||||
const item$ = this.reoRel.useLeftItem ?
|
const item$ = this.reoRel.useLeftItem ?
|
||||||
this.reoRel.relationship.leftItem : this.reoRel.relationship.rightItem;
|
this.reoRel.relationship.leftItem : this.reoRel.relationship.rightItem;
|
||||||
this.subs.push(item$.pipe(
|
this.subs.push(item$.pipe(
|
||||||
@@ -144,6 +145,7 @@ export class ExistingRelationListElementComponent implements OnInit, OnChanges,
|
|||||||
this.relatedItem = item;
|
this.relatedItem = item;
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -99,6 +99,7 @@ export abstract class FieldParser {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
const model = this.modelFactory(this.getInitFieldValue());
|
const model = this.modelFactory(this.getInitFieldValue());
|
||||||
|
model.submissionId = this.submissionId;
|
||||||
if (model.hasLanguages || isNotEmpty(model.relationship)) {
|
if (model.hasLanguages || isNotEmpty(model.relationship)) {
|
||||||
setLayout(model, 'grid', 'control', 'col');
|
setLayout(model, 'grid', 'control', 'col');
|
||||||
}
|
}
|
||||||
|
@@ -328,10 +328,12 @@ export class SubmissionObjectEffects {
|
|||||||
|
|
||||||
const sections: WorkspaceitemSectionsObject = (item.sections && isNotEmpty(item.sections)) ? item.sections : {};
|
const sections: WorkspaceitemSectionsObject = (item.sections && isNotEmpty(item.sections)) ? item.sections : {};
|
||||||
const sectionsKeys: string[] = union(Object.keys(sections), Object.keys(errorsList));
|
const sectionsKeys: string[] = union(Object.keys(sections), Object.keys(errorsList));
|
||||||
|
const metadata = (item.item as Item).metadata;
|
||||||
|
const metadataKeys = Object.keys(metadata);
|
||||||
|
|
||||||
for (const sectionId of sectionsKeys) {
|
for (const sectionId of sectionsKeys) {
|
||||||
const sectionErrors = errorsList[sectionId] || [];
|
const sectionErrors = errorsList[sectionId] || [];
|
||||||
const sectionData = sections[sectionId] || {};
|
let sectionData = sections[sectionId] || {};
|
||||||
|
|
||||||
// When Upload section is disabled, add to submission only if there are files
|
// When Upload section is disabled, add to submission only if there are files
|
||||||
if (currentState.sections[sectionId].sectionType === SectionsType.Upload
|
if (currentState.sections[sectionId].sectionType === SectionsType.Upload
|
||||||
@@ -340,10 +342,17 @@ export class SubmissionObjectEffects {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const sectionKeys = Object.keys(sectionData);
|
||||||
|
if (sectionKeys.every((key: string) => metadataKeys.includes(key))) {
|
||||||
|
sectionData = metadata as any;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('sectionData', sectionData);
|
||||||
|
|
||||||
|
|
||||||
if (notify && !currentState.sections[sectionId].enabled) {
|
if (notify && !currentState.sections[sectionId].enabled) {
|
||||||
this.submissionService.notifyNewSection(submissionId, sectionId, currentState.sections[sectionId].sectionType);
|
this.submissionService.notifyNewSection(submissionId, sectionId, currentState.sections[sectionId].sectionType);
|
||||||
}
|
}
|
||||||
console.log(sectionId, sectionData);
|
|
||||||
mappedActions.push(new UpdateSectionDataAction(submissionId, sectionId, sectionData, sectionErrors));
|
mappedActions.push(new UpdateSectionDataAction(submissionId, sectionId, sectionData, sectionErrors));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
import { combineLatest, Observable } from 'rxjs';
|
import { combineLatest, Observable } from 'rxjs';
|
||||||
import { distinctUntilChanged, filter, map, take } from 'rxjs/operators';
|
import { distinctUntilChanged, filter, map, take, tap } from 'rxjs/operators';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { ScrollToConfigOptions, ScrollToService } from '@nicky-lenaers/ngx-scroll-to';
|
import { ScrollToConfigOptions, ScrollToService } from '@nicky-lenaers/ngx-scroll-to';
|
||||||
@@ -175,7 +175,9 @@ export class SectionsService {
|
|||||||
return this.store.select(submissionSectionFromIdSelector(submissionId, sectionId)).pipe(
|
return this.store.select(submissionSectionFromIdSelector(submissionId, sectionId)).pipe(
|
||||||
filter((sectionObj: SubmissionSectionObject) => hasValue(sectionObj)),
|
filter((sectionObj: SubmissionSectionObject) => hasValue(sectionObj)),
|
||||||
map((sectionObj: SubmissionSectionObject) => sectionObj),
|
map((sectionObj: SubmissionSectionObject) => sectionObj),
|
||||||
distinctUntilChanged());
|
distinctUntilChanged(),
|
||||||
|
tap((v) => console.log('sectionStateChange', submissionId, sectionId, v)),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user