Skip to content

Commit 11eccd6

Browse files
committed
Client-side ac:mode function
Block dragging fix
1 parent 2488b0a commit 11eccd6

File tree

8 files changed

+34
-33
lines changed

8 files changed

+34
-33
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ exclude-result-prefixes="#all">
103103
<xsl:param name="id" select="concat('form-', generate-id())" as="xs:string?"/>
104104
<xsl:param name="class" select="'row-fluid'" as="xs:string?"/>
105105
<xsl:param name="method" select="'patch'" as="xs:string"/>
106-
<xsl:param name="action" select="ldh:href(ac:build-uri(ac:absolute-path(ldh:base-uri(.)), map{ '_method': 'PUT' }), map{ 'mode': for $mode in $ac:mode return string($mode) })" as="xs:anyURI"/>
106+
<xsl:param name="action" select="ldh:href(ac:build-uri(ac:absolute-path(ldh:base-uri(.)), map{ '_method': 'PUT' }))" as="xs:anyURI"/>
107107
<xsl:param name="enctype" select="'multipart/form-data'" as="xs:string?"/>
108108
<xsl:param name="create-resource" select="true()" as="xs:boolean"/>
109109
<!-- TO-DO: generate ontology classes from the OWL vocabulary -->

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ exclude-result-prefixes="#all"
257257

258258
<!-- start dragging top-level block (or its descendants - necessary for Map and Graph modes to work correctly) -->
259259

260-
<xsl:template match="div[@id = 'content-body']/div[ixsl:query-params()?mode = '&ldh;ContentMode'][@about][contains-token(@class, 'block')]/descendant-or-self::*" mode="ixsl:ondragstart">
260+
<xsl:template match="div[@id = 'content-body']/div[ac:mode() = '&ldh;ContentMode'][@about][contains-token(@class, 'block')]/descendant-or-self::*" mode="ixsl:ondragstart">
261261
<xsl:choose>
262262
<!-- allow drag on the block element (not necessarily top-level) -->
263263
<!-- TO-DO: better condition for checking whether blocks are top-level? -->
@@ -275,18 +275,18 @@ exclude-result-prefixes="#all"
275275

276276
<!-- dragging block over other block -->
277277

278-
<xsl:template match="div[@id = 'content-body']/div[ixsl:query-params()?mode = '&ldh;ContentMode'][@about][contains-token(@class, 'block')][acl:mode() = '&acl;Write']" mode="ixsl:ondragover">
278+
<xsl:template match="div[@id = 'content-body']/div[ac:mode() = '&ldh;ContentMode'][@about][contains-token(@class, 'block')][acl:mode() = '&acl;Write']" mode="ixsl:ondragover">
279279
<xsl:sequence select="ixsl:call(ixsl:event(), 'preventDefault', [])"/>
280280
<ixsl:set-property name="dataTransfer.dropEffect" select="'move'" object="ixsl:event()"/>
281281
</xsl:template>
282282

283283
<!-- change the style of blocks when block is dragged over them -->
284284

285-
<xsl:template match="div[@id = 'content-body']/div[ixsl:query-params()?mode = '&ldh;ContentMode'][@about][contains-token(@class, 'block')][acl:mode() = '&acl;Write']" mode="ixsl:ondragenter">
285+
<xsl:template match="div[@id = 'content-body']/div[ac:mode() = '&ldh;ContentMode'][@about][contains-token(@class, 'block')][acl:mode() = '&acl;Write']" mode="ixsl:ondragenter">
286286
<xsl:sequence select="ixsl:call(ixsl:get(., 'classList'), 'toggle', [ 'drag-over', true() ])[current-date() lt xs:date('2000-01-01')]"/>
287287
</xsl:template>
288288

289-
<xsl:template match="div[@id = 'content-body']/div[ixsl:query-params()?mode = '&ldh;ContentMode'][@about][contains-token(@class, 'block')][acl:mode() = '&acl;Write']" mode="ixsl:ondragleave">
289+
<xsl:template match="div[@id = 'content-body']/div[ac:mode() = '&ldh;ContentMode'][@about][contains-token(@class, 'block')][acl:mode() = '&acl;Write']" mode="ixsl:ondragleave">
290290
<xsl:variable name="related-target" select="ixsl:get(ixsl:event(), 'relatedTarget')" as="element()?"/> <!-- the element drag entered (optional) -->
291291

292292
<!-- only remove class if the related target does not have this div as ancestor (is not its child) -->
@@ -297,11 +297,13 @@ exclude-result-prefixes="#all"
297297

298298
<!-- dropping block over other top-level block -->
299299

300-
<xsl:template match="div[@id = 'content-body']/div[ixsl:query-params()?mode = '&ldh;ContentMode'][@about][contains-token(@class, 'block')][acl:mode() = '&acl;Write']" mode="ixsl:ondrop">
300+
<xsl:template match="div[@id = 'content-body']/div[ac:mode() = '&ldh;ContentMode'][@about][contains-token(@class, 'block')][acl:mode() = '&acl;Write']" mode="ixsl:ondrop">
301301
<xsl:sequence select="ixsl:call(ixsl:event(), 'preventDefault', [])"/>
302302
<xsl:variable name="block-uri" select="@about" as="xs:anyURI?"/>
303303
<xsl:variable name="drop-block-uri" select="ixsl:call(ixsl:get(ixsl:event(), 'dataTransfer'), 'getData', [ 'text/uri-list' ])" as="xs:anyURI"/>
304304

305+
<xsl:message>$drop-block-uri: <xsl:value-of select="$drop-block-uri"/></xsl:message>
306+
305307
<xsl:sequence select="ixsl:call(ixsl:get(., 'classList'), 'toggle', [ 'drag-over', false() ])[current-date() lt xs:date('2000-01-01')]"/>
306308

307309
<!-- only persist the change if the block is already saved and has an @about -->
@@ -310,7 +312,8 @@ exclude-result-prefixes="#all"
310312
<xsl:if test="not($block-uri = $drop-block-uri)">
311313
<ixsl:set-style name="cursor" select="'progress'" object="ixsl:page()//body"/>
312314

313-
<xsl:variable name="drop-block" select="key('element-by-about', $drop-block-uri)" as="element()"/>
315+
<!-- TO-DO: sketchy workaround to select block-level elements only because we might have duplicate @about values -->
316+
<xsl:variable name="drop-block" select="key('element-by-about', $drop-block-uri)[contains-token(@class, 'block')]" as="element()"/>
314317
<xsl:sequence select="ixsl:call(., 'after', [ $drop-block ])"/>
315318
<!-- TO-DO: use a VALUES block instead -->
316319
<xsl:variable name="update-string" select="replace($block-swap-string, '$this', '&lt;' || ac:absolute-path(ldh:base-uri(.)) || '&gt;', 'q')" as="xs:string"/>

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,6 @@ exclude-result-prefixes="#all"
702702
<xsl:variable name="action" select="ac:absolute-path(ldh:base-uri(.))" as="xs:anyURI"/>
703703
<xsl:variable name="accept" select="'application/rdf+xml'" as="xs:string"/>
704704
<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"/>
705-
<!-- not using ldh:base-uri(.) because it goes stale when DOM is replaced -->
706705
<xsl:variable name="doc" select="ixsl:get(ixsl:get(ixsl:get(ixsl:window(), 'LinkedDataHub.contents'), '`' || ac:absolute-path(xs:anyURI(ixsl:location())) || '`'), 'results')" as="document-node()"/>
707706
<xsl:variable name="chart" select="key('resources', $about, $doc)" as="element()"/>
708707
<!-- update the properties on the chart resource -->

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ exclude-result-prefixes="#all"
4343
<xsl:sequence select="ac:document-uri(ixsl:query-params()?uri)"/>
4444
</xsl:when>
4545
<xsl:otherwise>
46-
<xsl:sequence select="ac:document-uri(ixsl:get(ixsl:window(), 'location.href'))"/>
46+
<!-- ignore query params such as ?mode -->
47+
<xsl:sequence select="ac:absolute-path(xs:anyURI(ixsl:location()))"/>
4748
</xsl:otherwise>
4849
</xsl:choose>
4950
</xsl:function>
@@ -61,6 +62,14 @@ exclude-result-prefixes="#all"
6162
)"/>
6263
</xsl:function>
6364

