bnomei/kirby3-mailjet

View on GitHub
index.js

Summary

Maintainability
A
0 mins
Test Coverage
(function(){"use strict";var d=function(){var s=this,a=s.$createElement,n=s._self._c||a;return n("k-inside",[n("k-view",{staticClass:"k-mailjet-sms-view"},[n("k-header",[s._v("Mailjet SMS")]),n("k-fieldset",{attrs:{fields:{to:{label:this.$t("mailjet.sms.to"),type:"text",placeholder:this.$t("mailjet.sms.to.placeholder"),width:"1/2",required:!0},from:{label:this.$t("mailjet.sms.from"),type:"text",placeholder:this.$t("mailjet.sms.from.placeholder"),width:"1/2"},message:{label:this.$t("mailjet.sms.message"),maxlength:s.message.maxlength,required:!0,type:"textarea",buttons:!1}}},model:{value:s.sms,callback:function(r){s.sms=r},expression:"sms"}}),n("div",{staticClass:"buttonwrapper"},[n("k-button",{staticClass:"smsbutton",class:{sending:s.sending,"has-error":s.hasError,"is-success":s.isSuccess},attrs:{icon:s.currenticon,disabled:!s.cansend},on:{click:function(r){return s.onClick()}}},[s._v(s._s(this.$t("mailjet.sms.action")))])],1)],1)],1)},f=[],k="";function _(s,a,n,r,o,c,h,$){var e=typeof s=="function"?s.options:s;a&&(e.render=a,e.staticRenderFns=n,e._compiled=!0),r&&(e.functional=!0),c&&(e._scopeId="data-v-"+c);var i;if(h?(i=function(t){t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,!t&&typeof __VUE_SSR_CONTEXT__!="undefined"&&(t=__VUE_SSR_CONTEXT__),o&&o.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(h)},e._ssrRegister=i):o&&(i=$?function(){o.call(this,(e.functional?this.parent:this).$root.$options.shadowRoot)}:o),i)if(e.functional){e._injectStyles=i;var C=e.render;e.render=function(S,u){return i.call(u),C(S,u)}}else{var m=e.beforeCreate;e.beforeCreate=m?[].concat(m,i):[i]}return{exports:s,options:e}}const g={data:function(){return{sms:{from:"",to:"",message:""},message:{maxlength:0},cooldown:Number,sending:!1,hasError:!1,isSuccess:!1}},created(){this.$api.get("mailjet/sms/config").then(s=>{this.sms.from=s.from,this.message.maxlength=s.maxlength,this.cooldown=s.cooldown}).catch(s=>{console.log(s)})},computed:{currenticon:function(){return this.hasError?"alert":this.isSuccess?"check":"mailjet-sms"},cansend:function(){return this.sms.to.length>0&&this.sms.message.length>0&&this.sms.message.length<=this.message.maxlength}},methods:{onClick:function(){this.sending=!0,this.$api.post("mailjet/sms/send",this.sms).then(s=>{s.statusCode===200?(this.handleSuccess(),this.sms.to=""):this.handleError(),this.sending=!1}).catch(s=>{this.sending=!1,console.log(s)})},handleSuccess:function(){let s=this;s.isSuccess=!0,setTimeout(function(){s.isSuccess=!1},s.cooldown)},handleError:function(){let s=this;s.hasError=!0,setTimeout(function(){s.hasError=!1},s.cooldown)}}},l={};var p=_(g,d,f,!1,v,"6fef7f10",null,null);function v(s){for(let a in l)this[a]=l[a]}var w=function(){return p.exports}();panel.plugin("schnitzerund/sms",{components:{"k-mailjet-sms-view":w},icons:{"mailjet-sms":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48"><g class="nc-icon-wrapper"><path d="M43,1H23a4,4,0,0,0-4,4V25a1,1,0,0,0,1,1,.988.988,0,0,0,.581-.187L27.32,21H43a4,4,0,0,0,4-4V5A4,4,0,0,0,43,1ZM32,15H26a1,1,0,0,1,0-2h6a1,1,0,0,1,0,2Zm8-6H26a1,1,0,0,1,0-2H40a1,1,0,0,1,0,2Z" data-color="color-2"/><path d="M31,23V39a1,1,0,0,1-1,1H7a1,1,0,0,1-1-1V11a1,1,0,0,1,1-1H17V5H8A4,4,0,0,0,4,9V43a4,4,0,0,0,4,4H29a4,4,0,0,0,4-4V23Z"/></g></svg>'}})})();