Skip to content

Commit

Permalink
Restored document-level bs2:RowForm
Browse files Browse the repository at this point in the history
  • Loading branch information
namedgraph committed Dec 21, 2023
1 parent 428a9c2 commit db194c3
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -390,11 +390,11 @@ WHERE
</xsl:variable>
<xsl:sequence select="$request[current-date() lt xs:date('2000-01-01')]"/>

<xsl:call-template name="ldh:PushState">
<!-- <xsl:call-template name="ldh:PushState">
<xsl:with-param name="href" select="ldh:href($ldt:base, ac:absolute-path(base-uri()), map{}, $href)"/>
<!--<xsl:with-param name="title" select="/html/head/title"/>-->
<xsl:with-param name="title" select="/html/head/title"/>
<xsl:with-param name="container" select="id('content-body', ixsl:page())"/>
</xsl:call-template>
</xsl:call-template>-->
</xsl:template>

<!-- appends new SHACL-constructed instance to the form -->
Expand Down Expand Up @@ -424,10 +424,10 @@ WHERE
</xsl:variable>
<xsl:sequence select="$request[current-date() lt xs:date('2000-01-01')]"/>

<xsl:call-template name="ldh:PushState">
<!-- <xsl:call-template name="ldh:PushState">
<xsl:with-param name="href" select="ldh:href($ldt:base, ac:absolute-path(base-uri()), map{}, $href)"/>
<xsl:with-param name="container" select="id('content-body', ixsl:page())"/>
</xsl:call-template>
</xsl:call-template>-->
</xsl:template>

<!-- types (classes with constructors) are looked up in the <ns> endpoint -->
Expand Down Expand Up @@ -890,9 +890,7 @@ WHERE
<xsl:context-item as="map(*)" use="required"/>
<xsl:param name="container" as="element()"/>
<xsl:param name="add-class" as="xs:string?"/>
<!-- <xsl:param name="target-id" as="xs:string?"/>-->
<xsl:param name="new-form-id" as="xs:string?"/>
<!-- <xsl:param name="new-target-id" as="xs:string?"/>-->
<xsl:param name="max-bnode-id" as="xs:integer?"/>

<xsl:choose>
Expand All @@ -901,12 +899,10 @@ WHERE
<xsl:variable name="event" select="ixsl:event()"/>
<xsl:variable name="target" select="ixsl:get($event, 'target')"/>
<xsl:variable name="modal" select="exists(id($container/@id)//div[contains-token(@class, 'modal-constructor')])" as="xs:boolean"/>
<!-- <xsl:variable name="target-id" select="$target/@id" as="xs:string?"/>-->
<xsl:variable name="doc-id" select="concat('id', ixsl:call(ixsl:window(), 'generateUUID', []))" as="xs:string"/>

<xsl:variable name="form" as="element()">
<xsl:apply-templates select="id($container/@id)//form" mode="form">
<!-- <xsl:with-param name="target-id" select="$target-id" tunnel="yes"/>-->
<xsl:with-param name="doc-id" select="$doc-id" tunnel="yes"/>
<!-- only rewrite bnode labels if "Create" button was called within <form> -->
<xsl:with-param name="max-bnode-id" select="if ($target/ancestor::form[contains-token(@class, 'form-horizontal')]) then $max-bnode-id else ()" tunnel="yes"/>
Expand All @@ -920,23 +916,23 @@ WHERE

<xsl:choose>
<!-- if "Create" button is within a <form>, append elements to <form> -->
<xsl:when test="$target/ancestor::form[contains-token(@class, 'form-horizontal')]">
<!-- <xsl:when test="$target/ancestor::form[contains-token(@class, 'form-horizontal')]">
<xsl:for-each select="$target/ancestor::form[contains-token(@class, 'form-horizontal')]">
<!-- remove the old form-actions <div> because we'll be appending a new one below -->
remove the old form-actions <div> because we'll be appending a new one below
<xsl:for-each select="./div[./div[contains-token(@class, 'form-actions')]]">
<xsl:sequence select="ixsl:call(., 'remove', [])[current-date() lt xs:date('2000-01-01')]"/>
</xsl:for-each>
<!-- remove the current "Create" buttons from the form -->
remove the current "Create" buttons from the form
<xsl:for-each select="$target/ancestor::div[contains-token(@class, 'create-resource')]">
<xsl:sequence select="ixsl:call(., 'remove', [])[current-date() lt xs:date('2000-01-01')]"/>
</xsl:for-each>
<xsl:result-document href="?." method="ixsl:append-content">
<!-- only append the <fieldset> from the $form, not the whole <form> -->
only append the <fieldset> from the $form, not the whole <form>
<xsl:copy-of select="$form//div[contains-token(@class, 'row-fluid')]"/>
</xsl:result-document>
</xsl:for-each>
</xsl:when>
</xsl:when>-->
<!-- if "Create" button is ReadMode, append form as row -->
<xsl:when test="$target/ancestor::div[@id = 'content-body']">
<xsl:for-each select="$target/ancestor::div[@id = 'content-body']">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -648,9 +648,9 @@ extension-element-prefixes="ixsl"
</xsl:next-match>
</xsl:template>

