Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor / Add custom element in distribution and associated record directive #7997

Merged
merged 2 commits into from
May 16, 2024

Conversation

fxprunayre
Copy link
Member

Add the possibility to add custom elements in the panel of
data-gn-distribution-resources-panel or
data-gn-associated-resources-panel.

Common use case is to add explanatory text or add action for shortcuts

image

eg.

<directive data-gn-distribution-resources-panel="gnCurrentEdit.metadata"
                   data-mode="viewConfig.distributionConfig.layout || ''"
                   data-editor-config="default" ...
        >
          <section>
            <text>
              <div class="alert alert-info">
                This represents a general availability of a dataset. It implies no information about the actual access method of the data, i.e., whether by direct download, API, or through a Web page.
              </div>
            </text>
            <action type="add"
                    name=" "
                    btnLabel="mw-addAtomFeed"
                    or="onLine"
                    in="/mdb:MD_Metadata/mdb:distributionInfo/*/mrd:transferOptions/*"
                    if="count(mdb:MD_Metadata/mdb:distributionInfo/*/mrd:transferOptions/*/mrd:onLine[*/cit:protocol/*/text() = 'atom:feed']) = 0">
              <template>
                <snippet>
                  <mrd:onLine>
                    <cit:CI_OnlineResource>
                      <cit:linkage>
                        <gco:CharacterString>https://geoservices.wallonie.be/geotraitement/spwdatadownload/get/${uuid}/atom_service.xml</gco:CharacterString>
                      </cit:linkage>
                      <cit:protocol>
                        <gco:CharacterString>atom:feed</gco:CharacterString>
                      </cit:protocol>
                      <cit:name>
                        <gco:CharacterString>Service de téléchargement ATOM Feed</gco:CharacterString>
                      </cit:name>
                      <cit:description>
                        <gco:CharacterString>Ce service de téléchargement ATOM Feed permet de télécharger la série de couches de données</gco:CharacterString>
                      </cit:description>
                      <cit:function>
                        <cit:CI_OnLineFunctionCode codeList="http://standards.iso.org/iso/19115/resources/Codelists/cat/codelists.xml#CI_OnLineFunctionCode" codeListValue="download"/>
                      </cit:function>
                    </cit:CI_OnlineResource>
                  </mrd:onLine>
                </snippet>
              </template>
            </action>

Also add support for ${uuid} placeholder in snippet to dynamically
create snippet for current record.

Checklist

  • I have read the contribution guidelines
  • Pull request provided for main branch, backports managed with label
  • Good housekeeping of code, cleaning up comments, tests, and documentation
  • Clean commit history broken into understandable chucks, avoiding big commits with hundreds of files, cautious of reformatting and whitespace changes
  • Clean commit messages, longer verbose messages are encouraged
  • API Changes are identified in commit messages
  • Testing provided for features or enhancements using automatic tests
  • User documentation provided for new features or enhancements in manual
  • Build documentation provided for development instructions in README.md files
  • Library management using pom.xml dependency management. Update build documentation with intended library use and library tutorials or documentation

Funded by Service Public de Wallonie (SPW)

…ective

Add the possibility to add custom elements in the panel of
`data-gn-distribution-resources-panel` or
`data-gn-associated-resources-panel`.

Common use case is to add explanatory text or add action for shortcuts

eg.

```xml
<directive data-gn-distribution-resources-panel="gnCurrentEdit.metadata"
                   data-mode="viewConfig.distributionConfig.layout || ''"
                   data-editor-config="default" ...
        >
          <section>
            <text>
              <div class="alert alert-info">A specific representation of a dataset. A dataset might be available in multiple serializations that may differ in various ways, including natural language, media-type or format, schematic organization, temporal and spatial resolution, level of detail or profiles (which might specify any or all of the above).</div>
            </text>
            <action type="add"
                    name=" "
                    btnLabel="mw-addAtomFeed"
                    or="onLine"
                    in="/mdb:MD_Metadata/mdb:distributionInfo/*/mrd:transferOptions/*"
                    if="count(mdb:MD_Metadata/mdb:distributionInfo/*/mrd:transferOptions/*/mrd:onLine[*/cit:protocol/*/text() = 'atom:feed']) = 0">
              <template>
                <snippet>
                  <mrd:onLine>
                    <cit:CI_OnlineResource>
                      <cit:linkage>
                        <gco:CharacterString>https://geoservices.wallonie.be/geotraitement/spwdatadownload/get/${uuid}/atom_service.xml</gco:CharacterString>
                      </cit:linkage>
                      <cit:protocol>
                        <gco:CharacterString>atom:feed</gco:CharacterString>
                      </cit:protocol>
                      <cit:name>
                        <gco:CharacterString>Service de téléchargement ATOM Feed</gco:CharacterString>
                      </cit:name>
                      <cit:description>
                        <gco:CharacterString>Ce service de téléchargement ATOM Feed permet de télécharger la série de couches de données</gco:CharacterString>
                      </cit:description>
                      <cit:function>
                        <cit:CI_OnLineFunctionCode codeList="http://standards.iso.org/iso/19115/resources/Codelists/cat/codelists.xml#CI_OnLineFunctionCode" codeListValue="download"/>
                      </cit:function>
                    </cit:CI_OnlineResource>
                  </mrd:onLine>
                </snippet>
              </template>
            </action>
```

Also add support for `${uuid}` placeholder in snippet to dynamically
create snippet for current record.
@fxprunayre fxprunayre added this to the 4.4.5 milestone Apr 29, 2024
Copy link

sonarcloud bot commented Apr 29, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link
Member

@josegar74 josegar74 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fxprunayre code changes look fine, but using your example I don't get the button to add the ATOM feed.

I guess it is due to not being defined mrd:transferOptions so probably that causes these attributes to not being evaluated? Can you confirm this?

in="/mdb:MD_Metadata/mdb:distributionInfo/*/mrd:transferOptions/*"
if="count(mdb:MD_Metadata/mdb:distributionInfo/*/mrd:transferOptions/*/mrd:onLine[*/cit:protocol/*/text() = 'atom:feed']) = 0">

@fxprunayre
Copy link
Member Author

I guess it is due to not being defined mrd:transferOptions so probably that causes these attributes to not being evaluated? Can you confirm this?

Indeed if there is no transferOptions in the current record, then

or="onLine"
in="/mdb:MD_Metadata/mdb:distributionInfo/*/mrd:transferOptions/*"

evaluates to false. Same would happen in the editor. As it is now, we can't really avoid this.

@fxprunayre fxprunayre merged commit a402882 into main May 16, 2024
8 of 9 checks passed
@fxprunayre fxprunayre deleted the 44-customelementinsidepaneldirective branch May 16, 2024 06:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants