Working through getting record creation going

This commit is contained in:
Simon Brooke 2018-08-05 14:53:54 +01:00
parent 972dfd091e
commit 34552cff4f
2 changed files with 111 additions and 95 deletions

View file

@ -77,7 +77,7 @@
'if
(list
'all-keys-present?
'params (set (key-names e true)))
'params (key-names e true))
(list
'support/do-or-log-error
(list
@ -138,7 +138,7 @@
:entity
#(= (-> % :attrs :name) f-name))]
(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
(keyword (auxlist-data-name auxlist))
(list
@ -189,7 +189,12 @@
(descendants-with-tag e :property)))
(map
#(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
@ -248,7 +253,7 @@
(str
"db/list-"
(:name (:attrs e))))
(symbol "db/*db*") {})
(symbol "db/*db*") 'params)
:message (str
"Error while fetching "
(singularise (:name (:attrs e)))
@ -311,33 +316,32 @@
'valid-user-or-forbid
(list
'with-params-or-error
(list
'do-or-server-fail
(list
'if
(list 'all-keys-present? 'params (key-names e true))
(list
'do-or-server-fail
(list
update-name
'db/*db*
'params)
200)
(list
'do-or-server-fail
(list
create-name
'db/*db*
'params))
200) ;; OK
'params)
201))
'params
(set
(map
#(keyword (:name (:attrs %)))
(insertable-properties e))))
(required-properties e))))
'request))
(list
'if
(list
(set [200 400])
(list :status 'result))
(list
(symbol (handler-name f e a :get))
(list 'merge
(list
'assoc
'request
@ -345,8 +349,11 @@
(list
'merge
'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

View file

@ -405,6 +405,12 @@
:value (str "{{record." widget-name "}}")
:maxlength (str (max (get-size-for-widget property) 16))
: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
(if
(:minimum (:attrs typedef))
@ -584,6 +590,9 @@
(str "{% if all "
(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
:content [(prompt auxlist form entity application)]}
{:tag :table
@ -609,6 +618,7 @@
auxlist
farside
application)]}
"{% endif %}"
(if
(= (-> auxlist :attrs :canadd) "true")
(wrap-in-if-member-of
@ -620,8 +630,7 @@
farside
application)
)
"{% endif %}"
))))})))
"{% endif %}"))))})))
(defn compose-form-auxlists