From cd954f1596863214c7cd0fb274a5f0281d5c714c Mon Sep 17 00:00:00 2001 From: philipp lang Date: Sun, 11 Apr 2021 02:55:26 +0200 Subject: [PATCH] Add table --- app/Member/MemberController.php | 2 +- app/Member/MemberResource.php | 11 +++- package.json | 2 - resources/img/sprite.svg | 2 +- resources/img/svg/check.svg | 1 + resources/img/svg/close.svg | 1 + resources/js/app.js | 4 ++ resources/js/components/Pages.vue | 63 +++++++++++++++++++++ resources/js/components/VBool.vue | 19 +++++++ resources/js/layouts/App.vue | 8 ++- resources/js/mixins/mergesQueryString.js | 24 ++++++++ resources/js/views/member/Index.vue | 70 ++++++++++++++++-------- 12 files changed, 178 insertions(+), 29 deletions(-) create mode 100644 resources/img/svg/check.svg create mode 100644 resources/img/svg/close.svg create mode 100644 resources/js/components/Pages.vue create mode 100644 resources/js/components/VBool.vue create mode 100644 resources/js/mixins/mergesQueryString.js diff --git a/app/Member/MemberController.php b/app/Member/MemberController.php index 8e528f1b..28c84d0b 100644 --- a/app/Member/MemberController.php +++ b/app/Member/MemberController.php @@ -12,7 +12,7 @@ class MemberController extends Controller session()->put('title', 'Mitglieder'); return \Inertia::render('member/Index', [ - 'data' => MemberResource::collection(Member::search($request->query('search', null))->paginate(20)) + 'data' => MemberResource::collection(Member::search($request->query('search', null))->paginate(15)) ]); } } diff --git a/app/Member/MemberResource.php b/app/Member/MemberResource.php index 99c95a72..20a49e8d 100644 --- a/app/Member/MemberResource.php +++ b/app/Member/MemberResource.php @@ -14,6 +14,15 @@ class MemberResource extends JsonResource */ public function toArray($request) { - return parent::toArray($request); + return [ + 'firstname' => $this->firstname, + 'lastname' => $this->lastname, + 'address' => $this->address, + 'zip' => $this->zip, + 'location' => $this->location, + 'send_newspaper' => $this->send_newspaper, + 'birthday' => $this->birthday->format('d.m.Y'), + 'joined_at' => $this->joined_at->format('d.m.Y'), + ]; } } diff --git a/package.json b/package.json index 52f6ebca..7319c369 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,6 @@ "prod": "npm run production", "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", "img": "rm -R public/img && cd resources/img/svg && svg-sprite -s --symbol-dest=sprite *.svg && mv sprite/svg/sprite.symbol.svg ../sprite.svg && rm -R sprite && cd ../../../ && cp -R resources/img public/img" - - }, "devDependencies": { "laravel-mix": "^6.0.1", diff --git a/resources/img/sprite.svg b/resources/img/sprite.svg index e8cda8dd..84411f59 100644 --- a/resources/img/sprite.svg +++ b/resources/img/sprite.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/resources/img/svg/check.svg b/resources/img/svg/check.svg new file mode 100644 index 00000000..135fa67a --- /dev/null +++ b/resources/img/svg/check.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/resources/img/svg/close.svg b/resources/img/svg/close.svg new file mode 100644 index 00000000..224fff34 --- /dev/null +++ b/resources/img/svg/close.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/resources/js/app.js b/resources/js/app.js index 4d1c009c..f99335f5 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -6,10 +6,14 @@ window.io = require('socket.io-client'); import Sprite from './components/Sprite.js'; import FText from './components/FText.vue'; +import Pages from './components/Pages.vue'; +import VBool from './components/VBool.vue'; Vue.use(plugin) Vue.component('f-text', FText); Vue.component('sprite', Sprite); +Vue.component('pages', Pages); +Vue.component('v-bool', VBool); const el = document.getElementById('app') diff --git a/resources/js/components/Pages.vue b/resources/js/components/Pages.vue new file mode 100644 index 00000000..4684a621 --- /dev/null +++ b/resources/js/components/Pages.vue @@ -0,0 +1,63 @@ + + + diff --git a/resources/js/components/VBool.vue b/resources/js/components/VBool.vue new file mode 100644 index 00000000..1d8d1365 --- /dev/null +++ b/resources/js/components/VBool.vue @@ -0,0 +1,19 @@ + + + diff --git a/resources/js/layouts/App.vue b/resources/js/layouts/App.vue index 34450e1a..cfd96c96 100644 --- a/resources/js/layouts/App.vue +++ b/resources/js/layouts/App.vue @@ -9,8 +9,12 @@ -
- +
+
+ +
+ +
diff --git a/resources/js/mixins/mergesQueryString.js b/resources/js/mixins/mergesQueryString.js new file mode 100644 index 00000000..a2690a9f --- /dev/null +++ b/resources/js/mixins/mergesQueryString.js @@ -0,0 +1,24 @@ +import queryString from 'query-string'; + +export default { + methods: { + qs(merge) { + var c = queryString.parse(window.location.search); + + var m = { ...c, ...merge }; + var mn = {}; + + Object.keys(m).forEach((k) => { + console.log(m[k]); + if (m[k] !== null && !isNaN(m[k])) { + mn[k] = m[k]; + } + }); + + var merged = queryString.stringify(mn); + + return window.location.pathname + (merged ? '?'+merged : ''); + } + } +}; + diff --git a/resources/js/views/member/Index.vue b/resources/js/views/member/Index.vue index da68ae8d..7f969fe1 100644 --- a/resources/js/views/member/Index.vue +++ b/resources/js/views/member/Index.vue @@ -1,33 +1,59 @@ +