Conversation
- Add /tags admin page for dispatchers to manage rider tags - Tags can be marked as restricted, hiding them from riders on their profile - Restricted tags are shown with a lock icon in the dispatcher view - Riders can only see and modify non-restricted tags on their profile - Remove inline tag creation from rider edit form (use Tags page instead) - Add Tags link to sidebar navigation
- Add tag fixture in test/support/fixtures.ex for creating test tags - Add context tests in riders_test.exs for tag CRUD operations: - create_tag, update_tag, delete_tag - list_tags, list_tags_with_rider_count - toggle_tag_restricted, change_tag, get_tag!, search_tags - Create tag_live_test.exs for Tags admin page: - List tags with name, restricted status, and rider count - Create, edit, delete tags via modals - Toggle restricted status inline - Access control for non-dispatchers - Add tag visibility tests in rider_live_test.exs: - Dispatcher can see all tags including restricted - Rider cannot see restricted tags on profile - Rider cannot see restricted tags in edit form
teesloane
left a comment
There was a problem hiding this comment.
Added a few optional nits and comments but can be merged without.
| <span | ||
| class={[ | ||
| "my-0.5 inline-flex items-center px-2.5 py-1.5 rounded-md text-md font-medium cursor-pointer hover:bg-gray-200", | ||
| if(tag.restricted, do: "bg-gray-200 text-gray-500", else: "bg-gray-100 text-gray-500") | ||
| ]} | ||
| phx-click={JS.push("select", value: %{name: tag.name}, target: @myself)} | ||
| > | ||
| <Heroicons.plus mini class="w-4 h-4 mr-1" /> | ||
| {tag.name} | ||
| <Heroicons.lock_closed :if={tag.restricted} mini class="w-4 h-4 ml-1 text-amber-600" /> |
There was a problem hiding this comment.
Not required but we could make this a "dumb component" to tidy up a bit.
| <.header> | ||
| Tags | ||
| <:subtitle> | ||
| Manage rider tags. Restricted tags are hidden from riders on their profile. |
There was a problem hiding this comment.
Is it worth saying why one might want to add rider tags / how they are used?
| <% visible_tags = | ||
| if @current_user.is_dispatcher, | ||
| do: @rider.tags, | ||
| else: Enum.reject(@rider.tags, & &1.restricted) %> |
There was a problem hiding this comment.
Opinion: normally I think it's fine to assign variables in template code, but since we're dealing with content that may be restricted, it might be worth pulling this out into a function and putting it in rider_live/show.ex
There was a problem hiding this comment.
FWIW this is still executed in the server (e.g. the security consideration doesn't apply here afaik, based on the liveview design) but I think it's correct for code quality
Co-authored-by: Ty <12987958+teesloane@users.noreply.github.com>
Describe your changes
Editing a riders' tags

When not a dispatcher you don't see restricted tags

Checklist before requesting a review
about this update in the description above.