blob: fecfbcf69532afedecbf23d4d60d699a772ee92b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
(ns org-ckons-cljs.form.react
(:require-macros [clojure.string :as str]))
(defn react-generic-form [jsonobj namespace onclick-fn]
[:div
[:div {:id "form-errormsg"}]
[:form {:name (get jsonobj "name")
:id (get jsonobj "name")
:method (get jsonobj "httpMethod")
:action (when (get jsonobj "action")
(str "javascript:" namespace "." (get jsonobj "action")))}
(for [form-field (get jsonobj "formFields")]
(cond (= (get form-field "fieldType") "button")
[:div {:class "form-group row"}
[:div {:class "offset-sm-2 col-sm-10"}
[:button {:class "btn btn-primary"
:data-dismiss (get jsonobj "dismiss")
:type (cond (get form-field "onclick") "button" :else "submit")
:on-click onclick-fn}
(get form-field "label")]]]
(= (get form-field "fieldType") "hidden")
[:input {:name (get form-field "name")
:id (get form-field "name")
:value (get form-field "value")
:type (get form-field "fieldType")}]
(= (get form-field "fieldType") "checkbox")
[:div {:class "form-check form-check-inline"}
[:input {:type "checkbox"
:class "form-check-input"
:id (get form-field "name")
:value (get form-field "value")
:checked (get form-field "checked")
:required (get form-field "required")}]
(when (get form-field "label")
[:label {:class "form-check-label"
:for (get form-field "name")}
(get form-field "label")
(when (get form-field "required")
" *")])]
(= (get form-field "fieldType") "select")
[:div {:class "form-group"}
[:label {:for (get form-field "name")}
(get form-field "label")
(when (get form-field "required")
" *")]
[:select {:class "form-control"
:name (get form-field "name")
:id (get form-field "name")
:required (get form-field "required")
:onchange (when (get form-field "onchange")
(str namespace "." (get form-field "onchange")))}
(for [option (get form-field "options")]
[:option {:value (get option "value")
:selected (when (= (get option "value") (get form-field "value"))
"selected")}
(get option "label")])]]
(= (get form-field "fieldType") "textarea")
[:div {:class "form-group row"}
(when (get form-field "label")
[:label {:for (get form-field "name")
:class "col-form-label col-sm-2"
:style {:text-align "right"}}
(get form-field "label")
(when (get form-field "required")
" *")])
[:div {:class "col-sm-10"}
[:textarea {:class "form-control"
:name (get form-field "name")
:id (get form-field "name")
:rows "10"
:cols "80"
:required (get form-field "required")}
(get form-field "value")]]]
(= (get form-field "fieldType") "ckeditor")
[:div {:class "form-group row"}
(when (get form-field "label")
[:label {:for (get form-field "name")
:class "col-form-label col-sm-2"
:style {:text-align "right"}}
(get form-field "label")
(when (get form-field "required")
" *")])
[:div {:class "col-sm-10"}
[:textarea {:name (get form-field "name")
:id (get form-field "name")}
(get form-field "value")]]]
(= (get form-field "fieldType") "datetime-local")
[:div {:class "form-group row"}
(when (get form-field "label")
[:label {:for (get form-field "name")
:class "col-form-label col-sm-2"
:style {:text-align "right"}}
(get form-field "label")
(when (get form-field "required")
" *")])
[:div {:class "col-sm-10"}
[:input {:name (get form-field "name")
:id (get form-field "name")
:value (get form-field "value")
:type (get form-field "fieldType")
:class "form-control"
:required (get form-field "required")
:min "2018-01-01T00:00"
:max "2020:12-31T23:59"}]]]
(= (get form-field "fieldType") "file")
[:div {:class "form-group row"}
(when (get form-field "label")
[:label {:for (get form-field "name")
:class "col-form-label col-sm-2"
:style {:text-align "right"}}
(get form-field "label")
(when (get form-field "required")
" *")])
[:div {:class "col-sm-10"}
[:input {:name (get form-field "name")
:id (get form-field "name")
:type (get form-field "fieldType")
:class "form-control-file"
:required (get form-field "required")}]]]
:else
[:div {:class "form-group row"}
(when (get form-field "label")
[:label {:for (get form-field "name")
:class "col-form-label col-sm-2"
:style {:text-align "right"}}
(get form-field "label")
(when (get form-field "required")
" *")])
[:div {:class "col-sm-10"}
[:input {:name (get form-field "name")
:id (get form-field "name")
:value (get form-field "value")
:type (get form-field "fieldType")
:class "form-control"
:required (get form-field "required")}]]]))]
(when (get jsonobj "requiredP")
[:div "* Required"])])
|