From 1d5c8251d9cfbc8ace1d88eefc5390adb38d2729 Mon Sep 17 00:00:00 2001 From: philipp lang Date: Sun, 22 Aug 2021 04:28:11 +0200 Subject: [PATCH] Fixed: Keep page when opening payment sidebar --- resources/js/mixins/mergesQueryString.js | 18 ++++++++++++++++++ resources/js/views/member/Index.vue | 5 ++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/resources/js/mixins/mergesQueryString.js b/resources/js/mixins/mergesQueryString.js index 3ea230c2..97f64a72 100644 --- a/resources/js/mixins/mergesQueryString.js +++ b/resources/js/mixins/mergesQueryString.js @@ -1,4 +1,5 @@ import queryString from 'query-string'; +import merge from 'merge'; export default { methods: { @@ -17,6 +18,23 @@ export default { var merged = queryString.stringify(mn); return window.location.pathname + (merged ? '?'+merged : ''); + }, + + query(options) { + options = merge({ + only: null, + }, options); + var c = queryString.parse(window.location.search); + + if (options.only !== null) { + for (var k in c) { + if (options.only.indexOf(k) < 0) { + delete c[k]; + } + } + } + + return Object.keys(c).length === 0 ? '' : `?${queryString.stringify(c)}`; } } }; diff --git a/resources/js/views/member/Index.vue b/resources/js/views/member/Index.vue index 325b2b82..06ae69ab 100644 --- a/resources/js/views/member/Index.vue +++ b/resources/js/views/member/Index.vue @@ -46,7 +46,7 @@
- +
@@ -69,11 +69,14 @@ import App from '../../layouts/App'; import Payments from './Payments.vue'; import PaymentForm from './PaymentForm.vue'; +import mergesQueryString from '../../mixins/mergesQueryString.js'; export default { layout: App, + mixins: [mergesQueryString], + components: { Payments, PaymentForm }, methods: {