From b33d00f622ab7f6c67b1682ecb842d007f537abf Mon Sep 17 00:00:00 2001 From: motohiro-mm Date: Sun, 13 Oct 2024 12:13:10 +0900 Subject: [PATCH 1/5] =?UTF-8?q?flash=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB?= =?UTF-8?q?=E3=82=92=E4=BD=9C=E6=88=90=E3=80=81body=E3=81=AE=E4=B8=8A?= =?UTF-8?q?=E9=83=A8=E3=81=AB=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/_flash.html.erb | 8 ++++++++ app/views/layouts/application.html.erb | 3 +++ 2 files changed, 11 insertions(+) create mode 100644 app/views/layouts/_flash.html.erb diff --git a/app/views/layouts/_flash.html.erb b/app/views/layouts/_flash.html.erb new file mode 100644 index 0000000..03e73c2 --- /dev/null +++ b/app/views/layouts/_flash.html.erb @@ -0,0 +1,8 @@ +<% flash.each do |flash_type, message| %> +
+ + + + <%= message %> +
+<% end %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 2a7680d..b3df094 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -22,6 +22,9 @@ <% unless current_page?(root_path) %> <%= render 'shared/header' %> <% end %> +
+ <%= render "layouts/flash" %> +
<%= yield %>
From b63390d78b8543d080b5201739d386e3a5cbee31 Mon Sep 17 00:00:00 2001 From: motohiro-mm Date: Sun, 13 Oct 2024 12:14:09 +0900 Subject: [PATCH 2/5] =?UTF-8?q?remark=E3=81=AEflash=E3=83=A1=E3=83=83?= =?UTF-8?q?=E3=82=BB=E3=83=BC=E3=82=B8=E3=81=8C=E8=A1=A8=E7=A4=BA=E3=81=95?= =?UTF-8?q?=E3=82=8C=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E8=A8=AD=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/meal_plans_controller.rb | 4 ++-- app/controllers/remarks_controller.rb | 14 +++++------ app/views/meal_plans/_header_button.html.erb | 11 +++++++++ app/views/meal_plans/_meal_plan.html.erb | 25 ++++++++------------ app/views/meal_plans/edit.html.erb | 18 +++++++------- app/views/meal_plans/new.html.erb | 7 +----- app/views/meal_plans/show.html.erb | 15 ++++-------- app/views/remarks/create.turbo_stream.erb | 1 + app/views/remarks/destroy.turbo_stream.erb | 1 + app/views/remarks/update.turbo_stream.erb | 7 ++++++ 10 files changed, 53 insertions(+), 50 deletions(-) create mode 100644 app/views/meal_plans/_header_button.html.erb create mode 100644 app/views/remarks/update.turbo_stream.erb diff --git a/app/controllers/meal_plans_controller.rb b/app/controllers/meal_plans_controller.rb index 3538f44..98ea1a9 100644 --- a/app/controllers/meal_plans_controller.rb +++ b/app/controllers/meal_plans_controller.rb @@ -32,7 +32,7 @@ def create def update if @meal_plan.update_meal_plan(meal_plan_params) - redirect_to @meal_plan + redirect_to @meal_plan, notice: '更新しました' else @meal_plan.meals_build render :edit, status: :unprocessable_entity @@ -41,7 +41,7 @@ def update def destroy @meal_plan.meals.each(&:destroy!) - redirect_to meal_plans_path(meal_date: @meal_plan.meal_date), status: :see_other + redirect_to meal_plans_path(meal_date: @meal_plan.meal_date), notice: '削除しました', status: :see_other end def calendar diff --git a/app/controllers/remarks_controller.rb b/app/controllers/remarks_controller.rb index 4362927..4529ba9 100644 --- a/app/controllers/remarks_controller.rb +++ b/app/controllers/remarks_controller.rb @@ -13,9 +13,8 @@ def create @remark = current_user.remarks.build(remark_params) if @remark.save respond_to do |format| - format.html { redirect_to meeting_room_path(@meeting_room), notice: 'Date was successfully created.' } - # format.turbo_stream { flash.now[:notice] = "Date was successfully created." } - format.turbo_stream + format.html { redirect_to meeting_room_path(@meeting_room), notice: "投稿しました!" } + format.turbo_stream { flash.now[:notice] = "投稿しました!" } end else render :new, status: :unprocessable_entity @@ -25,8 +24,8 @@ def create def update if @remark.update(remark_params) respond_to do |format| - format.html { redirect_to meeting_room_path(@meeting_room), notice: 'Item was successfully updated.' } - # format.turbo_stream { flash.now[:notice] = "Item was successfully updated." } + format.html { redirect_to meeting_room_path(@meeting_room), notice: '更新しました!' } + format.turbo_stream { flash.now[:notice] = "更新しました!" } end else render :edit, status: :unprocessable_entity @@ -37,9 +36,8 @@ def destroy @remark.destroy! respond_to do |format| - format.html { redirect_to meeting_room_path(@meeting_room), notice: 'Item was successfully destroyed.', status: :see_other } - # format.turbo_stream { flash.now[:notice] = "Date was successfully destroyed." } - format.turbo_stream + format.html { redirect_to meeting_room_path(@meeting_room), notice: '削除しました!', status: :see_other } + format.turbo_stream { flash.now[:notice] = "削除しました!" } end end diff --git a/app/views/meal_plans/_header_button.html.erb b/app/views/meal_plans/_header_button.html.erb new file mode 100644 index 0000000..0b275fd --- /dev/null +++ b/app/views/meal_plans/_header_button.html.erb @@ -0,0 +1,11 @@ +
+ <%= button_to meeting_rooms_path(meal_plan: , meal_date: meal_plan.meal_date), method: :post, class: 'rounded-full py-3 px-4 bg-red-400 inline-block' do %> + + 会議へ + <% end %> + <%= link_to meal_plans_path(start_date: meal_plan.meal_date), + class: 'inline-block flex items-center' do %> + + 献立表へ + <% end %> +
diff --git a/app/views/meal_plans/_meal_plan.html.erb b/app/views/meal_plans/_meal_plan.html.erb index fa5143d..5d7d903 100644 --- a/app/views/meal_plans/_meal_plan.html.erb +++ b/app/views/meal_plans/_meal_plan.html.erb @@ -1,18 +1,13 @@ -<%= turbo_frame_tag meal_plan, autoscroll: true, data: { autoscroll_block: 'start' } do %> -
-
-

