@sulzanoks/vue-datatable 0.3.4 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/datatable-card.es.js +345 -306
- package/dist/datatable-card.umd.js +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/Components/DatatableCard.vue +89 -26
|
@@ -8,4 +8,4 @@
|
|
|
8
8
|
|
|
9
9
|
Please specify a more appropriate element using the "as" attribute. For example:
|
|
10
10
|
|
|
11
|
-
<Link href="${a}" method="${o}" as="button">...</Link>`),d.h(e.as,{...r,...i==="a"?{href:a}:{},onClick:c=>{_c(c)&&(c.preventDefault(),Rn.visit(a,{data:l,method:o,replace:e.replace,preserveScroll:e.preserveScroll,preserveState:e.preserveState??o!=="get",only:e.only,headers:e.headers,onCancelToken:r.onCancelToken||(()=>({})),onBefore:r.onBefore||(()=>({})),onStart:r.onStart||(()=>({})),onProgress:r.onProgress||(()=>({})),onFinish:r.onFinish||(()=>({})),onCancel:r.onCancel||(()=>({})),onSuccess:r.onSuccess||(()=>({})),onError:r.onError||(()=>({}))}))}},t)}}}),Oc=Ac;const vu="",Tc=(e,t)=>{const r=e.__vccOpts||e;for(const[i,o]of t)r[i]=o;return r},Pc={name:"DatatableCard",components:{Link:Oc},props:{cardTitle:{type:String,required:!1,default:null},cardIconStyle:{type:String,required:!1,default:"card-header-primary"},cardIcon:{type:String,required:!1,default:null},cardClasses:{type:String,required:!1,default:null},createLink:{type:String,required:!1,default:null},columns:{type:Array,required:!0},url:{type:String,required:!0},selectableRows:{type:Boolean,required:!1,default:!1},order:{type:Array,required:!1,default:[{column:0,dir:"asc"}]},advancedSearch:{type:Boolean,required:!1,default:!1},loadDataOnInit:{type:Boolean,required:!1,default:!0},requestQueryParams:{type:Object,required:!1,default:()=>({})},actions:{type:Array,required:!1},clickableRows:{type:Boolean,required:!1,default:!1},hyperlinkStyle:{type:String,required:!1,default:"Link"}},emits:["row-click"],data(){return{searchBarOpen:!1,rows:[],columnSettings:{},searchTerm:"",recordsTotal:0,recordsFiltered:0,selectedRows:[],cardError:null}},watch:{selectedRows:function(e,t){this.selectableRows&&(e.length===this.rows.length&&e.length>0?(this.$refs.selectAllRows.indeterminate=!1,this.$refs.selectAllRows.checked=!0):e.length===0?(this.$refs.selectAllRows.indeterminate=!1,this.$refs.selectAllRows.checked=!1):this.$refs.selectAllRows.indeterminate=!0)}},computed:{firstRecord(){return this.columnSettings.start+1},lastRecord(){return this.columnSettings.start+this.rows.length},currentPage(){return Math.ceil(this.columnSettings.start/this.columnSettings.length)+1},pageCount(){return Math.ceil(this.recordsFiltered/this.columnSettings.length)},lastPageStart(){return(this.pageCount-1)*this.columnSettings.length},columnSortingClasses(){let e=[];if(!this.columnSettings.order)return e;for(let t=0;t<this.columns.length;t++){let r="";for(let i=0;i<this.columnSettings.order.length;i++)this.columnSettings.order[i].column==t&&(r=this.columnSettings.order[i].dir=="asc"?"sorting_asc":"sorting_desc");e.push(r)}return e},pages(){let e=[],t=this.currentPage-2,r=this.currentPage+2;t<1&&(t=1,r=5),r>this.pageCount&&(t=this.pageCount-4,r=this.pageCount),t<1&&(t=1);for(let i=t;i<=r;i++)e.push(i);return e}},methods:{handleEmit(e,t){this.$emit(e,t)},refresh(){this.initColumnSettings(),this.searchBarOpen=!1,this.loadDataOnInit?this.loadData():this.rows=[],this.selectedRows=[],this.advancedSearch||(this.$el.querySelector(".filter-input").value=""),this.$el.querySelectorAll(".advanced-filter-input").forEach(e=>{e.value=""})},toggleSearch(){this.advancedSearch||(this.searchBarOpen=!0),this.advancedSearch&&(this.searchBarOpen=!this.searchBarOpen)},clearSearch(){this.searchBarOpen=!1,this.$el.querySelector(".filter-input").value="",this.columnSettings.search.value="",this.loadData()},setAdvancedSearchFilters(){this.columnSettings.columns.forEach((e,t)=>{e.searchable&&(e.search.value=this.$el.querySelector(`input[name="${e.name}"]`).value)}),this.loadData()},loadData(){this.columnSettings.draw++,this.clearSelectedRows();const e={...this.requestQueryParams,...this.columnSettings};rn.get(this.url,{params:e}).then(t=>{if(t.data.error){this.cardError="error loading data. see console for details",console.error(t.data.error);return}this.cardError=null,this.rows=t.data.data,this.recordsTotal=t.data.recordsTotal,this.recordsFiltered=t.data.recordsFiltered}).catch(t=>{this.cardError=t.response.data.message,console.error(t)})},initColumnSettings(){this.columnSettings={draw:0,columns:this.columns.map((e,t)=>({data:e.data,name:e.name,searchable:e.searchable===void 0?!0:e.searchable,sortable:e.sortable===void 0?!0:e.sortable,visible:e.visible===void 0?!0:e.visible,search:{value:"",regex:!1}})),order:this.order,start:0,length:10,search:{value:"",regex:!1}}},setPageLength(e){this.columnSettings.length=e,this.loadData()},setPage(e){e<1||e>this.pageCount||(this.columnSettings.start=(e-1)*this.columnSettings.length,this.loadData())},setSearchTerm(){setTimeout(()=>{this.columnSettings.search.value=this.$el.querySelector(".filter-input").value,this.columnSettings.start=0,this.loadData()},500)},setSorting(e){this.columnSettings.columns[e].sortable&&(this.columnSettings.order[0].column==e?this.columnSettings.order[0].dir=this.columnSettings.order[0].dir=="asc"?"desc":"asc":this.columnSettings.order=[{column:e,dir:"asc"}],this.loadData())},generateLink(e,t){const r=(o,a)=>{if(!a||typeof a!="object")return o;const l=new URLSearchParams(a).toString();return l?`${o}?${l}`:o},i=(o,a)=>{if(!o)return"";let l=o.replace(/\{(\w+)\}/g,(c,h)=>a[h]??"");return l=l.replace(/(^|[^:]):(\w+)/g,(c,h,f)=>`${h}${a[f]??""}`),l};if(typeof e=="string")return i(e,t);if(!e||typeof e!="object")return"";if(e.template){const o={...t||{},...e.params||{}},a=i(e.template,o);return r(a,e.query)}if(e.name){const o=Array.isArray(e.resourceIds)?e.resourceIds.map(l=>t?t[l]:void 0):[];let a=route(e.name,o);return r(a,e.query)}return""},selectAllRows(){this.selectedRows.length==this.rows.length?this.selectedRows=[]:this.selectedRows=this.rows.map(e=>e.id)},clearSelectedRows(){this.selectedRows=[]},filterColumns(e){this.columnSettings.columns.forEach((t,r)=>{t.searchable&&(t.search.value="",e.forEach(i=>{i.name==t.name&&(t.search.value=i.value)}))}),this.loadData()},getSelectedRows(){return this.selectedRows}},mounted(){this.initColumnSettings(),this.loadDataOnInit&&this.loadData()}},Se=e=>(d.pushScopeId("data-v-d1594d95"),e=e(),d.popScopeId(),e),Cc={key:0,class:"card-icon"},Rc={key:0,class:"material-icons"},xc={key:1,class:"material-icons"},Nc={key:1,class:"card-title"},Bc={key:2,class:"card-title text-danger"},Ic={class:"form-group label-floating is-empty"},Fc=Se(()=>d.createElementVNode("i",{class:"material-icons search-icon-left"},"search",-1)),kc=[Se(()=>d.createElementVNode("i",{class:"material-icons"},"close",-1))],Lc={class:"card-actions icons right-top"},Dc={key:0},Mc=Se(()=>d.createElementVNode("i",{class:"material-icons"},"add",-1)),jc=[Se(()=>d.createElementVNode("i",{class:"material-icons"},"search",-1))],Uc={class:"dropdown","data-tippy-content":"Show Entries"},Vc=Se(()=>d.createElementVNode("a",{href:"javascript:void(0)","data-bs-toggle":"dropdown"},[d.createElementVNode("i",{class:"material-icons"},"more_vert")],-1)),$c={class:"dropdown-menu dropdown-menu-right"},qc=[Se(()=>d.createElementVNode("a",{href:"javascript:void(0)"},"10",-1))],Hc=[Se(()=>d.createElementVNode("a",{href:"javascript:void(0)"},"25",-1))],zc=[Se(()=>d.createElementVNode("a",{href:"javascript:void(0)"},"50",-1))],Wc=[Se(()=>d.createElementVNode("a",{href:"javascript:void(0)"},"100",-1))],Gc={class:"card-body"},Jc=["name","placeholder"],Kc=Se(()=>d.createElementVNode("button",{type:"submit",class:"btn btn-primary"},"Meklēt",-1)),Qc={class:"table-responsive"},Xc={class:"dataTables_wrapper no-footer"},Yc={key:0},Zc=["onClick"],eu={key:1,class:"w-25"},tu=["onClick"],ru={key:0},nu=["value"],iu={key:0},ou=["href","innerHTML"],au=["innerHTML"],su={key:1},lu=["onClick"],cu={key:0,class:"material-icons"},uu={class:"dataTables_info"},fu={key:0},du={class:"dataTables_paginate paging_simple_numbers user-select-none",id:"document-index-table_paginate"},pu=["onClick"];function hu(e,t,r,i,o,a){const l=d.resolveComponent("Link");return d.openBlock(),d.createElementBlock("div",{class:d.normalizeClass(["card",r.cardClasses])},[d.createElementVNode("header",{class:d.normalizeClass(["card-header",{"card-header-primary":!o.cardError&&r.cardIcon,"card-header-danger":o.cardError&&r.cardIcon,"card-header-icon":r.cardIcon}])},[r.cardIcon?(d.openBlock(),d.createElementBlock("div",Cc,[o.cardError?(d.openBlock(),d.createElementBlock("i",xc,"dangerous")):(d.openBlock(),d.createElementBlock("i",Rc,d.toDisplayString(r.cardIcon),1))])):d.createCommentVNode("",!0),r.cardTitle&&!o.cardError?(d.openBlock(),d.createElementBlock("h4",Nc,d.toDisplayString(r.cardTitle),1)):d.createCommentVNode("",!0),o.cardError?(d.openBlock(),d.createElementBlock("h4",Bc,d.toDisplayString(o.cardError),1)):d.createCommentVNode("",!0),r.advancedSearch?d.createCommentVNode("",!0):(d.openBlock(),d.createElementBlock("div",{key:3,class:d.normalizeClass(["card-search",{open:o.searchBarOpen}])},[d.createElementVNode("div",Ic,[Fc,d.createElementVNode("input",{type:"text",class:"form-control filter-input",placeholder:"Search...",autocomplete:"off",onKeyup:t[0]||(t[0]=(...c)=>a.setSearchTerm&&a.setSearchTerm(...c))},null,32),d.createElementVNode("a",{href:"javascript:void(0)",class:"close-search",onClick:t[1]||(t[1]=(...c)=>a.clearSearch&&a.clearSearch(...c)),"data-tippy-content":"Close"},kc)])],2)),d.createElementVNode("ul",Lc,[d.renderSlot(e.$slots,"actions",{},void 0,!0),r.createLink?(d.openBlock(),d.createElementBlock("li",Dc,[d.createVNode(l,{href:r.createLink,"data-tippy-content":"Create new"},{default:d.withCtx(()=>[Mc]),_:1},8,["href"])])):d.createCommentVNode("",!0),d.createElementVNode("li",null,[d.createElementVNode("a",{href:"javascript:void(0)","data-tippy-content":"Meklēt",onClick:t[2]||(t[2]=(...c)=>a.toggleSearch&&a.toggleSearch(...c))},jc)]),d.createElementVNode("li",Uc,[Vc,d.createElementVNode("ul",$c,[d.createElementVNode("li",{onClick:t[3]||(t[3]=c=>a.setPageLength(10))},qc),d.createElementVNode("li",{onClick:t[4]||(t[4]=c=>a.setPageLength(25))},Hc),d.createElementVNode("li",{onClick:t[5]||(t[5]=c=>a.setPageLength(50))},zc),d.createElementVNode("li",{onClick:t[6]||(t[6]=c=>a.setPageLength(100))},Wc)])])])],2),d.createElementVNode("div",Gc,[d.renderSlot(e.$slots,"default",{},void 0,!0),r.advancedSearch?(d.openBlock(),d.createElementBlock("div",{key:0,class:d.normalizeClass(["toolbar",{open:o.searchBarOpen}])},[d.createElementVNode("form",{onSubmit:t[7]||(t[7]=d.withModifiers((...c)=>a.setAdvancedSearchFilters&&a.setAdvancedSearchFilters(...c),["prevent"]))},[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(r.columns,(c,h)=>(d.openBlock(),d.createElementBlock(d.Fragment,null,[c.searchable!==!1?(d.openBlock(),d.createElementBlock("span",{class:"bmd-form-group",key:h},[d.createElementVNode("input",{name:c.name,class:"form-control advanced-filter-input",placeholder:c.displayName,autocomplete:"off"},null,8,Jc)])):d.createCommentVNode("",!0)],64))),256)),Kc],32)],2)):d.createCommentVNode("",!0),d.createElementVNode("div",Qc,[d.createElementVNode("div",Xc,[d.createElementVNode("table",{class:d.normalizeClass(["table data-table dataTable no-footer",{"table-hover":r.clickableRows}])},[d.createElementVNode("thead",null,[d.createElementVNode("tr",null,[r.selectableRows?(d.openBlock(),d.createElementBlock("th",Yc,[d.createElementVNode("input",{type:"checkbox",onClick:t[8]||(t[8]=(...c)=>a.selectAllRows&&a.selectAllRows(...c)),ref:"selectAllRows"},null,512)])):d.createCommentVNode("",!0),(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(r.columns,(c,h)=>(d.openBlock(),d.createElementBlock(d.Fragment,{key:h},[c.visible!==!1?(d.openBlock(),d.createElementBlock("th",{key:0,class:d.normalizeClass([a.columnSortingClasses[h],c.sortable!==!1?"sorting":""]),onClick:f=>a.setSorting(h),style:d.normalizeStyle(c.width?{width:c.width}:{})},d.toDisplayString(c.displayName),15,Zc)):d.createCommentVNode("",!0)],64))),128)),r.actions?(d.openBlock(),d.createElementBlock("th",eu,"Darbības")):d.createCommentVNode("",!0)])]),d.createElementVNode("tbody",null,[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(o.rows,(c,h)=>(d.openBlock(),d.createElementBlock("tr",{key:h,onClick:f=>r.clickableRows?e.$emit("row-click",c):null},[r.selectableRows?(d.openBlock(),d.createElementBlock("td",ru,[d.withDirectives(d.createElementVNode("input",{type:"checkbox",value:c.id,"onUpdate:modelValue":t[9]||(t[9]=f=>o.selectedRows=f)},null,8,nu),[[d.vModelCheckbox,o.selectedRows]])])):d.createCommentVNode("",!0),(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(r.columns,(f,y)=>(d.openBlock(),d.createElementBlock(d.Fragment,{key:y},[f.visible!==!1?(d.openBlock(),d.createElementBlock("td",iu,[f.linkParams&&r.hyperlinkStyle==="Link"?(d.openBlock(),d.createBlock(l,{key:0,href:a.generateLink(f.linkParams,c),innerHTML:c[f.data]},null,8,["href","innerHTML"])):f.linkParams&&r.hyperlinkStyle==="a"?(d.openBlock(),d.createElementBlock("a",{key:1,href:a.generateLink(f.linkParams,c),innerHTML:c[f.data]},null,8,ou)):(d.openBlock(),d.createElementBlock("span",{key:2,innerHTML:c[f.data]},null,8,au))])):d.createCommentVNode("",!0)],64))),128)),r.actions?(d.openBlock(),d.createElementBlock("td",su,[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(r.actions,(f,y)=>(d.openBlock(),d.createElementBlock("button",{key:y,class:d.normalizeClass(["btn btn-sm",f.class]),onClick:b=>a.handleEmit(f.emit,c)},[f.icon?(d.openBlock(),d.createElementBlock("i",cu,d.toDisplayString(f.icon),1)):d.createCommentVNode("",!0),d.createTextVNode(" "+d.toDisplayString(f.label),1)],10,lu))),128))])):d.createCommentVNode("",!0)],8,tu))),128))])],2),d.createElementVNode("div",uu,[d.createTextVNode(" Rāda "+d.toDisplayString(a.firstRecord)+". līdz "+d.toDisplayString(a.lastRecord)+". no "+d.toDisplayString(o.recordsFiltered)+" ierakstiem ",1),o.recordsFiltered!=o.recordsTotal?(d.openBlock(),d.createElementBlock("span",fu," (kopā "+d.toDisplayString(o.recordsTotal)+" ieraksti) ",1)):d.createCommentVNode("",!0)]),d.createElementVNode("div",du,[d.createElementVNode("a",{class:d.normalizeClass(["paginate_button first user-select-none",{disabled:o.columnSettings.start==0}]),onClick:t[10]||(t[10]=c=>a.setPage(1))},"Pirmā",2),d.createElementVNode("a",{class:d.normalizeClass(["paginate_button previous",{disabled:o.columnSettings.start==0}]),onClick:t[11]||(t[11]=c=>a.setPage(a.currentPage-1))},"Iepriekšējā",2),d.createElementVNode("span",null,[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(a.pages,(c,h)=>(d.openBlock(),d.createElementBlock("a",{class:d.normalizeClass(["paginate_button",{current:c==a.currentPage}]),onClick:f=>a.setPage(c)},d.toDisplayString(c),11,pu))),256))]),d.createElementVNode("a",{class:d.normalizeClass(["paginate_button next",{disabled:o.columnSettings.start>=a.lastPageStart}]),onClick:t[12]||(t[12]=c=>a.setPage(a.currentPage+1))},"Nākamā",2),d.createElementVNode("a",{class:d.normalizeClass(["paginate_button last",{disabled:o.columnSettings.start>=a.lastPageStart}]),onClick:t[13]||(t[13]=c=>a.setPage(a.pageCount))},"Pēdējā",2)])])])])],2)}return Tc(Pc,[["render",hu],["__scopeId","data-v-d1594d95"]])});
|
|
11
|
+
<Link href="${a}" method="${o}" as="button">...</Link>`),d.h(e.as,{...r,...i==="a"?{href:a}:{},onClick:c=>{_c(c)&&(c.preventDefault(),Rn.visit(a,{data:l,method:o,replace:e.replace,preserveScroll:e.preserveScroll,preserveState:e.preserveState??o!=="get",only:e.only,headers:e.headers,onCancelToken:r.onCancelToken||(()=>({})),onBefore:r.onBefore||(()=>({})),onStart:r.onStart||(()=>({})),onProgress:r.onProgress||(()=>({})),onFinish:r.onFinish||(()=>({})),onCancel:r.onCancel||(()=>({})),onSuccess:r.onSuccess||(()=>({})),onError:r.onError||(()=>({}))}))}},t)}}}),Oc=Ac;const vu="",Tc=(e,t)=>{const r=e.__vccOpts||e;for(const[i,o]of t)r[i]=o;return r},Pc={name:"DatatableCard",components:{Link:Oc},props:{cardTitle:{type:String,required:!1,default:null},cardIconStyle:{type:String,required:!1,default:"card-header-primary"},cardIcon:{type:String,required:!1,default:null},cardClasses:{type:String,required:!1,default:null},createLink:{type:String,required:!1,default:null},columns:{type:Array,required:!0},url:{type:String,required:!0},selectableRows:{type:Boolean,required:!1,default:!1},order:{type:Array,required:!1,default:[{column:0,dir:"asc"}]},advancedSearch:{type:Boolean,required:!1,default:!1},loadDataOnInit:{type:Boolean,required:!1,default:!0},requestQueryParams:{type:Object,required:!1,default:()=>({})},actions:{type:Array,required:!1},clickableRows:{type:Boolean,required:!1,default:!1},hyperlinkStyle:{type:String,required:!1,default:"Link"},pageLength:{type:Number,required:!1,default:10}},emits:["row-click"],data(){return{searchBarOpen:!1,rows:[],columnSettings:{},searchTerm:"",recordsTotal:0,recordsFiltered:0,selectedRows:[],cardError:null}},watch:{selectedRows:function(e,t){this.selectableRows&&(e.length===this.rows.length&&e.length>0?(this.$refs.selectAllRows.indeterminate=!1,this.$refs.selectAllRows.checked=!0):e.length===0?(this.$refs.selectAllRows.indeterminate=!1,this.$refs.selectAllRows.checked=!1):this.$refs.selectAllRows.indeterminate=!0)}},computed:{firstRecord(){return this.columnSettings.start+1},lastRecord(){return this.columnSettings.start+this.rows.length},currentPage(){return Math.ceil(this.columnSettings.start/this.columnSettings.length)+1},pageCount(){return Math.ceil(this.recordsFiltered/this.columnSettings.length)},lastPageStart(){return(this.pageCount-1)*this.columnSettings.length},columnSortingClasses(){let e=[];if(!this.columnSettings.order)return e;for(let t=0;t<this.columns.length;t++){let r="";for(let i=0;i<this.columnSettings.order.length;i++)this.columnSettings.order[i].column==t&&(r=this.columnSettings.order[i].dir=="asc"?"sorting_asc":"sorting_desc");e.push(r)}return e},pages(){let e=[],t=this.currentPage-2,r=this.currentPage+2;t<1&&(t=1,r=5),r>this.pageCount&&(t=this.pageCount-4,r=this.pageCount),t<1&&(t=1);for(let i=t;i<=r;i++)e.push(i);return e}},methods:{getCellClasses(e,t){const r=[];if(!e.classes)return r;if(typeof e.classes=="string")return r.push(e.classes),r;if(Array.isArray(e.classes)){const i=t[e.data];e.classes.forEach(o=>{if(!o||!o.class)return;let l=o.valueKey?t[o.valueKey]:i;if(typeof l=="string"&&(l=parseFloat(l.replace("%","").trim())),typeof l!="number"||isNaN(l))return;const c=o.min!==void 0?o.min:-1/0,h=o.max!==void 0?o.max:1/0;l>=c&&l<=h&&r.push(o.class)})}return r},handleEmit(e,t){this.$emit(e,t)},refresh(){this.initColumnSettings(),this.searchBarOpen=!1,this.loadDataOnInit?this.loadData():this.rows=[],this.selectedRows=[],this.advancedSearch||(this.$el.querySelector(".filter-input").value=""),this.$el.querySelectorAll(".advanced-filter-input").forEach(e=>{e.value=""})},toggleSearch(){this.advancedSearch||(this.searchBarOpen=!0),this.advancedSearch&&(this.searchBarOpen=!this.searchBarOpen)},clearSearch(){this.searchBarOpen=!1,this.$el.querySelector(".filter-input").value="",this.columnSettings.search.value="",this.loadData()},setAdvancedSearchFilters(){this.columnSettings.columns.forEach((e,t)=>{e.searchable&&(e.search.value=this.$el.querySelector(`input[name="${e.name}"]`).value)}),this.loadData()},loadData(){this.columnSettings.draw++,this.clearSelectedRows();const e={...this.requestQueryParams,...this.columnSettings};rn.get(this.url,{params:e}).then(t=>{if(t.data.error){this.cardError="error loading data. see console for details",console.error(t.data.error);return}this.cardError=null,this.rows=t.data.data,this.recordsTotal=t.data.recordsTotal,this.recordsFiltered=t.data.recordsFiltered}).catch(t=>{this.cardError=t.response.data.message,console.error(t)})},initColumnSettings(){this.columnSettings={draw:0,columns:this.columns.map((e,t)=>({data:e.data,name:e.name,searchable:e.searchable===void 0?!0:e.searchable,sortable:e.sortable===void 0?!0:e.sortable,visible:e.visible===void 0?!0:e.visible,search:{value:"",regex:!1}})),order:this.order,start:0,length:this.pageLength,search:{value:"",regex:!1}}},setPageLength(e){this.columnSettings.length=e,this.loadData()},setPage(e){e<1||e>this.pageCount||(this.columnSettings.start=(e-1)*this.columnSettings.length,this.loadData())},setSearchTerm(){setTimeout(()=>{this.columnSettings.search.value=this.$el.querySelector(".filter-input").value,this.columnSettings.start=0,this.loadData()},500)},setSorting(e){this.columnSettings.columns[e].sortable&&(this.columnSettings.order[0].column==e?this.columnSettings.order[0].dir=this.columnSettings.order[0].dir=="asc"?"desc":"asc":this.columnSettings.order=[{column:e,dir:"asc"}],this.loadData())},generateLink(e,t){const r=(o,a)=>{if(!a||typeof a!="object")return o;const l=new URLSearchParams(a).toString();return l?`${o}?${l}`:o},i=(o,a)=>{if(!o)return"";let l=o.replace(/\{(\w+)\}/g,(c,h)=>a[h]??"");return l=l.replace(/(^|[^:]):(\w+)/g,(c,h,f)=>`${h}${a[f]??""}`),l};if(typeof e=="string")return i(e,t);if(!e||typeof e!="object")return"";if(e.template){const o={...t||{},...e.params||{}},a=i(e.template,o);return r(a,e.query)}if(e.name){const o=Array.isArray(e.resourceIds)?e.resourceIds.map(l=>t?t[l]:void 0):[];let a=route(e.name,o);return r(a,e.query)}return""},selectAllRows(){this.selectedRows.length==this.rows.length?this.selectedRows=[]:this.selectedRows=this.rows.map(e=>e.id)},clearSelectedRows(){this.selectedRows=[]},filterColumns(e){this.columnSettings.columns.forEach((t,r)=>{t.searchable&&(t.search.value="",e.forEach(i=>{i.name==t.name&&(t.search.value=i.value)}))}),this.loadData()},getSelectedRows(){return this.selectedRows}},mounted(){this.initColumnSettings(),this.loadDataOnInit&&this.loadData()}},Se=e=>(d.pushScopeId("data-v-de43b70a"),e=e(),d.popScopeId(),e),Cc={key:0,class:"card-icon"},Rc={key:0,class:"material-icons"},xc={key:1,class:"material-icons"},Nc={key:1,class:"card-title"},Bc={key:2,class:"card-title text-danger"},Ic={class:"form-group label-floating is-empty"},Fc=Se(()=>d.createElementVNode("i",{class:"material-icons search-icon-left"},"search",-1)),kc=[Se(()=>d.createElementVNode("i",{class:"material-icons"},"close",-1))],Lc={class:"card-actions icons right-top"},Dc={key:0},Mc=Se(()=>d.createElementVNode("i",{class:"material-icons"},"add",-1)),jc=[Se(()=>d.createElementVNode("i",{class:"material-icons"},"search",-1))],Uc={class:"dropdown","data-tippy-content":"Show Entries"},Vc=Se(()=>d.createElementVNode("a",{href:"javascript:void(0)","data-bs-toggle":"dropdown"},[d.createElementVNode("i",{class:"material-icons"},"more_vert")],-1)),$c={class:"dropdown-menu dropdown-menu-right"},qc=[Se(()=>d.createElementVNode("a",{href:"javascript:void(0)"},"10",-1))],Hc=[Se(()=>d.createElementVNode("a",{href:"javascript:void(0)"},"25",-1))],zc=[Se(()=>d.createElementVNode("a",{href:"javascript:void(0)"},"50",-1))],Wc=[Se(()=>d.createElementVNode("a",{href:"javascript:void(0)"},"100",-1))],Gc={class:"card-body"},Jc=["name","placeholder"],Kc=Se(()=>d.createElementVNode("button",{type:"submit",class:"btn btn-primary"},"Meklēt",-1)),Qc={class:"table-responsive"},Xc={class:"dataTables_wrapper no-footer"},Yc={key:0},Zc=["onClick"],eu={key:1,class:"w-25"},tu=["onClick"],ru={key:0},nu=["value"],iu=["href","innerHTML"],ou=["innerHTML"],au={key:1},su=["onClick"],lu={key:0,class:"material-icons"},cu={class:"d-flex justify-content-between align-items-center mt-3"},uu={class:"dataTables_info"},fu={key:0},du={class:"dataTables_paginate paging_simple_numbers user-select-none",id:"document-index-table_paginate"},pu=["onClick"];function hu(e,t,r,i,o,a){const l=d.resolveComponent("Link");return d.openBlock(),d.createElementBlock("div",{class:d.normalizeClass(["card",r.cardClasses])},[d.createElementVNode("header",{class:d.normalizeClass(["card-header",{"card-header-primary":!o.cardError&&r.cardIcon,"card-header-danger":o.cardError&&r.cardIcon,"card-header-icon":r.cardIcon}])},[r.cardIcon?(d.openBlock(),d.createElementBlock("div",Cc,[o.cardError?(d.openBlock(),d.createElementBlock("i",xc,"dangerous")):(d.openBlock(),d.createElementBlock("i",Rc,d.toDisplayString(r.cardIcon),1))])):d.createCommentVNode("",!0),r.cardTitle&&!o.cardError?(d.openBlock(),d.createElementBlock("h4",Nc,d.toDisplayString(r.cardTitle),1)):d.createCommentVNode("",!0),o.cardError?(d.openBlock(),d.createElementBlock("h4",Bc,d.toDisplayString(o.cardError),1)):d.createCommentVNode("",!0),r.advancedSearch?d.createCommentVNode("",!0):(d.openBlock(),d.createElementBlock("div",{key:3,class:d.normalizeClass(["card-search",{open:o.searchBarOpen}])},[d.createElementVNode("div",Ic,[Fc,d.createElementVNode("input",{type:"text",class:"form-control filter-input",placeholder:"Search...",autocomplete:"off",onKeyup:t[0]||(t[0]=(...c)=>a.setSearchTerm&&a.setSearchTerm(...c))},null,32),d.createElementVNode("a",{href:"javascript:void(0)",class:"close-search",onClick:t[1]||(t[1]=(...c)=>a.clearSearch&&a.clearSearch(...c)),"data-tippy-content":"Close"},kc)])],2)),d.createElementVNode("ul",Lc,[d.renderSlot(e.$slots,"actions",{},void 0,!0),r.createLink?(d.openBlock(),d.createElementBlock("li",Dc,[d.createVNode(l,{href:r.createLink,"data-tippy-content":"Create new"},{default:d.withCtx(()=>[Mc]),_:1},8,["href"])])):d.createCommentVNode("",!0),d.createElementVNode("li",null,[d.createElementVNode("a",{href:"javascript:void(0)","data-tippy-content":"Meklēt",onClick:t[2]||(t[2]=(...c)=>a.toggleSearch&&a.toggleSearch(...c))},jc)]),d.createElementVNode("li",Uc,[Vc,d.createElementVNode("ul",$c,[d.createElementVNode("li",{onClick:t[3]||(t[3]=c=>a.setPageLength(10))},qc),d.createElementVNode("li",{onClick:t[4]||(t[4]=c=>a.setPageLength(25))},Hc),d.createElementVNode("li",{onClick:t[5]||(t[5]=c=>a.setPageLength(50))},zc),d.createElementVNode("li",{onClick:t[6]||(t[6]=c=>a.setPageLength(100))},Wc)])])])],2),d.createElementVNode("div",Gc,[d.renderSlot(e.$slots,"default",{},void 0,!0),r.advancedSearch?(d.openBlock(),d.createElementBlock("div",{key:0,class:d.normalizeClass(["toolbar",{open:o.searchBarOpen}])},[d.createElementVNode("form",{onSubmit:t[7]||(t[7]=d.withModifiers((...c)=>a.setAdvancedSearchFilters&&a.setAdvancedSearchFilters(...c),["prevent"]))},[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(r.columns,(c,h)=>(d.openBlock(),d.createElementBlock(d.Fragment,null,[c.searchable!==!1?(d.openBlock(),d.createElementBlock("span",{class:"bmd-form-group",key:h},[d.createElementVNode("input",{name:c.name,class:"form-control advanced-filter-input",placeholder:c.displayName,autocomplete:"off"},null,8,Jc)])):d.createCommentVNode("",!0)],64))),256)),Kc],32)],2)):d.createCommentVNode("",!0),d.createElementVNode("div",Qc,[d.createElementVNode("div",Xc,[d.createElementVNode("table",{class:d.normalizeClass(["table data-table dataTable no-footer",{"table-hover":r.clickableRows}])},[d.createElementVNode("thead",null,[d.createElementVNode("tr",null,[r.selectableRows?(d.openBlock(),d.createElementBlock("th",Yc,[d.createElementVNode("input",{type:"checkbox",onClick:t[8]||(t[8]=(...c)=>a.selectAllRows&&a.selectAllRows(...c)),ref:"selectAllRows"},null,512)])):d.createCommentVNode("",!0),(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(r.columns,(c,h)=>(d.openBlock(),d.createElementBlock(d.Fragment,{key:h},[c.visible!==!1?(d.openBlock(),d.createElementBlock("th",{key:0,class:d.normalizeClass([a.columnSortingClasses[h],c.sortable!==!1?"sorting":""]),onClick:f=>a.setSorting(h),style:d.normalizeStyle(c.width?{width:c.width}:{})},d.toDisplayString(c.displayName),15,Zc)):d.createCommentVNode("",!0)],64))),128)),r.actions?(d.openBlock(),d.createElementBlock("th",eu,"Darbības")):d.createCommentVNode("",!0)])]),d.createElementVNode("tbody",null,[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(o.rows,(c,h)=>(d.openBlock(),d.createElementBlock("tr",{key:h,onClick:f=>r.clickableRows?e.$emit("row-click",c):null},[r.selectableRows?(d.openBlock(),d.createElementBlock("td",ru,[d.withDirectives(d.createElementVNode("input",{type:"checkbox",value:c.id,"onUpdate:modelValue":t[9]||(t[9]=f=>o.selectedRows=f)},null,8,nu),[[d.vModelCheckbox,o.selectedRows]])])):d.createCommentVNode("",!0),(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(r.columns,(f,y)=>(d.openBlock(),d.createElementBlock(d.Fragment,{key:y},[f.visible!==!1?(d.openBlock(),d.createElementBlock("td",{key:0,class:d.normalizeClass(a.getCellClasses(f,c))},[f.linkParams&&r.hyperlinkStyle==="Link"?(d.openBlock(),d.createBlock(l,{key:0,href:a.generateLink(f.linkParams,c),innerHTML:c[f.data]},null,8,["href","innerHTML"])):f.linkParams&&r.hyperlinkStyle==="a"?(d.openBlock(),d.createElementBlock("a",{key:1,href:a.generateLink(f.linkParams,c),innerHTML:c[f.data]},null,8,iu)):(d.openBlock(),d.createElementBlock("span",{key:2,innerHTML:c[f.data]},null,8,ou))],2)):d.createCommentVNode("",!0)],64))),128)),r.actions?(d.openBlock(),d.createElementBlock("td",au,[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(r.actions,(f,y)=>(d.openBlock(),d.createElementBlock("button",{key:y,class:d.normalizeClass(["btn btn-sm",f.class]),onClick:b=>a.handleEmit(f.emit,c)},[f.icon?(d.openBlock(),d.createElementBlock("i",lu,d.toDisplayString(f.icon),1)):d.createCommentVNode("",!0),d.createTextVNode(" "+d.toDisplayString(f.label),1)],10,su))),128))])):d.createCommentVNode("",!0)],8,tu))),128))])],2),d.createElementVNode("div",cu,[d.createElementVNode("div",uu,[d.createTextVNode(" Rāda "+d.toDisplayString(a.firstRecord)+". līdz "+d.toDisplayString(a.lastRecord)+". no "+d.toDisplayString(o.recordsFiltered)+" ierakstiem ",1),o.recordsFiltered!=o.recordsTotal?(d.openBlock(),d.createElementBlock("span",fu," (kopā "+d.toDisplayString(o.recordsTotal)+" ieraksti) ",1)):d.createCommentVNode("",!0)]),d.createElementVNode("div",du,[d.createElementVNode("a",{class:d.normalizeClass(["paginate_button first user-select-none",{disabled:o.columnSettings.start==0}]),onClick:t[10]||(t[10]=c=>a.setPage(1))},"Pirmā",2),d.createElementVNode("a",{class:d.normalizeClass(["paginate_button previous",{disabled:o.columnSettings.start==0}]),onClick:t[11]||(t[11]=c=>a.setPage(a.currentPage-1))},"Iepriekšējā",2),d.createElementVNode("span",null,[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(a.pages,(c,h)=>(d.openBlock(),d.createElementBlock("a",{class:d.normalizeClass(["paginate_button",{current:c==a.currentPage}]),onClick:f=>a.setPage(c)},d.toDisplayString(c),11,pu))),256))]),d.createElementVNode("a",{class:d.normalizeClass(["paginate_button next",{disabled:o.columnSettings.start>=a.lastPageStart}]),onClick:t[12]||(t[12]=c=>a.setPage(a.currentPage+1))},"Nākamā",2),d.createElementVNode("a",{class:d.normalizeClass(["paginate_button last",{disabled:o.columnSettings.start>=a.lastPageStart}]),onClick:t[13]||(t[13]=c=>a.setPage(a.pageCount))},"Pēdējā",2)])])])])])],2)}return Tc(Pc,[["render",hu],["__scopeId","data-v-de43b70a"]])});
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.toolbar[data-v-
|
|
1
|
+
.toolbar[data-v-de43b70a]:not(.open){display:none}.card .card-heading[data-v-de43b70a]{padding:15px 20px;position:relative;height:65px}.card .card-search[data-v-de43b70a]{position:absolute;top:0;right:0;margin:0;padding:0;height:100%;z-index:15;-webkit-transition:all .2s;-o-transition:all .2s;transition:all .2s;border:0;box-shadow:none;width:100%;display:none;background:#fff}.card .card-search .form-group[data-v-de43b70a]{margin:0;padding:0;height:65px}.card .card-search .search-icon-left[data-v-de43b70a]{left:15px;right:auto}.card .card-search .close-search[data-v-de43b70a],.card .card-search .search-icon-left[data-v-de43b70a]{top:50%;margin-top:-15px;line-height:30px;margin-right:10px;font-size:25px;position:absolute;right:15px;z-index:99}.card .card-search .form-control[data-v-de43b70a]{width:100%;height:100%;position:absolute;border:none;box-shadow:none;left:0;top:0;margin:0;font-size:15px;text-indent:45px;background-color:#eef5f9;background-image:none}.card .card-search .close-search[data-v-de43b70a]{right:15px;left:auto}.card .card-search .search-icon-left[data-v-de43b70a]{top:50%;margin-top:-15px;line-height:30px;margin-right:10px;font-size:25px;position:absolute;right:15px;z-index:99;width:30px}.card .card-search.open[data-v-de43b70a]{display:block}.card-heading ul.card-actions.icons[data-v-de43b70a]{position:absolute;list-style:none;padding:0;margin:0}ul.card-actions.icons li[data-v-de43b70a]{display:inline}.dataTables_wrapper .dataTables_paginate .paginate_button.current[data-v-de43b70a],.dataTables_wrapper .dataTables_paginate .paginate_button.current[data-v-de43b70a]:hover{background:unset;background-color:#00bcd4;border-color:#00bcd4;box-shadow:0 4px 5px #00bcd424,0 1px 10px #00bcd41f,0 2px 4px -1px #00bcd433}.dataTables_wrapper .dataTables_paginate .paginate_button[data-v-de43b70a],.dataTables_wrapper .dataTables_paginate .paginate_button[data-v-de43b70a]:hover{background:unset;border:0;border-color:#00bcd4;border-radius:30px!important;-webkit-transition:all .3s;transition:all .3s;padding:0 11px;margin:0 3px;min-width:30px;height:30px;line-height:30px;color:#999!important;font-weight:400;font-size:12px;text-transform:uppercase;background:transparent;text-align:center}.dataTables_wrapper .dataTables_paginate .paginate_button[data-v-de43b70a]:hover{border:1}.card-header[data-v-de43b70a]:first-child{border-radius:calc(.25rem - 1px) calc(.25rem - 1px) 0 0}.card .card-header[data-v-de43b70a]{border-bottom:none;background:transparent}.card [class*=card-header-][data-v-de43b70a],.card[class*=bg-][data-v-de43b70a]{color:#fff}.card .card-header[data-v-de43b70a]{z-index:3!important}.card [class*=card-header-][data-v-de43b70a]{margin:0 15px;padding:0;position:relative}.card [class*=card-header-] .card-icon[data-v-de43b70a],.card [class*=card-header-] .card-text[data-v-de43b70a]{border-radius:3px;background-color:#999;padding:15px;margin-top:-20px;margin-right:15px;float:left}.card .card-header.card-header-icon i[data-v-de43b70a],.card .card-header.card-header-text i[data-v-de43b70a]{width:33px;height:33px;text-align:center;line-height:33px}.card[data-v-de43b70a]{border:0;margin-bottom:30px;margin-top:30px;border-radius:6px;color:#333;background:#ffffff;width:100%;box-shadow:0 2px 2px #00000024,0 3px 1px -2px #0003,0 1px 5px #0000001f;box-shadow:0 1px 4px #00000024;font-size:.875rem}.card .card-header.card-header-icon .card-title[data-v-de43b70a],.card .card-header.card-header-text .card-title[data-v-de43b70a]{margin-top:15px;color:#3c4858}.card .card-header.card-header-icon h4[data-v-de43b70a],.card .card-header.card-header-text h4[data-v-de43b70a]{font-weight:300}.card .card-header .card-title[data-v-de43b70a]{margin-bottom:3px}.card .card-actions[data-v-de43b70a]{position:absolute;z-index:1;top:-50px;width:calc(100% - 30px);left:17px;right:17px;text-align:center}.card .card-actions[data-v-de43b70a]{text-align:end}.card ul.card-actions.icons[data-v-de43b70a]{position:absolute;list-style:none;padding:0;margin:0;right:10px;top:15px}ul.card-actions.icons.right-top[data-v-de43b70a]{right:10px;top:15px}ul.card-actions.icons li[data-v-de43b70a]{display:inline;width:100%;text-align:unset}.dropdown-menu .dropdown-item[data-v-de43b70a],.dropdown-menu li>a[data-v-de43b70a]{position:relative;width:auto;display:flex;flex-flow:nowrap;align-items:center;color:#333;font-weight:400;text-decoration:none;font-size:.8125rem;border-radius:.125rem;margin:0 .3125rem;transition:all .15s linear;min-width:7rem;padding:.625rem 1.25rem;overflow:hidden;line-height:1.42857143;text-overflow:ellipsis;word-wrap:break-word}.dropdown-menu .dropdown-item[data-v-de43b70a],.dropdown-menu li>a[data-v-de43b70a]{padding-right:1.5rem;padding-left:1.5rem}.dropdown-menu[data-v-de43b70a]{position:absolute;top:100%;left:0;z-index:1000;display:none;float:left;min-width:10rem;padding:.5rem 0;margin:.125rem 0 0;font-size:1rem;color:#212529;text-align:left;list-style:none;background-color:#fff;background-clip:padding-box;border:1px solid rgba(0,0,0,.15);border-radius:.25rem;box-shadow:0 2px 2px #00000024,0 3px 1px -2px #0003,0 1px 5px #0000001f}.dropdown-menu[data-v-de43b70a]{border:0;display:none;padding:.3125rem 0;transform:scale(0);transform-origin:0 0;will-change:transform,opacity;box-shadow:0 2px 5px #00000042}.dropdown-menu[data-v-de43b70a]{margin:0!important}.clickable-rows tbody tr[data-v-de43b70a]{cursor:pointer}
|
package/package.json
CHANGED
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
</thead>
|
|
87
87
|
<tbody>
|
|
88
88
|
<tr
|
|
89
|
-
v-for="(row, index) in rows"
|
|
89
|
+
v-for="(row, index) in rows"
|
|
90
90
|
:key="index"
|
|
91
91
|
@click="clickableRows ? $emit('row-click', row) : null"
|
|
92
92
|
>
|
|
@@ -94,7 +94,10 @@
|
|
|
94
94
|
<input type="checkbox" :value="row.id" v-model="selectedRows">
|
|
95
95
|
</td>
|
|
96
96
|
<template v-for="(column, index) in columns" :key="index">
|
|
97
|
-
<td
|
|
97
|
+
<td
|
|
98
|
+
v-if="column.visible !== false"
|
|
99
|
+
:class="getCellClasses(column, row)"
|
|
100
|
+
>
|
|
98
101
|
<Link v-if="column.linkParams && hyperlinkStyle === 'Link'" :href="generateLink(column.linkParams, row)"
|
|
99
102
|
v-html="row[column.data]">
|
|
100
103
|
</Link>
|
|
@@ -116,30 +119,30 @@
|
|
|
116
119
|
</tr>
|
|
117
120
|
</tbody>
|
|
118
121
|
</table>
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
122
|
+
<div class="d-flex justify-content-between align-items-center mt-3">
|
|
123
|
+
<div class="dataTables_info">
|
|
124
|
+
Rāda {{ firstRecord }}. līdz {{ lastRecord }}. no {{ recordsFiltered }} ierakstiem
|
|
125
|
+
<span v-if="recordsFiltered != recordsTotal">
|
|
126
|
+
(kopā {{ recordsTotal }} ieraksti)
|
|
127
|
+
</span>
|
|
128
|
+
</div>
|
|
129
|
+
<div class="dataTables_paginate paging_simple_numbers user-select-none"
|
|
130
|
+
id="document-index-table_paginate">
|
|
131
|
+
<a class="paginate_button first user-select-none" :class="{ disabled: columnSettings.start == 0 }"
|
|
132
|
+
@click="setPage(1)">Pirmā</a>
|
|
133
|
+
<a class="paginate_button previous" :class="{ disabled: columnSettings.start == 0 }"
|
|
134
|
+
@click="setPage(currentPage - 1)">Iepriekšējā</a>
|
|
135
|
+
|
|
136
|
+
<span>
|
|
137
|
+
<a v-for="(page, index) in pages" class="paginate_button"
|
|
138
|
+
:class="{ current: page == currentPage }" @click="setPage(page)">{{ page }}</a>
|
|
139
|
+
</span>
|
|
140
|
+
<a class="paginate_button next" :class="{ disabled: columnSettings.start >= lastPageStart }"
|
|
141
|
+
@click="setPage(currentPage + 1)">Nākamā</a>
|
|
142
|
+
<a class="paginate_button last" :class="{ disabled: columnSettings.start >= lastPageStart }"
|
|
143
|
+
@click="setPage(pageCount)">Pēdējā</a>
|
|
144
|
+
</div>
|
|
141
145
|
</div>
|
|
142
|
-
|
|
143
146
|
</div>
|
|
144
147
|
</div>
|
|
145
148
|
</div>
|
|
@@ -236,6 +239,11 @@ export default {
|
|
|
236
239
|
required: false,
|
|
237
240
|
default: 'Link',
|
|
238
241
|
},
|
|
242
|
+
pageLength: {
|
|
243
|
+
type: Number,
|
|
244
|
+
required: false,
|
|
245
|
+
default: 10,
|
|
246
|
+
},
|
|
239
247
|
},
|
|
240
248
|
emits: ['row-click'],
|
|
241
249
|
data() {
|
|
@@ -322,6 +330,61 @@ export default {
|
|
|
322
330
|
},
|
|
323
331
|
},
|
|
324
332
|
methods: {
|
|
333
|
+
/**
|
|
334
|
+
* Resolve classes for a cell based on column definition and row data.
|
|
335
|
+
*
|
|
336
|
+
* column.classes supports:
|
|
337
|
+
* 1) String => always applied, e.g. "text-end bg-light"
|
|
338
|
+
* 2) Array of rules => [{ min, max, class, valueKey? }]
|
|
339
|
+
* - valueKey (optional) lets you read a different field than column.data
|
|
340
|
+
* - min/max are numeric thresholds (inclusive)
|
|
341
|
+
*/
|
|
342
|
+
getCellClasses(column, row) {
|
|
343
|
+
const classes = [];
|
|
344
|
+
|
|
345
|
+
if (!column.classes) {
|
|
346
|
+
return classes;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// Simple string: always apply
|
|
350
|
+
if (typeof column.classes === 'string') {
|
|
351
|
+
classes.push(column.classes);
|
|
352
|
+
return classes;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
// Array of conditional rules
|
|
356
|
+
if (Array.isArray(column.classes)) {
|
|
357
|
+
const baseValue = row[column.data];
|
|
358
|
+
|
|
359
|
+
column.classes.forEach((rule) => {
|
|
360
|
+
if (!rule || !rule.class) {
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// which value to inspect (defaults to column.data)
|
|
365
|
+
const raw = rule.valueKey ? row[rule.valueKey] : baseValue;
|
|
366
|
+
|
|
367
|
+
// try to parse numeric (strip % if needed)
|
|
368
|
+
let num = raw;
|
|
369
|
+
if (typeof num === 'string') {
|
|
370
|
+
num = parseFloat(num.replace('%', '').trim());
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
if (typeof num !== 'number' || isNaN(num)) {
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
const min = rule.min !== undefined ? rule.min : -Infinity;
|
|
378
|
+
const max = rule.max !== undefined ? rule.max : Infinity;
|
|
379
|
+
|
|
380
|
+
if (num >= min && num <= max) {
|
|
381
|
+
classes.push(rule.class);
|
|
382
|
+
}
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
return classes;
|
|
387
|
+
},
|
|
325
388
|
handleEmit(emit, row) {
|
|
326
389
|
this.$emit(emit, row);
|
|
327
390
|
},
|
|
@@ -414,7 +477,7 @@ export default {
|
|
|
414
477
|
}),
|
|
415
478
|
order: this.order,
|
|
416
479
|
start: 0,
|
|
417
|
-
length:
|
|
480
|
+
length: this.pageLength,
|
|
418
481
|
search: {
|
|
419
482
|
value: '',
|
|
420
483
|
regex: false,
|