 (defn update-form-onclick [data-set focus]
   (if (= nil (form-validator @data-set))
     (let [onres (fn[data]
-                  (secretary/dispatch! "/"))
-         ; data (swap! data-set dissoc :districtid :subdivisionid)
-          ]
+                  (secretary/dispatch! "/"))]
       (http-put (str serverhost "mutations/" (:id @data-set))
                 onres (.serialize (Serializer.) (clj->js (map-mutation-data @data-set))))))
   (reset! focus "on"))


(defn login-validator [data-set]
  (first (b/validate data-set
                     :email [[v/required :message "Filed is required"]
                             [v/email :message "Enter valid email-id"]]
                     :password [[v/required :message "Filed is required"]
                                [v/string  :message "Enter valid password"]])))




(defroute consolidation-list "/consolidation" []
  (if (nil? (get-value! :user)) (set-page! [login])
      (let [onres (fn [json]
                    (let [dt (getdata json)]
                      (set-key-value :consolidations (.-data dt))
                      (set-key-value :total-pages (get-total-rec-no (.-pagesCount dt)))
                      (set-page!  [render-consolidation (get-value! :consolidations)])))]
        (set-key-value :is-searched-results false)
        (http-get-auth (str serverhost "consolidations?pageIndex="(dec (get-value! :current-page))"&pageSize=10") onres))))


(defroute consolidation-add-path "/consolidation/add" []
  (let [onres (fn[json](
                       (set-key-value :villages (getdata json))
                       (set-page! [consolidation-add-template])))]
    (http-get-auth (str serverhost "villages") onres)))

(defroute consolidation-upd-path "/consolidation/update/:id" [id]
  (let [onres (fn[json](
                       (set-key-value :villages (getdata json))
                       (set-page! [consolidation-update-template id
                                   (first (filter (fn[obj]
                                                    (=(.-id obj) (.parseInt js/window id))) (get-value! :consolidations)))])))]
    (http-get-auth (str serverhost "villages") onres)))

(defn consolidation-add [event]
  (secretary/dispatch! "/consolidation/add"))
