aboutsummaryrefslogtreecommitdiff
path: root/app/views/categories
diff options
context:
space:
mode:
Diffstat (limited to 'app/views/categories')
-rw-r--r--app/views/categories/_category.html.erb17
-rw-r--r--app/views/categories/_edit.html.erb6
-rw-r--r--app/views/categories/_form.html.erb25
-rw-r--r--app/views/categories/edit.html.erb1
-rw-r--r--app/views/categories/show.html.erb2
5 files changed, 51 insertions, 0 deletions
diff --git a/app/views/categories/_category.html.erb b/app/views/categories/_category.html.erb
new file mode 100644
index 0000000..d301fe6
--- /dev/null
+++ b/app/views/categories/_category.html.erb
@@ -0,0 +1,17 @@
+<article class="category" id="category-<%= category.id %>">
+ <header style="background-color: <%= category.color %>">
+ <h1><%= category.taxonomy.name %></h1>
+ <h2><%= category.name %></h2>
+ </header>
+ <p><%= h category.summary %></p>
+ <div class="markdown"><%= h category.description %></div>
+ <section id="stats"><h3>Info</h3>
+ <p><%= pluralize(category.sections_count, 'section') %></p>
+ <p><%= pluralize(category.sections.map { |s| s.resources }.sum(&:count) || 0, 'resources') %></p>
+ </section>
+ <section id="actions">
+ <ul>
+ <li><%= link_to 'edit', edit_category_path(category) %></li>
+ </ul>
+ </section>
+</article>
diff --git a/app/views/categories/_edit.html.erb b/app/views/categories/_edit.html.erb
new file mode 100644
index 0000000..4a2da94
--- /dev/null
+++ b/app/views/categories/_edit.html.erb
@@ -0,0 +1,6 @@
+<h3>Edit <%= @category.presence&.name || 'new category' %></h3>
+<h2>Context: <%= @taxonomy %></h2>
+
+<%= form_with model: [@taxonomy,@category], url: controller.action_name == 'new' ? taxonomy_categories_path(taxonomy: @taxonomy) : category_path(@category) do |f| %>
+ <%= render partial: 'form', locals: { category: category, f: f } %>
+<% end %>
diff --git a/app/views/categories/_form.html.erb b/app/views/categories/_form.html.erb
new file mode 100644
index 0000000..c4c77c6
--- /dev/null
+++ b/app/views/categories/_form.html.erb
@@ -0,0 +1,25 @@
+<fieldset>
+ <%= tag.legend "Categorie..." %>
+
+ <dl>
+ <dt><%= f.label :name %></dt>
+ <dd><%= f.text_field :name, maxlength: 64, placeholder: 'Se loger' %></dd>
+
+ <dt><%= f.label :summary %></dt>
+ <dd><%= f.text_field :summary, maxlength: 136, placeholder: 'Une ferme locale' %></dd>
+
+ <dt><%= f.label :description %></dt>
+ <dd><%= f.text_area :description, cols: 72, rows: 10, placeholder: '## Un choix pertinent
+
+La description _peut_ comporter du [Markdown].
+
+[Markdown]: https://www.markdownguide.org/getting-started/' %></dd>
+
+ <dt><%= f.label :color %></dt>
+ <dd><%= f.color_field :color, placeholder: '#cc0077 (or: rgba(255 0 0 0.5)' %></dd>
+ </dl>
+</fieldset>
+
+<%= f.hidden_field :taxonomy_id, value: @category.taxonomy_id %>
+
+<p><%= f.submit 'Save' %></p>
diff --git a/app/views/categories/edit.html.erb b/app/views/categories/edit.html.erb
new file mode 100644
index 0000000..054bed3
--- /dev/null
+++ b/app/views/categories/edit.html.erb
@@ -0,0 +1 @@
+<%= render partial: 'edit', locals: { category: @category } %>
diff --git a/app/views/categories/show.html.erb b/app/views/categories/show.html.erb
new file mode 100644
index 0000000..ed548c6
--- /dev/null
+++ b/app/views/categories/show.html.erb
@@ -0,0 +1,2 @@
+<%= @category.inspect %>
+<%= render @category %>