Skip to content

Commit f3190e4

Browse files
rtcode337claude
andauthored
重ね表示スポットからも訪問記録できるようにし自動削除を効かせる (#48)
重ね表示(別種別)スポットの詳細は readOnly で訪問記録もできず、種別を切り替えないと 記録できなかったため、経路表示中のリストから自動削除が効かなかった。 SpotDetailModal に allowVisitRecording を追加し、readOnly でも「訪問を記録」だけは 出せるようにする(編集・削除・訪問予定・予定リスト追加は従来どおり隠す)。地図の 重ね表示モーダルにこれと onVisitRecorded を渡し、記録すると既存の handleVisitRecorded で 表示中リストから外れる。訪問はspot_idに紐づくため記録先は重ね表示側(その種別)のまま。 別種別での記録は不整合を避けるため口コミは無効化する。 Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent bfc7cb0 commit f3190e4

2 files changed

Lines changed: 33 additions & 20 deletions

File tree

components/MapView.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2733,7 +2733,9 @@ export default function MapView({
27332733
<SpotDetailModal
27342734
spotId={overlayDetailSpotId}
27352735
readOnly
2736+
allowVisitRecording
27362737
onClose={() => setOverlayDetailSpotId(null)}
2738+
onVisitRecorded={handleVisitRecorded}
27372739
/>
27382740
)}
27392741

components/SpotDetailModal.tsx

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export default function SpotDetailModal({
6868
spotId,
6969
spots,
7070
readOnly = false,
71+
allowVisitRecording = false,
7172
onClose,
7273
onVisitChange,
7374
onVisitRecorded,
@@ -86,6 +87,10 @@ export default function SpotDetailModal({
8687
* (このスポットは表示中の種別の地図では表示できないため)
8788
*/
8889
readOnly?: boolean;
90+
/** readOnly(重ね表示)でも「訪問を記録」だけは許可する。地図で経路表示中に、
91+
* 重ね表示した別種別スポットへ種別を切り替えずに訪問記録し、リストから外すために使う。
92+
* スポットの編集・削除や訪問予定/予定リスト追加は readOnly のまま隠す */
93+
allowVisitRecording?: boolean;
8994
onClose: () => void;
9095
/** 訪問記録の追加・削除があったときに呼ばれる(呼び出し元の一覧・バッジ更新用) */
9196
onVisitChange?: () => void;
@@ -481,25 +486,31 @@ export default function SpotDetailModal({
481486
</p>
482487
)}
483488
</div>
484-
{!readOnly && (
489+
{(!readOnly || allowVisitRecording) && (
485490
<div className="flex flex-wrap justify-end gap-2">
486-
<button
487-
onClick={toggleVisitPlan}
488-
disabled={planUpdating}
489-
className={`rounded-lg px-3 py-1.5 text-sm font-medium disabled:opacity-50 ${
490-
planned
491-
? "border border-gray-300 text-gray-600"
492-
: "border border-blue-600 text-blue-600"
493-
}`}
494-
>
495-
{planned ? "訪問予定をはずす" : "訪問予定にする"}
496-
</button>
497-
<button
498-
onClick={() => setShowAddToList(true)}
499-
className="rounded-lg border border-blue-600 px-3 py-1.5 text-sm font-medium text-blue-600"
500-
>
501-
予定リストに追加
502-
</button>
491+
{/* スポットの管理系(訪問予定・予定リスト)は通常表示のときだけ。
492+
readOnly(重ね表示)では訪問記録だけを許可する */}
493+
{!readOnly && (
494+
<>
495+
<button
496+
onClick={toggleVisitPlan}
497+
disabled={planUpdating}
498+
className={`rounded-lg px-3 py-1.5 text-sm font-medium disabled:opacity-50 ${
499+
planned
500+
? "border border-gray-300 text-gray-600"
501+
: "border border-blue-600 text-blue-600"
502+
}`}
503+
>
504+
{planned ? "訪問予定をはずす" : "訪問予定にする"}
505+
</button>
506+
<button
507+
onClick={() => setShowAddToList(true)}
508+
className="rounded-lg border border-blue-600 px-3 py-1.5 text-sm font-medium text-blue-600"
509+
>
510+
予定リストに追加
511+
</button>
512+
</>
513+
)}
503514
<button
504515
onClick={() => setShowForm(true)}
505516
className="rounded-lg bg-blue-600 px-3 py-1.5 text-sm font-medium text-white"
@@ -642,7 +653,7 @@ export default function SpotDetailModal({
642653
<VisitFormModal
643654
spotId={spot.id}
644655
spotName={spot.name}
645-
reviewsEnabled={reviewsEnabled}
656+
reviewsEnabled={!readOnly && reviewsEnabled}
646657
onClose={() => setShowForm(false)}
647658
onSaved={() => {
648659
setShowForm(false);
@@ -663,7 +674,7 @@ export default function SpotDetailModal({
663674
<VisitFormModal
664675
spotId={spot.id}
665676
spotName={spot.name}
666-
reviewsEnabled={reviewsEnabled}
677+
reviewsEnabled={!readOnly && reviewsEnabled}
667678
visit={editingVisit}
668679
onClose={() => setEditingVisit(null)}
669680
onSaved={() => {

0 commit comments

Comments
 (0)