mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-13 02:31:39 -05:00
Major improvements: 1. Use Turbo for sharing updates - no page reload, modal stays open 2. Add Stimulus copy button controller - clean implementation with 'Copied!' feedback 3. Allow updating notes/photos toggles without disabling sharing 4. Add 'Update Sharing' button to save changes while keeping sharing enabled 5. Use 'true'/'false' strings consistently instead of '1'/'0' 6. Update all request specs to use 'true'/'false' values Technical changes: - Wrap form in turbo_frame_tag for seamless updates - Controller responds with turbo_stream to replace form content - Create copy_button_controller.js for proper copy feedback - Checkboxes now editable when sharing is enabled - Separate 'Update Sharing' and 'Disable Sharing' actions
217 lines
11 KiB
Text
217 lines
11 KiB
Text
<dialog id="sharing_modal_<%= trip.id %>" class="modal">
|
|
<div class="modal-box max-w-2xl">
|
|
<form method="dialog">
|
|
<button class="btn btn-sm btn-circle btn-ghost absolute right-2 top-2">✕</button>
|
|
</form>
|
|
|
|
<h3 class="font-bold text-lg mb-4 flex items-center gap-2">
|
|
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8.684 13.342C8.886 12.938 9 12.482 9 12c0-.482-.114-.938-.316-1.342m0 2.684a3 3 0 110-2.684m0 2.684l6.632 3.316m-6.632-6l6.632-3.316m0 0a3 3 0 105.367-2.684 3 3 0 00-5.367 2.684zm0 9.316a3 3 0 105.368 2.684 3 3 0 00-5.368-2.684z" />
|
|
</svg>
|
|
Trip Sharing Settings
|
|
</h3>
|
|
|
|
<%= turbo_frame_tag "sharing_form_#{trip.id}" do %>
|
|
<%= form_with model: trip, url: trip_path(trip), method: :patch, id: "sharing_form_#{trip.id}" do |f| %>
|
|
<% if trip.sharing_enabled? %>
|
|
<!-- Sharing is enabled -->
|
|
<div class="space-y-4">
|
|
<!-- Sharing Status -->
|
|
<div class="alert <%= trip.sharing_expired? ? 'alert-warning' : 'alert-success' %>">
|
|
<% if trip.sharing_expired? %>
|
|
<svg xmlns="http://www.w3.org/2000/svg" class="stroke-current flex-shrink-0 h-6 w-6" fill="none" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" /></svg>
|
|
<div>
|
|
<h3 class="font-bold">Link Expired</h3>
|
|
<p class="text-sm">This share link has expired and is no longer accessible</p>
|
|
</div>
|
|
<% else %>
|
|
<svg xmlns="http://www.w3.org/2000/svg" class="stroke-current flex-shrink-0 h-6 w-6" fill="none" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" /></svg>
|
|
<div>
|
|
<h3 class="font-bold">Sharing Active</h3>
|
|
<p class="text-sm">This trip is publicly accessible via the link below</p>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
|
|
<!-- Sharing URL -->
|
|
<div class="form-control">
|
|
<label class="label">
|
|
<span class="label-text font-medium">Sharing link</span>
|
|
</label>
|
|
<div class="join w-full">
|
|
<input
|
|
type="text"
|
|
value="<%= shared_trip_url(trip.sharing_uuid) %>"
|
|
readonly
|
|
class="input input-bordered join-item flex-1"
|
|
id="sharing-url-<%= trip.id %>">
|
|
<button
|
|
type="button"
|
|
class="btn btn-outline join-item gap-2"
|
|
data-action="click->copy-button#copy"
|
|
data-copy-button-target="button"
|
|
data-copy-text="<%= shared_trip_url(trip.sharing_uuid) %>">
|
|
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3" /></svg>
|
|
<span>Copy</span>
|
|
</button>
|
|
</div>
|
|
<div class="label">
|
|
<span class="label-text-alt">Share this link with others to give them access to your trip</span>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- View Public Page Button -->
|
|
<div class="flex justify-center">
|
|
<%= link_to shared_trip_path(trip.sharing_uuid), target: '_blank', class: 'btn btn-outline btn-primary gap-2' do %>
|
|
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" />
|
|
</svg>
|
|
View Public Page
|
|
<% end %>
|
|
</div>
|
|
|
|
<!-- Sharing Options -->
|
|
<div class="card bg-base-200">
|
|
<div class="card-body p-4">
|
|
<h4 class="font-semibold mb-3">What to share:</h4>
|
|
|
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
|
<div class="form-control">
|
|
<label class="label cursor-pointer justify-start gap-3">
|
|
<%= check_box_tag 'trip[sharing][share_notes]', 'true', trip.share_notes?, class: 'toggle toggle-primary' %>
|
|
<div>
|
|
<span class="label-text font-medium block">Share trip notes</span>
|
|
<span class="label-text-alt text-xs">Include your description and notes</span>
|
|
</div>
|
|
</label>
|
|
</div>
|
|
<div class="form-control">
|
|
<label class="label cursor-pointer justify-start gap-3">
|
|
<%= check_box_tag 'trip[sharing][share_photos]', 'true', trip.share_photos?, class: 'toggle toggle-primary' %>
|
|
<div>
|
|
<span class="label-text font-medium block">Share photos</span>
|
|
<span class="label-text-alt text-xs">Include photos from this trip</span>
|
|
</div>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="text-xs text-base-content/60 mt-3 p-2 bg-base-100 rounded">
|
|
<strong>Always included:</strong> Trip name, dates, route map, distance, and countries visited
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Privacy Notice -->
|
|
<div class="alert alert-info">
|
|
<svg xmlns="http://www.w3.org/2000/svg" class="stroke-current flex-shrink-0 h-6 w-6" fill="none" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" /></svg>
|
|
<div>
|
|
<h3 class="font-bold">Privacy Protection</h3>
|
|
<div class="text-sm">
|
|
• Only selected information is shared<br>
|
|
• Personal information and account details are never included<br>
|
|
• You can disable sharing at any time
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Action Buttons -->
|
|
<%= hidden_field_tag 'trip[sharing][enabled]', 'true' %>
|
|
<div class="modal-action">
|
|
<%= submit_tag "Update Sharing",
|
|
class: "btn btn-primary" %>
|
|
<%= submit_tag "Disable Sharing",
|
|
name: 'trip[sharing][enabled]',
|
|
value: 'false',
|
|
class: "btn btn-error",
|
|
data: { turbo_confirm: "Are you sure you want to disable sharing for this trip?" } %>
|
|
</div>
|
|
</div>
|
|
<% else %>
|
|
<!-- Sharing is disabled - Enable form -->
|
|
<div class="space-y-4">
|
|
<p class="text-base-content/70">
|
|
Generate a public link to share this trip with friends, family, or on social media.
|
|
</p>
|
|
|
|
<!-- Sharing Options -->
|
|
<div class="card bg-base-200">
|
|
<div class="card-body p-4">
|
|
<h4 class="font-semibold mb-3">Choose what to share:</h4>
|
|
|
|
<div class="form-control mb-3">
|
|
<label class="label">
|
|
<span class="label-text font-medium">Link expiration</span>
|
|
</label>
|
|
<%= select_tag 'trip[sharing][expiration]',
|
|
options_for_select([
|
|
['1 hour', '1h'],
|
|
['12 hours', '12h'],
|
|
['24 hours', '24h'],
|
|
['Never (permanent)', 'permanent']
|
|
], '24h'),
|
|
class: 'select select-bordered w-full' %>
|
|
<div class="label">
|
|
<span class="label-text-alt">Choose how long the sharing link will remain active</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="divider my-2"></div>
|
|
|
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
|
<div class="form-control">
|
|
<label class="label cursor-pointer justify-start gap-3">
|
|
<%= check_box_tag 'trip[sharing][share_notes]', 'true', true, class: 'toggle toggle-primary' %>
|
|
<div>
|
|
<span class="label-text font-medium block">Share trip notes</span>
|
|
<span class="label-text-alt text-xs">Include your description and notes</span>
|
|
</div>
|
|
</label>
|
|
</div>
|
|
<div class="form-control">
|
|
<label class="label cursor-pointer justify-start gap-3">
|
|
<%= check_box_tag 'trip[sharing][share_photos]', 'true', true, class: 'toggle toggle-primary' %>
|
|
<div>
|
|
<span class="label-text font-medium block">Share photos</span>
|
|
<span class="label-text-alt text-xs">Include photos from this trip</span>
|
|
</div>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="text-xs text-base-content/60 mt-3 p-2 bg-base-100 rounded">
|
|
<strong>Always included:</strong> Trip name, dates, route map, distance, and countries visited
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Privacy Notice -->
|
|
<div class="alert alert-info">
|
|
<svg xmlns="http://www.w3.org/2000/svg" class="stroke-current flex-shrink-0 h-6 w-6" fill="none" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" /></svg>
|
|
<div>
|
|
<h3 class="font-bold">Privacy Protection</h3>
|
|
<div class="text-sm">
|
|
• Only selected information will be shared<br>
|
|
• Personal information and account details are never included<br>
|
|
• You can disable sharing at any time
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Action Buttons -->
|
|
<%= hidden_field_tag 'trip[sharing][enabled]', 'true' %>
|
|
<div class="modal-action">
|
|
<button type="button" class="btn btn-ghost" onclick="sharing_modal_<%= trip.id %>.close()">
|
|
Cancel
|
|
</button>
|
|
<%= submit_tag "Enable Sharing", class: "btn btn-primary" %>
|
|
</div>
|
|
</div>
|
|
<% end %>
|
|
<% end %>
|
|
<% end %>
|
|
</div>
|
|
<form method="dialog" class="modal-backdrop">
|
|
<button>close</button>
|
|
</form>
|
|
</dialog>
|