<commit_before>(ns webapp.framework.client.components.main_view
  (:require
   [webapp.framework.client.coreclient   :as c ])
  (:use-macros
   [webapp.framework.client.coreclient  :only [ns-coils defn-ui-component def-coils-app
                                               container  map-many  inline  text log sql
                                               div img pre component h2 input section header button label form
                                               write-ui read-ui container input component <-- data-view-result-set
                                               h1 h2 h3 h4 h5 h6 span  data-view-v2 select dselect realtime drealtime
                                               input-field
                                               ]])
  (:require-macros
   [cljs.core.async.macros :refer [go alt!]]))
(ns-coils 'webapp.framework.client.components.main_view)









(defn-ui-component     main-to-do-component   [app]
  {}

  (section {:className "todoapp"}

           (header {} (h2 nil "Todo app"))


           (div {:className "main_div"}


                (input-field {}
                 app
                 (fn [new-value]
                   (go
                    (sql "insert into  coils_todo_items   (item, item_status) values (?,?)"
                        [new-value  "ACTIVE"]  ))))


                (div {:className "smallGap"})

                (div {:className "todo-list"}
                     (realtime select
                               id, item, item_status
                               from
                               coils_todo_items
                               where
                               item_status = ?
                               OR
                               item_status = ?
                               order
                               by id desc

                               {:params [(if (read-ui app [:show]) (read-ui app [:show]) "ACTIVE")
                                         (if (read-ui app [:show]) (read-ui app [:show]) "COMPLETED")
                                         ]}
                               (form {}
                                     (div {:className "view" }

                                          (div {:className  "checkbox"  :style { :width "20%" :display "inline-block;"} }
                                               (input {:type  "checkbox"
                                                       :checked   (if (= (<-- :item_status) "COMPLETED") "T" "")
                                                       :onChange  (fn [event]
                                                                    (let [newtext   (.. event -target -checked  )
                                                                          item-id   (<-- :id)]
                                                                      (if newtext
                                                                        (go (sql "update  coils_todo_items   set item_status = 'COMPLETED' where id = ?" [item-id]  ))
                                                                        (go (sql "update  coils_todo_items   set item_status = 'ACTIVE' where id = ?" [item-id]  ))
                                                                        )))}))

                                          (label {:style {:width   "50%"} :className (if (= (<-- :item_status) "COMPLETED") "completed" "item")} (str (<-- :item)))
                                          (button {:className   "destroy"
                                                   :style {:width   "10%"}
                                                   :onClick
                                                   (fn [e]
                                                     (go
                                                       (sql "delete from  coils_todo_items  where id = ?"
                                                            [(<-- :id)]  )))})
                                          ))))





                (div {:className "mediumGap"})




                (let [active-items      (select id from  coils_todo_items where item_status = 'ACTIVE' {})
                      total-items       (select id from  coils_todo_items {})
                      completed-items   (select id from  coils_todo_items where item_status = 'COMPLETED' {})
                      ]

                  (if (pos? (count total-items))
                    (do
                      (div {:style {:height "30px"}})
                      (div {:id "footer" :style {:backgroundColor "white" :fontSize "12"}}
                           (container
                            (div {:style {:width "27%" :display "inline-block;" :textAlign "left"}
                                  }  (str (count active-items) " items left"))

                            (button {:style {:width "9%" :border (str (if (nil? (read-ui app [:show])) "1px solid"))}
                                     :onClick #(write-ui app [:show] nil)
                                    } "ALL")

                            (button {:style {:width "13%" :border (str (if (= "ACTIVE" (read-ui app [:show])) "1px solid"))}
                                     :onClick #(write-ui app [:show] "ACTIVE")
                                    } "Active")

                            (button {:style {:width "17%" :border (str (if (= "COMPLETED" (read-ui app [:show])) "1px solid"))}
                                     :onClick #(write-ui app [:show] "COMPLETED")
                                    } "Completed")

                            (if (pos? (count completed-items))
                              (button {:style {  :width "34%" :textAlign "right"}
                                       :onClick #(go
                                                   (sql "delete from  coils_todo_items  where item_status = 'COMPLETED'" []  ))
                                                   } "Clear completed"))

                            ))))))))


(def-coils-app     main-view   main-to-do-component)
<commit_msg>Do not refresh page if buttons clicked in demo<commit_after>(ns webapp.framework.client.components.main_view
  (:require
   [webapp.framework.client.coreclient   :as c ])
  (:use-macros
   [webapp.framework.client.coreclient  :only [ns-coils defn-ui-component def-coils-app
                                               container  map-many  inline  text log sql
                                               div img pre component h2 input section header button label form
                                               write-ui read-ui container input component <-- data-view-result-set
                                               h1 h2 h3 h4 h5 h6 span  data-view-v2 select dselect realtime drealtime
                                               input-field
                                               ]])
  (:require-macros
   [cljs.core.async.macros :refer [go alt!]]))
(ns-coils 'webapp.framework.client.components.main_view)









(defn-ui-component     main-to-do-component   [app]
  {}

  (section {:className "todoapp"}

           (header {} (h2 nil "Todo app"))


           (div {:className "main_div"}


                (input-field {}
                 app
                 (fn [new-value]
                   (go
                    (sql "insert into  coils_todo_items   (item, item_status) values (?,?)"
                        [new-value  "ACTIVE"]  ))))


                (div {:className "smallGap"})

                (div {:className "todo-list"}
                     (realtime select
                               id, item, item_status
                               from
                               coils_todo_items
                               where
                               item_status = ?
                               OR
                               item_status = ?
                               order
                               by id desc

                               {:params [(if (read-ui app [:show]) (read-ui app [:show]) "ACTIVE")
                                         (if (read-ui app [:show]) (read-ui app [:show]) "COMPLETED")
                                         ]}
                               (form {}
                                     (div {:className "view" }

                                          (div {:className  "checkbox"  :style { :width "20%" :display "inline-block;"} }
                                               (input {:type  "checkbox"
                                                       :checked   (if (= (<-- :item_status) "COMPLETED") "T" "")
                                                       :onChange  (fn [event]
                                                                    (let [newtext   (.. event -target -checked  )
                                                                          item-id   (<-- :id)]
                                                                      (if newtext
                                                                        (go (sql "update  coils_todo_items   set item_status = 'COMPLETED' where id = ?" [item-id]  ))
                                                                        (go (sql "update  coils_todo_items   set item_status = 'ACTIVE' where id = ?" [item-id]  ))
                                                                        )))}))

                                          (label {:style {:width   "50%"} :className (if (= (<-- :item_status) "COMPLETED") "completed" "item")} (str (<-- :item)))
                                          (button {:className   "destroy"
                                                   :style {:width   "10%"}
                                                   :onClick
                                                   (fn [e]
                                                     (go
                                                       (sql "delete from  coils_todo_items  where id = ?"
                                                            [(<-- :id)]  ))
                                                     false)})
                                          ))))





                (div {:className "mediumGap"})




                (let [active-items      (select id from  coils_todo_items where item_status = 'ACTIVE' {})
                      total-items       (select id from  coils_todo_items {})
                      completed-items   (select id from  coils_todo_items where item_status = 'COMPLETED' {})
                      ]

                  (if (pos? (count total-items))
                    (do
                      (div {:style {:height "30px"}})
                      (div {:id "footer" :style {:backgroundColor "white" :fontSize "12"}}
                           (container
                            (div {:style {:width "27%" :display "inline-block;" :textAlign "left"}
                                  }  (str (count active-items) " items left"))

                            (button {:style {:width "9%" :border (str (if (nil? (read-ui app [:show])) "1px solid"))}
                                     :onClick #(do (write-ui app [:show] nil) false)
                                    } "ALL")

                            (button {:style {:width "13%" :border (str (if (= "ACTIVE" (read-ui app [:show])) "1px solid"))}
                                     :onClick #(do (write-ui app [:show] "ACTIVE") false)
                                    } "Active")

                            (button {:style {:width "17%" :border (str (if (= "COMPLETED" (read-ui app [:show])) "1px solid"))}
                                     :onClick #(do (write-ui app [:show] "COMPLETED") false)
                                    } "Completed")

                            (if (pos? (count completed-items))
                              (button {:style {  :width "34%" :textAlign "right"}
                                       :onClick #(do (go
                                                   (sql "delete from  coils_todo_items  where item_status = 'COMPLETED'" []  )) false)
                                                   } "Clear completed"))

                            ))))))))


(def-coils-app     main-view   main-to-do-component)

{'fraction_non_alphanumeric': 0.10299381711682395, 'fraction_numerical': 0.005043931012040351, 'mean_word_length': 0.7803041274438812, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 152, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2555593', 'n_tokens_mistral': 2778, 'n_tokens_neox': 2590, 'n_words': 695}