-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
1 lines (1 loc) · 3.96 KB
/
index.js
1
(function () {var a={methods:{publish:function(){this._createPage(!0)},submit:function(){this._createPage()},_createPage:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],a=this.target.replace("[YEAR]",this.$library.dayjs().format("YYYY"));this.$api.pages.create(a,{slug:this.$helper.slug(this.values.title),title:this.values.title,template:this.values.template,content:{title:this.values.title,text:this.values.text}}).then(function(a){e?t.$api.pages.changeStatus(a.id,"listed").then(function(e){t.$go("pages/".concat(a.id.replace(/\//g,"+")))}):t.$go("pages/".concat(a.id.replace(/\//g,"+")))})}},data:function(){return{headline:"",target:"",templates:[],values:{title:"",template:"",text:""},fields:{}}},computed:{templateOptions:function(){return this.templates.map(function(t){return{value:t,text:t}})}},created:function(){var t=this;this.load().then(function(e){t.headline=e.headline,t.target=e.target,t.templates=e.templates,t.values.template=e.defaultTemplate,t.fields={title:{label:"Title",type:"text",width:"1/2"},template:{label:"Template",type:"select",width:"1/2",options:t.templateOptions},text:{label:"Text",type:"textarea",buttons:!1}}})}};if(typeof a==="function"){a=a.options}Object.assign(a,function(){var render=function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("div",{staticClass:"panel"},[_c("k-headline",{staticClass:"headline",attrs:{"size":"medium"}},[_vm._v(_vm._s(_vm.headline))]),_vm._v(" "),_c("div",{staticClass:"form"},[_c("k-form",{attrs:{"fields":_vm.fields},on:{"submit":_vm.submit},model:{value:_vm.values,callback:function($$v){_vm.values=$$v},expression:"values"}},[_c("footer",{staticClass:"form-footer",attrs:{"slot":"footer"},slot:"footer"},[_c("div",{staticStyle:{"display":"flex","-webkit-box-pack":"justify","-ms-flex-pack":"justify","justify-content":"space-between"}},[_c("k-button",{attrs:{"icon":"add","type":"submit","theme":"positive"},on:{"click":function($event){$event.preventDefault();return _vm.publish($event)}}},[_vm._v(" Publish ")]),_vm._v(" "),_c("k-button",{attrs:{"icon":"check","type":"submit","theme":"positive"}},[_vm._v(" Create ")])],1)])])],1)],1)};var staticRenderFns=[];return{render:render,staticRenderFns:staticRenderFns,_compiled:true,_scopeId:null,functional:undefined}}());var b={methods:{onUploadSuccess:function(){var t=this;this.$api.pages.files(this.postPath.replace(/\//g,"+")).then(function(e){var a=e.data.map(function(e){var a=e.filename;return t.dragText.replace("[FILENAME]",a)});t.$api.pages.update(t.postPath.replace(/\//g,"+"),{text:a.join("\n")}).then(function(){t.$go("pages/".concat(t.postPath.replace(/\//g,"+")))})})},drop:function(t){var e=this,a=t[0];this.createShallowPost(a.name).then(function(a){e.postPath=a.id,e.$refs.uploader.drop(t,{url:e.$urls.api+"/"+e.$api.pages.url(e.postPath,"files"),multiple:!0})})},createShallowPost:function(t){var e=this.target.replace("[YEAR]",this.$library.dayjs().format("YYYY"));return this.$api.pages.create(e,{slug:this.$helper.slug(t),title:t,template:this.template,content:{title:t,text:""}})}},data:function(){return{postPath:null,headline:"",text:"",dragText:"",target:"",template:"",fields:{}}},created:function(){var t=this;this.load().then(function(e){t.headline=e.headline,t.text=e.text,t.dragText=e.dragText,t.target=e.target,t.template=e.template})}};if(typeof b==="function"){b=b.options}Object.assign(b,function(){var render=function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("div",{staticClass:"panel"},[_c("k-dropzone",{on:{"drop":_vm.drop}},[_c("k-headline",{staticClass:"headline",attrs:{"size":"medium"}},[_vm._v(_vm._s(_vm.headline))]),_vm._v(" "),_c("p",{staticClass:"inner"},[_vm._v(_vm._s(_vm.text))]),_vm._v(" "),_c("k-upload",{ref:"uploader",on:{"success":_vm.onUploadSuccess}})],1)],1)};var staticRenderFns=[];return{render:render,staticRenderFns:staticRenderFns,_compiled:true,_scopeId:null,functional:undefined}}());panel.plugin("pwaldhauer/quick-add",{sections:{quickadd:a,quickaddimage:b}});})();