<commit_before>(ns gtfve.components.side-panel
  (:require [clojure.string :refer [join]]
            [om.core :as om]
            [sablono.core :as html :refer-macros [html]]
            [gtfve.async :refer [raise!]]
            [gtfve.state :as state]
            [gtfve.utils :as utils]))

(defn side-panel-tab [{:keys [key label tab]} owner]
  (reify
    om/IDisplayName (display-name [_] "Side Panel Tab")
    om/IRender
    (render [_]
      (html [:li {:class (when (= tab key) "active")}
             [:a {:href "#"
                  :onClick (fn [e]
                             (raise! owner [:side-panel-changed {:key key}])
                             (.preventDefault e))} label]]))))

(defn ^:private tab-class [tab key]
  (join " "
        ["tab-pane" "fade" "side"
         (when (= tab key)
           "active in")]))

(defn stop-panel [{:keys [panel data]} owner]
  (reify
    om/IDisplayName (display-name [_] "Side Panel")
    om/IRender
    (render [_]
      (let [tab (:tab panel)
            query (:stops-query panel)]
        (html
         [:div {:className (tab-class tab :stops)}
          [:form.form-horizontal
           {:on-submit #(do
                          (raise! owner [:stops-search-submitted {:query query}])
                          (.preventDefault %))}
           [:fieldset
            [:div.form-group
             [:label.col-sm-2.control-label {:for "inputSearch"} "Stop"]
             [:div.col-sm-10
              [:input.form-control#inputSearch
               {:type "text"
                :placeholder "Search"
                :value query
                :on-change #(utils/edit-input owner :input-stops-search %)}]]]]]
          [:table.table.table-striped.table-hover
           [:thead
            [:tr
             [:th "#"]
             [:th "Code"]
             [:th "Name"]
             [:th "Description"]
             [:th "Lat/Lng"]]]
           [:tbody]]])))))

(defn side-panel [{:keys [panel data]} owner]
  (reify
    om/IDisplayName (display-name [_] "Side Panel")
    om/IRenderState
    (render-state [_ {:keys [active? in?]}]
      (let [tab (:tab panel)]
        (html [:div.side-panel
               [:ul.nav.nav-tabs
                (om/build side-panel-tab {:key :stops
                                          :label "Stops"
                                          :tab tab})
                (om/build side-panel-tab {:key :routes
                                          :label "Routes"
                                          :tab tab})
                (om/build side-panel-tab {:key :trips
                                          :label "Trips"
                                          :tab tab})]
               [:div.tab-content
                ;; stops
                [:div.tab-wrapper
                 (om/build stop-panel {:panel panel :data (:stops data)})
                 ;; routes
                 [:div {:className (tab-class tab :routes)}
                  [:p "Routes panel"]]
                 ;; trips
                 [:div {:className (tab-class tab :trips)}
                  [:p "Trips panel"]]]]])))))
<commit_msg>Use list groups for stops list<commit_after>(ns gtfve.components.side-panel
  (:require [clojure.string :refer [join]]
            [om.core :as om]
            [sablono.core :as html :refer-macros [html]]
            [gtfve.async :refer [raise!]]
            [gtfve.state :as state]
            [gtfve.utils :as utils]))

(defn side-panel-tab [{:keys [key label tab]} owner]
  (reify
    om/IDisplayName (display-name [_] "Side Panel Tab")
    om/IRender
    (render [_]
      (html [:li {:class (when (= tab key) "active")}
             [:a {:href "#"
                  :onClick (fn [e]
                             (raise! owner [:side-panel-changed {:key key}])
                             (.preventDefault e))} label]]))))

(defn ^:private tab-class [tab key]
  (join " "
        ["tab-pane" "fade" "side"
         (when (= tab key)
           "active in")]))

(defn stop-panel [{:keys [panel data]} owner]
  (reify
    om/IDisplayName (display-name [_] "Side Panel")
    om/IRender
    (render [_]
      (let [tab (:tab panel)
            query (:stops-query panel)]
        (html
         [:div {:className (tab-class tab :stops)}
          [:form.form-horizontal
           {:on-submit #(do
                          (raise! owner [:stops-search-submitted {:query query}])
                          (.preventDefault %))}
           [:fieldset
            [:div.form-group
             [:label.col-sm-2.control-label {:for "inputSearch"} "Stop"]
             [:div.col-sm-10
              [:input.form-control#inputSearch
               {:type "text"
                :placeholder "Search"
                :value query
                :on-change #(utils/edit-input owner :input-stops-search %)}]]]]]
          (into [:div.list-group]
                (map (fn [stop]
                       [:a.list-group-item {:key (:db/id stop)
                                            :href "#"}
                        [:h5.list-group-item-heading (:stop/name stop)]
                        [:p.list-group-item-text (str (:stop/latitude stop)
                                                      "/"
                                                      (:stop/longitude stop))]])
                     data))
          ])))))

(defn side-panel [{:keys [panel data]} owner]
  (reify
    om/IDisplayName (display-name [_] "Side Panel")
    om/IRenderState
    (render-state [_ {:keys [active? in?]}]
      (let [tab (:tab panel)]
        (html [:div.side-panel
               [:ul.nav.nav-tabs
                (om/build side-panel-tab {:key :stops
                                          :label "Stops"
                                          :tab tab})
                (om/build side-panel-tab {:key :routes
                                          :label "Routes"
                                          :tab tab})
                (om/build side-panel-tab {:key :trips
                                          :label "Trips"
                                          :tab tab})]
               [:div.tab-content
                ;; stops
                [:div.tab-wrapper
                 (om/build stop-panel {:panel panel :data (:stops data)})
                 ;; routes
                 [:div {:className (tab-class tab :routes)}
                  [:p "Routes panel"]]
                 ;; trips
                 [:div {:className (tab-class tab :trips)}
                  [:p "Trips panel"]]]]])))))

{'fraction_non_alphanumeric': 0.14438830194457203, 'fraction_numerical': 0.0010718113612004287, 'mean_word_length': 1.2008086253369272, 'pattern_counts': {'":': 0, '<': 3, '<?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': 30, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1999314', 'n_tokens_mistral': 1906, 'n_tokens_neox': 1779, 'n_words': 438}