Commit 16194b4c authored by Joachim Schunk's avatar Joachim Schunk

migrate list&range editors to Bulma

parent 8b8b8dcf
Pipeline #45419 passed with stages
in 2 minutes and 5 seconds
......@@ -220,6 +220,8 @@
{:margin ".5rem 0 1rem 0"}
[:div.card
{:margin "0px"}]]
[:div.vspace
{:height "1.6em"}]
)
......
......@@ -55,13 +55,16 @@
:with-units with-units
:del-fn del-fn
:set-test-fn set-test-fn}]
[:div.vspace]
[value-builder {:phys-val @val-state-atom
:path []
:change-fn (fn [path val _] (swap! val-state-atom assoc-in path val))
:add-fn add-fn}]
[value-renderer {:phys-val {:number number :units units}
:with-oom with-oom
:with-units with-units
:add-fn add-fn}]
[value-builder {:phys-val @val-state-atom
:path []
:change-fn (fn [path val _] (swap! val-state-atom assoc-in path val))}]
[:div.vspace]
[units-builder {:units units
:path path
:change-fn change-fn
......
......@@ -11,9 +11,11 @@
:path path
:change-fn change-fn
:collats-fn collats-fn}]
[:div.vspace]
[value-renderer {:phys-val phys-val
:with-oom with-oom
:with-units with-units}]
[:div.vspace]
(when (and (boolean? with-units) with-units)
[units-builder {:units (:units phys-val)
:path path
......
......@@ -12,22 +12,23 @@
[reagent.core :as reagent]))
(defn value-select [{:keys [val-key options-map on-change-fn precision precision-change-fn]}]
[:div.row
[:div.columns.is-gapless
(map-indexed (fn [index map-item]
^{:key index}
[:div.col.s3
[ui/radiobutton
:name "phys-val-select"
:label (val map-item)
:checked? (= val-key (key map-item))
:on-change #((partial on-change-fn (key map-item)))]])
[:div.column.is-3
[ui/field {:label (:label (val map-item)) :help (:help (val map-item))}
[ui/radiobutton
{:name "phys-val-select"
:checked? (= val-key (key map-item))
:on-change #((partial on-change-fn (key map-item)))}]]])
options-map)
[:div.col.s3
[ui/select
:label "Nachkommastellen"
:value precision
:options decimal-places-options
:on-change #(precision-change-fn (name %))]]])
[:div.column.is-3
[ui/field {:label "Nachkommastellen"}
[ui/select
{:label "Nachkommastellen"
:value precision
:options decimal-places-options
:on-change #(precision-change-fn (name %))}]]]])
(defn range-editor [{:keys [subject path variable-idx change-fn with-oom with-units collats-fn]}]
(reagent/with-let [val-state-atom (reagent/atom {})]
......@@ -45,9 +46,9 @@
:change-fn change-fn
:collats-fn collats-fn}]
[value-select {:val-key val-key
:options-map {:min "Minwert (inklusive)"
:max "Maxwert (exklusive)"
:number "Testwert"}
:options-map {:min {:label "Minwert" :help "(inklusive)"}
:max {:label "Maxwert" :help "(exklusive)"}
:number {:label "Testwert" :help ""}}
:on-change-fn (fn [val-key]
(swap! val-state-atom assoc-in [state-id :val-key] val-key))
:precision (get-in subject sig-path)
......@@ -57,6 +58,7 @@
:units units
:with-oom with-oom
:with-units with-units}]
[:div.vspace]
[units-builder {:units units
:path path
:change-fn change-fn
......
......@@ -17,75 +17,76 @@
(defn editor-heading [{:keys [sign subtext]}]
[:<> [:span "Größe editieren: "] [sign-with-subtext {:sign sign :subtext subtext}]])
(defn addable-value [{:keys [latex-str add-fn]}]
(if (not-empty latex-str)
[:div.buttons.has-addons
[:a.button.is-info
{:on-click add-fn}
[:span.icon [:i.fas.fa-plus]]]
[:a.button.is-static [:div.is-size-7 [latex-span latex-str]]]]
[:div.buttons.has-addons
[:a.button {:disabled true} [:span.icon [:i.fas.fa-plus]]]
[:a.button.is-static [:span "Keine gültiger Wert eingegeben"]]]))
(defn value-renderer [{:keys [phys-val with-oom with-units add-fn]}]
(let [external-units (if (vector? with-units) with-units nil)
latex-str (build-latex-string (merge {:with-oom with-oom :with-units with-units}
{:units external-units}
phys-val))]
[:div.columns.mb-3
[:div.column.is-11
[:span.icon.mr-3 [:i.fas.fa-arrow-right]]
(if (not-empty latex-str) [latex-span latex-str]
[:span.has-text-grey "Kein gültiger Wert angegeben ..."])]
(when add-fn
[:div.column.is-1
[:a.button.is-info
{:on-click add-fn}
[:span.icon [:i.fas.fa-plus]]]])]))
[:div.is-block
(if add-fn
[addable-value {:latex-str latex-str
:add-fn add-fn}]
[:<>
[:span.icon.mr-3 [:i.fas.fa-arrow-right]]
(if (not-empty latex-str)
[latex-span latex-str]
[:span.has-text-grey "Kein gültiger Wert angegeben ..."])])]))
(defn value-range-renderer [arg]
(let [latex-str (build-range-latex-string arg)]
[:div.row
[:div.col.s12.valign-wrapper
[:span.icon [:i.fas.fa-arrow-right]]
[latex-span latex-str]]]))
[:div.is-block
[:span.icon.mr-3 [:i.fas.fa-arrow-right]]
[latex-span latex-str]]))
(defn number-renderer [{:keys [phys-val]}]
(let [latex-str (build-number-latex-string (:number phys-val))]
[:div.columns.mb-3
[:div.column.is-full
[:span.icon.mr-3 [:i.fas.fa-arrow-right]]
(if (not-empty latex-str) [latex-span latex-str]
[:span.has-text-grey "Kein gültiger Wert angegeben ..."])]]))
[:div.is-block
[:span.icon.mr-3 [:i.fas.fa-arrow-right]]
(if (not-empty latex-str) [latex-span latex-str]
[:span.has-text-grey "Kein gültiger Wert angegeben ..."])]))
(defn units-renderer [phys-val]
(let [latex-str (build-units-latex-string (:units phys-val))]
[:div.columns.mb-3
[:div.column.is-full
[:span.icon.mr-3 [:i.fas.fa-arrow-right]]
(if (not-empty latex-str) [latex-span latex-str]
[:span.has-text-grey "Keine Einheit angegeben ..."])]]))
[:div.is-block
[:span.icon.mr-3 [:i.fas.fa-arrow-right]]
(if (not-empty latex-str) [latex-span latex-str]
[:span.has-text-grey "Keine Einheit angegeben ..."])]))
(defn list-renderer [{:keys [list units test-number with-oom with-units del-fn set-test-fn]}]
[:<>
[:div.row
[:div.col.font-plus [:b "Einträge:"]]]
[:div.row
[:div.col.s12
(when (and (vector? list) (not-empty list))
[:table
[:thead
[:tr
[:th "Nr."]
[:th.right-align "Wert"]
[:th.right-align "Testwert"]
[:th ""]]]
[:tbody
(map-indexed
(fn [index item]
(let [is-test? (= 0 (compare-number-objects (nth list index) test-number))]
^{:key (str "list-item-" index)}
[:tr
[:td index]
[:td.right-align
[latex-span (build-latex-string (merge {:with-oom with-oom :with-units with-units :units units}
item))]]
[:td.right-align
[ui/radiobutton :name "list-test-select"
:on-change #(set-test-fn index)
:checked? is-test?
:label ""]]
[:td
[:a.button
{:on-click #(del-fn index is-test?)}
[:span.icon [:i.fas.fa-minus]]]]])) list)]])]]])
[:div.is-block
(if (and (vector? list) (not-empty list))
[:table.table
[:thead
[:tr
[:th "Wert"]
[:th "Testwert"]
[:th ""]]]
[:tbody
(map-indexed
(fn [index item]
(let [is-test? (= 0 (compare-number-objects (nth list index) test-number))]
^{:key (str "list-item-" index)}
[:tr
[:td.is-vcentered
[latex-span (build-latex-string (merge {:with-oom with-oom :with-units with-units :units units}
item))]]
[:td.is-vcentered
[ui/radiobutton {:name "list-test-select"
:on-change #(set-test-fn index)
:checked? is-test?}]]
[:td.is-vcentered.has-text-right
[:a.button.is-danger
{:on-click #(del-fn index is-test?)}
[:span.icon [:i.fas.fa-trash]]]]])) list)]]
[:div.has-text-grey "Keine Listeneinträge vorhanden ..."])])
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment