Working through getting record creation going
This commit is contained in:
parent
972dfd091e
commit
34552cff4f
|
@ -77,7 +77,7 @@
|
||||||
'if
|
'if
|
||||||
(list
|
(list
|
||||||
'all-keys-present?
|
'all-keys-present?
|
||||||
'params (set (key-names e true)))
|
'params (key-names e true))
|
||||||
(list
|
(list
|
||||||
'support/do-or-log-error
|
'support/do-or-log-error
|
||||||
(list
|
(list
|
||||||
|
@ -138,7 +138,7 @@
|
||||||
:entity
|
:entity
|
||||||
#(= (-> % :attrs :name) f-name))]
|
#(= (-> % :attrs :name) f-name))]
|
||||||
(if (and (entity? entity) (entity? farside))
|
(if (and (entity? entity) (entity? farside))
|
||||||
(list 'if (list 'all-keys-present? 'params (set (key-names entity true)))
|
(list 'if (list 'all-keys-present? 'params (key-names entity true))
|
||||||
(hash-map
|
(hash-map
|
||||||
(keyword (auxlist-data-name auxlist))
|
(keyword (auxlist-data-name auxlist))
|
||||||
(list
|
(list
|
||||||
|
@ -189,7 +189,12 @@
|
||||||
(descendants-with-tag e :property)))
|
(descendants-with-tag e :property)))
|
||||||
(map
|
(map
|
||||||
#(compose-fetch-auxlist-data % e a)
|
#(compose-fetch-auxlist-data % e a)
|
||||||
(descendants-with-tag f :auxlist)))))))
|
(descendants-with-tag f :auxlist))
|
||||||
|
(list
|
||||||
|
(list 'if (list :error 'request)
|
||||||
|
{:error (list :error 'request)})
|
||||||
|
(list 'if (list :message 'request)
|
||||||
|
{:message (list :message 'request)})))))))
|
||||||
|
|
||||||
|
|
||||||
(defn make-page-get-handler-content
|
(defn make-page-get-handler-content
|
||||||
|
@ -248,7 +253,7 @@
|
||||||
(str
|
(str
|
||||||
"db/list-"
|
"db/list-"
|
||||||
(:name (:attrs e))))
|
(:name (:attrs e))))
|
||||||
(symbol "db/*db*") {})
|
(symbol "db/*db*") 'params)
|
||||||
:message (str
|
:message (str
|
||||||
"Error while fetching "
|
"Error while fetching "
|
||||||
(singularise (:name (:attrs e)))
|
(singularise (:name (:attrs e)))
|
||||||
|
@ -311,33 +316,32 @@
|
||||||
'valid-user-or-forbid
|
'valid-user-or-forbid
|
||||||
(list
|
(list
|
||||||
'with-params-or-error
|
'with-params-or-error
|
||||||
(list
|
|
||||||
'do-or-server-fail
|
|
||||||
(list
|
(list
|
||||||
'if
|
'if
|
||||||
(list 'all-keys-present? 'params (key-names e true))
|
(list 'all-keys-present? 'params (key-names e true))
|
||||||
|
(list
|
||||||
|
'do-or-server-fail
|
||||||
(list
|
(list
|
||||||
update-name
|
update-name
|
||||||
'db/*db*
|
'db/*db*
|
||||||
'params)
|
'params)
|
||||||
|
200)
|
||||||
|
(list
|
||||||
|
'do-or-server-fail
|
||||||
(list
|
(list
|
||||||
create-name
|
create-name
|
||||||
'db/*db*
|
'db/*db*
|
||||||
'params))
|
'params)
|
||||||
200) ;; OK
|
201))
|
||||||
'params
|
'params
|
||||||
(set
|
(set
|
||||||
(map
|
(map
|
||||||
#(keyword (:name (:attrs %)))
|
#(keyword (:name (:attrs %)))
|
||||||
(insertable-properties e))))
|
(required-properties e))))
|
||||||
'request))
|
'request))
|
||||||
(list
|
|
||||||
'if
|
|
||||||
(list
|
|
||||||
(set [200 400])
|
|
||||||
(list :status 'result))
|
|
||||||
(list
|
(list
|
||||||
(symbol (handler-name f e a :get))
|
(symbol (handler-name f e a :get))
|
||||||
|
(list 'merge
|
||||||
(list
|
(list
|
||||||
'assoc
|
'assoc
|
||||||
'request
|
'request
|
||||||
|
@ -345,8 +349,11 @@
|
||||||
(list
|
(list
|
||||||
'merge
|
'merge
|
||||||
'params
|
'params
|
||||||
'result)))
|
'result))
|
||||||
'result))))
|
(list 'case (:status 'result)
|
||||||
|
200 {:message "Record stored"}
|
||||||
|
201 (str "Record created: " (list :body 'result))
|
||||||
|
{:error (list :body 'result)}))))))
|
||||||
|
|
||||||
|
|
||||||
(defn make-post-handler
|
(defn make-post-handler
|
||||||
|
|
|
@ -405,6 +405,12 @@
|
||||||
:value (str "{{record." widget-name "}}")
|
:value (str "{{record." widget-name "}}")
|
||||||
:maxlength (str (max (get-size-for-widget property) 16))
|
:maxlength (str (max (get-size-for-widget property) 16))
|
||||||
:size (str (min (get-size-for-widget property) 60))}
|
:size (str (min (get-size-for-widget property) 60))}
|
||||||
|
(case (-> property :attrs :type)
|
||||||
|
"real"
|
||||||
|
{:step 0.000001} ;; this is a bit arbitrary!
|
||||||
|
"integer"
|
||||||
|
{:step 1}
|
||||||
|
nil)
|
||||||
;; TODO: should match pattern from typedef
|
;; TODO: should match pattern from typedef
|
||||||
(if
|
(if
|
||||||
(:minimum (:attrs typedef))
|
(:minimum (:attrs typedef))
|
||||||
|
@ -584,6 +590,9 @@
|
||||||
(str "{% if all "
|
(str "{% if all "
|
||||||
(s/join " " (map #(str "params." %) (key-names entity)))
|
(s/join " " (map #(str "params." %) (key-names entity)))
|
||||||
" %}")
|
" %}")
|
||||||
|
;; only show the body of auxlists if the list is non-empty
|
||||||
|
(str "{% if " (auxlist-data-name auxlist) "|not-empty %}")
|
||||||
|
|
||||||
{:tag :h2
|
{:tag :h2
|
||||||
:content [(prompt auxlist form entity application)]}
|
:content [(prompt auxlist form entity application)]}
|
||||||
{:tag :table
|
{:tag :table
|
||||||
|
@ -609,6 +618,7 @@
|
||||||
auxlist
|
auxlist
|
||||||
farside
|
farside
|
||||||
application)]}
|
application)]}
|
||||||
|
"{% endif %}"
|
||||||
(if
|
(if
|
||||||
(= (-> auxlist :attrs :canadd) "true")
|
(= (-> auxlist :attrs :canadd) "true")
|
||||||
(wrap-in-if-member-of
|
(wrap-in-if-member-of
|
||||||
|
@ -620,8 +630,7 @@
|
||||||
farside
|
farside
|
||||||
application)
|
application)
|
||||||
)
|
)
|
||||||
"{% endif %}"
|
"{% endif %}"))))})))
|
||||||
))))})))
|
|
||||||
|
|
||||||
|
|
||||||
(defn compose-form-auxlists
|
(defn compose-form-auxlists
|
||||||
|
|
Loading…
Reference in a new issue