Commit graph

157 commits

Author SHA1 Message Date
5144bf2b37 Allow shifts without a role
Allow a shift to have no role associated with it in order to simplify
conflict resolution around situations like a shift being created while
the role it was assoiated with was deleted. This also allows for shifts
that are freestanding to be created in case having a role doesn't make
sense for it.
2025-06-30 16:36:47 +02:00
1d2edf7535 Add dialog showing diff of changes to save
Add a save dialog at the bottom of the screen that is present whenever
there are unsaved changes.  This dialog provides a diff between the
client and server state so that the user can easily confirm the changes
they are about to make are the correct changes before applying them to
the server.
2025-06-30 15:43:15 +02:00
60f898e986 Set updatedAt in the past in demo schedule
Make sure that all of the entities generated in the demo schedule are
updated in the past. Otherwise updates for them will end up rejected
for being before the current entity's updateAt property.

This also sets the origin for the schedule to be yesterday to make it
easiser to demo the schedule between friday and tuesday.
2025-06-30 15:20:57 +02:00
f24dbae5eb Fix logic errors from mixing up client and server
All checks were successful
/ build (push) Successful in 1m33s
/ deploy (push) Successful in 16s
Fix discard and apiUpdate in Location, Role and Shift sometimes breaking
due to the field and serverField versions of the fields being mixed up.
2025-06-29 20:39:05 +02:00
f79f49b0f6 Fix schedule breaking on 2001-09-09 01:46:40Z
Array.sort() sorts by UTF-16 code points even when the items in the
array are numbers.  Fix the schedule breaking when events cross
different powers of 10 in Unix time which caused the junctions to no
longer be sorted by the numeric value of their Unix time.
2025-06-29 20:30:39 +02:00
27c4720328 Fix changes not being detected in SelectDropdown
When modifying the set instead of replacing it with a new set the change
detection logic in Vue.js doesn't properly propagate the change, causing
certain computed properties that depend on them to go stale.

Fix by creating a new set here, which will emit a modelValue:update
event which will propagate through the v-model bindings.
2025-06-29 20:26:32 +02:00
0c5b4c756f Make the first user created an admin
All checks were successful
/ build (push) Successful in 1m31s
/ deploy (push) Successful in 16s
To easily bootstrap of administration of the system make the first
regular user account created into an admin account.
2025-06-28 01:30:39 +02:00
e5e923bc8d Implement database administration
Add routes and admin panel elements for creating a database backup,
restoring from a backup, deleting the existing schedule, and replacing
the database with the demo schedule.  These server as crude ways to
manage the data stored in the system.
2025-06-28 01:30:39 +02:00
b2f48e98e0 Add API utility for requiring an admin session 2025-06-28 00:55:26 +02:00
b0d5cdf791 Refactor slot editing to use searchable selections
All checks were successful
/ build (push) Successful in 1m36s
/ deploy (push) Successful in 16s
Instead of having to type in exactly the name of events or shifts and
then hope you remembered it right, replace these interactions with the
custom select component that gives a complete list of the available
choices and allows quickly searching for the right one.
2025-06-27 18:59:23 +02:00
da65103e05 Use toRaw when calling Set.difference
Vue's proxy handling interferres with the new Set methods causing them
to throw a TypeError when used on Set objects that are replaced by
proxies. Workaround by dropping the proxy when using these.

See https://github.com/vuejs/core/issues/11398
2025-06-27 18:52:16 +02:00
73b28834a1 Allow orphaned event and shit slots
When editing the slots of events and shifts there are certain situations
where the event or shift a slot should belong to becomes unclear or
difficult to reliably assign.  For example when adding a new slot in the
UI it may be desirable to do so before the user has input the event
or shift the slot should belong to.

