Metadata editor / Online resources / Keep the panel configuration when editing a resource - #9462
Open
juanluisrp wants to merge 2 commits into
Open
Metadata editor / Online resources / Keep the panel configuration when editing a resource#9462juanluisrp wants to merge 2 commits into
juanluisrp wants to merge 2 commits into
Conversation
…when the dialog opens The default values declared in the associated resources panel configuration (fields.*.value and copyLabel) were only applied from the params.linkType watcher. That watcher is guarded by newValue !== oldValue, so it does nothing when the selected link type has not changed since the last time the dialog was used. openDialog resets protocol, name and description on every new resource, which means the second time the dialog is opened the configured defaults are not restored. For the iso19139 configuration the protocol field is both required and configured with a default, so adding a link, closing the dialog and adding another leaves the required protocol empty. Move the assignment of the configured defaults into a function and call it when the dialog opens as well, so it no longer depends on the link type reference changing.
…n editing a resource getTypeConfig matches the resource being edited against the configured types by comparing the type's fields.protocol.value with the resource protocol. In the iso19139 configuration that value is a default for new links rather than a discriminator, so editing a resource with any other protocol matches no type and falls back to DEFAULT_CONFIG. That fallback loses data. The process parameters are built from the fields the active configuration declares, and onlinesrc-add rebuilds the online resource from the parameters it receives, so any field the active configuration does not declare is dropped from the record. DEFAULT_CONFIG does not declare applicationProfile, so editing a resource that has one and changing only its description removes the applicationProfile element. Flag the generic addOnlinesrc type as the default type, which is the mechanism getTypeConfig already implements for this case, so that editing a resource that matches no specific type uses the schema configuration. Declare mimeType and mimeTypeStrategy in that configuration as well. DEFAULT_CONFIG declares both, so without them the change would only move the data loss to the MIME type: editing a resource stored as gmx:MimeFileType would rewrite the protocol without it. Declaring them keeps the fields the edit form already had, and adds the MIME type input to the add form, where it was missing while being available when editing the same resource. mimeTypeStrategy is declared non-multilingual because it is an option passed to the process rather than a user input. Without that, it is added to the multilingual field list and blanked when the protocol changes, and the process then stores the protocol without the MIME type.
josegar74
reviewed
Aug 7, 2026
josegar74
left a comment
Member
There was a problem hiding this comment.
Tested with ISO19139 and looks working fine. Please check the comments added.
| }, | ||
| "mimeType": { | ||
| "isMultilingual": false, | ||
| "tooltip": "gmd:MimeFileType" |
Member
There was a problem hiding this comment.
Suggested change
| "tooltip": "gmd:MimeFileType" | |
| "tooltip": "gmx:MimeFileType" |
Requires also to update the labels.xml in ISO19139 to add the following, as not defined:
<element name="gmx:MimeFileType">
<label>Format</label>
<description>File type format</description>
</element>| "required": true, | ||
| "tooltip": "gmd:URL" | ||
| }, | ||
| "mimeType": { |
Member
There was a problem hiding this comment.
With this change, it shows always the format field in the dialog. Previously it was displayed only if the XML contained gmx:MimeFileType.
It looks fine as if the value is empty, it is encoded as gco:CharacterString, but it can be maybe confusing for users, what do you think @fxprunayre?
| @@ -2,6 +2,7 @@ | |||
| "config": { | |||
Member
There was a problem hiding this comment.
Maybe similar changes should be applied to ISO19115-3.2018?
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.
Two problems in the online resources dialog, both found while testing #9461 on a local catalogue. The second one loses data.
Configured field defaults are lost when the dialog is reopened
The defaults declared in the associated resources panel configuration (
fields.*.value,copyLabel) were only applied from theparams.linkTypewatcher, which is guarded bynewValue !== oldValue.openDialogresets protocol, name and description for every new resource, but the watcher does not run again when the selected link type has not changed, so the defaults are never restored.Reproducible on current main with an iso19139 record, where
protocolis bothrequiredand configured with a default:WWW:LINK-1.0-http--linkThe defaults are now applied when the dialog opens as well, so they no longer depend on the link type reference changing.
Editing a resource discards the schema configuration, dropping fields from the record
getTypeConfigmatches the resource being edited against the configured types by comparing each type'sfields.protocol.valuewith the resource protocol. In the iso19139 configuration that value is a default for new links, not a discriminator, so editing a resource with any other protocol matches no type and falls back to the hardcodedDEFAULT_CONFIG.That is not cosmetic.
processParamsis built from the fields the active configuration declares, andonlinesrc-addrebuilds the online resource from the parameters it receives. Any field the active configuration does not declare is therefore dropped from the record.DEFAULT_CONFIGdoes not declareapplicationProfile. On current main, editing a resource that has one and changing only its description:applicationProfileis absent from the request even though the dialog loaded it correctly asinspire-download, and<gmd:applicationProfile>is gone from the stored record afterwards.This flags the generic
addOnlinesrctype as the default type, which is the mechanismgetTypeConfigalready implements for exactly this case (see the comment above the fallback), so editing a resource that matches no specific type uses the schema configuration.mimeTypeandmimeTypeStrategyare declared in that configuration too.DEFAULT_CONFIGdeclares both, so without them the change would just move the data loss to the MIME type: editing a resource stored asgmx:MimeFileTypewould rewrite the protocol without it. Declaring them keeps every field the edit form already had.mimeTypeStrategyis declared non-multilingual because it is an option passed to the process, not a user input. Without that it is added to the multilingual field list and blanked when the protocol changes, and the process then stores the protocol without the MIME type.Result
Editing a resource with both an
applicationProfileand a MIME type, changing only its description:applicationProfileVisible change
The MIME type input now appears in the Add dialog for iso19139. It was already present when editing a resource, via
DEFAULT_CONFIG, so this removes an inconsistency where a MIME type could be set on an existing resource but not on a new one.Testing
By hand on an iso19139 record, checking the submitted process parameters and the stored XML in each case:
requiredflags andapplicationProfilefieldapplicationProfilestoresgmx:MimeFileTypeandgmd:applicationProfilemvn -pl web-ui prettier:checkpassesNote
#9461 also touches
OnlineSrcDirective.jsa few lines from the first change here, so one of the two will likely need a trivial rebase depending on merge order. The changes are independent: that one concerns which value ofmimeTypeStrategyis submitted, this one concerns which configuration the dialog uses.