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 list mode #7998

Merged
merged 2 commits into from
Jun 3, 2024
Merged

Editor / Add list mode #7998

merged 2 commits into from
Jun 3, 2024

Conversation

fxprunayre
Copy link
Member

The list can be used to display a list of contact with only organisation name for example. This can facilitate building simple form hiding the details of ISO elements. In this case, use a contact directory to add new contact makes sense.

This mode can be also more efficient when record contains lots of contacts which in some case can create large HTML form which can take time to build, download and render in the browser (eg. when having more than 100 contacts in a record). If only label are used the form will be faster to render.

For large XML record, form may trigger error like Form with too many keys [1001 > 1000] when submitted. The list mode allows to deal with such situation.

eg.

image

<action type="add"
        forceLabel="true"
        addDirective="data-gn-directory-entry-selector"
        or="pointOfContact"
        in="/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification">
  <directiveAttributes
          data-template-add-action="false"
          data-search-action="true"
          data-popup-action="true"
          data-template-type="contact"
          data-variables="gmd:role/gmd:CI_RoleCode/@codeListValue~{role}"/>
</action>

<list name="Contact point"
      xpath="/gmd:MD_Metadata/gmd:identificationInfo/*/gmd:pointOfContact[*/gmd:role/*/@codeListValue = 'pointOfContact']"
      del="."
      sortBy="gmd:organisationName/gco:CharacterString">
  <item href="*[1]/@uuid">
    <label xpath="*/gmd:organisationName/gco:CharacterString/text()"/>
  </item>
</list>

<list name="Originator"
      xpath="/gmd:MD_Metadata/gmd:identificationInfo/*/gmd:pointOfContact[*/gmd:role/*/@codeListValue = 'originator']"
      sortBy="gmd:organisationName/gco:CharacterString">
  <item>
    <field xpath="*/gmd:organisationName"/>
  </item>
</list>

Funded by Ifremer

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

@fxprunayre fxprunayre added this to the 4.4.5 milestone Apr 30, 2024
The list can be used to display a list of contact with only organisation name for example.
This can facilitate building simple form hiding the details of ISO elements. In this case,
use a contact directory to add new contact makes sense.

This mode can be also more efficient when record contains lots of contacts which in some case
can create large HTML form which can take time to build, download and render in the browser
(eg. when having more than 100 contacts in a record). If only `label` are used the form will be faster to render.

For large XML record, form may trigger error like `Form with too many keys [1001 > 1000]` when submitted.
The list mode allows to deal with such situation.

eg.

```xml
<action type="add"
        forceLabel="true"
        addDirective="data-gn-directory-entry-selector"
        or="pointOfContact"
        in="/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification">
  <directiveAttributes
          data-template-add-action="false"
          data-search-action="true"
          data-popup-action="true"
          data-template-type="contact"
          data-variables="gmd:role/gmd:CI_RoleCode/@codeListValue~{role}"/>
</action>

<list name="Contact point"
      xpath="/gmd:MD_Metadata/gmd:identificationInfo/*/gmd:pointOfContact[*/gmd:role/*/@codeListValue = 'pointOfContact']"
      del="."
      sortBy="gmd:organisationName/gco:CharacterString">
  <item href="*[1]/@uuid">
    <label xpath="*/gmd:organisationName/gco:CharacterString/text()"/>
  </item>
</list>

<list name="Originator"
      xpath="/gmd:MD_Metadata/gmd:identificationInfo/*/gmd:pointOfContact[*/gmd:role/*/@codeListValue = 'originator']"
      sortBy="gmd:organisationName/gco:CharacterString">
  <item>
    <field xpath="*/gmd:organisationName"/>
  </item>
</list>
```

Funded by Ifremer
<xs:complexType>
<xs:sequence>
<xs:element ref="label"/>
<xs:element ref="text"/>
Copy link
Member

Choose a reason for hiding this comment

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

What is the difference between text and the other values?

Copy link
Member Author

Choose a reason for hiding this comment

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

See https://github.com/geonetwork/core-geonetwork/blob/main/schemas/config-editor.xsd#L1447-L1453 so you can also add text in the list item. It is not used for now but for example, we could think of

Org name
<hr/>
Address ...

<item>
<field xpath="*/gmd:organisationName"/>
</item>
</list>
Copy link
Member

Choose a reason for hiding this comment

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

Testing this example, the input box for the organisation, can be removed, but then is removed the organisation, not the contact (in the label mode, it is removed the contact, what makes more sense).

