Tactical commit
This commit is contained in:
parent
2d7e39ca29
commit
16f953741b
|
@ -99,8 +99,7 @@
|
||||||
"See [Application Description Language](https://github.com/simon-brooke/adl)."
|
"See [Application Description Language](https://github.com/simon-brooke/adl)."
|
||||||
"-->")
|
"-->")
|
||||||
(emit-content filename spec entity application :head)
|
(emit-content filename spec entity application :head)
|
||||||
(emit-content filename spec entity application :top)
|
(emit-content filename spec entity application :top))))))
|
||||||
"{% block content %}")))))
|
|
||||||
|
|
||||||
|
|
||||||
(defn file-footer
|
(defn file-footer
|
||||||
|
@ -111,11 +110,7 @@
|
||||||
([filename spec entity application]
|
([filename spec entity application]
|
||||||
(s/join
|
(s/join
|
||||||
"\n"
|
"\n"
|
||||||
(flatten
|
(emit-content filename spec entity application :foot))))
|
||||||
(list
|
|
||||||
"{% endblock %}"
|
|
||||||
(emit-content filename spec entity application :foot)
|
|
||||||
)))))
|
|
||||||
|
|
||||||
|
|
||||||
(defn prompt
|
(defn prompt
|
||||||
|
@ -362,6 +357,7 @@
|
||||||
[keyfields (children
|
[keyfields (children
|
||||||
;; there should only be one key; its keys are properties
|
;; there should only be one key; its keys are properties
|
||||||
(first (children entity #(= (:tag %) :key))))]
|
(first (children entity #(= (:tag %) :key))))]
|
||||||
|
{:content
|
||||||
{:tag :div
|
{:tag :div
|
||||||
:attrs {:id "content" :class "edit"}
|
:attrs {:id "content" :class "edit"}
|
||||||
:content
|
:content
|
||||||
|
@ -380,7 +376,7 @@
|
||||||
#(= (:distict (:attrs %)) :system)
|
#(= (:distict (:attrs %)) :system)
|
||||||
(fields entity)))
|
(fields entity)))
|
||||||
(save-widget form entity application)
|
(save-widget form entity application)
|
||||||
(delete-widget form entity application)))}]}))
|
(delete-widget form entity application)))}]}}))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -536,16 +532,46 @@
|
||||||
taken from this `application`. If `list` is nill, generate a default list
|
taken from this `application`. If `list` is nill, generate a default list
|
||||||
template for the entity."
|
template for the entity."
|
||||||
[list-spec entity application]
|
[list-spec entity application]
|
||||||
{:tag :form
|
(let [form-name
|
||||||
:attrs {:id "content" :class "list"}
|
(str
|
||||||
|
"list-"
|
||||||
|
(:name (:attrs entity))
|
||||||
|
"-"
|
||||||
|
(:name (:attrs list-spec)))]
|
||||||
|
{:big-links
|
||||||
|
{:tag :div
|
||||||
:content
|
:content
|
||||||
[(big-link (str "Add a new " (pretty-name entity)) (editor-name entity application))
|
[{:tag :div :attrs {:class "big-link-container"}
|
||||||
|
:content
|
||||||
|
[{:tag :a :attrs {:id "next-selector" :role "button" :class "big-link"}
|
||||||
|
:content ["Next"]}]}
|
||||||
|
(big-link (str "Add a new " (pretty-name entity)) (editor-name entity application))]}
|
||||||
|
:content
|
||||||
|
{:tag :form
|
||||||
|
:attrs {:id form-name :class "list"
|
||||||
|
:action (str "{{servlet-context}}/" form-name)
|
||||||
|
:method "POST"}
|
||||||
|
:content
|
||||||
|
[
|
||||||
|
(csrf-widget)
|
||||||
|
{:tag :input :attrs {:id "offset" :type "hidden" :value "{{offset|0}}"}}
|
||||||
|
{:tag :input :attrs {:id "limit" :type "hidden" :value "{{limit|50}}"}}
|
||||||
|
(big-link (str "Add a new " (pretty-name entity)) (editor-name entity application))
|
||||||
{:tag :table
|
{:tag :table
|
||||||
:attrs {:caption (:name (:attrs entity))}
|
:attrs {:caption (:name (:attrs entity))}
|
||||||
:content
|
:content
|
||||||
[(list-thead list-spec entity application)
|
[(list-thead list-spec entity application)
|
||||||
(list-tbody list-spec entity application)
|
(list-tbody list-spec entity application)
|
||||||
(list-tfoot list-spec entity application)]}]})
|
(list-tfoot list-spec entity application)]}]}
|
||||||
|
:extra-script
|
||||||
|
(str "var form = document.getElementById('" form-name "');
|
||||||
|
var ow = document.getElementById('offset');
|
||||||
|
var lw = document.getElementById('limit');
|
||||||
|
|
||||||
|
document.getElementById('next-selector').addEventListener('click', function () {
|
||||||
|
ow.text=(parseInt(ow.text)+parseInt(lw.text));
|
||||||
|
//form.submit();
|
||||||
|
});")}))
|
||||||
|
|
||||||
|
|
||||||
(defn entity-to-templates
|
(defn entity-to-templates
|
||||||
|
@ -591,6 +617,7 @@
|
||||||
[first-class-entities (filter
|
[first-class-entities (filter
|
||||||
#(children-with-tag % :list)
|
#(children-with-tag % :list)
|
||||||
(children-with-tag application :entity))]
|
(children-with-tag application :entity))]
|
||||||
|
{:content
|
||||||
{:application-index
|
{:application-index
|
||||||
{:tag :dl
|
{:tag :dl
|
||||||
:attrs {:class "index"}
|
:attrs {:class "index"}
|
||||||
|
@ -617,7 +644,7 @@
|
||||||
:tag :p
|
:tag :p
|
||||||
:content (:content d)))
|
:content (:content d)))
|
||||||
(children-with-tag % :documentation))))
|
(children-with-tag % :documentation))))
|
||||||
first-class-entities)))}}))
|
first-class-entities)))}}}))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -630,11 +657,24 @@
|
||||||
(str *output-path* filename)
|
(str *output-path* filename)
|
||||||
(s/join
|
(s/join
|
||||||
"\n"
|
"\n"
|
||||||
|
(flatten
|
||||||
(list
|
(list
|
||||||
(file-header filename application)
|
(file-header filename application)
|
||||||
|
(doall
|
||||||
|
(map
|
||||||
|
#(let [content (template %)]
|
||||||
|
(list
|
||||||
|
(str "{% block " (name %) " %}")
|
||||||
|
(cond (string? content)
|
||||||
|
content
|
||||||
|
(map? content)
|
||||||
(with-out-str
|
(with-out-str
|
||||||
(x/emit-element template))
|
(x/emit-element content))
|
||||||
(file-footer filename application))))
|
true
|
||||||
|
(str "<!-- don't know what to do with '" content "' -->"))
|
||||||
|
"{% endblock %}")
|
||||||
|
(keys template))))
|
||||||
|
(file-footer filename application)))))
|
||||||
(catch Exception any
|
(catch Exception any
|
||||||
(spit
|
(spit
|
||||||
(str *output-path* filename)
|
(str *output-path* filename)
|
||||||
|
|
Loading…
Reference in a new issue