Skip to content

Commit b0235f0

Browse files
committed
Modal editing form for the document resource
1 parent 15384fc commit b0235f0

6 files changed

Lines changed: 106 additions & 27 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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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/form.xsl

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<!ENTITY http "http://www.w3.org/2011/http#">
1212
<!ENTITY ldt "https://www.w3.org/ns/ldt#">
1313
<!ENTITY dh "https://www.w3.org/ns/ldt/document-hierarchy#">
14+
<!ENTITY acl "http://www.w3.org/ns/auth/acl#">
1415
<!ENTITY cert "http://www.w3.org/ns/auth/cert#">
1516
<!ENTITY sd "http://www.w3.org/ns/sparql-service-description#">
1617
<!ENTITY sh "http://www.w3.org/ns/shacl#">
@@ -38,8 +39,10 @@ xmlns:rdfs="&rdfs;"
3839
xmlns:dct="&dct;"
3940
xmlns:typeahead="&typeahead;"
4041
xmlns:ldt="&ldt;"
42+
xmlns:acl="&acl;"
4143
xmlns:sd="&sd;"
4244
xmlns:sh="&sh;"
45+
xmlns:sioc="&sioc;"
4346
xmlns:spin="&spin;"
4447
xmlns:bs2="http://graphity.org/xsl/bootstrap/2.3.2"
4548
extension-element-prefixes="ixsl"
@@ -103,6 +106,19 @@ WHERE
103106
<!-- hide constraint violations and HTTP responses in the form - they are displayed as errors on the edited resources -->
104107
<xsl:template match="*[rdf:type/@rdf:resource = ('&spin;ConstraintViolation', '&sh;ValidationResult', '&sh;ValidationReport', '&http;Response')]" mode="bs2:Form" priority="3"/>
105108

109+
<!-- hide the system properties of document resources (they are set automatically by LinkedDataHub) -->
110+
<xsl:template match="*[rdf:type/@rdf:resource = ('&def;Root', '&dh;Container', '&dh;Item')]/dct:created | *[rdf:type/@rdf:resource = ('&def;Root', '&dh;Container', '&dh;Item')]/dct:modified | *[rdf:type/@rdf:resource = ('&def;Root', '&dh;Container', '&dh;Item')]/sioc:has_container | *[rdf:type/@rdf:resource = ('&def;Root', '&dh;Container', '&dh;Item')]/sioc:has_parent | *[rdf:type/@rdf:resource = ('&def;Root', '&dh;Container', '&dh;Item')]/dct:creator | *[rdf:type/@rdf:resource = ('&def;Root', '&dh;Container', '&dh;Item')]/acl:owner | *[rdf:type/@rdf:resource = ('&def;Root', '&dh;Container', '&dh;Item')]/rdf:*[starts-with(local-name(), '_')]" mode="bs2:FormControl" priority="1">
111+
<xsl:apply-templates select="." mode="xhtml:Input">
112+
<xsl:with-param name="type" select="'hidden'"/>
113+
</xsl:apply-templates>
114+
<xsl:apply-templates select="node() | @rdf:resource | @rdf:nodeID" mode="xhtml:Input">
115+
<xsl:with-param name="type" select="'hidden'"/>
116+
</xsl:apply-templates>
117+
<xsl:apply-templates select="@xml:lang | @rdf:datatype" mode="xhtml:Input">
118+
<xsl:with-param name="type" select="'hidden'"/>
119+
</xsl:apply-templates>
120+
</xsl:template>
121+
106122
<!-- canonicalize XML in rdf:XMLLiterals -->
107123
<xsl:template match="json:string[@key = 'object'][ends-with(., '^^&rdf;XMLLiteral')]" mode="ldh:CanonicalizeXML" priority="1">
108124
<xsl:copy>
@@ -189,7 +205,7 @@ WHERE
189205
<ixsl:set-attribute name="type" select="'text'"/>
190206

191207
<xsl:variable name="timezone" select="ixsl:get(following-sibling::input[contains-token(@class, 'input-timezone')], 'value')" as="xs:string"/>
192-
<!--TO-DO: handle invalid timezone values -->
208+
<!-- concatenate datetime-local value together with timezone TO-DO: handle invalid timezone values -->
193209
<xsl:variable name="timezoned-value" select="xs:dateTime(ixsl:get(., 'value') || $timezone)" as="xs:dateTime"/>
194210
<ixsl:set-property name="value" select="$timezoned-value" object="."/>
195211
</xsl:template>
@@ -264,9 +280,9 @@ WHERE
264280
<xsl:sequence select="ixsl:call(ixsl:event(), 'preventDefault', [])"/>
265281
<ixsl:set-style name="cursor" select="'progress'" object="ixsl:page()//body"/>
266282

