-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
1 lines (1 loc) · 1.81 KB
/
Copy pathindex.js
File metadata and controls
1 lines (1 loc) · 1.81 KB
1
(function(){"use strict";function a(e,t,i,s,u,p,f,v){var n=typeof e=="function"?e.options:e;return t&&(n.render=t,n.staticRenderFns=i,n._compiled=!0),{exports:e,options:n}}const o={extends:"k-files-field",data(){return{csv:null}},computed:{button(){return[{icon:"remove",responsive:!0,size:"xs",text:this.$t("remove"),variant:"filled",click:()=>this.clear()}]},file(){var e;return(e=this.selected[0])==null?void 0:e.id},index(){var e;if((e=this.csv)!=null&&e.pagination)return(this.csv.pagination.page-1)*this.csv.pagination.limit+1},pagination(){var e;return{...((e=this.csv)==null?void 0:e.pagination)??{},details:!0}},table(){return this.csv?{...this.csv,index:this.index,pagination:this.pagination}:{}}},watch:{file:{handler(){this.preview()},immediate:!0}},methods:{clear(){this.selected=[],this.csv=null,this.onInput()},onInput(){this.$emit("input",this.selected),this.preview()},async preview(e=1){this.file&&(this.csv=await this.$api.get(this.endpoints.field+"/preview",{file:this.file,page:e}))}}};var l=function(){var t=this,i=t._self._c;return i("k-field",t._b({staticClass:"k-models-field k-csv-field",scopedSlots:t._u([t.disabled?null:{key:"options",fn:function(){return[i("k-button-group",{ref:"buttons",staticClass:"k-field-options",attrs:{buttons:t.file?t.button:t.buttons,layout:"collapsed",size:"xs",variant:"filled"}})]},proxy:!0}],null,!0)},"k-field",t.$props,!1),[t.csv?i("k-table",t._b({on:{paginate:function(s){return t.preview(s.page)}}},"k-table",t.table,!1)):t.file?i("k-empty",{attrs:{text:t.$t("field.csv.loading"),icon:"loader",layout:"table"}}):i("k-dropzone",{attrs:{disabled:!t.hasDropzone},on:{drop:t.drop}},[i("k-empty",{attrs:{text:t.$t("field.csv.empty"),icon:"table",layout:"table"},on:{click:t.open}})],1)],1)},r=[],c=a(o,l,r);const d=c.exports;panel.plugin("distantnative/kirby-csv-field",{fields:{csv:d}})})();