It's not something critical, but to confirm this is expected:

test-organisation-1

test-organisation-2

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, there is no del attribute in list, so the item has no button for removal. The org name is a normal field so can be removed as usual. If using

<field xpath="*/gmd:organisationName" del="ancestor::gmd:pointOfContact"/>

would remove the contact.

For now, we are more thinking using this mode with directory entries and only label.

This is needed when the custom editor is also used as a formatter.
Copy link

sonarcloud bot commented May 2, 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

fxprunayre added a commit that referenced this pull request May 15, 2024
A feature catalogue can contain one or more feature types description.
When describing a model with lots of feature types, then the editor can be quite large (and then can cause issue related to timeout or number of fields)

The problem is quite similar to #7998 (ie. timeout, number of form fields).

To better manage this case, make a list of existing feature types and user can click on it to edit only one feature type at a time.

This is enable by default for ISO19110 and ISO19115-3 feature catalogue
in all views. The first table is selected by default.

A selector can be manually configured using the following:

```xml
          <section name="gfc:featureType">
            <select name="Select a feature type"
                    xpath="/gfc:FC_FeatureCatalogue/gfc:featureType"
                    parameter="featureType"
                    value="*/gfc:typeName/gco:LocalName/text()"
                    layout="dropdown"/>
                    <!--tabs|pills|dropdown-->

            <section xpath="/gfc:FC_FeatureCatalogue/gfc:featureType[
                                    */gfc:typeName/gco:LocalName = $p2/featureType
                                    or (not($p2/featureType) and position() = 1)
                                    or ($p3 = 'md.format.html')]"
                     or="featureType"
                     in="/gfc:FC_FeatureCatalogue"/>
          </section>
```

`$p2` correspond to the variable `request` and `$p3` to the `service` in the XSL template (see `base-variables.xsl` and `evaluate.xsl`).
So if there is no `featureType` parameter, the first feature type will be displayed.
If the view mode is `md.format.html`, all feature types will be displayed.

It has only been tested for feature catalogue but can be probably reuse
in other places eg. conformity

* Dropdown (default)

* Tabs

* Pills

* Avoid JS error on large forms by using JQuery `empty()` instead of
find and remove:

```
RangeError: Maximum call stack size exceeded
    at Sizzle.select (jquery-2.2.4.js?v=dc93b22fa65aadfbbe3d7ad69b4d5d83601574de:2592:12)
    at Function.Sizzle [as find] (jquery-2.2.4.js?v=dc93b22fa65aadfbbe3d7ad69b4d5d83601574de:869:9)
    at jQuery.fn.init.find (jquery-2.2.4.js?v=dc93b22fa65aadfbbe3d7ad69b4d5d83601574de:2792:11)
    at refreshForm (EditorService.js:324:42)
```

* ISO19110 to ISO19115-3 conversion / Convert cardinality to
  CharacterString
fxprunayre added a commit that referenced this pull request May 15, 2024
A feature catalogue can contain one or more feature types description.
When describing a model with lots of feature types, then the editor can be quite large (and then can cause issue related to timeout or number of fields)

The problem is quite similar to #7998 (ie. timeout, number of form fields).

To better manage this case, make a list of existing feature types and user can click on it to edit only one feature type at a time.

This is enable by default for ISO19110 and ISO19115-3 feature catalogue
in all views. The first table is selected by default.

A selector can be manually configured using the following:

```xml
          <section name="gfc:featureType">
            <select name="Select a feature type"
                    xpath="/gfc:FC_FeatureCatalogue/gfc:featureType"
                    parameter="featureType"
                    value="*/gfc:typeName/gco:LocalName/text()"
                    layout="dropdown"/>
                    <!--tabs|pills|dropdown-->

            <section xpath="/gfc:FC_FeatureCatalogue/gfc:featureType[
                                    */gfc:typeName/gco:LocalName = $p2/featureType
                                    or (not($p2/featureType) and position() = 1)
                                    or ($p3 = 'md.format.html')]"
                     or="featureType"
                     in="/gfc:FC_FeatureCatalogue"/>
          </section>
```

`$p2` correspond to the variable `request` and `$p3` to the `service` in the XSL template (see `base-variables.xsl` and `evaluate.xsl`).
So if there is no `featureType` parameter, the first feature type will be displayed.
If the view mode is `md.format.html`, all feature types will be displayed.

