From 9340ba9cc05a381912c6da0d1f853b2ebcb2b094 Mon Sep 17 00:00:00 2001 From: Florian Schroedl Date: Mon, 29 Jul 2024 18:30:59 +0200 Subject: [PATCH] Allow passing custom on-update-shape function --- .../app/main/ui/workspace/tokens/context_menu.cljs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/frontend/src/app/main/ui/workspace/tokens/context_menu.cljs b/frontend/src/app/main/ui/workspace/tokens/context_menu.cljs index 344b8b8d2..1afbcad9d 100644 --- a/frontend/src/app/main/ui/workspace/tokens/context_menu.cljs +++ b/frontend/src/app/main/ui/workspace/tokens/context_menu.cljs @@ -32,8 +32,10 @@ :shape-ids shape-ids :selected-pred #(seq (% ids-by-attributes))})) -(defn generic-attribute-actions [attributes title {:keys [token selected-shapes]}] - (let [{:keys [on-update-shape]} (wtty/get-token-properties token) +(defn generic-attribute-actions [attributes title {:keys [token selected-shapes on-update-shape]}] + (let [on-update-shape-fn (or on-update-shape + (-> (wtty/get-token-properties token) + (:on-update-shape))) {:keys [selected-pred shape-ids]} (attribute-actions token selected-shapes attributes)] (map (fn [attribute] (let [selected? (selected-pred attribute) @@ -43,9 +45,9 @@ {:title title :selected? selected? - :action #(if selected? - (st/emit! (wtch/unapply-token props)) - (st/emit! (wtch/apply-token (assoc props :on-update-shape on-update-shape))))})) + :action (if selected? + (st/emit! (wtch/unapply-token props)) + (st/emit! (wtch/apply-token (assoc props :on-update-shape on-update-shape-fn))))})) attributes))) (defn all-or-sepearate-actions [{:keys [attribute-labels on-update-shape-all on-update-shape]}