Created
March 16, 2017 19:15
-
-
Save dupuchba/8afb34732f3feb7082c0714ad34e4de2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defui ElementList | |
static om/Ident | |
(ident [this {:keys [id]}] | |
[:list/by-id id]) | |
static om/IQuery | |
(query [this] | |
[:id {:elements (om/get-query Element)}]) | |
Object | |
(on-drag-start [this element] | |
(om/transact! this `[(element/drag {:from ~(om/get-ident this) :element ~element}) :app/lists])) | |
(render [this] | |
(let [{:keys [id elements]} (om/props this) | |
{:keys [dragging]} (om/get-computed this)] | |
(dom/div nil | |
(dom/h4 nil (str "List with id : " id)) | |
(dom/ul #js {:onDragEnter (fn [e] | |
(.preventDefault e)) | |
:onDragOver (fn [e] | |
(set! (.. e -dataTransfer -dropEffect) "move") | |
(.preventDefault e)) | |
:onDrop (fn [e] | |
(.preventDefault e) | |
)} | |
(map (fn [el] | |
(element (om/computed el {:on-drag-start #(.on-drag-start this %)}))) | |
elements)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment