diff --git a/bases/behave_components/src/cljs/behave/components/matrix_table.cljs b/bases/behave_components/src/cljs/behave/components/matrix_table.cljs index 81982516..4f6deaf0 100644 --- a/bases/behave_components/src/cljs/behave/components/matrix_table.cljs +++ b/bases/behave_components/src/cljs/behave/components/matrix_table.cljs @@ -1,9 +1,9 @@ (ns behave.components.matrix-table (:require [behave.stories.utils :refer [->params]])) -(defn- table-header [title rows-label cols-label header-names & [sub-title]] +(defn- table-header [title rows-label cols-label header-names header-color & [sub-title]] [:thead.table-header - [:tr.table__title + [:tr.table__title (when header-color {:style {:background-color header-color}}) [:th {:col-span (inc (count header-names))} title]] (when sub-title [:tr.table__sub-title @@ -28,13 +28,13 @@ - cols-labl : string - cell-colors : a map of [row col] -> hex color " - [{:keys [title sub-title column-headers row-headers data rows-label cols-label cell-colors]}] + [{:keys [title sub-title column-headers row-headers data rows-label cols-label header-color cell-colors]}] (let [column-headers (->params column-headers) row-headers (->params row-headers) data (->params data) column-header-names (map :name column-headers)] [:table.table - [table-header title rows-label cols-label column-header-names sub-title] + [table-header title rows-label cols-label column-header-names header-color sub-title] [:tbody.table__body (for [row-header row-headers :let [i (:key row-header) diff --git a/bases/behave_schema/src/behave/schema/group_variable.cljc b/bases/behave_schema/src/behave/schema/group_variable.cljc index f1d7e068..d643a774 100644 --- a/bases/behave_schema/src/behave/schema/group_variable.cljc +++ b/bases/behave_schema/src/behave/schema/group_variable.cljc @@ -38,6 +38,7 @@ ;;; Schema +#_{:clj-kondo/ignore [:missing-docstring]} (def schema [{:db/ident :group-variable/cpp-namespace :db/doc "Group variable's C++ namespace." @@ -94,10 +95,15 @@ :db/cardinality :db.cardinality/many} {:db/ident :group-variable/direction - :db/doc "Group variable's direction." + :db/doc "DEPRECATED: use :group-variable/direction-ref. Group variable's direction keyword." :db/valueType :db.type/keyword :db/cardinality :db.cardinality/one} + {:db/ident :group-variable/direction-ref + :db/doc "Group variable's reference to a list-option of the 'Directions' list. Replaces :group-variable/direction." + :db/valueType :db.type/ref + :db/cardinality :db.cardinality/one} + ;; Boolean Settings {:db/ident :group-variable/research? :db/doc "Whether a Group Variable is for research." @@ -162,6 +168,7 @@ ;;; Tests +#_{:clj-kondo/ignore [:unresolved-symbol]} (comment (s/explain :behave/group-variable {:bp/uuid (str (random-uuid)) :group-variable/order 0 diff --git a/bases/behave_schema/src/behave/schema/list.cljc b/bases/behave_schema/src/behave/schema/list.cljc index 3806819d..f3c15743 100644 --- a/bases/behave_schema/src/behave/schema/list.cljc +++ b/bases/behave_schema/src/behave/schema/list.cljc @@ -1,6 +1,6 @@ (ns behave.schema.list - (:require [clojure.spec.alpha :as s] - [behave.schema.utils :refer [many-ref? valid-key? uuid-string? zero-pos?]])) + (:require [behave.schema.utils :refer [many-ref? valid-key? uuid-string? zero-pos?]] + [clojure.spec.alpha :as s])) ;;; Spec @@ -30,6 +30,7 @@ :opt [:list-option/default :list-option/hide?])) +#_{:clj-kondo/ignore [:missing-docstring]} (def schema ;; Lists [{:db/ident :list/uuid @@ -68,7 +69,8 @@ {:db/ident :list/options :db/doc "List's options." :db/valueType :db.type/ref - :db/cardinality :db.cardinality/many} + :db/cardinality :db.cardinality/many + :db/isComponent true} ;; List Options {:db/ident :list-option/uuid @@ -216,6 +218,7 @@ ;;; Tests +#_{:clj-kondo/ignore [:unresolved-symbol]} (comment (s/valid? :behave/list {:list/uuid (str (random-uuid)) :list/name "My List" diff --git a/development/migrations/2026_04_28_link_directions_to_fire_direction.clj b/development/migrations/2026_04_28_link_directions_to_fire_direction.clj new file mode 100644 index 00000000..d1c128bc --- /dev/null +++ b/development/migrations/2026_04_28_link_directions_to_fire_direction.clj @@ -0,0 +1,143 @@ +(ns migrations.2026-04-28-link-directions-to-fire-direction + (:require [behave-cms.server :as cms] + [behave-cms.store :refer [default-conn]] + [clojure.string :as str] + [datomic.api :as d] + [schema-migrate.interface :as sm])) + +;; =========================================================================================================== +;; Overview +;; =========================================================================================================== + +;; 1. Create "Directions" color tag-set with Heading/Flanking/Backing tags and hex colors. +;; 2. Seed an English translation for the new tag-set key only; per-direction keys already exist. +;; 3. Attach :list/color-tag-set to the existing FireDirection list. +;; 4. Add :list-option/color-tag-ref to each FireDirection list-option (matched by :list-option/name). +;; 5. Backfill :group-variable/direction-ref from existing :group-variable/direction keywords, +;; resolving against FireDirection options by :list-option/name. + +;; =========================================================================================================== +;; Initialize +;; =========================================================================================================== + +(cms/init-db!) + +#_{:clj-kondo/ignore [:missing-docstring]} +(def conn (default-conn)) + +;; =========================================================================================================== +;; Step 1 — color tag-set + tags +;; =========================================================================================================== + +#_{:clj-kondo/ignore [:missing-docstring]} +(def directions-color-tag-payload + (sm/postwalk-insert + [{:db/id -100 + :tag-set/name "Directions" + :tag-set/translation-key "behave:tag-set:directions" + :tag-set/color? true + :tag-set/tags + [{:db/id -101 + :tag/name "Heading" + :tag/color "#13486a" + :tag/translation-key "behave:list-option:list-option:firedirection:heading" + :tag/order 0} + {:db/id -102 + :tag/name "Flanking" + :tag/color "#4a7086" + :tag/translation-key "behave:list-option:list-option:firedirection:flanking" + :tag/order 1} + {:db/id -103 + :tag/name "Backing" + :tag/color "#8297a3" + :tag/translation-key "behave:list-option:list-option:firedirection:backing" + :tag/order 2}]}])) + +;; =========================================================================================================== +;; Step 2 — translation for the new tag-set (per-direction keys already exist) +;; =========================================================================================================== + +#_{:clj-kondo/ignore [:missing-docstring]} +(def translations-payload + (sm/build-translations-payload + conn + {"behave:tag-set:directions" "Directions"})) + +;; =========================================================================================================== +;; Step 3 + 4 — attach tag-set and color-tag-ref to FireDirection list and its options +;; =========================================================================================================== + +#_{:clj-kondo/ignore [:missing-docstring]} +(def fire-direction-eid + (d/q '[:find ?l . + :where [?l :list/name "FireDirection"]] + (d/db conn))) + +(def ^:private tag-name->tempid + {"heading" -101 + "flanking" -102 + "backing" -103}) + +#_{:clj-kondo/ignore [:missing-docstring]} +(def fire-direction-options + (d/q '[:find ?opt ?name + :in $ ?l + :where + [?l :list/options ?opt] + [?opt :list-option/name ?name]] + (d/db conn) + fire-direction-eid)) + +#_{:clj-kondo/ignore [:missing-docstring]} +(def attach-payload + (concat + [[:db/add fire-direction-eid :list/color-tag-set -100]] + (for [[opt-eid opt-name] fire-direction-options + :let [lc-name (str/lower-case opt-name) + tag-id (tag-name->tempid lc-name)] + :when tag-id] + [:db/add opt-eid :list-option/color-tag-ref tag-id]))) + +;; =========================================================================================================== +;; Step 5 — backfill :group-variable/direction-ref from legacy :group-variable/direction keywords +;; =========================================================================================================== + +(def ^:private name->option-eid + (into {} (for [[opt-eid opt-name] fire-direction-options] + [(str/lower-case opt-name) opt-eid]))) + +#_{:clj-kondo/ignore [:missing-docstring]} +(def gv-pairs + (d/q '[:find ?gv ?dir + :where [?gv :group-variable/direction ?dir]] + (d/db conn))) + +#_{:clj-kondo/ignore [:missing-docstring]} +(def backfill-payload + (vec (for [[gv-eid dir-kw] gv-pairs + :let [opt-eid (name->option-eid (name dir-kw))] + :when opt-eid] + [:db/add gv-eid :group-variable/direction-ref opt-eid]))) + +#_{:clj-kondo/ignore [:missing-docstring]} +(def payload + (concat directions-color-tag-payload + translations-payload + attach-payload + backfill-payload)) + +;; =========================================================================================================== +;; Transact +;; =========================================================================================================== + +(comment + #_{:clj-kondo/ignore [:missing-docstring]} + (try (def tx-data @(d/transact conn payload)) + (catch Exception e (str "caught exception: " (.getMessage e))))) + +;; =========================================================================================================== +;; Rollback +;; =========================================================================================================== + +(comment + (sm/rollback-tx! conn tx-data)) diff --git a/projects/behave/resources/public/layout.msgpack b/projects/behave/resources/public/layout.msgpack index b02825c2..c5a02fc3 100644 Binary files a/projects/behave/resources/public/layout.msgpack and b/projects/behave/resources/public/layout.msgpack differ diff --git a/projects/behave/src/cljs/behave/components/results/matrices.cljs b/projects/behave/src/cljs/behave/components/results/matrices.cljs index 8ca71419..34795a6c 100644 --- a/projects/behave/src/cljs/behave/components/results/matrices.cljs +++ b/projects/behave/src/cljs/behave/components/results/matrices.cljs @@ -22,15 +22,15 @@ (defn- color-options->value-color-map [color-options] (into {} (map (fn [{:keys [value color]}] [value color]) color-options))) -(defn- compute-color-map-1d [color-gv-uuid matrix-data-raw input-fmt-fn] - (when color-gv-uuid - (let [color-options @(subscribe [:wizard/gv-list-options-with-colors color-gv-uuid]) +(defn- compute-color-map-1d [cell-color-gv-uuid matrix-data-raw input-fmt-fn] + (when cell-color-gv-uuid + (let [color-options @(subscribe [:wizard/gv-list-options-with-colors cell-color-gv-uuid]) value->color (color-options->value-color-map color-options) entries-by-row (group-by (fn [[[row _] _]] row) matrix-data-raw)] (reduce-kv (fn [acc row entries] (if-let [color (some (fn [[[_ col-uuid] v]] - (when (= col-uuid color-gv-uuid) + (when (= col-uuid cell-color-gv-uuid) (get value->color v))) entries)] (let [fmt-row (input-fmt-fn row)] @@ -196,16 +196,16 @@ (defn- compute-color-map-2d [{:keys [ws-uuid row-gv-uuid row-values col-gv-uuid col-values - color-gv-uuid submatrix-gv-uuid submatrix-value]}] - (when color-gv-uuid - (let [color-options @(subscribe [:wizard/gv-list-options-with-colors color-gv-uuid]) + cell-color-gv-uuid submatrix-gv-uuid submatrix-value]}] + (when cell-color-gv-uuid + (let [color-options @(subscribe [:wizard/gv-list-options-with-colors cell-color-gv-uuid]) value->color (color-options->value-color-map color-options) matrix-data (fetch-matrix-data-2d {:ws-uuid ws-uuid :row-gv-uuid row-gv-uuid :row-values row-values :col-gv-uuid col-gv-uuid :col-values col-values - :output-gv-uuid color-gv-uuid + :output-gv-uuid cell-color-gv-uuid :submatrix-gv-uuid submatrix-gv-uuid :submatrix-value submatrix-value})] (reduce-kv (fn [acc [row col] value] @@ -281,7 +281,7 @@ :rows map-units-rows}))])) (defmethod construct-result-matrices 1 - [{:keys [ws-uuid process-map-units? multi-valued-inputs formatters output-entities units-lookup shade-set any-filters-enabled? title color-gv-uuid]}] + [{:keys [ws-uuid process-map-units? multi-valued-inputs formatters output-entities units-lookup shade-set any-filters-enabled? title header-color cell-color-gv-uuid]}] (let [[multi-var-name multi-var-units multi-var-gv-uuid @@ -292,7 +292,7 @@ multi-var-gv-uuid multi-var-values (map :bp/uuid output-entities)]) - color-map (compute-color-map-1d color-gv-uuid matrix-data-raw input-fmt-fn) + color-map (compute-color-map-1d cell-color-gv-uuid matrix-data-raw input-fmt-fn) {:keys [units rep-fraction]} (fetch-map-units-settings ws-uuid) [regular-column-headers map-units-column-headers] (reduce (fn [[reg mu] {output-gv-uuid :bp/uuid output-units :units}] @@ -330,6 +330,7 @@ [:div.print__result-table (c/matrix-table (merge common-matrix-props {:title title + :header-color header-color :column-headers regular-column-headers :data matrix-data-formatted :cell-colors color-map})) @@ -337,12 +338,13 @@ [:div.result-matrix__map-units-table (c/matrix-table (merge common-matrix-props {:title (gstring/format @(> multi-valued-inputs @@ -448,7 +452,8 @@ :output-entities output-entities :units-lookup units-lookup :formatters formatters - :color-gv-uuid color-gv-uuid + :header-color header-color + :cell-color-gv-uuid cell-color-gv-uuid :shade-set (get shade-set value) :any-filters-enabled? any-filters-enabled?}]])])) @@ -456,8 +461,8 @@ ;; Discrete Color Selector & Legend ;;============================================================================== -(defn- color-legend [color-gv-uuid] - (let [color-options @(subscribe [:wizard/gv-list-options-with-colors color-gv-uuid]) +(defn- color-legend [cell-color-gv-uuid] + (let [color-options @(subscribe [:wizard/gv-list-options-with-colors cell-color-gv-uuid]) color-options-grouped-by-color (group-by :color color-options)] (when (seq color-options-grouped-by-color) [:div.result-matrices__color-legend @@ -470,9 +475,9 @@ [:span.result-matrices__color-legend__text @(kebab ->str]])) ;; Helpers -(defn make-tree +(defn- make-tree [xs] (into {} (map (fn [x] [(butlast x) [(last x)]]) xs))) -(defn input-tree-to-vec +(defn- input-tree-to-vec [[path leaf]] (let [input-vec (vec (concat (vec path) leaf))] (if (= (count input-vec) 4) (conj input-vec :none) input-vec))) -(defn re-entity-from-uuid [bp-uuid] - (re/entity [:bp/uuid bp-uuid])) - -(defn re-entity-from-eid [eid] +(defn- re-entity-from-eid [eid] (re/entity eid)) (rf/reg-sub @@ -856,11 +853,12 @@ [ws-uuid]})) (defn- is-directional? [gv-uuid direction] - (= (d/q '[:find ?direction . + (= (d/q '[:find ?dir-id . :in $ ?gv-uuid :where [?gv :bp/uuid ?gv-uuid] - [?gv :group-variable/direction ?direction]] + [?gv :group-variable/direction-ref ?dir-eid] + [?dir-eid :list-option/name ?dir-id]] @@vms-conn gv-uuid) direction)) @@ -1224,7 +1222,7 @@ (rf/reg-sub :worksheet/output-directions (fn [_ [_ ws-uuid]] - (d/q '[:find [?direction ...] + (d/q '[:find [?dir-id ...] :in $ $ws % ?ws-uuid :where [$ws ?w :worksheet/uuid ?ws-uuid] @@ -1232,7 +1230,8 @@ [$ws ?o :output/group-variable-uuid ?gv-uuid] [$ws ?o :output/enabled? true] (lookup ?gv-uuid ?gv) - [?gv :group-variable/direction ?direction]] + [?gv :group-variable/direction-ref ?dir-eid] + [?dir-eid :list-option/name ?dir-id]] @@vms-conn @@s/conn rules ws-uuid))) (rf/reg-sub diff --git a/projects/behave_cms/src/cljs/behave_cms/components/conditionals/views.cljs b/projects/behave_cms/src/cljs/behave_cms/components/conditionals/views.cljs index 141a8524..ce39230d 100644 --- a/projects/behave_cms/src/cljs/behave_cms/components/conditionals/views.cljs +++ b/projects/behave_cms/src/cljs/behave_cms/components/conditionals/views.cljs @@ -138,11 +138,15 @@ (set-field (conj cond-path :conditional/values) nil) (set-field (conj cond-path :conditional/group-variable-uuid) (u/input-value %))) - :options (map (fn [{value :bp/uuid label :variable/name direction :group-variable/direction}] - {:value value - :label (if direction - (str label " (" (name direction) ")") - label)}) @variables)}] + :options (map (fn [{value :bp/uuid + label :variable/name + dir-ref :group-variable/direction-ref + dir-kw :group-variable/direction}] + (let [direction (or (:list-option/value dir-ref) (some-> dir-kw name))] + {:value value + :label (if direction + (str label " (" direction ")") + label)})) @variables)}] [dropdown {:label "Operator:" @@ -301,12 +305,14 @@ gv-id @(rf/subscribe [:bp/lookup gv-uuid]) [module-id] @(rf/subscribe [:group-variable/module-submodule-group gv-id]) module-name @(rf/subscribe [:entity-attr module-id :module/name]) - direction @(rf/subscribe [:entity-attr gv-id :group-variable/direction]) + dir-ref-eid @(rf/subscribe [:entity-attr gv-id :group-variable/direction-ref]) + direction (or (when dir-ref-eid @(rf/subscribe [:entity-attr dir-ref-eid :list-option/value])) + (some-> @(rf/subscribe [:entity-attr gv-id :group-variable/direction]) name)) v-name (if (= conditional-type :module) "Module" (let [n @(rf/subscribe [:gv-uuid->variable-name gv-uuid])] (if direction - (str n " (" (name direction) ")") + (str n " (" direction ")") n)))] [:div.conditionals-graph__node (when (seq sub-conditionals) diff --git a/projects/behave_cms/src/cljs/behave_cms/components/group_variable_selector.cljs b/projects/behave_cms/src/cljs/behave_cms/components/group_variable_selector.cljs index 2512f622..12958d05 100644 --- a/projects/behave_cms/src/cljs/behave_cms/components/group_variable_selector.cljs +++ b/projects/behave_cms/src/cljs/behave_cms/components/group_variable_selector.cljs @@ -8,9 +8,11 @@ (defn- ->option [name-key] (fn [m] {:value (:db/id m) - :label (if-let [direction (:group-variable/direction m)] - (gstring/format "%s (%s)" (name-key m) (name direction)) - (name-key m))})) + :label (let [direction (or (get-in m [:group-variable/direction-ref :list-option/value]) + (some-> (:group-variable/direction m) name))] + (if direction + (gstring/format "%s (%s)" (name-key m) direction) + (name-key m)))})) (defn group-variable-selector "Displays a Group Variable selector. diff --git a/projects/behave_cms/src/cljs/behave_cms/group_variables/views.cljs b/projects/behave_cms/src/cljs/behave_cms/group_variables/views.cljs index c6bff25a..cc210824 100644 --- a/projects/behave_cms/src/cljs/behave_cms/group_variables/views.cljs +++ b/projects/behave_cms/src/cljs/behave_cms/group_variables/views.cljs @@ -14,6 +14,7 @@ [behave-cms.routes :refer [app-routes]] [behave-cms.utils :as u] [bidi.bidi :refer [path-for]] + [goog.string :as gstring] [re-frame.core :as rf])) ;;; Constants @@ -67,22 +68,21 @@ #(do (swap! *value? not) (update!))]])) -(defn- dropdown-setting [label attr entity] +(defn- direction-ref-setting [entity] (let [{id :db/id} entity - selected (get entity attr)] + dir-list (first (filter #(= (:list/name %) "FireDirection") @(rf/subscribe [:lists]))) + options (sort-by :list-option/order (:list/options dir-list)) + selected (get-in entity [:group-variable/direction-ref :list-option/name])] [:div.mt-1 - [dropdown {:label label + [dropdown {:label "Direction" :selected selected - :options [{:label "Heading" - :value "heading"} - {:label "Backing" - :value "backing"} - {:label "Flanking" - :value "flanking"}] - :on-select #(do - (if (= (u/input-keyword %) (keyword "Select Direction...")) - (rf/dispatch [:api/retract-entity-attr entity attr]) - (rf/dispatch [:api/update-entity {:db/id id attr (u/input-keyword %)}])))}]])) + :options (map (fn [o] {:label (:list-option/name o) :value (:list-option/name o)}) options) + :on-select #(let [v (u/input-value %)] + (if (= v "Select Direction...") + (rf/dispatch [:api/retract-entity-attr entity :group-variable/direction-ref]) + (when-let [opt (first (filter (fn [list-option] (= (:list-option/name list-option) v)) options))] + (rf/dispatch [:api/update-entity {:db/id id + :group-variable/direction-ref (:db/id opt)}]))))}]])) (defn- settings [group-variable] [:div.row.mt-2 @@ -92,7 +92,7 @@ [bool-setting "Hide from Results?" :group-variable/hide-result? group-variable] [bool-setting "Hide from CSV Export?" :group-variable/hide-csv? group-variable] [bool-setting "Hide from Graphs?" :group-variable/hide-graph? group-variable] - [dropdown-setting "Direction" :group-variable/direction group-variable]]) + [direction-ref-setting group-variable]]) ;;; Public Views @@ -117,11 +117,10 @@ (let [group-variable (rf/subscribe [:entity [:bp/nid nid] '[* {:variable/_group-variables [*] :group/_group-variables [*] :group-variable/actions [*] - :group-variable/direction-variables [* {:variable/_group-variables [*]}]}]]) + :group-variable/direction-variables [* {:variable/_group-variables [*]}] + :group-variable/direction-ref [:list-option/name :db/id]}]]) gv-id (:db/id @group-variable) - is-output? (rf/subscribe [:group-variable/output? gv-id]) actions (:group-variable/actions @group-variable) - action-id (rf/subscribe [:editors :action]) group (:group/_group-variables @group-variable) variable (get-in @group-variable [:variable/_group-variables 0]) group-variables (rf/subscribe [:sidebar/variables (:db/id group)]) @@ -129,7 +128,8 @@ link-id (rf/subscribe [:state :link]) destination-link-id (-> (rf/subscribe [:entity @link-id]) deref - (get-in [:link/destination :db/id]))] + (get-in [:link/destination :db/id])) + direction (get-in @group-variable [:group-variable/direction-ref :list-option/name])] [:<> [sidebar "Variables" @@ -140,7 +140,9 @@ sidebar-width [:div.container [:div.row.mb-3.mt-4 - [:h2 (:variable/name variable)]] + [:h2 (if direction + (gstring/format "%s (%s)" (:variable/name variable) direction) + (:variable/name variable))]] [accordion "Translations" [:h5 "Worksheet Translations"] diff --git a/projects/behave_cms/src/cljs/behave_cms/subgroups/subs.cljs b/projects/behave_cms/src/cljs/behave_cms/subgroups/subs.cljs index 63ff9a13..2de124e2 100644 --- a/projects/behave_cms/src/cljs/behave_cms/subgroups/subs.cljs +++ b/projects/behave_cms/src/cljs/behave_cms/subgroups/subs.cljs @@ -104,8 +104,8 @@ (fn [groups _] (->> groups - (map (fn [{nid :bp/nid name :group/name}] - {:label name + (map (fn [{nid :bp/nid group-name :group/name}] + {:label group-name :link (path-for app-routes :get-group :nid nid)})) (sort-by :label)))) @@ -126,9 +126,9 @@ [?v :variable/name ?name]] [group-id]])) (fn [results] - (mapv (fn [[id name]] + (mapv (fn [[id var-name]] (-> @(subscribe [:entity id]) - (assoc :variable/name name))) results))) + (assoc :variable/name var-name))) results))) (reg-sub :group/module-conditionals @@ -150,7 +150,8 @@ (reg-sub :group/_variables (fn [[_ group-id]] - (subscribe [:pull-children :group/group-variables group-id '[* {:variable/_group-variables [*]}]])) + (subscribe [:pull-children :group/group-variables group-id '[* {:variable/_group-variables [*] + :group-variable/direction-ref [:list-option/name]}]])) identity) (reg-sub @@ -173,10 +174,11 @@ (->> variables (map (fn [variable] (let [nid (:bp/nid variable) - direction (:group-variable/direction variable) + direction (or (get-in variable [:group-variable/direction-ref :list-option/name]) + (some-> (:group-variable/direction variable) name)) v-name (get-in variable [:variable/_group-variables 0 :variable/name])] {:label (if direction - (gstring/format "%s (%s)" v-name (name direction)) + (gstring/format "%s (%s)" v-name direction) v-name) :link (path-for app-routes :get-group-variable :nid nid)}))) (sort-by :label)))) diff --git a/projects/behave_cms/src/cljs/behave_cms/subgroups/views.cljs b/projects/behave_cms/src/cljs/behave_cms/subgroups/views.cljs index 39501c03..1b780f36 100644 --- a/projects/behave_cms/src/cljs/behave_cms/subgroups/views.cljs +++ b/projects/behave_cms/src/cljs/behave_cms/subgroups/views.cljs @@ -34,12 +34,17 @@ :field-key :group/name}]}]])) (defn- variables-table [group-id] - (let [group-variables (rf/subscribe [:group/variables group-id])] + (let [group-variables (rf/subscribe [:group/variables group-id]) + rows (mapv (fn [gv] + (assoc gv :group-variable/direction + (or (get-in gv [:group-variable/direction-ref :list-option/name]) + (some-> (:group-variable/direction gv) name)))) + (sort-by :group-variable/order @group-variables))] [simple-table [:variable/name :group-variable/direction :group-variable/conditionally-set?] - (sort-by :group-variable/order @group-variables) - {:on-increase #(rf/dispatch [:api/reorder % @group-variables :group-variable/order :inc]) - :on-decrease #(rf/dispatch [:api/reorder % @group-variables :group-variable/order :dec]) + rows + {:on-increase #(rf/dispatch [:api/reorder % rows :group-variable/order :inc]) + :on-decrease #(rf/dispatch [:api/reorder % rows :group-variable/order :dec]) :on-select #(rf/dispatch [:subgroups/edit-variables (first (:variable/_group-variables %))])}])) (defn- add-variable [group-id]