From c10556b817f022af819bc95962f85dc30abb591d Mon Sep 17 00:00:00 2001 From: Norman Huth Date: Fri, 8 Mar 2024 19:38:33 +0100 Subject: [PATCH] fix: apply filter state after navigate Closes https://github.com/Muetze42/nova-menu/issues/50 --- dist/js/tool.js | 2 +- dist/mix-manifest.json | 2 +- resources/js/components/MainMenu.vue | 9 +++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/dist/js/tool.js b/dist/js/tool.js index aa314c7..8f9b2d8 100644 --- a/dist/js/tool.js +++ b/dist/js/tool.js @@ -1,2 +1,2 @@ /*! For license information please see tool.js.LICENSE.txt */ -(()=>{var e={9680:(e,t,o)=>{function n(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var r=n(o(9669)),a=o(129),l=n(o(9996));function c(){return(c=Object.assign?Object.assign.bind():function(e){for(var t=1;t0&&"back_forward"===window.performance.getEntriesByType("navigation")[0].type},o.handleBackForwardVisit=function(e){var t=this;window.history.state.version=e.version,this.setPage(window.history.state,{preserveScroll:!0,preserveState:!0}).then((function(){t.restoreScrollPositions(),k(e)}))},o.locationVisit=function(e,t){try{window.sessionStorage.setItem("inertiaLocationVisit",JSON.stringify({preserveScroll:t})),window.location.href=e.href,w(window.location).href===w(e).href&&window.location.reload()}catch(e){return!1}},o.isLocationVisit=function(){try{return null!==window.sessionStorage.getItem("inertiaLocationVisit")}catch(e){return!1}},o.handleLocationVisit=function(e){var t,o,n,r,a=this,l=JSON.parse(window.sessionStorage.getItem("inertiaLocationVisit")||"");window.sessionStorage.removeItem("inertiaLocationVisit"),e.url+=window.location.hash,e.rememberedState=null!=(t=null==(o=window.history.state)?void 0:o.rememberedState)?t:{},e.scrollRegions=null!=(n=null==(r=window.history.state)?void 0:r.scrollRegions)?n:[],this.setPage(e,{preserveScroll:l.preserveScroll,preserveState:!0}).then((function(){l.preserveScroll&&a.restoreScrollPositions(),k(e)}))},o.isLocationVisitResponse=function(e){return e&&409===e.status&&e.headers["x-inertia-location"]},o.isInertiaResponse=function(e){return null==e?void 0:e.headers["x-inertia"]},o.createVisitId=function(){return this.visitId={},this.visitId},o.cancelVisit=function(e,t){var o=t.cancelled,n=void 0!==o&&o,r=t.interrupted,a=void 0!==r&&r;!e||e.completed||e.cancelled||e.interrupted||(e.cancelToken.cancel(),e.onCancel(),e.completed=!1,e.cancelled=n,e.interrupted=a,g(e),e.onFinish(e))},o.finishVisit=function(e){e.cancelled||e.interrupted||(e.completed=!0,e.cancelled=!1,e.interrupted=!1,g(e),e.onFinish(e))},o.resolvePreserveOption=function(e,t){return"function"==typeof e?e(t):"errors"===e?Object.keys(t.props.errors||{}).length>0:e},o.visit=function(e,o){var n=this,a=void 0===o?{}:o,l=a.method,i=void 0===l?t.n$.GET:l,u=a.data,v=void 0===u?{}:u,h=a.replace,g=void 0!==h&&h,k=a.preserveScroll,B=void 0!==k&&k,E=a.preserveState,x=void 0!==E&&E,Z=a.only,V=void 0===Z?[]:Z,M=a.headers,A=void 0===M?{}:M,C=a.errorBag,y=void 0===C?"":C,N=a.forceFormData,I=void 0!==N&&N,b=a.onCancelToken,H=void 0===b?function(){}:b,L=a.onBefore,j=void 0===L?function(){}:L,S=a.onStart,O=void 0===S?function(){}:S,P=a.onProgress,D=void 0===P?function(){}:P,_=a.onFinish,T=void 0===_?function(){}:_,R=a.onCancel,U=void 0===R?function(){}:R,F=a.onSuccess,z=void 0===F?function(){}:F,G=a.onError,q=void 0===G?function(){}:G,$=a.queryStringArrayFormat,W=void 0===$?"brackets":$,X="string"==typeof e?p(e):e;if(!function e(t){return t instanceof File||t instanceof Blob||t instanceof FileList&&t.length>0||t instanceof FormData&&Array.from(t.values()).some((function(t){return e(t)}))||"object"==typeof t&&null!==t&&Object.values(t).some((function(t){return e(t)}))}(v)&&!I||v instanceof FormData||(v=s(v)),!(v instanceof FormData)){var Q=m(i,X,v,W),J=Q[1];X=p(Q[0]),v=J}var K={url:X,method:i,data:v,replace:g,preserveScroll:B,preserveState:x,only:V,headers:A,errorBag:y,forceFormData:I,queryStringArrayFormat:W,cancelled:!1,completed:!1,interrupted:!1};if(!1!==j(K)&&function(e){return f("before",{cancelable:!0,detail:{visit:e}})}(K)){this.activeVisit&&this.cancelVisit(this.activeVisit,{interrupted:!0}),this.saveScrollPositions();var Y=this.createVisitId();this.activeVisit=c({},K,{onCancelToken:H,onBefore:j,onStart:O,onProgress:D,onFinish:T,onCancel:U,onSuccess:z,onError:q,queryStringArrayFormat:W,cancelToken:r.CancelToken.source()}),H({cancel:function(){n.activeVisit&&n.cancelVisit(n.activeVisit,{cancelled:!0})}}),function(e){f("start",{detail:{visit:e}})}(K),O(K),r({method:i,url:w(X).href,data:i===t.n$.GET?{}:v,params:i===t.n$.GET?v:{},cancelToken:this.activeVisit.cancelToken.token,headers:c({},A,{Accept:"text/html, application/xhtml+xml","X-Requested-With":"XMLHttpRequest","X-Inertia":!0},V.length?{"X-Inertia-Partial-Component":this.page.component,"X-Inertia-Partial-Data":V.join(",")}:{},y&&y.length?{"X-Inertia-Error-Bag":y}:{},this.page.version?{"X-Inertia-Version":this.page.version}:{}),onUploadProgress:function(e){v instanceof FormData&&(e.percentage=Math.round(e.loaded/e.total*100),function(e){f("progress",{detail:{progress:e}})}(e),D(e))}}).then((function(e){var t;if(!n.isInertiaResponse(e))return Promise.reject({response:e});var o=e.data;V.length&&o.component===n.page.component&&(o.props=c({},n.page.props,o.props)),B=n.resolvePreserveOption(B,o),(x=n.resolvePreserveOption(x,o))&&null!=(t=window.history.state)&&t.rememberedState&&o.component===n.page.component&&(o.rememberedState=window.history.state.rememberedState);var r=X,a=p(o.url);return r.hash&&!a.hash&&w(r).href===a.href&&(a.hash=r.hash,o.url=a.href),n.setPage(o,{visitId:Y,replace:g,preserveScroll:B,preserveState:x})})).then((function(){var e=n.page.props.errors||{};if(Object.keys(e).length>0){var t=y?e[y]?e[y]:{}:e;return function(e){f("error",{detail:{errors:e}})}(t),q(t)}return f("success",{detail:{page:n.page}}),z(n.page)})).catch((function(e){if(n.isInertiaResponse(e.response))return n.setPage(e.response.data,{visitId:Y});if(n.isLocationVisitResponse(e.response)){var t=p(e.response.headers["x-inertia-location"]),o=X;o.hash&&!t.hash&&w(o).href===t.href&&(t.hash=o.hash),n.locationVisit(t,!0===B)}else{if(!e.response)return Promise.reject(e);f("invalid",{cancelable:!0,detail:{response:e.response}})&&d.show(e.response.data)}})).then((function(){n.activeVisit&&n.finishVisit(n.activeVisit)})).catch((function(e){if(!r.isCancel(e)){var t=f("exception",{cancelable:!0,detail:{exception:e}});if(n.activeVisit&&n.finishVisit(n.activeVisit),t)return Promise.reject(e)}}))}},o.setPage=function(e,t){var o=this,n=void 0===t?{}:t,r=n.visitId,a=void 0===r?this.createVisitId():r,l=n.replace,c=void 0!==l&&l,i=n.preserveScroll,d=void 0!==i&&i,u=n.preserveState,s=void 0!==u&&u;return Promise.resolve(this.resolveComponent(e.component)).then((function(t){a===o.visitId&&(e.scrollRegions=e.scrollRegions||[],e.rememberedState=e.rememberedState||{},(c=c||p(e.url).href===window.location.href)?o.replaceState(e):o.pushState(e),o.swapComponent({component:t,page:e,preserveState:s}).then((function(){d||o.resetScrollPositions(),c||k(e)})))}))},o.pushState=function(e){this.page=e,window.history.pushState(e,"",e.url)},o.replaceState=function(e){this.page=e,window.history.replaceState(e,"",e.url)},o.handlePopstateEvent=function(e){var t=this;if(null!==e.state){var o=e.state,n=this.createVisitId();Promise.resolve(this.resolveComponent(o.component)).then((function(e){n===t.visitId&&(t.page=o,t.swapComponent({component:e,page:o,preserveState:!1}).then((function(){t.restoreScrollPositions(),k(o)})))}))}else{var r=p(this.page.url);r.hash=window.location.hash,this.replaceState(c({},this.page,{url:r.href})),this.resetScrollPositions()}},o.get=function(e,o,n){return void 0===o&&(o={}),void 0===n&&(n={}),this.visit(e,c({},n,{method:t.n$.GET,data:o}))},o.reload=function(e){return void 0===e&&(e={}),this.visit(window.location.href,c({},e,{preserveScroll:!0,preserveState:!0}))},o.replace=function(e,t){var o;return void 0===t&&(t={}),console.warn("Inertia.replace() has been deprecated and will be removed in a future release. Please use Inertia."+(null!=(o=t.method)?o:"get")+"() instead."),this.visit(e,c({preserveState:!0},t,{replace:!0}))},o.post=function(e,o,n){return void 0===o&&(o={}),void 0===n&&(n={}),this.visit(e,c({preserveState:!0},n,{method:t.n$.POST,data:o}))},o.put=function(e,o,n){return void 0===o&&(o={}),void 0===n&&(n={}),this.visit(e,c({preserveState:!0},n,{method:t.n$.PUT,data:o}))},o.patch=function(e,o,n){return void 0===o&&(o={}),void 0===n&&(n={}),this.visit(e,c({preserveState:!0},n,{method:t.n$.PATCH,data:o}))},o.delete=function(e,o){return void 0===o&&(o={}),this.visit(e,c({preserveState:!0},o,{method:t.n$.DELETE}))},o.remember=function(e,t){var o,n;void 0===t&&(t="default"),B||this.replaceState(c({},this.page,{rememberedState:c({},null==(o=this.page)?void 0:o.rememberedState,(n={},n[t]=e,n))}))},o.restore=function(e){var t,o;if(void 0===e&&(e="default"),!B)return null==(t=window.history.state)||null==(o=t.rememberedState)?void 0:o[e]},o.on=function(e,t){var o=function(e){var o=t(e);e.cancelable&&!e.defaultPrevented&&!1===o&&e.preventDefault()};return document.addEventListener("inertia:"+e,o),function(){return document.removeEventListener("inertia:"+e,o)}},e}(),x={buildDOMElement:function(e){var t=document.createElement("template");t.innerHTML=e;var o=t.content.firstChild;if(!e.startsWith("