Ab sofort ist der Login auf der Weboberfläche von git.fh-muenster.de bevorzugt über FH Muenster SSO möglich.

Commit 2ad40cd4 authored by Bruno Burke's avatar Bruno Burke 😁

fix select* in logic-editor, add row-class to table-component, fix ui/table in logic-card devcard

parent 551e226d
Pipeline #45091 passed with stages
in 1 minute and 58 seconds
......@@ -64,13 +64,17 @@
[:table.table.is-striped.is-fullwidth
[:thead
[:tr
(doall (for [h head]
^{:key (str table-id (:id h))} [:th {:on-click #(set-sort-status sort-status h)} (:label h)
(when (and (= (:column @sort-status) (:id h)) (:order @sort-status))
(case (:order @sort-status)
:asc [icon "fa-sort-up"]
:desc [icon "fa-sort-down"]
))]))]]
(doall
(for [h head]
^{:key (str table-id (:id h))}
[:th {:on-click #(set-sort-status sort-status h)}
(:label h (:id h))
(when (and (= (:column @sort-status) (:id h))
(:order @sort-status))
(case (:order @sort-status)
:asc [icon "fa-sort-up"]
:desc [icon "fa-sort-down"]
))]))]]
[:tbody
(let [data (if-let [order (:order @sort-status)]
(sort-by (fn [data]
......@@ -90,9 +94,12 @@
(for [d data]
(let [row-id (:id d)
row-data d]
^{:key row-id} [:tr
(for [h head]
^{:key (str row-id "-" (:id h))} [:td (let [data (get row-data (:id h))]
(if (is-labeled? data)
(:label data)
data))])])))]]])))
^{:key row-id}
[:tr (when-let [row-class (:_row-class d)]
{:class row-class})
(for [h head]
^{:key (str row-id "-" (:id h))}
[:td (let [data (get row-data (:id h))]
(if (is-labeled? data)
(:label data)
data))])])))]]])))
......@@ -94,7 +94,9 @@
(defn rule [r options delete-fn depth]
(fn [r options delete-fn depth]
(if (or (nil? (:attributes options)) (and (string? (:id @r)) (not (empty? (:id @r)))))
(if (or (nil? (:attributes options))
(and (string? (:id @r))
(not (empty? (:id @r)))))
[default-rule r options delete-fn depth]
[:div.columns
[:div.column.is-5
......@@ -112,9 +114,10 @@
(select-keys (:labels options) (keys conditions)))]
[:<>
[:div.columns
[:div.column.is-full [ui/select*
:cursor (reagent/cursor g [:condition])
:options (mapv #(hash-map :key (first %) :title (second %)) conditions)]]]
[:div.column.is-full
[ui/select*
{:cursor (reagent/cursor g [:condition])
:options (mapv #(hash-map :key (first %) :title (second %)) conditions)}]]]
[:div.columns
[:div.column.is-full
[:div.columns
......@@ -123,9 +126,8 @@
[:em (get-in options [:labels :info-add-element] "Bitte fügen Sie ein Element hinzu.")]]
[:div.column.is-offset-1.is-11
(map-indexed (fn [idx item]
[:div.columns.is-vcentered
[:div.column.is-1 {:key (str id "-child-" idx)
:class (str "row z-depth-" depth)}
[:div.columns.is-vcentered {:key (str id "-child-" idx)}
[:div.column.is-1 {:class (str "row z-depth-" depth)}
[:a.button {:on-click #(swap! g update :rules vec-remove idx)}
[ui/icon "fa-trash"]]]
[:div.column.is-11
......
......@@ -8,6 +8,7 @@
[lernmeister.components.sample-data :as data]
[lernmeister.components.logic.core :refer [validate]]
[lernmeister.components.logic.editor :refer [editor]]
[lernmeister.components.ui :as ui]
[clojure.pprint :refer [pprint]]
[devcards.core]
[reagent.core :as reagent]))
......@@ -16,16 +17,16 @@
(def testdata [{:price 9.99 :category 2 :name "Apfelsaft" :tags ["saft" "getränk" "frühstück" "abendessen"]}
{:price 19.99 :category 1 :name "Orangensaft" :tags ["saft" "getränk" "frühstück" "abendessen"]}
{:price 2.39 :category 2 :name "Marmelade" :tags ["aufstrich" "frühstück" "abendessen"]}
{:price 5.79 :category 3 :name "Brötchen" :tags ["brot" "frühstück" "abendessen"]}
{:price 1.97 :category 4 :name "Tee" :tags ["wasser" "getränk" "frühstück" "abendessen" "alltag"]}
{:price 6.32 :category 2 :name "Milch" :tags ["milchprodukt" "getränk" "frühstück" "abendessen"]}
{:price 12.22 :category 1 :name "Ei" :tags ["frühstück" "abendessen"]}
{:price 123.99 :category 2 :name "Salat" :tags ["gemüse" "frühstück" "mittagessen" "abendessen"]}
{:price 43.99 :category 1 :name "Tomate" :tags ["frühstück" "mittagessen" "abendessen"]}
{:price 65.99 :category 1 :name "Mozzarello" :tags ["milchprodukt" "käse" "frühstück" "mittagessen" "abendessen"]}])
(defonce testdata [{:id (gensym "testdata") :price 9.99 :category 2 :name "Apfelsaft" :tags ["saft" "getränk" "frühstück" "abendessen"]}
{:id (gensym "testdata") :price 19.99 :category 1 :name "Orangensaft" :tags ["saft" "getränk" "frühstück" "abendessen"]}
{:id (gensym "testdata") :price 2.39 :category 2 :name "Marmelade" :tags ["aufstrich" "frühstück" "abendessen"]}
{:id (gensym "testdata") :price 5.79 :category 3 :name "Brötchen" :tags ["brot" "frühstück" "abendessen"]}
{:id (gensym "testdata") :price 1.97 :category 4 :name "Tee" :tags ["wasser" "getränk" "frühstück" "abendessen" "alltag"]}
{:id (gensym "testdata") :price 6.32 :category 2 :name "Milch" :tags ["milchprodukt" "getränk" "frühstück" "abendessen"]}
{:id (gensym "testdata") :price 12.22 :category 1 :name "Ei" :tags ["frühstück" "abendessen"]}
{:id (gensym "testdata") :price 123.99 :category 2 :name "Salat" :tags ["gemüse" "frühstück" "mittagessen" "abendessen"]}
{:id (gensym "testdata") :price 43.99 :category 1 :name "Tomate" :tags ["frühstück" "mittagessen" "abendessen"]}
{:id (gensym "testdata") :price 65.99 :category 1 :name "Mozzarello" :tags ["milchprodukt" "käse" "frühstück" "mittagessen" "abendessen"]}])
(defcard "#Logic Editor")
......@@ -35,25 +36,26 @@
(defn data-table [logic data]
(fn [logic testdata]
[:table.striped
[:thead
[:tr
[:th "price"]
[:th "category"]
[:th "name"]
[:th "tags"]
[:th "logic-result"]]]
[:tbody
(doall (for [d testdata]
[:tr {:key (hash d)
:class (if (validate @logic-rule d)
"green"
"red")}
[:td (:price d)]
[:td (:category d)]
[:td (:name d)]
[:td (str (:tags d))]
[:td (str (validate @logic d))]]))]]
(let [logic-rule @logic-rule
logic @logic]
[ui/table
{:head
[{:id :price :sortable true}
{:id :category :sortable true}
{:id :name :sortable true}
{:id :tags :sortable true}
{:id :logic-result :sortable true}]
:data
(for [d testdata]
{:id (:id d)
:_row-class (if (validate logic-rule d)
"has-background-success"
"has-background-danger")
:price (:price d)
:category (:category d)
:name (:name d)
:tags (str (:tags d))
:logic-result (str (validate logic d))})}])
)
)
......
......@@ -8,6 +8,7 @@
[lernmeister.components.sample-data :as data]
[lernmeister.components.logic.core :refer [validate]]
[lernmeister.components.logic.editor :refer [editor]]
[lernmeister.components.ui :as ui]
[clojure.pprint :refer [pprint]]
[devcards.core]
[reagent.core :as reagent]))
......@@ -16,16 +17,16 @@
(def testdata [{:price 9.99 :category 2 :name "Apfelsaft" :tags ["saft" "getränk" "frühstück" "abendessen"]}
{:price 19.99 :category 1 :name "Orangensaft" :tags ["saft" "getränk" "frühstück" "abendessen"]}
{:price 2.39 :category 2 :name "Marmelade" :tags ["aufstrich" "frühstück" "abendessen"]}
{:price 5.79 :category 3 :name "Brötchen" :tags ["brot" "frühstück" "abendessen"]}
{:price 1.97 :category 4 :name "Tee" :tags ["wasser" "getränk" "frühstück" "abendessen" "alltag"]}
{:price 6.32 :category 2 :name "Milch" :tags ["milchprodukt" "getränk" "frühstück" "abendessen"]}
{:price 12.22 :category 1 :name "Ei" :tags ["frühstück" "abendessen"]}
{:price 123.99 :category 2 :name "Salat" :tags ["gemüse" "frühstück" "mittagessen" "abendessen"]}
{:price 43.99 :category 1 :name "Tomate" :tags ["frühstück" "mittagessen" "abendessen"]}
{:price 65.99 :category 1 :name "Mozzarello" :tags ["milchprodukt" "käse" "frühstück" "mittagessen" "abendessen"]}])
(defonce testdata [{:id (gensym "testdata") :price 9.99 :category 2 :name "Apfelsaft" :tags ["saft" "getränk" "frühstück" "abendessen"]}
{:id (gensym "testdata") :price 19.99 :category 1 :name "Orangensaft" :tags ["saft" "getränk" "frühstück" "abendessen"]}
{:id (gensym "testdata") :price 2.39 :category 2 :name "Marmelade" :tags ["aufstrich" "frühstück" "abendessen"]}
{:id (gensym "testdata") :price 5.79 :category 3 :name "Brötchen" :tags ["brot" "frühstück" "abendessen"]}
{:id (gensym "testdata") :price 1.97 :category 4 :name "Tee" :tags ["wasser" "getränk" "frühstück" "abendessen" "alltag"]}
{:id (gensym "testdata") :price 6.32 :category 2 :name "Milch" :tags ["milchprodukt" "getränk" "frühstück" "abendessen"]}
{:id (gensym "testdata") :price 12.22 :category 1 :name "Ei" :tags ["frühstück" "abendessen"]}
{:id (gensym "testdata") :price 123.99 :category 2 :name "Salat" :tags ["gemüse" "frühstück" "mittagessen" "abendessen"]}
{:id (gensym "testdata") :price 43.99 :category 1 :name "Tomate" :tags ["frühstück" "mittagessen" "abendessen"]}
{:id (gensym "testdata") :price 65.99 :category 1 :name "Mozzarello" :tags ["milchprodukt" "käse" "frühstück" "mittagessen" "abendessen"]}])
(defcard "#Logic Editor")
......@@ -59,25 +60,26 @@
(defn data-table [logic data]
(fn [logic testdata]
[:table.striped
[:thead
[:tr
[:th "price"]
[:th "category"]
[:th "name"]
[:th "tags"]
[:th "logic-result"]]]
[:tbody
(doall (for [d testdata]
[:tr {:key (hash d)
:class (if (validate @logic-rule d)
"green"
"red")}
[:td (:price d)]
[:td (:category d)]
[:td (:name d)]
[:td (str (:tags d))]
[:td (str (validate @logic d))]]))]]
(let [logic-rule @logic-rule
logic @logic]
[ui/table
{:head
[{:id :price :sortable true}
{:id :category :sortable true}
{:id :name :sortable true}
{:id :tags :sortable true}
{:id :logic-result :sortable true}]
:data
(for [d testdata]
{:id (:id d)
:_row-class (if (validate logic-rule d)
"has-background-success"
"has-background-danger")
:price (:price d)
:category (:category d)
:name (:name d)
:tags (str (:tags d))
:logic-result (str (validate logic d))})}])
)
)
......
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