Skip to content

Commit

Permalink
Editor / Table mode / Add ordering control. (#8016)
Browse files Browse the repository at this point in the history
Add possibility to enable ordering control in table mode.

Refactor templates to use the same for all plugins.

Also stop event propagation to avoid to collapse a fieldset when moving
such elements.

Fix visibility of icons depending on position.

Funded by Ifremer.
  • Loading branch information
fxprunayre committed May 17, 2024
1 parent b407555 commit 83b1ab3
Show file tree
Hide file tree
Showing 9 changed files with 159 additions and 273 deletions.
11 changes: 7 additions & 4 deletions schemas/config-editor.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,14 @@ Configure here the list of fields to display using a table. This only applies to
<tableFields>
<table for="gmd:CI_OnlineResource">
<header>
<hcol label="gmd:protocol"/>
<hcol label="gmd:linkage"/>
<hcol label="gmd:name"/>
<hcol/>
<col/>
<col label="gmd:protocol"/>
<col label="gmd:linkage"/>
<col label="gmd:name"/>
<col/>
</header>
<row>
<col orderControl=".."/>
<col xpath="gmd:protocol"/>
<col xpath="gmd:linkage"/>
<col xpath="gmd:name"/>
Expand Down Expand Up @@ -434,6 +436,7 @@ Table column.
</xs:sequence>
<xs:attribute name="xpath" type="xs:string" use="optional"/>
<xs:attribute name="del" type="xs:string" use="optional"/>
<xs:attribute name="orderControl" type="xs:string" use="optional"/>
<xs:attribute name="use" type="xs:string" use="optional"/>
</xs:complexType>
</xs:element>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -569,12 +569,14 @@
a table view force some constraints. -->
<table for="cit:CI_Responsibility">
<header>
<col/>
<col label="cit:role"/>
<col label="cit:CI_Organisation"/>
<col label="cit:electronicMailAddress"/>
<col/>
</header>
<row>
<col orderControl=".."/>
<col xpath="cit:role"/>
<col xpath="cit:party/cit:CI_Organisation/cit:name"/>
<col xpath="cit:party/*/cit:contactInfo/*/cit:address/*/cit:electronicMailAddress"/>
Expand All @@ -583,11 +585,14 @@
</table>
<table for="gfc:FC_ListedValue">
<header>
<col/>
<col label="gfc:code"/>
<col label="gfc:label"/>
<col label="gfc:definition"/>
<col/>
</header>
<row>
<col orderControl=".."/>
<col xpath="gfc:code"/>
<col xpath="gfc:label"/>
<col xpath="gfc:definition"/>
Expand All @@ -596,11 +601,15 @@
</table>
<table for="gfc:FC_ListedValue">
<header>
<col/>
<col label="gfc:code"/>
<col label="gfc:label"/>
<col label="gfc:definition"/>
<col label="gfc:valueType"/>
<col/>
</header>
<row>
<col orderControl=".."/>
<col xpath="gfc:code"/>
<col xpath="gfc:label"/>
<col xpath="gfc:definition"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,9 @@
(1 or @gn:addedObj = 'true') and
$isFlatMode]"
priority="2000">
<xsl:call-template name="iso19115-3.2018-table"/>
<xsl:call-template name="build-table">
<xsl:with-param name="isoType" select="if (../@gco:isoType) then ../@gco:isoType else ''"/>
</xsl:call-template>
</xsl:template>

<!-- Ignore the following -->
Expand All @@ -358,132 +360,5 @@
$isFlatMode]"
priority="2000"/>

<!-- Define table layout -->
<xsl:template name="iso19115-3.2018-table">
<xsl:variable name="name" select="name()"/>
<xsl:variable name="xpath" select="gn-fn-metadata:getXPath(.)"/>
<xsl:variable name="isoType" select="if (../@gco:isoType) then ../@gco:isoType else ''"/>

<xsl:variable name="childName"
select="*[1]/name()"/>

<xsl:variable name="isEmbeddedMode"
select="@gn:addedObj = 'true'"/>
<xsl:variable name="isFirstOfItsKind"
select="preceding-sibling::*[1]/name() != $name"/>

<xsl:variable name="tableConfig"
select="$editorConfig/editor/tableFields/table[@for = $childName]"/>

<xsl:variable name="values">
<xsl:if test="not($isEmbeddedMode) or ($isEmbeddedMode and $isFirstOfItsKind)">
<header>
<xsl:for-each select="$tableConfig/header/col">
<col>
<xsl:copy-of select="@*"/>
<xsl:if test="@label">
<!-- TODO: column names may comes from strings.xml -->
<xsl:value-of select="gn-fn-metadata:getLabel($schema, @label, $labels, '', $isoType, $xpath)/label"/>
</xsl:if>
</col>
</xsl:for-each>
</header>
</xsl:if>
<xsl:for-each select="(.|following-sibling::*[name() = $name])/*[name() = $childName]">