<!-- <xsl:template match="rdf:RDF[$ac:forClass][$ac:method = 'GET']" mode="bs2:RowForm" priority="1" use-when="system-property('xsl:product-name') = 'SAXON'">
<xsl:template match="rdf:RDF[$ac:forClass][$ac:method = 'GET']" mode="bs2:RowForm" priority="1" use-when="system-property('xsl:product-name') = 'SAXON'">
<xsl:param name="base-uri" as="xs:anyURI" tunnel="yes"/>
document resource might not always be present in the form (e.g. ldh:Content only)
<!-- document resource might not always be present in the form (e.g. ldh:Content only) -->
<xsl:param name="document-uri" select="if (key('resources-by-type', ('&dh;Container', '&dh;Item'))/@rdf:about) then key('resources-by-type', ('&dh;Container', '&dh;Item'))/@rdf:about else $base-uri" as="xs:anyURI"/> $doc-uri of the constructed document
<xsl:param name="action" select="ac:build-uri($document-uri, map{ '_method': 'PUT', 'forClass': string($ac:forClass), 'mode': '&ac;EditMode' })" as="xs:anyURI"/>
<xsl:param name="classes" as="element()*"/>
Expand Down Expand Up @@ -706,15 +706,15 @@ extension-element-prefixes="ixsl"

<xsl:apply-templates mode="bs2:Exception"/>

show the current document on the top
<!-- show the current document on the top -->
<xsl:apply-templates select="*[@rdf:about = ac:absolute-path(base-uri())]" mode="#current">
<xsl:with-param name="inline" select="false()" tunnel="yes"/>
<xsl:with-param name="constructors" select="$constructors" tunnel="yes"/>
<xsl:with-param name="constraints" select="$constraints" tunnel="yes"/>
<xsl:with-param name="type-metadata" select="$type-metadata" tunnel="yes"/>
<xsl:with-param name="property-metadata" select="$property-metadata" tunnel="yes"/>
</xsl:apply-templates>
show the rest of the resources (contents, instances) below it
<!-- show the rest of the resources (contents, instances) below it -->
<xsl:apply-templates select="*[not(@rdf:about = ac:absolute-path(base-uri()))]" mode="#current">
<xsl:sort select="ac:label(.)"/>
<xsl:with-param name="inline" select="false()" tunnel="yes"/>
Expand All @@ -739,7 +739,7 @@ extension-element-prefixes="ixsl"
<xsl:with-param name="button-class" select="$button-class"/>
</xsl:apply-templates>
</form>
</xsl:template>-->
</xsl:template>

<!-- MODAL FORM ACTIONS -->

Expand Down Expand Up @@ -780,7 +780,7 @@ extension-element-prefixes="ixsl"

<!-- FORM ACTIONS -->

<!-- <xsl:template match="rdf:RDF" mode="bs2:FormActions">
<xsl:template match="rdf:RDF" mode="bs2:FormActions">
<xsl:param name="class" select="'row-fluid'" as="xs:string?"/>
<xsl:param name="button-class" select="'btn btn-primary'" as="xs:string?"/>

Expand All @@ -807,7 +807,7 @@ extension-element-prefixes="ixsl"
</xsl:value-of>
</button>
</div>
</xsl:template>-->
</xsl:template>

<!-- CREATE -->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,9 @@ extension-element-prefixes="ixsl"
<xsl:when test="$mode = '&ac;GraphMode'">
<xsl:apply-templates select=".." mode="bs2:Graph"/>
</xsl:when>
<xsl:when test="$mode = '&ac;EditMode'">
<xsl:apply-templates select="." mode="bs2:Form"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="." mode="bs2:Block"/>
</xsl:otherwise>
Expand Down Expand Up @@ -1039,17 +1042,17 @@ extension-element-prefixes="ixsl"
<!-- ROW FORM -->

<!-- hide constraint violations and HTTP responses in the form - they are displayed as errors on the edited resources -->
<xsl:template match="*[rdf:type/@rdf:resource = ('&spin;ConstraintViolation', '&sh;ValidationResult', '&sh;ValidationReport', '&http;Response')]" mode="bs2:RowForm" priority="3" use-when="system-property('xsl:product-name') = 'SAXON'"/>
<xsl:template match="*[rdf:type/@rdf:resource = ('&spin;ConstraintViolation', '&sh;ValidationResult', '&sh;ValidationReport', '&http;Response')]" mode="bs2:Form" priority="3" use-when="system-property('xsl:product-name') = 'SAXON'"/>