It has only been tested for feature catalogue but can be probably reuse
in other places eg. conformity

* Dropdown (default)

* Tabs

* Pills

* Avoid JS error on large forms by using JQuery `empty()` instead of
find and remove:

```
RangeError: Maximum call stack size exceeded
    at Sizzle.select (jquery-2.2.4.js?v=dc93b22fa65aadfbbe3d7ad69b4d5d83601574de:2592:12)
    at Function.Sizzle [as find] (jquery-2.2.4.js?v=dc93b22fa65aadfbbe3d7ad69b4d5d83601574de:869:9)
    at jQuery.fn.init.find (jquery-2.2.4.js?v=dc93b22fa65aadfbbe3d7ad69b4d5d83601574de:2792:11)
    at refreshForm (EditorService.js:324:42)
```

* ISO19110 to ISO19115-3 conversion / Convert cardinality to
  CharacterString
fxprunayre added a commit that referenced this pull request May 15, 2024
A feature catalogue can contain one or more feature types description.
When describing a model with lots of feature types, then the editor can be quite large (and then can cause issue related to timeout or number of fields)

The problem is quite similar to #7998 (ie. timeout, number of form fields).

To better manage this case, make a list of existing feature types and user can click on it to edit only one feature type at a time.

This is enable by default for ISO19110 and ISO19115-3 feature catalogue
in all views. The first table is selected by default.

A selector can be manually configured using the following:

```xml
          <section name="gfc:featureType">
            <select name="Select a feature type"
                    xpath="/gfc:FC_FeatureCatalogue/gfc:featureType"
                    parameter="featureType"
                    value="*/gfc:typeName/gco:LocalName/text()"
                    layout="dropdown"/>
                    <!--tabs|pills|dropdown-->

            <section xpath="/gfc:FC_FeatureCatalogue/gfc:featureType[
                                    */gfc:typeName/gco:LocalName = $p2/featureType
                                    or (not($p2/featureType) and position() = 1)
                                    or ($p3 = 'md.format.html')]"
                     or="featureType"
                     in="/gfc:FC_FeatureCatalogue"/>
          </section>
```

`$p2` correspond to the variable `request` and `$p3` to the `service` in the XSL template (see `base-variables.xsl` and `evaluate.xsl`).
So if there is no `featureType` parameter, the first feature type will be displayed.
If the view mode is `md.format.html`, all feature types will be displayed.

It has only been tested for feature catalogue but can be probably reuse
in other places eg. conformity

* Dropdown (default)

* Tabs

* Pills

* Avoid JS error on large forms by using JQuery `empty()` instead of
find and remove:

```
RangeError: Maximum call stack size exceeded
    at Sizzle.select (jquery-2.2.4.js?v=dc93b22fa65aadfbbe3d7ad69b4d5d83601574de:2592:12)
    at Function.Sizzle [as find] (jquery-2.2.4.js?v=dc93b22fa65aadfbbe3d7ad69b4d5d83601574de:869:9)
    at jQuery.fn.init.find (jquery-2.2.4.js?v=dc93b22fa65aadfbbe3d7ad69b4d5d83601574de:2792:11)
    at refreshForm (EditorService.js:324:42)
```

* ISO19110 to ISO19115-3 conversion / Convert cardinality to
  CharacterString
joachimnielandt pushed a commit to Informatievlaanderen/metadata-geonetwork that referenced this pull request May 28, 2024
A feature catalogue can contain one or more feature types description.
When describing a model with lots of feature types, then the editor can be quite large (and then can cause issue related to timeout or number of fields)

The problem is quite similar to geonetwork#7998 (ie. timeout, number of form fields).

To better manage this case, make a list of existing feature types and user can click on it to edit only one feature type at a time.

This is enable by default for ISO19110 and ISO19115-3 feature catalogue
in all views. The first table is selected by default.

A selector can be manually configured using the following:

```xml
          <section name="gfc:featureType">
            <select name="Select a feature type"
                    xpath="/gfc:FC_FeatureCatalogue/gfc:featureType"
                    parameter="featureType"
                    value="*/gfc:typeName/gco:LocalName/text()"
                    layout="dropdown"/>
                    <!--tabs|pills|dropdown-->

            <section xpath="/gfc:FC_FeatureCatalogue/gfc:featureType[
                                    */gfc:typeName/gco:LocalName = $p2/featureType
                                    or (not($p2/featureType) and position() = 1)
                                    or ($p3 = 'md.format.html')]"
                     or="featureType"
                     in="/gfc:FC_FeatureCatalogue"/>
          </section>
```

