index.js
(()=>{(function(){"use strict";var d={};/*!
* vue-slim-tabs v0.3.0
* (c) 2017-present egoist <0x142857@gmail.com>
* Released under the MIT License.
*/Object.defineProperty(d,"__esModule",{value:!0});var v={name:"tabs",props:{defaultIndex:{default:0,type:Number},onSelect:{type:Function}},data:function(){return{selectedIndex:this.defaultIndex}},methods:{switchTab:function(s,t,i){i||(this.selectedIndex=t,this.onSelect&&this.onSelect(s,t))}},render:function(){var s=this,t=arguments[0],i=this.$slots.default.filter(function(l){return l.componentOptions}),o=[];return i.forEach(function(l,u){var c=l.componentOptions.propsData,r=c.title,a=c.titleSlot,p=c.disabled,_=a?s.$slots[a]:r,n=p===!0||p==="";o.push(t("li",{class:"vue-tab",attrs:{role:"tab","aria-selected":s.selectedIndex===u?"true":"false","aria-disabled":n?"true":"false"},on:{click:function(h){return s.switchTab(h,u,n)}}},[_]))}),t("div",{class:"vue-tabs",attrs:{role:"tabs"}},[t("ul",{class:"vue-tablist",attrs:{role:"tablist"}},[this.$slots.left,o,this.$slots.right]),i[this.selectedIndex]])}},m={name:"tab",props:["title","titleSlot","disabled"],render:function(){var s=arguments[0];return s("div",{class:"vue-tabpanel",attrs:{role:"tabpanel"}},[this.$slots.default])}};function C(e){e.component(v.name,v),e.component(m.name,m)}var S=d.Tabs=v,T=d.Tab=m;d.install=C;var F=function(){var e=this,s=e.$createElement,t=e._self._c||s;return e.data?t("k-textarea-field",{attrs:{label:"Preview",value:e.data,buttons:!1,disabled:"true"}}):t("k-text",[e._v(" "+e._s(e.$t("reporter.tab.preview.empty"))+" ")])},I=[];function f(e,s,t,i,o,l,u,c){var r=typeof e=="function"?e.options:e;s&&(r.render=s,r.staticRenderFns=t,r._compiled=!0),i&&(r.functional=!0),l&&(r._scopeId="data-v-"+l);var a;if(u?(a=function(n){n=n||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,!n&&typeof __VUE_SSR_CONTEXT__!="undefined"&&(n=__VUE_SSR_CONTEXT__),o&&o.call(this,n),n&&n._registeredComponents&&n._registeredComponents.add(u)},r._ssrRegister=a):o&&(a=c?function(){o.call(this,(r.functional?this.parent:this).$root.$options.shadowRoot)}:o),a)if(r.functional){r._injectStyles=a;var p=r.render;r.render=function(y,h){return a.call(h),p(y,h)}}else{var _=r.beforeCreate;r.beforeCreate=_?[].concat(_,a):[a]}return{exports:e,options:r}}const x={name:"IssuePreview",props:{data:String}},b={};var L=f(x,F,I,!1,R,null,null,null);function R(e){for(let s in b)this[s]=b[s]}var O=function(){return L.exports}(),E=function(){var e=this,s=e.$createElement,t=e._self._c||s;return t("div",{staticClass:"k-kit-form",on:{input:function(i){return e.somethingChanged()}}},[e.errors.length?t("k-box",{staticClass:"k-kit-form--note",attrs:{theme:"negative"}},[t("k-icon",{attrs:{type:"alert"}}),e._l(e.errors,function(i){return t("p",[e._v(e._s(i))])})],2):e._e(),e.hasResponse?t("k-box",{staticClass:"k-kit-form--note",attrs:{theme:"positive"}},[t("k-icon",{attrs:{type:"check"}}),t("p",{domProps:{innerHTML:e._s(e.successMessage)}})],1):e._e(),t("k-form",[t("k-grid",{staticClass:"title-field"},[t("k-column",[t("k-text-field",{attrs:{name:"title",label:e.$t("reporter.form.field.title"),required:""},model:{value:e.issue.title,callback:function(i){e.$set(e.issue,"title",i)},expression:"issue.title"}})],1)],1),t("tabs",[t("tab",{attrs:{title:e.$t("reporter.tab.write")}},[t("k-fieldset",{attrs:{fields:e.fields},on:{submit:function(i){return i.preventDefault(),e.checkForm.apply(null,arguments)}},model:{value:e.issue.formFields,callback:function(i){e.$set(e.issue,"formFields",i)},expression:"issue.formFields"}})],1),t("tab",{attrs:{title:e.$t("reporter.tab.preview")}},[t("issue-preview",{attrs:{data:e.previewData}})],1)],1),t("k-line-field"),t("k-button",{class:{"is-loading":e.loading},attrs:{disabled:e.loading,icon:e.buttonIcon},on:{click:e.checkForm}},[e._v(" "+e._s(e.$t("reporter.form.button.save"))+" ")])],1)],1)},M=[],K="";const P={name:"IssueForm",components:{IssuePreview:O,Tabs:S,Tab:T},props:{fields:{type:Object},previewData:{type:String}},computed:{hasResponse(){return Object.keys(this.response).length>1},buttonIcon(){return this.loading?"loader":"check"},successMessage(){return console.log(this.issueLink),this.issueLink?this.$t("reporter.form.success",{issueLink:this.issueLink}):this.$t("reporter.form.mail.success")},issueLink(){const e=this.response.issueUrl,s=this.response.issueId;return s?this.$t("reporter.form.issue.link",{issueLink:e,issueId:s}):null}},data(){return{errors:[],response:{},loading:!1,previewClicked:!1,dirty:!0,previewData:{},issue:{title:null,formFields:{}}}},mounted(){const e=this.$el.querySelectorAll(".vue-tab")[1];e.addEventListener("click",()=>{this.previewClicked&&this.loadPreview(),this.previewClicked=!0}),e.addEventListener("mouseenter",()=>{this.dirty&&this.loadPreview()}),this.$el.querySelectorAll(".vue-tab")[0].addEventListener("click",()=>{this.dirty=!1,this.previewClicked=!1})},methods:{somethingChanged(){this.dirty=!0},loadPreview(){this.$api.post("reporter/report/preview",this.issue).then(s=>{this.previewData=s,this.dirty=!1})},checkForm(){this.errors=[],!this.issue.title&&this.issue.title<3&&this.errors.push(this.$t("reporter.form.error.title")),this.errors.length||this.submit()},submit(){this.loading=!0,this.$api.post("reporter/report",this.issue).then(s=>{this.response=s,this.loading=!1,this.issue={}},s=>{this.errors.push(this.$t(s)),this.loading=!1,this.response={}})}}},$={};var j=f(P,E,M,!1,q,null,null,null);function q(e){for(let s in $)this[s]=$[s]}var k=function(){return j.exports}(),D=function(){var e=this,s=e.$createElement,t=e._self._c||s;return t("k-inside",[t("k-view",{staticClass:"k-issue-tracker-view"},[t("k-header",[e._v(e._s(e.$t("reporter.headline")))]),t("k-text",[e._v(e._s(e.$t("reporter.description")))]),t("issue-form",{attrs:{fields:e.fields}})],1)],1)},V=[];const N={components:{IssueForm:k},props:{fields:Object},data(){return{fields:{}}},async created(){this.$api.get("reporter/fields").then(e=>{this.fields=e})}},g={};var U=f(N,D,V,!1,A,null,null,null);function A(e){for(let s in g)this[s]=g[s]}var X=function(){return U.exports}(),z=function(){var e=this,s=e.$createElement,t=e._self._c||s;return t("section",[t("header",{staticClass:"k-section-header"},[t("k-headline",[e._v(" "+e._s(e.headline)+" ")])],1),t("issue-form",{attrs:{fields:e.fields}})],1)},H=[],Q="";const W={components:{IssueForm:k},props:{fields:Object,headline:String},data(){return{fields:{}}},async created(){this.$api.get("reporter/fields").then(e=>{this.fields=e})}},w={};var B=f(W,z,H,!1,G,null,null,null);function G(e){for(let s in w)this[s]=w[s]}var J=function(){return B.exports}();panel.plugin("gearsdigital/kirby-reporter",{components:{"k-reporter-view":X},sections:{reporter:J}})})();})();