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.radio_button :parking_flag, 1, data: { action: "change->parking#toggle" }, checked: form.object.parking_flag == 1 %> ある
+
+
+ <%= form.radio_button :parking_flag, 0, data: { action: "change->parking#toggle" }, checked: form.object.parking_flag == 0 %> ない
+
+
+ <%= form.radio_button :parking_flag, nil, data: { action: "change->parking#toggle" }, checked: form.object.parking_flag.nil? %> わからない
+
+
+
+ <%= 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 %>
+
+
+<%# モーダルウィンドウのHTML部分 %>
+
-
-
-
- <%# 閉じるボタン %>
-
- ×
-
- <%# 左右の矢印ボタン %>
-
- ‹
-
-
- ›
-
-
+
+
+
+ <%# 閉じるボタン %>
+
+ ×
+
+ <%# 左右の矢印ボタン %>
+
+ ‹
+
+
+ ›
+
+
\ No newline at end of file
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" %>
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 %>