267-
<xsl:if test="ixsl:contains(ixsl:get(ixsl:window(), 'LinkedDataHub.contents'), '`' || ac:absolute-path(ldh:base-uri(.)) || '`')">
283+
<!-- <xsl:if test="ixsl:contains(ixsl:get(ixsl:window(), 'LinkedDataHub.contents'), '`' || ac:absolute-path(ldh:base-uri(.)) || '`')">
268284
<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"/>
269-
</xsl:if>
285+
</xsl:if>-->
270286
<xsl:if test="not(ixsl:contains(ixsl:get(ixsl:window(), 'LinkedDataHub.contents'), '`' || $about || '`'))">
271287
<ixsl:set-property name="{'`' || $about || '`'}" select="ldh:new-object()" object="ixsl:get(ixsl:window(), 'LinkedDataHub.contents')"/>
272288
</xsl:if>
@@ -275,11 +291,10 @@ WHERE
275291

276292
<!-- if the URI is external, dereference it through the proxy -->
277293
<xsl:variable name="request-uri" select="ldh:href($ldt:base, ac:absolute-path(ldh:base-uri(.)), map{}, ac:absolute-path(ldh:base-uri(.)), $graph, ())" as="xs:anyURI"/>
278-
279294
<xsl:variable name="request" as="item()*">
280295
<!-- If-Match header checks preconditions, i.e. that the graph has not been modified in the meanwhile -->
281296
<ixsl:schedule-action http-request="map{ 'method': 'GET', 'href': $request-uri, 'headers': map{ 'Accept': 'application/rdf+xml' } }">
282-
<xsl:call-template name="ldh:LoadEditedDocument">
297+
<xsl:call-template name="ldh:LoadEditedResource">
283298
<xsl:with-param name="block" select="$block"/>
284299
<xsl:with-param name="about" select="$about"/>
285300
</xsl:call-template>
@@ -288,7 +303,7 @@ WHERE
288303
<xsl:sequence select="$request[current-date() lt xs:date('2000-01-01')]"/>
289304
</xsl:template>
290305

291-
<xsl:template name="ldh:LoadEditedDocument">
306+
<xsl:template name="ldh:LoadEditedResource">
292307
<xsl:context-item as="map(*)" use="required"/>
293308
<xsl:param name="block" as="element()"/>
294309
<xsl:param name="about" as="xs:anyURI"/>

src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/imports/dct.xsl

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,21 @@ xmlns:dct="&dct;"
2525
xmlns:bs2="http://graphity.org/xsl/bootstrap/2.3.2"
2626
exclude-result-prefixes="#all">
2727

28+
<xsl:preserve-space elements="dct:description"/>
29+
30+
<xsl:template match="dct:description/text()" mode="bs2:FormControl">
31+
<xsl:param name="type-label" select="true()" as="xs:boolean"/>
32+
<xsl:param name="rows" select="10" as="xs:integer"/>
33+
34+
<textarea name="ol" id="{generate-id()}" rows="{$rows}">
35+
<xsl:value-of select="."/>
36+
</textarea>
2837

29-
<!-- hide the dct:created/dct:modified properties of graph resources (dct:modified is set automatically by the Graph Store) -->
30-
<xsl:template match="*[rdf:type/@rdf:resource = ('&def;Root', '&dh;Container', '&dh;Item')]/dct:created | *[rdf:type/@rdf:resource = ('&def;Root', '&dh;Container', '&dh;Item')]/dct:modified | *[rdf:type/@rdf:resource = ('&adm;Root', '&dh;Container', '&dh;Item')]/dct:created | *[rdf:type/@rdf:resource = ('&adm;Root', '&dh;Container', '&dh;Item')]/dct:modified" mode="bs2:FormControl" priority="1">
31-
<xsl:apply-templates select="." mode="xhtml:Input">
32-
<xsl:with-param name="type" select="'hidden'"/>
33-
</xsl:apply-templates>
34-
<xsl:apply-templates select="node() | @rdf:resource | @rdf:nodeID" mode="xhtml:Input">
35-
<xsl:with-param name="type" select="'hidden'"/>
36-
</xsl:apply-templates>
37-
<xsl:apply-templates select="@xml:lang | @rdf:datatype" mode="xhtml:Input">
38-
<xsl:with-param name="type" select="'hidden'"/>
39-
</xsl:apply-templates>
38+
<xsl:if test="$type-label">
39+
<xsl:apply-templates select="." mode="bs2:FormControlTypeLabel"/>
40+
</xsl:if>
4041
</xsl:template>
41-
42+
4243
<xsl:template match="dct:format/@rdf:nodeID" mode="bs2:FormControl">
4344
<xsl:param name="id" select="generate-id()" as="xs:string"/>
4445
<xsl:param name="class" as="xs:string?"/>

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -626,11 +626,15 @@ LIMIT 100
626626
<div class="row-fluid">
627627
<xsl:apply-templates select="." mode="bs2:BreadCrumbBar"/>
628628