<!-- hide instances of system classes -->
<!-- <xsl:template match="*[not($ldh:renderSystemResources)][@rdf:about = ac:absolute-path(base-uri()) and rdf:type/@rdf:resource = ('&def;Root', '&dh;Container', '&dh;Item')] | *[not($ldh:renderSystemResources)][rdf:type/@rdf:resource = '&ldh;Content']" mode="bs2:RowForm" priority="2.5" use-when="system-property('xsl:product-name') = 'SAXON'"/> -->

<!-- hide object blank nodes that only have a single rdf:type property from constructed models, unless the type is owl:NamedIndividual -->
<xsl:template match="*[@rdf:nodeID][$ac:forClass or $ldh:forShape][$ac:method = 'GET'][key('predicates-by-object', @rdf:nodeID)][not(* except rdf:type or rdf:type/@rdf:resource = '&owl;NamedIndividual')]" mode="bs2:RowForm" priority="2" use-when="system-property('xsl:product-name') = 'SAXON'"/>
<xsl:template match="*[@rdf:nodeID][$ac:forClass or $ldh:forShape][$ac:method = 'GET'][key('predicates-by-object', @rdf:nodeID)][not(* except rdf:type or rdf:type/@rdf:resource = '&owl;NamedIndividual')]" mode="bs2:Form" priority="2" use-when="system-property('xsl:product-name') = 'SAXON'"/>

<xsl:template match="*[*][@rdf:about] | *[*][@rdf:nodeID]" mode="bs2:RowForm"> <!-- use-when="system-property('xsl:product-name') = 'SAXON'" -->
<xsl:param name="id" select="generate-id()" as="xs:string?"/>
<xsl:param name="class" select="'main span7 offset2'" as="xs:string?"/>
<xsl:template match="*[*][@rdf:about] | *[*][@rdf:nodeID]" mode="bs2:Form"> <!-- use-when="system-property('xsl:product-name') = 'SAXON'" -->
<xsl:param name="id" select="'form-' || generate-id()" as="xs:string?"/>
<xsl:param name="class" select="'form-horizontal'" as="xs:string?"/>
<xsl:param name="method" select="'post'" as="xs:string"/>
<xsl:param name="base-uri" select="base-uri()" as="xs:anyURI" tunnel="yes"/>
<xsl:param name="action" select="ldh:href($ldt:base, ac:absolute-path($base-uri), map{}, ac:build-uri(ac:absolute-path($base-uri), map{ '_method': 'PUT', 'mode': for $mode in $ac:mode return string($mode) }))" as="xs:anyURI"/>
Expand All @@ -1069,74 +1072,71 @@ extension-element-prefixes="ixsl"
<xsl:param name="property-uris" select="distinct-values(*/concat(namespace-uri(), local-name()))" as="xs:string*"/>
<xsl:param name="property-metadata" select="if (exists($property-uris)) then ldh:send-request(resolve-uri('ns', $ldt:base), 'POST', 'application/sparql-query', 'DESCRIBE $Type' || ' VALUES $Type { ' || string-join(for $uri in $property-uris return '&lt;' || $uri || '&gt;', ' ') || ' }', map{ 'Accept': 'application/rdf+xml' }) else ()" as="document-node()?" tunnel="yes"/>

<div>
<form method="{$method}" action="{$action}">
<xsl:if test="$id">
<xsl:attribute name="id" select="$id"/>
</xsl:if>
<xsl:if test="$class">
<xsl:attribute name="class" select="$class"/>
</xsl:if>
<xsl:if test="$accept-charset">
<xsl:attribute name="accept-charset" select="$accept-charset"/>
</xsl:if>
<xsl:if test="$enctype">
<xsl:attribute name="enctype" select="$enctype"/>
</xsl:if>

<form method="{$method}" action="{$action}" id="{concat('form-', $id)}" class="form-horizontal">
<xsl:if test="$accept-charset">
<xsl:attribute name="accept-charset" select="$accept-charset"/>
</xsl:if>
<xsl:if test="$enctype">
<xsl:attribute name="enctype" select="$enctype"/>
</xsl:if>
<xsl:comment>This form uses RDF/POST encoding: https://atomgraph.github.io/RDF-POST/</xsl:comment>
<xsl:call-template name="xhtml:Input">
<xsl:with-param name="name" select="'rdf'"/>
<xsl:with-param name="type" select="'hidden'"/>
</xsl:call-template>

<xsl:comment>This form uses RDF/POST encoding: https://atomgraph.github.io/RDF-POST/</xsl:comment>
<xsl:call-template name="xhtml:Input">
<xsl:with-param name="name" select="'rdf'"/>
<xsl:with-param name="type" select="'hidden'"/>
</xsl:call-template>

