Skip to content

Instantly share code, notes, and snippets.

@dupuchba
Created March 16, 2017 19:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dupuchba/8afb34732f3feb7082c0714ad34e4de2 to your computer and use it in GitHub Desktop.
Save dupuchba/8afb34732f3feb7082c0714ad34e4de2 to your computer and use it in GitHub Desktop.
(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