<xsl:variable name="base"
select="."/>
<xsl:for-each select="$tableConfig/row">
<row>
<xsl:for-each select="col">
<col>
<xsl:if test="@use != ''">
<xsl:copy-of select="@use|directiveAttributes"/>
</xsl:if>
<xsl:if test="@del != ''">
<xsl:attribute name="remove" select="'true'"/>

<saxon:call-template name="{concat('evaluate-', $schema)}">
<xsl:with-param name="base" select="$base"/>
<xsl:with-param name="in"
select="concat('/', @del, '/gn:element')"/>
</saxon:call-template>
</xsl:if>

<xsl:if test="@xpath != ''">
<saxon:call-template name="{concat('evaluate-', $schema)}">
<xsl:with-param name="base" select="$base"/>
<xsl:with-param name="in"
select="concat('/', @xpath)"/>
</saxon:call-template>
</xsl:if>
</col>
</xsl:for-each>
</row>

<xsl:for-each select="section[@xpath]">
<row>
<col colspan="{count(../col)}" type="form" withLabel="true">
<xsl:apply-templates mode="form-builder" select=".">
<xsl:with-param name="base" select="$base"/>
</xsl:apply-templates>
<!--<xsl:variable name="nodes">
<saxon:call-template name="{concat('evaluate-', $schema)}">
<xsl:with-param name="base" select="$base"/>
<xsl:with-param name="in"
select="concat('/', @xpath)"/>
</saxon:call-template>
</xsl:variable>
<xsl:for-each select="$nodes">
<saxon:call-template name="{concat('dispatch-', $schema)}">
<xsl:with-param name="base" select="."/>
</saxon:call-template>
</xsl:for-each>
<xsl:if test="@or and @in">
<saxon:call-template name="{concat('evaluate-', $schema)}">
<xsl:with-param name="base" select="$base"/>
<xsl:with-param name="in"
select="concat('/../', @in, '/gn:child[@name=''', @or, ''']')"/>
</saxon:call-template>
</xsl:if>-->
</col>
</row>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</xsl:variable>


<!-- Return only the new row in embed mode. -->
<xsl:choose>
<xsl:when test="$tableConfig/@fieldset = 'false' or ($isEmbeddedMode and not($isFirstOfItsKind))">
<xsl:call-template name="render-table">
<xsl:with-param name="values" select="$values"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>

