fix reflection warning

fix reflection warning

--- src/main/clojure/org/dada/core.clj
+++ src/main/clojure/org/dada/core.clj
@@ -43,11 +43,9 @@

 (defn start-server [#^String name]
   (System/setProperty "server.name" name)
-  (let [context (ClassPathXmlApplicationContext. "application-context.xml")]
-    (def #^ClassPathXmlApplicationContext *spring-context* context)
-    (def #^ServiceFactory *internal-view-service-factory*
-	 (.getBean *spring-context* "internalViewServiceFactory"))
-    (.getBean context "metaModel")))
+  (def #^ClassPathXmlApplicationContext *spring-context* (ClassPathXmlApplicationContext. "application-context.xml"))
+  (def #^ServiceFactory *internal-view-service-factory* (.getBean *spring-context* "internalViewServiceFactory"))
+  (.getBean *spring-context* "metaModel"))

 (defn start-client [#^String name]
   (Client/main (into-array String (list name))))
@@ -282,7 +280,7 @@
   (let [map (new ConcurrentHashMap)
 	prefix (str (.getName src-model) "." (name key) "=")
 	metadata (.getMetadata src-model)
-	view-factory (proxy [Factory] [] (create [key] (.decouple *internal-view-service-factory* (view-hook (model (str prefix (route-to-value key)) metadata)))))
+	view-factory (proxy [Factory] [] (create [key] (.decouple #^ServiceFactory *internal-view-service-factory* (view-hook (model (str prefix (route-to-value key)) metadata)))))
 	lazy-factory (proxy [Factory] [] (create [key] (new LazyView map key view-factory)))
 	table (new SparseOpenLazyViewTable map lazy-factory)
 	getter (.getAttributeGetter metadata (name key))]


(RE-8861) Change git_sha to version

(RE-8861) Change git_sha to version

Vanagon can package things that are not in a git repo so we are changing
this key to a more generic key so that we can have consistency in this
file.

--- src/puppetlabs/ezbake/core.clj
+++ src/puppetlabs/ezbake/core.clj
@@ -728,7 +728,7 @@
   (let [dep-map (deputils/generate-dependency-map lein-project)
         deps (munge-deps dep-map)
         metadata {"packaging_type" {"ezbake" (get-ezbake-version lein-project)}
-                  "git_sha" (get-git-sha)
+                  "version" (get-git-sha)
                   "build_time" (local-time/format-local-time (local-time/local-now) :basic-date-time)
                   "components" deps}
         json-string (json/generate-string metadata)]


Experiment with skipping wrappers for native React components

This should make initial rendering a bit faster, as well as cases
where many components change simultaneously.

It should also lead to slightly less memory use.

The drawback is that native components no longer use
shouldComponentUpdate, and so requires more conversion from cljs
to js values – but this is now quite fast anyway.

--- src/reagent/impl/template.cljs
+++ src/reagent/impl/template.cljs
@@ -69,14 +69,15 @@
                                  (str class " " old)
                                  class))))))

-(defn convert-props [props id-class]
+(defn convert-props [props id-class allow-key]
   (cond
    (and (empty? props) (nil? id-class)) nil
    (identical? (type props) js/Object) props
    :else (let [objprops
                (reduce-kv (fn [o k v]
                             (let [pname (cached-prop-name k)]
-                              (if-not (identical? pname "key")
+                              (if (or allow-key
+                                      (not (identical? pname "key")))
                                 ;; Skip key, it is set by parent
                                 (aset o pname (convert-prop-value v))))
                             o)
@@ -139,7 +140,7 @@
         argv (.' inprops :argv)
         props (nth argv 1 nil)
         hasprops (or (nil? props) (map? props))
-        jsprops (convert-props (if hasprops props) id-class)]
+        jsprops (convert-props (if hasprops props) id-class false)]
     (when-not (nil? input-setup)
       (input-setup this jsprops))
     (make-element argv comp jsprops
@@ -203,22 +204,38 @@
           (util/cache-react-class tag (wrap-component tag nil nil))
           (fn-to-class tag))))))

+(def cached-parse (util/memoize-1 parse-tag))
+
+(defn native-element [tag argv]
+  (when (hiccup-tag? tag)
+    (let [[comp id-class] (cached-parse tag)]
+      (when-not (input-component? comp)
+        (let [props (nth argv 1 nil)
+              hasprops (or (nil? props) (map? props))
+              jsprops (convert-props (if hasprops props) id-class true)]
+          (make-element argv comp jsprops
+                        (if hasprops 2 1)))))))
+
 (defn get-key [x]
   (when (map? x) (get x :key)))

 (defn vec-to-comp [v]
   (assert (pos? (count v)) "Hiccup form should not be empty")
-  (assert (valid-tag? (nth v 0))
-          (str "Invalid Hiccup form: " (pr-str v)))
-  (let [c (as-class (nth v 0))
-        jsprops #js{:argv v}]
-    (let [k (-> v meta get-key)
-          k' (if (nil? k)
-               (-> v (nth 1 nil) get-key)
-               k)]
-      (when-not (nil? k')
-        (.! jsprops :key k')))
-    (.' js/React createElement c jsprops)))
+  (let [tag (nth v 0)]
+    (assert (valid-tag? tag)
+            (str "Invalid Hiccup form: " (pr-str v)))
+    (let [ne (native-element tag v)]
+      (if (some? ne)
+        ne
+        (let [c (as-class (nth v 0))
+              jsprops #js{:argv v}]
+          (let [k (-> v meta get-key)
+                k' (if (nil? k)
+                     (-> v (nth 1 nil) get-key)
+                     k)]
+            (when-not (nil? k')
+              (.! jsprops :key k')))
+          (.' js/React createElement c jsprops))))))

 (def seq-ctx #js{})


removed unnecessary local values

removed unnecessary local values

--- src/reagent_search/search.cljs
+++ src/reagent_search/search.cljs
@@ -18,15 +18,13 @@
   and a selected item channel
   the number of items rendered is limited to size items"
   [size itemsref chan-selecteditems]
-  (let [items itemsref]
-  (fn []
-  (if-not (empty? @items)
+  (if-not (empty? @itemsref)
     [:div.open.dropdown-toggle {:data-toggle "dropdown"}
      [:ul.dropdown-menu
       {:role "menu"}
-      (for [item (reverse (take size @items))]
+      (for [item (reverse (take size @itemsref))]
         ^{:key (utils/uuid)} [autocomplete-item item])]]
-    [:div.close]))))
+    [:div.close]))

 ;;; search input box and component
 (defn- handle-querystream


access the original object via a private util fn

--- src/java_time/data.clj
+++ src/java_time/data.clj
@@ -35,6 +35,10 @@
     :rata-die     (.get o JulianFields/RATA_DIE)
     nil))

+(defn- original-object
+  [d]  ;; `d/datafy` adds the original object in the metadata
+  (-> d meta ::d/obj))
+
 (defonce ^:private system-zone
   (delay (ZoneId/systemDefault)))

@@ -68,8 +72,8 @@

         {`p/nav (fn [_ k v]
                   (case k
-                    :before? (.isBefore ym (-> v meta ::d/obj))
-                    :after?  (.isAfter  ym (-> v meta ::d/obj))
+                    :before? (.isBefore ym (original-object v))
+                    :after?  (.isAfter  ym (original-object v))
                     :instant (-> (.atDay ym 1)
                                  (.atStartOfDay)
                                  (.toInstant (or (zone-offset v) @system-offset)))
@@ -89,15 +93,15 @@

         {`p/nav  (fn [_ k v]
                    (case k
-                     :before?    (.isBefore lt (-> v meta ::d/obj))
-                     :after?     (.isAfter  lt (-> v meta ::d/obj))
+                     :before?    (.isBefore lt (original-object v))
+                     :after?     (.isAfter  lt (original-object v))
                      :iso-format (.format DateTimeFormatter/ISO_TIME lt)
                      :format     (.format (dt-formatter v) lt)
                      nil))})))

   LocalDate
   (datafy [ld]
-    (let [weekday (.getDayOfWeek  ld)
+    (let [weekday (.getDayOfWeek ld)
           ym      (YearMonth/of (.getYear ld)
                                 (.getMonth ld))]
       (with-meta
@@ -107,8 +111,8 @@

         {`p/nav (fn [_ k v]
                   (case k
-                    :before?    (.isBefore ld (-> v meta ::d/obj))
-                    :after?     (.isAfter  ld (-> v meta ::d/obj))
+                    :before?    (.isBefore ld (original-object v))
+                    :after?     (.isAfter  ld (original-object v))
                     :iso-format (.format DateTimeFormatter/ISO_DATE ld)
                     :format     (.format (dt-formatter v) ld)
                     :julian     (julian-field ld v)
@@ -130,8 +134,8 @@

         {`p/nav (fn [_ k v]
                   (case k
-                    :before?    (.isBefore ldt (-> v meta ::d/obj))
-                    :after?     (.isAfter  ldt (-> v meta ::d/obj))
+                    :before?    (.isBefore ldt (original-object v))
+                    :after?     (.isAfter  ldt (original-object v))
                     :iso-format (.format DateTimeFormatter/ISO_LOCAL_DATE_TIME ldt)
                     :format     (.format (dt-formatter v) ldt)
                     :instant    (.toInstant ldt (or (zone-offset v) @system-offset))
@@ -153,8 +157,8 @@

         {`p/nav (fn [_ k v]
                   (case k
-                    :before?    (.isBefore odt (-> v meta ::d/obj))
-                    :after?     (.isAfter  odt (-> v meta ::d/obj))
+                    :before?    (.isBefore odt (original-object v))
+                    :after?     (.isAfter  odt (original-object v))
                     :iso-format (.format DateTimeFormatter/ISO_OFFSET_DATE_TIME odt)
                     :format     (.format (dt-formatter v) ldt)
                     :instant    (.toInstant odt)
@@ -172,8 +176,8 @@

         {`p/nav (fn [_ k v]
                   (case k
-                    :before?    (.isBefore zdt (-> v meta ::d/obj))
-                    :after?     (.isAfter  zdt (-> v meta ::d/obj))
+                    :before?    (.isBefore zdt (original-object v))
+                    :after?     (.isAfter  zdt (original-object v))
                     :iso-format (.format DateTimeFormatter/ISO_ZONED_DATE_TIME zdt)
                     :format     (.format (dt-formatter v) zdt)
                     :instant    (.toInstant zdt)
@@ -198,8 +202,8 @@
                  :nano   epoch-nano}}
         {`p/nav (fn [_ k v]
                   (case k
-                    :before?         (.isBefore inst (-> v meta ::d/obj))
-                    :after?          (.isAfter  inst (-> v meta ::d/obj))
+                    :before?         (.isBefore inst (original-object v))
+                    :after?          (.isAfter  inst (original-object v))
                     :iso-format      (.format DateTimeFormatter/ISO_INSTANT inst)
                     :format          (.format ^DateTimeFormatter v inst)
                     :local-time      (LocalTime/ofInstant      inst  (or (zone-id v) @system-zone))


friend-list example: update clj-fakes dep

--- examples/friend-list/project.clj
+++ examples/friend-list/project.clj
@@ -18,7 +18,7 @@
                  [org.clojure/core.match "0.3.0-alpha4"]

                  ; for tests
-                 [clj-fakes "0.7.0"]
+                 [clj-fakes "0.8.0"]
                  [prismatic/schema-generators "0.1.0"]]

   :pedantic? :abort


slightly more robust configuration

slightly more robust configuration

--- src/statuses/configuration.clj
+++ src/statuses/configuration.clj
@@ -10,8 +10,14 @@
 (def config-holder (atom default-config))

 (defn init! [path]
-  (println "Initializing configuration from" path)
-  (reset! config-holder (merge default-config (read-string (slurp path)))))
+  (if path
+    (try
+      (println "Initializing configuration from" path ":")
+      (swap! config-holder #(merge % (read-string (slurp path))))
+      (catch java.io.FileNotFoundException e
+        (println "Configuration not found, exiting.")
+        (System/exit -1)))
+    (println "Using default configuration.")))

 (defn config
   ([] @config-holder)


Fix compilation error message :wrench:

Fix compilation error message :wrench:

--- src/metabase/util.clj
+++ src/metabase/util.clj
@@ -10,7 +10,8 @@
                       [coerce :as coerce]
                       [format :as time])
             colorize.core
-            [metabase.config :as config])
+            [metabase.config :as config]
+            metabase.logger)             ; make sure this is loaded since we use clojure.tools.logging here
   (:import clojure.lang.Keyword
            (java.net Socket
                      InetSocketAddress


fix misaki.config/make-output-filename

fix misaki.config/make-output-filename

--- src/misaki/config.clj
+++ src/misaki/config.clj
@@ -200,25 +200,36 @@
              :day      (-?>> date day   (format "%02d"))
              :filename filename})))

+; =make-regular-output-filename
+(defn- make-regular-output-filename
+  "Make regular output filename from java.io.File."
+  [#^File file]
+  (let [path (.getPath file)
+        len  (count (:template-dir *config*))]
+    (if (.startsWith path (:template-dir *config*))
+      (.substring path len)
+      path)))
+
+; =make-index-output-filename
+(defn- make-index-output-filename
+  "Make index output filename from java.io.File."
+  [#^File file & {:keys [page] :or {page nil}}]
+  (let [filename   (make-regular-output-filename file)
+        page-index (or page *page-index*)]
+    (if (not= 0 page-index)
+      (render (:page-filename-format *config*)
+              {:filename filename, :page (inc page-index)})
+      filename)))
+
 ; =make-output-filename
 (defn make-output-filename
   "Make output filename from java.io.File."
   [#^File file & {:keys [page] :or {page nil}}]
   {:pre [(file? file)]}
-
-  (if (post-file? file)
-    (make-post-output-filename file)
-    (let [path (.getPath file)
-          len  (count (:template-dir *config*))
-          filename (if (.startsWith path (:template-dir *config*))
-                     (.substring path len)
-                     path)
-          page-index (if page page *page-index*)]
-      (if (and (index-file? file) (not= 0 page-index))
-        (render (:page-filename-format *config*)
-                {:filename filename
-                 :page     (inc page-index)})
-        filename))))
+  (cond
+    (post-file? file)  (make-post-output-filename file)
+    (index-file? file) (make-index-output-filename file :page page)
+    :else              (make-regular-output-filename file)))

 ; =make-output-url
 (defn make-output-url


benchmark keypath alongside direct keyword navigation

--- scripts/benchmarks.clj
+++ scripts/benchmarks.clj
@@ -55,6 +55,7 @@
   (run-benchmark "get value in nested map" 10000000
     (get-in data [:a :b :c])
     (select [:a :b :c] data)
+    (select [(keypath :a) (keypath :b) (keypath :c)] data)
     (compiled-select p data)
     (-> data :a :b :c vector)
     )


Add date and remove consumer group id to/from s3 key.

--- src/uswitch/bifrost/s3.clj
+++ src/uswitch/bifrost/s3.clj
@@ -8,13 +8,16 @@
             [clj-kafka.zk :refer (committed-offset set-offset!)]
             [uswitch.bifrost.util :refer (close-channels)]
             [uswitch.bifrost.async :refer (observable-chan map->Spawner)]
-            [uswitch.bifrost.telemetry :refer (rate-gauge reset-gauge! stop-gauge! update-gauge!)]))
+            [uswitch.bifrost.telemetry :refer (rate-gauge reset-gauge! stop-gauge! update-gauge!)]
+            [clj-time.core :refer (now)]
+            [clj-time.format :as tf]))

 (def buffer-size 100)
+(def key-date-formatter (tf/formatters :basic-date))

-(defn generate-key [consumer-group-id topic partition first-offset]
+(defn generate-key [topic partition first-offset]
   (format "%s/%s/partition%02d/%s.baldr.gz"
-          consumer-group-id
+          (tf/unparse key-date-formatter (now))
           topic
           partition
           (format "%010d" first-offset)))
@@ -25,7 +28,7 @@
   (let [f (file file-path)]
     (if (.exists f)
       (let [g        (caching-rate-gauge (str topic "-" partition "-uploadBytes"))
-            key      (generate-key consumer-group-id topic partition first-offset)
+            key      (generate-key topic partition first-offset)
             dest-url (str "s3n://" bucket "/" key)]
         (info "Uploading" file-path "to" dest-url)
         (time! (timer (str topic "-s3-upload-time"))


Start move-hints

Start move-hints

--- src/obb_api/handlers/show_game.clj
+++ src/obb_api/handlers/show_game.clj
@@ -43,6 +43,13 @@
                             :player-code viewer})
     game))

+(defn add-move-hints
+  "Adds to the given hash hints to use to move the elements"
+  [response game viewer]
+  (if (and viewer (simplify/name= viewer (get-in game [:board :state])))
+    (assoc response :move-hints {})
+    response))
+
 (defn handler
   "Shows a game's info"
   [request]
@@ -55,5 +62,6 @@
       (-> (prepare-game request built-game viewer)
           (simplify/clean-result)
           (add-username-info username viewer)
+          (add-move-hints built-game viewer)
           (response/json-ok))
       (response/json-not-found))))


Add missing license header on mixins ns file.

--- src/uxbox/util/mixins.cljs
+++ src/uxbox/util/mixins.cljs
@@ -1,3 +1,9 @@
+;; This Source Code Form is subject to the terms of the Mozilla Public
+;; License, v. 2.0. If a copy of the MPL was not distributed with this
+;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
+;;
+;; Copyright (c) 2016 Andrey Antukh <niwi@niwi.nz>
+
 (ns uxbox.util.mixins
   (:refer-clojure :exclude [concat])
   (:require [sablono.core :refer-macros [html]]


Make local storage compatible with the routes

Wrapped the file return in create-storage-object so we get the
mime type and the length.

--- src/vignette/storage/local.clj
+++ src/vignette/storage/local.clj
@@ -1,9 +1,11 @@
 (ns vignette.storage.local
-  (:require [vignette.storage.protocols :refer :all]
+  (:require (vignette.storage [protocols :refer :all]
+                              [common :refer :all])
             [vignette.media-types :as mt]
             [vignette.util.filesystem :refer :all]
             [clojure.java.io :as io]
-            [clojure.java.shell :as sh])
+            [clojure.java.shell :as sh]
+            [pantomime.mime :refer (mime-type-of)])
   (:import  (java.io FileInputStream)))

 ; TODO: when the logger has a closure port, we should create an exception that has context that we can log w/ exceptions
@@ -13,7 +15,7 @@
   (get-object [this bucket path]
     (let [real-file (io/file (resolve-local-path (:directory this) bucket path))]
       (when (file-exists? real-file)
-        real-file)))
+        (create-storage-object real-file (mime-type-of real-file) (file-length real-file)))))

   (put-object [this resource bucket path]
     (let [real-path (resolve-local-path (:directory this) bucket path)]


Remove duplicate task output from help task.

Consolidate IO in help.

--- src/leiningen/help.clj
+++ src/leiningen/help.clj
@@ -2,29 +2,29 @@
   "Display a list of tasks or help for a given task."
   (:use [clojure.contrib.find-namespaces :only [find-namespaces-on-classpath]]))

-(def tasks (filter #(re-find #"^leiningen\.(?!core)" (name %))
-                      (find-namespaces-on-classpath)))
+(def tasks (set (filter #(re-find #"^leiningen\.(?!core)" (name %))
+                        (find-namespaces-on-classpath))))

 ;; affected by clojure ticket #130: bug of AOT'd namespaces losing metadata
 (defn help-for [task]
   (let [task-ns (symbol (str "leiningen." task))
         _ (require task-ns)
         task (ns-resolve task-ns (symbol task))]
-    (println (or (:doc (meta task))
-                 (:doc (meta (find-ns task-ns)))))))
+    (or (:doc (meta task))
+        (:doc (meta (find-ns task-ns))))))

 (defn help-summary-for [task-ns]
   (require task-ns)
   (let [task-name (last (.split (name task-ns) "\\."))]
-    (println task-name (apply str (repeat (- 7 (count task-name)) " "))
-             "-" (:doc (meta (find-ns task-ns))))))
+    (str task-name (apply str (repeat (- 8 (count task-name)) " "))
+         " - " (:doc (meta (find-ns task-ns))))))

 (defn help [project & [task]]
   (if task
-    (help-for task)
+    (println (help-for task))
     (do (println "Leiningen is a build tool for Clojure.\n")
         (println "Several tasks are available:")
         (doseq [task-ns tasks]
-          (help-summary-for task-ns))
+          (println (help-summary-for task-ns)))
         (println "\nRun lein help $TASK for details.")
         (println "See http://github.com/technomancy/leiningen as well."))))


Only call (exit) if tests failed

Only call (exit) if tests failed

--- src/leiningen/spec.clj
+++ src/leiningen/spec.clj
@@ -42,6 +42,14 @@
         'leiningen.compile)
       ((ns-resolve 'leiningen.compile 'prep) project false))))

+(defn- exit-if-needed
+  [exit-code]
+  (when-not (zero? exit-code)
+    (try
+      (require 'leiningen.core.main)
+      ((ns-resolve (the-ns 'leiningen.core.main) 'exit) exit-code)
+      (catch java.io.FileNotFoundException e))))
+
 (defn spec
   "Speclj - pronounced \"speckle\": a TDD/BDD framework for Clojure.

@@ -56,8 +64,5 @@
   (let [speclj-args (cons "-c" args)
         classpath (compute-classpath-string project)
         jvm-args ["-cp" classpath "-Dspeclj.invocation=lein spec"]]
-    (try
-      (require 'leiningen.core.main)
-      ((ns-resolve (the-ns 'leiningen.core.main) 'exit) (java jvm-args "speclj.main" speclj-args (:root project)))
-      (catch java.io.FileNotFoundException e
-        (java jvm-args "speclj.main" speclj-args (:root project))))))
+    (exit-if-needed
+      (java jvm-args "speclj.main" speclj-args (:root project)))))


Clojure Example

Clojure Example

--- Clojure/src/at/rocworks/oa4j/core.clj
+++ Clojure/src/at/rocworks/oa4j/core.clj
@@ -25,7 +25,7 @@

 ; test clojure style
 (defn callback [dpIdValueList]
-  (let [v (reduce #(+ %1 %2) (map #(.getValueObject %) (seq dpIdValueList)))];
+  (let [v (reduce #(+ %1 %2) (map #(.getValueObject %) dpIdValueList))];
     (dpSet :ExampleDP_Trend1. v)))

 (def manager (new JManager))


Style for mobile consistency

Style for mobile consistency

--- src/yorck_ratings/view.clj
+++ src/yorck_ratings/view.clj
@@ -10,11 +10,17 @@
     [:head
      [:title "Yorck movies with IMDB ratings"]
      [:meta {:charset "utf-8"}]
+     [:meta {:name "viewport" :content "width=device-width, initial-scale=1"}]
      [:style "body {
                 font-size: 16px;
                 line-height: 1.4rem;
+                margin: 0;
               }
-              ol { list-style: none; }
+              ol {
+                list-style: none;
+                padding: 0;
+                margin: 2.8rem 10%;
+              }
               li {
                 padding: .1rem;
               }


update corecljs file

update corecljs file

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

           (defn submit-login [data-set focus]
@@ -1435,20 +1435,28 @@
 (defn khasragirdwani-form-validator [data-set]
   (first (b/validate data-set
                      :serialnumber [[v/required :message "Field is required Must be number"]]
-                     :subdivisionname [[v/required :message "Field is required"]]
-                     :tehsil [[v/required :message "Field is required"]]
-                     :year [[v/required :message "Field is required"]
-                            [date-year-after? :message "Year must greater than 1900"]
-                            [date-year-before? :message "Year must less than 9999"]]
+                     :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 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 [input-int id ttype data-set label input-focus]]
+       [: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]
@@ -1469,22 +1477,44 @@
                            [:b (str (first ((khasragirdwani-form-validator @data-set) id)))]])
                         [:div])]])))

-(defn khasragirdwani-tags-template [data-set]
-  (cond (nil? (:villageid @data-set)) [:select.form-control {:id "khasragirdwani-districts"}
-                                       (for [d (get-value! :villages)]
-                                         ^{:key (.-id d)} [:option {:value (.-id d)} (.-villagename d)])]
-        :else [:select.form-control {:id "khasragirdwani-districts" :defaultValue (:villageid @data-set)}
-               (doall (for [d (get-value! :villages)]
-                        ^{:key (.-id d)} [:option {:value (.-id d)} (.-villagename d)]))]))
-
-
-(defn khasragirdwani-input-select [label data-set focus]
-  (let [input-focus (r/atom nil)]
-    (fn []
-      [:div.form-group
-       [:label.col-sm-3.control-label label]
-       [:div#tagdiv.col-sm-6 [khasragirdwani-tags-template data-set]]
-       [:div.col-sm-3 [: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-form-cancel [event]
   (accountant/navigate! "/khasragirdwani"))
@@ -1498,10 +1528,9 @@
      [:div.form-horizontal
       [:div.box-body
        [khasragirdwani-input-int-row :serialnumber "Serial Number" "text" data-set focus]
-       [khasragirdwani-input-select "Village Name" data-set focus ]
-       [khasragirdwani-input-row :subdivisionname "Sub Division Name" "text" data-set focus]
-       [khasragirdwani-input-row :tehsil "Tehsil" "text" data-set focus]
-       [khasragirdwani-input-row :year "Year" "date" 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]
+       [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
@@ -1512,23 +1541,19 @@
         ]]]]]])

+
 (defn khasragirdwani-add-form-onclick [data-set focus]
-  (if (= nil (khasragirdwani-form-validator @data-set))
-    (do (reset! data-set (assoc @data-set :villageid
-                                (int (.-value (.getElementById js/document "khasragirdwani-districts")))))
-        (let [onres (fn[json] (accountant/navigate! "/khasragirdwani"))]
-          (http-post (str serverhost "khasragirdwanis") onres  (.serialize (Serializer.) (clj->js @data-set)))))
-    (reset! focus "on")))
+  (if (= nil (revenue-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"))

 (defn khasragirdwani-update-form-onclick [data-set focus]
   (if (= nil (khasragirdwani-form-validator @data-set))
-    (do (reset! data-set (assoc @data-set :villageid
-                                (int (.-value (.getElementById js/document "khasragirdwani-districts")))))
-        (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")))
+    (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"))

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

 (defn khasragirdwani-update-template [id dmt]
   (let [update-data (r/atom {:id (int id)
                              :serialnumber (.-serialnumber dmt)
-                             :subdivisionname (.-subdivisionname dmt)
+                             :subdivisionid (.-subdivisionid dmt)
                              :villageid (.-villageid dmt)
-                             :villagename (.-villagename 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]
@@ -1581,27 +1604,31 @@
 (defroute khasragirdwani-add-path "/khasragirdwani/add" []
   (if (nil? (get-value! :user)) (accountant/navigate! "/login")
       (let [onres (fn[json](
-                           (set-key-value :villages (getdata json))
+                           (set-key-value :subdivisions (getdata json))
                            (set-page! [khasragirdwani-add-template])))]
-        (http-get-auth (str serverhost "villages") onres))))
+        (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)))])))]
-    (http-get-auth (str serverhost "villages") onres)))
+                                                    (=(.-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-sm-12
+  [:div.col-md-12
    [:div {:class "box"}
     [:div {:class "box-header"}
-     [:h3.box-title "List of Khasragirdwani Records"]]
+     [:h3.box-title "List of Khasragirdwani"]]
     [:div.box-body
       [:div.form-group
        [:input {:type "button" :value "Add"
@@ -1613,13 +1640,12 @@
           (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 "Sub Division Name"]
-          [:th "Tehsil"]
+          ;; [:th "Tehsil"]
           [:th "Year"]
           [:th "Rack Number"]
-          [:th "Description"]
-          ]]
+          [:th "Description"]]]
         [:tbody
          (doall (for [mt khasragirdwanis]
                   ^{:key (.-id mt)}
@@ -1631,37 +1657,46 @@
                      [:td  [button {:bs-style "danger"
                                     :on-click #(khasragirdwani-delete(.-id mt))} "Delete"]])
                    [:td (.-serialnumber mt)]
+                   [:td (.-subdivisionname mt)]
                    [:td (.-villagename mt)]
-                   [:td (.-subdivisionname 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"]]
-                     :subdivisionname [[v/required :message "Field is required"]]
-                     :tehsil [[v/required :message "Field is required"]]
-                     :year [[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 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")
+                        }])

 (defn masavi-input-int-row [id label ttype data-set focus]
@@ -1669,7 +1704,7 @@
     (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-6 [masavi-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]
@@ -1691,22 +1726,43 @@
                         [:div])]])))

-(defn masavi-tags-template [data-set]
-  (cond (nil? (:villageid @data-set)) [:select.form-control {:id "masavi-districts"}
-                                       (for [d (get-value! :villages)]
-                                         ^{:key (.-id d)} [:option {:value (.-id d)} (.-villagename d)])]
-        :else [:select.form-control {:id "masavi-districts" :defaultValue (:villageid @data-set)}
-               (doall (for [d (get-value! :villages)]
-                        ^{:key (.-id d)} [:option {:value (.-id d)} (.-villagename d)]))]))
-
-(defn masavi-input-select [label data-set focus]
-  (let [input-focus (r/atom nil)]
-    (fn []
-      [:div.form-group
-       [:label.col-sm-3.control-label label]
-       [:div#tagdiv.col-sm-6 [masavi-tags-template data-set]]
-       [:div.col-sm-3 [: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"))
@@ -1720,9 +1776,8 @@
      [:div.form-horizontal
       [:div.box-body
        [masavi-input-int-row :serialnumber "Serial Number" "text" data-set focus]
-       [masavi-input-select "Village Name" data-set focus ]
-       [masavi-input-row :subdivisionname "Sub Division Name" "text" data-set focus]
-       [masavi-input-row :tehsil "Tehsil" "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]
        [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]
@@ -1730,23 +1785,24 @@
         [: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"]]]]]]]]])
+          [button {:bs-style "danger" :on-click masavi-form-cancel } "Cancel"]]]
+        ]]]]]])
+

 (defn masavi-add-form-onclick [data-set focus]
-  (if (= nil (masavi-form-validator @data-set))
-    (do (reset! data-set (assoc @data-set :villageid (int (.-value (.getElementById js/document "masavi-districts")))))
-        (let [onres (fn[json] (accountant/navigate! "/masavi"))]
-          (http-post (str serverhost "masavis") onres  (.serialize (Serializer.) (clj->js @data-set)))))
-    (reset! focus "on")))
+  (if (= nil (revenue-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"))

 (defn masavi-update-form-onclick [data-set focus]
   (if (= nil (masavi-form-validator @data-set))
-    (do (reset! data-set (assoc @data-set :villageid (int (.-value (.getElementById js/document "masavi-districts")))))
-        (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")))
+    (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]
@@ -1764,25 +1820,24 @@
   (let [add-data (r/atom {:isactive true})
         focus (r/atom nil)]
     (fn [] [masavi-template
-           "Masavi Add Form"
+           "Khasra Girdwani Add Form"
            add-data focus
            #(masavi-add-form-onclick add-data focus)])))

 (defn masavi-update-template [id dmt]
   (let [update-data (r/atom {:id (int id)
                              :serialnumber (.-serialnumber dmt)
-                             :subdivisionname (.-subdivisionname dmt)
+                             :subdivisionid (.-subdivisionid dmt)
                              :villageid (.-villageid dmt)
-                             :villagename (.-villagename dmt)
-                             :tehsil (.-tehsil dmt)
                              :year (.-year dmt)
                              :racknumber (.-racknumber dmt)
-                             :description (.-description dmt)})
+                             :description (.-description dmt)
+                             :isactive true})
         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]
@@ -1793,29 +1848,35 @@
                 (accountant/navigate! "/masavi"))]
     (http-delete (str serverhost "masavis/" id)  onres)))

+
 (defroute masavi-add-path "/masavi/add" []
   (if (nil? (get-value! :user)) (accountant/navigate! "/login")
       (let [onres (fn[json](
-                           (set-key-value :villages (getdata json))
+                           (set-key-value :subdivisions (getdata json))
                            (set-page! [masavi-add-template])))]
-        (http-get-auth (str serverhost "villages") onres))))
+        (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)))])))]
-    (http-get-auth (str serverhost "villages") onres)))
+                                                    (=(.-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))))

 (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 Records"]]
+     [:h3.box-title "List of masavi"]]
     [:div.box-body
       [:div.form-group
        [:input {:type "button" :value "Add"
@@ -1827,13 +1888,12 @@
           (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 "Sub Division Name"]
-          [:th "Tehsil"]
+          ;; [:th "Tehsil"]
           [:th "Year"]
           [:th "Rack Number"]
-          [:th "Description"]
-         ]]
+          [:th "Description"]]]
         [:tbody
          (doall (for [mt masavis]
                   ^{:key (.-id mt)}
@@ -1845,44 +1905,53 @@
                      [:td  [button {:bs-style "danger"
                                     :on-click #(masavi-delete(.-id mt))} "Delete"]])
                    [:td (.-serialnumber mt)]
+                   [:td (.-subdivisionname mt)]
                    [:td (.-villagename mt)]
-                   [:td (.-subdivisionname 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 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"]]
-                     :subdivisionname [[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")
+                        }])
+

 (defn consolidation-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-6 [consolidation-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]
@@ -1904,28 +1973,46 @@
                         [:div])]])))

-(defn consolidation-tags-template [data-set]
-  (cond (nil? (:villageid @data-set)) [:select.form-control {:id "consolidation-districts"}
-                                       (for [d (get-value! :villages)]
-                                         ^{:key (.-id d)} [:option {:value (.-id d)} (.-villagename d)])]
-        :else [:select.form-control {:id "consolidation-districts" :defaultValue (:villageid @data-set)}
-               (doall (for [d (get-value! :villages)]
-                        ^{:key (.-id d)} [:option {:value (.-id d)} (.-villagename d)]))]))
-
-(defn consolidation-input-select [label data-set focus]
-  (let [input-focus (r/atom nil)]
-    (fn []
-      [:div.form-group
-       [:label.col-sm-3.control-label label]
-       [:div#tagdiv.col-sm-6 [consolidation-tags-template data-set]]
-       [:div.col-sm-3 [: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
@@ -1936,9 +2023,8 @@
      [:div.form-horizontal
       [:div.box-body
        [consolidation-input-int-row :serialnumber "Serial Number" "text" data-set focus]
-       [consolidation-input-select "Village Name" data-set focus ]
-       [consolidation-input-row :subdivisionname "Sub Division Name" "text" data-set focus]
-       [consolidation-input-row :tehsil "Tehsil" "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]
        [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]
@@ -1950,20 +2036,20 @@
         ]]]]]])

+
 (defn consolidation-add-form-onclick [data-set focus]
-  (if (= nil (consolidation-form-validator @data-set))
-    (do (reset! data-set (assoc @data-set :villageid (int (.-value (.getElementById js/document "consolidation-districts")))))
-        (let [onres (fn[json] (accountant/navigate! "/consolidation"))]
-          (http-post (str serverhost "consolidations") onres  (.serialize (Serializer.) (clj->js @data-set)))))
-  (reset! focus "on")))
+  (if (= nil (revenue-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"))

 (defn consolidation-update-form-onclick [data-set focus]
   (if (= nil (consolidation-form-validator @data-set))
-    (do (reset! data-set (assoc @data-set :villageid (int (.-value (.getElementById js/document "consolidation-districts")))))
-        (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")))
+    (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]
@@ -1977,30 +2063,28 @@
       (http-get-auth (str serverhost "villages/search?name=" eval) onresp))))

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

 (defn consolidation-update-template [id dmt]
   (let [update-data (r/atom {:id (int id)
                              :serialnumber (.-serialnumber dmt)
-                             :subdivisionname (.-subdivisionname dmt)
+                             :subdivisionid (.-subdivisionid dmt)
                              :villageid (.-villageid dmt)
-                             :villagename (.-villagename dmt)
-                             :tehsil (.-tehsil dmt)
                              :year (.-year dmt)
                              :racknumber (.-racknumber dmt)
-                             :description (.-description dmt)})
+                             :description (.-description dmt)
+                             :isactive true})
         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]
@@ -2011,68 +2095,78 @@
                 (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 :villages (getdata json))
+                           (set-key-value :subdivisions (getdata json))
                            (set-page! [consolidation-add-template])))]
-        (http-get-auth (str serverhost "villages") onres))))
+        (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)))])))]
-    (http-get-auth (str serverhost "villages") onres)))
+                                                    (=(.-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"))
+
+

 (defn render-consolidation [consolidations]
   [:div.col-md-12
    [:div {:class "box"}
     [:div {:class "box-header"}
-     [:h3.box-title "List of Consolidation Records"]]
+     [:h3.box-title "List of consolidation"]]
     [: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 "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.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.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)))

@@ -2084,20 +2178,28 @@
 (defn fieldbook-form-validator [data-set]
   (first (b/validate data-set
                      :serialnumber [[v/required :message "Field is required Must be number"]]
-                     :subdivisionname [[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")
+                        }])
+
+
 (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 [input-int id ttype data-set label input-focus]]
+       [:div.col-sm-6 [fieldbook-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]
@@ -2119,25 +2221,46 @@
                         [:div])]])))

-(defn fieldbook-tags-template [data-set]
-  (cond (nil? (:villageid @data-set)) [:select.form-control {:id "fieldbook-districts"}
-                                       (for [d (get-value! :villages)]
-                                         ^{:key (.-id d)} [:option {:value (.-id d)} (.-villagename d)])]
-        :else [:select.form-control {:id "fieldbook-districts" :defaultValue (:villageid @data-set)}
-               (doall (for [d (get-value! :villages)]
-                        ^{:key (.-id d)} [:option {:value (.-id d)} (.-villagename d)]))]))
-
-(defn fieldbook-input-select [label data-set focus]
-  (let [input-focus (r/atom nil)]
-    (fn []
-      [:div.form-group
-       [:label.col-sm-3.control-label label]
-       [:div#tagdiv.col-sm-6 [fieldbook-tags-template data-set]]
-       [:div.col-sm-3 [: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
@@ -2148,9 +2271,8 @@
      [:div.form-horizontal
       [:div.box-body
        [fieldbook-input-int-row :serialnumber "Serial Number" "text" data-set focus]
-       [fieldbook-input-select "Village Name" data-set focus ]
-       [fieldbook-input-row :subdivisionname "Sub Division Name" "text" data-set focus]
-       [fieldbook-input-row :tehsil "Tehsil" "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]
        [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]
@@ -2158,22 +2280,23 @@
         [: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"]]] ]]]]]])
+          [button {:bs-style "danger" :on-click fieldbook-form-cancel } "Cancel"]]]
+        ]]]]]])
+
+

 (defn fieldbook-add-form-onclick [data-set focus]
-  (if (= nil (fieldbook-form-validator @data-set))
-    (do (reset! data-set (assoc @data-set :villageid (int (.-value (.getElementById js/document "fieldbook-districts")))))
-        (let [onres (fn[json] (accountant/navigate! "/fieldbook"))]
-          (http-post (str serverhost "fieldbooks") onres  (.serialize (Serializer.) (clj->js @data-set)))))
-    (reset! focus "on")))
+  (if (= nil (revenue-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"))

 (defn fieldbook-update-form-onclick [data-set focus]
   (if (= nil (fieldbook-form-validator @data-set))
-    (do (reset! data-set (assoc @data-set :villageid (int (.-value (.getElementById js/document "fieldbook-districts")))))
-        (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")))
+    (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"))

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

 (defn fieldbook-update-template [id dmt]
   (let [update-data (r/atom {:id (int id)
                              :serialnumber (.-serialnumber dmt)
-                             :subdivisionname (.-subdivisionname dmt)
+                             :subdivisionid (.-subdivisionid dmt)
                              :villageid (.-villageid dmt)
-                             :villagename (.-villagename dmt)
-                             :tehsil (.-tehsil dmt)
                              :year (.-year dmt)
                              :racknumber (.-racknumber dmt)
-                             :description (.-description dmt)})
+                             :description (.-description dmt)
+                             :isactive true})
         focus (r/atom nil)]
     (fn [] [fieldbook-template
-            "Field Book Update Form"
-            update-data focus
-            #(fieldbook-update-form-onclick update-data focus)])))
+           "fieldbook Update Form"
+           update-data focus
+           #(fieldbook-update-form-onclick update-data focus)])))

 (defn fieldbook-update[id]
@@ -2225,27 +2347,31 @@
 (defroute fieldbook-add-path "/fieldbook/add" []
   (if (nil? (get-value! :user)) (accountant/navigate! "/login")
       (let [onres (fn[json](
-                           (set-key-value :villages (getdata json))
+                           (set-key-value :subdivisions (getdata json))
                            (set-page! [fieldbook-add-template])))]
-        (http-get-auth (str serverhost "villages") onres))))
+        (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)))])))]
-    (http-get-auth (str serverhost "villages") onres)))
+                                                    (=(.-id obj) (.parseInt js/window id))) (get-value! :fieldbooks)))])))
+        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 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 Field Book Records"]]
+     [:h3.box-title "List of fieldbook"]]
     [:div.box-body
       [:div.form-group
        [:input {:type "button" :value "Add"
@@ -2254,42 +2380,41 @@
        [: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 "Sub Division Name"]
           [:th "Name of the Village"]
-          [:th "Sub Division Name"]
-          [:th "Tehsil"]
+          ;; [: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 (.-villagename mt)]
-                  [:td (.-subdivisionname 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 (.-subdivisionname mt)]
+                   [:td (.-villagename 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)))


fix append-delim-trail to append to correct line

--- src/parinfer/prep.cljs
+++ src/parinfer/prep.cljs
@@ -37,7 +37,7 @@
     (-> state
         (assoc :stack stack
                :dedent-x (:x-pos opener))
-        (update-in [:lines line-no] insert-string (:x-pos insert) close-ch)
+        (update-in [:lines (:line-no insert)] insert-string (:x-pos insert) close-ch)
         (update-in [:insert :x-pos] inc))))

 (defn min-indent


added at update template function

added at update template function

--- src_cljs/rrm/corecljs.cljs
+++ src_cljs/rrm/corecljs.cljs
@@ -532,6 +532,9 @@
            [:div.col-sm-3 [:div]]]
           [form-input-element :remarks "Remarks" "text" data-set focus]
           ])])))
+
+(def button-tool-bar (r/adapt-react-class (aget js/ReactBootstrap "ButtonToolbar")))
+(def button (r/adapt-react-class (aget js/ReactBootstrap "Button")))

 (defn add-mutation-template [doc-name data-set focus save-function]
@@ -562,50 +565,44 @@
        [add-check-input-element :senddate "Send Date" data-set focus]
        ]
       [:div.box-footer
-       [:button.btn.btn-default {:on-click form-cancel} "Cancel"]
-       [:button.btn.btn-info.pull-right {:on-click save-function} "Save"]
+       [:div.col-sm-8.col-md-offset-5
+        [button-tool-bar
+         [button {:bs-style "default" :on-click form-cancel } "Cancel"]
+         [button {:bs-style "info" :on-click save-function} "Save"]]]
        ;;[:span (str @data-set)]
        ]]]]])

 (defn upd-check-input-element [data-set focus]
-  (let [check1 (r/atom true)
-        check2 (r/atom true)]
+  (let [check (r/atom true)]
     (fn []
       [:div
-       (if (:senddate @data-set)
-         [:div.form-group
-          [:label.col-sm-3.control-label "Send Date"]
-          [:div.col-sm-6 [date-input :senddate data-set "Send Date" true]]
-          [:div.col-sm-3 [:div]]]
+       [:div.form-group
+        [:label.col-sm-3.control-label "Send Date"]
+        [:div.col-sm-6 [date-input :senddate data-set "Send Date" true]]
+        [:div.col-sm-3 [:div]]]
+       (if (:receiveddate @data-set)
+         [:div
+          [:div.form-group
+           [:label.col-sm-3.control-label "Received Date"]
+           [:div.col-sm-6 [date-input :receiveddate data-set "Received Date" false]]
+           [:div.col-sm-3 [:div]]]
+          [form-input-element :remarks "Remarks" "text" data-set focus]]
          [:div
           [:div.form-group
            [:div.col-sm-3
             [:input {:type "checkbox"
                      :style {:width "17px" :height "17px" :float "right"}
-                     :on-change #(swap! check1 not)}]]
-           [:label.col-sm-6 "Check here to enter Send date"]
+                     :on-change #(swap! check not)}]]
+           [:label.col-sm-6 "Check here to enter received date"]
            [:div.col-sm-3 [:div]]]
-          (if @check1
+          (if @check
             [:div]
-            [:div.form-group
-             [:label.col-sm-3.control-label "Send Date"]
-             [:div.col-sm-6 [date-input :senddate data-set "Send Date" false]]
-             [:div.col-sm-3 [:div]]])])
-       [:div.form-group
-        [:div.col-sm-3
-         [:input {:type "checkbox"
-                  :style {:width "17px" :height "17px" :float "right"}
-                  :on-change #(swap! check2 not)}]]
-        [:label.col-sm-6 "Check here to enter received date"]
-        [:div.col-sm-3 [:div]]]
-       (if @check2
-         [:div]
-         [:div.form-group
-          [:label.col-sm-3.control-label "Received Date"]
-          [:div.col-sm-6 [date-input :receiveddate data-set "Received Date" false]]
-          [:div.col-sm-3 [:div]]])
-       [form-input-element :remarks "Remarks" "text" data-set focus]])))
-
+            [:div
+             [:div.form-group
+              [:label.col-sm-3.control-label "Received Date"]
+              [:div.col-sm-6 [date-input :receiveddate data-set "Received Date" false]]
+              [:div.col-sm-3 [:div]]]
+             [form-input-element :remarks "Remarks" "text" data-set focus]])])])))

 (defn update-mutation-template [doc-name data-set focus save-function]
@@ -681,36 +678,97 @@

 (defn mutation-update-template [id dmt]
-  (let [update-data (r/atom {:id (int id)
-                             :mutationnumber (.-mutationnumber (.-numbers dmt))
-                             :nameofthefirstparty (.-nameofthefirstparty dmt)
-                             :nameofthesecondparty (.-nameofthesecondparty dmt)
-                             :dateofinstitution (.-dateofinstitution dmt)
-                             :nameofpo (.-nameofpo dmt)
-                             :dateofdecision (.-dateofdecision dmt)
-                             :title (.-title dmt)
-                             :khasranumber (.-khasranumber (.-numbers dmt))
-                             :khatakhatuninumber (.-khasranumber (.-numbers dmt))
-                             :area (.-area dmt)
-                             :o2number (.-o2number (.-numbers dmt))
-                             :o4number (.-o4number (.-numbers dmt))
-                             :o6number (.-o6number (.-numbers dmt))
-                             :racknumber (.-racknumber (.-numbers dmt))
-                             :senddate (.-senddate dmt)
-                             :receiveddate (.-receiveddate dmt)
-                             :remarks (.-remarks dmt)
-                             :villageid (.-id (.-village dmt))
-                             :subdivisionid (.-id (.-subdivision dmt))
-                             :districtid (.-id (.-district dmt))
-                             :isactive true})
-        focus (r/atom nil)]
-    (fn [] [update-mutation-template
+  (do
+     (if (and (not= nil (.-senddate dmt)) (not= nil (.-receiveddate dmt)))
+        (let [update-data (r/atom {:id (int id)
+                                 :mutationnumber (.-mutationnumber (.-numbers dmt))
+                                 :nameofthefirstparty (.-nameofthefirstparty dmt)
+                                 :nameofthesecondparty (.-nameofthesecondparty dmt)
+                                 :dateofinstitution (.-dateofinstitution dmt)
+                                 :nameofpo (.-nameofpo dmt)
+                                 :dateofdecision (.-dateofdecision dmt)
+                                 :title (.-title dmt)
+                                 :khasranumber (.-khasranumber (.-numbers dmt))
+                                 :khatakhatuninumber (.-khasranumber (.-numbers dmt))
+                                 :area (.-area dmt)
+                                 :o2number (.-o2number (.-numbers dmt))
+                                 :o4number (.-o4number (.-numbers dmt))
+                                 :o6number (.-o6number (.-numbers dmt))
+                                 :racknumber (.-racknumber (.-numbers dmt))
+                                 :senddate nil
+                                 :receiveddate nil
+                                 :remarks (.-remarks dmt)
+                                 :villageid (.-id (.-village dmt))
+                                 :subdivisionid (.-id (.-subdivision dmt))
+                                 :districtid (.-id (.-district dmt))
+                                 :isactive true})
+              focus (r/atom nil)]
+        (fn []
+          [add-mutation-template
            "Mutation Update Form"
            update-data
            focus
-           #(update-form-onclick update-data focus)])))
-
-
+           #(update-form-onclick update-data focus)]))
+        (if (= nil (.-senddate dmt))
+          (let [update-data (r/atom {:id (int id)
+                                     :mutationnumber (.-mutationnumber (.-numbers dmt))
+                                     :nameofthefirstparty (.-nameofthefirstparty dmt)
+                                     :nameofthesecondparty (.-nameofthesecondparty dmt)
+                                     :dateofinstitution (.-dateofinstitution dmt)
+                                     :nameofpo (.-nameofpo dmt)
+                                     :dateofdecision (.-dateofdecision dmt)
+                                     :title (.-title dmt)
+                                     :khasranumber (.-khasranumber (.-numbers dmt))
+                                     :khatakhatuninumber (.-khasranumber (.-numbers dmt))
+                                     :area (.-area dmt)
+                                     :o2number (.-o2number (.-numbers dmt))
+                                     :o4number (.-o4number (.-numbers dmt))
+                                     :o6number (.-o6number (.-numbers dmt))
+                                     :racknumber (.-racknumber (.-numbers dmt))
+                                     :senddate (.-senddate dmt)
+                                     :receiveddate (.-receiveddate dmt)
+                                     :remarks (.-remarks dmt)
+                                     :villageid (.-id (.-village dmt))
+                                     :subdivisionid (.-id (.-subdivision dmt))
+                                     :districtid (.-id (.-district dmt))
+                                     :isactive true})
+                focus (r/atom nil)]
+            (fn []
+              [add-mutation-template
+               "Mutation Update Form"
+               update-data
+               focus
+               #(update-form-onclick update-data focus)]))
+          (let [update-data (r/atom {:id (int id)
+                                     :mutationnumber (.-mutationnumber (.-numbers dmt))
+                                     :nameofthefirstparty (.-nameofthefirstparty dmt)
+                                     :nameofthesecondparty (.-nameofthesecondparty dmt)
+                                     :dateofinstitution (.-dateofinstitution dmt)
+                                     :nameofpo (.-nameofpo dmt)
+                                     :dateofdecision (.-dateofdecision dmt)
+                                     :title (.-title dmt)
+                                     :khasranumber (.-khasranumber (.-numbers dmt))
+                                     :khatakhatuninumber (.-khasranumber (.-numbers dmt))
+                                     :area (.-area dmt)
+                                     :o2number (.-o2number (.-numbers dmt))
+                                     :o4number (.-o4number (.-numbers dmt))
+                                     :o6number (.-o6number (.-numbers dmt))
+                                     :racknumber (.-racknumber (.-numbers dmt))
+                                     :senddate (.-senddate dmt)
+                                     :receiveddate (.-receiveddate dmt)
+                                     :remarks (.-remarks dmt)
+                                     :villageid (.-id (.-village dmt))
+                                     :subdivisionid (.-id (.-subdivision dmt))
+                                     :districtid (.-id (.-district dmt))
+                                     :isactive true})
+                focus (r/atom nil)]
+            (fn []
+              [update-mutation-template
+               "Mutation Update Form"
+               update-data
+               focus
+               #(update-form-onclick update-data focus)]))))))
+
 (defn click-update[id]
   (secretary/dispatch! (str "/mutations/update/" id)))

@@ -774,8 +832,7 @@
      ^{:key (.-id d)}
      [:option {:value (.-id d)} (.-villagename d)])])

-(def button-tool-bar (r/adapt-react-class (aget js/ReactBootstrap "ButtonToolbar")))
-(def button (r/adapt-react-class (aget js/ReactBootstrap "Button")))
+

 (defn render-mutations [mutations]
   [:div


order matters for the form upload

order matters for the form upload

--- src/pc/views/admin.clj
+++ src/pc/views/admin.clj
@@ -458,19 +458,22 @@
              :method "post"
              :enctype "multipart/form-data"
              :onSubmit (format "this.submit(); event.preventDefault(); window.setTimeout(function () { window.location.assign('https://%s.storage.googleapis.com/' + document.getElementById('key').value)}, 10)"
-                               bucket)}
-      [:p "Upload file:"]
-      [:p [:input {:name "file" :type "file"}]]
+                               bucket)
+             }
       [:p "Choose path (careful not to override an existing path):"]
       [:p
        (format "https://%s.storage.googleapis.com/" bucket)
        [:input {:type "text"
                 :name "key"
                 :id "key"
-                :value ""}]]
+                :value ""
+                :style "width: 500px"}]]
       [:input {:type "hidden" :name "bucket" :value bucket}]
       [:input {:type "hidden" :name "GoogleAccessId" :value pc.gcs/access-id}]
       [:input {:type "hidden" :name "acl" :value acl}]
       [:input {:type "hidden" :name "policy" :value policy}]
       [:input {:type "hidden" :name "signature" :value (pc.gcs/sign policy)}]
+      ;; must be last (!)
+      [:p "Upload file:"]
+      [:p [:input {:name "file" :type "file"}]]
       [:input {:type "submit" :value "Upload"}]])))


Removing skip-aot setting as it didn't fix the original problem it was added for.

--- search-app/project.clj
+++ search-app/project.clj
@@ -34,10 +34,7 @@
          :injections [(require 'pjstadig.humane-test-output)
                       (pjstadig.humane-test-output/activate!)]}
    :uberjar {:aot :all}}
-  ;; Skip AOT to prevent double-compilation during uberjar phase,
-  ;; avoiding errors when loading code that uses protocol functions at
-  ;; load time.
-  :main ^:skip-aot cmr.search.runner
+  :main cmr.search.runner

   :aliases {"generate-docs" ["exec" "-p" "./support/generate_docs.clj"]
             ;; Prints out documentation on configuration environment variables.


variable

variable

--- src/lights/my_show.clj
+++ src/lights/my_show.clj
@@ -14,6 +14,7 @@
             [afterglow.effects.movement :as move]
             [afterglow.effects.oscillators :as oscillators]
             [afterglow.effects.params :as params]
+            [afterglow.effects.show-variable :as var-fx]
             [afterglow.fixtures.blizzard :as blizzard]
             [afterglow.rhythm :as rhythm]
             [afterglow.show :as show]
@@ -26,6 +27,9 @@
   my-show
   (atom nil))

+(defonce ^{:doc "Allows effects to set variables in the running show."}
+  var-binder
+  (atom nil))

 ; 2DO: understand how to pack dimmer and strobe into 1 function definition
 (defn simple-rgbd
@@ -433,6 +437,20 @@
         (afterglow.effects.color/color-effect
           "Plain Blue" (create-color "blue") (show/fixtures-named "back-even"))
     ))))
+
+  (ct/set-cue! (:cue-grid *show*) 0 18
+    (cues/cue :color (fn [_](afterglow.effects/scene
+      "Hue 0"
+        (fn [_] (var-fx/variable-effect @var-binder :main-hue 0))
+      )
+    )))
+  (ct/set-cue! (:cue-grid *show*) 1 18
+    (cues/cue :color (fn [_](afterglow.effects/scene
+      "Hue 120"
+        (set-hue 120)
+        (fn [_] (var-fx/variable-effect @var-binder :main-hue 120))
+      )
+    )))
 )

 (defn make-cues


reset beat func

reset beat func

--- src/lights/my_show.clj
+++ src/lights/my_show.clj
@@ -179,6 +179,14 @@
   (show/sync-to-external-clock
     (afterglow.midi/sync-to-midi-clock "Network midi-net"))
   )
+
+(defn reset-beat
+  "Reset beat of the show"
+  []
+  (:rhythm/metro-start (:metronome my-show) 1)
+  (:rhythm/metro-bar-start (:metronome my-show) 1)
+  (:rhythm/metro-phase-start (:metronome my-show) 1)
+)

 (fiat-lux)


indent via parinfer

indent via parinfer

--- src/om_next_datascript_localisation_demo/datascript/db.cljs
+++ src/om_next_datascript_localisation_demo/datascript/db.cljs
@@ -269,12 +269,12 @@

 (defn read-localised-string
   [db query]
-    (let [string-id (first query)
-          eid (string-id->eid db string-id)
-          query (rest query)
-          query (if (not-empty query) query '[*])]
-      (when eid
-        (db-pull db eid query))))
+  (let [string-id (first query)
+        eid (string-id->eid db string-id)
+        query (rest query)
+        query (if (not-empty query) query '[*])]
+    (when eid
+      (db-pull db eid query))))

 ;; dates


update sasuga

update sasuga

--- src/panpan/sasuga.clj
+++ src/panpan/sasuga.clj
@@ -14,7 +14,7 @@
 (defn sasuga-handler
   [{:keys [user] :as arg}]
   (jh/regexp arg
-    #"^s$"
+    #"^sasuga"
     (fn [& _]
       (let [i (get-sasuga-count)]
         (jb/set SASUGA_KEY (inc i))
@@ -24,5 +24,6 @@
   (js/schedules
     "0 0 9 * * * *"
     (fn [& _]
-      (str "昨日は " (get-sasuga-count) "さすが だったよ")
-      (jb/set SASUGA_KEY 0))))
+      (let [i (get-sasuga-count)]
+        (jb/set SASUGA_KEY 0)
+        (str "昨日は " i "さすが だったよ")))))


Fix handling of reset/length fields

Fix handling of reset/length fields

--- src/protobuf/codec.clj
+++ src/protobuf/codec.clj
@@ -9,22 +9,24 @@

 (declare protobuf-codec)

-(let [len-key :proto_length]
-  (defn length-prefix [proto]
-    (let [proto (protodef proto)
-          min   (alength (protobuf-dump proto {len-key 0}))
-          max   (alength (protobuf-dump proto {len-key Integer/MAX_VALUE}))]
-      (letfn [(check [test msg]
-                (when-not test
-                  (throw (Exception. (format "In %s: %s %s"
-                                             (.getFullName proto) (name len-key) msg)))))]
-        (check (pos? min)
-               "field is required for repeated protobufs")
-        (check (= min max)
-               "must be of type fixed32 or fixed64"))
-      (gloss/compile-frame (gloss/finite-frame max (protobuf-codec proto))
-                           #(hash-map len-key %)
-                           len-key))))
+(def ^{:private true} len-key :proto_length)
+(def ^{:private true} reset-key :codec_reset)
+
+(defn length-prefix [proto]
+  (let [proto (protodef proto)
+        min   (alength (protobuf-dump proto {len-key 0}))
+        max   (alength (protobuf-dump proto {len-key Integer/MAX_VALUE}))]
+    (letfn [(check [test msg]
+              (when-not test
+                (throw (Exception. (format "In %s: %s %s"
+                                           (.getFullName proto) (name len-key) msg)))))]
+      (check (pos? min)
+             "field is required for repeated protobufs")
+      (check (= min max)
+             "must be of type fixed32 or fixed64"))
+    (gloss/compile-frame (gloss/finite-frame max (protobuf-codec proto))
+                         #(hash-map len-key %)
+                         len-key)))

 (defn protobuf-codec [proto & {:keys [validator repeated]}]
   (let [proto (protodef proto)]
@@ -43,5 +45,13 @@
                 val
                 (protobuf proto val))))))
         (fix repeated
-             #(gloss/repeated (gloss/finite-frame (length-prefix proto) %) :prefix :none))
+             #(gloss/compile-frame (gloss/repeated (gloss/finite-frame (length-prefix proto) %)
+                                                   :prefix :none)
+                                   identity
+                                   (partial dissoc len-key)))
+        (gloss/compile-frame identity
+                             (fn [data]
+                               (-> data
+                                   (dissoc reset-key :revisions)
+                                   (with-meta (select-keys data [:revisions])))))
         (with-meta {:schema (protobuf-schema proto)}))))


Add document and refactor komachi.clj

Add document and refactor komachi.clj

--- src/puzzle/komachi.clj
+++ src/puzzle/komachi.clj
@@ -1,10 +1,19 @@
+;; Komachi Mushi Kui Zan (小町虫食い算)
+;;
+;; Finding a triplet of three-digit prime numbers
+;; where the nine digits are composed of 1, 2, 3, 4, 5, 6, 7, 8 and 9
+;; and the sum of the triplets ('JKL' below) is a three-digit number.
+;;
+;;   A B C
+;;   D E F
+;; + G H I
+;; --------
+;;   J K L
+
+
 (ns puzzle.komachi
   (:gen-class)
   (:require [clojure.math.combinatorics :refer [combinations]]))
-
-;; Finding triplet of three-digit prime numbers
-;; where the 9 digits are composed of 1, 2, 3, 4, 5, 6, 7, 8 and 9
-;; and the sum of the triplets is a three-digit number (i.e. 100 <= sum <= 999).

 (def prime-numbers
   "Returns a lazy-seq of prime numbers
@@ -24,7 +33,8 @@
   "Returns true if a list of three natural three-digit numbers
    has numbers from 1 to 9 in their 9 digits"
   [triplet]
-  (= (sort (mapcat #(seq (str %)) triplet)) '(\1 \2 \3 \4 \5 \6 \7 \8 \9)))
+  (= (sort (mapcat #(seq (str %)) triplet))
+     '(\1 \2 \3 \4 \5 \6 \7 \8 \9)))

 (defn three-digit-sum?
   "Returns true if a sum of triplet is a three digit in decimal form"
@@ -32,11 +42,13 @@
   (<= 100 (apply + triplet) 999))

 (def three-digit-prime-numbers
-  (take-while #(< % 1000) (drop-while #(< % 100) prime-numbers)))
+  (take-while #(< % 1000)
+              (drop-while #(< % 100) prime-numbers)))

 (def all-possible-combinations
   (->> (combinations three-digit-prime-numbers 3) ; take triplets
-       (filter #(and (komachi? %) (three-digit-sum? %)))))
+       (filter #(and (komachi? %)
+                     (three-digit-sum? %)))))

 (defn -main
   "Solve the Komachi Mushi Kui Zan puzzle"


Better name for (prevent-scrolling)

Better name for (prevent-scrolling)

--- src/playmary/one.cljs
+++ src/playmary/one.cljs
@@ -17,7 +17,7 @@
              {:light "#A76AB9" :dark "#1E1E1E"}
              {:light "#6DA0CB" :dark "#000000"}])

-(defn prevent-scrolling
+(defn prevent-web-view-scrolling
   []
   (set! (.-ontouchmove js/document) (fn [e] (.preventDefault e))))

@@ -333,7 +333,7 @@
       (step-time delta)
       (inertial-scroll delta)))

-(prevent-scrolling)
+(prevent-web-view-scrolling)
 (set-up-web-audio-on-first-touch)

 (let [canvas-id "canvas"


Allow screen URL parameter segments to be typed

Bidi supports segments like [keyword :foo], [long :bar] and
[uuid :id]. This commit adds support for parsing URL strings
like "/foo/:bar^long/baz" into ["foo" [long :bar] "baz"] segments,
allowing our generated Bidi routes to automatically convert
typed segments to the right data type.

--- src/main/workflo/macros/screen/util.cljc
+++ src/main/workflo/macros/screen/util.cljc
@@ -3,29 +3,48 @@
                :clj  [clojure.spec :as s])
             [clojure.string :as string]))

+(s/def ::typed-url-segment
+  (s/cat :qualifier '#{long keyword uuid}
+         :keyword keyword?))
+
 (s/fdef url-segment
   :args (s/cat :s string?)
   :ret  (s/or :string string?
-              :keyword keyword?)
+              :keyword keyword?
+              :typed ::typed-url-segment)
   :fn   (s/or :string (s/and #(not= \: (-> % :args :s first))
                              #(= :string (-> % :ret first))
                              #(string? (-> % :ret second)))
               :keyword (s/and #(= \: (-> % :args :s first))
                               #(= :keyword (-> % :ret first))
-                              #(keyword? (-> % :ret second)))))
+                              #(keyword? (-> % :ret second)))
+              :typed   (s/and #(= \: (-> % :args :s first))
+                              #(re-find #"\^" (-> % :args :s))
+                              #(= :typed (-> % :ret first))
+                              #(vector? (-> % :ret second))
+                              #(= 2 (count (-> % :ret second)))
+                              #(some #{(-> % :ret second first)}
+                                     '[long keyword uuid])
+                              #(keyword? (-> % :ret second second)))))

 (defn url-segment
   [s]
-  (cond-> s
-    (= \: (first s)) (-> (subs 1) keyword)))
+  (if (= \: (first s))
+    (let [[name type] (string/split (subs s 1) #"\^")]
+      (if type
+        [(symbol type) (keyword name)]
+        (keyword name)))
+    s))

 (s/fdef url-segments
   :args (s/cat :s string?)
   :ret  #?(:cljs (s/and vector?
                         (s/* (s/or :string string?
-                                   :keyword keyword?)))
+                                   :keyword keyword?
+                                   :typed ::typed-url-segment)))
            :clj  (s/coll-of (s/or :string string?
-                                  :keyword keyword?)
+                                  :keyword keyword?
+                                  :typed ::typed-url-segment)
                             :kind vector?)))

 (defn url-segments