Skip to content

Commit a35e956

Browse files
authored
Document editing form (#207)
* Modal editing form for the document resource * Hide RDF sequence properties * Replaced `ldh:LoadEditedResource` and `ldh:LoadTypeMetadata` named templates with functioons * Context map passing Map as the common promise contract allowed to improve their composition * More promise composition * XSLT fixes * Refactores view using promises * Function cleanup * View map mode fix * Refactored error promise functions * Undone server-side query rendering New `ldh:uri-po-pattern` function * Custom `WHERE` pattern for the document editing `PATCH` update * Multipart file upload fix * Removed unnecessary `use-when`
1 parent 15384fc commit a35e956

10 files changed

Lines changed: 1245 additions & 620 deletions

File tree

src/main/webapp/static/com/atomgraph/linkeddatahub/css/bootstrap.css

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@ body.embed { padding-top: 0; }
1414
.navbar-form .btn-search { background-image: url('../icons/ic_search_white_24px.svg'); background-position: center center; background-repeat: no-repeat; width: 34px; height: 34px; }
1515
.action-bar { background-color: #dfdfdf; }
1616
.action-bar form { margin-bottom: 0; }
17+
.action-bar .span7 .row-fluid > * { margin-top: 10px; }
1718
.action-bar .add-constructor, .dropdown-menu .add-constructor { background-color: inherit; display: block; text-align: left; width: 100%; }
1819
.action-bar .add-constructor:hover { color: #ffffff; background-color: #007af5; }
19-
.action-bar .breadcrumb { background-color: inherit; margin-top: 10px; margin-bottom: 0; padding-left: 0; padding-top: 5px; }
20+
.action-bar .breadcrumb { background-color: inherit; margin-bottom: 0; padding-left: 0; padding-top: 5px; }
2021
.action-bar .breadcrumb .container-logo { background-image: url('../icons/folder.svg'); background-position: left center; background-repeat: no-repeat; padding-left: 28px; }
2122
.action-bar .breadcrumb .item-logo { background-image: url('../icons/file.svg'); background-position: left center; background-repeat: no-repeat; padding-left: 28px; }
2223
.action-bar .breadcrumb .btn-group { margin-top: -4px; }
23-
.action-bar #breadcrumb-nav > .label-info { margin-top: 10px; padding: 8px 15px; margin-right: 8px; font-size: inherit; background-color: #9954bb; }
24-
.action-bar #created-modified-date p { text-align: right; margin-top: 10px; padding-top: 5px; }
24+
.action-bar #breadcrumb-nav > .label-info { padding: 8px 15px; margin-right: 8px; font-size: inherit; background-color: #9954bb; }
25+
.action-bar #doc-controls { text-align: right; padding-top: 5px; }
26+
.action-bar #doc-controls .btn-edit { margin-top: -5px; margin-left: 10px; }
2527
.action-bar p.alert { margin-bottom: 0; }
2628
.nav-header.btn { color: inherit; }
2729
ul.dropdown-menu { max-height: 26em; overflow-x: hidden; overflow-y: auto; }

src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/block.xsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ exclude-result-prefixes="#all"
115115

116116
<!-- TEMPLATES -->
117117

118-
<!-- render block -->
118+
<!-- render row -->
119119

120120
<!-- match resources that are not LDH system resources -->
121121
<xsl:template match="*[@typeof[not(. = ('&ldh;Object', '&ldh;View', '&ldh;GraphChart', '&ldh;ResultSetChart'))]]" mode="ldh:RenderRow" priority="1">
@@ -181,7 +181,7 @@ exclude-result-prefixes="#all"
181181

182182
<xsl:template match="div[following-sibling::div[@typeof = ('&ldh;XHTML', '&ldh;Object')]]//button[contains-token(@class, 'btn-edit')][not(contains-token(@class, 'disabled'))]" mode="ixsl:onclick" priority="1">
183183
<xsl:param name="block" select="ancestor::div[contains-token(@class, 'block')][1]" as="element()"/>
184-
<!-- for content types, button.btn-edit is placed in its own div.row-fluid, therefore the next row is the actual container -->
184+
<!-- for block types, button.btn-edit is placed in its own div.row-fluid, therefore the next row is the actual container -->
185185
<xsl:param name="container" select="$block/descendant::div[@typeof][1]" as="element()"/> <!-- other resources can be nested within object -->
186186

187187
<xsl:next-match>

src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/block/query.xsl

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ exclude-result-prefixes="#all"
361361
<xsl:variable name="textarea" select="ancestor::form/descendant::textarea[@name = 'query']" as="element()"/>
362362
<xsl:variable name="yasqe" select="ixsl:get(ixsl:get(ixsl:window(), 'LinkedDataHub.yasqe'), $textarea/ixsl:get(., 'id'))"/>
363363
<xsl:variable name="query-string" select="ixsl:call($yasqe, 'getValue', [])" as="xs:string?"/> <!-- get query string from YASQE -->
364+
<xsl:variable name="method" select="'PATCH'" as="xs:string"/>
364365
<xsl:variable name="action" select="ac:absolute-path(ldh:base-uri(.))" as="xs:anyURI"/>
365366
<xsl:variable name="accept" select="'application/rdf+xml'" as="xs:string"/>
366367
<xsl:variable name="etag" select="ixsl:get(ixsl:get(ixsl:get(ixsl:window(), 'LinkedDataHub.contents'), '`' || ac:absolute-path(ldh:base-uri(.)) || '`'), 'etag')" as="xs:string"/>
@@ -377,7 +378,7 @@ exclude-result-prefixes="#all"
377378
</xsl:apply-templates>
378379
</xsl:variable>
379380
<xsl:variable name="triples" select="ldh:descriptions-to-triples($query)" as="element()*"/>
380-
<xsl:variable name="update-string" select="ldh:triples-to-sparql-update($about, $triples)" as="xs:string"/>
381+
<xsl:variable name="update-string" select="ldh:insertdelete-update(ldh:triples-to-bgp(ldh:uri-po-pattern($about)), ldh:triples-to-bgp($triples), ldh:triples-to-bgp(ldh:uri-po-pattern($about)))" as="xs:string"/>
381382
<xsl:variable name="resources" as="document-node()">
382383
<xsl:document>
383384
<rdf:RDF>
@@ -386,19 +387,21 @@ exclude-result-prefixes="#all"
386387
</xsl:document>
387388
</xsl:variable>
388389
<xsl:variable name="request-uri" select="ldh:href($ldt:base, ac:absolute-path(ldh:base-uri(.)), map{}, $action)" as="xs:anyURI"/>
389-
390-
<xsl:variable name="request" as="item()*">
391-
<!-- If-Match header checks preconditions, i.e. that the graph has not been modified in the meanwhile -->
392-
<ixsl:schedule-action http-request="map{ 'method': 'PATCH', 'href': $request-uri, 'media-type': 'application/sparql-update', 'body': $update-string, 'headers': map{ 'If-Match': $etag, 'Accept': 'application/rdf+xml', 'Cache-Control': 'no-cache' } }">
393-
<xsl:call-template name="ldh:ResourceUpdated">
394-
<xsl:with-param name="doc-uri" select="ac:absolute-path(ldh:base-uri(.))"/>
395-
<xsl:with-param name="block" select="$block"/>
396-
<!-- <xsl:with-param name="container" select="$container"/>-->
397-
<xsl:with-param name="resources" select="$resources"/>
398-
</xsl:call-template>
399-
</ixsl:schedule-action>
400-
</xsl:variable>
401-
<xsl:sequence select="$request[current-date() lt xs:date('2000-01-01')]"/>
390+
<!-- If-Match header checks preconditions, i.e. that the graph has not been modified in the meanwhile -->
391+
<xsl:variable name="request" select="map{ 'method': $method, 'href': $request-uri, 'media-type': 'application/sparql-update', 'body': $update-string, 'headers': map{ 'If-Match': $etag, 'Accept': 'application/rdf+xml', 'Cache-Control': 'no-cache' } }" as="map(*)"/>
392+
<xsl:variable name="context" as="map(*)" select="
393+
map{
394+
'request': $request,
395+
'doc-uri': ac:absolute-path(ldh:base-uri(.)),
396+
'block': $block,
397+
'resources': $resources
398+
}"/>
399+
<ixsl:promise select="
400+
ixsl:http-request($context('request')) (: Step 1: send initial request :)
401+
=> ixsl:then(ldh:rethread-response($context, ?)) (: Step 2: attach response to context :)
402+
=> ixsl:then(ldh:handle-response#1) (: Step 3: handle 429s, etc. :)
403+
=> ixsl:then(ldh:row-form-patch-response#1)
404+
"/>
402405
</xsl:template>
403406

404407
<!-- open query onclick -->

0 commit comments

Comments
 (0)