In these cases, not being able to store the slot into the schedule makes
the UI logic needlessly complicated.  Allow slots to be added that do
not have its assiated relation linked up to make editing and handling
such scenarios easier.
2025-06-27 18:34:37 +02:00
d49ed38185 Add custom select component
The selection of locations, events, roles, shifts and users using the
native <select> element makes for awkward and difficult interactions.
Add an alternative select control that fixes the issues with the poor
handling and navigation of the control when having many options.

The custom select component can handle the selection of either one or
many entity from a ClientMap of entiteis with a name. Typing into the
text box searches the entities by name, arrow keys can navigate and
enter confirms the chosen entity by toggling it's presence in the
selection.
2025-06-27 18:20:24 +02:00
3f9f218ed0 Add composable for string sort and search
To avoid hydration matches string operations need to do the same thing
on the client and server. Add utilities for performing sorting and fuzzy
matching of strings that uses the account's locale.
2025-06-27 18:13:51 +02:00
016930f933 Render overlapping events/shifts in separate rows
All checks were successful
/ build (push) Successful in 1m33s
/ deploy (push) Successful in 15s
Instead of merging overlapping events and shifts when displaying them in
the timetable which causes a very confusing display, add new rows when
events overlap so that each event can be fully displayed without any
overlapping in the table.
2025-06-25 15:38:47 +02:00
5662b890de Fix userStore fetching when not allowed
All checks were successful
/ build (push) Successful in 1m32s
/ deploy (push) Successful in 26s
Fix userStore attempting to fetch the users list when it's either not
logged in or not allowed to fetch the users, causing the schedule page
to not render.
2025-06-24 16:18:28 +02:00
e01e162367 Add About page with info about the project
Provide a rudimentary description of what this project does, existing
features and future planned work.
2025-06-24 16:00:55 +02:00
9299fa2682 Add cards for shifts 2025-06-24 15:41:53 +02:00
afd7aeea04 De-duplicate serverUserToApi
All checks were successful
/ build (push) Successful in 1m32s
/ deploy (push) Successful in 15s
2025-06-24 15:31:47 +02:00
985b8e0950 Refactor base types for entities and tombstones
Rename the base Entity type to ApiEntity, and the base EntityToombstone
to ApiTombstone to better reflect the reality that its only used in the
API interface and that the client and server types uses its own base if
any.

Remove EntityLiving and pull EntityTombstone out of of the base entity
type so that the types based on ApiEntity are always living entities and
if it's possible for it to contain tombstone this will be explicitly
told with the type including a union with ApiTombstone.

Refactor the types of the ClientEntity and ClientMap to better reflect
the types of the entities it stores and converts to/from.
2025-06-24 15:19:11 +02:00
e3ff872b5c Refactor ClientSchedule to mutable types
All checks were successful
/ build (push) Successful in 1m30s
/ deploy (push) Successful in 16s
Use a single mutable location, event, slot, etc, for each unique
resource that keeps track of the local editable client copy and
the server copy of the data contained in it.

This makes it much simpler to update these data structures as I can take
advantage of the v-model bindings in Vue.js and work with the system
instead of against it.
2025-06-24 00:07:18 +02:00
d48fb035b4 Remove type from Api serialisation of ClientMap
All checks were successful
/ build (push) Successful in 1m34s
/ deploy (push) Successful in 16s
Move the logic that converts the EntityClass of a map to a string and
then back into the class to the payload plugin in order to avoid a
circular dependency where the ClientMap needs to know the entity classes
and the entity classes needs to know the ClientMap.