`$p2` correspond to the variable `request` and `$p3` to the `service` in the XSL template (see `base-variables.xsl` and `evaluate.xsl`).
So if there is no `featureType` parameter, the first feature type will be displayed.
If the view mode is `md.format.html`, all feature types will be displayed.

It has only been tested for feature catalogue but can be probably reuse
in other places eg. conformity

* Dropdown (default)

* Tabs

* Pills

* Avoid JS error on large forms by using JQuery `empty()` instead of
find and remove:

```
RangeError: Maximum call stack size exceeded
    at Sizzle.select (jquery-2.2.4.js?v=dc93b22fa65aadfbbe3d7ad69b4d5d83601574de:2592:12)
    at Function.Sizzle [as find] (jquery-2.2.4.js?v=dc93b22fa65aadfbbe3d7ad69b4d5d83601574de:869:9)
    at jQuery.fn.init.find (jquery-2.2.4.js?v=dc93b22fa65aadfbbe3d7ad69b4d5d83601574de:2792:11)
    at refreshForm (EditorService.js:324:42)
```

* ISO19110 to ISO19115-3 conversion / Convert cardinality to
  CharacterString
joachimnielandt pushed a commit to Informatievlaanderen/metadata-geonetwork that referenced this pull request May 28, 2024
…types

A feature catalogue can contain one or more feature type description.
When describing a model with lots of feature types, then the editor can be quite large (and then can cause issue related to timeout or number of fields)

The problem is quite similar to geonetwork#7998

To better manage this case, make a list of existing feature types and user can click on it to edit only one feature type at a time.

## Configuration

This is enabled by default in all views for ISO19110 and ISO19115-3. The first table is selected by default.

A selector can be manually configured using the following:

```xml
          <section name="gfc:featureType">
            <select name="Select a feature type"
                    xpath="/gfc:FC_FeatureCatalogue/gfc:featureType"
                    parameter="featureType"
                    value="*/gfc:typeName/gco:LocalName/text()"
                    layout="dropdown"/>

            <section xpath="/gfc:FC_FeatureCatalogue/gfc:featureType[
                                    */gfc:typeName/gco:LocalName = $p2/featureType
                                    or (not($p2/featureType) and position() = 1)
                                    or ($p3 = 'md.format.html')]"
                     or="featureType"
                     in="/gfc:FC_FeatureCatalogue"/>
          </section>
```

`$p2` correspond to the variable `request` and `$p3` to the `service` in the XSL template (see `base-variables.xsl`).
So if there is no `featureType` parameter, the first feature type will be displayed.
If the view mode is `md.format.html`, all feature types will be displayed.

## Layout

* layout: dropdown

![image (5).png](https://agiv.visualstudio.com/dc849554-199a-495a-86b3-2669ea01f14c/_apis/git/repositories/0a154993-bcec-4021-98e4-034a6161db36/pullRequests/35571/attachments/image%20%285%29.png)

![image.png](https://agiv.visualstudio.com/dc849554-199a-495a-86b3-2669ea01f14c/_apis/git/repositories/0a154993-bcec-4021-98e4-034a6161db36/pullRequests/35571/attachments/image.png)

* layout: pills

![image (6).png](https://agiv.visualstudio.com/dc849554-199a-495a-86b3-2669ea01f14c/_apis/git/repositories/0a154993-bcec-4021-98e4-034a6161db36/pullRequests/35571/attachments/image%20%286%29.png)

It has only been tested for feature catalogue but can be probably reuse
in other places eg. conformity

* layout: tabs

![image (4).png](https://agiv.visualstudio.com/dc849554-199a-495a-86b3-2669ea01f14c/_apis/git/repositories/0a154993-bcec-4021-98e4-034a6161db36/pullRequests/35571/attachments/image%20%284%29.png)

The formatter API also use the config-editor for rendering xsl-view formatter.
http://localhost:8080/geonetwork/srv/dut/catalog.search#/metadata/9b86a7b6-a860-493e-827a-f3012c5d7760/formatters/xsl-view?view=default

Related work items: #191055
@fxprunayre fxprunayre merged commit 4141f26 into main Jun 3, 2024
9 checks passed
@fxprunayre fxprunayre deleted the 44-editorlist branch June 3, 2024 08:12
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