Skip to content

Instantly share code, notes, and snippets.

@rwillig
Created August 20, 2015 22:31
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 rwillig/e5f8fb5d3e65194be66e to your computer and use it in GitHub Desktop.
Save rwillig/e5f8fb5d3e65194be66e to your computer and use it in GitHub Desktop.
(defelem solution-form [{:keys [depots mappings] :as attr} kids]
(let [current-solution (cell nil)
prop (cell {:files nil})
solution-schema {:id nil :label nil :depot nil :mapping nil :file nil :files nil}]
(form/with-form [{:keys [data error state exception loading] :as form-machine}
(workflow/form-machine
:current current-solution
:action (fn [& x] (.log js/console (clj->js x)))
:schema solution-schema
:success #(.log js/console "Success!"))]
(form :class "m-t" :role "form"
:submit #(let [q (js/jQuery "#problem-orders")
e (aget q 0)]
(do (reset! (:files data) (.-files e)) (workflow/submit form-machine)))
(form/with-field :label
(div :class "form-group" (form/text-input :placeholder "describe this file" :id "problem-description")))
(form/with-field :depot (div :class "form-group"
(form/select :class "form-control m-b" :id "problem-depot"
(option :value "" "choose a depot")
(loop-tpl :bindings [[i {:keys [id label]}] (cell= (map-indexed vector depots))]
(option :value id :text label)))))
(form/with-field :mapping (div :class "form-group"
(form/select :class "form-control m-b" :id "problem-mapping"
(option :value "" "choose a tenplate")
(loop-tpl :bindings [[i {:keys [id label]}] (cell= (map-indexed vector mappings))]
(option :value id :text label)))))
(form/with-field :file
(div :class "form-group"
(form/file-input :id "problem-orders")))
(button :type "submit" :class "btn btn-primary" "Submit")))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment