all-forms functionality are changed

all-forms functionality are changed

--- src_cljs/rrm/corecljs.cljs
+++ src_cljs/rrm/corecljs.cljs
@@ -140,8 +140,6 @@
             [:div]
             [:div {:style  {:color "red"}} [:b (str (first ((login-validator @data-set) id)))]])
           [:div])])))
-
-

           (defn submit-login [data-set focus]
             (if (= nil (login-validator @data-set))
@@ -1231,30 +1229,30 @@
                         [:div])]])))

-(defn rev-sub-onchange [id val data-set]
+(defn all-sub-onchange [id val data-set]
   (let [res (fn [json]
               (let [dt (getdata json)]
                 (set-key-value :villages dt)))]
     (do (http-get-auth (str serverhost "subdivisions/" val  "/villages") res)
         (swap! data-set assoc id (js/parseInt val)))))

-(defn rev-sub-sel-tag [id data data-set]
+(defn all-sub-sel-tag [id data data-set]
   [:select.form-control {:id id
                          :value (@data-set id)
-                         :on-change #(rev-sub-onchange  id (-> % .-target .-value) data-set)}
+                         :on-change #(all-sub-onchange  id (-> % .-target .-value) data-set)}
    [:option {:value 0} "--Select--"]
    (for [d  data]
      ^{:key (.-id d) }
      [:option {:value (.-id d)} (.-subdivisionname d)])])

-(defn rev-form-sub-sel [label id opt-data data-set]
+(defn all-form-sub-sel [label id opt-data data-set]
   [:div.form-group
    [:label.col-sm-3.control-label label]
-   [:div.col-sm-6 [rev-sub-sel-tag id opt-data data-set]]
+   [:div.col-sm-6 [all-sub-sel-tag id opt-data data-set]]
    [:div.col-sm-3 [:div]]])

-(defn rev-villages-sel-tag [id data data-set ]
+(defn all-villages-sel-tag [id data data-set ]
   [:select.form-control {:id id
                          :value (@data-set id)
                          :on-change #(swap! data-set assoc id (js/parseInt (-> % .-target .-value)))}
@@ -1263,10 +1261,10 @@
      ^{:key (.-id d) }
      [:option {:value (.-id d)} (.-villagename d)])])

-(defn rev-form-villages-sel [label id opt-data data-set]
+(defn all-form-villages-sel [label id opt-data data-set]
   [:div.form-group
    [:label.col-sm-3.control-label label]
-   [:div.col-sm-6 [rev-villages-sel-tag id opt-data data-set]]
+   [:div.col-sm-6 [all-villages-sel-tag id opt-data data-set]]
    [:div.col-sm-3 [:div]]])

 (defn revenue-form-cancel [event]
@@ -1281,18 +1279,17 @@
      [:div.form-horizontal
       [:div.box-body
        [revenue-input-int-row :serialnumber "Serial Number" "text" data-set focus]
-       [rev-form-sub-sel "Sub Division Name" :subdivisionid (:subdivisions @storage) data-set]
-       [rev-form-villages-sel "Village Name" :villageid (:villages @storage) data-set]
+       [all-form-sub-sel "Sub Division Name" :subdivisionid (:subdivisions @storage) data-set]
+       [all-form-villages-sel "Village Name" :villageid (:villages @storage) data-set]
        [revenue-input-int-row :year "Year" "text" data-set focus]
        [revenue-input-row :racknumber "Rack Number" "text" data-set focus]
-       [revenue-input-row :description "Description" "text" data-set focus]
+       [revenue-input-row :description "Description" "text" data-set focus]]
        [:div.box-footer
         [:div.col-sm-8.col-md-offset-5
          [button-tool-bar
           [button {:bs-style "success" :on-click save-function} "Save"]
           [button {:bs-style "danger" :on-click revenue-form-cancel } "Cancel"]]]
-        ]]]]]])
-
+        ]]]]])

 (defn revenue-add-form-onclick [data-set focus]
@@ -1307,19 +1304,6 @@
     (let [onres (fn[data] (accountant/navigate! "/revenue"))]
       (http-put (str serverhost "revenuerecords/" (:id @data-set)) onres (.serialize (Serializer.) (clj->js @data-set)))))
   (reset! focus "on"))
-
-
-
-(defn revenue-on-change [event]
-  (let [ele (.getElementById js/document "id")
-        eval (.-value ele)
-        onresp (fn [json]
-                 (let [dt (getdata json)]
-                   (set-key-value :villages dt)))]
-    (set-key-value :villages [])
-    (when-not ( >  1 (.-length eval))
-      (http-get-auth (str serverhost "villages/search?name=" eval) onresp))))
-

 (defn revenue-add-template []
   (let [add-data (r/atom {:isactive true})
@@ -1435,34 +1419,15 @@
 (defn khasragirdwani-form-validator [data-set]
   (first (b/validate data-set
                      :serialnumber [[v/required :message "Field is required Must be number"]]
-                     :year [[v/required :message "Field is required Must be number"]
+                     :villageid [[v/required :message "Field is required"]]
+                     :subdivisionid [[v/required :message "Field is required"]]
+                     ;; :tehsil [[v/required :message "Field is required"]]
+                     :year [[v/required :message "Field is required"]
                             [year-after? :message "Year must greater than 1900"]
                             [year-before? :message "Year must less than 9999"]]
                      :racknumber [[v/required :message "Field is required"]]
-                     :description [[v/required :message "Field is required"]])))
-
-(defn khasragirdwani-input-int [id ttype data-set placeholder in-focus]
-  [:input.form-control {:id id
-                        :type ttype
-                        :value (@data-set id)
-                        :placeholder placeholder
-                        :on-change #(swap! data-set assoc id (int (-> % .-target .-value )))
-                        :on-blur  #(reset! in-focus "on")
-                        }])
-
-
-(defn khasragirdwani-input-int-row [id label ttype data-set focus]
-  (let [input-focus (r/atom nil)]
-    (fn []
-      [:div.form-group
-       [:label.col-sm-3.control-label label]
-       [:div.col-sm-6 [khasragirdwani-input-int id ttype data-set label input-focus]]
-       [:div.col-sm-3 (if (or @input-focus @focus)
-                        (if (= nil (khasragirdwani-form-validator @data-set))
-                          [:div]
-                          [:div {:style  {:color "red"}}
-                           [:b (str (first ((khasragirdwani-form-validator @data-set) id)))]])
-                        [:div])]])))
+                     :description [[v/required :message "Field is required"]]
+                     )))

 (defn khasragirdwani-input-row [id label ttype data-set focus]
   (let [input-focus (r/atom nil)]
@@ -1477,47 +1442,23 @@
                            [:b (str (first ((khasragirdwani-form-validator @data-set) id)))]])
                         [:div])]])))

-
-(defn kg-sub-onchange [id val data-set]
-  (let [res (fn [json]
-              (let [dt (getdata json)]
-                (set-key-value :villages dt)))]
-    (do (http-get-auth (str serverhost "subdivisions/" val  "/villages") res)
-        (swap! data-set assoc id (js/parseInt val)))))
-
-(defn kg-sub-sel-tag [id data data-set]
-  [:select.form-control {:id id
-                         :value (@data-set id)
-                         :on-change #(kg-sub-onchange  id (-> % .-target .-value) data-set)}
-   [:option {:value 0} "--Select--"]
-   (for [d  data]
-     ^{:key (.-id d) }
-     [:option {:value (.-id d)} (.-subdivisionname d)])])
-
-(defn kg-form-sub-sel [label id opt-data data-set]
-  [:div.form-group
-   [:label.col-sm-3.control-label label]
-   [:div.col-sm-6 [kg-sub-sel-tag id opt-data data-set]]
-   [:div.col-sm-3 [:div]]])
-
-
-(defn kg-villages-sel-tag [id data data-set ]
-  [:select.form-control {:id id
-                         :value (@data-set id)
-                         :on-change #(swap! data-set assoc id (js/parseInt (-> % .-target .-value)))}
-   [:option {:value 0} "--Select--"]
-   (for [d  data]
-     ^{:key (.-id d) }
-     [:option {:value (.-id d)} (.-villagename d)])])
-
-(defn kg-form-villages-sel [label id opt-data data-set]
-  [:div.form-group
-   [:label.col-sm-3.control-label label]
-   [:div.col-sm-6 [kg-villages-sel-tag id opt-data data-set]]
-   [:div.col-sm-3 [:div]]])
+(defn khasragirdwani-input-int-row [id label ttype data-set focus]
+  (let [input-focus (r/atom nil)]
+    (fn []
+      [:div.form-group
+       [:label.col-sm-3.control-label label]
+       [:div.col-sm-6 [input-int id ttype data-set label input-focus]]
+       [:div.col-sm-3 (if (or @input-focus @focus)
+                        (if (= nil (revenue-form-validator @data-set))
+                          [:div]
+                          [:div {:style  {:color "red"}}
+                           [:b (str (first ((revenue-form-validator @data-set) id)))]])
+                        [:div])]])))
+

 (defn khasragirdwani-form-cancel [event]
   (accountant/navigate! "/khasragirdwani"))
+

 (defn khasragirdwani-template [doc-name data-set focus save-function]
   [:div.container
@@ -1528,51 +1469,38 @@
      [:div.form-horizontal
       [:div.box-body
        [khasragirdwani-input-int-row :serialnumber "Serial Number" "text" data-set focus]
-       [kg-form-sub-sel "Sub Division Name" :subdivisionid (:subdivisions @storage) data-set]
-       [kg-form-villages-sel "Village Name" :villageid (:villages @storage) data-set]
+       [all-form-sub-sel "Sub Division Name" :subdivisionid (:subdivisions @storage) data-set]
+       [all-form-villages-sel "Village Name" :villageid (:villages @storage) data-set]
+       ;; [khasragirdwani-input-row :tehsil "Tehsil" "text" data-set focus]
        [khasragirdwani-input-int-row :year "Year" "text" data-set focus]
        [khasragirdwani-input-row :racknumber "Rack Number" "text" data-set focus]
-       [khasragirdwani-input-row :description "Description" "text" data-set focus]
-       [:div.box-footer
-        [:div.col-sm-8.col-md-offset-5
-         [button-tool-bar
-          [button {:bs-style "success" :on-click save-function} "Save"]
-          [button {:bs-style "danger" :on-click khasragirdwani-form-cancel } "Cancel"]]]
-        ]]]]]])
-
-
+       [khasragirdwani-input-row :description "Description" "text" data-set focus]]
+      [:div.box-footer
+       [:div.col-sm-8.col-md-offset-5
+        [button-tool-bar
+         [button {:bs-style "success" :on-click save-function} "Save"]
+         [button {:bs-style "danger" :on-click khasragirdwani-form-cancel } "Cancel"]]]
+       ]]]]])

 (defn khasragirdwani-add-form-onclick [data-set focus]
-  (if (= nil (revenue-form-validator @data-set))
+  (if (= nil (khasragirdwani-form-validator @data-set))
     (let [onres (fn[json] (accountant/navigate! "/khasragirdwani"))]
-      (http-post (str serverhost "khasragirdwanis") onres  (.serialize (Serializer.) (clj->js @data-set)))))
-  (reset! focus "on"))
-
+      (http-post (str serverhost "khasragirdwanis")
+                 onres  (.serialize (Serializer.) (clj->js @data-set))))
+    (reset! focus "on")))

 (defn khasragirdwani-update-form-onclick [data-set focus]
   (if (= nil (khasragirdwani-form-validator @data-set))
     (let [onres (fn[data] (accountant/navigate! "/khasragirdwani"))]
-      (http-put (str serverhost "khasragirdwanis/" (:id @data-set)) onres (.serialize (Serializer.) (clj->js @data-set)))))
-  (reset! focus "on"))
-
-
-
-(defn khasragirdwani-on-change [event]
-  (let [ele (.getElementById js/document "id")
-        eval (.-value ele)
-        onresp (fn [json]
-                 (let [dt (getdata json)]
-                   (set-key-value :villages dt)))]
-    (set-key-value :villages [])
-    (when-not ( >  1 (.-length eval))
-      (http-get-auth (str serverhost "villages/search?name=" eval) onresp))))
-
+      (http-put (str serverhost "khasragirdwanis/"
+                     (:id @data-set)) onres (.serialize (Serializer.) (clj->js @data-set))))
+    (reset! focus "on")))

 (defn khasragirdwani-add-template []
   (let [add-data (r/atom {:isactive true})
         focus (r/atom nil)]
     (fn [] [khasragirdwani-template
-           "Khasra Girdwani Add Form"
+           "Khasragirdwani Add Form"
            add-data focus
            #(khasragirdwani-add-form-onclick add-data focus)])))

@@ -1581,16 +1509,16 @@
                              :serialnumber (.-serialnumber dmt)
                              :subdivisionid (.-subdivisionid dmt)
                              :villageid (.-villageid dmt)
+                             :tehsil (.-tehsil dmt)
                              :year (.-year dmt)
                              :racknumber (.-racknumber dmt)
                              :description (.-description dmt)
                              :isactive true})
         focus (r/atom nil)]
     (fn [] [khasragirdwani-template
-           "KhasraGirdwani Update Form"
-           update-data focus
-           #(khasragirdwani-update-form-onclick update-data focus)])))
-
+            "Khasragirdwani Update Form"
+            update-data focus
+            #(khasragirdwani-update-form-onclick update-data focus)])))

 (defn khasragirdwani-update[id]
   (accountant/navigate! (str "/khasragirdwani/update/" id)))
@@ -1599,7 +1527,6 @@
   (let [onres (fn [json]
                 (accountant/navigate! "/khasragirdwani"))]
     (http-delete (str serverhost "khasragirdwanis/" id)  onres)))
-

 (defroute khasragirdwani-add-path "/khasragirdwani/add" []
   (if (nil? (get-value! :user)) (accountant/navigate! "/login")
@@ -1608,27 +1535,25 @@
                            (set-page! [khasragirdwani-add-template])))]
         (http-get-auth (str serverhost "subdivisions") onres))))

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

 (defn khasragirdwani-add [event]
   (accountant/navigate! "/khasragirdwani/add"))

-
-
 (defn render-khasragirdwani [khasragirdwanis]
-  [:div.col-md-12
+  [:div.col-sm-12
    [:div {:class "box"}
     [:div {:class "box-header"}
-     [:h3.box-title "List of Khasragirdwani"]]
+     [:h3.box-title "List of Khasragirdwani Records"]]
     [:div.box-body
       [:div.form-group
        [:input {:type "button" :value "Add"
@@ -1640,12 +1565,13 @@
           (when (is-admin-or-super-admin)[:th " "])
           (when (is-admin-or-super-admin)[:th " "])
           [:th "S.No"]
+          [:th "Name of the Village"]
           [:th "Sub Division Name"]
-          [:th "Name of the Village"]
           ;; [:th "Tehsil"]
           [:th "Year"]
           [:th "Rack Number"]
-          [:th "Description"]]]
+          [:th "Description"]
+          ]]
         [:tbody
          (doall (for [mt khasragirdwanis]
                   ^{:key (.-id mt)}
@@ -1657,54 +1583,45 @@
                      [:td  [button {:bs-style "danger"
                                     :on-click #(khasragirdwani-delete(.-id mt))} "Delete"]])
                    [:td (.-serialnumber mt)]
+                   [:td (.-villagename mt)]
                    [:td (.-subdivisionname mt)]
-                   [:td (.-villagename mt)]
-                   ;; [:td (.-tehsil mt)]
+                   ;;  [:td (.-tehsil mt)]
                    [:td (.-year mt)]
                    [:td (.-racknumber mt)]
                    [:td (.-description mt)]
                    ]))]]]
        [:div.col-sm-6.col-md-offset-5 [shared-state 0]]]]])

-
 (defroute khasragirdwani-list "/khasragirdwani" []
   (let [onres (fn [json]
                 (cond (= (get-status json) 200) (set-authorized-list json :khasragirdwanis render-khasragirdwani)
                       :else (sign-out)))]
-    (set-url "/khasragirdwani")
     (set-key-value :is-searched-results false)
     (http-get-auth (str serverhost "khasragirdwanis?pageIndex="(dec (get-value! :current-page))"&pageSize=10") onres)))

 ;; ---------------------------------------------------------
 ;; masavi-records
-

 (defn masavi-form-validator [data-set]
   (first (b/validate data-set
                      :serialnumber [[v/required :message "Field is required Must be number"]]
-                     :year [[v/required :message "Field is required Must be number"]
+                     :subdivisionid [[v/required :message "Field is required"]]
+                     :villageid [[v/required :message "Field is required"]]
+                     ;; :tehsil [[v/required :message "Field is required"]]
+                     :year [[v/required :message "Field is required"]
                             [year-after? :message "Year must greater than 1900"]
                             [year-before? :message "Year must less than 9999"]]
                      :racknumber [[v/required :message "Field is required"]]
-                     :description [[v/required :message "Field is required"]])))
-
-(defn masavi-input-int [id ttype data-set placeholder in-focus]
-  [:input.form-control {:id id
-                        :type ttype
-                        :value (@data-set id)
-                        :placeholder placeholder
-                        :on-change #(swap! data-set assoc id (int (-> % .-target .-value )))
-                        :on-blur  #(reset! in-focus "on")
-                        }])
-
+                     :description [[v/required :message "Field is required"]]
+                     )))

 (defn masavi-input-int-row [id label ttype data-set focus]
   (let [input-focus (r/atom nil)]
     (fn []
       [:div.form-group
        [:label.col-sm-3.control-label label]
-       [:div.col-sm-6 [masavi-input-int id ttype data-set label input-focus]]
+       [:div.col-sm-6 [input-int id ttype data-set label input-focus]]
        [:div.col-sm-3 (if (or @input-focus @focus)
                         (if (= nil (masavi-form-validator @data-set))
                           [:div]
@@ -1725,45 +1642,6 @@
                            [:b (str (first ((masavi-form-validator @data-set) id)))]])
                         [:div])]])))

-
-(defn ms-sub-onchange [id val data-set]
-  (let [res (fn [json]
-              (let [dt (getdata json)]
-                (set-key-value :villages dt)))]
-    (do (http-get-auth (str serverhost "subdivisions/" val  "/villages") res)
-        (swap! data-set assoc id (js/parseInt val)))))
-
-(defn ms-sub-sel-tag [id data data-set]
-  [:select.form-control {:id id
-                         :value (@data-set id)
-                         :on-change #(kg-sub-onchange  id (-> % .-target .-value) data-set)}
-   [:option {:value 0} "--Select--"]
-   (for [d  data]
-     ^{:key (.-id d) }
-     [:option {:value (.-id d)} (.-subdivisionname d)])])
-
-(defn ms-form-sub-sel [label id opt-data data-set]
-  [:div.form-group
-   [:label.col-sm-3.control-label label]
-   [:div.col-sm-6 [ms-sub-sel-tag id opt-data data-set]]
-   [:div.col-sm-3 [:div]]])
-
-
-(defn ms-villages-sel-tag [id data data-set ]
-  [:select.form-control {:id id
-                         :value (@data-set id)
-                         :on-change #(swap! data-set assoc id (js/parseInt (-> % .-target .-value)))}
-   [:option {:value 0} "--Select--"]
-   (for [d  data]
-     ^{:key (.-id d) }
-     [:option {:value (.-id d)} (.-villagename d)])])
-
-(defn ms-form-villages-sel [label id opt-data data-set]
-  [:div.form-group
-   [:label.col-sm-3.control-label label]
-   [:div.col-sm-6 [ms-villages-sel-tag id opt-data data-set]]
-   [:div.col-sm-3 [:div]]])
-
 (defn masavi-form-cancel [event]
   (accountant/navigate! "/masavi"))

@@ -1776,51 +1654,37 @@
      [:div.form-horizontal
       [:div.box-body
        [masavi-input-int-row :serialnumber "Serial Number" "text" data-set focus]
-       [ms-form-sub-sel "Sub Division Name" :subdivisionid (:subdivisions @storage) data-set]
-       [ms-form-villages-sel "Village Name" :villageid (:villages @storage) data-set]
+       [all-form-sub-sel "Sub Division Name" :subdivisionid (:subdivisions @storage) data-set]
+       [all-form-villages-sel "Village Name" :villageid (:villages @storage) data-set]
+       ;; [masavi-input-row :tehsil "Tehsil" "text" data-set focus]
        [masavi-input-int-row :year "Year" "text" data-set focus]
        [masavi-input-row :racknumber "Rack Number" "text" data-set focus]
-       [masavi-input-row :description "Description" "text" data-set focus]
-       [:div.box-footer
-        [:div.col-sm-8.col-md-offset-5
-         [button-tool-bar
-          [button {:bs-style "success" :on-click save-function} "Save"]
-          [button {:bs-style "danger" :on-click masavi-form-cancel } "Cancel"]]]
-        ]]]]]])
-
+       [masavi-input-row :description "Description" "text" data-set focus]]
+
+      [:div.box-footer
+       [:div.col-sm-8.col-md-offset-5
+        [button-tool-bar
+         [button {:bs-style "success" :on-click save-function} "Save"]
+         [button {:bs-style "danger" :on-click masavi-form-cancel } "Cancel"]]]]]]]])

 (defn masavi-add-form-onclick [data-set focus]
-  (if (= nil (revenue-form-validator @data-set))
+  (if (= nil (masavi-form-validator @data-set))
     (let [onres (fn[json] (accountant/navigate! "/masavi"))]
-      (http-post (str serverhost "masavis") onres  (.serialize (Serializer.) (clj->js @data-set)))))
-  (reset! focus "on"))
-
+      (http-post (str serverhost "masavis") onres  (.serialize (Serializer.) (clj->js @data-set))))
+    (reset! focus "on")))

 (defn masavi-update-form-onclick [data-set focus]
   (if (= nil (masavi-form-validator @data-set))
     (let [onres (fn[data] (accountant/navigate! "/masavi"))]
-      (http-put (str serverhost "masavis/" (:id @data-set)) onres (.serialize (Serializer.) (clj->js @data-set)))))
-  (reset! focus "on"))
-
-
-
-(defn masavi-on-change [event]
-  (let [ele (.getElementById js/document "id")
-        eval (.-value ele)
-        onresp (fn [json]
-                 (let [dt (getdata json)]
-                   (set-key-value :villages dt)))]
-    (set-key-value :villages [])
-    (when-not ( >  1 (.-length eval))
-      (http-get-auth (str serverhost "villages/search?name=" eval) onresp))))
-
+      (http-put (str serverhost "masavis/" (:id @data-set)) onres (.serialize (Serializer.) (clj->js @data-set))))
+    (reset! focus "on")))

 (defn masavi-add-template []
   (let [add-data (r/atom {:isactive true})
         focus (r/atom nil)]
     (fn [] [masavi-template
-           "Khasra Girdwani Add Form"
+           "Masavi Add Form"
            add-data focus
            #(masavi-add-form-onclick add-data focus)])))

@@ -1829,15 +1693,15 @@
                              :serialnumber (.-serialnumber dmt)
                              :subdivisionid (.-subdivisionid dmt)
                              :villageid (.-villageid dmt)
+                             ;; :tehsil (.-tehsil dmt)
                              :year (.-year dmt)
                              :racknumber (.-racknumber dmt)
-                             :description (.-description dmt)
-                             :isactive true})
+                             :description (.-description dmt)})
         focus (r/atom nil)]
     (fn [] [masavi-template
-           "masavi Update Form"
-           update-data focus
-           #(masavi-update-form-onclick update-data focus)])))
+            "Masavi Update Form"
+            update-data focus
+            #(masavi-update-form-onclick update-data focus)])))

 (defn masavi-update[id]
@@ -1847,7 +1711,6 @@
   (let [onres (fn [json]
                 (accountant/navigate! "/masavi"))]
     (http-delete (str serverhost "masavis/" id)  onres)))
-

 (defroute masavi-add-path "/masavi/add" []
   (if (nil? (get-value! :user)) (accountant/navigate! "/login")
@@ -1857,26 +1720,24 @@
         (http-get-auth (str serverhost "subdivisions") onres))))

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

 (defn masavi-add [event]
   (accountant/navigate! "/masavi/add"))
-
-

 (defn render-masavi [masavis]
   [:div.col-md-12
    [:div {:class "box"}
     [:div {:class "box-header"}
-     [:h3.box-title "List of masavi"]]
+     [:h3.box-title "List of Masavi Records"]]
     [:div.box-body
       [:div.form-group
        [:input {:type "button" :value "Add"
@@ -1888,12 +1749,13 @@
           (when (is-admin-or-super-admin)[:th " "])
           (when (is-admin-or-super-admin)[:th " "])
           [:th "S.No"]
+          [:th "Name of the Village"]
           [:th "Sub Division Name"]
-          [:th "Name of the Village"]
           ;; [:th "Tehsil"]
           [:th "Year"]
           [:th "Rack Number"]
-          [:th "Description"]]]
+          [:th "Description"]
+         ]]
         [:tbody
          (doall (for [mt masavis]
                   ^{:key (.-id mt)}
@@ -1905,8 +1767,8 @@
                      [:td  [button {:bs-style "danger"
                                     :on-click #(masavi-delete(.-id mt))} "Delete"]])
                    [:td (.-serialnumber mt)]
+                   [:td (.-villagename mt)]
                    [:td (.-subdivisionname mt)]
-                   [:td (.-villagename mt)]
                    ;; [:td (.-tehsil mt)]
                    [:td (.-year mt)]
                    [:td (.-racknumber mt)]
@@ -1914,36 +1776,29 @@
                    ]))]]]
        [:div.col-sm-6.col-md-offset-5 [shared-state 0]]]]])

-
 (defroute masavi-list "/masavi" []
   (let [onres (fn [json]
                 (cond (= (get-status json) 200) (set-authorized-list json :masavis render-masavi)
                       :else (sign-out)))]
-    (set-url "/masavi")
     (set-key-value :is-searched-results false)
     (http-get-auth (str serverhost "masavis?pageIndex="(dec (get-value! :current-page))"&pageSize=10") onres)))

+
 ;; ---------------------------------------------------------
 ;; Consolidation-records
-

 (defn consolidation-form-validator [data-set]
   (first (b/validate data-set
                      :serialnumber [[v/required :message "Field is required Must be number"]]
+                     :subdivisionid [[v/required :message "Field is required"]]
+                     :villageid [[v/required :message "Field is required"]]
+                     ;; :tehsil [[v/required :message "Field is required"]]
                      :year [[v/required :message "Field is required Must be number"]
                             [year-after? :message "Year must greater than 1900"]
                             [year-before? :message "Year must less than 9999"]]
                      :racknumber [[v/required :message "Field is required"]]
-                     :description [[v/required :message "Field is required"]])))
-
-(defn consolidation-input-int [id ttype data-set placeholder in-focus]
-  [:input.form-control {:id id
-                        :type ttype
-                        :value (@data-set id)
-                        :placeholder placeholder
-                        :on-change #(swap! data-set assoc id (int (-> % .-target .-value )))
-                        :on-blur  #(reset! in-focus "on")
-                        }])
+                     :description [[v/required :message "Field is required"]]
+                     )))

 (defn consolidation-input-int-row [id label ttype data-set focus]
@@ -1951,7 +1806,7 @@
     (fn []
       [:div.form-group
        [:label.col-sm-3.control-label label]
-       [:div.col-sm-6 [consolidation-input-int id ttype data-set label input-focus]]
+       [:div.col-sm-6 [input-int id ttype data-set label input-focus]]
        [:div.col-sm-3 (if (or @input-focus @focus)
                         (if (= nil (consolidation-form-validator @data-set))
                           [:div]
@@ -1973,46 +1828,11 @@
                         [:div])]])))

-(defn cons-sub-onchange [id val data-set]
-  (let [res (fn [json]
-              (let [dt (getdata json)]
-                (set-key-value :villages dt)))]
-    (do (http-get-auth (str serverhost "subdivisions/" val  "/villages") res)
-        (swap! data-set assoc id (js/parseInt val)))))
-
-(defn cons-sub-sel-tag [id data data-set]
-  [:select.form-control {:id id
-                         :value (@data-set id)
-                         :on-change #(cons-sub-onchange  id (-> % .-target .-value) data-set)}
-   [:option {:value 0} "--Select--"]
-   (for [d  data]
-     ^{:key (.-id d) }
-     [:option {:value (.-id d)} (.-subdivisionname d)])])
-
-(defn cons-form-sub-sel [label id opt-data data-set]
-  [:div.form-group
-   [:label.col-sm-3.control-label label]
-   [:div.col-sm-6 [cons-sub-sel-tag id opt-data data-set]]
-   [:div.col-sm-3 [:div]]])
-
-
-(defn cons-villages-sel-tag [id data data-set ]
-  [:select.form-control {:id id
-                         :value (@data-set id)
-                         :on-change #(swap! data-set assoc id (js/parseInt (-> % .-target .-value)))}
-   [:option {:value 0} "--Select--"]
-   (for [d  data]
-     ^{:key (.-id d) }
-     [:option {:value (.-id d)} (.-villagename d)])])
-
-(defn cons-form-villages-sel [label id opt-data data-set]
-  [:div.form-group
-   [:label.col-sm-3.control-label label]
-   [:div.col-sm-6 [cons-villages-sel-tag id opt-data data-set]]
-   [:div.col-sm-3 [:div]]])
-
 (defn consolidation-form-cancel [event]
   (accountant/navigate! "/consolidation"))
+
+(defn consolidation-add [event]
+  (accountant/navigate! "/consolidation/add"))

 (defn consolidation-template [doc-name data-set focus save-function]
   [:div.container
@@ -2023,51 +1843,38 @@
      [:div.form-horizontal
       [:div.box-body
        [consolidation-input-int-row :serialnumber "Serial Number" "text" data-set focus]
-       [cons-form-sub-sel "Sub Division Name" :subdivisionid (:subdivisions @storage) data-set]
-       [cons-form-villages-sel "Village Name" :villageid (:villages @storage) data-set]
+       [all-form-sub-sel "Sub Division Name" :subdivisionid (:subdivisions @storage) data-set]
+       [all-form-villages-sel "Village Name" :villageid (:villages @storage) data-set]
+       ;; [consolidation-input-row :tehsil "Tehsil" "text" data-set focus]
        [consolidation-input-int-row :year "Year" "text" data-set focus]
        [consolidation-input-row :racknumber "Rack Number" "text" data-set focus]
-       [consolidation-input-row :description "Description" "text" data-set focus]
-       [:div.box-footer
-        [:div.col-sm-8.col-md-offset-5
-         [button-tool-bar
-          [button {:bs-style "success" :on-click save-function} "Save"]
-          [button {:bs-style "danger" :on-click consolidation-form-cancel } "Cancel"]]]
-        ]]]]]])
-
+       [consolidation-input-row :description "Description" "text" data-set focus]]
+      [:div.box-footer
+       [:div.col-sm-8.col-md-offset-5
+        [button-tool-bar
+         [button {:bs-style "success" :on-click save-function} "Save"]
+         [button {:bs-style "danger" :on-click consolidation-form-cancel } "Cancel"]]]
+       ]]]]])

 (defn consolidation-add-form-onclick [data-set focus]
-  (if (= nil (revenue-form-validator @data-set))
+  (if (= nil (consolidation-form-validator @data-set))
     (let [onres (fn[json] (accountant/navigate! "/consolidation"))]
-      (http-post (str serverhost "consolidations") onres  (.serialize (Serializer.) (clj->js @data-set)))))
-  (reset! focus "on"))
+      (http-post (str serverhost "consolidations") onres  (.serialize (Serializer.) (clj->js @data-set))))
+  (reset! focus "on")))

 (defn consolidation-update-form-onclick [data-set focus]
   (if (= nil (consolidation-form-validator @data-set))
     (let [onres (fn[data] (accountant/navigate! "/consolidation"))]
-      (http-put (str serverhost "consolidations/" (:id @data-set)) onres (.serialize (Serializer.) (clj->js @data-set)))))
-  (reset! focus "on"))
-
-
-
-(defn consolidation-on-change [event]
-  (let [ele (.getElementById js/document "id")
-        eval (.-value ele)
-        onresp (fn [json]
-                 (let [dt (getdata json)]
-                   (set-key-value :villages dt)))]
-    (set-key-value :villages [])
-    (when-not ( >  1 (.-length eval))
-      (http-get-auth (str serverhost "villages/search?name=" eval) onresp))))
-
+      (http-put (str serverhost "consolidations/" (:id @data-set)) onres (.serialize (Serializer.) (clj->js @data-set))))
+    (reset! focus "on")))

 (defn consolidation-add-template []
   (let [add-data (r/atom {:isactive true})
         focus (r/atom nil)]
     (fn [] [consolidation-template
-           "Khasra Girdwani Add Form"
+           "Consolidation Add Form"
            add-data focus
            #(consolidation-add-form-onclick add-data focus)])))

@@ -2076,15 +1883,15 @@
                              :serialnumber (.-serialnumber dmt)
                              :subdivisionid (.-subdivisionid dmt)
                              :villageid (.-villageid dmt)
+                             ;; :tehsil (.-tehsil dmt)
                              :year (.-year dmt)
                              :racknumber (.-racknumber dmt)
-                             :description (.-description dmt)
-                             :isactive true})
+                             :description (.-description dmt)})
         focus (r/atom nil)]
     (fn [] [consolidation-template
-           "consolidation Update Form"
-           update-data focus
-           #(consolidation-update-form-onclick update-data focus)])))
+            "Consolidation Update Form"
+            update-data focus
+            #(consolidation-update-form-onclick update-data focus)])))

 (defn consolidation-update[id]
@@ -2095,111 +1902,96 @@
                 (accountant/navigate! "/consolidation"))]
     (http-delete (str serverhost "consolidations/" id)  onres)))

-
 (defroute consolidation-add-path "/consolidation/add" []
   (if (nil? (get-value! :user)) (accountant/navigate! "/login")
-      (let [onres (fn[json](
-                           (set-key-value :subdivisions (getdata json))
-                           (set-page! [consolidation-add-template])))]
+      (let [onres (fn[json]
+                    ((set-key-value :subdivisions (getdata json))
+                     (set-page! [consolidation-add-template])))]
         (http-get-auth (str serverhost "subdivisions") 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)))])))
-        sub-res (fn[json](set-key-value :subdivisions (getdata json)))]
-    (do
-      (http-get-auth (str serverhost "villages") onres)
-      (http-get-auth (str serverhost "subdivisions") sub-res))))
-
-(defn consolidation-add [event]
-  (accountant/navigate! "/consolidation/add"))
-
-
+  (let [onres (fn[json] (set-key-value :villages (getdata json)))
+        sub-res (fn[json] (set-key-value :subdivisions (getdata json)))]
+    (http-get-auth (str serverhost "villages") onres)
+    (http-get-auth (str serverhost "subdivisions") sub-res)
+    (set-page! [consolidation-update-template id
+                (first (filter (fn[obj]
+                                 (=(.-id obj) (.parseInt js/window id)))
+                               (get-value! :consolidations)))])))

 (defn render-consolidation [consolidations]
   [:div.col-md-12
    [:div {:class "box"}
     [:div {:class "box-header"}
-     [:h3.box-title "List of consolidation"]]
+     [:h3.box-title "List of Consolidation Records"]]
     [:div.box-body
-      [:div.form-group
-       [:input {:type "button" :value "Add"
-                :class "btn btn-primary" :on-click consolidation-add}]]
-      [:div.table-responsive
-       [:table {:class "table table-bordered table-striped dataTable"}
-        [:thead
-         [:tr
-          (when (is-admin-or-super-admin)[:th " "])
-          (when (is-admin-or-super-admin)[:th " "])
-          [:th "S.No"]
-          [:th "Sub Division Name"]
-          [:th "Name of the Village"]
-          ;; [:th "Tehsil"]
-          [:th "Year"]
-          [:th "Rack Number"]
-          [:th "Description"]]]
-        [:tbody
-         (doall (for [mt consolidations]
-                  ^{:key (.-id mt)}
-                  [:tr
-                   (when (is-admin-or-super-admin)
-                     [:td [button {:bs-style "success"
-                                   :on-click  #(consolidation-update(.-id mt))} "Update"]])
-                   (when (is-admin-or-super-admin)
-                     [:td  [button {:bs-style "danger"
-                                    :on-click #(consolidation-delete(.-id mt))} "Delete"]])
-                   [:td (.-serialnumber mt)]
-                   [:td (.-subdivisionname mt)]
-                   [:td (.-villagename mt)]
-                   ;; [:td (.-tehsil mt)]
-                   [:td (.-year mt)]
-                   [:td (.-racknumber mt)]
-                   [:td (.-description mt)]
-                   ]))]]]
+     [:div.form-group
+      [:input {:type "button" :value "Add"
+               :class "btn btn-primary" :on-click consolidation-add}]]
+     [:div.table-responsive
+      [:table {:class "table table-bordered table-striped dataTable"}
+       [:thead
+        [:tr
+         (when (is-admin-or-super-admin)[:th " "])
+         (when (is-admin-or-super-admin)[:th " "])
+         [:th "S.No"]
+         [:th "Name of the Village"]
+         [:th "Sub Division Name"]
+         ;; [:th "Tehsil"]
+         [:th "Year"]
+         [:th "Rack Number"]
+         [:th "Description"]
+         ]]
+       [:tbody
+        (doall (for [mt consolidations]
+                 ^{:key (.-id mt)}
+                 [:tr
+                  (when (is-admin-or-super-admin)
+                    [:td [button {:bs-style "success"
+                                  :on-click  #(consolidation-update(.-id mt))} "Update"]])
+                  (when (is-admin-or-super-admin)
+                    [:td  [button {:bs-style "danger"
+                                   :on-click #(consolidation-delete(.-id mt))} "Delete"]])
+                  [:td (.-serialnumber mt)]
+                  [:td (.-villagename mt)]
+                  [:td (.-subdivisionname mt)]
+                  ;; [:td (.-tehsil mt)]
+                  [:td (.-year mt)]
+                  [:td (.-racknumber mt)]
+                  [:td (.-description mt)]
+                  ]))]]]
        [:div.col-sm-6.col-md-offset-5 [shared-state 0]]]]])
-

 (defroute consolidation-list "/consolidation" []
   (let [onres (fn [json]
                 (cond (= (get-status json) 200) (set-authorized-list json :consolidations render-consolidation)
                       :else (sign-out)))]
-    (set-url "/consolidation")
     (set-key-value :is-searched-results false)
     (http-get-auth (str serverhost "consolidations?pageIndex="(dec (get-value! :current-page))"&pageSize=10") onres)))

 ;; ---------------------------------------------------------
 ;; fieldbook-records
-

 (defn fieldbook-form-validator [data-set]
   (first (b/validate data-set
                      :serialnumber [[v/required :message "Field is required Must be number"]]
+                     :subdivisionid [[v/required :message "Field is required"]]
+                     :villageid [[v/required :message "Field is required"]]
+                     ;; :tehsil [[v/required :message "Field is required"]]
                      :year [[v/required :message "Field is required Must be number"]
                             [year-after? :message "Year must greater than 1900"]
                             [year-before? :message "Year must less than 9999"]]
                      :racknumber [[v/required :message "Field is required"]]
-                     :description [[v/required :message "Field is required"]])))
-
-(defn fieldbook-input-int [id ttype data-set placeholder in-focus]
-  [:input.form-control {:id id
-                        :type ttype
-                        :value (@data-set id)
-                        :placeholder placeholder
-                        :on-change #(swap! data-set assoc id (int (-> % .-target .-value )))
-                        :on-blur  #(reset! in-focus "on")
-                        }])
-
+                     :description [[v/required :message "Field is required"]]
+                     )))

 (defn fieldbook-input-int-row [id label ttype data-set focus]
   (let [input-focus (r/atom nil)]
     (fn []
       [:div.form-group
        [:label.col-sm-3.control-label label]
-       [:div.col-sm-6 [fieldbook-input-int id ttype data-set label input-focus]]
+       [:div.col-sm-6 [input-int id ttype data-set label input-focus]]
        [:div.col-sm-3 (if (or @input-focus @focus)
                         (if (= nil (fieldbook-form-validator @data-set))
                           [:div]
@@ -2220,47 +2012,9 @@
                            [:b (str (first ((fieldbook-form-validator @data-set) id)))]])
                         [:div])]])))

-
-(defn fb-sub-onchange [id val data-set]
-  (let [res (fn [json]
-              (let [dt (getdata json)]
-                (set-key-value :villages dt)))]
-    (do (http-get-auth (str serverhost "subdivisions/" val  "/villages") res)
-        (swap! data-set assoc id (js/parseInt val)))))
-
-(defn fb-sub-sel-tag [id data data-set]
-  [:select.form-control {:id id
-                         :value (@data-set id)
-                         :on-change #(fb-sub-onchange  id (-> % .-target .-value) data-set)}
-   [:option {:value 0} "--Select--"]
-   (for [d  data]
-     ^{:key (.-id d) }
-     [:option {:value (.-id d)} (.-subdivisionname d)])])
-
-(defn fb-form-sub-sel [label id opt-data data-set]
-  [:div.form-group
-   [:label.col-sm-3.control-label label]
-   [:div.col-sm-6 [fb-sub-sel-tag id opt-data data-set]]
-   [:div.col-sm-3 [:div]]])
-
-
-(defn fb-villages-sel-tag [id data data-set ]
-  [:select.form-control {:id id
-                         :value (@data-set id)
-                         :on-change #(swap! data-set assoc id (js/parseInt (-> % .-target .-value)))}
-   [:option {:value 0} "--Select--"]
-   (for [d  data]
-     ^{:key (.-id d) }
-     [:option {:value (.-id d)} (.-villagename d)])])
-
-(defn fb-form-villages-sel [label id opt-data data-set]
-  [:div.form-group
-   [:label.col-sm-3.control-label label]
-   [:div.col-sm-6 [fb-villages-sel-tag id opt-data data-set]]
-   [:div.col-sm-3 [:div]]])
-
 (defn fieldbook-form-cancel [event]
   (accountant/navigate! "/fieldbook"))
+

 (defn fieldbook-template [doc-name data-set focus save-function]
   [:div.container
@@ -2271,51 +2025,35 @@
      [:div.form-horizontal
       [:div.box-body
        [fieldbook-input-int-row :serialnumber "Serial Number" "text" data-set focus]
-       [fb-form-sub-sel "Sub Division Name" :subdivisionid (:subdivisions @storage) data-set]
-       [fb-form-villages-sel "Village Name" :villageid (:villages @storage) data-set]
+       [all-form-sub-sel "Sub Division Name" :subdivisionid (:subdivisions @storage) data-set]
+       [all-form-villages-sel "Village Name" :villageid (:villages @storage) data-set]
+       ;; [fieldbook-input-row :tehsil "Tehsil" "text" data-set focus]
        [fieldbook-input-int-row :year "Year" "text" data-set focus]
        [fieldbook-input-row :racknumber "Rack Number" "text" data-set focus]
-       [fieldbook-input-row :description "Description" "text" data-set focus]
-       [:div.box-footer
-        [:div.col-sm-8.col-md-offset-5
-         [button-tool-bar
-          [button {:bs-style "success" :on-click save-function} "Save"]
-          [button {:bs-style "danger" :on-click fieldbook-form-cancel } "Cancel"]]]
-        ]]]]]])
-
-
+       [fieldbook-input-row :description "Description" "text" data-set focus]]
+      [:div.box-footer
+       [:div.col-sm-8.col-md-offset-5
+        [button-tool-bar
+         [button {:bs-style "success" :on-click save-function} "Save"]
+         [button {:bs-style "danger" :on-click fieldbook-form-cancel } "Cancel"]]] ]]]]])

 (defn fieldbook-add-form-onclick [data-set focus]
-  (if (= nil (revenue-form-validator @data-set))
+  (if (= nil (fieldbook-form-validator @data-set))
     (let [onres (fn[json] (accountant/navigate! "/fieldbook"))]
-      (http-post (str serverhost "fieldbooks") onres  (.serialize (Serializer.) (clj->js @data-set)))))
-  (reset! focus "on"))
-
+      (http-post (str serverhost "fieldbooks") onres  (.serialize (Serializer.) (clj->js @data-set))))
+    (reset! focus "on")))

 (defn fieldbook-update-form-onclick [data-set focus]
   (if (= nil (fieldbook-form-validator @data-set))
     (let [onres (fn[data] (accountant/navigate! "/fieldbook"))]
-      (http-put (str serverhost "fieldbooks/" (:id @data-set)) onres (.serialize (Serializer.) (clj->js @data-set)))))
-  (reset! focus "on"))
-
-
-
-(defn fieldbook-on-change [event]
-  (let [ele (.getElementById js/document "id")
-        eval (.-value ele)
-        onresp (fn [json]
-                 (let [dt (getdata json)]
-                   (set-key-value :villages dt)))]
-    (set-key-value :villages [])
-    (when-not ( >  1 (.-length eval))
-      (http-get-auth (str serverhost "villages/search?name=" eval) onresp))))
-
+      (http-put (str serverhost "fieldbooks/" (:id @data-set)) onres (.serialize (Serializer.) (clj->js @data-set))))
+    (reset! focus "on")))

 (defn fieldbook-add-template []
   (let [add-data (r/atom {:isactive true})
         focus (r/atom nil)]
     (fn [] [fieldbook-template
-           "Khasra Girdwani Add Form"
+           "Field Book Add Form"
            add-data focus
            #(fieldbook-add-form-onclick add-data focus)])))

@@ -2324,15 +2062,15 @@
                              :serialnumber (.-serialnumber dmt)
                              :subdivisionid (.-subdivisionid dmt)
                              :villageid (.-villageid dmt)
+                             ;; :tehsil (.-tehsil dmt)
                              :year (.-year dmt)
                              :racknumber (.-racknumber dmt)
-                             :description (.-description dmt)
-                             :isactive true})
+                             :description (.-description dmt)})
         focus (r/atom nil)]
     (fn [] [fieldbook-template
-           "fieldbook Update Form"
-           update-data focus
-           #(fieldbook-update-form-onclick update-data focus)])))
+            "Field Book Update Form"
+            update-data focus
+            #(fieldbook-update-form-onclick update-data focus)])))

 (defn fieldbook-update[id]
@@ -2342,7 +2080,6 @@
   (let [onres (fn [json]
                 (accountant/navigate! "/fieldbook"))]
     (http-delete (str serverhost "fieldbooks/" id)  onres)))
-

 (defroute fieldbook-add-path "/fieldbook/add" []
   (if (nil? (get-value! :user)) (accountant/navigate! "/login")
@@ -2352,26 +2089,23 @@
         (http-get-auth (str serverhost "subdivisions") onres))))

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

 (defn fieldbook-add [event]
   (accountant/navigate! "/fieldbook/add"))
-
-

 (defn render-fieldbook [fieldbooks]
   [:div.col-md-12
    [:div {:class "box"}
     [:div {:class "box-header"}
-     [:h3.box-title "List of fieldbook"]]
+     [:h3.box-title "List of Field Book Records"]]
     [:div.box-body
       [:div.form-group
        [:input {:type "button" :value "Add"
@@ -2380,41 +2114,40 @@
        [:table {:class "table table-bordered table-striped dataTable"}
         [:thead
          [:tr
-          (when (is-admin-or-super-admin)[:th " "])
-          (when (is-admin-or-super-admin)[:th " "])
+          (when (is-admin-or-super-admin) [:th " "])
+          (when (is-admin-or-super-admin) [:th " "])
           [:th "S.No"]
+          [:th "Name of the Village"]
           [:th "Sub Division Name"]
-          [:th "Name of the Village"]
           ;; [:th "Tehsil"]
           [:th "Year"]
           [:th "Rack Number"]
-          [:th "Description"]]]
+          [:th "Description"]
+          ]]
         [:tbody
-         (doall (for [mt fieldbooks]
-                  ^{:key (.-id mt)}
-                  [:tr
-                   (when (is-admin-or-super-admin)
-                     [:td [button {:bs-style "success"
-                                   :on-click  #(fieldbook-update(.-id mt))} "Update"]])
-                   (when (is-admin-or-super-admin)
-                     [:td  [button {:bs-style "danger"
-                                    :on-click #(fieldbook-delete(.-id mt))} "Delete"]])
-                   [:td (.-serialnumber mt)]
-                   [:td (.-subdivisionname mt)]
-                   [:td (.-villagename mt)]
-                   ;; [:td (.-tehsil mt)]
-                   [:td (.-year mt)]
-                   [:td (.-racknumber mt)]
-                   [:td (.-description mt)]
-                   ]))]]]
+         (doall(for [mt fieldbooks]
+                 ^{:key (.-id mt)}
+                 [:tr
+                  (when (is-admin-or-super-admin)
+                    [:td [button {:bs-style "success"
+                                  :on-click  #(fieldbook-update(.-id mt))} "Update"]])
+                  (when (is-admin-or-super-admin)
+                    [:td  [button {:bs-style "danger"
+                                   :on-click #(fieldbook-delete(.-id mt))} "Delete"]])
+                  [:td (.-serialnumber mt)]
+                  [:td (.-villagename mt)]
+                  [:td (.-subdivisionname mt)]
+                  ;; [:td (.-tehsil mt)]
+                  [:td (.-year mt)]
+                  [:td (.-racknumber mt)]
+                  [:td (.-description mt)]
+                  ]))]]]
        [:div.col-sm-6.col-md-offset-5 [shared-state 0]]]]])
-

 (defroute fieldbook-list "/fieldbook" []
   (let [onres (fn [json]
                 (cond (= (get-status json) 200) (set-authorized-list json :fieldbooks render-fieldbook)
                       :else (sign-out)))]
-    (set-url "/fieldbook")
     (set-key-value :is-searched-results false)
     (http-get-auth (str serverhost "fieldbooks?pageIndex="(dec (get-value! :current-page))"&pageSize=10") onres)))

@@ -2566,14 +2299,11 @@
                 (accountant/navigate! "/misc"))]
     (http-delete (str serverhost "miscs/" id)  onres)))

-
-
-
 (defroute misc-add-path "/misc/add" []
   (if (nil? (get-value! :user)) (accountant/navigate! "/login")
       (let [onres (fn[json](
-                           (set-key-value :villages (getdata json))
-                           (set-page! [misc-add-template])))]
+                            (set-key-value :villages (getdata json))
+                            (set-page! [misc-add-template])))]
         (http-get-auth (str serverhost "villages") onres))))

 (defroute misc-upd-path "/misc/update/:id" [id]
@@ -2676,23 +2406,6 @@

 (defn o2register-form-cancel [event]
   (accountant/navigate! "/o2register"))
-
-(defn o2num-sel-tag [id data data-set ]
-  [:select.form-control {:id id
-                         :value (@data-set id)
-                         :on-change #(swap! data-set assoc id  (-> % .-target .-value))}
-   [:option {:value 0} "--Select--"]
-   (for [d  data]
-     ^{:key  d}
-     [:option {:value d} d])])
-
-(defn o2-form-o2num-sel [label id opt-data data-set]
-  [:div.form-group
-   [:label.col-sm-3.control-label label]
-   [:div.col-sm-6 [o2num-sel-tag id opt-data data-set]]
-   [:div.col-sm-3 [:div]]])
-
-

 (defn o2-subdiv-sel-tag [id data data-set ]
   [:select.form-control {:id id
@@ -2848,7 +2561,8 @@

 (defroute o2register-list "/o2register" []
   (let [onres (fn [json]
-                (cond (= (get-status json) 200) (set-authorized-list json :o2registers render-o2register)
+                (cond (= (get-status json) 200)
+                      (set-authorized-list json :o2registers render-o2register)
                       :else (sign-out)))]
     (set-key-value :is-searched-results false)
     (http-get-auth (str serverhost "o2registers?pageIndex="(dec (get-value! :current-page))"&pageSize=10") onres)))
@@ -2863,7 +2577,7 @@
                      :o4number [[v/required :message "Field is required"]]
                      :villageid [[v/required :message "Field is required"]]
                      :racknumber [[v/required :message "Field is required"]]
-                     ;; :description [[v/required :message "Field is required"]]
+                     :description [[v/required :message "Field is required"]]
                      )))

 (defn o4register-input-row [id label ttype data-set focus]
@@ -2896,62 +2610,6 @@
   (accountant/navigate! "/o4register"))

-
-(defn o4num-sel-tag [id data data-set ]
-  [:input.form-control {:id id
-                        :value (@data-set id)
-                        :on-change #()}
-   [:option {:value 0} "--Select--"]
-   (for [d  data]
-     ^{:key  (.-id d)}
-     [:option {:value (.-o4number d)} (.-o4number d)])])
-
-(defn o4-form-o4num-sel [label id opt-data data-set]
-  [:div.form-group
-   [:label.col-sm-3.control-label label]
-   [:div.col-sm-6 [o4num-sel-tag id opt-data data-set]]
-   [:div.col-sm-3 [:div]]])
-
-(defn o4-sub-onchange [id val data-set]
-  (let [res (fn [json]
-              (let [dt (getdata json)]
-                (set-key-value :villages dt)))]
-    (do (http-get-auth (str serverhost "subdivisions/" val  "/villages") res)
-        (swap! data-set assoc id (js/parseInt val)))))
-
-
-(defn o4-sub-sel-tag [id data data-set]
-  [:select.form-control {:id id
-                         :value (@data-set id)
-                         :on-change #(rev-sub-onchange  id (-> % .-target .-value) data-set)}
-   [:option {:value 0} "--Select--"]
-   (for [d  data]
-     ^{:key (.-id d) }
-     [:option {:value (.-id d)} (.-subdivisionname d)])])
-
-(defn o4-form-sub-sel [label id opt-data data-set]
-  [:div.form-group
-   [:label.col-sm-3.control-label label]
-   [:div.col-sm-6 [o4-sub-sel-tag id opt-data data-set]]
-   [:div.col-sm-3 [:div]]])
-
-
-(defn o4-villages-sel-tag [id data data-set ]
-  [:select.form-control {:id id
-                         :value (@data-set id)
-                         :on-change #(swap! data-set assoc id (js/parseInt (-> % .-target .-value)))}
-   [:option {:value 0} "--Select--"]
-   (for [d  data]
-     ^{:key (.-id d) }
-     [:option {:value (.-id d)} (.-villagename d)])])
-
-(defn o4-form-villages-sel [label id opt-data data-set]
-  [:div.form-group
-   [:label.col-sm-3.control-label label]
-   [:div.col-sm-6 [o4-villages-sel-tag id opt-data data-set]]
-   [:div.col-sm-3 [:div]]])
-
-
 (defn o4register-template [doc-name data-set focus save-function]
   [:div.container
    [:div.col-md-12
@@ -2962,8 +2620,8 @@
       [:div.box-body
        [o4register-input-int-row :serialnumber "Serial Number" "text" data-set focus ]
        [o4register-input-row :o4number "O4 Number" "text" data-set focus]
-       [o4-form-sub-sel "Sub Division Name" :subdivisionid (:subdivisions @storage) data-set]
-       [o4-form-villages-sel "Village Name" :villageid (:villages @storage) data-set]
+       [all-form-sub-sel "Sub Division Name" :subdivisionid (:subdivisions @storage) data-set]
+       [all-form-villages-sel "Village Name" :villageid (:villages @storage) data-set]
        [o4register-input-row :racknumber "Rack Number" "text" data-set focus]
        [o4register-input-row :description "Description" "text" data-set focus]
        ]
@@ -3090,10 +2748,12 @@

 (defroute o4register-list "/o4register" []
   (let [onres (fn [json]
-                (cond (= (get-status json) 200) (set-authorized-list json :o4registers render-o4register)
+                (cond (= (get-status json) 200)
+                      (set-authorized-list json :o4registers render-o4register)
                       :else (sign-out)))]
     (set-key-value :is-searched-results false)
-    (http-get-auth (str serverhost "o4registers?pageIndex="(dec (get-value! :current-page))"&pageSize=10") onres)))
+    (http-get-auth
+     (str serverhost "o4registers?pageIndex="(dec (get-value! :current-page))"&pageSize=10") onres)))

 ;; ---------------------------------------------------------
@@ -3113,7 +2773,7 @@
                      ;;              [date-year-after? :message "Year must greater than 1900"]
                      ;;              [date-year-before? :message "Year must less than 9999"]]
                      :racknumber  [[v/required :message "Field is required"]]
-                     ;;:description [[v/required :message "Field is required"]]
+                     ;; :description [[v/required :message "Field is required"]]
                      )))

 (defn o6register-input-row [id label ttype data-set focus]
@@ -3145,22 +2805,6 @@

 (defn o6register-form-cancel [event]
   (accountant/navigate! "/o6register"))
-
-(defn o6num-sel-tag [id data data-set ]
-  [:select.form-control {:id id
-                         :value (@data-set id)
-                         :on-change #(swap! data-set assoc id  (-> % .-target .-value))}
-   [:option {:value 0} "--Select--"]
-   (for [d  data]
-     ^{:key  (.-id d)}
-     [:option {:value (.-o6number d)} (.-o6number d)])])
-
-
-(defn o6-form-o6num-sel [label id opt-data data-set]
-  [:div.form-group
-   [:label.col-sm-3.control-label label]
-   [:div.col-sm-6 [o6num-sel-tag id opt-data data-set]]
-   [:div.col-sm-3 [:div]]])

 (defn o6-subdiv-sel-tag [id data data-set ]
   [:select.form-control {:id id


[#650] Fix operator precedence issues in aggregate filters

--- backend/src/akvo/lumen/lib/aggregation/filter.clj
+++ backend/src/akvo/lumen/lib/aggregation/filter.clj
@@ -92,4 +92,5 @@
     "TRUE"
     (let [filters (map #(assoc % "column" (find-column columns (get % "column")))
                        filters)]
-      (str/join " AND " (map filter-sql filters)))))
+      (str/join " AND " (map #(format "(%s)" (filter-sql %))
+                             filters)))))


Simplify bench macro

Simplify bench macro

--- benchmarks/caesium/crypto/secretbox_benchmark.clj
+++ benchmarks/caesium/crypto/secretbox_benchmark.clj
@@ -68,12 +68,12 @@

 (defmacro bench-secretnonce
   [prefix fs converter]
-  (let [rand-buf `(comp ~converter ~randombytes)]
-    `(doseq [[size# ptext#] (map (juxt identity ~rand-buf) sizes)
+  `(let [rand-buf# (comp ~converter randombytes)]
+    (doseq [[size# ptext#] (map (juxt identity rand-buf#) sizes)
              f# ~fs]
-       (let [key# (~rand-buf s/keybytes)
-             nonce# (~rand-buf s/noncebytes)
-             out# (~rand-buf (+ s/macbytes size#))]
+       (let [key# (rand-buf# s/keybytes)
+             nonce# (rand-buf# s/noncebytes)
+             out# (rand-buf# (+ s/macbytes size#))]
          (print-title ~prefix
                       f#
                       (fmt-bytes size#)


Document n-answers

Document n-answers

Thanks, @derwolfe!

--- src/desdemona/query.clj
+++ src/desdemona/query.clj
@@ -6,7 +6,11 @@
   it.

   This is implemented using syntax-quote because that was the easiest
-  way to produce this data structure with some values interpolated."
+  way to produce this data structure with some values interpolated.
+
+  The n-answers is simply passed to core.logic/run; we're relying on
+  it to correctly bound the number of answers. This helps us limit how
+  long it takes to query."
   [n-answers query events]
   `(l/run ~n-answers [results#]
      (l/fresh [~'x] ;; ~'x means "literally x, don't gensym", see #28


Reconfigure route to dbas

Reconfigure route to dbas

--- src/discuss/config.cljs
+++ src/discuss/config.cljs
@@ -4,7 +4,7 @@

 (def user "Q2hyaXN0aWFu")

-(def api {:host "https://mayweather.cn.uni-duesseldorf.de/dbas/"
+(def api {:host "http://localhost:4284/"
           :init "api/elektroautos"
           :base "api/"
           :add  {:add-start-statement "add/start_statement"


Working on better titles

Working on better titles

--- src/re_demo/utils.cljs
+++ src/re_demo/utils.cljs
@@ -3,12 +3,20 @@
             [reagent.core    :as    reagent]))

-(def panel-title-style {
+#_(def panel-title-style {
     :font-family "Ubuntu"
     :font-weight "300"
     :font-size   "24px"
     :color       "#FF6522"    ;; orange
     :margin-top  "7px"
+   })
+
+(def panel-title-style {
+    :font-family "Ubuntu"
+    :font-weight "300"
+    :font-size   "24px"
+    :color       "#EEE"
+    :height      "50px"
    })

 (defn panel-title


Remove completed todos

Remove completed todos

--- src/re_frame/core.cljc
+++ src/re_frame/core.cljc
@@ -55,23 +55,20 @@
    there is only a chain."
   ([id db-handler]
     (reg-event-db id nil db-handler))
-
   ([id interceptors db-handler]
-   (events/register id [base interceptors (db-handler->interceptor db-handler)])))   ;; XXX add a base-interceptor
+   (events/register id [base interceptors (db-handler->interceptor db-handler)])))

 (defn reg-event-fx
   ([id fx-handler]
    (reg-event-fx id nil fx-handler))
-
   ([id interceptors fx-handler]
-   (events/register id [base interceptors (fx-handler->interceptor fx-handler)])))   ;; XXX add a base-interceptor
+   (events/register id [base interceptors (fx-handler->interceptor fx-handler)])))

 (defn reg-event-ctx
   ([id handler]
    (reg-event-ctx id nil handler))
-
   ([id interceptors handler]
    (events/register id [base interceptors (ctx-handler->interceptor handler)])))


csv uploading no longer matches synthetic sensors.

Synthetic sensors have the same alias as their parent, but obviously we
shouldn't be uploading to them as they are something we calculate after
upload.

--- src/kixi/hecuba/data/measurements/upload.clj
+++ src/kixi/hecuba/data/measurements/upload.clj
@@ -102,16 +102,18 @@
                                                 (doall)))]
     (db/with-session [session (:hecuba-session store)]
       (let [devices (->> (devices/get-devices session entity_id)
-                         (map #(vector (:device_id %) (identity %)))
+                         (map #(vector (:device_id %) %))
                          (into {}))
             sensors (->> (sensors/get-sensors-by-device_ids (keys devices) session)
-                         (map #(vector (:alias %) (identity %)))
+                         (remove :synthetic)
+                         (map #(vector (:alias %) %))
                          (into {}))
             header  (->> (map (partial str/join \|) (rest (transpose header-rows)))
                          (map #(if-let [s (get sensors %)]
-                                 (assoc-in s [:metadata :exists?] true) {:alias % :metadata {:exists? false}}))
+                                 (assoc-in s [:metadata :exists?] true)
+                                 {:alias % :metadata {:exists? false}}))
                          (map #(if-let [d (get devices (:device_id %))]
-                                 (do (log/infof "merging device %s onto header slug %s" d %) (merge d %))
+                                 (do (log/infof "merging device %s onto header sensor %s" d %) (merge d %))
                                  %))
                          (map (partial relocate-user-id item)))
             _       (log/infof "%s sensors in header %s" (count header) (vec header))]


Add sanity check after writing files

Add sanity check after writing files

--- src/runbld/process.clj
+++ src/runbld/process.clj
@@ -12,6 +12,10 @@
                                  (.getErrorStream proc) err)
           exit-code (.waitFor proc)
           end (System/currentTimeMillis)]
+      (assert (= @out-bytes (count (slurp outfile)))
+              "file truncated")
+      (assert (= @err-bytes (count (slurp errfile)))
+              "file truncated")
       {:start-millis start
        :time-start (date/ms-to-iso start)
        :end-millis end


Refactoring to support complex scalars

Refactoring to support complex scalars

--- src/main/clj/clojure/core/matrix/complex.clj
+++ src/main/clj/clojure/core/matrix/complex.clj
@@ -6,9 +6,11 @@
             [mikera.cljutils.error :refer :all])
   (:import [org.apache.commons.math3.complex Complex]))

-(declare real imag complex-array)
+(declare real imag complex-array complex complex? canonical-complex-array)

-;; The complex array class
+;; ==============================================================
+;;
+;; The ComplexArray class and protocol implementations
 ;;
 ;; Implemented as a wrapper of two numerical arrays representing the real and imaginary parts

@@ -84,6 +86,48 @@
      (seq [m]
        (map complex-array (m/slices (.real m)) (m/slices (.imag m)))))

+
+;; ========================================================================
+;;
+;; Protocol implementations for the Complex number type, used as a scalar
+;;
+;; These are needed to allow the COmplex numbers themselves to participate fully in core.matrix protocols
+
+(extend-protocol mp/PImplementation
+   Complex
+	  (implementation-key [m]
+	    :complex)
+	  (meta-info [m]
+	      {:doc "Implementation for complex scalars"})
+	  (new-vector [m length]
+      (mp/new-vector canonical-complex-array length))
+	  (new-matrix [m rows columns]
+      (mp/new-matrix canonical-complex-array rows columns))
+	  (new-matrix-nd [m dims]
+	    (mp/new-matrix-nd canonical-complex-array dims))
+	  (construct-matrix [m data]
+	    (complex data))
+	  (supports-dimensionality? [m dims]
+	    true))
+
+;; ========================================================================
+;;
+;; Functions for handling complex arrays
+
+(defn complex
+  "Function to coerce a value to a complex scalar or array"
+  ([a]
+    (cond
+      (complex? a) a
+      (number? a) (c/complex-number a)
+      (mp/get-shape a) (complex-array a)
+      :else (error "Unable to coerce to complex value: " a))))
+
+(defn complex?
+  "Predicate to test whether a value is a complex number or array supported by core.matrix.complex"
+  ([a]
+    (boolean (or (instance? Complex a) (instance? ComplexArray a)))))
+
 (defn complex-array
   ([real]
     (complex-array real 0.0))
@@ -110,5 +154,9 @@
 	    (and (m/array? m) (m/numerical? m)) (mp/coerce-param m (mp/broadcast-like m 0.0))
 	    :else (error "Unable to get imaginary part of object: " m))))

+;; a canoncial object used to register the complex array implementation
+(def canonical-complex-array
+  (let [a (complex-array 0 1)]
+    (imp/register-implementation a)
+    a))

-(imp/register-implementation (complex-array 0 1))


tweaks

tweaks

--- src/main/clj/clojure_club/gurps/mbastian.clj
+++ src/main/clj/clojure_club/gurps/mbastian.clj
@@ -6,14 +6,6 @@
             [clojure.edn :as edn]))

 (def x (->> "clojure_club/gurps/basic_set.adq" io/resource slurp xml/parse-str))
-
-#_(clojure.walk/prewalk
-  (fn [{:keys [tag attrs content] :as m}]
-    (cond
-      (string? content) {tag content}
-      (seq content) {tag m}
-      :else m))
-  x)

 (defn numeric-attr [{:keys [tag content]}]
   {tag (some-> content first)})
@@ -35,7 +27,6 @@
 (defmethod parse-adq :amount [m] (numeric-attr m))
 (defmethod parse-adq :cr [m] (numeric-attr m))
 (defmethod parse-adq :percentage [m] (numeric-attr m))
-;(defmethod parse-adq :modifier [m] (numeric-attr m))

 (defmethod parse-adq :name [m] (string-attr m))
 (defmethod parse-adq :reference [m] (string-attr m))
@@ -43,10 +34,31 @@
 (defmethod parse-adq :affects [m] (string-attr m))
 (defmethod parse-adq :damage [m] (string-attr m))
 (defmethod parse-adq :usage [m] (string-attr m))
+(defmethod parse-adq :reach [m] (string-attr m))
+(defmethod parse-adq :parry [m] (string-attr m))
+(defmethod parse-adq :block [m] (string-attr m))
 (defmethod parse-adq :attribute [m] (string-attr m))
+(defmethod parse-adq :college_name [m] (string-attr m))
+(defmethod parse-adq :accuracy [m] (string-attr m))
+(defmethod parse-adq :range [m] (string-attr m))
+(defmethod parse-adq :rate_of_fire [m] (string-attr m))
+(defmethod parse-adq :recoil [m] (string-attr m))
+(defmethod parse-adq :location [m] (string-attr m))

 (defmethod parse-adq :type [{:keys [content]}]
   {:type (set (map cs/trim (cs/split (first content) #",")))})
+
+(defmethod parse-adq :skill_prereq [{:keys [content]}]
+  {:skill_prereq (map parse-adq content)})
+
+(defmethod parse-adq :advantage_prereq [{:keys [content]}]
+  {:advantage_prereq (map parse-adq content)})
+
+(defmethod parse-adq :attribute_prereq [{:keys [content]}]
+  {:attribute_prereq (map parse-adq content)})
+
+(defmethod parse-adq :spell_bonus [{:keys [content]}]
+  {:spell_bonus (map parse-adq content)})

 (defmethod parse-adq :specialization [{:keys [tag content attrs]}]
   ;how do these attrs work?
@@ -64,6 +76,11 @@

 (defmethod parse-adq :modifier [{:keys [content attrs]}]
   {:modifier (apply merge (map parse-adq content))})
+
+(defmethod parse-adq :ranged_weapon[{:keys [content attrs]}]
+  {:ranged-weapon (map parse-adq content)
+   ;(apply merge (map parse-adq content))
+   })

 (defmethod parse-adq :dr_bonus [{:keys [content attrs]}]
   {:dr_bonus (map parse-adq content)})
@@ -88,4 +105,4 @@
     {:default (map parse-adq content)}
     (prn tag)))

-(parse-adq x)
+;(parse-adq x)


Fix progress on question page

Fix progress on question page

--- src/formlogic/views.clj
+++ src/formlogic/views.clj
@@ -322,8 +322,8 @@
         total-tasks (:count (db/unique-result db/get-number-of-tasks-for-assignment
                                               {:id assignment-id}))
         last-task? (= total-tasks (:ord task))
-        perc-complete (calculate-perc-completed (:id assignment-progress)
-                                                assignment-id)]
+        perc-complete (:progress (calculate-perc-completed (:id assignment-progress)
+                                                           assignment-id))]
     (page-template
       "Pitanja"
       (include-js "/js/task.js")


Cleanup log messages

Cleanup log messages

--- src/onyx/log/commands/peer_replica_state.clj
+++ src/onyx/log/commands/peer_replica_state.clj
@@ -90,16 +90,13 @@
                             (common/root-tasks workflow (:name task)))
             {:keys [peer-state]} new-replica
             receivable-peers (common/job-receivable-peers peer-state allocations job-id)
-            ;; TODO implement acking peer publications / task-id / peer-id
             slot-ids (get-in new-replica [:task-slot-ids job-id])
             peer-sites (:peer-sites new-replica)
             egress-ids (:egress-ids task)
             egress-sites (set (map peer-sites (distinct (mapcat receivable-peers (vals egress-ids)))))
             old-egress-sites (set (keys (:site->publication old-peer-replica-state)))
-            _ (info "old egress sites " old-egress-sites)
             new-egress-sites (difference egress-sites old-egress-sites)
             stale-egress-sites (difference old-egress-sites egress-sites)
-            _ (info (:id state) (:message-id entry) "new egress sites " new-egress-sites "stale " stale-egress-sites "site to pub" (:site->publication old-peer-replica-state))
             cont-egress-sites (intersection egress-sites old-egress-sites)
             cont-site->publication (select-keys (:site->publication old-peer-replica-state) cont-egress-sites)
             new-site->publication (zipmap new-egress-sites (mapv aeron/new-publication new-egress-sites))
@@ -108,11 +105,7 @@
             task-id->publications (task-egress-publications egress-ids receivable-peers peer-sites site->publication)
             barrier-publications (mapv :pub (vals site->publication))
             stale-publications (map (:site->publication old-peer-replica-state) stale-egress-sites)]
-        ;; Cleanup stale egress sites
-        (info "removing stale publication " (vec stale-publications))
         (run! remove-publication stale-publications)
-        (info "egress publications " egress-sites)
-        (info "site->publication " site->publication "task-id->publications" task-id->publications "barrier-publications" barrier-publications)
         (->PeerReplicaView site->publication task-id->publications barrier-publications root-task-ids job-id task-id workflow catalog task))
       (do
         (stop-task-state old-peer-replica-state)


Add delete link to the revision HATEOAS.

--- src/open_company/representations/section.clj
+++ src/open_company/representations/section.clj
@@ -40,6 +40,9 @@
 (defn- partial-update-link [company-slug section-name updated-at]
   (common/partial-update-link (url company-slug section-name updated-at) media-type))

+(defn- delete-link [company-slug section-name updated-at]
+  (common/delete-link (url company-slug section-name updated-at) media-type))
+
 (defun- section-links
   "Add the HATEAOS links to the section"
   ([section authorized] (section-links (:company-slug section) (:section-name section) section authorized))
@@ -66,7 +69,8 @@
   ([company-slug section-name updated-at revision true]
   (assoc revision :links (flatten [
     (self-link company-slug section-name updated-at)
-    (partial-update-link company-slug section-name updated-at)]))))
+    (partial-update-link company-slug section-name updated-at)
+    (delete-link company-slug section-name updated-at)]))))

 (defn section-template-for-rendering
   "Add a create link to the provided section template."


Tweaks.

Tweaks.

--- src/leverage/server.clj
+++ src/leverage/server.clj
@@ -11,7 +11,7 @@
 ;; HTML layout

 (defn layout
-  [& content]
+  [content]
   (hiccup/html
    (page/html5
     [:head
@@ -23,13 +23,13 @@
      [:div.ui.one.column.page.grid
       [:div.column
        [:h1.ui.header
-        [:img.ui.floated.left.image {:src "/images/clojure-icon.gif" :width "100" :height "100"}]
+        [:img.ui.floated.left.image {:src "/images/clojure-icon.gif"
+                                     :width "100" :height "100"}]
         [:div.content "Get leverage with Clojure!"]]
        [:div.ui.compact.menu
         [:a.item {:href "/"} "Clojure"]
         [:a.item {:href "/cljs"} "ClojureScript"]]
-       [:div#content
-        content]]]])))
+       [:div#content content]]]])))

 (comment
   (layout "Hello, Tech4Africa!")
@@ -56,7 +56,7 @@
 (comment
   (app {:request-method :get :uri "/"})

-
+

   (app {:request-method :get :uri "/cljs"})

@@ -82,5 +82,7 @@
 (defn start-web!
   []
   (stop-web!)
-  (let [server (ring-server/serve app {:port 3333 :open-browser? false :join? false})]
+  (let [server (ring-server/serve app {:port 3333
+                                       :open-browser? false
+                                       :join? false})]
     (reset! web-process server)))


proxy support for downloads via the http_proxy, https_proxy environment
vars thanks to @sethyuan. Fixes #1451

Signed-off-by: Chris Granger <5654cde260ae99bc4d30054171b8bcd902efd19a@gmail.com>

--- src/lt/objs/deploy.cljs
+++ src/lt/objs/deploy.cljs
@@ -75,6 +75,8 @@
   (let [options (js-obj "url" from
                         "headers" (js-obj "User-Agent" "Light Table"))
         out (.createWriteStream fs to)]
+    (when-let [proxy (or js/process.env.http_proxy js/process.env.https_proxy)]
+      (set! (.-proxy options) proxy))
     (.pipe (request options cb) out)))

 (defn download-zip [ver cb]


.setDryRun fails if not internet connection available. Do it differently

--- src/marketing/store.clj
+++ src/marketing/store.clj
@@ -40,8 +40,8 @@
     (git-commit @repo (str "Store " (count emails) " collected emails.") {:name "Marketing Bot" :email ""})
     (let [push-cmd (.push @repo)
           dry-run? (not (zero? (env/flush-dry-run)))]
-      (when dry-run? (.setDryRun push-cmd true))
-      (.call push-cmd))))
+      (when-not dry-run?
+        (.call push-cmd)))))

 (defn flush
   "Flush in-memory emails into file and git store them,


fixes the invalid cookie warning

fixes the invalid cookie warning

--- src/nevergreen/http.clj
+++ src/nevergreen/http.clj
@@ -16,7 +16,8 @@
                                :conn-timeout          ten-seconds
                                :headers               (merge {"Accept" "application/xml"} additional-headers)
                                :as                    :stream
-                               :throw-entire-message? true})]
+                               :throw-entire-message? true
+                               :cookie-policy         :standard})]
       (log/info (str "GET from [" url "] returned a status of [" (:status res) "]"))
       (:body res))
     (catch SocketTimeoutException e


Improve log message, created pub, not connectd

--- src/onyx/messaging/aeron/publication_manager.clj
+++ src/onyx/messaging/aeron/publication_manager.clj
@@ -66,7 +66,7 @@
                             (taoensso.timbre/warn "Aeron messaging publication error:" x)))
           conn (Aeron/connect (.errorHandler (Aeron$Context.) error-handler))
           pub (.addPublication conn channel stream-id)]