629-
<div id="created-modified-date" class="span3">
630-
<p>
631-
<xsl:apply-templates select="key('resources', ac:absolute-path(ldh:base-uri(.)))" mode="bs2:Timestamp"/>
632-
</p>
633-
</div>
629+
<div id="doc-controls" class="span3">
630+
<xsl:apply-templates select="key('resources', ac:absolute-path(ldh:base-uri(.)))" mode="bs2:Timestamp"/>
631+
632+
<xsl:if test="$acl:mode = '&acl;Write'">
633+
<button type="button" class="btn btn-edit pull-right">
634+
<xsl:apply-templates select="key('resources', '&ac;EditMode', document(ac:document-uri('&ac;')))" mode="ac:label"/>
635+
</button>
636+
</xsl:if>
637+
</div>
634638
</div>
635639
</div>
636640
</xsl:template>

src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client.xsl

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,6 +1240,63 @@ WHERE
12401240
</xsl:call-template>
12411241
</xsl:template>
12421242

1243+
<!-- open a form form document editing -->
1244+
1245+
<xsl:template match="div[contains-token(@class, 'navbar')]//div[@id = 'doc-controls']//button[contains-token(@class, 'btn-edit')]" mode="ixsl:onclick">
1246+
<xsl:variable name="about" select="ac:absolute-path(ldh:base-uri(.))" as="xs:anyURI"/> <!-- editing the current document resources -->
1247+
<xsl:variable name="graph" as="xs:anyURI?"/>
1248+
1249+
<ixsl:set-style name="cursor" select="'progress'" object="ixsl:page()//body"/>
1250+
1251+
<!-- <xsl:if test="ixsl:contains(ixsl:get(ixsl:window(), 'LinkedDataHub.contents'), '`' || ac:absolute-path(ldh:base-uri(.)) || '`')">
1252+
<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"/>
1253+
</xsl:if>-->
1254+
<xsl:if test="not(ixsl:contains(ixsl:get(ixsl:window(), 'LinkedDataHub.contents'), '`' || $about || '`'))">
1255+
<ixsl:set-property name="{'`' || $about || '`'}" select="ldh:new-object()" object="ixsl:get(ixsl:window(), 'LinkedDataHub.contents')"/>
1256+
</xsl:if>
1257+
1258+
<xsl:variable name="block-id" select="'block-' || generate-id()" as="xs:string"/>
1259+
<xsl:for-each select="ixsl:page()//body">
1260+
<xsl:result-document href="?." method="ixsl:append-content">
1261+
<div class="modal modal-constructor fade in">
1262+
<form class="form-horizontal constructor-template" about="{$about}">
1263+
<div class="modal-header">
1264+
<button type="button" class="close">&#215;</button>
1265+
</div>
1266+
<div class="modal-body" id="{$block-id}">
1267+
<!-- to be injected -->
1268+
</div>
1269+
<div class="form-actions modal-footer">
1270+
<button type="button" class="btn btn-primary btn-save">
1271+
<xsl:value-of>
1272+
<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"/>
1273+
</xsl:value-of>
1274+
</button>
1275+
<button type="button" class="btn btn-close">
1276+
<xsl:value-of>
1277+
<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"/>
1278+
</xsl:value-of>
1279+
</button>
1280+
</div>
1281+
</form>
1282+
</div>
1283+
</xsl:result-document>
1284+
</xsl:for-each>
1285+
1286+
<!-- if the URI is external, dereference it through the proxy -->
1287+
<xsl:variable name="request-uri" select="ldh:href($ldt:base, ac:absolute-path(ldh:base-uri(.)), map{}, ac:absolute-path(ldh:base-uri(.)), $graph, ())" as="xs:anyURI"/>
1288+
<xsl:variable name="request" as="item()*">
1289+
<!-- If-Match header checks preconditions, i.e. that the graph has not been modified in the meanwhile -->
1290+
<ixsl:schedule-action http-request="map{ 'method': 'GET', 'href': $request-uri, 'headers': map{ 'Accept': 'application/rdf+xml' } }">
1291+
<xsl:call-template name="ldh:LoadEditedResource">
1292+
<xsl:with-param name="block" select="id($block-id, ixsl:page())"/>
1293+
<xsl:with-param name="about" select="$about"/>
1294+
</xsl:call-template>
1295+
</ixsl:schedule-action>
1296+
</xsl:variable>
1297+
<xsl:sequence select="$request[current-date() lt xs:date('2000-01-01')]"/>
1298+
</xsl:template>
1299+
12431300
<!-- document mode tabs -->
12441301

12451302
<xsl:template match="div[@id = 'content-body']/div/ul[contains-token(@class, 'nav-tabs')]/li[not(contains-token(@class, 'active'))]/a" mode="ixsl:onclick">

0 commit comments

Comments
 (0)