<xsl:apply-templates select="/rdf:RDF/*[http:sc/@rdf:resource = '&sc;Conflict']" mode="bs2:Exception"/>

<xsl:apply-templates select="." mode="bs2:FormControl">
<xsl:with-param name="inline" select="false()" tunnel="yes"/>
<xsl:with-param name="constructors" select="$constructors" tunnel="yes"/>
<xsl:with-param name="constraints" select="$constraints" tunnel="yes"/>
<xsl:with-param name="shapes" select="$shapes" tunnel="yes"/>
<xsl:with-param name="type-metadata" select="$type-metadata" tunnel="yes"/>
<xsl:with-param name="property-metadata" select="$property-metadata" tunnel="yes"/>
</xsl:apply-templates>
<xsl:apply-templates select="/rdf:RDF/*[http:sc/@rdf:resource = '&sc;Conflict']" mode="bs2:Exception"/>

<xsl:if test="$create-resource">
<div class="create-resource row-fluid">
<div class="main offset2 span7">
<xsl:apply-templates select="." mode="bs2:Create">
<xsl:with-param name="classes" select="$classes"/>
</xsl:apply-templates>
</div>
</div>
</xsl:if>
<xsl:apply-templates select="." mode="bs2:FormControl">
<xsl:with-param name="inline" select="false()" tunnel="yes"/>
<xsl:with-param name="constructors" select="$constructors" tunnel="yes"/>
<xsl:with-param name="constraints" select="$constraints" tunnel="yes"/>
<xsl:with-param name="shapes" select="$shapes" tunnel="yes"/>
<xsl:with-param name="type-metadata" select="$type-metadata" tunnel="yes"/>
<xsl:with-param name="property-metadata" select="$property-metadata" tunnel="yes"/>
</xsl:apply-templates>

<div class="form-actions">
<button type="submit" class="btn-primary">
<xsl:apply-templates select="key('resources', 'save', document(resolve-uri('static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/translations.rdf', $ac:contextUri)))" mode="ldh:logo">
<xsl:with-param name="class" select="$button-class"/>
<xsl:if test="$create-resource">
<div class="create-resource row-fluid">
<div class="main offset2 span7">
<xsl:apply-templates select="." mode="bs2:Create">
<xsl:with-param name="classes" select="$classes"/>
</xsl:apply-templates>
</div>
</div>
</xsl:if>

<xsl:apply-templates select="key('resources', 'save', document(resolve-uri('static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/translations.rdf', $ac:contextUri)))" mode="ac:label"/>
</button>
<div class="form-actions">
<button type="submit" class="btn-primary">
<xsl:apply-templates select="key('resources', 'save', document(resolve-uri('static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/translations.rdf', $ac:contextUri)))" mode="ldh:logo">
<xsl:with-param name="class" select="$button-class"/>
</xsl:apply-templates>

<button type="reset" class="btn">
<xsl:apply-templates select="key('resources', 'reset', document(resolve-uri('static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/translations.rdf', $ac:contextUri)))" mode="ldh:logo">
<xsl:with-param name="class" select="'btn'"/>
</xsl:apply-templates>
<xsl:apply-templates select="key('resources', 'save', document(resolve-uri('static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/translations.rdf', $ac:contextUri)))" mode="ac:label"/>
</button>

<xsl:apply-templates select="key('resources', 'reset', document(resolve-uri('static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/translations.rdf', $ac:contextUri)))" mode="ac:label"/>
</button>
<button type="reset" class="btn">
<xsl:apply-templates select="key('resources', 'reset', document(resolve-uri('static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/translations.rdf', $ac:contextUri)))" mode="ldh:logo">
<xsl:with-param name="class" select="'btn'"/>
</xsl:apply-templates>

<button type="button" class="btn btn-cancel">
<xsl:value-of>
<xsl:apply-templates select="key('resources', 'cancel', document(resolve-uri('static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/translations.rdf', $ac:contextUri)))" mode="ac:label"/>
</xsl:value-of>
</button>
</div>
</form>
</div>
<xsl:apply-templates select="key('resources', 'reset', document(resolve-uri('static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/translations.rdf', $ac:contextUri)))" mode="ac:label"/>
</button>

<button type="button" class="btn btn-cancel">
<xsl:value-of>
<xsl:apply-templates select="key('resources', 'cancel', document(resolve-uri('static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/translations.rdf', $ac:contextUri)))" mode="ac:label"/>
</xsl:value-of>
</button>
</div>
</form>
</xsl:template>

<!-- EXCEPTION -->
Expand Down
Loading

0 comments on commit db194c3

Please sign in to comment.