From d41aa466b1fe23906b98ce580fd6642e494e74b8 Mon Sep 17 00:00:00 2001 From: Philipp Lang Date: Wed, 14 Jun 2023 17:10:50 +0200 Subject: [PATCH] Add member filter --- app/Member/Actions/SearchAction.php | 8 +-- .../member => components/ui}/AgeGroups.vue | 14 +--- resources/js/mixins/indexHelpers.js | 5 +- .../maildispatcher/MaildispatcherForm.vue | 68 ++++++++++++++----- resources/js/views/member/VIndex.vue | 9 ++- 5 files changed, 65 insertions(+), 39 deletions(-) rename resources/js/{views/member => components/ui}/AgeGroups.vue (61%) diff --git a/app/Member/Actions/SearchAction.php b/app/Member/Actions/SearchAction.php index 2a2677a0..9bfd9870 100644 --- a/app/Member/Actions/SearchAction.php +++ b/app/Member/Actions/SearchAction.php @@ -5,8 +5,8 @@ namespace App\Member\Actions; use App\Member\FilterScope; use App\Member\Member; use App\Member\MemberResource; -use Illuminate\Database\Eloquent\Collection; use Illuminate\Http\Resources\Json\AnonymousResourceCollection; +use Illuminate\Pagination\LengthAwarePaginator; use Lorisleiva\Actions\ActionRequest; use Lorisleiva\Actions\Concerns\AsAction; @@ -15,14 +15,14 @@ class SearchAction use AsAction; /** - * @return Collection + * @return LengthAwarePaginator */ - public function handle(FilterScope $filter): Collection + public function handle(FilterScope $filter): LengthAwarePaginator { return Member::search($filter->search)->query(fn ($q) => $q->select('*') ->withFilter($filter) ->ordered() - )->get(); + )->paginate(15); } public function asController(ActionRequest $request): AnonymousResourceCollection diff --git a/resources/js/views/member/AgeGroups.vue b/resources/js/components/ui/AgeGroups.vue similarity index 61% rename from resources/js/views/member/AgeGroups.vue rename to resources/js/components/ui/AgeGroups.vue index 438a13d3..6d38af07 100644 --- a/resources/js/views/member/AgeGroups.vue +++ b/resources/js/components/ui/AgeGroups.vue @@ -1,17 +1,7 @@ diff --git a/resources/js/mixins/indexHelpers.js b/resources/js/mixins/indexHelpers.js index d29e800c..3148d654 100644 --- a/resources/js/mixins/indexHelpers.js +++ b/resources/js/mixins/indexHelpers.js @@ -9,10 +9,13 @@ export default { }, computed: { filterString() { - return btoa(encodeURIComponent(JSON.stringify(this.inner.meta.filter))); + return this.toFilterString(this.inner.meta.filter); }, }, methods: { + toFilterString(data) { + return btoa(encodeURIComponent(JSON.stringify(data))); + }, reload(resetPage = true) { var _self = this; var data = { diff --git a/resources/js/views/maildispatcher/MaildispatcherForm.vue b/resources/js/views/maildispatcher/MaildispatcherForm.vue index 0624f898..15a899d0 100644 --- a/resources/js/views/maildispatcher/MaildispatcherForm.vue +++ b/resources/js/views/maildispatcher/MaildispatcherForm.vue @@ -7,31 +7,62 @@
- - + +
- -
-
- - - - - -
-
+ + + + + + + + + + + + + + + + + + + diff --git a/resources/js/views/member/VIndex.vue b/resources/js/views/member/VIndex.vue index fc1ba875..30c5b1b2 100644 --- a/resources/js/views/member/VIndex.vue +++ b/resources/js/views/member/VIndex.vue @@ -71,7 +71,7 @@ - + @@ -92,7 +92,7 @@
- +
@@ -153,9 +153,8 @@ export default { MemberMemberships, MemberPayments, MemberCourses, - 'age-groups': () => import('./AgeGroups.vue'), - 'tags': () => import('./Tags.vue'), - 'actions': () => import('./index/Actions.vue'), + tags: () => import('./Tags.vue'), + actions: () => import('./index/Actions.vue'), }, methods: {