forked from moritzebeling/kirby-panel-button
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
1 lines (1 loc) · 2.48 KB
/
index.js
1
(function(){"use strict";function d(n){console.log("Button field",n.label,n.url),window.open(n.url,"_blank")}function _(n){console.log("Button field",n.label,n.url),n.isLoading=!0,fetch(n.url).then(t=>t.json()).then(t=>{n.isLoading=!1,console.log("Button field","Webhook successfully triggered",t),console.log(n),n.reload===!0&&setTimeout(()=>{n.$reload()},50)}).catch(t=>{n.hasError=!0,console.error("Button field","Error",t)})}const B="";function b(n,t,o,v,i,r,l,C){var e=typeof n=="function"?n.options:n;t&&(e.render=t,e.staticRenderFns=o,e._compiled=!0),v&&(e.functional=!0),r&&(e._scopeId="data-v-"+r);var a;if(l?(a=function(s){s=s||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,!s&&typeof __VUE_SSR_CONTEXT__<"u"&&(s=__VUE_SSR_CONTEXT__),i&&i.call(this,s),s&&s._registeredComponents&&s._registeredComponents.add(l)},e._ssrRegister=a):i&&(a=C?function(){i.call(this,(e.functional?this.parent:this).$root.$options.shadowRoot)}:i),a)if(e.functional){e._injectStyles=a;var m=e.render;e.render=function(y,c){return a.call(c),m(y,c)}}else{var u=e.beforeCreate;e.beforeCreate=u?[].concat(u,a):[a]}return{exports:n,options:e}}const f={props:{label:String,text:String,url:String,theme:String,icon:String,open:Boolean,reload:Boolean,help:String,isLoading:!0,hasError:!1},methods:{async onClick(){this.open===!0?d(this):_(this)}}};var p=function(){var t=this,o=t._self._c;return o("k-field",{staticClass:"k-button-field",attrs:{label:t.label,help:t.help}},[o("div",{staticClass:"k-button-field-button-wrapper"},[t.isLoading?t._e():o("button",{staticClass:"k-button-field-button k-button k-box",attrs:{type:"button","data-theme":t.theme},on:{click:t.onClick}},[o("k-icon",{staticClass:"k-button-icon",attrs:{type:t.icon}}),o("span",{staticClass:"k-button-text"},[t._v(t._s(t.text))])],1),t.isLoading&&!t.hasError?o("div",{staticClass:"k-button-field-button k-button k-button-disabled k-box",attrs:{type:"button","data-disabled":"true"}},[o("k-icon",{staticClass:"k-button-icon",attrs:{type:"dots"}}),o("span",{staticClass:"k-button-text"},[t._v("Please wait")])],1):t._e(),t.hasError?o("div",{staticClass:"k-button-field-button k-button k-button-disabled k-box",attrs:{type:"button","data-disabled":"true","data-theme":"negative"}},[o("k-icon",{staticClass:"k-button-icon",attrs:{type:"alert"}}),o("span",{staticClass:"k-button-text"},[t._v("Error")])],1):t._e()])])},h=[],k=b(f,p,h,!1,null,null,null,null);const g=k.exports;panel.plugin("moritzebeling/panel-button",{fields:{button:g}})})();