Created
March 1, 2016 17:40
-
-
Save jbaiter/47438286323f51d4582f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn linking-tool [tags tokens empty_tag] | |
(let [show-suggestions (subscribe [:get :show-suggestions])] | |
(fn [] | |
(log "Called with: " tags) | |
[:div.linking-tool | |
[:table.table>tbody | |
(doall | |
(for [[idx {:keys [tokens tag] :as ent}] | |
(indexed (extract-entities tokens tags empty_tag))] | |
(let [name (string/join " " tokens) | |
query-key (str name "." tag) | |
show-suggs? (get @show-suggestions query-key)] | |
^{:key idx} | |
[:tr | |
[:td name] | |
[:td | |
[:a.button {:on-click #(dispatch [:set [:show-suggestions query-key] (not show-suggs?)])} | |
"Show suggestions"] | |
(when show-suggs? | |
[linking-suggestions query-key])] | |
[:td [:a.icon {:on-click #(dispatch [:query-gnd ent])} | |
[icon :search]]]])))]]))) | |
(defn tagging-panel [] | |
(let [sentence (subscribe [:get :active-sentence]) | |
sentences (subscribe [:get :sentences]) | |
project (subscribe [:active-project]) | |
fetching? (subscribe [:get :loading? :initial-sentences])] | |
(fn [] | |
(let [{:keys [tagset id]} @project | |
{:keys [tags empty_tag]} tagset | |
tag-colors (make-tag-colors tagset)] | |
[:section.hero.is-fullheight.tagging-container | |
[:div.hero-content | |
[:div.container | |
(if @fetching? | |
[:div.loading-spinner] | |
[:div | |
[tagging-info] | |
[tagging-sentence (:tokens @sentence) (:tags @sentence) | |
tag-colors empty_tag] | |
(when (has-entities? (:tags @sentence) empty_tag) | |
(do | |
(log "Calling with: " (:tags @sentence)) | |
[linking-tool (:tags @sentence) (:tokens @sentence) empty_tag]))])] | |
(when-not @fetching? | |
[tagging-toolbar id (not (empty? @sentences))])]])))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment