admin: photo preview fixed size (inline styles); preview mode ?preview=1 (banner, no scan functionality) with Preview buttons in admin row action + owner edit link
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
|||||||
|
|
||||||
type publicData struct {
|
type publicData struct {
|
||||||
UpdatedAt pgtype.Timestamptz
|
UpdatedAt pgtype.Timestamptz
|
||||||
|
Preview bool
|
||||||
ID int64
|
ID int64
|
||||||
TagCode string
|
TagCode string
|
||||||
Status string
|
Status string
|
||||||
@@ -48,6 +49,7 @@ func (a *App) PublicTag(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pd := publicData{
|
pd := publicData{
|
||||||
|
Preview: r.URL.Query().Get("preview") == "1",
|
||||||
UpdatedAt: tag.UpdatedAt,
|
UpdatedAt: tag.UpdatedAt,
|
||||||
ID: tag.ID,
|
ID: tag.ID,
|
||||||
TagCode: tag.TagCode,
|
TagCode: tag.TagCode,
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<input type="file" name="photo" accept="image/*" class="text-sm" onchange="var f=this.files[0]; if(f){ var p=document.getElementById('photo-preview'); p.classList.remove('hidden'); var r=new FileReader(); r.onload=function(e){ p.src=e.target.result; }; r.readAsDataURL(f); }">
|
<input type="file" name="photo" accept="image/*" class="text-sm" onchange="var f=this.files[0]; if(f){ var p=document.getElementById('photo-preview'); p.classList.remove('hidden'); var r=new FileReader(); r.onload=function(e){ p.src=e.target.result; }; r.readAsDataURL(f); }">
|
||||||
<p class="mt-1 text-xs text-stone-500">Choose a photo and press Save. If you choose nothing, the current photo is kept.</p>
|
<p class="mt-1 text-xs text-stone-500">Choose a photo and press Save. If you choose nothing, the current photo is kept.</p>
|
||||||
<p class="mt-2"><a href="/t/{{.Data.TagCode}}" target="_blank" rel="noopener" class="text-xs text-amber-600 hover:underline">👁 View the live tag page</a></p>
|
<p class="mt-2"><a href="/t/{{.Data.TagCode}}?preview=1" target="_blank" rel="noopener" class="text-xs text-amber-600 hover:underline">👁 Preview the tag page (no scan)</a></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -29,7 +29,10 @@
|
|||||||
</div>
|
</div>
|
||||||
{{else}}
|
{{else}}
|
||||||
<div class="overflow-hidden rounded-xl border border-stone-200 bg-white shadow-sm">
|
<div class="overflow-hidden rounded-xl border border-stone-200 bg-white shadow-sm">
|
||||||
<div class="bg-stone-900 px-6 py-5 text-white">
|
{{if .Data.Preview}}
|
||||||
|
<div class="bg-amber-400 px-6 py-2 text-center text-xs font-bold text-stone-900">👁 PREVIEW — this is how the page looks to a finder (scan functionality disabled)</div>
|
||||||
|
{{end}}
|
||||||
|
<div class="bg-stone-900 px-6 py-5 text-white">
|
||||||
<h1 class="text-2xl font-bold">
|
<h1 class="text-2xl font-bold">
|
||||||
{{if .Data.ItemType.Valid}}{{.Data.ItemType.String | title}}{{else}}Item{{end}} — found!
|
{{if .Data.ItemType.Valid}}{{.Data.ItemType.String | title}}{{else}}Item{{end}} — found!
|
||||||
</h1>
|
</h1>
|
||||||
@@ -71,12 +74,15 @@
|
|||||||
{{end}}
|
{{end}}
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
|
{{if not .Data.Preview}}
|
||||||
<div class="mt-4 rounded border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-800">
|
<div class="mt-4 rounded border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-800">
|
||||||
<p><strong>Help the owner find it:</strong> sharing your location sends them a map link. No location? No problem — the page still works.</p>
|
<p><strong>Help the owner find it:</strong> sharing your location sends them a map link. No location? No problem — the page still works.</p>
|
||||||
<button id="recheck-btn" type="button" class="mt-2 rounded bg-amber-500 px-3 py-1.5 text-xs font-semibold text-stone-900 hover:bg-amber-400">📍 Re-check my location</button>
|
<button id="recheck-btn" type="button" class="mt-2 rounded bg-amber-500 px-3 py-1.5 text-xs font-semibold text-stone-900 hover:bg-amber-400">📍 Re-check my location</button>
|
||||||
<p id="location-shared" class="hidden mt-2 text-xs font-medium text-green-700">✓ Location shared — the owner has been sent a map link.</p>
|
<p id="location-shared" class="hidden mt-2 text-xs font-medium text-green-700">✓ Location shared — the owner has been sent a map link.</p>
|
||||||
</div>
|
</div>
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{if not .Data.Preview}}
|
||||||
<div id="contact-area" class="mt-4" x-data="{ phone: '', get valid() { return /^[0-9+ ]{8,16}$/.test(this.phone.trim()); } }">
|
<div id="contact-area" class="mt-4" x-data="{ phone: '', get valid() { return /^[0-9+ ]{8,16}$/.test(this.phone.trim()); } }">
|
||||||
<form hx-post="/t/{{.Data.TagCode}}/contact" hx-target="#contact-area" hx-swap="innerHTML" class="flex gap-2" @submit.prevent="if(!valid) return; $el.requestSubmit()">
|
<form hx-post="/t/{{.Data.TagCode}}/contact" hx-target="#contact-area" hx-swap="innerHTML" class="flex gap-2" @submit.prevent="if(!valid) return; $el.requestSubmit()">
|
||||||
<input type="hidden" name="fingerprint" value="">
|
<input type="hidden" name="fingerprint" value="">
|
||||||
@@ -86,6 +92,7 @@
|
|||||||
</form>
|
</form>
|
||||||
<p x-show="phone && !valid" class="mt-1 text-xs text-red-600">Enter a valid phone number (8–16 digits, e.g. 0423 274 487).</p>
|
<p x-show="phone && !valid" class="mt-1 text-xs text-red-600">Enter a valid phone number (8–16 digits, e.g. 0423 274 487).</p>
|
||||||
</div>
|
</div>
|
||||||
|
{{end}}
|
||||||
|
|
||||||
{{if .Data.IsOwner}}
|
{{if .Data.IsOwner}}
|
||||||
<p class="mt-4 text-center text-sm"><a href="/account/tags/{{.Data.ID}}/edit" class="text-amber-600 hover:underline">✏️ Edit this tag's details</a></p>
|
<p class="mt-4 text-center text-sm"><a href="/account/tags/{{.Data.ID}}/edit" class="text-amber-600 hover:underline">✏️ Edit this tag's details</a></p>
|
||||||
@@ -93,6 +100,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{if not .Data.Preview}}
|
||||||
<script>
|
<script>
|
||||||
(function () {
|
(function () {
|
||||||
var code = {{.Data.TagCode | printf "%q"}};
|
var code = {{.Data.TagCode | printf "%q"}};
|
||||||
@@ -137,6 +145,7 @@
|
|||||||
tryLocation();
|
tryLocation();
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|||||||
Reference in New Issue
Block a user