feat(posts): multi-select label filter on the posts list#34
Merged
Conversation
Adds a combobox-style filter to the posts index toolbar so users can
narrow All / Scheduled / Posted / Drafts views by one or more labels.
- `PostController::index` accepts `?labels[]=<id>` and applies
`whereHas('labels', whereIn(...))` (OR semantics across selected labels).
Workspace labels are exposed to the page (sorted by name) and the
selected set comes back under `filters.labels`.
- New `LabelFilter.vue` component reuses the existing Popover + Command
pattern (matching `FontPicker` in the Brand settings page). Trigger
renders the selected `LabelBadge`s inline (mirroring how each post row
already displays its labels): 1-3 shown directly, 4+ shown as the
first three plus a "+N" overflow indicator. Clear button has a
tooltip and `cursor-pointer`, and stops `click`/`pointerdown`/
`mousedown` so it doesn't reopen the Popover.
- Existing search debounce is shared with the new label watcher via a
single `buildFilterUrl` helper. URL is updated with `preserveState +
replace` so the back stack stays clean.
- i18n in en / pt-BR / es: `filter_by_label`, `label_search_placeholder`,
`no_labels`, `clear_label_filter`.
Tests: 4 new index tests covering the labels prop exposure, single-label
filter, multi-label OR filter, and blank-id sanitization. Full suite:
1509 passed, 2 skipped, 0 failed.
Same semantics, more idiomatic Laravel. Drops the (array) cast, the array_values+array_filter pair, and the if (!empty(...)) guard in favor of $request->collect() + Collection pipeline + $query->when() conditional clause.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Posts list (
/postsand its/scheduled//posted//draftsvariants) was already showing labels on each row but had no way to filter by label. Users with many labels had to scroll or use search-by-content as a workaround.Summary
FontPicker.vue— same UX pattern, no new dependency.+N.Xbutton with tooltip andcursor-pointer. Three event stops (click,pointerdown,mousedown) so it doesn't reopen the Popover (the bug we hit during review).preserveState + replaceso back-button history stays clean.Files
app/Http/Controllers/App/PostController.phpindex()accepts?labels[]=<id>and applieswhereHas+whereIn. Sanitizes blank/empty entries. Exposeslabels(workspace labels sorted by name) andfilters.labelsto the page.resources/js/components/labels/LabelFilter.vue(new)resources/js/pages/posts/Index.vueselectedLabelIdsmodel, watcher shared withsearchvia a singlebuildFilterUrlhelperlang/{en,pt-BR,es}/posts.phpfilter_by_label,label_search_placeholder,no_labels,clear_label_filtertests/Feature/PostControllerTest.phpTest plan
php artisan test --compact --parallel— 1509 passed, 2 skipped, 0 failed (+4 over main)