aboutsummaryrefslogtreecommitdiff
path: root/app/helpers/taxonomies
diff options
context:
space:
mode:
authorhellekin <hellekin@cepheide.org>2020-11-12 23:39:13 +0100
committerhellekin <hellekin@cepheide.org>2020-11-12 23:39:13 +0100
commit6c9922a87fb72b958b78014c45b6cd1efafdd30e (patch)
treec58addb0b39bafe5bc8aceebe659bb2cc86f3851 /app/helpers/taxonomies
parent8d9387cf64929b6467b6ba52f22ca0aa5ed35782 (diff)
downloadincommon-map-6c9922a87fb72b958b78014c45b6cd1efafdd30e.tar.gz
Add Stimulus Map and Taxonomy (WIP)
This commit add StimulusJS interaction for the map and taxonomy, as well as styling. It provides preliminary work to hook up live data on the map from the taxonomy.
Diffstat (limited to 'app/helpers/taxonomies')
-rw-r--r--app/helpers/taxonomies/filter_helper.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/app/helpers/taxonomies/filter_helper.rb b/app/helpers/taxonomies/filter_helper.rb
new file mode 100644
index 0000000..97fe271
--- /dev/null
+++ b/app/helpers/taxonomies/filter_helper.rb
@@ -0,0 +1,22 @@
+# SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc>
+#
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
+# coding: utf-8
+# frozen_string_literal: true
+module Taxonomies::FilterHelper
+ def taxonomy_filter
+ @taxonomy ||= Taxonomy.first
+ html = []
+ @taxonomy.categories.each do |cat|
+ list = []
+ cat.sections.each do |sec|
+ list << tag.li(h("#{sec.rank}. #{sec.name}"), id: "section-#{sec.id}", data: { action: "taxonomy#section", target: 'taxonomy.section', 'taxonomy-section-id': sec.id })
+ end
+ html << tag.li(h("#{cat.rank}. #{cat.name}") << tag.ol(list.join.html_safe),
+ id: "category-#{cat.id}",
+ data: { action: "click->taxonomy#category", target: 'taxonomy.category', 'taxonomy-category-id': cat.id })
+ end
+ raw(tag.nav(tag.ol(html.join.html_safe), id: "taxonomy-#{@taxonomy.uuid}"))
+ end
+end