Commit af5912e3 authored by Joachim Schunk's avatar Joachim Schunk

integrate add-desc-select into card-headers

parent 0fa7bebe
......@@ -2,7 +2,7 @@
(:require [lernmeister.components.common :refer [latex-span]]
[lernmeister.components.exercise-types.calchelper
:refer
[build-units-latex-string units-to-set]]
[build-units-latex-string dissoc-in units-to-set]]
[lernmeister.components.exercise-types.multistep-calculation.check
:refer
[number-obj]]
......@@ -119,6 +119,18 @@
[:div.level-item
[blue-line]]]]]))
(defn add-desc-select [{:keys [description-ids add-desc-options field change-fn core]}]
[ui/field {:addons? true}
[:div.control
[:div.button.is-static "Ergänzende Beschreibung"]]
[ui/select
{:value (or (field description-ids) :$-§)
:options add-desc-options
:on-change #(change-fn [:core]
(if (= % :$-§)
(dissoc-in core [:description-ids field])
(assoc-in core [:description-ids field] %)))}]])
(defn discrete-phys-val-editor [{:keys [context assignment-type path collats-fn symbol-data modal-state-atom
latex-number-str latex-units-str selectable-units]}]
(let [editable-number? (and assignment-type
......
......@@ -4,7 +4,6 @@
:refer
[build-latex-string
build-range-latex-string
dissoc-in
find-cascading-step-indices
find-step-indices-by-var-id
find-vec-index-by-id]]
......@@ -13,7 +12,7 @@
[number-obj]]
[lernmeister.components.exercise-types.multistep-calculation.views.common
:refer
[clear-step-data clear-steps-by-index-set map-params-to-assocs]]
[add-desc-select clear-step-data clear-steps-by-index-set map-params-to-assocs]]
[lernmeister.components.helper :refer [vec-remove]]
[lernmeister.components.jshelper :refer [get-unique-id]]
[lernmeister.components.ui :as ui]))
......@@ -220,18 +219,14 @@
with-units phrase-fn description-ids add-desc-options modal-state-atom]}]
(let [mapped-params (map-params-to-assocs params assocs)]
[:div.new-question.card-panel.z-depth-3
[ui/card {:title (str (phrase-fn :param) " mit " (phrase-fn :assoc))}
[ui/card {:title (str (phrase-fn :param) " mit " (phrase-fn :assoc))
:title-right (when (not-empty add-desc-options)
[add-desc-select {:description-ids description-ids
:add-desc-options add-desc-options
:field :params
:change-fn change-fn
:core core}])}
[:<>
[:div.valign-wrapper {:style {:justify-content "space-between"}}
#_[:h6 (str (phrase-fn :param) " mit " (phrase-fn :assoc))]
(when (not-empty add-desc-options)
[ui/select
{:label "Ergänzende Beschreibung"
:value (or (:params description-ids) :$-§)
:options add-desc-options
:on-change #(change-fn [:core] (if (= % :$-§)
(dissoc-in core [:description-ids :params])
(assoc-in core [:description-ids :params] %)))}])]
(if (not-empty assocs)
[ui/scrollable-tabs
{:tabs (into [] (map-indexed
......
......@@ -3,7 +3,6 @@
:refer
[build-number-latex-string
build-units-latex-string
dissoc-in
find-cascading-step-indices
find-step-indices-by-var-id]]
[lernmeister.components.exercise-types.multistep-calculation.check
......@@ -11,7 +10,8 @@
[number-obj]]
[lernmeister.components.exercise-types.multistep-calculation.views.common
:refer
[clear-step-data
[add-desc-select
clear-step-data
clear-steps-by-index-set
get-step-symbol-data
step-add-tr
......@@ -94,42 +94,37 @@
{:on-click #(step-remove change-fn path assignments steps)}
[:span.icon [:i.fas.fa-trash]]]]]]))
(defn steps-input [{:keys [core assocs params assignments steps authoring change-fn phrase-fn description-ids add-desc-options modal-state-atom]}]
(defn steps-input [{:keys [core assocs params assignments steps authoring change-fn phrase-fn
description-ids add-desc-options modal-state-atom]}]
[:div.new-question.card-panel.z-depth-3
[ui/card
{:title (phrase-fn :steps)}
[:<>
[:div.valign-wrapper {:style {:justify-content "space-between"}}
#_[:h6 (phrase-fn :steps)]
(when (not-empty add-desc-options)
[ui/select
{:label "Ergänzende Beschreibung"
:value (or (:steps description-ids) :$-§)
:options add-desc-options
:on-change #(change-fn [:core] (if (= % :$-§)
(dissoc-in core [:description-ids :steps])
(assoc-in core [:description-ids :steps] %)))}])]
[:table.table
[:thead
[:tr
[:th (phrase-fn :assoc)]
[:th (phrase-fn :assignment)]
[:th (phrase-fn :vars)]
[:th "Wert"]
[:th {:style {:width "1%"}} ""]]]
[:tbody
(map-indexed
(fn [index step]
^{:key (str "step-" index)}
[step-input
{:step step
:path [:core :steps index]
:assocs assocs
:params params
:assignments assignments
:steps steps
:authoring authoring
:change-fn change-fn
:modal-state-atom modal-state-atom}])
steps)
[step-add-tr {:add-fn #(change-fn [:core :steps] (conj steps (get-new-step assocs)))}]]]]]])
[ui/card {:title (phrase-fn :steps)
:title-right (when (not-empty add-desc-options)
[add-desc-select {:description-ids description-ids
:add-desc-options add-desc-options
:field :steps
:change-fn change-fn
:core core}])}
[:table.table
[:thead
[:tr
[:th (phrase-fn :assoc)]
[:th (phrase-fn :assignment)]
[:th (phrase-fn :vars)]
[:th "Wert"]
[:th {:style {:width "1%"}} ""]]]
[:tbody
(map-indexed
(fn [index step]
^{:key (str "step-" index)}
[step-input
{:step step
:path [:core :steps index]
:assocs assocs
:params params
:assignments assignments
:steps steps
:authoring authoring
:change-fn change-fn
:modal-state-atom modal-state-atom}])
steps)
[step-add-tr {:add-fn #(change-fn [:core :steps] (conj steps (get-new-step assocs)))}]]]]])
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