65+
<xsl:function name="ac:mode" as="xs:anyURI*">
66+
<xsl:variable name="doc" select="ixsl:get(ixsl:get(ixsl:get(ixsl:window(), 'LinkedDataHub.contents'), '`' || ac:absolute-path(xs:anyURI(ixsl:location())) || '`'), 'results')" as="document-node()"/>
67+
<xsl:variable name="block-uris" select="key('resources', ac:absolute-path(xs:anyURI(ixsl:location())), $doc)/rdf:*[starts-with(local-name(), '_')]/@rdf:resource" as="xs:anyURI*"/>
68+
<!-- this is an approximation - server-side layout.xsl also checks exists($template-block-uris) which are blocks defined on ontology classes using ldh:template -->
69+
<xsl:variable name="has-content" select="exists($block-uris)" as="xs:boolean"/>
70+
<xsl:sequence select="if (ixsl:query-params()?mode) then for $mode in ixsl:query-params()?mode return xs:anyURI($mode) else (if ($has-content) then xs:anyURI('&ldh;ContentMode') else xs:anyURI('&ac;ReadMode'))"/>
71+
</xsl:function>
72+
6473
<xsl:function name="sd:endpoint" as="xs:anyURI">
6574
<xsl:sequence select="xs:anyURI(ixsl:get(ixsl:window(), 'LinkedDataHub.endpoint'))"/>
6675
</xsl:function>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ extension-element-prefixes="ixsl"
670670
<xsl:template match="rdf:RDF" mode="bs2:Form">
671671
<xsl:param name="method" select="'post'" as="xs:string"/>
672672
<xsl:param name="base-uri" select="ldh:base-uri(.)" as="xs:anyURI" tunnel="yes"/>
673-
<xsl:param name="action" select="ldh:href(ac:absolute-path($base-uri), map{ 'mode': for $mode in $ac:mode return string($mode) })" as="xs:anyURI"/>
673+
<xsl:param name="action" select="ldh:href(ac:absolute-path($base-uri))" as="xs:anyURI"/>
674674
<xsl:param name="id" select="concat('form-', generate-id())" as="xs:string?"/>
675675
<xsl:param name="class" select="'form-horizontal'" as="xs:string?"/>
676676
<xsl:param name="form-actions-class" select="'form-actions'" as="xs:string?"/>

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,18 @@ exclude-result-prefixes="#all">
107107
<xsl:param name="ac:uri" as="xs:anyURI"/>
108108
<xsl:param name="ac:httpHeaders" as="xs:string"/>
109109
<xsl:param name="ac:method" as="xs:string"/>
110-
<xsl:param name="ac:mode" as="xs:anyURI*"/> <!-- select="xs:anyURI('&ac;ReadMode')" -->
111110
<xsl:param name="acl:mode" as="xs:anyURI*"/>
112111
<xsl:param name="ldh:ajaxRendering" select="true()" as="xs:boolean"/>
113112
<xsl:param name="ldhc:enableWebIDSignUp" as="xs:boolean"/>
114113
<xsl:param name="ldh:renderSystemResources" select="false()" as="xs:boolean"/>
115114
<xsl:param name="google:clientID" as="xs:string?"/>
115+
<xsl:param name="doc-types" select="key('resources', ac:absolute-path(ldh:base-uri(.)))/rdf:type/@rdf:resource[ . = ('&def;Root', '&dh;Container', '&dh;Item')]" as="xs:anyURI*"/>
116+
<!-- take care not to load unnecessary documents over HTTP when $doc-types is empty -->
117+
<xsl:param name="template-block-uris" select="if (exists($doc-types)) then (if (doc-available(resolve-uri('ns?query=ASK%20%7B%7D', $ldt:base))) then (ldh:query-result(resolve-uri('ns', $ldt:base), $template-query || ' VALUES $Type { ' || string-join(for $type in $doc-types return '&lt;' || $type || '&gt;', ' ') || ' }')//srx:binding[@name = 'block']/srx:uri/xs:anyURI(.)) else ()) else ()" as="xs:anyURI*"/>
118+
<xsl:param name="block-uris" select="key('resources', ac:absolute-path(ldh:base-uri(.)))/rdf:*[starts-with(local-name(), '_')]/@rdf:resource" as="xs:anyURI*"/>
119+
<!-- document has content when there are are content sequence properties or template-declared class-level blocks exist -->
120+
<xsl:param name="has-content" select="exists($block-uris) or exists($template-block-uris)" as="xs:boolean"/>
121+
<xsl:param name="ac:mode" select="if ($has-content) then xs:anyURI('&ldh;ContentMode') else xs:anyURI('&ac;ReadMode')" as="xs:anyURI*"/>
116122
<xsl:param name="location-mapping" as="map(xs:anyURI, xs:anyURI)">
117123
<xsl:map>
118124
<xsl:map-entry key="resolve-uri('static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/translations.rdf', $ac:contextUri)" select="resolve-uri('static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/translations.rdf', $ac:contextUri)"/>
@@ -810,12 +816,6 @@ LIMIT 100
810816
<xsl:param name="class" select="'container-fluid'" as="xs:string?"/>
811817
<xsl:param name="about" select="ac:absolute-path(ldh:base-uri(.))" as="xs:anyURI?"/>
812818
<xsl:param name="typeof" select="key('resources', ac:absolute-path(ldh:base-uri(.)))/rdf:type/@rdf:resource/xs:anyURI(.)" as="xs:anyURI*"/>
813-
<xsl:param name="doc-types" select="key('resources', ac:absolute-path(ldh:base-uri(.)))/rdf:type/@rdf:resource[ . = ('&def;Root', '&dh;Container', '&dh;Item')]" as="xs:anyURI*"/>
814-
<!-- take care not to load unnecessary documents over HTTP when $doc-types is empty -->
815-
<xsl:param name="template-block-uris" select="if (exists($doc-types)) then (if (doc-available(resolve-uri('ns?query=ASK%20%7B%7D', $ldt:base))) then (ldh:query-result(resolve-uri('ns', $ldt:base), $template-query || ' VALUES $Type { ' || string-join(for $type in $doc-types return '&lt;' || $type || '&gt;', ' ') || ' }')//srx:binding[@name = 'block']/srx:uri/xs:anyURI(.)) else ()) else ()" as="xs:anyURI*"/>
816-
<xsl:param name="block-uris" select="key('resources', ac:absolute-path(ldh:base-uri(.)))/rdf:*[starts-with(local-name(), '_')]/@rdf:resource" as="xs:anyURI*"/>
817-
<!-- document has content when either explicitly declared document-level blocks exist or template-declared class-level blocks exist -->
818-
<xsl:param name="has-content" select="exists(for $block-uri in $block-uris return (if (doc-available(ac:document-uri($block-uri))) then key('resources', $block-uri, document(ac:document-uri($block-uri))) else ())) or exists($template-block-uris)" as="xs:boolean"/>
819819