The only place that doesn't know the type of the entities stored in the
client map is the payload reviver, so it makes sense to keep this logic
contained to the payload plugin.
2025-06-23 18:17:23 +02:00
930d93a95f Fix typo in deleteDatabase function 2025-06-23 12:55:06 +02:00
b1053a95ba Fix import statements
Remove unused or unneeded imports and change imports of luxon APIs to
use the wrapper.
2025-06-23 12:54:09 +02:00
87525a6ef5 Add admin page that can edit users
All checks were successful
/ build (push) Successful in 1m30s
/ deploy (push) Successful in 16s
Add admin page that's only accessible to admins with a listing of users
and the ability to edit the access types of those users.
2025-06-23 00:28:59 +02:00
3be7f8be05 Refactor user storage and update
Rename accounts to users to be consistent with the new naming scheme
where account only referes to the logged in user of the session and
implement live updates of users via a user store which listens for
updates from the event stream.
2025-06-23 00:28:58 +02:00
6336ccdb96 Implement mutable mapping for client entities
Create a simple Map like class for storing and keeping track of client
entities that are synced from the server and have local editable state.
This will form the basis for storing entities on the client and should
replace the immutable concept used be the ClientSchedule class.
2025-06-23 00:28:58 +02:00
5edea4dd72 Implement ClientUser based on a new concept
Create a new mutable ClientEntity type and implement ClientUser on top
of it. The mutable concept is intended to replace the immutable concept
used by the ClientSchedule entities as updating immutable types in a
deep interconnected structure is a lot of hassle for little benefit.
2025-06-23 00:28:58 +02:00
ebf7bdcc9c Add line indicating now to Timetable
All checks were successful
/ build (push) Successful in 1m33s
/ deploy (push) Successful in 16s
Add a red vertical line indicated the current time and date in the
timetable with the label "now" on top of it.
2025-06-18 18:17:03 +02:00
bea8e77742 Shift hour display to be on the lines
The hour headers indicate the time on the left line of the cell, this
makes them confusing to read. Shift the displayed hour to be in the
middle of the left line of the cell so that it is clear which line is
the start of which hour.
2025-06-18 15:13:18 +02:00
a087172d39 Add vue-tsc for running TypeScript typechecks
All checks were successful
/ build (push) Successful in 2m57s
/ deploy (push) Successful in 17s
The nuxi typecheck command requires vue-tsc to work.  Add it to the
project so the command doesn't ask to install it.
2025-06-18 01:02:58 +02:00
e821100987 Add back wrongly removed shiftSlotFilter 2025-06-18 01:00:51 +02:00
bfb9acaa78 Use a stable scroll gutter
All checks were successful
/ build (push) Successful in 1m32s
/ deploy (push) Successful in 16s
Prevent horizontal page shifts when switching tabs due to the scrollbar
changing visibility.
2025-06-18 00:24:51 +02:00
6ef3800a53 Organise edit page into tabs
Use tabs for the various sections on the edit page so that the schedule
timetable is more easily visible at the same time as the editable tables.
2025-06-18 00:24:45 +02:00
7a95d6c3c4 Use prefix notation for component names
Start component names with the kind of element it creates on the page
(button, input, table, card, etc), then follow it with an hierarchy like
set of parts describing what part of the system it operates on.

This makes related components stick together in the directory listing of
components and auto-complete work better.
2025-06-17 22:29:16 +02:00
f4f23e6c18 Validate timezone with normalizeZone
All checks were successful
/ build (push) Successful in 1m29s
/ deploy (push) Successful in 16s
Instead of constructing a new DateTime object and seeing if it
succeeded, validate the client's timezone selection using the
Info.normalizeZone utility function.  This prevents throwing an
unexpected error creating the DateTime object after the change
in e100555 to throw on invalid dates.
2025-06-14 19:26:58 +02:00
bb450fd583 Refactor to use ClientSchedule on client
Use the ClientSchedule data structure for deserialising and tracking
edit state on the client instead of trying to directly deal with the
ApiSchedule type which is not build for ease of edits or rendering.
2025-06-14 19:22:53 +02:00
ce9f758f84 Implement editing of slots in ClientSchedule
Implement tracking of time slots along with editing and restoration of
singularly edited time slots.  This provides a simpler interface to work
with when rendering tables of time slots that can be edited than
directly manipulating events and shifts containing an array of slots.
2025-06-14 19:12:31 +02:00
73bb12c104 Add payload plugin for ClientSchedule
All checks were successful
/ build (push) Successful in 1m29s
/ deploy (push) Successful in 16s
Add plugin to serialise ClientSchedule objects as JSON when it's passed
from the server to client on SSR requests.
2025-06-13 22:01:42 +02:00
fb7a60db28 Add per account locale setting
Add a per user account setting for the locale so that the server can
correctly render pages with localized time formatting.
2025-06-13 21:50:22 +02:00
fad1bb2482 Ignore updatedAt timestamp when comparing entities
All checks were successful
/ build (push) Successful in 1m28s
/ deploy (push) Successful in 16s
To determine if the entity received from the server is the same as the
entity the client has the equals method is use.  To avoid problems with
clients that have incorrect clocks the timestamp is overriden with the
server's time when the entities are saved on the server.

