<commit_before>(ns r6p3s.cpt.actions-modal
  (:require-macros [cljs.core.async.macros :refer [go]])
  (:require [cljs.core.async :refer [put! chan <!]]
            [om.core :as om :include-macros true]
            [om.dom :as dom :include-macros true]
            [r6p3s.core :as c]
            [r6p3s.cpt.modal :as modal]
            [r6p3s.cpt.actions-modal-button :as actions-modal-button]))


(def app-init modal/app-init)

(defn component [app owner {:keys [chan-open]}]
  (reify
    om/IInitState
    (init-state [_]
      {:actions
       {:label "Пусто"
        :acts  []}})
    om/IWillMount
    (will-mount [this]
      (when chan-open
        (go
          (while true
            (let [actions (<! chan-open)]
              (om/set-state! owner :actions actions)
              (modal/show app))))))
    om/IRenderState
    (render-state [_ {{:keys [label acts]} :actions}]
      (om/build modal/component app
                {:opts {:label      label
                        :modal-size :sm
                        :body       (let [buttons (map
                                                   (fn [opts]
                                                     (om/build actions-modal-button/component
                                                               app {:opts opts}))
                                                   acts)]
                                      (if (empty? buttons)
                                        (dom/h2 nil "Действий нет")
                                        (apply dom/div nil buttons)))
                        }}
                ))))

<commit_msg>Фильтрация nil значений в списке кнопок<commit_after>(ns r6p3s.cpt.actions-modal
  (:require-macros [cljs.core.async.macros :refer [go]])
  (:require [cljs.core.async :refer [put! chan <!]]
            [om.core :as om :include-macros true]
            [om.dom :as dom :include-macros true]
            [r6p3s.core :as c]
            [r6p3s.cpt.modal :as modal]
            [r6p3s.cpt.actions-modal-button :as actions-modal-button]))


(def app-init modal/app-init)

(defn component [app owner {:keys [chan-open]}]
  (reify
    om/IInitState
    (init-state [_]
      {:actions
       {:label "Пусто"
        :acts  []}})
    om/IWillMount
    (will-mount [this]
      (when chan-open
        (go
          (while true
            (let [actions (<! chan-open)]
              (om/set-state! owner :actions actions)
              (modal/show app))))))
    om/IRenderState
    (render-state [_ {{:keys [label acts]} :actions}]
      (om/build modal/component app
                {:opts {:label      label
                        :modal-size :sm
                        :body       (let [buttons (->> acts
                                                       (filterv (comp not nil?))
                                                       (map
                                                        (fn [opts]
                                                          (om/build actions-modal-button/component
                                                                    app {:opts opts}))))]
                                      (if (empty? buttons)
                                        (dom/h2 nil "Действий нет")
                                        (apply dom/div nil buttons)))
                        }}
                ))))
{'fraction_non_alphanumeric': 0.11508646392367322, 'fraction_numerical': 0.005366726296958855, 'mean_word_length': 1.0162259615384615, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 27, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7142637', 'n_tokens_mistral': 905, 'n_tokens_neox': 880, 'n_words': 209}