         :hide (get fielddef "hide") :values (get fielddef "values")} }
     ]
     (swap! fieldnum inc)
+
     newdata
   )
 )

                (dom/div {:className "col-sm-10"}
                  (cond 
                    (= (:fieldtype (nth text 1)  )  0)
                      ;;(dom/input {:type "text" :id (name (first text) ) :onChange #(handle-change %)})
                      (dom/div {:className "col-sm-10"}
                        (b/button-group
                          {:id  (name (first text) ) }
                          (b/dropdown {:title
                          (if
                            (= ( (keyword (nth text 0)) (:leaveapp @app-state)) nil )
                              (:name  (nth text 1))  
                              ( (keyword (nth text 0)) (:leaveapp @app-state))  

                          ) 

                          }
                            (map (fn [item]
                              (b/menu-item {:key (get item "code")
                                :on-select  (fn [e](alertselected1 e (name (first text) )))
                              } (get item "value"))
                              )(:values (nth text 1))
                            )                  
                          )
                        )
                      )
                    
                    (= (:fieldtype (nth text 1)  )  1)
                      (dom/input {:type "text" :id (name (first text) ) :oninput #(handle-change %)})
                    (= (:fieldtype (nth text 1)  )  2)
                      (dom/input {:type "text" :id (name (first text) ) :onChange #(handle-change %)})
                    (= (:fieldtype (nth text 1)  )  3)
                      (dom/input {:type "checkbox"   :id (name (first text)) :label (:name  (nth text 1))
                      ;;:onClick #(handle-chkb-click %)
                      :onChange ( fn [e]( handle-chkb-change  e )   ) 
                      }) 
                  )


                )
              )            
              )

)


(defn setcalculatedfield [field] 
    ;(.log js/console (keyword  (nth field 0) )  )
    ;(.log js/console (get (nth fields 2 ) "fieldcode"    )   )


  ;; leavedays, leavehours - these fields are calculated fields, set initial values to 0
  (if (= (:fieldtype (nth field 1)) 5)
    (if (=   ( (keyword  (nth field 0) ) (:leaveapp @app-state)) nil)
      (swap! app-state assoc-in [:leaveapp (keyword  (nth field 0) )] 
        0
      )    
    )
  )


  ;; boolean fields initialize to TRUE
  (if (= (:fieldtype (nth field 1)) 3)
    (if (=   ( (keyword  (nth field 0) ) (:leaveapp @app-state)) nil)
      (swap! app-state assoc-in [:leaveapp (keyword  (nth field 0) )] 
        1
      ) 
    )
  )
)


(defn setcalculatedfields []
  (let [fields  (:fields ((keyword (:leavecode (:leaveapp @app-state) )) (:leavetypes @app-state) ) ) ]
    ;(.log js/console "Inside  setcalculatedfields" )
    ;(.log js/console (get (nth fields 2 ) "fieldcode"    )   )
    (dorun (map setcalculatedfield fields   ))
  )
)


(defn setdatepicker2 [field]
  (.log js/console (:name (nth field 1)  ) )