<%= l meal_plan.meal_date, format: :long %>

- <% if meal_plan.meals.present? %> -
- <%= link_to '編集', edit_meal_plan_path(meal_plan), class: 'text-l inline-block rounded-full py-2 px-4 flex items-center bg-orange-100/80' %> -
- <% end %> -
- <% meal_plan.meals_sort_by_timing.each do |meal| %> - <%= render 'meals/meal', meal: %> +
+
+

<%= l meal_plan.meal_date, format: :long %>

+ <% if meal_plan.meals.present? %> +
+ <%= link_to '編集', edit_meal_plan_path(meal_plan), class: 'text-l inline-block rounded-full py-2 px-4 flex items-center bg-orange-100/80' %> +
<% end %>
-<% end %> -
- <%= button_to 'この献立を削除する', meal_plan, method: :delete, class: 'text-orange-950/70' %> + <% meal_plan.meals_sort_by_timing.each do |meal| %> + <%= render 'meals/meal', meal: %> + <% end %>
diff --git a/app/views/meal_plans/edit.html.erb b/app/views/meal_plans/edit.html.erb index 3c26687..5b2a8ff 100644 --- a/app/views/meal_plans/edit.html.erb +++ b/app/views/meal_plans/edit.html.erb @@ -1,10 +1,12 @@
- <%= turbo_frame_tag @meal_plan do %> -
- <%= render 'form', meal_plan: @meal_plan %> -
-
- <%= link_to 'キャンセル', @meal_plan, class: 'rounded-full py-3 px-4 text-red-9500/50 bg-stone-100 inline-block' %> -
- <% end %> + <%= render 'header_button', meal_plan: @meal_plan %> +
+ <%= render 'form', meal_plan: @meal_plan %> +
+
+ <%= link_to 'キャンセル', @meal_plan, class: 'rounded-full py-3 px-4 text-red-9500/50 bg-stone-100 inline-block' %> +
+
+ <%= button_to 'この献立を削除する', @meal_plan, method: :delete, class: 'text-orange-950/70' %> +
diff --git a/app/views/meal_plans/new.html.erb b/app/views/meal_plans/new.html.erb index d556067..306db83 100644 --- a/app/views/meal_plans/new.html.erb +++ b/app/views/meal_plans/new.html.erb @@ -1,10 +1,5 @@
-
- <%= link_to meal_plans_path(start_date: @meal_plan.meal_date), class: 'inline-block flex items-center mr-4' do %> - - 献立表へ - <% end %> -
+ <%= render 'header_button', meal_plan: @meal_plan %>
<%= render 'form', meal_plan: @meal_plan %>
diff --git a/app/views/meal_plans/show.html.erb b/app/views/meal_plans/show.html.erb index 028b84a..24c80a8 100644 --- a/app/views/meal_plans/show.html.erb +++ b/app/views/meal_plans/show.html.erb @@ -1,16 +1,9 @@
-
- <%= button_to meeting_rooms_path(meal_plan: @meal_plan, meal_date: @meal_plan.meal_date), method: :post, data: { turbo_frame: '_top' }, class: 'rounded-full py-3 px-4 bg-red-400 inline-block' do %> - - 会議へ - <% end %> - <%= link_to meal_plans_path(start_date: @meal_plan.meal_date), - class: 'inline-block flex items-center' do %> - - 献立表へ - <% end %> -
+ <%= render 'header_button', meal_plan: @meal_plan %>
<%= render @meal_plan %>
+
+ <%= button_to 'この献立を削除する', @meal_plan, method: :delete, class: 'text-orange-950/70' %> +
diff --git a/app/views/remarks/create.turbo_stream.erb b/app/views/remarks/create.turbo_stream.erb index fee3e80..574104f 100644 --- a/app/views/remarks/create.turbo_stream.erb +++ b/app/views/remarks/create.turbo_stream.erb @@ -5,3 +5,4 @@ <% end %> <%= turbo_stream.update Remark.new, "" %> +<%= turbo_stream.prepend "flash", partial: "layouts/flash" %> diff --git a/app/views/remarks/destroy.turbo_stream.erb b/app/views/remarks/destroy.turbo_stream.erb index ab21ae2..8a5f545 100644 --- a/app/views/remarks/destroy.turbo_stream.erb +++ b/app/views/remarks/destroy.turbo_stream.erb @@ -1 +1,2 @@ <%= turbo_stream.remove @remark %> +<%= turbo_stream.prepend "flash", partial: "layouts/flash" %> diff --git a/app/views/remarks/update.turbo_stream.erb b/app/views/remarks/update.turbo_stream.erb new file mode 100644 index 0000000..9f1eb1b --- /dev/null +++ b/app/views/remarks/update.turbo_stream.erb @@ -0,0 +1,7 @@ +<% if @remark.proposal? %> + <%= turbo_stream.replace "proposal", partial: "remarks/proposal", locals: {remark: @remark} %> +<% else %> + <%= turbo_stream.replace "comment", partial: "remarks/comment", locals: {remark: @remark} %> +<% end %> + +<%= turbo_stream.prepend "flash", partial: "layouts/flash" %> From bc61841821c678469fc9e800aa3976bad4d754c4 Mon Sep 17 00:00:00 2001 From: motohiro-mm Date: Sun, 13 Oct 2024 15:31:17 +0900 Subject: [PATCH 3/5] =?UTF-8?q?flash=E3=83=A1=E3=83=83=E3=82=BB=E3=83=BC?= =?UTF-8?q?=E3=82=B8=E3=81=AE=E6=96=87=E8=A8=80=E3=81=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/meal_plans_controller.rb | 2 +- app/controllers/remarks_controller.rb | 12 ++++++------ app/controllers/sessions_controller.rb | 2 +- app/controllers/users_controller.rb | 4 ++-- app/javascript/controllers/flash_controller.js | 0 5 files changed, 10 insertions(+), 10 deletions(-) create mode 100644 app/javascript/controllers/flash_controller.js diff --git a/app/controllers/meal_plans_controller.rb b/app/controllers/meal_plans_controller.rb index 98ea1a9..0f5a25c 100644 --- a/app/controllers/meal_plans_controller.rb +++ b/app/controllers/meal_plans_controller.rb @@ -23,7 +23,7 @@ def create @meal_plan.assign_attributes(meal_plan_params) if @meal_plan.save - redirect_to @meal_plan, notice: '献立を作成しました。' + redirect_to @meal_plan, notice: '献立を作成しました' else @meal_plan.meals_build render :new, status: :unprocessable_entity diff --git a/app/controllers/remarks_controller.rb b/app/controllers/remarks_controller.rb index 4529ba9..23f21ec 100644 --- a/app/controllers/remarks_controller.rb +++ b/app/controllers/remarks_controller.rb @@ -13,8 +13,8 @@ def create @remark = current_user.remarks.build(remark_params) if @remark.save respond_to do |format| - format.html { redirect_to meeting_room_path(@meeting_room), notice: "投稿しました!" } - format.turbo_stream { flash.now[:notice] = "投稿しました!" } + format.html { redirect_to meeting_room_path(@meeting_room), notice: "投稿しました" } + format.turbo_stream { flash.now[:notice] = "投稿しました" } end else render :new, status: :unprocessable_entity @@ -24,8 +24,8 @@ def create def update if @remark.update(remark_params) respond_to do |format| - format.html { redirect_to meeting_room_path(@meeting_room), notice: '更新しました!' } - format.turbo_stream { flash.now[:notice] = "更新しました!" } + format.html { redirect_to meeting_room_path(@meeting_room), notice: '更新しました' } + format.turbo_stream { flash.now[:notice] = "更新しました" } end else render :edit, status: :unprocessable_entity @@ -36,8 +36,8 @@ def destroy @remark.destroy! respond_to do |format| - format.html { redirect_to meeting_room_path(@meeting_room), notice: '削除しました!', status: :see_other } - format.turbo_stream { flash.now[:notice] = "削除しました!" } + format.html { redirect_to meeting_room_path(@meeting_room), notice: '削除しました', status: :see_other } + format.turbo_stream { flash.now[:notice] = "削除しました" } end end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 84cb88b..0af126f 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -8,7 +8,7 @@ def create user.find_or_new_family(request.env['omniauth.params']['invitation_token']) if user.family_id.nil? if user.save session[:user_id] = user.id - redirect_to meal_plans_path, notice: 'ログインに成功しました' + redirect_to meal_plans_path, notice: 'ログインしました' else redirect_to root_path, notice: 'ログインに失敗しました' end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index c732c0e..0f46ef7 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -6,7 +6,7 @@ def edit; end def update if @user.update(user_params) - redirect_to meal_plans_path, notice: 'User was successfully updated.' + redirect_to meal_plans_path, notice: '更新しました' else render :edit, status: :unprocessable_entity end @@ -16,7 +16,7 @@ def destroy current_user.destroy! current_user.family.destroy_family_having_no_user reset_session - redirect_to root_path, notice: 'User was successfully deleted.', status: :see_other + redirect_to root_path, notice: '削除しました', status: :see_other end private diff --git a/app/javascript/controllers/flash_controller.js b/app/javascript/controllers/flash_controller.js new file mode 100644 index 0000000..e69de29 From e8ceca8a92a9068e18595fa71ed30036995f8dd1 Mon Sep 17 00:00:00 2001 From: motohiro-mm Date: Sun, 13 Oct 2024 15:45:36 +0900 Subject: [PATCH 4/5] =?UTF-8?q?tailwindcss-stimulus-component=E3=82=92?= =?UTF-8?q?=E4=BD=BF=E3=81=A3=E3=81=A6flash=E3=81=AE=E8=A1=A8=E7=A4=BA?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/controllers/flash_controller.js | 7 +++++++ app/views/layouts/_flash.html.erb | 11 ++++++----- app/views/layouts/application.html.erb | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/app/javascript/controllers/flash_controller.js b/app/javascript/controllers/flash_controller.js index e69de29..c77f999 100644 --- a/app/javascript/controllers/flash_controller.js +++ b/app/javascript/controllers/flash_controller.js @@ -0,0 +1,7 @@ +import { Application } from "@hotwired/stimulus"; +import { Alert } from "tailwindcss-stimulus-components" + +const application = Application.start(); +application.register('flash', Alert) + +export default class extends Alert {} diff --git a/app/views/layouts/_flash.html.erb b/app/views/layouts/_flash.html.erb index 03e73c2..c392699 100644 --- a/app/views/layouts/_flash.html.erb +++ b/app/views/layouts/_flash.html.erb @@ -1,8 +1,9 @@ <% flash.each do |flash_type, message| %> -
- - - - <%= message %> +
+
+

