diff --git a/assets/js/app.js b/assets/js/app.js index 7f88668..b6d8f5d 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -1,8 +1,23 @@ -import {Socket} from "phoenix" -import {LiveSocket} from "phoenix_live_view" +import { Socket } from "phoenix" +import { LiveSocket } from "phoenix_live_view" +import Alpine from "alpinejs" +import focus from "@alpinejs/focus" + +window.Alpine = Alpine +Alpine.plugin(focus) +Alpine.start() let csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute("content") -let liveSocket = new LiveSocket("/live", Socket, {params: {_csrf_token: csrfToken}}) +let liveSocket = new LiveSocket("/live", Socket, { + params: { _csrf_token: csrfToken }, + dom: { + onBeforeElUpdated(from, to) { + if (from._x_dataStack) { + window.Alpine.clone(from, to) + } + } + } +}) // Connect if there are any LiveViews on the page liveSocket.connect() diff --git a/assets/package.json b/assets/package.json index c0eebd1..6c45be9 100644 --- a/assets/package.json +++ b/assets/package.json @@ -10,7 +10,8 @@ "author": "", "license": "ISC", "dependencies": { - "alpinejs": "^3.12.3" + "@alpinejs/focus": "^3.13.3", + "alpinejs": "^3.13.3" }, "devDependencies": { "@tailwindcss/typography": "^0.5.9", diff --git a/assets/yarn.lock b/assets/yarn.lock index 7d80288..a5e0ebc 100644 --- a/assets/yarn.lock +++ b/assets/yarn.lock @@ -7,6 +7,14 @@ resolved "https://registry.yarnpkg.com/@alloc/quick-lru/-/quick-lru-5.2.0.tgz#7bf68b20c0a350f936915fcae06f58e32007ce30" integrity sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw== +"@alpinejs/focus@^3.13.3": + version "3.13.3" + resolved "https://registry.yarnpkg.com/@alpinejs/focus/-/focus-3.13.3.tgz#fd06d055175ff64b07a7e4a64fa01a4ad85104dd" + integrity sha512-fTRX/9wOfysyZ1PJ4gHeUnmiNTIgqBDIqKxeP5iMvj1UHD3TFLDXllvoIKH3ezqcsyQZqxd/q1MFM7dlIhkmeg== + dependencies: + focus-trap "^6.9.4" + tabbable "^5.3.3" + "@jridgewell/gen-mapping@^0.3.2": version "0.3.3" resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz#7e02e6eb5df901aaedb08514203b096614024098" @@ -87,10 +95,10 @@ resolved "https://registry.yarnpkg.com/@vue/shared/-/shared-3.1.5.tgz#74ee3aad995d0a3996a6bb9533d4d280514ede03" integrity sha512-oJ4F3TnvpXaQwZJNF3ZK+kLPHKarDmJjJ6jyzVNDKH9md1dptjC7lWR//jrGuLdek/U6iltWxqAnYOu8gCiOvA== -alpinejs@^3.12.3: - version "3.12.3" - resolved "https://registry.yarnpkg.com/alpinejs/-/alpinejs-3.12.3.tgz#d7f311b39318c5144e99205ab69557c0d90a552a" - integrity sha512-fLz2dfYQ3xCk7Ip8LiIpV2W+9brUyex2TAE7Z0BCvZdUDklJE+n+a8gCgLWzfZ0GzZNZu7HUP8Z0z6Xbm6fsSA== +alpinejs@^3.13.3: + version "3.13.3" + resolved "https://registry.yarnpkg.com/alpinejs/-/alpinejs-3.13.3.tgz#92eb7e869b99ff548e7a55044e45660597cf530b" + integrity sha512-WZ6WQjkAOl+WdW/jukzNHq9zHFDNKmkk/x6WF7WdyNDD6woinrfXCVsZXm0galjbco+pEpYmJLtwlZwcOfIVdg== dependencies: "@vue/reactivity" "~3.1.1" @@ -272,6 +280,13 @@ fill-range@^7.0.1: dependencies: to-regex-range "^5.0.1" +focus-trap@^6.9.4: + version "6.9.4" + resolved "https://registry.yarnpkg.com/focus-trap/-/focus-trap-6.9.4.tgz#436da1a1d935c48b97da63cd8f361c6f3aa16444" + integrity sha512-v2NTsZe2FF59Y+sDykKY+XjqZ0cPfhq/hikWVL88BqLivnNiEffAsac6rP6H45ff9wG9LL5ToiDqrLEP9GX9mw== + dependencies: + tabbable "^5.3.3" + fraction.js@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/fraction.js/-/fraction.js-4.2.0.tgz#448e5109a313a3527f5a3ab2119ec4cf0e0e2950" @@ -628,6 +643,11 @@ supports-preserve-symlinks-flag@^1.0.0: resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09" integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== +tabbable@^5.3.3: + version "5.3.3" + resolved "https://registry.yarnpkg.com/tabbable/-/tabbable-5.3.3.tgz#aac0ff88c73b22d6c3c5a50b1586310006b47fbf" + integrity sha512-QD9qKY3StfbZqWOPLp0++pOrAVb/HbUi5xCc8cUo4XjP19808oaMiDzn0leBY5mCespIBM0CIZePzZjgzR83kA== + tailwindcss@^3, tailwindcss@^3.3.2: version "3.3.2" resolved "https://registry.yarnpkg.com/tailwindcss/-/tailwindcss-3.3.2.tgz#2f9e35d715fdf0bbf674d90147a0684d7054a2d3" diff --git a/config/config.exs b/config/config.exs index 4c697fb..16d1e7d 100644 --- a/config/config.exs +++ b/config/config.exs @@ -9,7 +9,7 @@ import Config config :esbuild, path: System.get_env("MIX_ESBUILD_PATH"), default: [ - args: ~w(js/app.js --bundle --target=es2016 --outdir=../priv/static/js --external:/images/*), + args: ~w(js/app.js --bundle --target=es2017 --outdir=../priv/static/js --external:/images/*), cd: Path.expand("../assets", __DIR__), env: %{"NODE_PATH" => Path.expand("../deps", __DIR__)} ] diff --git a/lib/lanpartyseating_web/components/cancellation_modal.ex b/lib/lanpartyseating_web/components/cancellation_modal.ex index b530608..dc6827e 100644 --- a/lib/lanpartyseating_web/components/cancellation_modal.ex +++ b/lib/lanpartyseating_web/components/cancellation_modal.ex @@ -10,110 +10,133 @@ defmodule CancellationModalComponent do case assigns.status do :available -> ~H""" - - - - - -
Do you want to close this station?
- - -Occupied by badge #<%= @reservation.badge %> *REPLACE WITH NAME*
-The reservation will end at - <%= Calendar.strftime( - @reservation.end_date |> Timex.to_datetime("America/Montreal"), - "%H:%M" - ) %> *REPLACE WITH COUNTDOWN* -
-Enter a reason for canceling the reservation
- - -Do you want to re-open this station?
- - -Once your badge is scanned, a 45 min session will start at the chosen station
-Une fois votre badge scanné, une session de 45 min commencera à la station choisie
+