Clarin9/Save submission immediately when a type/sponsor/author field changes - #1489
Merged
milanmajchrak merged 2 commits intoSep 3, 2026
Merged
Conversation
…changes In the DSpace 9 upgrade, the CLARIN section-form lost the logic that persisted the submission as soon as a type-bind controlling field (e.g. dc.type) or a sponsor/author autocomplete value was picked. In v7, selecting such a value in a dropdown fired an immediate section save (verified live on dev-5: choosing a resource type triggers a PATCH). In v9 nothing was saved until the whole section lost focus, so the choice could be lost. Restore the v7 behaviour in SubmissionSectionFormComponent.onChange: when the changed field is a type-bind controlling field or the sponsor/author field, dispatch a section save immediately. The set of type-bind controlling fields is owned by FormBuilderService in v9 (populated from `submit.type-bind.field`), so expose it via a new getTypeFieldValues() accessor rather than duplicating the map in the component. Form reconfiguration on type change is already handled reactively by v9's type-bind machinery, so only the save is restored here. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Kasinhou
force-pushed
the
clarin9/submission-save-on-type-change
branch
from
August 26, 2026 13:43
0837dba to
0447307
Compare
There was a problem hiding this comment.
Pull request overview
This PR restores DSpace 7 / CLARIN behavior in the Angular v9 submission UI by triggering an immediate section save when key “type-bind controlling” dropdowns and sponsor/author autocompletes change, preventing user selections from being lost before leaving the section.
Changes:
- Add
FormBuilderService.getTypeFieldValues()accessor to expose type-bind controlling field ids fromsubmit.type-bind.field. - Update
SubmissionSectionFormComponent.onChangeto immediatelydispatchSaveSectionwhen a type-bind controlling field or sponsor/author field changes. - Extend mocks and add unit tests verifying immediate save behavior for type-bind fields and sponsor fields.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/app/submission/sections/form/section-form.component.ts | Triggers immediate section save on type-bind controlling fields and sponsor/author changes. |
| src/app/submission/sections/form/section-form.component.spec.ts | Adds unit tests for the new immediate-save triggers. |
| src/app/shared/mocks/form-builder-service.mock.ts | Updates the FormBuilderService mock to support getTypeFieldValues(). |
| src/app/shared/form/builder/form-builder.service.ts | Adds getTypeFieldValues() accessor for type-bind controlling fields. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Convert metadata to underscore notation instead of replacing only the first underscore in the field id (addresses Copilot review). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Kasinhou
requested review from
milanmajchrak
and removed request for
milanmajchrak
September 2, 2026 14:50
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The regression (confirmed live on both dev machines)
In v7 (dev-5), selecting a value in a dropdown that drives type-bind (e.g. the resource type) — or picking a sponsor/author autocomplete value — saved the submission immediately. I verified it live: choosing a resource type fires a
PATCH .../workspaceitems/{id}right away, with no need to leave the section.In v9 (dev-6) this does not happen — the choice is only persisted once the whole section loses focus (i.e. when you click into another section). If the user picks a type and then leaves/loses the session, the choice is lost.
Root cause
The CLARIN logic in
SubmissionSectionFormComponent.onChangewas not propagated in the DSpace 9 upgrade. v7 (dtq-dev) had:v9's
onChangeonly kept the (disabled-by-default)autosave.metadatacheck — none of the type/sponsor/author handling.Fix
Restore the immediate save in
onChangefor type-bind controlling fields and the sponsor/author fields.form-builder.service.ts— newgetTypeFieldValues()accessor. In v9 the type-bind field map moved intoFormBuilderService(populated fromsubmit.type-bind.field), so the component reads the controlling field names from there instead of maintaining its own copy (as v7 did).section-form.component.ts— inonChange, when the changed field is a type-bind controlling field (e.g.dc.type,edm.type) orlocal.sponsor/dc.contributor.author, dispatchdispatchSaveSectionimmediately.form-builder-service.mock.ts,section-form.component.spec.ts— mock + tests.Scope note — save vs. reinitialize
v7's
dispatchFormSaveAndReinitializedid two things: save the section and reinitialize the form (a 20s DB-pollingreinitializeFormthat rebuilt the form viangOnInit). This PR restores the save — the observed regression. The form reconfiguration on type change is already handled reactively in v9 (FormBuilderService.typeBindModelUpdates/registerTypeBindModels), so the old polling reinit is not re-added. If, after testing on a dev deploy, the author/sponsor sub-fields don't refresh with server-computed values the way they did in v7, I'll port that refresh too as a follow-up.Testing
tsc -p tsconfig.app.json --noEmitandtsconfig.spec.jsonpass (the only spec error is pre-existing in an unrelated file,server-hard-redirect.service.spec.ts).dc.typechange and onlocal.sponsorchange; does not fire for a regular field.🤖 Generated with Claude Code