Skip to content

Commit

Permalink
Use distinct droppable trash ID. (#167)
Browse files Browse the repository at this point in the history
Co-authored-by: Aaron Sánchez Wolters <aaronsanchez.wolters@es.gestamp.com>
Co-authored-by: Sam Ferrell <mail@samcf.me>
  • Loading branch information
3 people authored Dec 16, 2024
1 parent 44193d6 commit f86d085
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/main/ogres/app/component/panel_tokens.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[ogres.app.util :refer [separate]]
[uix.core :as uix :refer [defui $]]
[uix.dom :refer [create-portal]]
[clojure.string :as str]
["@dnd-kit/core"
:refer [DndContext DragOverlay useDndMonitor useDraggable useDroppable]
:rename {DndContext dnd-context
Expand Down Expand Up @@ -61,7 +62,9 @@
(.querySelector js/document "#root"))))

(defui ^:private gallery [props]
(let [option (use-droppable #js {"id" "trash"})]
(let [name (:name props)
dynamic-id (str name "-" "trash")
option (use-droppable #js {"id" dynamic-id})]
($ :<>
(for [[idx data] (sequence (map-indexed vector) (:data props))]
(cond (map? data)
Expand Down Expand Up @@ -112,7 +115,7 @@
(concat (subvec data start stop))
(take limit))]
($ :<>
($ gallery {:data data})
($ gallery {:name name :data data})
(if (> pages 1)
($ pagination
{:name name
Expand Down Expand Up @@ -179,10 +182,13 @@
drop (getValueByKeys event #js ["over" "id"])
nail (getValueByKeys event #js ["active" "data" "current" "image"])]
(if (and (some? drop) (not= drag "default"))
(case drop
"scope-pub" (dispatch :token-images/change-scope drag :public)
"scope-prv" (dispatch :token-images/change-scope drag :private)
"trash" (dispatch :token-images/remove drag nail))
(cond
(= drop "scope-pub")
(dispatch :token-images/change-scope drag :public)
(= drop "scope-prv")
(dispatch :token-images/change-scope drag :private)
(str/includes? drop "trash")
(dispatch :token-images/remove drag nail))
(let [target (.. event -activatorEvent -target)
delta (.-delta event)]
(on-create drag target delta)))))
Expand Down

0 comments on commit f86d085

Please sign in to comment.