diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c50f8fd --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 OneWay + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/dist/min.css b/dist/min.css index 469dd9e..fcd8660 100644 --- a/dist/min.css +++ b/dist/min.css @@ -1 +1 @@ -.fade-enter-active,.fade-leave-active{transition:opacity .2s}.fade-enter,.fade-leave-active{opacity:0}.-col-group-container{border-bottom:1px solid #ddd}.-col-group{display:inline-block;width:150px;padding:0;vertical-align:top}.-col-group-title{display:block;margin:5px;padding:5px;border-bottom:1px solid #ddd;font-size:18px}.-col-group>li{margin-bottom:2px;padding-left:10px;list-style:none;line-height:20px;font-size:12px}.-col-group>li>input{vertical-align:-2px}.-complex-table{position:relative}.-complex-table table{background:#fff}.-table-body,.-table-footer,.-table-header{position:relative;overflow:scroll}.-fixed-table{position:absolute;top:0}.-fixed-table table{width:auto}.-left-fixed,.-right-fixed{box-shadow:1px 0 5px #ddd}.-summary-row{font-weight:700;background-color:#eee!important}.-page-size-select{display:inline-block;width:65px} \ No newline at end of file +.fade-enter-active,.fade-leave-active{transition:opacity .2s}.fade-enter,.fade-leave-active{opacity:0}.-col-group-container{border-bottom:1px solid #ddd}.-col-group{display:inline-block;margin-bottom:5px;padding:0;width:150px;vertical-align:top}.-col-group-title{display:block;margin:5px;padding:5px;border-bottom:1px solid #ddd;font-size:18px}.-col-group>li{margin-bottom:5px;padding-left:10px;list-style:none;line-height:20px;font-size:12px}.-col-group>li>*{margin:0;vertical-align:middle}.-complex-table{position:relative}.-complex-table table{background:#fff}.-table-body,.-table-footer,.-table-header{position:relative;overflow:scroll}.-fixed-table{position:absolute;top:0}.-fixed-table table{width:auto}.-left-fixed,.-right-fixed{box-shadow:1px 0 5px #ddd}.-summary-row{font-weight:700;background-color:#eee!important}.-page-size-select{display:inline-block;width:65px} \ No newline at end of file diff --git a/dist/min.js b/dist/min.js index 48e770b..8864018 100644 --- a/dist/min.js +++ b/dist/min.js @@ -1 +1 @@ -(function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Datatable=e():t.Datatable=e()})(this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};return e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="/",e(e.s=181)}([function(t,e){t.exports=function(t,e,n,r){var o,i=t=t||{},a=typeof t.default;"object"!==a&&"function"!==a||(o=t,i=t.default);var s="function"==typeof i?i.options:i;if(e&&(s.render=e.render,s.staticRenderFns=e.staticRenderFns),n&&(s._scopeId=n),r){var u=s.computed||(s.computed={});Object.keys(r).forEach(function(t){var e=r[t];u[t]=function(){return e}})}return{esModule:o,exports:i,options:s}}},function(t,e,n){var r=n(29),o="object"==typeof self&&self&&self.Object===Object&&self,i=r||o||Function("return this")();t.exports=i},function(t,e){var n=Array.isArray;t.exports=n},function(t,e,n){function r(t,e){var n=i(t,e);return o(n)?n:void 0}var o=n(96),i=n(120);t.exports=r},function(t,e){function n(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}t.exports=n},function(t,e,n){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};e.a={props:{columns:{type:Array,required:!0},data:{type:Array,required:!0},total:{type:Number,required:!0},query:{type:Object,required:!0},selection:Array,summary:Object,xprops:Object,HeaderSettings:{type:Boolean,default:!0},Pagination:{type:Boolean,default:!0},pageSizeOptions:{type:Array,default:function(){return[10,20,40,80,100]}},tblClass:[String,Object,Array],tblStyle:[String,Object,Array],fixHeaderAndSetBodyMaxHeight:Number,supportNested:[Boolean,String],supportBackup:Boolean},data:function(){for(var t=this;"Datatable"!==t.$options.name;)t=t.$parent;return{comp:t.$parent.$options.components}},methods:{forDynCompIs:function(t){return"object"===(void 0===t?"undefined":r(t))?t:this.comp[t]}}}},function(t,e,n){function r(t){return null==t?void 0===t?u:s:c&&c in Object(t)?i(t):a(t)}var o=n(9),i=n(117),a=n(144),s="[object Null]",u="[object Undefined]",c=o?o.toStringTag:void 0;t.exports=r},function(t,e){function n(t){return null!=t&&"object"==typeof t}t.exports=n},function(t,e,n){function r(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e-1&&t%1==0&&t<=r}var r=9007199254740991;t.exports=n},function(t,e,n){function r(t){return a(t)?o(t):i(t)}var o=n(82),i=n(99),a=n(37);t.exports=r},function(t,e){var n=Object.keys;t.exports=function(t,e){return Array.isArray(t)?t.splice.apply(t,[0,t.length].concat(e)):(n(t).forEach(function(e){delete t[e]}),n(e).forEach(function(n){t[n]=e[n]})),t}},function(t,e,n){var r=n(0)(n(172),n(61),null,null);t.exports=r.exports},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e,n){function r(t){var e=this.__data__=new o(t);this.size=e.size}var o=n(8),i=n(149),a=n(150),s=n(151),u=n(152),c=n(153);r.prototype.clear=i,r.prototype.delete=a,r.prototype.get=s,r.prototype.has=u,r.prototype.set=c,t.exports=r},function(t,e,n){function r(t,e){e=o(e,t);for(var n=0,r=e.length;null!=t&&np))return!1;var v=l.get(t);if(v&&l.get(e))return v==e;var h=-1,b=!0,y=n&u?new o:void 0;for(l.set(t,e),l.set(e,t);++h-1&&t%1==0&&t=e||n<0||S&&r>=g}function d(){var t=i();if(p(t))return v(t);j=setTimeout(d,f(t))}function v(t){return j=void 0,$&&_?r(t):(_=m=void 0,x)}function h(){void 0!==j&&clearTimeout(j),C=0,_=w=m=j=void 0}function b(){return void 0===j?x:v(i())}function y(){var t=i(),n=p(t);if(_=arguments,m=this,w=t,n){if(void 0===j)return l(w);if(S)return j=setTimeout(d,e),r(w)}return void 0===j&&(j=setTimeout(d,e)),x}var _,m,g,x,j,w,C=0,O=!1,S=!1,$=!0;if("function"!=typeof t)throw new TypeError(s);return e=a(e)||0,o(n)&&(O=!!n.leading,S="maxWait"in n,g=S?u(a(n.maxWait)||0,e):g,$="trailing"in n?!!n.trailing:$),y.cancel=h,y.flush=b,y}var o=n(4),i=n(160),a=n(165),s="Expected a function",u=Math.max,c=Math.min;t.exports=r},function(t,e){function n(t,e){return t===e||t!==t&&e!==e}t.exports=n},function(t,e,n){var r=n(93),o=n(7),i=Object.prototype,a=i.hasOwnProperty,s=i.propertyIsEnumerable,u=r(function(){return arguments}())?r:function(t){return o(t)&&a.call(t,"callee")&&!s.call(t,"callee")};t.exports=u},function(t,e,n){function r(t){return null!=t&&i(t.length)&&!o(t)}var o=n(39),i=n(19);t.exports=r},function(t,e,n){(function(t){var r=n(1),o=n(163),i="object"==typeof e&&e&&!e.nodeType&&e,a=i&&"object"==typeof t&&t&&!t.nodeType&&t,s=a&&a.exports===i,u=s?r.Buffer:void 0,c=u?u.isBuffer:void 0,l=c||o;t.exports=l}).call(e,n(23)(t))},function(t,e,n){function r(t){if(!i(t))return!1;var e=o(t);return e==s||e==u||e==a||e==c}var o=n(6),i=n(4),a="[object AsyncFunction]",s="[object Function]",u="[object GeneratorFunction]",c="[object Proxy]";t.exports=r},function(t,e,n){var r=n(97),o=n(106),i=n(143),a=i&&i.isTypedArray,s=a?o(a):r;t.exports=s},function(t,e,n){"use strict";e.a=function(t){return void 0===t.visible||""+t.visible=="true"}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(53),o=n.n(r);o.a.install=function(t,e){var n=e&&e.locale||{};t.prototype.$i18nForDatatable=function(t){return n[t]||t},t.component("Datatable",o.a)},"undefined"!=typeof window&&window.Vue&&window.Vue.use(o.a),e.default=o.a},function(t,e,n){n(69);var r=n(0)(n(167),n(59),null,null);t.exports=r.exports},function(t,e,n){n(71);var r=n(0)(n(168),n(65),null,null);t.exports=r.exports},function(t,e,n){n(70);var r=n(0)(n(169),n(60),null,null);t.exports=r.exports},function(t,e,n){var r=n(0)(n(170),n(58),null,null);t.exports=r.exports},function(t,e,n){var r=n(0)(n(171),n(63),null,null);t.exports=r.exports},function(t,e,n){var r=n(0)(n(173),n(55),null,null);t.exports=r.exports},function(t,e,n){n(68);var r=n(0)(n(174),n(57),null,null);t.exports=r.exports},function(t,e,n){var r=n(0)(n(175),n(62),null,null);t.exports=r.exports},function(t,e,n){var r=n(0)(n(176),n(64),null,null);t.exports=r.exports},function(t,e,n){n(66);var r=n(0)(n(177),n(54),null,null);t.exports=r.exports},function(t,e,n){n(67);var r=n(0)(n(178),n(56),null,null);t.exports=r.exports},function(t,e){t.exports={render:function(){var t=this,e=t.$createElement,n=t._self._c||e;return t.useComplexMode?n("div",{staticClass:"-complex-table",attrs:{name:"ComplexTable"}},[t._l(["Header","Body","Footer"],function(e){return["Footer"!==e||"Footer"===e&&t.summary?n("div",{ref:"wrappers",refInFor:!0,class:"-table-"+e.toLowerCase(),style:["Header"!==e&&{marginTop:"-"+t.SCROLLBAR_WIDTH+"px"},"Body"===e&&{maxHeight:t.fixHeaderAndSetBodyMaxHeight+"px"}],attrs:{name:"Table"+e+"Wrapper"}},[n("div",{attrs:{name:"NormalTable"+e}},[n("table-frame",t._b({},"table-frame",t.propsToNormalTable,!1),[n("Table"+e,t._b({tag:"component"},"component",t.propsToNormalTable,!1))],1)],1),t._v(" "),t.leftFixedColumns.length?n("div",{staticClass:"-left-fixed -fixed-table",style:{left:t.offsetLeft+"px"},attrs:{name:"LeftFixedTable"+e}},[n("table-frame",t._b({attrs:{"left-fixed":""}},"table-frame",t.propsToLeftFixedTable,!1),[n("Table"+e,t._b({tag:"component",attrs:{"left-fixed":""}},"component",t.propsToLeftFixedTable,!1))],1)],1):t._e(),t._v(" "),t.rightFixedColumns.length?n("div",{staticClass:"-right-fixed -fixed-table",style:{right:"-"+t.offsetLeft+"px"},attrs:{name:"RightFixedTable"+e}},[n("table-frame",t._b({attrs:{"right-fixed":""}},"table-frame",t.propsToRightFixedTable,!1),[n("Table"+e,t._b({tag:"component",attrs:{"right-fixed":""}},"component",t.propsToRightFixedTable,!1))],1)],1):t._e()]):t._e()]})],2):n("div",{attrs:{name:"SimpleTable"}},[n("table-frame",t._b({},"table-frame",t.propsToNormalTable,!1),[n("table-header",t._b({},"table-header",t.propsToNormalTable,!1)),t._v(" "),n("table-body",t._b({},"table-body",t.propsToNormalTable,!1)),t._v(" "),t.summary?n("table-footer",t._b({},"table-footer",t.propsToNormalTable,!1)):t._e()],1)],1)},staticRenderFns:[]}},function(t,e){t.exports={render:function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("tbody",[t.data.length?[t._l(t.data,function(e){return[n("tr",[t.shouldRenderSelection?n("td",[n("multi-select",{attrs:{selection:t.selection,row:e}})],1):t._e(),t._v(" "),t._l(t.columns,function(r){return n("td",{class:r.tdClass,style:r.tdStyle},[r.tdComp?n(t.forDynCompIs(r.tdComp),t._b({tag:"component",attrs:{row:e,field:r.field,value:e[r.field],nested:e.__nested__}},"component",t.$props,!1)):[t._v("\n "+t._s(e[r.field])+"\n ")]],2)})],2),t._v(" "),n("transition",{attrs:{name:"fade"}},[e.__nested__&&e.__nested__.visible?n("tr",[n("td",{attrs:{colspan:t.colLen}},[n(t.forDynCompIs(e.__nested__.comp),t._b({tag:"component",attrs:{row:e,nested:e.__nested__}},"component",t.$props,!1))],1)]):t._e()])]})]:t.leftFixed||t.rightFixed?t._e():n("tr",[n("td",{staticClass:"text-center text-muted",attrs:{colspan:t.colLen}},[t._v("\n ( "+t._s(t.$i18nForDatatable("No Data"))+" )\n ")])])],2)},staticRenderFns:[]}},function(t,e){t.exports={render:function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{attrs:{name:"Datatable"}},[t.$slots.default||t.HeaderSettings?n("div",{staticClass:"clearfix",staticStyle:{"margin-bottom":"10px"}},[t.HeaderSettings?n("header-settings",{staticClass:"pull-right",attrs:{columns:t.columns,"support-backup":t.supportBackup}}):t._e(),t._v(" "),t._t("default")],2):t._e(),t._v(" "),n("tbl",t._b({},"tbl",t.$props,!1)),t._v(" "),t.Pagination?n("div",{staticClass:"row",staticStyle:{"margin-top":"10px"}},[n("div",{staticClass:"col-sm-6",staticStyle:{"white-space":"nowrap"}},[n("strong",[t._v("\n "+t._s(t.$i18nForDatatable("Total"))+" "+t._s(t.total)+" "+t._s(t.$i18nForDatatable(","))+"\n ")]),t._v(" "),n("page-size-select",{attrs:{query:t.query,"page-size-options":t.pageSizeOptions}})],1),t._v(" "),n("div",{staticClass:"col-sm-6"},[n("pagination",{staticClass:"pull-right",attrs:{total:t.total,query:t.query}})],1)]):t._e()],1)},staticRenderFns:[]}},function(t,e){t.exports={render:function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("tfoot",{directives:[{name:"show",rawName:"v-show",value:t.data.length,expression:"data.length"}]},[n("tr",{staticClass:"-summary-row"},[t.shouldRenderSelection?n("td"):t._e(),t._v(" "),t._l(t.columns,function(e,r){return[t.summary[e.field]?n("td",{class:e.tdClass,style:e.tdStyle},[e.tdComp?n(t.forDynCompIs(e.tdComp),t._b({tag:"component",attrs:{row:t.summary,field:e.field,value:t.summary[e.field]}},"component",t.$props,!1)):[t._v("\n "+t._s(t.summary[e.field])+"\n ")]],2):n("td")]})],2)])},staticRenderFns:[]}},function(t,e){t.exports={render:function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("ul",{staticClass:"pagination",staticStyle:{margin:"0"},attrs:{name:"Pagination"}},[t.isFirstPage?t._e():n("li",{on:{click:function(e){t.turnPage(-1)}}},[t._m(0)]),t._v(" "),t._l(t.dspBtns,function(e){return n("li",{class:{active:e===t.curPage}},[e?n("a",{attrs:{href:"javascript:;"},on:{click:function(n){t.handleClick(e)}}},[t._v("\n "+t._s(e)+"\n ")]):n("a",[n("i",{staticClass:"fa fa-ellipsis-h"})])])}),t._v(" "),t.isLastPage?t._e():n("li",{on:{click:function(e){t.turnPage(1)}}},[t._m(1)])],2)},staticRenderFns:[function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("a",{attrs:{href:"javascript:;"}},[n("i",{staticClass:"fa fa-arrow-left"})])},function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("a",{attrs:{href:"javascript:;"}},[n("i",{staticClass:"fa fa-arrow-right"})])}]}},function(t,e){t.exports={render:function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("ul",{staticClass:"-col-group",attrs:{name:"ColumnGroup"}},[n("label",{staticClass:"-col-group-title"},[t._v("\n "+t._s("undefined"===t.groupName?"Columns":t.groupName)+"\n ")]),t._v(" "),t._l(t.columns,function(e,r){return n("li",[n("input",{attrs:{type:"checkbox",id:t.uuidGen(e.field||r),name:t.groupName,disabled:"string"==typeof e.visible},domProps:{checked:t.isColVisible(e)},on:{change:function(n){t.handleChange(e,n.target.checked)}}}),t._v(" "),n("label",{attrs:{for:t.uuidGen(e.field||r)}},[t._v("\n "+t._s(e.label||e.title)+"\n "),e.explain?n("i",{staticClass:"fa fa-info-circle",staticStyle:{cursor:"help"},attrs:{title:e.explain}}):t._e()])])})],2)},staticRenderFns:[]}},function(t,e){t.exports={render:function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("label",{attrs:{name:"PageSizeSelect"}},[n("select",{directives:[{name:"model",rawName:"v-model",value:t.query.limit,expression:"query.limit"}],staticClass:"form-control input-sm -page-size-select",on:{change:[function(e){var n=Array.prototype.filter.call(e.target.options,function(t){return t.selected}).map(function(t){return"_value"in t?t._value:t.value});t.query.limit=e.target.multiple?n:n[0]},function(e){t.query.offset=0}]}},t._l(t.pageSizeOptions,function(e){return n("option",{domProps:{value:e}},[t._v(t._s(e))])})),t._v("\n "+t._s(t.$i18nForDatatable("items / page"))+"\n")])},staticRenderFns:[]}},function(t,e){t.exports={render:function(){var t=this,e=t.$createElement;return(t._self._c||e)("input",{directives:[{name:"model",rawName:"v-model",value:t.status,expression:"status"}],staticStyle:{margin:"0"},attrs:{type:"checkbox",name:"MultiSelect"},domProps:{checked:Array.isArray(t.status)?t._i(t.status,null)>-1:t.status},on:{change:t.toggle,__c:function(e){var n=t.status,r=e.target,o=!!r.checked;if(Array.isArray(n)){var i=t._i(n,null);r.checked?i<0&&(t.status=n.concat([null])):i>-1&&(t.status=n.slice(0,i).concat(n.slice(i+1)))}else t.status=o}}})},staticRenderFns:[]}},function(t,e){t.exports={render:function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("table",{staticClass:"table table-striped table-hover",class:t.tblClass,staticStyle:{"margin-bottom":"0"},style:t.tblStyle},[n("colgroup",[t.shouldRenderSelection?n("col",{staticStyle:{width:"30px"}}):t._e(),t._v(" "),t._l(t.columns,function(t){return n("col",{class:t.colClass,style:t.colStyle})})],2),t._v(" "),t._t("default")],2)},staticRenderFns:[]}},function(t,e){t.exports={render:function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("a",{attrs:{href:"javascript:;",name:"HeadSort"},on:{click:t.handleClick}},[n("i",{class:t.cls})])},staticRenderFns:[]}},function(t,e){t.exports={render:function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("thead",[n("transition-group",{attrs:{name:"fade",tag:"tr"}},[t.shouldRenderSelection?n("th",{key:"--th-multi"},[n("multi-select",{attrs:{selection:t.selection,rows:t.data}})],1):t._e(),t._v(" "),t._l(t.columns,function(e,r){return n("th",{key:e.title||e.field||r,class:e.thClass,style:e.thStyle},[e.thComp?n(t.forDynCompIs(e.thComp),t._b({tag:"component",attrs:{column:e,field:e.field,title:e.title}},"component",t.$props,!1)):[t._v("\n "+t._s(e.title)+"\n ")],t._v(" "),e.explain?n("i",{staticClass:"fa fa-info-circle",staticStyle:{cursor:"help"},attrs:{title:e.explain}}):t._e(),t._v(" "),e.sortable?n("head-sort",{attrs:{field:e.field,query:t.query}}):t._e()],2)})],2)],1)},staticRenderFns:[]}},function(t,e){t.exports={render:function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"btn-group",attrs:{name:"HeaderSettings"}},[n("button",{ref:"dropdownBtn",staticClass:"btn btn-default dropdown-toggle"},[n("i",{staticClass:"fa",class:[t.usingBak&&"text-info",t.processingCls||"fa-cog"]}),t._v(" "),n("span",{staticClass:"caret"})]),t._v(" "),n("div",{staticClass:"dropdown-menu clearfix",style:t.drpMenuStyle},[n("div",{staticClass:"-col-group-container"},t._l(t.colGroups,function(t,e){return n("column-group",{key:e,ref:"colGroups",refInFor:!0,attrs:{"group-name":e,columns:t}})})),t._v(" "),n("div",{staticClass:"clearfix",staticStyle:{margin:"10px"}},[n("div",{staticClass:"btn-group btn-group-sm pull-right"},[n("button",{staticClass:"btn btn-default",on:{click:function(e){t.apply()}}},[t._v("\n "+t._s(t.$i18nForDatatable("Apply"))+"\n ")]),t._v(" "),t.supportBackup?[t._m(0),t._v(" "),n("ul",{staticClass:"dropdown-menu"},[n("li",{on:{click:function(e){t.apply(!0)}}},[n("a",{attrs:{href:"javascript:;"}},[n("i",{staticClass:"fa fa-floppy-o"}),t._v(" \n "+t._s(t.$i18nForDatatable("Apply and backup settings to local"))+"\n ")])]),t._v(" "),t.usingBak?n("li",{on:{click:function(e){t.rmBackup()}}},[n("a",{attrs:{href:"javascript:;"}},[n("i",{staticClass:"fa fa-trash-o text-danger"}),t._v(" \n "+t._s(t.$i18nForDatatable("Clear local settings backup and restore"))+"\n ")])]):t._e()])]:t._e()],2)]),t._v(" "),t.usingBak?n("small",{staticClass:"pull-left text-muted",staticStyle:{"margin-top":"-8px"}},[t._v("\n ( "+t._s(t.$i18nForDatatable("Using local settings"))+" )\n ")]):t._e()])])},staticRenderFns:[function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("button",{staticClass:"btn btn-default dropdown-toggle",staticStyle:{"box-shadow":"none"},attrs:{"data-toggle":"dropdown"}},[n("span",{staticClass:"caret"})])}]}},function(t,e){},function(t,e){},function(t,e){},function(t,e){},function(t,e){},function(t,e){},function(t,e){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){var r=n(3),o=n(1),i=r(o,"DataView");t.exports=i},function(t,e,n){function r(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e-1}var o=n(10);t.exports=r},function(t,e,n){function r(t,e){var n=this.__data__,r=o(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this}var o=n(10);t.exports=r},function(t,e,n){function r(){this.size=0,this.__data__={hash:new o,map:new(a||i),string:new o}}var o=n(74),i=n(8),a=n(16);t.exports=r},function(t,e,n){function r(t){var e=o(this,t).delete(t);return this.size-=e?1:0,e}var o=n(11);t.exports=r},function(t,e,n){function r(t){return o(this,t).get(t)}var o=n(11);t.exports=r},function(t,e,n){function r(t){return o(this,t).has(t)}var o=n(11);t.exports=r},function(t,e,n){function r(t,e){var n=o(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this}var o=n(11);t.exports=r},function(t,e){function n(t){var e=-1,n=Array(t.size);return t.forEach(function(t,r){n[++e]=[r,t]}),n}t.exports=n},function(t,e,n){function r(t){var e=o(t,function(t){return n.size===i&&n.clear(),t}),n=e.cache;return e}var o=n(159),i=500;t.exports=r},function(t,e,n){var r=n(145),o=r(Object.keys,Object);t.exports=o},function(t,e,n){(function(t){var r=n(29),o="object"==typeof e&&e&&!e.nodeType&&e,i=o&&"object"==typeof t&&t&&!t.nodeType&&t,a=i&&i.exports===o,s=a&&r.process,u=function(){try{return s&&s.binding&&s.binding("util")}catch(t){}}();t.exports=u}).call(e,n(23)(t))},function(t,e){function n(t){return o.call(t)}var r=Object.prototype,o=r.toString;t.exports=n},function(t,e){function n(t,e){return function(n){return t(e(n))}}t.exports=n},function(t,e){function n(t){return this.__data__.set(t,r),this}var r="__lodash_hash_undefined__";t.exports=n},function(t,e){function n(t){return this.__data__.has(t)}t.exports=n},function(t,e){function n(t){var e=-1,n=Array(t.size);return t.forEach(function(t){n[++e]=t}),n}t.exports=n},function(t,e,n){function r(){this.__data__=new o,this.size=0}var o=n(8);t.exports=r},function(t,e){function n(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n}t.exports=n},function(t,e){function n(t){return this.__data__.get(t)}t.exports=n},function(t,e){function n(t){return this.__data__.has(t)}t.exports=n},function(t,e,n){function r(t,e){var n=this.__data__;if(n instanceof o){var r=n.__data__;if(!i||r.length=this.total},isLastPage:function(){return+this.query.offset+ +this.query.limit>=this.total},totalPage:function(){return Math.ceil(this.total/+this.query.limit)},curPage:function(){return Math.ceil(+this.query.offset/+this.query.limit)+1},dspBtns:function(){var t=this.totalPage,e=this.curPage;return t<=9?function(t){for(var e=Array(t);t;)e[t-1]=t--;return e}(t):e<=5?[1,2,3,4,5,6,7,0,t]:e>=t-4?[1,0,t-6,t-5,t-4,t-3,t-2,t-1,t]:[1,0,e-2,e-1,e,e+1,e+2,0,t]}},methods:{handleClick:function(t){this.query.offset=(t-1)*+this.query.limit},turnPage:function(t){t<0&&this.isFirstPage||t>0&&this.isLastPage||(this.query.offset=+this.query.offset+t*+this.query.limit)}}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default={name:"HeadSort",props:{field:{type:String,required:!0},query:{type:Object,required:!0}},data:function(){return{order:""}},computed:{cls:function(){return["fa",("fa-sort-"+this.order).replace(/-$/,""),{"text-muted":!this.order}]}},watch:{query:{handler:function(t){var e=t.sort,n=t.order;this.order=e===this.field?n:""},deep:!0,immediate:!0}},methods:{handleClick:function(){var t=this.query,e=this.order;t.sort=this.field,t.order=this.order="desc"===e?"asc":"desc"}}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(21),o=n.n(r);e.default={name:"MultiSelect",props:{selection:{type:Array,required:!0},row:Object,rows:Array},data:function(){return{status:!1}},computed:{pos:function(){var t=this.selection,e=this.row;if(t&&e)return t.indexOf(e)}},methods:{toggle:function(){var t=this.selection,e=this.row,n=this.rows,r=this.status,i=this.pos;if(n)return void o()(t,r?n:[]);e&&(r&&-1===i&&t.push(e),!r&&i>=0&&t.splice(i,1))}},watch:{rows:function(){o()(this.selection,[])},selection:function(t){if(this.row)return void(this.status=this.pos>=0);this.rows&&(this.status=this.rows.length===t.length&&t.length)}}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(22),o=n.n(r),i=n(5),a=n(15);e.default={name:"TableBody",components:{MultiSelect:o.a},mixins:[i.a,a.a],computed:{colLen:function(){return this.columns.length+!!this.selection}}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(5),o=n(15);e.default={name:"TableFooter",mixins:[r.a,o.a]}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(5),o=n(15);e.default={name:"TableFrame",mixins:[r.a,o.a]}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(47),o=n.n(r),i=n(22),a=n.n(i),s=n(5),u=n(15);e.default={name:"TableHeader",components:{HeadSort:o.a,MultiSelect:a.a},mixins:[s.a,u.a]}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(50),o=n.n(r),i=n(51),a=n.n(i),s=n(48),u=n.n(s),c=n(49),l=n.n(c),f=n(5),p=n(41),d=n(179),v=n(180),h=Object.assign||function(t){for(var e=1;e-1&&t%1==0&&t<=r}var r=9007199254740991;t.exports=n},function(t,e,n){function r(t){return a(t)?o(t):i(t)}var o=n(82),i=n(99),a=n(36);t.exports=r},function(t,e,n){var r=n(0)(n(172),n(61),null,null);t.exports=r.exports},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e,n){function r(t){var e=this.__data__=new o(t);this.size=e.size}var o=n(8),i=n(149),a=n(150),s=n(151),u=n(152),c=n(153);r.prototype.clear=i,r.prototype.delete=a,r.prototype.get=s,r.prototype.has=u,r.prototype.set=c,t.exports=r},function(t,e,n){function r(t,e){e=o(e,t);for(var n=0,r=e.length;null!=t&&np))return!1;var v=l.get(t);if(v&&l.get(e))return v==e;var h=-1,b=!0,y=n&u?new o:void 0;for(l.set(t,e),l.set(e,t);++h-1&&t%1==0&&t=e||n<0||S&&r>=g}function d(){var t=i();if(p(t))return v(t);j=setTimeout(d,f(t))}function v(t){return j=void 0,k&&_?r(t):(_=m=void 0,x)}function h(){void 0!==j&&clearTimeout(j),C=0,_=w=m=j=void 0}function b(){return void 0===j?x:v(i())}function y(){var t=i(),n=p(t);if(_=arguments,m=this,w=t,n){if(void 0===j)return l(w);if(S)return j=setTimeout(d,e),r(w)}return void 0===j&&(j=setTimeout(d,e)),x}var _,m,g,x,j,w,C=0,O=!1,S=!1,k=!0;if("function"!=typeof t)throw new TypeError(s);return e=a(e)||0,o(n)&&(O=!!n.leading,S="maxWait"in n,g=S?u(a(n.maxWait)||0,e):g,k="trailing"in n?!!n.trailing:k),y.cancel=h,y.flush=b,y}var o=n(4),i=n(160),a=n(165),s="Expected a function",u=Math.max,c=Math.min;t.exports=r},function(t,e){function n(t,e){return t===e||t!==t&&e!==e}t.exports=n},function(t,e,n){var r=n(93),o=n(7),i=Object.prototype,a=i.hasOwnProperty,s=i.propertyIsEnumerable,u=r(function(){return arguments}())?r:function(t){return o(t)&&a.call(t,"callee")&&!s.call(t,"callee")};t.exports=u},function(t,e,n){function r(t){return null!=t&&i(t.length)&&!o(t)}var o=n(38),i=n(19);t.exports=r},function(t,e,n){(function(t){var r=n(1),o=n(163),i="object"==typeof e&&e&&!e.nodeType&&e,a=i&&"object"==typeof t&&t&&!t.nodeType&&t,s=a&&a.exports===i,u=s?r.Buffer:void 0,c=u?u.isBuffer:void 0,l=c||o;t.exports=l}).call(e,n(22)(t))},function(t,e,n){function r(t){if(!i(t))return!1;var e=o(t);return e==s||e==u||e==a||e==c}var o=n(6),i=n(4),a="[object AsyncFunction]",s="[object Function]",u="[object GeneratorFunction]",c="[object Proxy]";t.exports=r},function(t,e,n){var r=n(97),o=n(106),i=n(143),a=i&&i.isTypedArray,s=a?o(a):r;t.exports=s},function(t,e,n){"use strict";e.a=function(t){return void 0===t.visible||""+t.visible=="true"}},function(t,e,n){"use strict";function r(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e-1:t.status},on:{change:[function(e){var n=t.status,r=e.target,o=!!r.checked;if(Array.isArray(n)){var i=t._i(n,null);r.checked?i<0&&(t.status=n.concat([null])):i>-1&&(t.status=n.slice(0,i).concat(n.slice(i+1)))}else t.status=o},t.toggle]}})},staticRenderFns:[]}},function(t,e){t.exports={render:function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("table",{staticClass:"table table-striped table-hover",class:t.tblClass,staticStyle:{"margin-bottom":"0"},style:t.tblStyle},[n("colgroup",[t.shouldRenderSelection?n("col",{staticStyle:{width:"30px"}}):t._e(),t._v(" "),t._l(t.columns,function(t){return n("col",{class:t.colClass,style:t.colStyle})})],2),t._v(" "),t._t("default")],2)},staticRenderFns:[]}},function(t,e){t.exports={render:function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("a",{attrs:{href:"#",name:"HeadSort"},on:{click:function(e){e.preventDefault(),t.handleClick(e)}}},[n("i",{class:t.cls})])},staticRenderFns:[]}},function(t,e){t.exports={render:function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("thead",[n("transition-group",{attrs:{name:"fade",tag:"tr"}},[t.shouldRenderSelection?n("th",{key:"--th-multi"},[n("multi-select",{attrs:{selection:t.selection,rows:t.data}})],1):t._e(),t._v(" "),t._l(t.columns,function(e,r){return n("th",{key:e.title||e.field||r,class:e.thClass,style:e.thStyle},[e.thComp?n(t.forDynCompIs(e.thComp),t._b({tag:"component",attrs:{column:e,field:e.field,title:e.title}},"component",t.$props,!1)):[t._v("\n "+t._s(e.title)+"\n ")],t._v(" "),e.explain?n("i",{staticClass:"fa fa-info-circle",staticStyle:{cursor:"help"},attrs:{title:e.explain}}):t._e(),t._v(" "),e.sortable?n("head-sort",{attrs:{field:e.field,query:t.query}}):t._e()],2)})],2)],1)},staticRenderFns:[]}},function(t,e){t.exports={render:function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"btn-group",attrs:{name:"HeaderSettings"}},[n("button",{ref:"dropdownBtn",staticClass:"btn btn-default dropdown-toggle",attrs:{type:"button"}},[n("i",{staticClass:"fa",class:[t.usingBak&&"text-info",t.processingCls||"fa-cog"]}),t._v(" "),n("span",{staticClass:"caret"})]),t._v(" "),n("div",{staticClass:"dropdown-menu clearfix",style:t.drpMenuStyle},[n("div",{staticClass:"-col-group-container"},t._l(t.colGroups,function(t,e){return n("column-group",{key:e,ref:"colGroups",refInFor:!0,attrs:{"group-name":e,columns:t}})})),t._v(" "),n("div",{staticClass:"clearfix",staticStyle:{margin:"10px 0"}},[n("div",{staticClass:"btn-group btn-group-sm pull-right"},[n("button",{staticClass:"btn btn-default",attrs:{type:"button"},on:{click:function(e){t.apply()}}},[t._v("\n "+t._s(t.$i18nForDatatable("Apply"))+"\n ")]),t._v(" "),t.supportBackup?[t._m(0),t._v(" "),n("ul",{staticClass:"dropdown-menu"},[n("li",{on:{click:function(e){t.apply(!0)}}},[n("a",{attrs:{href:"#"},on:{click:function(t){t.preventDefault()}}},[n("i",{staticClass:"fa fa-floppy-o"}),t._v(" \n "+t._s(t.$i18nForDatatable("Apply and backup settings to local"))+"\n ")])]),t._v(" "),t.usingBak?n("li",{on:{click:function(e){t.rmBackup()}}},[n("a",{attrs:{href:"#"},on:{click:function(t){t.preventDefault()}}},[n("i",{staticClass:"fa fa-trash-o text-danger"}),t._v(" \n "+t._s(t.$i18nForDatatable("Clear local settings backup and restore"))+"\n ")])]):t._e()])]:t._e()],2)]),t._v(" "),t.usingBak?n("small",{staticClass:"pull-left text-muted",staticStyle:{"margin-top":"-8px"}},[t._v("\n ( "+t._s(t.$i18nForDatatable("Using local settings"))+" )\n ")]):t._e()])])},staticRenderFns:[function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("button",{staticClass:"btn btn-default dropdown-toggle",staticStyle:{"box-shadow":"none"},attrs:{"data-toggle":"dropdown",type:"button"}},[n("span",{staticClass:"caret"})])}]}},function(t,e){},function(t,e){},function(t,e){},function(t,e){},function(t,e){},function(t,e){},function(t,e){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){var r=n(3),o=n(1),i=r(o,"DataView");t.exports=i},function(t,e,n){function r(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e-1}var o=n(10);t.exports=r},function(t,e,n){function r(t,e){var n=this.__data__,r=o(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this}var o=n(10);t.exports=r},function(t,e,n){function r(){this.size=0,this.__data__={hash:new o,map:new(a||i),string:new o}}var o=n(74),i=n(8),a=n(16);t.exports=r},function(t,e,n){function r(t){var e=o(this,t).delete(t);return this.size-=e?1:0,e}var o=n(11);t.exports=r},function(t,e,n){function r(t){return o(this,t).get(t)}var o=n(11);t.exports=r},function(t,e,n){function r(t){return o(this,t).has(t)}var o=n(11);t.exports=r},function(t,e,n){function r(t,e){var n=o(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this}var o=n(11);t.exports=r},function(t,e){function n(t){var e=-1,n=Array(t.size);return t.forEach(function(t,r){n[++e]=[r,t]}),n}t.exports=n},function(t,e,n){function r(t){var e=o(t,function(t){return n.size===i&&n.clear(),t}),n=e.cache;return e}var o=n(159),i=500;t.exports=r},function(t,e,n){var r=n(145),o=r(Object.keys,Object);t.exports=o},function(t,e,n){(function(t){var r=n(28),o="object"==typeof e&&e&&!e.nodeType&&e,i=o&&"object"==typeof t&&t&&!t.nodeType&&t,a=i&&i.exports===o,s=a&&r.process,u=function(){try{return s&&s.binding&&s.binding("util")}catch(t){}}();t.exports=u}).call(e,n(22)(t))},function(t,e){function n(t){return o.call(t)}var r=Object.prototype,o=r.toString;t.exports=n},function(t,e){function n(t,e){return function(n){return t(e(n))}}t.exports=n},function(t,e){function n(t){return this.__data__.set(t,r),this}var r="__lodash_hash_undefined__";t.exports=n},function(t,e){function n(t){return this.__data__.has(t)}t.exports=n},function(t,e){function n(t){var e=-1,n=Array(t.size);return t.forEach(function(t){n[++e]=t}),n}t.exports=n},function(t,e,n){function r(){this.__data__=new o,this.size=0}var o=n(8);t.exports=r},function(t,e){function n(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n}t.exports=n},function(t,e){function n(t){return this.__data__.get(t)}t.exports=n},function(t,e){function n(t){return this.__data__.has(t)}t.exports=n},function(t,e,n){function r(t,e){var n=this.__data__;if(n instanceof o){var r=n.__data__;if(!i||r.length=this.total},isLastPage:function(){return+this.query.offset+ +this.query.limit>=this.total},totalPage:function(){return Math.ceil(this.total/+this.query.limit)},curPage:function(){return Math.ceil(+this.query.offset/+this.query.limit)+1},dspBtns:function(){var t=this.totalPage,e=this.curPage;return t<=9?function(t){for(var e=Array(t);t;)e[t-1]=t--;return e}(t):e<=5?[1,2,3,4,5,6,7,0,t]:e>=t-4?[1,0,t-6,t-5,t-4,t-3,t-2,t-1,t]:[1,0,e-2,e-1,e,e+1,e+2,0,t]}},methods:{handleClick:function(t){this.query.offset=(t-1)*+this.query.limit},turnPage:function(t){t<0&&this.isFirstPage||t>0&&this.isLastPage||(this.query.offset=+this.query.offset+t*+this.query.limit)}}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default={name:"HeadSort",props:{field:{type:String,required:!0},query:{type:Object,required:!0}},data:function(){return{order:""}},computed:{cls:function(){var t=this.order;return["fa",{"fa-sort text-muted":!t,"fa-sort-up":"asc"===t,"fa-sort-down":"desc"===t}]}},watch:{query:{handler:function(t){var e=t.sort,n=t.order;this.order=e===this.field?n:""},deep:!0,immediate:!0}},methods:{handleClick:function(){var t=this.query,e=this.order;t.sort=this.field,t.order=this.order="desc"===e?"asc":"desc"}}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(41);e.default={name:"MultiSelect",props:{selection:{type:Array,required:!0},row:Object,rows:Array},data:function(){return{status:!1}},computed:{pos:function(){var t=this.selection,e=this.row;if(t&&e)return t.indexOf(e)}},methods:{toggle:function(){var t=this.selection,e=this.row,o=this.rows,i=this.status,a=this.pos;if(o)return void n.i(r.a)(t,i?o:[]);e&&(i&&-1===a&&t.push(e),!i&&a>=0&&t.splice(a,1))}},watch:{rows:function(){n.i(r.a)(this.selection,[])},selection:function(t){if(this.row)return void(this.status=this.pos>=0);this.rows&&(this.status=this.rows.length===t.length&&t.length)}}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(21),o=n.n(r),i=n(5),a=n(15);e.default={name:"TableBody",components:{MultiSelect:o.a},mixins:[i.a,a.a],computed:{colLen:function(){return this.columns.length+!!this.selection}}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(5),o=n(15);e.default={name:"TableFooter",mixins:[r.a,o.a]}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(5),o=n(15);e.default={name:"TableFrame",mixins:[r.a,o.a]}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(47),o=n.n(r),i=n(21),a=n.n(i),s=n(5),u=n(15);e.default={name:"TableHeader",components:{HeadSort:o.a,MultiSelect:a.a},mixins:[s.a,u.a]}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(50),o=n.n(r),i=n(51),a=n.n(i),s=n(48),u=n.n(s),c=n(49),l=n.n(c),f=n(5),p=n(179),d=n(40),v=n(182),h=Object.assign||function(t){for(var e=1;e { - if (!item.__nested__) { - this.$set(item, '__nested__', { - comp: '', // name of the current nested component + if (!item[MAGIC_FIELD]) { + this.$set(item, MAGIC_FIELD, { + comp: undefined, // current nested component visible: false, $toggle (comp, visible) { switch (arguments.length) { @@ -31,6 +32,7 @@ watch: { this.visible = comp break case 'string': + case 'object': this.comp = comp this.visible = !this.visible break @@ -44,7 +46,7 @@ watch: { } }) // omit the implementation of accordion... - Object.defineProperty(item, '__nested__', { enumerable: false }) + Object.defineProperty(item, MAGIC_FIELD, { enumerable: false }) } }) } diff --git a/doc/en/details/props-query.md b/doc/en/details/props-query.md index b91b74c..b008f00 100644 --- a/doc/en/details/props-query.md +++ b/doc/en/details/props-query.md @@ -26,6 +26,12 @@ If there are any other query conditions (such as `keyword`), you should: *** +**Hereon, I have to point out a very common bug:** +**Any changes to `query` should reset `query.offset` to `0` (e.g. [`examples/src/Advanced/comps/th-Filter.vue - Line 39`](https://github.com/OneWayTech/vue2-datatable/blob/master/examples/src/Advanced/comps/th-Filter.vue#L39))** +**Otherwise, the query result is doomed to be wrong!** + +*** + #### ⊙ Extention Now we have a very common scenario: remain the query conditions after the full page reload. diff --git a/doc/en/getting-started.md b/doc/en/getting-started.md index 4427f14..3e330ee 100644 --- a/doc/en/getting-started.md +++ b/doc/en/getting-started.md @@ -4,6 +4,22 @@ `>_ npm i -S vue2-datatable-component` +```js +// Webpack configuration +module: { + rules: [ + { + test: /\.js$/, + loader: 'babel-loader?cacheDirectory', + include: [ + , + /vue2-datatable-component/ // <-- add this! + ] + } + ] +} +``` + ```js import Vue from 'vue' import Datatable from 'vue2-datatable-component' diff --git a/doc/zh-cn/README.md b/doc/zh-cn/README.md index e65b337..043efd1 100644 --- a/doc/zh-cn/README.md +++ b/doc/zh-cn/README.md @@ -9,8 +9,7 @@ 本 Datatable 的依赖如下: -* BootStrap 3.x + Font Awesome 4.x(全局引入) +* BootStrap 3 + Font Awesome(全局引入) * [lodash: groupBy / throttle / debounce](https://lodash.com/docs) -* [replace-with](https://github.com/kenberkeley/replace-with) 注:*BootStrap* 以及 *Font Awesome* 的可替换性极强,您完全可以使用其他库替代(一般就是改一下类名即可) diff --git a/doc/zh-cn/_sidebar.md b/doc/zh-cn/_sidebar.md index 0eb9aad..70bd080 100644 --- a/doc/zh-cn/_sidebar.md +++ b/doc/zh-cn/_sidebar.md @@ -11,5 +11,5 @@ - [动态组件](zh-cn/details/dynamic-comps) - [国际化](zh-cn/i18n) - [自定制 (DIY)](zh-cn/DIY) -- [问题反馈(issues)](zh-cn/https://github.com/OneWayTech/vue2-datatable/issues) -- [版本迭代(releases)](https://github.com/OneWayTech/vue2-datatable/releases) +- [问题反馈(issues)](https://github.com/OneWayTech/vue2-datatable/issues) +- [自定制插件](https://github.com/OneWayTech/vue2-datatable/tree/master/plugins) diff --git a/doc/zh-cn/details/props-data.md b/doc/zh-cn/details/props-data.md index 7622541..439f60a 100644 --- a/doc/zh-cn/details/props-data.md +++ b/doc/zh-cn/details/props-data.md @@ -12,10 +12,11 @@ watch: { const { supportNested } = this // support nested components feature with extra magic if (supportNested) { + const MAGIC_FIELD = '__nested__' data.forEach(item => { - if (!item.__nested__) { - this.$set(item, '__nested__', { - comp: '', // name of the current nested component + if (!item[MAGIC_FIELD]) { + this.$set(item, MAGIC_FIELD, { + comp: undefined, // current nested component visible: false, $toggle (comp, visible) { switch (arguments.length) { @@ -28,6 +29,7 @@ watch: { this.visible = comp break case 'string': + case 'object': this.comp = comp this.visible = !this.visible break @@ -41,7 +43,7 @@ watch: { } }) // 省略手风琴的实现... - Object.defineProperty(item, '__nested__', { enumerable: false }) + Object.defineProperty(item, MAGIC_FIELD, { enumerable: false }) } }) } diff --git a/doc/zh-cn/details/props-query.md b/doc/zh-cn/details/props-query.md index 32ac3c6..552ac3a 100644 --- a/doc/zh-cn/details/props-query.md +++ b/doc/zh-cn/details/props-query.md @@ -21,6 +21,12 @@ created () { > > 温馨提示:若采用 Ajax - GET 请求,赋值较为复杂时(例如一个网址)最好使用 [`encodeURIComponent`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent) 转义 +**在此必须指出极度常见的 bug:对 `query` 的任何修改** +**都应该重置 `query.offset` 为 `0`**(参考 [`examples/src/Advanced/comps/th-Filter.vue - Line 39`](https://github.com/OneWayTech/vue2-datatable/blob/master/examples/src/Advanced/comps/th-Filter.vue#L39)) +**否则查询结果必然有误!** + +*** + 在此提一个常见的需求:实现刷新后保持查询条件 最常见的解决方案是**同步查询条件到 URL** 稍微把基本例子改一下就可以了: diff --git a/doc/zh-cn/getting-started.md b/doc/zh-cn/getting-started.md index 56fcaac..21dada3 100644 --- a/doc/zh-cn/getting-started.md +++ b/doc/zh-cn/getting-started.md @@ -4,6 +4,22 @@ `>_ npm i -S vue2-datatable-component` +```js +// Webpack configuration +module: { + rules: [ + { + test: /\.js$/, + loader: 'babel-loader?cacheDirectory', + include: [ + , + /vue2-datatable-component/ // <-- 添加这行 + ] + } + ] +} +``` + ```js import Vue from 'vue' import Datatable from 'vue2-datatable-component' diff --git a/examples/dist/client.af43b3be.css b/examples/dist/client.07979e74.css similarity index 56% rename from examples/dist/client.af43b3be.css rename to examples/dist/client.07979e74.css index 068eca7..e6d9c6f 100644 --- a/examples/dist/client.af43b3be.css +++ b/examples/dist/client.07979e74.css @@ -1 +1 @@ -html{position:relative;min-height:100%}footer{position:absolute;left:0;right:0;bottom:0;padding:5px 0;font-size:12px;text-align:center;color:#afafaf}.w-240{width:240px}.-nested-dsp-row-comp{position:relative;padding:10px}.-nested-dsp-row-close-btn{position:absolute;top:5px;right:5px}.-td-color-comp{width:50px;height:20px;font-size:12px;font-weight:700;text-align:center;line-height:20px}.-th-createtime-comp{display:inline-block;margin-bottom:-6px}.-th-createtime-comp>select{display:inline-block;width:80px;height:26px}.-nested-comp-open-btn{color:#fff!important;background-color:#337ab7!important}input[type=search]::-webkit-search-cancel-button{-webkit-appearance:searchfield-cancel-button;cursor:pointer}.fade-enter-active,.fade-leave-active{transition:opacity .2s}.fade-enter,.fade-leave-active{opacity:0}.-col-group-container{border-bottom:1px solid #ddd}.-col-group{display:inline-block;width:150px;padding:0;vertical-align:top}.-col-group-title{display:block;margin:5px;padding:5px;border-bottom:1px solid #ddd;font-size:18px}.-col-group>li{margin-bottom:2px;padding-left:10px;list-style:none;line-height:20px;font-size:12px}.-col-group>li>input{vertical-align:-2px}.-complex-table{position:relative}.-complex-table table{background:#fff}.-table-body,.-table-footer,.-table-header{position:relative;overflow:scroll}.-fixed-table{position:absolute;top:0}.-fixed-table table{width:auto}.-left-fixed,.-right-fixed{box-shadow:1px 0 5px #ddd}.-summary-row{font-weight:700;background-color:#eee!important}.-page-size-select{display:inline-block;width:65px} \ No newline at end of file +html{position:relative;min-height:100%}footer{position:absolute;left:0;right:0;bottom:0;padding:5px 0;font-size:12px;text-align:center;color:#afafaf}.w-240{width:240px}.-nested-dsp-row-comp{position:relative;padding:10px}.-nested-dsp-row-close-btn{position:absolute;top:5px;right:5px}.-td-color-comp{width:50px;height:20px;font-size:12px;font-weight:700;text-align:center;line-height:20px}.-th-createtime-comp{display:inline-block;margin-bottom:-6px}.-th-createtime-comp>select{display:inline-block;width:80px;height:26px}.-nested-comp-open-btn{color:#fff!important;background-color:#337ab7!important}input[type=search]::-webkit-search-cancel-button{-webkit-appearance:searchfield-cancel-button;cursor:pointer}.fade-enter-active,.fade-leave-active{transition:opacity .2s}.fade-enter,.fade-leave-active{opacity:0}.-col-group-container{border-bottom:1px solid #ddd}.-col-group{display:inline-block;margin-bottom:5px;padding:0;width:150px;vertical-align:top}.-col-group-title{display:block;margin:5px;padding:5px;border-bottom:1px solid #ddd;font-size:18px}.-col-group>li{margin-bottom:5px;padding-left:10px;list-style:none;line-height:20px;font-size:12px}.-col-group>li>*{margin:0;vertical-align:middle}.-complex-table{position:relative}.-complex-table table{background:#fff}.-table-body,.-table-footer,.-table-header{position:relative;overflow:scroll}.-fixed-table{position:absolute;top:0}.-fixed-table table{width:auto}.-left-fixed,.-right-fixed{box-shadow:1px 0 5px #ddd}.-summary-row{font-weight:700;background-color:#eee!important}.-page-size-select{display:inline-block;width:65px} \ No newline at end of file diff --git a/examples/dist/client.1e46594b.js b/examples/dist/client.1e46594b.js deleted file mode 100644 index 185e63b..0000000 --- a/examples/dist/client.1e46594b.js +++ /dev/null @@ -1 +0,0 @@ -(function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var n={};e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=601)})([function(t,e,n){var r=n(2),i=n(23),o=n(13),a=n(14),s=n(20),u=function(t,e,n){var c,l,f,h,d=t&u.F,p=t&u.G,v=t&u.S,m=t&u.P,y=t&u.B,g=p?r:v?r[e]||(r[e]={}):(r[e]||{}).prototype,_=p?i:i[e]||(i[e]={}),b=_.prototype||(_.prototype={});p&&(n=e);for(c in n)l=!d&&g&&void 0!==g[c],f=(l?g:n)[c],h=y&&l?s(f,r):m&&"function"==typeof f?s(Function.call,f):f,g&&a(g,c,f,t&u.U),_[c]!=f&&o(_,c,h),m&&b[c]!=f&&(b[c]=f)};r.core=i,u.F=1,u.G=2,u.S=4,u.P=8,u.B=16,u.W=32,u.U=64,u.R=128,t.exports=u},function(t,e,n){var r=n(4);t.exports=function(t){if(!r(t))throw TypeError(t+" is not an object!");return t}},function(t,e){var n=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=n)},function(t,e){t.exports=function(t){try{return!!t()}catch(t){return!0}}},function(t,e){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,e,n){var r=n(70)("wks"),i=n(44),o=n(2).Symbol,a="function"==typeof o;(t.exports=function(t){return r[t]||(r[t]=a&&o[t]||(a?o:i)("Symbol."+t))}).store=r},function(t,e){t.exports=function(t,e,n,r){var i,o=t=t||{},a=typeof t.default;"object"!==a&&"function"!==a||(i=t,o=t.default);var s="function"==typeof o?o.options:o;if(e&&(s.render=e.render,s.staticRenderFns=e.staticRenderFns),n&&(s._scopeId=n),r){var u=s.computed||(s.computed={});Object.keys(r).forEach(function(t){var e=r[t];u[t]=function(){return e}})}return{esModule:i,exports:o,options:s}}},function(t,e,n){t.exports=!n(3)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(t,e,n){var r=n(1),i=n(134),o=n(27),a=Object.defineProperty;e.f=n(7)?Object.defineProperty:function(t,e,n){if(r(t),e=o(e,!0),r(n),i)try{return a(t,e,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported!");return"value"in n&&(t[e]=n.value),t}},function(t,e,n){var r=n(26),i=Math.min;t.exports=function(t){return t>0?i(r(t),9007199254740991):0}},function(t,e,n){var r=n(24);t.exports=function(t){return Object(r(t))}},function(t,e){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},function(t,e){var n={}.hasOwnProperty;t.exports=function(t,e){return n.call(t,e)}},function(t,e,n){var r=n(8),i=n(40);t.exports=n(7)?function(t,e,n){return r.f(t,e,i(1,n))}:function(t,e,n){return t[e]=n,t}},function(t,e,n){var r=n(2),i=n(13),o=n(12),a=n(44)("src"),s=Function.toString,u=(""+s).split("toString");n(23).inspectSource=function(t){return s.call(t)},(t.exports=function(t,e,n,s){var c="function"==typeof n;c&&(o(n,"name")||i(n,"name",e)),t[e]!==n&&(c&&(o(n,a)||i(n,a,t[e]?""+t[e]:u.join(String(e)))),t===r?t[e]=n:s?t[e]?t[e]=n:i(t,e,n):(delete t[e],i(t,e,n)))})(Function.prototype,"toString",function(){return"function"==typeof this&&this[a]||s.call(this)})},function(t,e,n){var r=n(0),i=n(3),o=n(24),a=/"/g,s=function(t,e,n,r){var i=String(o(t)),s="<"+e;return""!==n&&(s+=" "+n+'="'+String(r).replace(a,""")+'"'),s+">"+i+""};t.exports=function(t,e){var n={};n[t]=e(s),r(r.P+r.F*i(function(){var e=""[t]('"');return e!==e.toLowerCase()||e.split('"').length>3}),"String",n)}},function(t,e,n){var r=n(55),i=n(40),o=n(18),a=n(27),s=n(12),u=n(134),c=Object.getOwnPropertyDescriptor;e.f=n(7)?c:function(t,e){if(t=o(t),e=a(e,!0),u)try{return c(t,e)}catch(t){}if(s(t,e))return i(!r.f.call(t,e),t[e])}},function(t,e,n){var r=n(12),i=n(10),o=n(98)("IE_PROTO"),a=Object.prototype;t.exports=Object.getPrototypeOf||function(t){return t=i(t),r(t,o)?t[o]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?a:null}},function(t,e,n){var r=n(54),i=n(24);t.exports=function(t){return r(i(t))}},function(t,e){var n={}.toString;t.exports=function(t){return n.call(t).slice(8,-1)}},function(t,e,n){var r=n(11);t.exports=function(t,e,n){if(r(t),void 0===e)return t;switch(n){case 1:return function(n){return t.call(e,n)};case 2:return function(n,r){return t.call(e,n,r)};case 3:return function(n,r,i){return t.call(e,n,r,i)}}return function(){return t.apply(e,arguments)}}},function(t,e,n){"use strict";var r=n(3);t.exports=function(t,e){return!!t&&r(function(){e?t.call(null,function(){},1):t.call(null)})}},function(t,e,n){var r=n(20),i=n(54),o=n(10),a=n(9),s=n(83);t.exports=function(t,e){var n=1==t,u=2==t,c=3==t,l=4==t,f=6==t,h=5==t||f,d=e||s;return function(e,s,p){for(var v,m,y=o(e),g=i(y),_=r(s,p,3),b=a(g.length),x=0,w=n?d(e,b):u?d(e,0):void 0;b>x;x++)if((h||x in g)&&(v=g[x],m=_(v,x,y),t))if(n)w[x]=m;else if(m)switch(t){case 3:return!0;case 5:return v;case 6:return x;case 2:w.push(v)}else if(l)return!1;return f?-1:c||l?l:w}}},function(t,e){var n=t.exports={version:"2.5.1"};"number"==typeof __e&&(__e=n)},function(t,e){t.exports=function(t){if(void 0==t)throw TypeError("Can't call method on "+t);return t}},function(t,e,n){var r=n(0),i=n(23),o=n(3);t.exports=function(t,e){var n=(i.Object||{})[t]||Object[t],a={};a[t]=e(n),r(r.S+r.F*o(function(){n(1)}),"Object",a)}},function(t,e){var n=Math.ceil,r=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?r:n)(t)}},function(t,e,n){var r=n(4);t.exports=function(t,e){if(!r(t))return t;var n,i;if(e&&"function"==typeof(n=t.toString)&&!r(i=n.call(t)))return i;if("function"==typeof(n=t.valueOf)&&!r(i=n.call(t)))return i;if(!e&&"function"==typeof(n=t.toString)&&!r(i=n.call(t)))return i;throw TypeError("Can't convert object to primitive value")}},function(t,e,n){var r=n(170),i="object"==typeof self&&self&&self.Object===Object&&self,o=r||i||Function("return this")();t.exports=o},function(t,e){var n=Array.isArray;t.exports=n},function(t,e,n){var r=n(155),i=n(0),o=n(70)("metadata"),a=o.store||(o.store=new(n(158))),s=function(t,e,n){var i=a.get(t);if(!i){if(!n)return;a.set(t,i=new r)}var o=i.get(e);if(!o){if(!n)return;i.set(e,o=new r)}return o},u=function(t,e,n){var r=s(e,n,!1);return void 0!==r&&r.has(t)},c=function(t,e,n){var r=s(e,n,!1);return void 0===r?void 0:r.get(t)},l=function(t,e,n,r){s(n,r,!0).set(t,e)},f=function(t,e){var n=s(t,e,!1),r=[];return n&&n.forEach(function(t,e){r.push(e)}),r},h=function(t){return void 0===t||"symbol"==typeof t?t:String(t)},d=function(t){i(i.S,"Reflect",t)};t.exports={store:a,map:s,has:u,get:c,set:l,keys:f,key:h,exp:d}},function(t,e,n){"use strict";if(n(7)){var r=n(36),i=n(2),o=n(3),a=n(0),s=n(72),u=n(104),c=n(20),l=n(34),f=n(40),h=n(13),d=n(41),p=n(26),v=n(9),m=n(153),y=n(43),g=n(27),_=n(12),b=n(53),x=n(4),w=n(10),S=n(90),k=n(37),C=n(17),O=n(38).f,M=n(106),A=n(44),E=n(5),T=n(22),P=n(59),D=n(71),j=n(107),R=n(46),F=n(65),L=n(42),I=n(82),N=n(126),$=n(8),Y=n(16),H=$.f,U=Y.f,W=i.RangeError,q=i.TypeError,G=i.Uint8Array,z=Array.prototype,B=u.ArrayBuffer,V=u.DataView,Z=T(0),J=T(2),K=T(3),X=T(4),Q=T(5),tt=T(6),et=P(!0),nt=P(!1),rt=j.values,it=j.keys,ot=j.entries,at=z.lastIndexOf,st=z.reduce,ut=z.reduceRight,ct=z.join,lt=z.sort,ft=z.slice,ht=z.toString,dt=z.toLocaleString,pt=E("iterator"),vt=E("toStringTag"),mt=A("typed_constructor"),yt=A("def_constructor"),gt=s.CONSTR,_t=s.TYPED,bt=s.VIEW,xt=T(1,function(t,e){return Ot(D(t,t[yt]),e)}),wt=o(function(){return 1===new G(new Uint16Array([1]).buffer)[0]}),St=!!G&&!!G.prototype.set&&o(function(){new G(1).set({})}),kt=function(t,e){var n=p(t);if(n<0||n%e)throw W("Wrong offset!");return n},Ct=function(t){if(x(t)&&_t in t)return t;throw q(t+" is not a typed array!")},Ot=function(t,e){if(!(x(t)&&mt in t))throw q("It is not a typed array constructor!");return new t(e)},Mt=function(t,e){return At(D(t,t[yt]),e)},At=function(t,e){for(var n=0,r=e.length,i=Ot(t,r);r>n;)i[n]=e[n++];return i},Et=function(t,e,n){H(t,e,{get:function(){return this._d[n]}})},Tt=function(t){var e,n,r,i,o,a,s=w(t),u=arguments.length,l=u>1?arguments[1]:void 0,f=void 0!==l,h=M(s);if(void 0!=h&&!S(h)){for(a=h.call(s),r=[],e=0;!(o=a.next()).done;e++)r.push(o.value);s=r}for(f&&u>2&&(l=c(l,arguments[2],2)),e=0,n=v(s.length),i=Ot(this,n);n>e;e++)i[e]=f?l(s[e],e):s[e];return i},Pt=function(){for(var t=0,e=arguments.length,n=Ot(this,e);e>t;)n[t]=arguments[t++];return n},Dt=!!G&&o(function(){dt.call(new G(1))}),jt=function(){return dt.apply(Dt?ft.call(Ct(this)):Ct(this),arguments)},Rt={copyWithin:function(t,e){return N.call(Ct(this),t,e,arguments.length>2?arguments[2]:void 0)},every:function(t){return X(Ct(this),t,arguments.length>1?arguments[1]:void 0)},fill:function(t){return I.apply(Ct(this),arguments)},filter:function(t){return Mt(this,J(Ct(this),t,arguments.length>1?arguments[1]:void 0))},find:function(t){return Q(Ct(this),t,arguments.length>1?arguments[1]:void 0)},findIndex:function(t){return tt(Ct(this),t,arguments.length>1?arguments[1]:void 0)},forEach:function(t){Z(Ct(this),t,arguments.length>1?arguments[1]:void 0)},indexOf:function(t){return nt(Ct(this),t,arguments.length>1?arguments[1]:void 0)},includes:function(t){return et(Ct(this),t,arguments.length>1?arguments[1]:void 0)},join:function(t){return ct.apply(Ct(this),arguments)},lastIndexOf:function(t){return at.apply(Ct(this),arguments)},map:function(t){return xt(Ct(this),t,arguments.length>1?arguments[1]:void 0)},reduce:function(t){return st.apply(Ct(this),arguments)},reduceRight:function(t){return ut.apply(Ct(this),arguments)},reverse:function(){for(var t,e=this,n=Ct(e).length,r=Math.floor(n/2),i=0;i1?arguments[1]:void 0)},sort:function(t){return lt.call(Ct(this),t)},subarray:function(t,e){var n=Ct(this),r=n.length,i=y(t,r);return new(D(n,n[yt]))(n.buffer,n.byteOffset+i*n.BYTES_PER_ELEMENT,v((void 0===e?r:y(e,r))-i))}},Ft=function(t,e){return Mt(this,ft.call(Ct(this),t,e))},Lt=function(t){Ct(this);var e=kt(arguments[1],1),n=this.length,r=w(t),i=v(r.length),o=0;if(i+e>n)throw W("Wrong length!");for(;o255?255:255&r),i.v[d](n*e+i.o,r,wt)},E=function(t,e){H(t,e,{get:function(){return M(this,e)},set:function(t){return A(this,e,t)},enumerable:!0})};_?(p=n(function(t,n,r,i){l(t,p,c,"_d");var o,a,s,u,f=0,d=0;if(x(n)){if(!(n instanceof B||"ArrayBuffer"==(u=b(n))||"SharedArrayBuffer"==u))return _t in n?At(p,n):Tt.call(p,n);o=n,d=kt(r,e);var y=n.byteLength;if(void 0===i){if(y%e)throw W("Wrong length!");if((a=y-d)<0)throw W("Wrong length!")}else if((a=v(i)*e)+d>y)throw W("Wrong length!");s=a/e}else s=m(n),a=s*e,o=new B(a);for(h(t,"_d",{b:o,o:d,l:a,e:s,v:new V(o)});f_;_++)if((m=e?g(a(p=t[_])[0],p[1]):g(t[_]))===c||m===l)return m}else for(v=y.call(t);!(p=v.next()).done;)if((m=i(v,g,p.value,e))===c||m===l)return m};e.BREAK=c,e.RETURN=l},function(t,e){t.exports=!1},function(t,e,n){var r=n(1),i=n(143),o=n(86),a=n(98)("IE_PROTO"),s=function(){},u=function(){var t,e=n(85)("iframe"),r=o.length;for(e.style.display="none",n(88).appendChild(e),e.src="javascript:",t=e.contentWindow.document,t.open(),t.write(" - + diff --git a/index.html b/index.html new file mode 100644 index 0000000..1d9e803 --- /dev/null +++ b/index.html @@ -0,0 +1,5 @@ + + + + + diff --git a/locale/cs-CZ.js b/locale/cs-CZ.js new file mode 100644 index 0000000..8e9e280 --- /dev/null +++ b/locale/cs-CZ.js @@ -0,0 +1,17 @@ +export default { + /* HeaderSettings/index.vue */ + 'Apply': 'Aplikovat', + 'Apply and backup settings to local': 'Aplikovat a zapamatovat nastavení', + 'Clear local settings backup and restore': 'Výchozí nstavení', + 'Using local settings': 'Použito lokální nastavení', + + /* Table/TableBody.vue */ + 'No Data': 'Žádná data k dispozici', + + /* index.vue */ + 'Total': 'Celkově', + ',': ',', + + /* PageSizeSelect.vue */ + 'items / page': 'záznamů / strana' +} diff --git a/locale/es.js b/locale/es.js new file mode 100644 index 0000000..3e5b5a3 --- /dev/null +++ b/locale/es.js @@ -0,0 +1,19 @@ +export default { + /* HeaderSettings/index.vue */ + Apply: 'Aplicar', + 'Apply and backup settings to local': + 'Aplicar y respaldar configuración en local', + 'Clear local settings backup and restore': + 'Borrar configuración de respaldo local y restaurar', + 'Using local settings': 'Utilizar configuración local', + + /* Table/TableBody.vue */ + 'No Data': 'No existen datos', + + /* index.vue */ + Total: 'Total', + ',': ',', + + /* PageSizeSelect.vue */ + 'items / page': 'registros / página' +} diff --git a/locale/it-it.js b/locale/it-it.js new file mode 100644 index 0000000..cc02f97 --- /dev/null +++ b/locale/it-it.js @@ -0,0 +1,17 @@ +export default { + /* HeaderSettings/index.vue */ + 'Apply': 'Applica', + 'Apply and backup settings to local': 'Applica e salva nelle impostazioni locali', + 'Clear local settings backup and restore': 'Cancella le impostazioni locali salvate e ripristina', + 'Using local settings': 'Utilizza le impostazioni locali', + + /* Table/TableBody.vue */ + 'No Data': 'Nessun Dato', + + /* index.vue */ + 'Total': 'Totale', + ',': ',', + + /* PageSizeSelect.vue */ + 'items / page': 'elementi / pagina' +} diff --git a/locale/pt-br.js b/locale/pt-br.js new file mode 100644 index 0000000..7294be2 --- /dev/null +++ b/locale/pt-br.js @@ -0,0 +1,17 @@ +export default { + /* HeaderSettings/index.vue */ + 'Apply': 'Aplicar', + 'Apply and backup settings to local': 'Aplicar e salvar para as configurações locais', + 'Clear local settings backup and restore': 'Limpar configurações locais salvas e restaurar', + 'Using local settings': 'Usando configurações locais', + + /* Table/TableBody.vue */ + 'No Data': 'Não há dados', + + /* index.vue */ + 'Total': 'Total', + ',': ',', + + /* PageSizeSelect.vue */ + 'items / page': 'itens / página' +} diff --git a/package.json b/package.json index 54cea59..4660f92 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "vue2-datatable-component", "description": "The best Datatable for Vue.js 2.x which never sucks", - "version": "2.1.17", + "version": "2.3.1", "main": "dist/min.js", "module": "src/main.js", "author": "Ken Berkeley ", @@ -31,8 +31,7 @@ "table" ], "dependencies": { - "lodash": "^4.17.4", - "replace-with": "^1.0.0" + "lodash": "^4.17.4" }, "devDependencies": { "ava": "^0.22.0", @@ -41,7 +40,7 @@ "browser-env": "^3.2.0", "clean-webpack-plugin": "^0.1.16", "docsify-cli": "^4.1.10", - "eslint": "^4.6.1", + "eslint": "4.6.1", "eslint-config-standard": "^10.2.1", "eslint-friendly-formatter": "^3.0.0", "eslint-plugin-import": "^2.7.0", diff --git a/plugins/HeaderSettingsDnD.js b/plugins/HeaderSettingsDnD.js new file mode 100644 index 0000000..9252660 --- /dev/null +++ b/plugins/HeaderSettingsDnD.js @@ -0,0 +1,134 @@ +/** + * apply drag-and-drop sortable feature to HeaderSettings + * note that this function should be invoked in `mounted` + * e.g. + + + + * `vm.columns` should also meet the requirement that: + * the same-group columns should be put together + * e.g. + [ // ok + { field: 'a1', group: 'A' }, + { field: 'a2', group: 'A' }, + { field: 'b1', group: 'B' }, + { field: 'b2', group: 'B' }, + { field: 'c1', group: 'C' }, + { field: 'c2', group: 'C' } + ] + [ // not ok + { field: 'a1', group: 'A' }, + { field: 'b1', group: 'B' }, + { field: 'c1', group: 'C' }, + { field: 'a2', group: 'A' }, + { field: 'b2', group: 'B' }, + { field: 'c2', group: 'C' } + ] + + * @param {VueInstance} vm + */ +export default function dnd(vm) { + const $ColGroupContainer = $(vm.$el).find('div.-col-group-container') + const DRAGGABLE = 'li[draggable=true]' + const DROP_ZONE = 'li.-col-drop-zone' + + function dropZoneGen(idx) { + return `
  • ` + } + /** generate adjacent drop zones for each column displayed as
  • */ + function generateDropZones() { + $ColGroupContainer + .find(DROP_ZONE).remove().end() // ensure no drop zone exists + .find('li').each(function (idx) { + const $this = $(this) + $this + .attr('draggable', 'true') + .attr('source-idx', idx) + .before( + dropZoneGen( + $this.is('li:first-of-type') ? idx - 0.25 : idx + ) + ) + + $this.is('li:last-of-type') && $this.after(dropZoneGen(idx + 0.25)) + }) + } + + vm.$watch('columns', () => { + vm.$nextTick(generateDropZones) + }, { immediate: true, deep: true }) + + /*** ↑↑↑ preparatory work --- main logic ↓↓↓ ***/ + + let draggingIdx = null + + $.fn.isAllowedToDrop = function () { + const targetIdx = +$(this).attr('target-idx') + return ![-0.25, 0, 0.25, 1].includes(targetIdx - draggingIdx) // filter adjacent drop zones + } + + $ColGroupContainer + .on('dragstart', DRAGGABLE, function () { + draggingIdx = +$(this).addClass('-dragging').attr('source-idx') + }) + .on('dragend', DRAGGABLE, function () { + draggingIdx = null + $(this).removeClass('-dragging') + }) + .on('dragover', DROP_ZONE, function (e) { + e.preventDefault() // must + e.originalEvent.dataTransfer.dropEffect = $(this).isAllowedToDrop() ? 'move' : 'none' + }) + .on('dragenter', DROP_ZONE, function () { + const $this = $(this) + $this.isAllowedToDrop() && $this.addClass('-droppable') + }) + .on('drop', DROP_ZONE, function () { + const $this = $(this).removeClass('-droppable') + if (!$this.isAllowedToDrop()) return + + const { columns } = vm + const targetIdx = +$this.attr('target-idx') + columns[draggingIdx].group = columns[Math.round(targetIdx)].group + arrMove(columns, draggingIdx, Math.ceil(targetIdx)) + }) + .on('dragleave', DROP_ZONE, function () { + const $this = $(this) + $this.isAllowedToDrop() && $this.removeClass('-droppable') + }) +} + +// similar to https://github.com/sindresorhus/array-move +function arrMove(arr, from, to) { + arr.splice((from < to ? to - 1 : to), 0, arr.splice(from, 1)[0]) +} + +$('head').append(``) diff --git a/src/HeaderSettings/ColumnGroup.vue b/src/HeaderSettings/ColumnGroup.vue index ae0efcf..c620653 100644 --- a/src/HeaderSettings/ColumnGroup.vue +++ b/src/HeaderSettings/ColumnGroup.vue @@ -51,8 +51,9 @@ export default { diff --git a/src/HeaderSettings/index.vue b/src/HeaderSettings/index.vue index 464c11d..099a915 100644 --- a/src/HeaderSettings/index.vue +++ b/src/HeaderSettings/index.vue @@ -1,6 +1,6 @@