Skip to content

Commit 2f0cdf3

Browse files
local binding and updating of values works
1 parent aa623d3 commit 2f0cdf3

29 files changed

+1215
-1141
lines changed

.idea/workspace.xml

+472-638
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

controller.xql

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ else if ($exist:path = "/") then
2323
<redirect url="index.html"/>
2424
</dispatch>
2525

26+
else if (ends-with($exist:path, ".json")) then
27+
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
28+
<cache-control cache="yes"/>
29+
</dispatch>
2630
else if (starts-with($exist:path, "/demo/")) then
2731
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
2832
<forward url="{$exist:controller}/modules/load-form.xql" method="get">

demo/helloworld.html

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8"/>
5+
<meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes"/>
6+
7+
<title>Hello World</title>
8+
9+
<script src="../assets/@webcomponents/webcomponentsjs/webcomponents-loader.js"> </script>
10+
<script type="module" src="../elements/xf-form.js"> </script>
11+
<script type="module" src="../elements/xf-output.js"> </script>
12+
13+
<style>
14+
xf-model{
15+
display:none;
16+
}
17+
xf-output{
18+
color:blue;
19+
}
20+
</style>
21+
</head>
22+
<body>
23+
<!-- ##### xf-model is not exposed to the client! ##### -->
24+
<xf-model id="record">
25+
26+
<xf-instance>
27+
<data>
28+
<greeting>World!</greeting>
29+
</data>
30+
</xf-instance>
31+
32+
<xf-bind id="b-greeting" ref="greeting"> </xf-bind>
33+
34+
</xf-model>
35+
36+
37+
<xf-form mockup='[
38+
{
39+
"bind":{
40+
"id":"b-greeting",
41+
"required":true,
42+
"value":"World"
43+
}
44+
}
45+
]'>
46+
<h1>Hello <xf-output id="output" bind="b-greeting"></xf-output></h1>
47+
48+
<label for="greeting">Greeting:</label>
49+
<input id="greeting" bind="b-greeting" type="text" incremental="incremental"/>
50+
51+
<!--
52+
<xf-button>
53+
<xf-setvalue bind="b-greeting" value="foobar"></xf-setvalue>
54+
</xf-button>
55+
-->
56+
</xf-form>
57+
</body>
58+
</html>

demo/todo.html

+71-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!DOCTYPE html>
12
<html lang="en">
23
<head>
34
<meta charset="utf-8"/>
@@ -8,6 +9,9 @@
89
<script src="../assets/@webcomponents/webcomponentsjs/webcomponents-loader.js"/>
910
<script type="module" src="../elements/xf-form.js"></script>
1011
<script type="module" src="../elements/xf-repeat.js"></script>
12+
<script type="module" src="../elements/xf-button.js"></script>
13+
<script type="module" src="../elements/xf-append.js"></script>
14+
<script type="module" src="../elements/xf-submit.js"></script>
1115

1216
<script>
1317
function append() {
@@ -21,6 +25,10 @@
2125
</script>
2226

2327
<style>
28+
xf-model{
29+
display:none;
30+
}
31+
2432
.header, .repeat-item{
2533
display:grid;
2634
grid-template-columns: 200px 120px 50px 20px;
@@ -32,7 +40,7 @@
3240
</style>
3341
</head>
3442
<body>
35-
<!-- xf-model is not exposed to the client! -->
43+
<!-- ##### xf-model is not exposed to the client! ##### -->
3644
<xf-model id="record">
3745
<xf-instance>
3846
<data>
@@ -65,22 +73,65 @@
6573
</xf-submit-error>
6674
<xf-submit-done>
6775
<!-- start over -->
68-
<xf-load url="seed-form.html"/>
76+
<xf-load url="seed-form.html"></xf-load>
6977
<xf-message level="ephemeral">Your data have been stored</xf-message>
7078
</xf-submit-done>
7179
</xf-submission>
7280

7381
</xf-model>
7482

7583

76-
<xf-form>
84+
<xf-form mockup='[
85+
{
86+
"bind": {
87+
"id": "b-todo",
88+
"bind": [
89+
[
90+
{
91+
"id": "b-task",
92+
"required": true,
93+
"value": "Pick up Milk"
94+
},
95+
{
96+
"id": "b-state",
97+
"type": "boolean",
98+
"value": false
99+
},
100+
{
101+
"id": "b-due",
102+
"type": "date",
103+
"value": "2019-03-01"
104+
}
105+
],
106+
[
107+
{
108+
"id": "b-task",
109+
"required": true,
110+
"value": "Make tutorial part"
111+
},
112+
{
113+
"id": "b-state",
114+
"type": "boolean",
115+
"value": true
116+
},
117+
{
118+
"id": "b-due",
119+
"type": "date",
120+
"value": "2019-04-01"
121+
}
122+
]
123+
]
124+
}
125+
}
126+
]'>
77127
<h1>todos</h1>
78128

79129
<div class="header">
80130
<span>todo</span>
81131
<span>due</span>
82132
<span>status</span>
83133
</div>
134+
<!--
84135
<xf-repeat id="r-todos" bind="b-todo">
85136
<template>
86137
<div>
@@ -91,7 +142,23 @@ <h1>todos</h1>
91142
</div>
92143
</template>
93144
</xf-repeat>
94-
<button type="button" onclick="append();">add</button>
145+
-->
146+
147+
<!-- <button type="button" onclick="append();">add</button>-->
148+
149+
150+
<xf-button label="set task to 'foo'">
151+
<xf-setvalue bind="b-task" value="'foo'"> </xf-setvalue>
152+
</xf-button>
153+
154+
<xf-button label="add todo">
155+
<xf-append bind="b-todo"> </xf-append>
156+
<!-- +++ immediately save changes +++ -->
157+
<xf-submit submission="s-save"> </xf-submit>
158+
</xf-button>
159+
160+
161+
95162
</xf-form>
96163
</body>
97164
</html>

demo/todo.json

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[
22
{
33
"bind": {
4-
"id": "todo",
4+
"id": "b-todo",
55
"bind": [
66
[
77
{
88
"id": "b-task",
99
"required": true,
10-
"value":"Pick up Milk"
10+
"value": "Pick up Milk"
1111
},
1212
{
1313
"id": "b-state",
@@ -16,14 +16,15 @@
1616
},
1717
{
1818
"id": "b-due",
19-
"type": "date"
19+
"type": "date",
20+
"value": "2019-03-01"
2021
}
2122
],
2223
[
2324
{
2425
"id": "b-task",
2526
"required": true,
26-
"value":"Make tutorial part"
27+
"value": "Make tutorial part"
2728
},
2829
{
2930
"id": "b-state",
@@ -32,7 +33,8 @@
3233
},
3334
{
3435
"id": "b-due",
35-
"type": "date"
36+
"type": "date",
37+
"value": "2019-04-01"
3638
}
3739
]
3840
]

demo/todo2.json

-46
This file was deleted.

demo/todo3.json

-42
This file was deleted.

0 commit comments

Comments
 (0)