<commit_before>(ns kixi.hecuba.tabs.hierarchy.properties
  (:require-macros [cljs.core.async.macros :refer [go go-loop]])
  (:require
   [om.core :as om :include-macros true]
   [cljs.core.async :refer [<! >! chan put!]]
   [clojure.string :as str]
   [kixi.hecuba.history :as history]
   [kixi.hecuba.tabs.hierarchy.data :refer (fetch-properties)]
   [kixi.hecuba.tabs.slugs :as slugs]
   [kixi.hecuba.bootstrap  :as bs]
   [kixi.hecuba.common :refer (log) :as common]
   [kixi.hecuba.widgets.fileupload :as file]
   [sablono.core :as html :refer-macros [html]]))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; properties

(defn error-handler [data]
  (fn [{:keys [status status-text]}]
    (om/update! data [:properties :alert] {:status true
                                           :class "alert alert-danger"
                                           :text status-text})))
(defn valid-property? [property]
  (not (nil? (:property_code property)))) ;; project_id comes from the selection above

(defn post-new-property [data owner property project_id]
  (common/post-resource data  "/4/entities/"
                        property
                        (fn [_]
                          (fetch-properties project_id data)
                          (om/update! data [:properties :adding-property] false))
                        (error-handler data)))

(defn property-add-form [data project_id]
  (fn [cursor owner]
    (om/component

     (html
      [:div
       [:h3 "Add new property"]
       [:form.form-horizontal {:role "form"}<commit_msg>Resurrected entity upload form.<commit_after>(ns kixi.hecuba.tabs.hierarchy.properties
  (:require-macros [cljs.core.async.macros :refer [go go-loop]])
  (:require
   [om.core :as om :include-macros true]
   [cljs.core.async :refer [<! >! chan put!]]
   [clojure.string :as str]
   [kixi.hecuba.history :as history]
   [kixi.hecuba.tabs.hierarchy.data :refer (fetch-properties)]
   [kixi.hecuba.tabs.slugs :as slugs]
   [kixi.hecuba.bootstrap  :as bs]
   [kixi.hecuba.common :refer (log) :as common]
   [kixi.hecuba.widgets.fileupload :as file]
   [sablono.core :as html :refer-macros [html]]))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; properties

(defn error-handler [data]
  (fn [{:keys [status status-text]}]
    (om/update! data [:properties :alert] {:status true
                                           :class "alert alert-danger"
                                           :text status-text})))
(defn valid-property? [property]
  (not (nil? (:property_code property)))) ;; project_id comes from the selection above

(defn post-new-property [data owner property project_id]
  (common/post-resource data  "/4/entities/"
                        property
                        (fn [_]
                          (fetch-properties project_id data)
                          (om/update! data [:properties :adding-property] false))
                        (error-handler data)))

(defn property-add-form [data project_id]
  (fn [cursor owner]
    (om/component

     (html
      [:div
       [:div
        [:h3 "Upload Properties"]
        (let [div-id "properties-upload-form"]
          (om/build (file/file-upload (str "/4/projects/" project_id "/entities/")
                                      div-id)
                    nil {:opts {:method "POST"}}))]
       [:h3 "Add new property"]
       [:form.form-horizontal {:role "form"}
{'fraction_non_alphanumeric': 0.17289313640312773, 'fraction_numerical': 0.0017376194613379669, 'mean_word_length': 2.258490566037736, 'pattern_counts': {'":': 0, '<': 5, '<?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': 9, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3429419', 'n_tokens_mistral': 1149, 'n_tokens_neox': 1084, 'n_words': 250}