From c9c36f5f28eabf91db6724a1f221db07580a474a Mon Sep 17 00:00:00 2001 From: Mr-T18 Date: Thu, 28 Aug 2025 06:59:08 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=E7=AE=A1=E7=90=86=E7=94=BB=E9=9D=A2?= =?UTF-8?q?=E3=81=AE=E4=B8=80=E8=A6=A7=E8=A1=A8=E7=A4=BA=E3=82=92=E3=82=B3?= =?UTF-8?q?=E3=83=B3=E3=83=91=E3=82=AF=E3=83=88=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/admin/photo_spots/index.html.erb | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/app/views/admin/photo_spots/index.html.erb b/app/views/admin/photo_spots/index.html.erb index 186afa8..4bcd92a 100644 --- a/app/views/admin/photo_spots/index.html.erb +++ b/app/views/admin/photo_spots/index.html.erb @@ -12,14 +12,12 @@ <% @photo_spots.each do |photo_spot| %>
- <%= render partial: 'photo_spot', locals: { photo_spot: photo_spot } %> - - <% if photo_spot.images.attached? %> -
- <% photo_spot.images.each do |img| %><%= image_tag img.variant(resize_to_limit: [80,80]), class: "rounded shadow border w-20 h-20 object-cover", alt: photo_spot.name %> + <%= render partial: 'photo_spot', locals: { photo_spot: photo_spot } %> + + <% if photo_spot.images.attached? %> +
+
<% end %> -
- <% end %>
<%= link_to t('admin.photo_spots.index.show', default: '詳細'), admin_photo_spot_path(photo_spot), class: "rounded-md px-4 py-2 bg-gray-100 hover:bg-gray-200 text-gray-800 font-medium text-center w-full md:w-auto" %> From a5e0a1b96ce5cf33c7b66a6bce06142435cad76a Mon Sep 17 00:00:00 2001 From: Mr-T18 Date: Thu, 28 Aug 2025 07:37:54 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=E5=8F=B0=E6=95=B0=E3=81=AE=E5=85=A5?= =?UTF-8?q?=E5=8A=9B=E3=81=A8=E8=A1=A8=E7=A4=BA(admin)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/photo_spots_controller.rb | 2 +- .../controllers/parking_controller.js | 27 ++++++ app/views/admin/photo_spots/_form.html.erb | 23 +++++- .../admin/photo_spots/_photo_spot.html.erb | 82 +++++++++++-------- app/views/photo_spots/_spot_card.html.erb | 19 +++-- 5 files changed, 109 insertions(+), 44 deletions(-) create mode 100644 app/javascript/controllers/parking_controller.js diff --git a/app/controllers/admin/photo_spots_controller.rb b/app/controllers/admin/photo_spots_controller.rb index c20071c..093b5fd 100644 --- a/app/controllers/admin/photo_spots_controller.rb +++ b/app/controllers/admin/photo_spots_controller.rb @@ -71,7 +71,7 @@ def set_photo_spot end def photo_spot_params - params.require(:photo_spot).permit(:name, :address, :detail, :parking_flag, :tags, { images: [] }, + params.require(:photo_spot).permit(:name, :address, :detail, :parking_flag, :parking_count, :tags, { images: [] }, :latitude, :longitude, :timestart, :timeend, :season,) end end diff --git a/app/javascript/controllers/parking_controller.js b/app/javascript/controllers/parking_controller.js new file mode 100644 index 0000000..4ad0c91 --- /dev/null +++ b/app/javascript/controllers/parking_controller.js @@ -0,0 +1,27 @@ +import { Controller } from "@hotwired/stimulus" + +export default class extends Controller { + static targets = ["countInput"] + + connect() { + this.updateInputState() + } + + toggle(event) { + this.updateInputState() + } + + updateInputState() { + const selected = this.element.querySelector("input[name='photo_spot[parking_flag]']:checked") + if (selected && selected.value === "1") { + this.countInputTarget.disabled = false + this.countInputTarget.classList.remove("bg-gray-200", "text-gray-500") + this.countInputTarget.classList.add("bg-white", "text-black") + } else { + this.countInputTarget.disabled = true + this.countInputTarget.value = "" + this.countInputTarget.classList.remove("bg-white", "text-black") + this.countInputTarget.classList.add("bg-gray-200", "text-gray-500") + } + } +} diff --git a/app/views/admin/photo_spots/_form.html.erb b/app/views/admin/photo_spots/_form.html.erb index cdb706c..6f17224 100644 --- a/app/views/admin/photo_spots/_form.html.erb +++ b/app/views/admin/photo_spots/_form.html.erb @@ -65,9 +65,26 @@ <%= form.label :tags, 'タグ(カンマ区切り)', class: 'block font-semibold mb-1' %> <%= form.text_field :tags, class: "block shadow-sm rounded-md border px-3 py-2 w-full border-gray-300 focus:outline-blue-600" %>
-
- <%= form.label :parking_flag, '駐車場の有無', class: 'block font-semibold mb-1' %> - <%= form.text_field :parking_flag, class: "block shadow-sm rounded-md border px-3 py-2 w-full border-gray-300 focus:outline-blue-600" %> +
+
+ + + +
+
+ <%= form.label :parking_count, '台数' %> + <%= form.number_field :parking_count, + min: 1, + data: { parking_target: "countInput" }, + disabled: form.object.parking_flag != 1, + class: form.object.parking_flag == 1 ? "bg-white text-black border rounded px-2 py-1" : "bg-gray-200 text-gray-500 border rounded px-2 py-1" %> +
<%= form.label :images, '画像(最大5枚・JPEG/PNG/GIF)', class: 'block font-semibold mb-1' %> diff --git a/app/views/admin/photo_spots/_photo_spot.html.erb b/app/views/admin/photo_spots/_photo_spot.html.erb index bcf2f1e..94baf3f 100644 --- a/app/views/admin/photo_spots/_photo_spot.html.erb +++ b/app/views/admin/photo_spots/_photo_spot.html.erb @@ -27,45 +27,57 @@
<%= photo_spot.tags %>
時間帯
- <%= photo_spot.timestart ? photo_spot.timestart.strftime("%H:%M") : "未設定" %> 〜 - <%= photo_spot.timeend ? photo_spot.timeend.strftime("%H:%M") : "未設定" %> + <%= photo_spot.timestart ? photo_spot.timestart.strftime("%H:%M") : "未設定" %> 〜 + <%= photo_spot.timeend ? photo_spot.timeend.strftime("%H:%M") : "未設定" %>
-
おすすめの季節
+
駐車場
- <% case photo_spot.season %> - <% when 'spring' %> - 春 - <% when 'summer' %> - 夏 - <% when 'autumn' %> - 秋 - <% when 'winter' %> - 冬 - <% else %> - 未設定 - <% end %> -
- -
+ <% if photo_spot.parking_flag == 1 %> + 駐車場あり + <% if photo_spot.parking_count%> + :<%= photo_spot.parking_count %> 台 + <% end %> + <% elsif photo_spot.parking_flag == 0 %> + 駐車場なし +
+ <% end %> + +
おすすめの季節
+
+ <% case photo_spot.season %> + <% when 'spring' %> + 春 + <% when 'summer' %> + 夏 + <% when 'autumn' %> + 秋 + <% when 'winter' %> + 冬 + <% else %> + 未設定 + <% end %> +
+
- <%# モーダルウィンドウのHTML部分 %> -
+<%# モーダルウィンドウのHTML部分 %> + \ No newline at end of file diff --git a/app/views/photo_spots/_spot_card.html.erb b/app/views/photo_spots/_spot_card.html.erb index f0b426a..f0b7400 100644 --- a/app/views/photo_spots/_spot_card.html.erb +++ b/app/views/photo_spots/_spot_card.html.erb @@ -11,11 +11,6 @@

<%= photo_spot.name %>

<%= truncate(photo_spot.detail, length: 60) %>
- <% if photo_spot.tags.present? %> -
- タグ: <%= photo_spot.tags %> -
- <% end %>
<% if photo_spot.reviews.any? %> <%= render partial: "shared/rating_stars", locals: { rating: (photo_spot.reviews.average(:rating)&.round || 0) } %> @@ -24,6 +19,20 @@ 未評価 <% end %>
+ <% if photo_spot.tags.present? %> +
+ タグ: <%= photo_spot.tags %> +
+ <% end %> + <% if photo_spot.parking_flag == 1 %> +
+ 駐車場あり +
+ <% elsif photo_spot.parking_flag == 0 %> +
+ 駐車場なし +
+ <% end %>
<% end %>