Skip to content

Commit

Permalink
New bs2:AccessRequestComplete client-side template handles special …
Browse files Browse the repository at this point in the history
…`201 Created` case for `form-request-access`
  • Loading branch information
namedgraph committed Oct 12, 2023
1 parent ad9bdaf commit b082776
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ exclude-result-prefixes="#all">

<xsl:template match="rdf:RDF[if (doc-available(ldh:absolute-path($ldh:requestUri))) then (key('resources', ldh:absolute-path($ldh:requestUri), document(ldh:absolute-path($ldh:requestUri)))/rdf:type/@rdf:resource = '&adm;RequestAccess') else false()][$ac:method = 'POST'][key('resources-by-type', '&spin;ConstraintViolation') or key('resources-by-type', '&sh;ValidationResult')]" mode="xhtml:Body" priority="3">
<xsl:apply-templates select="." mode="bs2:RowForm">
<xsl:with-param name="id" select="'form-request-access'"/>
<xsl:with-param name="action" select="ldh:absolute-path(base-uri($main-doc))"/>
<xsl:with-param name="enctype" select="()"/> <!-- don't use 'multipart/form-data' which is the default -->
<xsl:with-param name="create-resource" select="false()"/>
Expand All @@ -66,9 +67,6 @@ exclude-result-prefixes="#all">
</div>
</xsl:template>

<!-- currently doesn't work because the client-side does not refresh the bs2:NavBarActions -->
<!--<xsl:template match="rdf:RDF[if (doc-available(ldh:absolute-path($ldh:requestUri))) then (key('resources', ldh:absolute-path($ldh:requestUri), document(ldh:absolute-path($ldh:requestUri)))/rdf:type/@rdf:resource = '&adm;RequestAccess') else false()]" mode="bs2:NavBarActions" priority="2"/>-->

<xsl:template match="rdf:RDF[if (doc-available(ldh:absolute-path($ldh:requestUri))) then (key('resources', ldh:absolute-path($ldh:requestUri), document(ldh:absolute-path($ldh:requestUri)))/rdf:type/@rdf:resource = '&adm;RequestAccess') else false()]" mode="bs2:ModeTabs" priority="2"/>

<xsl:template match="*[rdf:type/@rdf:resource = '&adm;RequestAccess'][$ac:method = 'GET']" mode="bs2:Row" priority="2">
Expand All @@ -87,6 +85,7 @@ exclude-result-prefixes="#all">
</xsl:variable>

<xsl:apply-templates select="$constructor" mode="bs2:RowForm">
<xsl:with-param name="id" select="'form-request-access'"/>
<xsl:with-param name="action" select="ldh:absolute-path(base-uri($main-doc))"/>
<xsl:with-param name="enctype" select="()"/> <!-- don't use 'multipart/form-data' which is the default -->
<xsl:with-param name="create-resource" select="false()"/>
Expand All @@ -97,26 +96,6 @@ exclude-result-prefixes="#all">
</xsl:apply-templates>
</xsl:template>

<!-- display stored AuthorizationRequest data after successful POST (without ConstraintViolations) -->
<xsl:template match="rdf:RDF[if (doc-available(ldh:absolute-path($ldh:requestUri))) then (key('resources', ldh:absolute-path($ldh:requestUri), document(ldh:absolute-path($ldh:requestUri)))/rdf:type/@rdf:resource = '&adm;RequestAccess') else false()][$ac:method = 'POST'][not(key('resources-by-type', '&http;Response'))][1]" mode="bs2:Row" priority="3">
<xsl:param name="id" as="xs:string?"/>
<xsl:param name="class" select="'offset2 span7'" as="xs:string?"/>