820820
<div>
821821
<xsl:if test="$id">
@@ -845,8 +845,7 @@ LIMIT 100
845845
<xsl:sort select="ac:label(.)"/>
846846
</xsl:apply-templates>
847847
</xsl:when>
848-
<!-- check if the current document has content or its class has content -->
849-
<xsl:when test="(empty($ac:mode) and $has-content) or $ac:mode = '&ldh;ContentMode'">
848+
<xsl:when test="$ac:mode = '&ldh;ContentMode'">
850849
<xsl:for-each select="$template-block-uris">
851850
<xsl:if test="doc-available(ac:document-uri(.))">
852851
<xsl:apply-templates select="key('resources', ., document(ac:document-uri(.)))" mode="bs2:Row"/>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1092,7 +1092,7 @@ extension-element-prefixes="ixsl"
10921092
<xsl:param name="form-id" select="'form-' || generate-id()" as="xs:string?"/>
10931093
<xsl:param name="method" select="'patch'" as="xs:string"/>
10941094
<xsl:param name="base-uri" select="ldh:base-uri(.)" as="xs:anyURI" tunnel="yes"/>
1095-
<xsl:param name="action" select="ldh:href(ac:absolute-path($base-uri), map{ 'mode': for $mode in $ac:mode return string($mode) })" as="xs:anyURI"/>
1095+
<xsl:param name="action" select="ldh:href(ac:absolute-path($base-uri))" as="xs:anyURI"/>
10961096
<xsl:param name="enctype" select="if ($typeof = '&nfo;FileDataObject') then 'multipart/form-data' else ()" as="xs:string?"/>
10971097
<xsl:param name="button-class" select="'btn btn-primary wymupdate'" as="xs:string?"/>
10981098
<xsl:param name="accept-charset" select="'UTF-8'" as="xs:string?"/>

0 commit comments

Comments
 (0)