(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-11484efe"],{"2d93":function(t,e,a){"use strict";a("6d14")},"6d14":function(t,e,a){},"831f":function(t,e,a){"use strict";a.r(e);a("386d"),a("7f7f");var s=function(){var t=this,e=t._self._c;return e("div",[t._t("btn",(function(){return[e("button",{staticClass:"btn btn-light dropdown-toggle",attrs:{type:"button","data-toggle":"dropdown"},on:{click:t.loadData}},[t._v("\n      "+t._s(t.tab.name)+" "+t._s(t.selectedFilter[t.tab.val]&&t.selectedFilter[t.tab.val].length?"*":"")+"\n    ")])]})),e("div",{staticClass:"dropdown-menu dropdown-menu-form mr-0 mt-0 pb-3 pt-0",staticStyle:{"max-height":"60vh","overflow-y":"auto"},on:{scroll:t.onScrollDebounce}},[e("div",{staticClass:"DropdownView__filters-container"},[t.isOrdersByUser?e("div",{staticClass:"dropdown-item",on:{click:function(t){t.stopPropagation()}}},[e("div",{staticClass:"custom-control custom-checkbox p-0"},[e("input",{directives:[{name:"model",rawName:"v-model",value:t.active,expression:"active"}],staticClass:"custom-control-input",attrs:{type:"checkbox",id:"".concat(t.storageName,"-Active")},domProps:{checked:Array.isArray(t.active)?t._i(t.active,null)>-1:t.active},on:{change:[function(e){var a=t.active,s=e.target,i=!!s.checked;if(Array.isArray(a)){var o=null,c=t._i(a,o);s.checked?c<0&&(t.active=a.concat([o])):c>-1&&(t.active=a.slice(0,c).concat(a.slice(c+1)))}else t.active=i},t.handleFilterClick]}}),e("label",{staticClass:"custom-control-label",attrs:{for:"".concat(t.storageName,"-Active")}},[e("b",[t._v("Active")])])])]):t._e(),e("div",{staticClass:"dropdown-item",on:{click:function(t){t.stopPropagation()}}},[e("div",{staticClass:"custom-control custom-checkbox p-0"},[e("input",{directives:[{name:"model",rawName:"v-model",value:t.sales,expression:"sales"}],staticClass:"custom-control-input",attrs:{type:"checkbox",id:"".concat(t.storageName,"-Sales")},domProps:{checked:Array.isArray(t.sales)?t._i(t.sales,null)>-1:t.sales},on:{change:[function(e){var a=t.sales,s=e.target,i=!!s.checked;if(Array.isArray(a)){var o=null,c=t._i(a,o);s.checked?c<0&&(t.sales=a.concat([o])):c>-1&&(t.sales=a.slice(0,c).concat(a.slice(c+1)))}else t.sales=i},t.handleFilterClick]}}),e("label",{staticClass:"custom-control-label",attrs:{for:"".concat(t.storageName,"-Sales")}},[e("b",[t._v("Sales")])])])]),e("div",{staticClass:"dropdown-item",on:{click:function(t){t.stopPropagation()}}},[e("div",{staticClass:"custom-control custom-checkbox p-0"},[e("input",{directives:[{name:"model",rawName:"v-model",value:t.salesAdmin,expression:"salesAdmin"}],staticClass:"custom-control-input",attrs:{type:"checkbox",id:"".concat(t.storageName,"-SalesAdmin")},domProps:{checked:Array.isArray(t.salesAdmin)?t._i(t.salesAdmin,null)>-1:t.salesAdmin},on:{change:[function(e){var a=t.salesAdmin,s=e.target,i=!!s.checked;if(Array.isArray(a)){var o=null,c=t._i(a,o);s.checked?c<0&&(t.salesAdmin=a.concat([o])):c>-1&&(t.salesAdmin=a.slice(0,c).concat(a.slice(c+1)))}else t.salesAdmin=i},t.handleFilterClick]}}),e("label",{staticClass:"custom-control-label",attrs:{for:"".concat(t.storageName,"-SalesAdmin")}},[e("b",[t._v("Sales Admin")])])])]),e("div",{staticClass:"dropdown-item",on:{click:function(t){t.stopPropagation()}}},[e("div",{staticClass:"custom-control custom-checkbox p-0"},[e("input",{directives:[{name:"model",rawName:"v-model",value:t.outsideSales,expression:"outsideSales"}],staticClass:"custom-control-input",attrs:{type:"checkbox",id:"".concat(t.storageName,"-OutsideSales")},domProps:{checked:Array.isArray(t.outsideSales)?t._i(t.outsideSales,null)>-1:t.outsideSales},on:{change:[function(e){var a=t.outsideSales,s=e.target,i=!!s.checked;if(Array.isArray(a)){var o=null,c=t._i(a,o);s.checked?c<0&&(t.outsideSales=a.concat([o])):c>-1&&(t.outsideSales=a.slice(0,c).concat(a.slice(c+1)))}else t.outsideSales=i},t.handleFilterClick]}}),e("label",{staticClass:"custom-control-label",attrs:{for:"".concat(t.storageName,"-OutsideSales")}},[e("b",[t._v("Outside Sales")])])])]),e("hr"),e("div",{staticClass:"dropdown-item pl-0 pr-0"},[e("b-form-input",{attrs:{placeholder:"Search"},on:{input:t.onSearchData},model:{value:t.search,callback:function(e){t.search=e},expression:"search"}})],1)]),t.loading?e("loading"):e("div",{staticClass:"DropdownView__list-container"},[t._t("list",(function(){return[t.options&&t.options.length>1?e("div",{staticClass:"dropdown-item",on:{click:function(t){t.stopPropagation()}}},[e("div",{staticClass:"custom-control custom-checkbox p-0"},[e("input",{directives:[{name:"model",rawName:"v-model",value:t.isAll,expression:"isAll"}],staticClass:"custom-control-input",attrs:{type:"checkbox",id:"".concat(t.tab.val,"-all")},domProps:{checked:Array.isArray(t.isAll)?t._i(t.isAll,null)>-1:t.isAll},on:{change:[function(e){var a=t.isAll,s=e.target,i=!!s.checked;if(Array.isArray(a)){var o=null,c=t._i(a,o);s.checked?c<0&&(t.isAll=a.concat([o])):c>-1&&(t.isAll=a.slice(0,c).concat(a.slice(c+1)))}else t.isAll=i},t.toggleSelectAll]}}),e("label",{staticClass:"custom-control-label",attrs:{for:"".concat(t.tab.val,"-all")}},[e("b",[t._v("Select All")])])])]):t._e(),t._l(t.options,(function(a,s){return e("div",{key:s,staticClass:"dropdown-item",on:{click:function(t){t.stopPropagation()}}},[e("div",{staticClass:"custom-control custom-checkbox p-0"},[e("input",{directives:[{name:"model",rawName:"v-model",value:t.selectedFilter[t.tab.val],expression:"selectedFilter[tab.val]"}],staticClass:"custom-control-input",attrs:{type:"checkbox",id:"".concat(a.fullName,"-").concat(s)},domProps:{value:a._id,checked:Array.isArray(t.selectedFilter[t.tab.val])?t._i(t.selectedFilter[t.tab.val],a._id)>-1:t.selectedFilter[t.tab.val]},on:{change:[function(e){var s=t.selectedFilter[t.tab.val],i=e.target,o=!!i.checked;if(Array.isArray(s)){var c=a._id,l=t._i(s,c);i.checked?l<0&&t.$set(t.selectedFilter,t.tab.val,s.concat([c])):l>-1&&t.$set(t.selectedFilter,t.tab.val,s.slice(0,l).concat(s.slice(l+1)))}else t.$set(t.selectedFilter,t.tab.val,o)},t.changeItem]}}),e("label",{staticClass:"custom-control-label",attrs:{for:"".concat(a.fullName,"-").concat(s)}},[t._v("\n              "+t._s(a.fullName)+"\n            ")])])])}))]}),{options:t.options}),t.loadingMoreData?e("loading"):t._e()],2)],1)],2)},i=[],o=(a("8e6e"),a("456d"),a("7618")),c=(a("ac6a"),a("6762"),a("2fdb"),a("75fc")),l=(a("96cf"),a("3b8d")),r=a("bd86"),n=a("db0f"),d=a("ef43"),u=a("2f62");function h(t,e){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),a.push.apply(a,s)}return a}function p(t){for(var e=1;e<arguments.length;e++){var a=null!=arguments[e]?arguments[e]:{};e%2?h(Object(a),!0).forEach((function(e){Object(r["a"])(t,e,a[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):h(Object(a)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(a,e))}))}return t}var m={name:"DropdownView",data:function(){var t,e=this;return{options:(null===(t=this.tab)||void 0===t?void 0:t.criteria)||[],search:"",page:1,total:null,loading:!1,loadingMoreData:!1,isAll:!1,active:!0,sales:!1,salesAdmin:!1,outsideSales:!1,onScrollDebounce:_.debounce((function(t){e.onScroll(t)}),300)}},props:{url:{type:String,required:!0},params:{type:Object},storageName:{type:String,require:!0},filtersFields:{type:Array,require:!0},selectedFilter:{type:Object},tab:{type:Object},isOrdersByUser:{type:Boolean}},computed:p({},Object(u["d"])(["loggedInUser"])),mounted:function(){this.isOrdersByUser&&this.onLoadStorageData()},methods:{onSearchData:function(t){var e=this;this.timeOut&&clearTimeout(this.timeOut),this.timeOut=setTimeout((function(){e.page=1,e.search=t,e.total=0,e.loadData()}),300)},onScroll:function(t){var e=t.target,a=e.scrollHeight-e.scrollTop===e.clientHeight;a&&!this.loading&&!this.loadingMoreData&&this.options.length<this.total&&(this.loadingMoreData=!0,this.loadData())},loadData:function(){var t=Object(l["a"])(regeneratorRuntime.mark((function t(){var e,a,s,i;return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:if(e=this.generateParams(),!(this.total>0&&this.options.length>=this.total)){t.next=3;break}return t.abrupt("return");case 3:return t.prev=3,this.loadingMoreData||(this.loading=!0),t.next=7,this.http.get(this.url,{params:e});case 7:a=t.sent,s=a.data,this.page++,this.total||(this.total=s.count,this.options=[]),i=this.options.map((function(t){return t._id||t})),this.options=[].concat(Object(c["a"])(this.options),Object(c["a"])(s.data.filter((function(t){return!i.includes(t._id||t)})))),t.next=18;break;case 15:t.prev=15,t.t0=t["catch"](3),console.log(t.t0);case 18:return t.prev=18,this.loading=!1,this.loadingMoreData=!1,this.saveSettings(),t.finish(18);case 23:case"end":return t.stop()}}),t,this,[[3,15,18,23]])})));function e(){return t.apply(this,arguments)}return e}(),generateParams:function(){var t=p(p({},this.params),{},{page:this.page});if(this.search&&(t.query=this.search.toLowerCase()),this.outsideSales||this.sales||this.salesAdmin||this.active){var e=[];(this.outsideSales||this.sales)&&e.push(d["h"].TOOLS.USER_AS_OUTSIDE_SALE),this.salesAdmin&&e.push(d["h"].TOOLS.USER_AS_SALE_ADMIN),e.length>0&&(t.roleTool=e),this.isOrdersByUser&&(t.filter={isActive:this.active?[{val:!0}]:void 0})}return t},handleFilterClick:function(){this.page=1,this.total=0,this.saveSettings(),this.loadData()},onLoadStorageData:function(){var t=this,e=n["a"].filters.ordersSalesPersons.get(this.storageName);e&&(this.filtersFields.forEach((function(a){"object"===Object(o["a"])(e[a])&&null!==e[a]?Object.assign(t[a],e[a]):t[a]=e[a]})),this.$forceUpdate(),this.$emit("change"))},saveSettings:function(){var t=this,e={};this.filtersFields.forEach((function(a){e[a]=t[a]})),n["a"].filters.ordersSalesPersons.set(e,this.storageName)},toggleSelectAll:function(){this.isAll?(this.selectedFilter[this.tab.val]||(this.selectedFilter[this.tab.val]=[]),this.selectedFilter[this.tab.val]=this.options.map((function(t){return t._id}))):this.selectedFilter[this.tab.val]=[],this.$emit("change"),this.saveSettings()},changeItem:function(){this.$emit("change",this.selectedFilter[this.tab.val]),this.saveSettings()}}},v=m,f=(a("2d93"),a("2877")),g=Object(f["a"])(v,s,i,!1,null,"473fa98c",null);e["default"]=g.exports}}]);
//# sourceMappingURL=chunk-11484efe.27115b44.js.map