(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2449ccfd"],{"0c81":function(e,t,n){"use strict";n.d(t,"b",(function(){return r})),n.d(t,"f",(function(){return a})),n.d(t,"e",(function(){return c})),n.d(t,"d",(function(){return o})),n.d(t,"c",(function(){return i})),n.d(t,"g",(function(){return s})),n.d(t,"a",(function(){return u}));var r=function(e){return"".concat(e," har blivit tillagt!")},a=function(e){return"".concat(e," sparades!")},c="Något gick fel!",o="Din åtgärd har blivit raderad!",i="Är du säker?",s="Ja",u="Avbryt"},"129f":function(e,t){e.exports=Object.is||function(e,t){return e===t?0!==e||1/e===1/t:e!=e&&t!=t}},5530:function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));n("b64b"),n("a4d3"),n("4de4"),n("e439"),n("159b"),n("dbb4");var r=n("ade3");function a(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function c(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,c=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,o={limit:n,skip:t?t-1:null,search:r,bindStatus:e,company:c};return a.a.get("/boxes",{params:o})},addBox:function(e){return a.a.post("/boxes",e)},setBoxToVehicleLink:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"bind";return a.a.put("/vehicles/".concat(e,"/").concat(r,"/box/").concat(t,"?company=").concat(n))},deleteBox:function(e){return a.a.delete("/boxes/".concat(e))}}},"5ae6":function(e,t,n){},"7c06":function(e,t,n){"use strict";n("5ae6")},"7c69":function(e,t,n){"use strict";n.d(t,"b",(function(){return r})),n.d(t,"a",(function(){return o}));n("dca8");var r=Object.freeze({UNKNOWN_ERROR:"Hoppsan! Något gick fel, försök igen!",INVALID_CREDENTIALS:"Fel inloggningsuppgifter!",BOX_ALREADY_EXISTS:"Detta IMEI-nummer finns redan i bruk!",VEHICLE_ALREADY_EXISTS:"Detta fordon finns redan!",USER_ALREADY_EXISTS:"Denna e-post används redan som användarnamn!",COMPANY_ALREADY_EXISTS:"Detta företag finns redan!",PASSWORD_RESET_SUCCESS:"En återställningslänk har skickats till din e-post!",BOX_DELETED:"Enheten togs bort!",SOMETHING_WENT_WRONG:"Hoppsan! Något gick fel, försök igen!"}),a=Object.freeze({ERR_0000:r.UNKNOWN_ERROR,ERR_0001:r.INVALID_CREDENTIALS,ERR_0002:r.BOX_ALREADY_EXISTS,ERR_0003:r.VEHICLE_ALREADY_EXISTS,ERR_0004:r.USER_ALREADY_EXISTS,ERR_0005:r.COMPANY_ALREADY_EXISTS}),c=function(e){return a[e]?a[e]:r.UNKNOWN_ERROR},o=function(e){var t=null===e||void 0===e?void 0:e.response.data,n=t.drivelogErrorCode;return c(n)}},"7d50":function(e,t,n){},"7db0":function(e,t,n){"use strict";var r=n("23e7"),a=n("b727").find,c=n("44d2"),o="find",i=!0;o in[]&&Array(1)[o]((function(){i=!1})),r({target:"Array",proto:!0,forced:i},{find:function(e){return a(this,e,arguments.length>1?arguments[1]:void 0)}}),c(o)},8090:function(e,t,n){"use strict";n.r(t);var r=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"boxes"},[n("h1",{staticClass:"section-header"},[e._v("Enheter")]),e.showModal?n("app-modal",{on:{close:function(t){e.showModal=!1}}},[n("AddBox",{attrs:{isCompanyAdmin:e.isCompanyAdmin,companies:e.companies},on:{boxAdded:e.onBoxAdded}})],1):e._e(),n("div",{staticClass:"row justify-content-between mt-4"},[n("div",{staticClass:"row col-md-8"},[n("input-field",{staticClass:"col-md-3",attrs:{placeholder:"Sök ..."},on:{input:e.searchBoxes},model:{value:e.search,callback:function(t){e.search=t},expression:"search"}}),e.isCompanyAdmin?e._e():n("v-select",{staticClass:"col-md-4 mt-2",attrs:{reduce:function(e){return e._id},options:e.companies,label:"name",placeholder:"Företag"},on:{input:e.searchBoxes},model:{value:e.company,callback:function(t){e.company=t},expression:"company"}})],1),n("app-button",{staticClass:"btn--secondary mr-3",on:{click:function(t){e.showModal=!0}}},[e._v("Lägg till enhet")])],1),n("div",{staticClass:"box box--outline mt-3"},[n("app-table",{attrs:{head:e.head}},[e._l(e.boxes,(function(t,r){return[n("tr",{key:t._id,class:{expanded:t.expanded},on:{click:function(e){t.expanded=!t.expanded}}},[n("td",[e._v(e._s(t.boxId))]),n("td",[e._v(e._s(t.vehicle.licencePlate?t.vehicle.licencePlate:"Inget fordon"))]),n("td",[e._v(e._s(t.company.name))]),n("td",[n("div",{staticClass:"d-flex justify-content-end align-items-center"},[t.vehicle.licencePlate?n("div",{staticClass:"box-icon"},[n("app-icon",{staticClass:"active-icon",attrs:{name:"checkmark"}})],1):e._e(),n("app-icon",{staticClass:"arrow ml-3",class:{"rotate-arrow":!t.expanded},attrs:{name:"chevron-down"},nativeOn:{click:function(e){e.stopPropagation(),t.expanded=!t.expanded}}})],1)])]),t.expanded?n("tr",[n("td",{attrs:{colspan:"3"}},[n("div",{staticClass:"row justify-content-between align-items-center pb-4"},[n("div",{staticClass:"col-md-3 select-item"},[n("label",{staticClass:"mb-2"},[e._v("Fordon")]),n("v-select",{attrs:{disabled:t.bound,selectable:function(e){return e.company._id===t.company._id},options:e.vehicles,reduce:function(e){return e.licencePlate},label:"licencePlate"},scopedSlots:e._u([{key:"no-options",fn:function(){return[e._v("Inga tillgängliga val.")]},proxy:!0}],null,!0),model:{value:t.vehicle.licencePlate,callback:function(n){e.$set(t.vehicle,"licencePlate",n)},expression:"box.vehicle.licencePlate"}})],1),n("div",{staticClass:"d-flex"},[n("app-button",{staticClass:"btn--red mr-2",on:{click:function(n){return e.deleteBox(t.boxId)}}},[e._v("Radera")]),n("app-button",{staticClass:"btn--secondary mr-2",on:{click:function(n){return e.bindVehicleToBox(t.boxId,t.bound)}}},[t.bound?[e._v("Koppla ifrån")]:[e._v("Anslut")]],2)],1)])])]):e._e()]}))],2)],1),n("div",{staticClass:"d-flex justify-content-end mt-5"},[n("app-pagination",{attrs:{"current-page":e.currentPage,"total-pages":e.totalPages},on:{pageChanged:e.onPageChanged}})],1)],1)},a=[],c=n("1da1"),o=n("5530"),i=(n("ac1f"),n("841c"),n("d81d"),n("7db0"),n("b0c0"),n("96cf"),n("5962")),s=n("a947"),u=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",[n("h1",{staticClass:"section-header"},[e._v("Enhetsinformation")]),n("div",{staticClass:"row mt-5"},[n("div",{staticClass:"col-md-6"},[n("input-field",{attrs:{label:"IMEI-nummer"},model:{value:e.form.boxId,callback:function(t){e.$set(e.form,"boxId",t)},expression:"form.boxId"}})],1),e.isCompanyAdmin?e._e():n("div",{staticClass:"col-md-6 select-item"},[n("label",{staticClass:"mb-2"},[e._v("Välj företag")]),n("v-select",{attrs:{options:e.companies,label:"name",reduce:function(e){return e._id}},model:{value:e.form.company,callback:function(t){e.$set(e.form,"company",t)},expression:"form.company"}})],1)]),n("div",{staticClass:"mt-5 d-flex justify-content-end"},[n("app-button",{staticClass:"btn--secondary",attrs:{loading:e.loading},on:{click:e.addBox}},[e._v("Lägg till")])],1)])},l=[],d=n("0c81"),f=n("7c69"),p={props:["companies","isCompanyAdmin"],data:function(){return{form:{boxId:"",company:null},loading:!1}},methods:{addBox:function(){var e=this;return Object(c["a"])(regeneratorRuntime.mark((function t(){var n;return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:if(e.form.boxId){t.next=3;break}return e.$notify.error("IMEI-nummer krävs!"),t.abrupt("return");case 3:return t.prev=3,e.loading=!0,t.next=7,i["a"].addBox(e.form);case 7:e.$emit("boxAdded"),e.$notify.success(Object(d["b"])("Enheten")),t.next=15;break;case 11:t.prev=11,t.t0=t["catch"](3),n=Object(f["a"])(t.t0),e.$notify.error(n);case 15:return t.prev=15,e.loading=!1,t.finish(15);case 18:case"end":return t.stop()}}),t,null,[[3,11,15,18]])})))()}}},b=p,v=n("2877"),m=Object(v["a"])(b,u,l,!1,null,"2d1ae148",null),h=m.exports,g=n("bb26"),x=n("2f62"),E=n("bce3"),y=n("5627"),_={components:{AppPagination:E["a"],AddBox:h},data:function(){return{showModal:!1,boxes:[],companies:[],vehicles:[],currentPage:1,totalPages:1,search:null,company:null,head:[{name:"IMEI-nummer"},{name:"Ansluten till fordon"},{name:"Företag"},{name:"",width:15}]}},computed:Object(o["a"])({},Object(x["b"])(["isCompanyAdmin"])),methods:{getCompanies:function(){var e=this;return Object(c["a"])(regeneratorRuntime.mark((function t(){var n,r;return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,s["a"].getCompanies();case 3:n=t.sent,r=n.companies,e.companies=r,t.next=11;break;case 8:t.prev=8,t.t0=t["catch"](0),e.$notify.error("Error fetching companies");case 11:case"end":return t.stop()}}),t,null,[[0,8]])})))()},getBoxes:function(){var e=this;return Object(c["a"])(regeneratorRuntime.mark((function t(){var n,r,a;return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,i["a"].getBoxes(null,e.currentPage,10,e.search,e.company);case 3:n=t.sent,r=n.boxes,a=n.totalCount,e.boxes=r.map((function(e){return Object(o["a"])(Object(o["a"])({},e),{},{expanded:!1,bound:!!e.vehicle.licencePlate})})),e.totalPages=Object(y["a"])(a),t.next=14;break;case 10:t.prev=10,t.t0=t["catch"](0),console.log(t.t0),e.$notify.error("Error fetching boxes");case 14:case"end":return t.stop()}}),t,null,[[0,10]])})))()},deleteBox:function(e){var t=this;return Object(c["a"])(regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){while(1)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,t.$confirm("",d["c"],{confirmButtonText:d["g"],cancelButtonText:d["a"],type:"warning"});case 3:n.next=8;break;case 5:return n.prev=5,n.t0=n["catch"](0),n.abrupt("return");case 8:return n.prev=8,n.next=11,i["a"].deleteBox(e);case 11:return t.$notify.success("Enheten togs bort!"),n.next=14,t.getBoxes();case 14:n.next=19;break;case 16:n.prev=16,n.t1=n["catch"](8),t.$notify.success(d["d"]);case 19:case"end":return n.stop()}}),n,null,[[0,5],[8,16]])})))()},onPageChanged:function(e){this.currentPage=e,this.getBoxes()},bindVehicleToBox:function(e,t){var n=this;return Object(c["a"])(regeneratorRuntime.mark((function r(){var a,c,o,s;return regeneratorRuntime.wrap((function(r){while(1)switch(r.prev=r.next){case 0:if(r.prev=0,a=n.boxes.find((function(t){return t.boxId===e})),c=a.vehicle,o=a.company,c.licencePlate){r.next=6;break}return n.$notify.error("Välj ett fordon i listan!"),r.abrupt("return");case 6:return s=t?"unbind":"bind",r.next=9,i["a"].setBoxToVehicleLink(c.licencePlate,e,o._id,s);case 9:return r.next=11,n.getBoxes();case 11:return r.next=13,n.getVehicles();case 13:r.next=18;break;case 15:r.prev=15,r.t0=r["catch"](0),n.$notify.error(f["b"].SOMETHING_WENT_WRONG);case 18:case"end":return r.stop()}}),r,null,[[0,15]])})))()},getVehicles:function(){var e=this;return Object(c["a"])(regeneratorRuntime.mark((function t(){var n,r;return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,g["a"].getVehicles({boxBindStatus:"unbound"});case 3:n=t.sent,r=n.vehicles,e.vehicles=r,t.next=10;break;case 8:t.prev=8,t.t0=t["catch"](0);case 10:case"end":return t.stop()}}),t,null,[[0,8]])})))()},searchBoxes:function(){this.currentPage=1,this.getBoxes()},onBoxAdded:function(){this.getBoxes(),this.showModal=!1},getCompanyName:function(e){var t=this.companies.find((function(t){return t._id===e}));return t?t.name:"-"}},created:function(){var e=this;return Object(c["a"])(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:if(e.isCompanyAdmin){t.next=3;break}return t.next=3,e.getCompanies();case 3:return t.next=5,e.getBoxes();case 5:return t.next=7,e.getVehicles();case 7:case"end":return t.stop()}}),t)})))()}},k=_,O=(n("7c06"),Object(v["a"])(k,r,a,!1,null,null,null));t["default"]=O.exports},"841c":function(e,t,n){"use strict";var r=n("d784"),a=n("825a"),c=n("1d80"),o=n("129f"),i=n("14c3");r("search",1,(function(e,t,n){return[function(t){var n=c(this),r=void 0==t?void 0:t[e];return void 0!==r?r.call(t,n):new RegExp(t)[e](String(n))},function(e){var r=n(t,e,this);if(r.done)return r.value;var c=a(e),s=String(this),u=c.lastIndex;o(u,0)||(c.lastIndex=0);var l=i(c,s);return o(c.lastIndex,u)||(c.lastIndex=u),null===l?-1:l.index}]}))},a947:function(e,t,n){"use strict";var r=n("5530"),a=n("bc3a"),c=n.n(a);t["a"]={getCompanies:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1?arguments[1]:void 0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r={limit:t,skip:e?e-1:null,search:n};return c.a.get("/companies",{params:r})},addCompany:function(e){return c.a.post("/companies",Object(r["a"])({},e))},updateCompany:function(e){return c.a.put("/companies",Object(r["a"])({},e))},deleteCompany:function(e){return c.a.delete("/companies/".concat(e))}}},b0c0:function(e,t,n){var r=n("83ab"),a=n("9bf2").f,c=Function.prototype,o=c.toString,i=/^\s*function ([^ (]*)/,s="name";r&&!(s in c)&&a(c,s,{configurable:!0,get:function(){try{return o.call(this).match(i)[1]}catch(e){return""}}})},b8f6:function(e,t,n){"use strict";n("7d50")},bb26:function(e,t,n){"use strict";var r=n("5530"),a=(n("ac1f"),n("841c"),n("bc3a")),c=n.n(a);t["a"]={getVehicles:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.bindStatus,n=void 0===t?null:t,r=e.limit,a=void 0===r?null:r,o=e.page,i=void 0===o?null:o,s=e.search,u=void 0===s?null:s,l=e.company,d=void 0===l?null:l,f=e.boxBindStatus,p=void 0===f?null:f,b=e.includeDeleted,v=void 0===b?null:b;return i=i?i-1:null,c.a.get("/vehicles",{params:{bindStatus:n,limit:a,skip:i,search:u,company:d,boxBindStatus:p,includeDeleted:v}})},addVehicle:function(e){return c.a.post("/vehicles",Object(r["a"])({},e))},updateVehicle:function(e){return c.a.put("/vehicles",e)},deleteVehicle:function(e){return c.a.delete("/vehicles/".concat(e))},getMakers:function(){return c.a.get("/vehiclecodebook/make")},getModelsForMake:function(e){return c.a.get("/vehiclecodebook/make/".concat(e,"/model"))},getCurrentLocation:function(e){return c.a.get("vehicles/".concat(e,"/current-location"))}}},bb2f:function(e,t,n){var r=n("d039");e.exports=!r((function(){return Object.isExtensible(Object.preventExtensions({}))}))},bce3:function(e,t,n){"use strict";var r=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",[n("paginate",{attrs:{"page-count":e.totalPages,"prev-text":e.arrow,"next-text":e.arrow,"prev-class":"prev","next-class":"next",value:e.currentPage,"click-handler":e.onPageChanged,"container-class":"vue-pagination"}})],1)},a=[],c={props:["totalPages","currentPage"],computed:{arrow:function(){return'\n \n \n \n '}},methods:{onPageChanged:function(e){this.$emit("pageChanged",e)}}},o=c,i=(n("b8f6"),n("2877")),s=Object(i["a"])(o,r,a,!1,null,null,null);t["a"]=s.exports},d81d:function(e,t,n){"use strict";var r=n("23e7"),a=n("b727").map,c=n("1dde"),o=c("map");r({target:"Array",proto:!0,forced:!o},{map:function(e){return a(this,e,arguments.length>1?arguments[1]:void 0)}})},dca8:function(e,t,n){var r=n("23e7"),a=n("bb2f"),c=n("d039"),o=n("861d"),i=n("f183").onFreeze,s=Object.freeze,u=c((function(){s(1)}));r({target:"Object",stat:!0,forced:u,sham:!a},{freeze:function(e){return s&&o(e)?s(i(e)):e}})},f183:function(e,t,n){var r=n("d012"),a=n("861d"),c=n("5135"),o=n("9bf2").f,i=n("90e3"),s=n("bb2f"),u=i("meta"),l=0,d=Object.isExtensible||function(){return!0},f=function(e){o(e,u,{value:{objectID:"O"+ ++l,weakData:{}}})},p=function(e,t){if(!a(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!c(e,u)){if(!d(e))return"F";if(!t)return"E";f(e)}return e[u].objectID},b=function(e,t){if(!c(e,u)){if(!d(e))return!0;if(!t)return!1;f(e)}return e[u].weakData},v=function(e){return s&&m.REQUIRED&&d(e)&&!c(e,u)&&f(e),e},m=e.exports={REQUIRED:!1,fastKey:p,getWeakData:b,onFreeze:v};r[u]=!0}}]); //# sourceMappingURL=chunk-2449ccfd.3837fb69.js.map