Work on getting forms to work - almost, but not quite, complete
This commit is contained in:
parent
9d34005f9e
commit
2d7e39ca29
|
@ -259,6 +259,31 @@
|
|||
:content (apply vector (get-options property form entity application))})))}))
|
||||
|
||||
|
||||
(defn permissions-for
|
||||
[property entity application]
|
||||
(first
|
||||
(remove
|
||||
empty?
|
||||
(list
|
||||
(children-with-tag property :permission)
|
||||
(children-with-tag entity :permission)
|
||||
(children-with-tag application :permission)))))
|
||||
|
||||
|
||||
(defn compose-if-member-of-tag
|
||||
[property entity application writable?]
|
||||
(let
|
||||
[all-permissions (permissions-for property entity application)
|
||||
permissions (if writable? (writable-by all-permissions) (visible-to all-permissions))]
|
||||
(s/join
|
||||
" "
|
||||
(flatten
|
||||
(list
|
||||
"{% ifmemberof"
|
||||
permissions
|
||||
"%}")))))
|
||||
|
||||
|
||||
(defn widget
|
||||
"Generate a widget for this `field-or-property` of this `form` for this `entity`
|
||||
taken from within this `application`."
|
||||
|
@ -294,7 +319,7 @@
|
|||
:content [{:tag :label
|
||||
:attrs {:for widget-name}
|
||||
:content [(prompt field-or-property form entity application)]}
|
||||
(str "{% ifwritable " (:name (:attrs entity)) " " (:name (:attrs property)) " %}")
|
||||
(compose-if-member-of-tag property entity application true)
|
||||
(cond
|
||||
select?
|
||||
(select-widget property form entity application)
|
||||
|
@ -312,14 +337,14 @@
|
|||
(:maximum (:attrs typedef))
|
||||
{:max (:maximum (:attrs typedef))}))})
|
||||
"{% else %}"
|
||||
(str "{% ifreadable " (:name (:attrs entity)) " " (:name (:attrs property)) "%}")
|
||||
(compose-if-member-of-tag property entity application false)
|
||||
{:tag :span
|
||||
:attrs {:id widget-name
|
||||
:name widget-name
|
||||
:class "pseudo-widget disabled"}
|
||||
:content [(str "{{record." widget-name "}}")]}
|
||||
"{% endifreadable %}"
|
||||
"{% endifwritable %}"]})))
|
||||
"{% endifmemberof %}"
|
||||
"{% endifmemberof %}"]})))
|
||||
|
||||
|
||||
(defn fields
|
||||
|
@ -351,7 +376,9 @@
|
|||
keyfields)
|
||||
(map
|
||||
#(widget % form entity application)
|
||||
(fields entity))
|
||||
(remove
|
||||
#(= (:distict (:attrs %)) :system)
|
||||
(fields entity)))
|
||||
(save-widget form entity application)
|
||||
(delete-widget form entity application)))}]}))
|
||||
|
||||
|
|
|
@ -222,8 +222,10 @@
|
|||
|
||||
|
||||
(defn writable-by
|
||||
"Return a list of names of groups to which are granted read access,
|
||||
given these `permissions`, else nil."
|
||||
"Return a list of names of groups to which are granted write access,
|
||||
given these `permissions`, else nil.
|
||||
TODO: TOTHINKABOUT: properties are also writable by `insert` and `noedit`, but only if the
|
||||
current value is nil."
|
||||
[permissions]
|
||||
(permission-groups permissions #(#{"edit" "all"} (:permission (:attrs %)))))
|
||||
|
||||
|
|
Loading…
Reference in a new issue