mirror of
https://github.com/pelican-dev/panel.git
synced 2025-06-03 21:29:00 +02:00
2 lines
859 B
JavaScript
2 lines
859 B
JavaScript
function o({name:r,recordKey:s,state:n}){return{error:void 0,isLoading:!1,state:n,init:function(){Livewire.hook("commit",({component:e,commit:i,succeed:a,fail:u,respond:f})=>{a(({snapshot:h,effect:d})=>{this.$nextTick(()=>{if(this.isLoading||e.id!==this.$root.closest("[wire\\:id]").attributes["wire:id"].value)return;let t=this.getServerState();t===void 0||Alpine.raw(this.state)===t||(this.state=t)})})}),this.$watch("state",async()=>{let e=this.getServerState();if(e===void 0||Alpine.raw(this.state)===e)return;this.isLoading=!0;let i=await this.$wire.updateTableColumnState(r,s,this.state);this.error=i?.error??void 0,!this.error&&this.$refs.serverState&&(this.$refs.serverState.value=this.state?"1":"0"),this.isLoading=!1})},getServerState:function(){if(this.$refs.serverState)return[1,"1"].includes(this.$refs.serverState.value)}}}export{o as default};
|