-      (info (format "Connected via publication on: %s, stream-id: %s" channel stream-id))
+      (info (format "Created publication at: %s, stream-id: %s" channel stream-id))
       (assoc this :publication pub :connection conn))))

 (defn new-publication-manager [channel stream-id send-idle-strategy write-buffer-size cleanup-fn]


update info ugen docstrings

update info ugen docstrings

--- src/overtone/sc/machinery/ugen/metadata/info.clj
+++ src/overtone/sc/machinery/ugen/metadata/info.clj
@@ -29,15 +29,15 @@

    {:name "NumOutputBuses"
     :rates #{:ir}
-    :doc "returns the number of output buses allocated on the server"}
+    :doc "returns the number of output buses allocated on the server.  This is the number of hardware outputs provided by the host machine such as left and right speakers."}

    {:name "NumInputBuses"
     :rates #{:ir}
-    :doc "returns the number of output buses allocated on the server"}
+    :doc "returns the number of input buses allocated on the server. This is the number of hardware inputs provided by the host machine such as a mic."}

    {:name "NumAudioBuses"
     :rates #{:ir}
-    :doc "returns the number of audio buses allocated on the server"}
+    :doc "returns the number of audio buses allocated on the server."}

    {:name "NumControlBuses"
     :rates #{:ir}


ones->components, feels more natural to me

--- src/pc/views/blog/diagramming_with_precursor.clj
+++ src/pc/views/blog/diagramming_with_precursor.clj
@@ -19,7 +19,7 @@
     [:article
      [:h3 "Let's build something"]
      [:p "For a case-study in sketching flow diagrams, we're going to map out Precursor's infrastructure."]
-     [:p "Precursor's infrastructure is made up of 2 main types of components: 1. ones that store data and 2. ones that process data. We'll represent components that store data with the classic spinning disks icon. I'm a pretty poor artist, but I searched Google for \"database icon\" and they're just a stack of circles. We'll spend 30 seconds and illustrate one ourselves. Then when we need it to represent a component, we can just copy/paste it into place."]]
+     [:p "Precursor's infrastructure is made up of 2 main types of components: 1. components that store data and 2. components that process data. We'll represent components that store data with the classic spinning disks icon. I'm a pretty poor artist, but I searched Google for \"database icon\" and they're just a stack of circles. We'll spend 30 seconds and illustrate one ourselves. Then when we need it to represent a component, we can just copy/paste it into place."]]

     (common/demo (external-cdn-path "/blog/diagramming-with-precursor/db-placeholder.png")
                  (external-cdn-path "/blog/diagramming-with-precursor/db.gif")


functionality implemented, now to map to command line

--- src/nquick/commands.clj
+++ src/nquick/commands.clj
@@ -6,27 +6,42 @@
             [clojure.tools.cli :refer [parse-opts]]))

 (defn flush
-  ([] ())
-  ([filename] ()))
-
-;; helper function that destroys all notes
-(defn- the-nuclear-option
-  ([] ()))
+  ([]
+   (when (ask-if-sure)
+     (do
+       (spit util/nquick-default-file "")
+       (println "default note file cleaned."))))
+  ([filename]
+   (when (ask-if-sure)
+     (let [fullpath (str util/nquick-directory "/" filename)]
+       (if (and (not (= filename "default")) (.exists (io/file fullpath)))
+         (do
+           (io/delete-file (str util/nquick-directory "/" filename) "")
+           (println (str filename " deleted!")))
+         (println "file can't be deleted!"))))))

 ;; helper to ask if sure
