From 55ef4efe503d4f589ee3ac09b299f339761fce9f Mon Sep 17 00:00:00 2001 From: philipp lang Date: Tue, 2 May 2023 23:13:00 +0200 Subject: [PATCH] Remove toolbars --- app/Activity/Actions/CreateAction.php | 3 +++ app/Activity/Actions/IndexAction.php | 3 --- app/Activity/Resources/ActivityResource.php | 4 ++++ app/Http/Views/MemberView.php | 1 - app/Member/Actions/MemberShowAction.php | 2 +- app/Member/MemberController.php | 7 ++---- app/Member/MemberResource.php | 6 +++++ app/Payment/SubscriptionController.php | 3 ++- app/Payment/SubscriptionResource.php | 16 +++++++++++++ resources/js/app.js | 2 ++ resources/js/components/Page/Layout.vue | 7 +----- resources/js/components/Ui/ToolbarButton.vue | 23 +++++++++++++++++++ resources/js/views/activity/VForm.vue | 3 +++ resources/js/views/activity/VIndex.vue | 3 +++ resources/js/views/member/ShowView.vue | 4 ++++ resources/js/views/member/VForm.vue | 4 ++++ resources/js/views/member/VIndex.vue | 8 ++++++- .../views/subscription/SubscriptionForm.vue | 10 ++++---- .../views/subscription/SubscriptionIndex.vue | 5 +++- 19 files changed, 90 insertions(+), 24 deletions(-) create mode 100644 resources/js/components/Ui/ToolbarButton.vue diff --git a/app/Activity/Actions/CreateAction.php b/app/Activity/Actions/CreateAction.php index ce60a787..5d8755b0 100644 --- a/app/Activity/Actions/CreateAction.php +++ b/app/Activity/Actions/CreateAction.php @@ -13,6 +13,9 @@ class CreateAction public function handle(): Response { + session()->put('menu', 'activity'); + session()->put('title', 'Tätigkeit erstellen'); + return Inertia::render('activity/VForm', [ 'meta' => ActivityResource::meta(), 'data' => [ diff --git a/app/Activity/Actions/IndexAction.php b/app/Activity/Actions/IndexAction.php index 58c98ff3..5c194231 100644 --- a/app/Activity/Actions/IndexAction.php +++ b/app/Activity/Actions/IndexAction.php @@ -28,9 +28,6 @@ class IndexAction return Inertia::render('activity/VIndex', [ 'data' => $this->handle($filter), - 'toolbar' => [ - ['href' => route('activity.create'), 'label' => 'Tätigkeit erstellen', 'color' => 'primary', 'icon' => 'plus'], - ], ]); } } diff --git a/app/Activity/Resources/ActivityResource.php b/app/Activity/Resources/ActivityResource.php index 341b1612..54b38d05 100644 --- a/app/Activity/Resources/ActivityResource.php +++ b/app/Activity/Resources/ActivityResource.php @@ -52,6 +52,10 @@ class ActivityResource extends JsonResource return [ 'subactivities' => SubactivityResource::collectionWithoutMeta(Subactivity::get()), 'filter' => ActivityFilterScope::fromRequest(request()->input('filter')), + 'links' => [ + 'index' => route('activity.index'), + 'create' => route('activity.create'), + ], ]; } } diff --git a/app/Http/Views/MemberView.php b/app/Http/Views/MemberView.php index c16e3017..a407f856 100644 --- a/app/Http/Views/MemberView.php +++ b/app/Http/Views/MemberView.php @@ -29,7 +29,6 @@ class MemberView )->paginate(15)), 'filterActivities' => Activity::where('is_filterable', true)->pluck('name', 'id'), 'filterSubactivities' => Subactivity::where('is_filterable', true)->pluck('name', 'id'), - 'toolbar' => [['href' => route('member.index'), 'label' => 'Zurück', 'color' => 'primary', 'icon' => 'plus']], 'paymentDefaults' => ['nr' => date('Y')], 'subscriptions' => Subscription::pluck('name', 'id'), 'statuses' => Status::pluck('name', 'id'), diff --git a/app/Member/Actions/MemberShowAction.php b/app/Member/Actions/MemberShowAction.php index 4f24eb9a..0ff44be3 100644 --- a/app/Member/Actions/MemberShowAction.php +++ b/app/Member/Actions/MemberShowAction.php @@ -26,7 +26,7 @@ class MemberShowAction ->load('subscription') ->load('courses.course') ), - 'toolbar' => [['href' => route('member.index'), 'label' => 'Zurück', 'color' => 'primary', 'icon' => 'undo']], + 'meta' => MemberResource::meta(), ]; } diff --git a/app/Member/MemberController.php b/app/Member/MemberController.php index fdaf36ac..fb786e20 100644 --- a/app/Member/MemberController.php +++ b/app/Member/MemberController.php @@ -27,11 +27,6 @@ class MemberController extends Controller session()->put('title', 'Mitglieder'); $payload = app(MemberView::class)->index($request); - $payload['toolbar'] = [ - ['href' => route('member.create'), 'label' => 'Mitglied anlegen', 'color' => 'primary', 'icon' => 'plus'], - ['href' => route('allpayment.page'), 'label' => 'Rechnungen erstellen', 'color' => 'primary', 'icon' => 'invoice', 'show' => $settings->hasModule('bill')], - ['href' => route('sendpayment.create'), 'label' => 'Rechnungen versenden', 'color' => 'info', 'icon' => 'envelope', 'show' => $settings->hasModule('bill')], - ]; $payload['billKinds'] = BillKind::forSelect(); return \Inertia::render('member/VIndex', $payload); @@ -65,6 +60,7 @@ class MemberController extends Controller 'more_ps_at' => null, ], 'mode' => 'create', + 'meta' => MemberResource::meta(), ]); } @@ -97,6 +93,7 @@ class MemberController extends Controller 'data' => new MemberResource($member), 'mode' => 'edit', 'conflict' => '1' === $request->query('conflict', '0'), + 'meta' => MemberResource::meta(), ]); } diff --git a/app/Member/MemberResource.php b/app/Member/MemberResource.php index fda33d14..04acc7f4 100644 --- a/app/Member/MemberResource.php +++ b/app/Member/MemberResource.php @@ -106,6 +106,12 @@ class MemberResource extends JsonResource return [ 'groups' => NestedGroup::cacheForSelect(), 'filter' => FilterScope::fromRequest(request()->input('filter', '')), + 'links' => [ + 'index' => route('member.index'), + 'create' => route('member.create'), + 'allpayment' => route('allpayment.page'), + 'sendpayment' => route('sendpayment.create'), + ], ]; } } diff --git a/app/Payment/SubscriptionController.php b/app/Payment/SubscriptionController.php index 816f0546..6bd184db 100644 --- a/app/Payment/SubscriptionController.php +++ b/app/Payment/SubscriptionController.php @@ -17,7 +17,6 @@ class SubscriptionController extends Controller return \Inertia::render('subscription/SubscriptionIndex', [ 'data' => SubscriptionResource::collection(Subscription::get()), - 'toolbar' => [['href' => route('subscription.create'), 'label' => 'Beitrag anlegen', 'color' => 'primary', 'icon' => 'plus']], ]); } @@ -32,6 +31,7 @@ class SubscriptionController extends Controller 'data' => [ 'children' => [], ], + 'meta' => SubscriptionResource::meta(), ]); } @@ -68,6 +68,7 @@ class SubscriptionController extends Controller 'fees' => Fee::pluck('name', 'id'), 'mode' => 'edit', 'data' => new SubscriptionResource($subscription), + 'meta' => SubscriptionResource::meta(), ]); } diff --git a/app/Payment/SubscriptionResource.php b/app/Payment/SubscriptionResource.php index cfd4395a..78f1132b 100644 --- a/app/Payment/SubscriptionResource.php +++ b/app/Payment/SubscriptionResource.php @@ -2,6 +2,7 @@ namespace App\Payment; +use App\Lib\HasMeta; use Illuminate\Http\Resources\Json\JsonResource; /** @@ -9,6 +10,8 @@ use Illuminate\Http\Resources\Json\JsonResource; */ class SubscriptionResource extends JsonResource { + use HasMeta; + /** * Transform the resource into an array. * @@ -30,4 +33,17 @@ class SubscriptionResource extends JsonResource 'for_promise' => $this->for_promise, ]; } + + /** + * @return array + */ + public static function meta(): array + { + return [ + 'links' => [ + 'index' => route('subscription.index'), + 'create' => route('subscription.create'), + ], + ]; + } } diff --git a/resources/js/app.js b/resources/js/app.js index a30f9e6d..d3ce8eaa 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -9,6 +9,7 @@ import VBool from './components/VBool.vue'; import Box from './components/Box.vue'; import Heading from './components/Heading.vue'; import IconButton from './components/Ui/IconButton.vue'; +import ToolbarButton from './components/Ui/ToolbarButton.vue'; import PageLayout from './components/Page/Layout.vue'; import AppLayout from './layouts/AppLayout.vue'; import VTooltip from 'v-tooltip'; @@ -37,6 +38,7 @@ Vue.component('v-label', VLabel); Vue.component('box', Box); Vue.component('heading', Heading); Vue.component('icon-button', IconButton); +Vue.component('toolbar-button', ToolbarButton); Vue.component('page-layout', PageLayout); Vue.component('save-button', () => import(/* webpackChunkName: "form" */ './components/SaveButton')); diff --git a/resources/js/components/Page/Layout.vue b/resources/js/components/Page/Layout.vue index 3f5796e5..80f5bbb5 100644 --- a/resources/js/components/Page/Layout.vue +++ b/resources/js/components/Page/Layout.vue @@ -5,12 +5,7 @@ - +
diff --git a/resources/js/components/Ui/ToolbarButton.vue b/resources/js/components/Ui/ToolbarButton.vue new file mode 100644 index 00000000..75fd38fe --- /dev/null +++ b/resources/js/components/Ui/ToolbarButton.vue @@ -0,0 +1,23 @@ + + + diff --git a/resources/js/views/activity/VForm.vue b/resources/js/views/activity/VForm.vue index 18980369..1bbd6705 100644 --- a/resources/js/views/activity/VForm.vue +++ b/resources/js/views/activity/VForm.vue @@ -1,5 +1,8 @@