Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-webui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-webui
Commits
b366bf50
Verified
Commit
b366bf50
authored
3 years ago
by
Timm Fitschen
Browse files
Options
Downloads
Patches
Plain Diff
WIP: fix SELECT id ...
parent
c2dc8e9e
No related branches found
No related tags found
2 merge requests
!47
Release v0.4.0
,
!45
fix SELECT id ...
Pipeline
#15058
failed
3 years ago
Stage: linting
Stage: test
Stage: deploy
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/core/xsl/query.xsl
+22
-9
22 additions, 9 deletions
src/core/xsl/query.xsl
test/core/js/modules/entity.xsl.js
+3
-2
3 additions, 2 deletions
test/core/js/modules/entity.xsl.js
test/core/js/modules/query.xsl.js
+43
-8
43 additions, 8 deletions
test/core/js/modules/query.xsl.js
with
68 additions
and
19 deletions
src/core/xsl/query.xsl
+
22
−
9
View file @
b366bf50
...
...
@@ -223,15 +223,28 @@
<xsl:value-of
select=
"$field-name"
/>
</xsl:attribute>
<div
class=
"caosdb-f-property-value caosdb-v-property-value"
>
<xsl:apply-templates
select=
"/Response/*[@id=$entity-id and Version/@id=$version-id]"
mode=
"walk-select-segments"
>
<!--<xsl:apply-templates select="/Response/*[@id=$entity-id]" mode="walk-select-segments">-->
<xsl:with-param
name=
"first-segment"
>
<xsl:value-of
select=
"substring-before(concat($field-name, '.'), '.')"
/>
</xsl:with-param>
<xsl:with-param
name=
"next-segments"
>
<xsl:value-of
select=
"substring-after($field-name, '.')"
/>
</xsl:with-param>
</xsl:apply-templates>
<xsl:choose>
<xsl:when
test=
"$version-id!=''"
>
<xsl:apply-templates
select=
"/Response/*[@id=$entity-id and Version/@id=$version-id]"
mode=
"walk-select-segments"
>
<xsl:with-param
name=
"first-segment"
>
<xsl:value-of
select=
"substring-before(concat($field-name, '.'), '.')"
/>
</xsl:with-param>
<xsl:with-param
name=
"next-segments"
>
<xsl:value-of
select=
"substring-after($field-name, '.')"
/>
</xsl:with-param>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates
select=
"/Response/*[@id=$entity-id]"
mode=
"walk-select-segments"
>
<xsl:with-param
name=
"first-segment"
>
<xsl:value-of
select=
"substring-before(concat($field-name, '.'), '.')"
/>
</xsl:with-param>
<xsl:with-param
name=
"next-segments"
>
<xsl:value-of
select=
"substring-after($field-name, '.')"
/>
</xsl:with-param>
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
</div>
</td>
</xsl:template>
...
...
This diff is collapsed.
Click to expand it.
test/core/js/modules/entity.xsl.js
+
3
−
2
View file @
b366bf50
...
...
@@ -317,7 +317,7 @@ function applyTemplates(xml, xsl, mode, select = "*") {
return
xslt
(
xml
,
modXsl
);
}
function
callTemplate
(
xsl
,
template
,
params
,
wrap_call
)
{
function
callTemplate
(
xsl
,
template
,
params
,
wrap_call
,
root
)
{
let
entryRuleStart
=
'
<xsl:call-template name="
'
+
template
+
'
">
'
;
let
entryRuleEnd
=
'
</xsl:call-template>
'
;
var
entryRule
=
entryRuleStart
;
...
...
@@ -331,5 +331,6 @@ function callTemplate(xsl, template, params, wrap_call) {
entryRule
=
'
<xsl:template xmlns="http://www.w3.org/1999/xhtml" priority="9" match="/">
'
+
entryRule
+
'
</xsl:template>
'
;
let
modXsl
=
injectTemplate
(
xsl
,
entryRule
);
return
xslt
(
str2xml
(
'
<root/>
'
),
modXsl
);
root
=
root
||
'
<root/>
'
;
return
xslt
(
str2xml
(
root
),
modXsl
);
}
This diff is collapsed.
Click to expand it.
test/core/js/modules/query.xsl.js
+
43
−
8
View file @
b366bf50
...
...
@@ -28,19 +28,25 @@ QUnit.module("query.xsl", {
// load query.xsl
var
done
=
assert
.
async
();
var
qunit_obj
=
this
;
$
.
ajax
({
cache
:
true
,
dataType
:
'
xml
'
,
url
:
"
xsl/query.xsl
"
,
}).
done
(
function
(
data
,
textStatus
,
jdXHR
)
{
insertParam
(
data
,
"
entitypath
"
,
"
/entitypath/
"
);
qunit_obj
.
queryXSL
=
data
;
}).
always
(
function
()
{
_retrieveQueryXSL
().
then
(
function
(
xsl
)
{
qunit_obj
.
queryXSL
=
xsl
;
done
();
});
}
});
async
function
_retrieveQueryXSL
()
{
var
queryXsl
=
await
transformation
.
retrieveXsltScript
(
"
query.xsl
"
);
var
entityXsl
=
await
transformation
.
retrieveXsltScript
(
"
entity.xsl
"
);
var
commonXsl
=
await
transformation
.
retrieveXsltScript
(
"
common.xsl
"
);
var
xsl
=
transformation
.
mergeXsltScripts
(
entityXsl
,
[
commonXsl
,
queryXsl
]);
insertParam
(
xsl
,
"
entitypath
"
,
"
/entitypath/
"
);
insertParam
(
xsl
,
"
filesystempath
"
,
"
/filesystempath/
"
);
insertParam
(
xsl
,
"
lowercase
"
,
"
abcdefghijklmnopqrstuvwxyz
"
);
insertParam
(
xsl
,
"
uppercase
"
,
"
ABCDEFGHIJKLMNOPQRSTUVWXYZ
"
);
return
xsl
;
}
/* TESTS */
QUnit
.
test
(
"
availability
"
,
function
(
assert
)
{
assert
.
ok
(
this
.
queryXSL
);
...
...
@@ -183,6 +189,35 @@ QUnit.test("template select-table-row ", function(assert){
assert
.
equal
(
next
.
tagName
,
"
A
"
,
"
tagName = A
"
);
});
QUnit
.
test
(
"
template select-table-cell (with version)
"
,
function
(
assert
){
let
cell
=
callTemplate
(
this
.
queryXSL
,
"
select-table-cell
"
,
{
"
version-id
"
:
"
vid-2345
"
,
"
entity-id
"
:
"
eid-1234
"
,
"
field-name
"
:
"
name
"
},
(
x
)
=>
`<table><tbody><tr>
${
x
}
</tr></tbody></table>`
,
`<Response><Entity id="eid-1234" name="the-name"><Version id="vid-2345"/></Entity></Response>`
);
var
next
=
cell
.
firstElementChild
;
assert
.
equal
(
next
.
tagName
,
"
TABLE
"
,
"
tagName = TABLE
"
);
next
=
next
.
firstElementChild
;
assert
.
equal
(
next
.
tagName
,
"
TBODY
"
,
"
tagName = TBODY
"
);
next
=
next
.
firstElementChild
;
assert
.
equal
(
next
.
tagName
,
"
TR
"
,
"
tagName = TR
"
);
next
=
next
.
firstElementChild
;
assert
.
equal
(
next
.
tagName
,
"
TD
"
,
"
tagName = TD
"
);
next
=
next
.
textContent
;
assert
.
equal
(
next
,
"
eid-1234
"
,
"
id = eid-1234
"
);
});
QUnit
.
test
(
"
template select-table-cell (id only)
"
,
function
(
assert
){
let
cell
=
callTemplate
(
this
.
queryXSL
,
"
select-table-cell
"
,
{
"
entity-id
"
:
"
eid-1234
"
,
"
field-name
"
:
"
id
"
},
(
x
)
=>
`<table><tbody><tr>
${
x
}
</tr></tbody></table>`
,
`<Response><Entity id="eid-1234"/></Response>`
);
var
next
=
cell
.
firstElementChild
;
assert
.
equal
(
next
.
tagName
,
"
TABLE
"
,
"
tagName = TABLE
"
);
next
=
next
.
firstElementChild
;
assert
.
equal
(
next
.
tagName
,
"
TBODY
"
,
"
tagName = TBODY
"
);
next
=
next
.
firstElementChild
;
assert
.
equal
(
next
.
tagName
,
"
TR
"
,
"
tagName = TR
"
);
next
=
next
.
firstElementChild
;
assert
.
equal
(
next
.
tagName
,
"
TD
"
,
"
tagName = TD
"
);
next
=
next
.
textContent
;
assert
.
equal
(
next
,
"
eid-1234
"
,
"
id = eid-1234
"
);
});
/* MISC FUNCTIONS */
function
getQueryForm
(
queryXSL
)
{
var
html
=
callTemplate
(
queryXSL
,
"
caosdb-query-panel
"
,
{});
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment