Commit afdde6c5 authored by Joachim Schunk's avatar Joachim Schunk

make edit-view work with bulma-compnents

parent 9d0fcd43
Pipeline #45502 passed with stages
in 2 minutes and 12 seconds
......@@ -54,14 +54,13 @@
(defn phrasing-input [{:keys [path name-key name-text replacement change-fn]}]
[:tr
[:td name-text]
[:td [:input {:type "text"
:value replacement
:on-change #(change-fn (conj path name-key)
(or (not-empty (-> % .-target .-value)) nil))}]]])
[:td.is-narrow name-text]
[:td [ui/input-text {:value replacement
:on-change #(change-fn (conj path name-key)
(or (not-empty (-> % .-target .-value)) nil))}]]])
(defn phrasings-input [{:keys [names-mapping phrasing-map path change-fn]}]
[:table.table
[:table.table.is-narrow.is-fullwidth
[:tbody
(map (fn [m]
(let [name-key (:name-key m)]
......@@ -169,47 +168,42 @@
hide-assignments? (boolean (:hide-assignments exercise-core))
additional-descriptions? (contains? exercise-core :additional-descriptions)
assignment-categories? (boolean (:assignment-categories exercise-core))]
[:<>
[:div.row
[:div.col.s12 [:p [:b "Optionen:"]]]]
[:div.row
[:div.col.s5
[ui/checkbox
{:on-change #(change-fn [:core :hide-assocs] (not hide-assocs?))
:checked? hide-assocs?
:label (str (phrase-fn :assocs) " verbergen?")}]]]
[:div.row
[:div.col.s5
[ui/checkbox
{:on-change #(change-fn [:core :hide-assignments] (not hide-assignments?))
:checked? hide-assignments?
:label (str assignments-phrase " verbergen?")}]]]
[:div.row
[:div.col.s12
[ui/checkbox
{:on-change #(if assignment-categories?
(change-fn [:core] (dissoc exercise-core :assignment-categories)
(get-collats-for-vec [:core :assignments] assignment-indices
[:category-id]))
(change-fn [:core] (assoc exercise-core :assignment-categories [])
(get-collats-for-vec [:core :assignments] assignment-indices
{:category-id nil})))
:checked? assignment-categories?
:label (str "Kategorien zur Differenzierung von " assignments-phrase "?")}]]]
[:div.row
[:div.col.s12
[ui/checkbox
{:on-change #(if additional-descriptions?
(change-fn [:core] (-> exercise-core
(dissoc :additional-descriptions)
(dissoc :description-ids))
(get-collats-for-vec [:core :assocs] assoc-indices
[:additional-description-id]))
(change-fn [:core] (assoc exercise-core :additional-descriptions {})
(get-collats-for-vec [:core :assocs] assoc-indices
{:additional-description-id nil})))
:checked? additional-descriptions?
:label "Ergänzende Beschreibungen?"}]]]
[:div.is-block
[:h5.mt-4.mb-2 [:b "Optionen:"]]
[:div
[ui/checkbox
{:on-change #(change-fn [:core :hide-assocs] (not hide-assocs?))
:checked? hide-assocs?
:label (str (phrase-fn :assocs) " verbergen?")}]]
[:div
[ui/checkbox
{:on-change #(change-fn [:core :hide-assignments] (not hide-assignments?))
:checked? hide-assignments?
:label (str assignments-phrase " verbergen?")}]]
[:div
[ui/checkbox
{:on-change #(if assignment-categories?
(change-fn [:core] (dissoc exercise-core :assignment-categories)
(get-collats-for-vec [:core :assignments] assignment-indices
[:category-id]))
(change-fn [:core] (assoc exercise-core :assignment-categories [])
(get-collats-for-vec [:core :assignments] assignment-indices
{:category-id nil})))
:checked? assignment-categories?
:label (str "Kategorien zur Differenzierung von " assignments-phrase "?")}]]
[:div
[ui/checkbox
{:on-change #(if additional-descriptions?
(change-fn [:core] (-> exercise-core
(dissoc :additional-descriptions)
(dissoc :description-ids))
(get-collats-for-vec [:core :assocs] assoc-indices
[:additional-description-id]))
(change-fn [:core] (assoc exercise-core :additional-descriptions {})
(get-collats-for-vec [:core :assocs] assoc-indices
{:additional-description-id nil})))
:checked? additional-descriptions?
:label "Ergänzende Beschreibungen?"}]]
[ui/collapsible
{:elements [{:icon "edit"
:label "Benennungen"
......
......@@ -17,12 +17,10 @@
(defn assignment-category-input [{:keys [assignment-category assignments path change-fn assignment-categories]}]
[:tr
[:td [:input {:type "text"
:value (:name assignment-category)
:on-change #(change-fn (conj path :name) (-> % .-target .-value))}]]
[:td [:input {:type "text"
:value (:text assignment-category)
:on-change #(change-fn (conj path :text) (-> % .-target .-value))}]]
[:td [ui/input-text {:value (:name assignment-category)
:on-change #(change-fn (conj path :name) (-> % .-target .-value))}]]
[:td [ui/input-text {:value (:text assignment-category)
:on-change #(change-fn (conj path :text) (-> % .-target .-value))}]]
[:td
[:a.button.is-danger
{:on-click #(change-fn [:core :assignment-categories] (vec-remove assignment-categories (last path))
......@@ -34,24 +32,24 @@
[ui/card {:title (str "Kategorien für " (phrase-fn :assignments))}
#_[:h6 (str "Kategorien für " (phrase-fn :assignments))]
[:<>
[:table.table
[:thead
[:tr
[:th "Benennung"]
[:th "Text"]
[:th {:style {:width "1%"}} ""]]]
[:tbody
(map-indexed
(fn [index assignment-category]
^{:key (str "assignment-category-" index)}
[assignment-category-input
{:assignment-category assignment-category
:assignments assignments
:path [:core :assignment-categories index]
:change-fn change-fn
:assignment-categories assignment-categories}])
assignment-categories)]]
[:a.button.is-primary
{:on-click #(change-fn [:core :assignment-categories]
(conj assignment-categories (get-new-assignment-category)))}
[:span.icon [:i.fas.fa-plus]]]]]])
[:table.table.is-narrow.is-fullwidth
[:thead
[:tr
[:th "Benennung"]
[:th "Text"]
[:th {:style {:width "1%"}} ""]]]
[:tbody
(map-indexed
(fn [index assignment-category]
^{:key (str "assignment-category-" index)}
[assignment-category-input
{:assignment-category assignment-category
:assignments assignments
:path [:core :assignment-categories index]
:change-fn change-fn
:assignment-categories assignment-categories}])
assignment-categories)]]
[:a.button.is-primary
{:on-click #(change-fn [:core :assignment-categories]
(conj assignment-categories (get-new-assignment-category)))}
[:span.icon [:i.fas.fa-plus]]]]]])
......@@ -169,7 +169,7 @@
[ui/card {:title (phrase-fn :assignments)}
#_[:h6 (phrase-fn :assignments)]
[:<>
[:table.table.is-narrow
[:table.table.is-narrow.is-fullwidth
[:thead
[:tr
[:th "Zeichen"]
......
......@@ -32,12 +32,10 @@
(defn assoc-input [{:keys [assoc path change-fn assocs params steps add-desc-options]}]
[:tr
[:td [:input {:type "text"
:value (:sign assoc)
:on-change #(change-fn (conj path :sign) (-> % .-target .-value))}]]
[:td [:input {:type "text"
:value (:description assoc)
:on-change #(change-fn (conj path :description) (-> % .-target .-value))}]]
[:td [ui/input-text {:value (:sign assoc)
:on-change #(change-fn (conj path :sign) (-> % .-target .-value))}]]
[:td [ui/input-text {:value (:description assoc)
:on-change #(change-fn (conj path :description) (-> % .-target .-value))}]]
(when (> (count add-desc-options) 1)
[:td
[ui/select
......@@ -55,8 +53,7 @@
(defn assocs-input [{:keys [assocs params steps change-fn phrase-fn add-desc-options]}]
[:div.new-question.card-panel.z-depth-3
[ui/card {:title (phrase-fn :assocs)}
#_[:h6 (phrase-fn :assocs)]
[:table.table
[:table.table.is-narrow.is-fullwidth
[:thead
[:tr
[:th "Zeichen"]
......
......@@ -134,12 +134,10 @@
(build-latex-string (merge {:with-oom with-oom :with-units with-units}
param)))]
[:tr
[:td [:input {:type "text"
:value sign
:on-change #(change-fn (conj path :sign) (-> % .-target .-value))}]]
[:td [:input {:type "text"
:value idx
:on-change #(change-fn (conj path :idx) (-> % .-target .-value))}]]
[:td [ui/input-text {:value sign
:on-change #(change-fn (conj path :sign) (-> % .-target .-value))}]]
[:td [ui/input-text {:value idx
:on-change #(change-fn (conj path :idx) (-> % .-target .-value))}]]
(when-not assoc-id
[:td
[ui/select
......@@ -179,7 +177,7 @@
(defn params-tab [{:keys [assocs assoc-id params tab-params assignments steps authoring variables change-fn
with-oom with-units modal-state-atom]}]
[:<>
[:table.table
[:table.table.is-narrow.is-fullwidth
[:thead
[:tr
[:th "Zeichen"]
......
......@@ -104,7 +104,7 @@
:field :steps
:change-fn change-fn
:core core}])}
[:table.table
[:table.table.is-narrow.is-fullwidth
[:thead
[:tr
[:th (phrase-fn :assoc)]
......
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