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 / Configuration / Add condition on element and session for all. #6355

Merged
merged 1 commit into from Jun 14, 2022

Conversation

fxprunayre
Copy link
Member

Editor configuration allows to conditionnaly display elements or not. Condition based on session info (eg. user profile) was only allowed for view and tab elements. Apply condition on the current record and on session for all elements (field, section, text, directive, action).

Example:

  • Display a view for admin only
 <view name="custom-view"
          displayIfServiceInfo="count(session[profile = 'Administrator']) = 1"
  • Display help text for non geographic dataset
<text if="count(gmd:MD_Metadata/gmd:hierarchyLevel[*/@codeListValue =
          'nonGeographicDataset']) = 1"
                ref="eea-conformity-help"/>
  • Display an action if the element does not exist and user is admin
<action   type="add"
          btnLabel="eea-add-identifier"
          if="count(gmd:MD_Metadata/gmd:identificationInfo/*/gmd:citation/*/gmd:identifier/*/gmd:code) = 0"
          displayIfServiceInfo="count(session[profile = 'Administrator']) = 1"
          or="identifier"
          in="/gmd:MD_Metadata/gmd:identificationInfo/*/gmd:citation/*">
    <template>
      <snippet>
        <gmd:identifier>
          <gmd:MD_Identifier>
            <gmd:code>
              <gco:CharacterString>[Provider_DataType_EpsgCode_ScaleResolution_ScaleResUnit_DatasetShortName_PublicOrInternal_TimeCoverage_VersionNumber_RevisionNumber]</gco:CharacterString>
            </gmd:code>
          </gmd:MD_Identifier>
        </gmd:identifier>
      </snippet>
    </template>
  </action>
  • Customize side panel based on resource type
<sidePanel>
<!-- No overview for non geographic dataset -->
<directive data-gn-overview-manager=""
           displayIfRecord="not(contains(gmd:MD_Metadata/
                            gmd:hierarchyLevel/*/@codeListValue,
                            'nonGeographicDataset'))"/>
<!-- All type of links for spatial dataset -->
<directive data-gn-onlinesrc-list=""
           data-types="onlinesrc|parent|dataset|service|source|sibling|associated|fcats"
           displayIfRecord="not(contains(gmd:MD_Metadata/
                            gmd:hierarchyLevel/*/@codeListValue,
                            'nonGeographicDataset'))"/>
<!-- only online resource, parent and source for non geographic dataset -->
<directive data-gn-onlinesrc-list=""
           data-types="onlinesrc|parent|source"
           displayIfRecord="contains(gmd:MD_Metadata/
                            gmd:hierarchyLevel/*/@codeListValue,
                            'nonGeographicDataset')"/>

Editor configuration allows to conditionnaly display elements or not. Condition based on session info (eg. user profile) was only allowed for `view` and `tab` elements. Apply condition on the current record and on session for all elements (`field`, `section`, `text`, `directive`, `action`).

Example:
* Display a view for admin only
```xml
 <view name="custom-view"
          displayIfServiceInfo="count(session[profile = 'Administrator']) = 1"
```

* Display help text for non geographic dataset
```xml
<text if="count(gmd:MD_Metadata/gmd:hierarchyLevel[*/@codeListValue =
          'nonGeographicDataset']) = 1"
                ref="eea-conformity-help"/>
```

* Display an action if the element does not exist and user is admin
```xml
<action   type="add"
          btnLabel="eea-add-identifier"
          if="count(gmd:MD_Metadata/gmd:identificationInfo/*/gmd:citation/*/gmd:identifier/*/gmd:code) = 0"
          displayIfServiceInfo="count(session[profile = 'Administrator']) = 1"
          or="identifier"
          in="/gmd:MD_Metadata/gmd:identificationInfo/*/gmd:citation/*">
    <template>
      <snippet>
        <gmd:identifier>
          <gmd:MD_Identifier>
            <gmd:code>
              <gco:CharacterString>[Provider_DataType_EpsgCode_ScaleResolution_ScaleResUnit_DatasetShortName_PublicOrInternal_TimeCoverage_VersionNumber_RevisionNumber]</gco:CharacterString>
            </gmd:code>
          </gmd:MD_Identifier>
        </gmd:identifier>
      </snippet>
    </template>
  </action>
```

* Customize side panel based on resource type
```xml
<sidePanel>
<directive data-gn-overview-manager=""
           displayIfRecord="not(contains(gmd:MD_Metadata/
                            gmd:hierarchyLevel/*/@codeListValue,
                            'nonGeographicDataset'))"/>
<directive data-gn-onlinesrc-list=""
           data-types="onlinesrc|parent|dataset|service|source|sibling|associated|fcats"
           displayIfRecord="not(contains(gmd:MD_Metadata/
                            gmd:hierarchyLevel/*/@codeListValue,
                            'nonGeographicDataset'))"/>
<directive data-gn-onlinesrc-list=""
           data-types="onlinesrc|parent|source"
           displayIfRecord="contains(gmd:MD_Metadata/
                            gmd:hierarchyLevel/*/@codeListValue,
                            'nonGeographicDataset')"/>

```
@fxprunayre fxprunayre added this to the 4.2.1 milestone Jun 8, 2022
@fxprunayre fxprunayre requested a review from josegar74 June 8, 2022 06:55
@fxprunayre
Copy link
Member Author

@fxprunayre fxprunayre merged commit 5c12352 into main Jun 14, 2022
@fxprunayre fxprunayre deleted the 421-editorconfigconditional branch June 14, 2022 07:27
fxprunayre added a commit that referenced this pull request Jun 14, 2022
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