Skip to content

Commit

Permalink
Only show the dictionary tabs when the language is German
Browse files Browse the repository at this point in the history
  • Loading branch information
egli committed Oct 1, 2024
1 parent dd809e1 commit 9c8367e
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions src/cljs/daisyproducer2/documents/document.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
(fn [db _]
(-> db :current-document)))

(rf/reg-sub
::current-is-german
:<- [::current]
(fn [current] (#{"de" "de-1901"} (-> current :language))))

(rf/reg-event-db
::set-current
(fn [db [_ document]]
Expand Down Expand Up @@ -59,18 +64,20 @@
[:li [:a {:href uri :on-click on-click} title]]))

(defn tabs [{:keys [id]}]
[:div.block
[:div.tabs.is-boxed
[:ul
[tab-link (str "#/documents/" id) (tr [:details]) :document]
[tab-link-with-total (str "#/documents/" id "/unknown") (tr [:unknown-words]) :document-unknown
(fn [_] (rf/dispatch [::unknown/fetch-words id]) (rf/dispatch [::unknown/fetch-words-total id]))]
[tab-link (str "#/documents/" id "/local") (tr [:local-words]) :document-local (fn [_] (rf/dispatch [::local/fetch-words id]))]
[tab-link (str "#/documents/" id "/versions") (tr [:versions]) :document-versions (fn [_] (rf/dispatch [::version/fetch-versions id]))]
[tab-link (str "#/documents/" id "/images") (tr [:images]) :document-images (fn [_] (rf/dispatch [::image/fetch-images id]))]
[tab-link (str "#/documents/" id "/markup") (tr [:markup]) :document-markup (fn [_] (rf/dispatch [::markup/fetch-latest-version id]))]
[tab-link (str "#/documents/" id "/preview") (tr [:preview]) :document-preview]
]]])
(let [german? @(rf/subscribe [::current-is-german])]
[:div.block
[:div.tabs.is-boxed
[:ul
[tab-link (str "#/documents/" id) (tr [:details]) :document]
(when german?
[tab-link-with-total (str "#/documents/" id "/unknown") (tr [:unknown-words]) :document-unknown
(fn [_] (rf/dispatch [::unknown/fetch-words id]) (rf/dispatch [::unknown/fetch-words-total id]))]
[tab-link (str "#/documents/" id "/local") (tr [:local-words]) :document-local (fn [_] (rf/dispatch [::local/fetch-words id]))])
[tab-link (str "#/documents/" id "/versions") (tr [:versions]) :document-versions (fn [_] (rf/dispatch [::version/fetch-versions id]))]
[tab-link (str "#/documents/" id "/images") (tr [:images]) :document-images (fn [_] (rf/dispatch [::image/fetch-images id]))]
[tab-link (str "#/documents/" id "/markup") (tr [:markup]) :document-markup (fn [_] (rf/dispatch [::markup/fetch-latest-version id]))]
[tab-link (str "#/documents/" id "/preview") (tr [:preview]) :document-preview]
]]]))

(defn summary [{:keys [title author source-publisher state] :as document}]
[:div.columns
Expand Down

0 comments on commit 9c8367e

Please sign in to comment.