aboutsummaryrefslogtreecommitdiff
path: root/app/helpers/taxonomies_helper.rb
diff options
context:
space:
mode:
authorhellekin <hellekin@cepheide.org>2020-10-29 22:40:35 +0100
committerhellekin <hellekin@cepheide.org>2020-10-29 22:40:35 +0100
commit3d4f9f2c280f9d85722951fa5850ca00a7e80aac (patch)
tree476e5100981e9507aeb5e41a784705e1c8bb1a0b /app/helpers/taxonomies_helper.rb
parent1cda1e3525b180778fb0ba864d63698941eb7360 (diff)
downloadincommon-map-3d4f9f2c280f9d85722951fa5850ca00a7e80aac.tar.gz
REUSE: Add AGPL-3.0-or-later to app/*
Diffstat (limited to 'app/helpers/taxonomies_helper.rb')
-rw-r--r--app/helpers/taxonomies_helper.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/app/helpers/taxonomies_helper.rb b/app/helpers/taxonomies_helper.rb
new file mode 100644
index 0000000..a584177
--- /dev/null
+++ b/app/helpers/taxonomies_helper.rb
@@ -0,0 +1,23 @@
+# 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 TaxonomiesHelper
+ 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" })
+ end
+ html << tag.li(h("#{cat.rank}. #{cat.name}") << tag.ol(list.join.html_safe),
+ id: "category-#{cat.id}",
+ data: { action: "taxonomy#category" })
+ end
+ raw(tag.nav(tag.ol(html.join.html_safe), id: "taxonomy-#{@taxonomy.uuid}"))
+ end
+end