This means that the entities received back from the server when the
client saves will have different timestamps than what the client set.
Ignore the updatedAt timestamp when comparing entities for equality so
that the update logic correctly replaces entities that only differ by
the update timestamp.
2025-06-13 21:06:48 +02:00
8c63c1cfbb Fix sanity checks failing on deleted entities
If the event/shift that a location/role was referencing had been marked
for deletion the sanity check would incorrectly refuse to delete the
event/role.  Fix by ignoring deleted events/shifts.
2025-06-13 20:51:24 +02:00
61734d4152 Add editing of client schedule entities
Add utility methods to more easily edit the fields of a single entity in
the schedule, along with a modification flag and is modified utility to
check for changes having been made.
2025-06-13 20:49:04 +02:00
faffe48706 Use TypeScript private modifier for methods
The Vue Ref system and assiated proxies does not work with the native
EcmaScript private fields, replace them with the TypeScript access
modifiers which are regular fields under the hood.
2025-06-13 17:04:55 +02:00
e100555304 Implement ClientSchedule state tracking class
All checks were successful
/ build (push) Successful in 2m16s
/ deploy (push) Successful in 16s
Write the logic of keeping track of location modifications and applying
updates from the server into the ClientSchedule class.  This should
serve as the foundation for replacing the prototype in-component update
logic which have turned into an unmaintainable spagetti.
2025-06-12 21:48:50 +02:00
aa52a6c651 Setup vitest
Done according to https://nuxt.com/docs/getting-started/testing
2025-06-12 21:38:47 +02:00
75abd82f81 Workaround issue with VSCode Nuxtr
When the object passed to defineNuxtConfig contains logic for enable
devtools option the Nuxtr plugin annoyingly shows an endlessly spinning
orb on the statusline.
2025-06-12 14:01:50 +02:00
fe06d0d6bd Refactor API types and sync logic
All checks were successful
/ build (push) Successful in 2m5s
/ deploy (push) Successful in 16s
Rename and refactor the types passed over the API to be based on an
entity that's either living or a tombstone.  A living entity has a
deleted property that's either undefined or false, while a tombstone
has a deleted property set to true.  All entities have a numeric id
and an updatedAt timestamp.

To sync entities, an array of replacements are passed around. Living
entities are replaced with tombstones when they're deleted. And
tombstones are replaced with living entities when restored.
2025-06-11 21:05:17 +02:00
251e83f640 Rename AcountSession to ServerSession
All checks were successful
/ build (push) Successful in 1m12s
/ deploy (push) Successful in 16s
Start the work of clearly distingushing client side types, server side
types and types shared over the API by renaming "AccountSession" and
"Session" names used on the server to "ServerSession".
2025-06-09 16:51:05 +02:00
16191a8dd2 Add debug route to delete the database
All checks were successful
/ build (push) Successful in 1m15s
/ deploy (push) Successful in 16s
To simplify development add a debug route to delete the database content
so that it'll be re-generated to the demo schedule.
2025-05-31 23:10:25 +02:00