diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-02-05 10:43:19 -1000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-02-05 10:43:19 -1000 |
| commit | 1eab4d59454fa5999675d51b99e77ac6580aba95 (patch) | |
| tree | 6b653e39d33fd879f29f769cdf3bd3f6bfcd3f05 /web/templates/partials/shopping-tab.html | |
| parent | 5ddb419137b814481a208d1dd0d18ac36ed554ea (diff) | |
Improve session handling, shopping UI, and cleanup
Session improvements:
- Extend session lifetime to 7 days for mobile convenience
- Add idle timeout to extend session on activity
- Use standard cookie name for better compatibility
Shopping model:
- Add FlattenItemsForStore helper for extracting store items
- Add StoreNames helper for store list
- Improve shopping-tab.html with inline add forms
Frontend:
- Add WebSocket reconnection and agent approval UI to app.js
- Simplify timeline calendar JS (move event positioning to CSS)
- Update login page styling
Deployment:
- Remove unused git checkout step from deploy.sh
- Update apache.conf WebSocket proxy settings
Documentation:
- Add Agent Context API feature spec to issues/
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Diffstat (limited to 'web/templates/partials/shopping-tab.html')
| -rw-r--r-- | web/templates/partials/shopping-tab.html | 74 |
1 files changed, 57 insertions, 17 deletions
diff --git a/web/templates/partials/shopping-tab.html b/web/templates/partials/shopping-tab.html index b09a54f..345549b 100644 --- a/web/templates/partials/shopping-tab.html +++ b/web/templates/partials/shopping-tab.html @@ -1,9 +1,5 @@ {{define "shopping-tab"}} -<div class="space-y-6 text-shadow-sm" - hx-get="/tabs/shopping{{if not .Grouped}}?grouped=false{{end}}" - hx-trigger="refresh-tasks from:body" - hx-target="#tab-content" - hx-swap="innerHTML"> +<div class="space-y-6 text-shadow-sm" id="shopping-tab-container"> <!-- Header with View Toggle --> <div class="flex items-center justify-between"> @@ -25,30 +21,74 @@ </div> <!-- Quick Add Form --> - <form hx-post="/shopping/add" - hx-target="#tab-content" - hx-swap="innerHTML" + <form id="shopping-quick-add" + hx-post="/shopping/add" + hx-target="#shopping-items-list" + hx-swap="innerHTML scroll:#shopping-quick-add:top" + hx-indicator="#shopping-add-indicator" class="bg-panel backdrop-blur-sm rounded-xl p-4 sm:p-5"> + <input type="hidden" name="grouped" value="{{.Grouped}}"> <div class="flex gap-2"> <input type="text" name="name" placeholder="Add item..." class="flex-1 bg-white/10 border border-white/20 rounded-lg px-3 py-2 text-white placeholder-white/40 focus:outline-none focus:ring-2 focus:ring-white/30 text-sm" - required> + required autocomplete="off"> <select name="store" class="bg-white/10 border border-white/20 rounded-lg px-3 py-2 text-white text-sm focus:outline-none focus:ring-2 focus:ring-white/30" required> {{range .Stores}} <option value="{{.Name}}">{{.Name}}</option> {{end}} </select> <button type="submit" class="bg-white/20 hover:bg-white/30 text-white px-4 py-2 rounded-lg text-sm font-medium transition-colors"> - Add + <span id="shopping-add-indicator" class="htmx-indicator">...</span> + <span class="htmx-hide-indicator">Add</span> </button> </div> </form> + <!-- Items List Container --> + <div id="shopping-items-list"> + {{template "shopping-items-content" .}} + </div> + + <script> + (function() { + document.body.addEventListener('htmx:afterRequest', function(evt) { + if (evt.detail.elt.id === 'shopping-quick-add' && evt.detail.successful) { + var form = evt.detail.elt; + var input = form.querySelector('input[name="name"]'); + if (input) { + input.value = ''; + input.focus(); + } + form.classList.add('flash-success'); + setTimeout(function() { form.classList.remove('flash-success'); }, 300); + } + // Handle inline add forms + if (evt.detail.elt.classList.contains('inline-add-form') && evt.detail.successful) { + var form = evt.detail.elt; + var input = form.querySelector('input[name="name"]'); + if (input) { + input.value = ''; + input.focus(); + } + } + }); + })(); + </script> + <style> + .flash-success { background: rgba(34, 197, 94, 0.2) !important; transition: background 0.3s; } + .htmx-indicator { display: none; } + .htmx-request .htmx-indicator { display: inline; } + .htmx-request .htmx-hide-indicator { display: none; } + </style> +</div> +{{end}} + +{{define "shopping-items-content"}} {{if .Stores}} {{if .Grouped}} <!-- Grouped View: Items by Store --> {{range .Stores}} - <section class="bg-panel backdrop-blur-sm rounded-xl p-4 sm:p-5"> + <section class="bg-panel backdrop-blur-sm rounded-xl p-4 sm:p-5 mb-6"> <div class="flex items-center justify-between mb-4"> <h2 class="text-xl font-medium text-white">{{.Name}}</h2> <a href="/shopping/mode/{{.Name}}" @@ -78,14 +118,15 @@ </div> {{end}} <!-- Inline Add Item --> - <form hx-post="/shopping/add" - hx-target="#tab-content" - hx-swap="innerHTML" - class="mt-3 flex gap-2"> + <form class="inline-add-form mt-3 flex gap-2" + hx-post="/shopping/add" + hx-target="#shopping-items-list" + hx-swap="innerHTML"> <input type="hidden" name="store" value="{{.Name}}"> + <input type="hidden" name="grouped" value="true"> <input type="text" name="name" placeholder="Add to {{.Name}}..." class="flex-1 bg-white/5 border border-white/10 rounded-lg px-3 py-2 text-white placeholder-white/30 focus:outline-none focus:ring-1 focus:ring-white/20 text-sm" - required> + required autocomplete="off"> <button type="submit" class="bg-white/10 hover:bg-white/20 text-white/70 hover:text-white px-3 py-2 rounded-lg text-sm transition-colors"> + </button> @@ -123,5 +164,4 @@ <p class="text-sm">Use the form above to add items quickly</p> </div> {{end}} -</div> {{end}} |