-(defn- ask-if-sure
+(defn- ask-if-sure []
   (let [answer (read-line)]
-    ()))
+    (cond
+     (= answer "y") true
+     (= answer "n") false
+     :else (do
+             (println "answer with y or n")
+             (ask-if-sure)))))

 (defn read
   ([] (println (slurp util/nquick-default-file)))
   ([filename]
-   (let [full-path (str util/nquick-directory "/" (util/mangle-name title))]
+   (let [full-path (str util/nquick-directory "/" filename)]
      (if (not (.exists (io/file full-path)))
        (println "file does not exist!")
        (println (slurp full-path))))))

-(defn write [& args] ())
+(defn write [s]
+  (do
+    (println "Please write a title for note (blank for default): ")
+    (write-title-helper s)))

 ;; helper function to optionally give a title to the notes
 (defn- write-title-helper [text]
@@ -38,7 +53,7 @@
         (spit util/nquick-default-file text :append true))
       (.exists (io/file (str util/nquick-directory "/" (util/mangle-name title))))
       (do
-        (println "that note already exists! pick another title.")
+        (println "that note already exists! pick another title. (blank for default)")
         (write-title-helper text))
       :else
       (do


fix pdb-file tags

fix pdb-file tags

git-svn-id: 03a8048b5ee8463be5048a3801110fb50f378627@9996 d0ab736e-dc22-4aeb-8dc9-08def0aa14fd

--- buildscripts/buildcheck/src/buildcheck/core.clj
+++ buildscripts/buildcheck/src/buildcheck/core.clj
@@ -231,19 +231,26 @@

 ;; other windows stuff (manual)

-(defn fix-output-file-tag
-  "Fix the dll output path specified in this vc proj."
-  [vcproj-file]
-  (spit vcproj-file
-        (-> vcproj-file
-            slurp
-            (clojure.string/replace #"\$\(OutDir\)/.+?\.dll"
-                                    "\\$(OutDir)/mmgr_dal_\\$(ProjectName).dll"))))
-
-(defn fix-output-file-tags
-  "Fix the dll output path in all vcproj files."
+
+(defn edit-file! [file edit-fn]
+  (let [file (clojure.java.io/file file)]
+    (spit file (edit-fn (slurp file)))))
+
+(defn replace-in-file!
+  "Replace a re-pattern in a file with a new value."
+  [file pat new-val]
+  (edit-file file #(clojure.string/replace % pat new-val)))
+
+(defn replace-in-files!
+  "Replace a re-pattern in a list of files with a new value."
+  [files pat new-val]
+  (dorun (map #(replace-in-file % pat new-val) files)))
+
+(defn fix-output-file-tags!
+  "Fix the dll output path specified in all vcproj files."
   []
-  (dorun (map fix-output-file-tag (device-vcproj-files))))
+  (replace-in-files (device-vcproj-files)
+                    #"\$\(OutDir\)/.+?\.dll" "\\$(OutDir)/mmgr_dal_\\$(ProjectName).dll"))

 (defn find-copy-step [vcproj]
   (re-find #"\"copy .+?\"" (slurp vcproj)))
@@ -255,6 +262,16 @@
   "Find all vcproj files with a bad post-build copy step"
   []
   (filter bad-copy-step (device-vcproj-files)))
+
+(defn find-pdb [vcproj]
+  (re-find #"\".*?\.pdb\"" (slurp vcproj)))
+
+(defn fix-pdb-file-tags!
+  "Fix the pdb file path specified in all vcproj files."
+  []
+  (replace-in-files! (device-vcproj-files)
+                    #"\".*?\.pdb\"" "\"\\$(OutDir)/\\$(ProjectName).pdb\""))
+

 ;;;; checking mac stuff (manual)


fix looking up cust name from chat

fix looking up cust name from chat

--- src/pc/http/datomic.clj
+++ src/pc/http/datomic.clj
@@ -112,7 +112,7 @@
 ;; TODO: teach the frontend how to lookup name from cust/uuid
 ;;       this will break if something else is associating cust/uuids
 (defmethod translate-datom :cust/uuid [db d]
-  (if (:chat/body (d/entity db (:e d)))
+  (if (:chat/body (d/entity db (:original-e d)))
     (assoc d
            :a :chat/cust-name
            :v (or (chat-model/find-chat-name db (:v d))
@@ -131,9 +131,12 @@
         v (if (contains? (schema/enums) a)
             (schema/get-ident v)
             v)
+        ;; Temporary fix until we teach frontend how to lookup cust name
+        original-e e
         e (web-peer/client-id db e)]
-    (->> {:e e :a a :v v :tx tx :added added}
-      (translate-datom db))))
+    (->> {:e e :a a :v v :tx tx :added added :original-e original-e}
+      (translate-datom db)
+      (#(dissoc % :original-e)))))

 (defn whitelisted? [datom]
   (contains? outgoing-whitelist (:a datom)))


(CTH-281) Add unit tests for connection-states/process-expired-message

--- test/puppetlabs/cthun/connection_states_test.clj
+++ test/puppetlabs/cthun/connection_states_test.clj
@@ -121,4 +121,18 @@
     (testing "It will process a server message"
       (with-redefs [puppetlabs.cthun.connection-states/session-associated? (fn [ws] true)
                     puppetlabs.cthun.connection-states/process-server-message (fn [host ws message-body] "server")]
-        (is (= (process-message "localhost" "ws" {:targets ["cth:///server"]}) "server"))))))
+        (is (= (process-message "localhost" "ws" {:targets ["cth:///server"]}) "server"))))
+    (testing "It will process an expired message"
+      (with-redefs [puppetlabs.cthun.connection-states/message-expired? (constantly true)
+                    puppetlabs.cthun.connection-states/process-expired-message (constantly :processed-expired)]
+        (is (= (process-message "localhost" "ws" {:id "12347890"}) :processed-expired))))))
+
+(deftest process-expired-message-test
+  (with-redefs [puppetlabs.cthun.connection-states/process-client-message (fn [_ _ response] response)]
+    (testing "It will create and send a ttl expired message"
+       (let [msg (puppetlabs.cthun.connection-states/process-expired-message {:id "12347890"
+                                                                              :sender "cth://client2.com/tester"})
+             msg_data (puppetlabs.cthun.message/get-json-data msg)]
+         (is (= "http://puppetlabs.com/ttl_expired" (:message_type msg)))
+         (is (= "12347890" (:id msg_data)))))))
+


(maint) Fix reports integration test

(maint) Fix reports integration test

Something in the agent changed to make it log more at info level; adjust the
tests to match.

--- test/puppetlabs/puppetdb/integration/reports.clj
+++ test/puppetlabs/puppetdb/integration/reports.clj
@@ -164,7 +164,7 @@
                   (filter #(= "notice" (:level %))
                           logs))))

-        (is (= 5 (count
+        (is (= 6 (count
                   (filter #(= "info" (:level %))
                           logs))))))))


Upgraded to Clojure 1.7.0alpha4

Upgraded to Clojure 1.7.0alpha4

--- lein-template/project.clj
+++ lein-template/project.clj
@@ -5,7 +5,7 @@
   :description "Leiningen template for a full-featured component based app using modular extensions."
   :license {:name "The MIT License"
             :url "http://opensource.org/licenses/MIT"}
-  :dependencies [[org.clojure/clojure "1.6.0"]
+  :dependencies [[org.clojure/clojure "1.7.0-alpha4"]
                  ;; EDN reader with location metadata
                  [org.clojure/tools.reader "0.8.3"]
                  [org.clojure/tools.logging "0.2.6"]]


More refactoring.

More refactoring.

--- umm-lib/src/cmr/umm/iso_smap/granule/spatial.clj
+++ umm-lib/src/cmr/umm/iso_smap/granule/spatial.clj
@@ -79,10 +79,10 @@
 (defn generate-spatial
   "Generates the Spatial element from spatial coverage"
   [spatial-coverage]
-  (when spatial-coverage
-    (let [{:keys [geometries]} spatial-coverage
-          geometries (filter (fn [g] (or (= cmr.spatial.mbr.Mbr (type g))
-                                         (= cmr.spatial.polygon.Polygon (type g)))) geometries)]
-      (map generate-geometry-element geometries))))
+  (for [geometry (:geometries spatial-coverage)
+        :let [gtype (type geometry)]
+        :when (or (= cmr.spatial.mbr.Mbr gtype)
+                  (= cmr.spatial.polygon.Polygon gtype))]
+    (generate-geometry-element geometry)))


test(input) cond

test(input) cond

--- src/portfolio/core.cljs
+++ src/portfolio/core.cljs
@@ -4,14 +4,38 @@
 ;; -------------------------
 ;; Views

+; (defonce site-name
+;   (reagent/atom
+;    {:text ""}))
+
+(defonce app-state
+  (reagent/atom
+   {:text "" :color "rgba(50, 50, 255, 0.2)"}))
+
 (defn home-page []
-  [:div [:h2 "Welcome to Reagent"]])
+  [:div [:h2 "Welcome tto Reagent"]])
+
+;; Page
+(defn paragraph [ratom]
+  (println (:color @ratom))
+  (when (> (count (:text @ratom)) 0)
+   [:div {:style {:background-color (:color @ratom) :width 160}}
+    [:p "Hi,  "(:text @ratom)]]))
+
+
+(defn page [ratom]
+  (let [guestname (fn [e]
+                   (swap! ratom assoc :text e.target.value))]
+   [:p "Hello, what is your name?"
+    [:p [:input {:type "text" :on-change guestname}]]
+    [paragraph ratom]]))
+

 ;; -------------------------
 ;; Initialize app

 (defn mount-root []
-  (reagent/render [home-page] (.getElementById js/document "app")))
+  (reagent/render [page app-state] (.getElementById js/document "app")))

 (defn init! []
   (mount-root))