Detail work, improving robustness and presentation.
This commit is contained in:
parent
9d086f7028
commit
7ea6b5f299
|
@ -140,7 +140,7 @@
|
|||
{}))
|
||||
|
||||
|
||||
(defn search-query [entity]
|
||||
(defn search-query [entity application]
|
||||
"Generate an appropriate search query for string fields of this `entity`"
|
||||
(let [entity-name (safe-name (:name (:attrs entity)) :sql)
|
||||
pretty-name (singularise entity-name)
|
||||
|
@ -164,7 +164,7 @@
|
|||
"-- :doc selects existing "
|
||||
pretty-name
|
||||
" records having any string field matching the parameter of the same name by substring match")
|
||||
(str "SELECT * FROM lv_" entity-name)
|
||||
(str "SELECT DISTINCT * FROM lv_" entity-name)
|
||||
(s/join
|
||||
"\n\t--~ "
|
||||
(cons
|
||||
|
@ -174,8 +174,8 @@
|
|||
(map
|
||||
#(str
|
||||
"(if (:" (-> % :attrs :name) " params) \"OR "
|
||||
(case (:type (:attrs %))
|
||||
("string" "text" "defined") ;; TODO: 'defined' types may be string or number - more work here
|
||||
(case (base-type % application)
|
||||
("string" "text")
|
||||
(str
|
||||
(safe-name (-> % :attrs :name) :sql)
|
||||
" LIKE '%:" (-> % :attrs :name) "%'")
|
||||
|
@ -257,7 +257,7 @@
|
|||
(list
|
||||
(str "-- :name " query-name " " signature)
|
||||
(str "-- :doc lists all existing " pretty-name " records")
|
||||
(str "SELECT * FROM lv_" entity-name)
|
||||
(str "SELECT DISTINCT * FROM lv_" entity-name)
|
||||
(order-by-clause entity "lv_")
|
||||
"--~ (if (:offset params) \"OFFSET :offset \")"
|
||||
"--~ (if (:limit params) \"LIMIT :limit\" \"LIMIT 100\")")))})))
|
||||
|
@ -359,7 +359,7 @@
|
|||
(list
|
||||
(str "-- :name " query-name " " signature)
|
||||
(str "-- :doc lists all existing " near-name " records related through " link-name " to a given " pretty-far )
|
||||
(str "SELECT "near-name ".*")
|
||||
(str "SELECT DISTINCT "near-name ".*")
|
||||
(str "FROM " near-name ", " link-name )
|
||||
(str "WHERE " near-name "." (first (key-names near)) " = " link-name "." (singularise near-name) "_id" )
|
||||
("\tAND " link-name "." (singularise far-name) "_id = :id")
|
||||
|
@ -428,7 +428,7 @@
|
|||
(delete-query entity)
|
||||
(select-query entity)
|
||||
(list-query entity)
|
||||
(search-query entity)
|
||||
(search-query entity application)
|
||||
(foreign-queries entity application)))
|
||||
([application]
|
||||
(apply
|
||||
|
|
|
@ -77,6 +77,7 @@
|
|||
(list
|
||||
'l/render
|
||||
(list 'support/resolve-template (str n ".html"))
|
||||
'(:session r)
|
||||
(merge
|
||||
{:title (capitalise (:name (:attrs f)))
|
||||
:params 'p}
|
||||
|
@ -96,7 +97,8 @@
|
|||
(hash-map
|
||||
(keyword (-> p :attrs :entity))
|
||||
(list (symbol (str "db/list-" (:entity (:attrs p)))) (symbol "db/*db*"))))
|
||||
(filter #(= (:type (:attrs %)) "entity") (descendants-with-tag e :property))))
|
||||
(filter #(#{"entity" "link"} (:type (:attrs %)))
|
||||
(descendants-with-tag e :property))))
|
||||
:list
|
||||
{:records
|
||||
(list
|
||||
|
|
|
@ -132,7 +132,6 @@
|
|||
#(and
|
||||
(= (:tag %) :prompt)
|
||||
(= (:locale :attrs %) *locale*))))
|
||||
|
||||
(:name (:attrs field-or-property))
|
||||
(:property (:attrs field-or-property)))))
|
||||
|
||||
|
@ -265,7 +264,12 @@
|
|||
[property entity application writable?]
|
||||
(let
|
||||
[all-permissions (find-permissions property entity application)
|
||||
permissions (if writable? (writable-by all-permissions) (visible-to all-permissions))]
|
||||
permissions (map
|
||||
s/lower-case
|
||||
(if
|
||||
writable?
|
||||
(writable-by all-permissions)
|
||||
(visible-to all-permissions)))]
|
||||
(s/join
|
||||
" "
|
||||
(flatten
|
||||
|
@ -590,9 +594,12 @@
|
|||
(defn application-to-template
|
||||
[application]
|
||||
(let
|
||||
[first-class-entities (filter
|
||||
#(children-with-tag % :list)
|
||||
(children-with-tag application :entity))]
|
||||
[first-class-entities
|
||||
(sort-by
|
||||
#(:name (:attrs %))
|
||||
(filter
|
||||
#(children-with-tag % :list)
|
||||
(children-with-tag application :entity)))]
|
||||
{:application-index
|
||||
{:tag :dl
|
||||
:attrs {:class "index"}
|
||||
|
|
Loading…
Reference in a new issue