From b54a8458d5029b3494165b7430e21b3ae34ecc0c Mon Sep 17 00:00:00 2001 From: hellekin Date: Fri, 22 Jan 2021 05:32:15 +0100 Subject: Upgrade Rails and add StimulusJS support --- app/views/categories/_category.html.erb | 17 +++++++++++++++++ app/views/categories/_edit.html.erb | 6 ++++++ app/views/categories/_form.html.erb | 25 +++++++++++++++++++++++++ app/views/categories/edit.html.erb | 1 + app/views/categories/show.html.erb | 2 ++ 5 files changed, 51 insertions(+) create mode 100644 app/views/categories/_category.html.erb create mode 100644 app/views/categories/_edit.html.erb create mode 100644 app/views/categories/_form.html.erb create mode 100644 app/views/categories/edit.html.erb create mode 100644 app/views/categories/show.html.erb (limited to 'app/views/categories') 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 @@ +
+
+

<%= category.taxonomy.name %>

+

<%= category.name %>

+
+

<%= h category.summary %>

+
<%= h category.description %>
+

Info

+

<%= pluralize(category.sections_count, 'section') %>

+

<%= pluralize(category.sections.map { |s| s.resources }.sum(&:count) || 0, 'resources') %>

+
+
+
    +
  • <%= link_to 'edit', edit_category_path(category) %>
  • +
+
+
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 @@ +

Edit <%= @category.presence&.name || 'new category' %>

+

Context: <%= @taxonomy %>

+ +<%= 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 @@ +
+ <%= tag.legend "Categorie..." %> + +
+
<%= f.label :name %>
+
<%= f.text_field :name, maxlength: 64, placeholder: 'Se loger' %>
+ +
<%= f.label :summary %>
+
<%= f.text_field :summary, maxlength: 136, placeholder: 'Une ferme locale' %>
+ +
<%= f.label :description %>
+
<%= 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/' %>
+ +
<%= f.label :color %>
+
<%= f.color_field :color, placeholder: '#cc0077 (or: rgba(255 0 0 0.5)' %>
+
+
+ +<%= f.hidden_field :taxonomy_id, value: @category.taxonomy_id %> + +

<%= f.submit 'Save' %>

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 %> -- cgit v1.2.3