+ <%= message %> +

+
<% end %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index b3df094..a397cc1 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -22,7 +22,7 @@ <% unless current_page?(root_path) %> <%= render 'shared/header' %> <% end %> -
+
<%= render "layouts/flash" %>
From b6053c98473c3e9e9459078673a03b3423c2b7d8 Mon Sep 17 00:00:00 2001 From: motohiro-mm Date: Sun, 13 Oct 2024 15:49:21 +0900 Subject: [PATCH 5/5] =?UTF-8?q?lint=E5=AE=9F=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/remarks_controller.rb | 8 ++++---- app/javascript/controllers/dropdown_controller.js | 2 -- app/javascript/controllers/flash_controller.js | 6 ++---- app/views/layouts/application.html.erb | 2 +- app/views/meal_plans/_header_button.html.erb | 2 +- 5 files changed, 8 insertions(+), 12 deletions(-) diff --git a/app/controllers/remarks_controller.rb b/app/controllers/remarks_controller.rb index 23f21ec..268a4d4 100644 --- a/app/controllers/remarks_controller.rb +++ b/app/controllers/remarks_controller.rb @@ -13,8 +13,8 @@ def create @remark = current_user.remarks.build(remark_params) if @remark.save respond_to do |format| - format.html { redirect_to meeting_room_path(@meeting_room), notice: "投稿しました" } - format.turbo_stream { flash.now[:notice] = "投稿しました" } + format.html { redirect_to meeting_room_path(@meeting_room), notice: '投稿しました' } + format.turbo_stream { flash.now[:notice] = '投稿しました' } end else render :new, status: :unprocessable_entity @@ -25,7 +25,7 @@ def update if @remark.update(remark_params) respond_to do |format| format.html { redirect_to meeting_room_path(@meeting_room), notice: '更新しました' } - format.turbo_stream { flash.now[:notice] = "更新しました" } + format.turbo_stream { flash.now[:notice] = '更新しました' } end else render :edit, status: :unprocessable_entity @@ -37,7 +37,7 @@ def destroy respond_to do |format| format.html { redirect_to meeting_room_path(@meeting_room), notice: '削除しました', status: :see_other } - format.turbo_stream { flash.now[:notice] = "削除しました" } + format.turbo_stream { flash.now[:notice] = '削除しました' } end end diff --git a/app/javascript/controllers/dropdown_controller.js b/app/javascript/controllers/dropdown_controller.js index cb1eaf8..ab7d7ce 100644 --- a/app/javascript/controllers/dropdown_controller.js +++ b/app/javascript/controllers/dropdown_controller.js @@ -3,5 +3,3 @@ import { Dropdown } from "tailwindcss-stimulus-components"; const application = Application.start(); application.register("dropdown", Dropdown); - -export default class extends Dropdown {} diff --git a/app/javascript/controllers/flash_controller.js b/app/javascript/controllers/flash_controller.js index c77f999..7977ed9 100644 --- a/app/javascript/controllers/flash_controller.js +++ b/app/javascript/controllers/flash_controller.js @@ -1,7 +1,5 @@ import { Application } from "@hotwired/stimulus"; -import { Alert } from "tailwindcss-stimulus-components" +import { Alert } from "tailwindcss-stimulus-components"; const application = Application.start(); -application.register('flash', Alert) - -export default class extends Alert {} +application.register("flash", Alert); diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index a397cc1..ec6243b 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -23,7 +23,7 @@ <%= render 'shared/header' %> <% end %>
- <%= render "layouts/flash" %> + <%= render 'layouts/flash' %>
<%= yield %> diff --git a/app/views/meal_plans/_header_button.html.erb b/app/views/meal_plans/_header_button.html.erb index 0b275fd..e12baf5 100644 --- a/app/views/meal_plans/_header_button.html.erb +++ b/app/views/meal_plans/_header_button.html.erb @@ -1,5 +1,5 @@
- <%= button_to meeting_rooms_path(meal_plan: , meal_date: meal_plan.meal_date), method: :post, class: 'rounded-full py-3 px-4 bg-red-400 inline-block' do %> + <%= button_to meeting_rooms_path(meal_plan:, meal_date: meal_plan.meal_date), method: :post, class: 'rounded-full py-3 px-4 bg-red-400 inline-block' do %> 会議へ <% end %>