<xsl:variable name="tableTitle" select="if (($tableConfig/@label) and (string($strings/*[name() = $tableConfig/@label])))
then $strings/*[name() = $tableConfig/@label]
else gn-fn-metadata:getLabel($schema, $name, $labels, name(..), $isoType, $xpath)/label" />

<xsl:call-template name="render-boxed-element">
<xsl:with-param name="label"
select="$tableTitle"/>
<xsl:with-param name="cls" select="local-name()"/>
<xsl:with-param name="subTreeSnippet">

<xsl:call-template name="render-table">
<xsl:with-param name="values" select="$values"/>
</xsl:call-template>

</xsl:with-param>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

</xsl:stylesheet>
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@
<tableFields>
<table for="gmd:CI_ResponsibleParty">
<header>
<col/>
<!-- TODO: Add label from strings.xml / label with context-->
<col label="gmd:organisationName"/>
<col label="gmd:individualName"/>
Expand All @@ -432,6 +433,7 @@
<col/>
</header>
<row>
<col orderControl=".."/>
<col xpath="gmd:organisationName"/>
<col xpath="gmd:individualName"/>
<col xpath="gmd:contactInfo/*/gmd:address/*/gmd:electronicMailAddress"/>
Expand All @@ -441,12 +443,14 @@
</table>
<table for="gmd:CI_OnlineResource">
<header>
<col/>
<col label="gmd:protocol"/>
<col label="gmd:linkage"/>
<col label="gmd:name"/>
<col/>
</header>
<row>
<col orderControl=".."/>
<col xpath="gmd:protocol"/>
<col xpath="gmd:linkage"/>
<col xpath="gmd:name"/>
Expand Down
133 changes: 3 additions & 130 deletions schemas/iso19139/src/main/plugin/iso19139/layout/layout-custom-tpl.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
(1 or @gn:addedObj = 'true') and
$isFlatMode]"
priority="2000">
<xsl:call-template name="iso19139-table"/>
<xsl:call-template name="build-table">
<xsl:with-param name="isoType" select="if (../@gco:isoType) then ../@gco:isoType else ''"/>
</xsl:call-template>
</xsl:template>

<!-- Ignore the following -->
Expand All @@ -35,135 +37,6 @@
$isFlatMode]"
priority="2000"/>

<!-- Define table layout -->
<xsl:template name="iso19139-table">
<xsl:variable name="name" select="name()"/>
<xsl:variable name="xpath" select="gn-fn-metadata:getXPath(.)"/>
<xsl:variable name="isoType" select="if (../@gco:isoType) then ../@gco:isoType else ''"/>

<xsl:variable name="childName"
select="*[1]/name()"/>

<xsl:variable name="isEmbeddedMode"
select="@gn:addedObj = 'true'"/>
<xsl:variable name="isFirstOfItsKind"
select="preceding-sibling::*[1]/name() != $name"/>

<xsl:variable name="tableConfig"
select="$editorConfig/editor/tableFields/table[@for = $childName]"/>

<xsl:variable name="values">
<xsl:if test="not($isEmbeddedMode) or ($isEmbeddedMode and $isFirstOfItsKind)">
<header>
<xsl:for-each select="$tableConfig/header/col">
<col>
<xsl:copy-of select="@*"/>
<xsl:if test="@label">
<!-- TODO: column names may comes from strings.xml -->
<xsl:value-of select="gn-fn-metadata:getLabel($schema, @label, $labels, '', $isoType, $xpath)/label"/>
</xsl:if>
</col>
</xsl:for-each>
</header>
</xsl:if>
<xsl:for-each select="(.|following-sibling::*[name() = $name])/*[name() = $childName]">

<xsl:variable name="base"
select="."/>
<xsl:for-each select="$tableConfig/row">
<row>
<xsl:for-each select="col">
<col>
<xsl:if test="@use != ''">
<xsl:copy-of select="@use|directiveAttributes"/>
</xsl:if>
<xsl:if test="@del != ''">
<xsl:attribute name="remove" select="'true'"/>

<saxon:call-template name="{concat('evaluate-', $schema)}">
<xsl:with-param name="base" select="$base"/>
<xsl:with-param name="in"
select="concat('/', @del, '/gn:element')"/>
</saxon:call-template>
</xsl:if>

<xsl:if test="@xpath != ''">
<saxon:call-template name="{concat('evaluate-', $schema)}">
<xsl:with-param name="base" select="$base"/>
<xsl:with-param name="in"
select="concat('/', @xpath)"/>
</saxon:call-template>
</xsl:if>
</col>
</xsl:for-each>
</row>

<xsl:for-each select="section[@xpath]">
<row>
<col colspan="{count(../col)}" type="form" withLabel="true">
<xsl:apply-templates mode="form-builder" select=".">
<xsl:with-param name="base" select="$base"/>
</xsl:apply-templates>
<!--<xsl:variable name="nodes">
<saxon:call-template name="{concat('evaluate-', $schema)}">
<xsl:with-param name="base" select="$base"/>
<xsl:with-param name="in"
select="concat('/', @xpath)"/>
</saxon:call-template>
</xsl:variable>
<xsl:for-each select="$nodes">
<saxon:call-template name="{concat('dispatch-', $schema)}">
<xsl:with-param name="base" select="."/>
</saxon:call-template>
</xsl:for-each>
<xsl:if test="@or and @in">
<saxon:call-template name="{concat('evaluate-', $schema)}">
<xsl:with-param name="base" select="$base"/>
<xsl:with-param name="in"
select="concat('/../', @in, '/gn:child[@name=''', @or, ''']')"/>
</saxon:call-template>
</xsl:if>-->
</col>
</row>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</xsl:variable>


<!-- Return only the new row in embed mode. -->
<xsl:choose>
<xsl:when test="$tableConfig/@fieldset = 'false' or ($isEmbeddedMode and not($isFirstOfItsKind))">
<xsl:call-template name="render-table">
<xsl:with-param name="values" select="$values"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>

<xsl:variable name="tableTitle" select="if (($tableConfig/@label) and (string($strings/*[name() = $tableConfig/@label])))
then $strings/*[name() = $tableConfig/@label]
else gn-fn-metadata:getLabel($schema, $name, $labels, name(..), $isoType, $xpath)/label" />

<xsl:call-template name="render-boxed-element">
<xsl:with-param name="label"
select="$tableTitle"/>
<xsl:with-param name="cls" select="local-name()"/>
<xsl:with-param name="subTreeSnippet">

<xsl:call-template name="render-table">
<xsl:with-param name="values" select="$values"/>
</xsl:call-template>

</xsl:with-param>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>




<xsl:template mode="mode-iso19139"
Expand Down
Loading

0 comments on commit 83b1ab3

Please sign in to comment.