aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/assets/stylesheets/tags.css2
-rw-r--r--app/controllers/tags_controller.rb12
-rw-r--r--app/views/tags/_tag.html.erb1
-rw-r--r--app/views/tags/edit.html.erb9
-rw-r--r--app/views/tags/new.html.erb2
5 files changed, 23 insertions, 3 deletions
diff --git a/app/assets/stylesheets/tags.css b/app/assets/stylesheets/tags.css
index 75dd87d..bcf74cf 100644
--- a/app/assets/stylesheets/tags.css
+++ b/app/assets/stylesheets/tags.css
@@ -3,7 +3,7 @@
vertical-align: middle;
}
-#tag-new h3 span {
+#tag-page h3 span {
font-size: 1rem;
vertical-align: middle;
}
diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb
index 8ae36d7..9d87687 100644
--- a/app/controllers/tags_controller.rb
+++ b/app/controllers/tags_controller.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class TagsController < ApplicationController
- before_action :set_tag, only: %i[destroy]
+ before_action :set_tag, only: %i[edit update destroy]
def index
@tags = Tag.order(:name)
@@ -11,6 +11,8 @@ class TagsController < ApplicationController
@tag = Tag.new
end
+ def edit; end
+
def create
@tag = Tag.new(tag_params)
@@ -21,6 +23,14 @@ class TagsController < ApplicationController
end
end
+ def update
+ if @tag.update(tag_params)
+ redirect_to tags_url, notice: t('tags.update-success')
+ else
+ render :edit, status: :unprocessable_entity
+ end
+ end
+
def destroy
@tag.destroy!
diff --git a/app/views/tags/_tag.html.erb b/app/views/tags/_tag.html.erb
index 65c6d4e..0a82898 100644
--- a/app/views/tags/_tag.html.erb
+++ b/app/views/tags/_tag.html.erb
@@ -3,6 +3,7 @@
<%= tag.name %>
</div>
<div class="action">
+ <%= link_to I18n.t('general.edit'), edit_tag_path(tag) %> |
<%= link_to I18n.t('general.delete'), tag_path(tag), data: { "turbo-method": :delete } %>
</div>
</div>
diff --git a/app/views/tags/edit.html.erb b/app/views/tags/edit.html.erb
new file mode 100644
index 0000000..44214a3
--- /dev/null
+++ b/app/views/tags/edit.html.erb
@@ -0,0 +1,9 @@
+<div class="center-contents">
+ <div></div>
+ <div id="tag-page">
+ <h3><%= I18n.t('tags.update') %> <span>&#8212; <%= link_to I18n.t('general.back-to-list'), tags_path %></span></h3>
+
+ <%= render "form", tag: @tag %>
+ </div>
+ <div></div>
+</div>
diff --git a/app/views/tags/new.html.erb b/app/views/tags/new.html.erb
index 9d6e1a8..97cd410 100644
--- a/app/views/tags/new.html.erb
+++ b/app/views/tags/new.html.erb
@@ -1,6 +1,6 @@
<div class="center-contents">
<div></div>
- <div id="tag-new">
+ <div id="tag-page">
<h3><%= I18n.t('tags.new') %> <span>&#8212; <%= link_to I18n.t('general.back-to-list'), tags_path %></span></h3>
<%= render "form", tag: @tag %>