Summary
Templates (session_templates) and the exercise library (exercise_library) are currently user-private. Co-instructors at the same gym cannot see or edit each other's templates or exercises, forcing duplicate work and inconsistent muscle mappings. Making both gym-wide lets the team build a shared program library and correct muscle data together.
Priority
High
UI spec (Carbon g100)
- Bibliotek "Mine maler" tab renamed to "Maler" (templates are no longer personal)
- Template cards: show
"Av [display_name]" in var(--cds-font-mono) 11px below exercise/muscle count — only when the creator differs from the current user
- Exercise rows: same attribution below muscle chips
- No permission gating on Edit/Delete buttons — all co-instructors can act on any item
Data model
RLS changes (migration gym_wide_templates_and_exercises):
-- session_templates: INSERT own, SELECT/UPDATE/DELETE same-gym
-- session_template_exercises: ALL via parent template gym check
-- exercise_library: INSERT own, SELECT/UPDATE/DELETE same-gym
-- Same-gym check pattern (mirrors sessions policy):
EXISTS (
SELECT 1 FROM user_gyms ug1
JOIN user_gyms ug2 ON ug2.sporty_business_unit_id = ug1.sporty_business_unit_id
WHERE ug1.user_id = auth.uid()
AND ug2.user_id = <table>.user_id
)
user_id retained on both tables as "created by" for attribution display.
fetchTemplates() and fetchLibraryExercises() updated to join profiles!user_id(display_name).
Acceptance criteria
Out of scope
- Retroactive muscle remapping when an exercise is edited (tracked separately)
- Private/opt-out templates — all templates are gym-wide with no exceptions
- Cross-gym template sharing
Summary
Templates (
session_templates) and the exercise library (exercise_library) are currently user-private. Co-instructors at the same gym cannot see or edit each other's templates or exercises, forcing duplicate work and inconsistent muscle mappings. Making both gym-wide lets the team build a shared program library and correct muscle data together.Priority
High
UI spec (Carbon g100)
"Av [display_name]"invar(--cds-font-mono)11px below exercise/muscle count — only when the creator differs from the current userData model
RLS changes (migration
gym_wide_templates_and_exercises):user_idretained on both tables as "created by" for attribution display.fetchTemplates()andfetchLibraryExercises()updated to joinprofiles!user_id(display_name).Acceptance criteria
touchTemplatesucceeds when using a colleague's template in Planleggeruser_id(cannot create on behalf of another)npm test— 82 tests)user_gymsentry cannot see templates (covered byensureGymMembershipon sign-in)Out of scope