<div class="row-fluid">
<div class="offset2 span7">
<div class="alert alert-success row-fluid ">
<div class="span1">
<img src="{resolve-uri('static/com/atomgraph/linkeddatahub/icons/baseline_done_white_48dp.png', $ac:contextUri)}" alt="Request created"/>
</div>
<div class="span11">
<p>Your access request has been created.</p>
<p>You will be notified when the administrator approves or rejects it.</p>
</div>
</div>
</div>
</div>
</xsl:template>

<!-- suppress other resources -->
<xsl:template match="*[if (doc-available(ldh:absolute-path($ldh:requestUri))) then (key('resources', ldh:absolute-path($ldh:requestUri), document(ldh:absolute-path($ldh:requestUri)))/rdf:type/@rdf:resource = '&adm;RequestAccess') else false()][$ac:method = 'POST'][not(key('resources-by-type', '&http;Response'))]" mode="bs2:Row" priority="2"/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,12 @@ WHERE
<ixsl:set-property name="value" select="string(adjust-dateTime-to-timezone(ixsl:get(., 'value')))" object="."/>
</xsl:template>


<xsl:template name="bs2:SignUpComplete">
<xsl:context-item as="map(*)" use="required"/>
<xsl:param name="created-uri" select="?headers?location" as="xs:anyURI"/>

<ixsl:set-style name="cursor" select="'default'" object="ixsl:page()//body"/>

<xsl:for-each select="id('content-body', ixsl:page())">
<xsl:result-document href="?." method="ixsl:replace-content">
<div class="row-fluid">
Expand All @@ -246,12 +247,36 @@ WHERE
<xsl:variable name="request-uri" select="ac:build-uri($created-uri, map{ 'accept': 'application/rdf+xml' })" as="xs:anyURI"/>
<xsl:for-each select="document($request-uri)">
<xsl:apply-templates select="key('resources-by-type', '&foaf;Person')[@rdf:about]" mode="bs2:Row"/>
<xsl:apply-templates select="key('resources-by-type', '&cert;PublicKey')[@rdf:about]" mode="bs2:Row"/>
</xsl:for-each>
</xsl:result-document>
</xsl:for-each>
</xsl:template>

<xsl:template name="bs2:AccessRequestComplete">
<xsl:context-item as="map(*)" use="required"/>
<xsl:param name="created-uri" select="?headers?location" as="xs:anyURI"/>

<ixsl:set-style name="cursor" select="'default'" object="ixsl:page()//body"/>

<xsl:for-each select="id('content-body', ixsl:page())">
<xsl:result-document href="?." method="ixsl:replace-content">
<div class="row-fluid">
<div class="offset2 span7">
<div class="alert alert-success row-fluid ">
<div class="span1">
<img src="{resolve-uri('static/com/atomgraph/linkeddatahub/icons/baseline_done_white_48dp.png', $ac:contextUri)}" alt="Request created"/>
</div>
<div class="span11">
<p>Your access request has been created.</p>
<p>You will be notified when the administrator approves or rejects it.</p>
</div>
</div>
</div>
</div>
</xsl:result-document>
</xsl:for-each>
</xsl:template>

<!-- EVENT HANDLERS -->

<xsl:template match="form[contains-token(@class, 'form-horizontal')] | form[ancestor::div[contains-token(@class, 'modal')]]" mode="ixsl:onsubmit">
Expand Down Expand Up @@ -1176,6 +1201,10 @@ WHERE
<xsl:when test="ixsl:get($form, 'id') = 'form-signup'">
<xsl:call-template name="bs2:SignUpComplete"/>
</xsl:when>
<!-- special case for request access form -->
<xsl:when test="ixsl:get($form, 'id') = 'form-request-access'">
<xsl:call-template name="bs2:AccessRequestComplete"/>
</xsl:when>
<!-- special case for "Save query/chart" forms: simpy hide the modal form -->
<xsl:when test="contains-token($form/@class, 'form-save-query') or contains-token($form/@class, 'form-save-chart')">
<!-- remove the modal div -->
Expand Down

0 comments on commit b082776

Please sign in to comment.