@@ -5,95 +5,99 @@ declare option exist:serialize "method=xhtml media-type=text/xml indent=yes proc
55let $new := request:get-parameter('new', '')
66let $id := request:get-parameter('id', '')
77let $data-collection := '/db/apps/terms/data'
8-
9- (: Put in the appropriate file name. Use new-instance.xml for new forms and get the data
10- from the data collection for updates. :)
11- let $file := if ($new) then
8+ let $file :=
9+ if ($new ne '') then
1210 'new-instance.xml'
13- else
11+ else
1412 concat('../data/', $id, '.xml')
15-
16- let $form :=
17- <html xmlns="http://www.w3.org/1999/xhtml"
18- xmlns:xf="http://www.w3.org/2002/xforms"
19- xmlns:xs="http://www.w3.org/2001/XMLSchema"
20- xmlns:ev="http://www.w3.org/2001/xml-events" >
21- <head>
22- <title>Edit Item</title>
23- <style type="text/css">
24- <![CDATA[
25- @namespace xf url("http://www.w3.org/2002/xforms");
26-
27- body {
28- font-family: Helvetica, Ariel, Verdana, sans-serif;
29- }
30-
31- .term-name .xforms-value {width: 50ex;}
32- .definition .xforms-value {
33- height: 5em;
34- width: 600px;
35- }
36-
37- /* align the labels but not the save label */
38- xf|output xf|label, xf|input xf|label, xf|textarea xf|label, xf|select1 xf|label {
39- display: inline-block;
40- width: 14ex;
41- text-align: right;
42- vertical-align: top;
43- margin-right: 1ex;
44- font-weight: bold;
45- }
46-
47- xf|input, xf|select1, xf|textarea, xf|ouptut {
48- display: block;
49- margin: 1ex;
50- }
51- ]]>
52- </style>
53- <xf:model>
54- <xf:instance xmlns="" src="{$file}" id="save-data"/>
55- <xf:submission id="save" method="post" action="{if ($new='true') then ('save-new.xq') else ('update.xq')}" instance="my-task" replace="all"/>
56- </xf:model>
57- </head>
58- <body>
59- <h1>Edit Term</h1>
60-
61- {if ($id) then
13+ let $form :=
14+ <html xmlns="http://www.w3.org/1999/xhtml"
15+ xmlns:xf="http://www.w3.org/2002/xforms"
16+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
17+ xmlns:ev="http://www.w3.org/2001/xml-events">
18+ <head>
19+ <title>Edit Item</title>
20+ <style type="text/css">
21+ <![CDATA[
22+ @namespace xf url("http://www.w3.org/2002/xforms");
23+
24+ body {
25+ font-family: Helvetica, Ariel, Verdana, sans-serif;
26+ }
27+
28+ .term-name .xforms-value {width: 50ex;}
29+ .definition .xforms-value {
30+ height: 5em;
31+ width: 600px;
32+ }
33+
34+ /* align the labels but not the save label */
35+ xf|output xf|label, xf|input xf|label, xf|textarea xf|label, xf|select1 xf|label {
36+ display: inline-block;
37+ width: 14ex;
38+ text-align: right;
39+ vertical-align: top;
40+ margin-right: 1ex;
41+ font-weight: bold;
42+ }
43+
44+ xf|input, xf|select1, xf|textarea, xf|ouptut {
45+ display: block;
46+ margin: 1ex;
47+ }
48+ ]]>
49+ </style>
50+ <xf:model>
51+ <xf:instance xmlns="" src="{$file}" id="save-data"/>
52+ <xf:submission id="save" method="post" action="{
53+ if ($new eq 'true') then
54+ 'save-new.xq'
55+ else
56+ 'update.xq'
57+ }" instance="my-task" replace="all"/>
58+ </xf:model>
59+ </head>
60+ <body>
61+ <h1>Edit Term</h1>
62+ {
63+ if ($id) then
6264 <xf:output ref="id" class="id">
6365 <xf:label>ID:</xf:label>
6466 </xf:output>
65- else ()}
66-
67- <xf:input ref="term-name" class="term-name">
68- <xf:label>Term Name:</xf:label>
69- </xf:input>
70-
71- <xf:textarea ref="definition" class="definition">
72- <xf:label>Definition:</xf:label>
73- </xf:textarea>
74-
75- <xf:select1 ref="publish-status-code">
76- <xf:label>Status:</xf:label>
77- <xf:item>
78- <xf:label>Draft</xf:label>
79- <xf:value>draft</xf:value>
80- </xf:item>
81- <xf:item>
82- <xf:label>Under Review</xf:label>
83- <xf:value>review</xf:value>
84- </xf:item>
85- <xf:item>
86- <xf:label>Published</xf:label>
87- <xf:value>published</xf:value>
88- </xf:item>
89- </xf:select1>
90-
91- <xf:submit submission="save">
92- <xf:label>Save</xf:label>
93- </xf:submit>
94- </body>
95- </html>
96-
97- let $xslt-pi := processing-instruction xml-stylesheet {'type="text/xsl" href="/exist/rest/db/xforms/xsltforms/xsltforms.xsl"'}
98-
99- return ($xslt-pi, $form)
67+ else
68+ ()
69+ }
70+ <xf:input ref="term-name" class="term-name">
71+ <xf:label>Term Name:</xf:label>
72+ </xf:input>
73+ <xf:textarea ref="definition" class="definition">
74+ <xf:label>Definition:</xf:label>
75+ </xf:textarea>
76+ <xf:select1 ref="publish-status-code">
77+ <xf:label>Status:</xf:label>
78+ <xf:item>
79+ <xf:label>Draft</xf:label>
80+ <xf:value>draft</xf:value>
81+ </xf:item>
82+ <xf:item>
83+ <xf:label>Under Review</xf:label>
84+ <xf:value>review</xf:value>
85+ </xf:item>
86+ <xf:item>
87+ <xf:label>Published</xf:label>
88+ <xf:value>published</xf:value>
89+ </xf:item>
90+ </xf:select1>
91+ <xf:submit submission="save">
92+ <xf:label>Save</xf:label>
93+ </xf:submit>
94+ </body>
95+ </html>
96+ let $xslt-pi := processing-instruction xml-stylesheet {'type="text/xsl" href="/exist/apps/xsltforms/xsltforms.xsl"'}
97+ return
98+ (
99+ (: Prevent betterFORM (still enabled by default) from intercepting the form, allowing XSLTForms to handle it :)
100+ request:set-attribute("betterform.filter.ignoreResponseBody", "true"),
101+ $xslt-pi,
102+ $form
103+ )
0 commit comments