(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-567df881"],{"01e6":function(t,e,a){"use strict";a("046e")},"046e":function(t,e,a){},"15e5":function(t,e,a){"use strict";a("8a3e")},"261e":function(t,e,a){"use strict";var n=function(){var t=this,e=t.$createElement,a=t._self._c||e;return t.showRatingButton?a("div",[a("button",{staticClass:"primary-button d-inline",on:{click:function(e){t.showModal=!0}}},[t._v(" "+t._s(t.btnTitle)+" ")]),a("RatingModal",{attrs:{forUserId:t.forUserId,showModal:t.showModal,editMode:t.editMode,oldRating:t.oldRating},on:{hideModal:function(e){return t.hideModal()},ratingChange:function(e){return t.$emit("ratingChange")}}})],1):t._e()},r=[],i=(a("a9e3"),a("96cf"),a("1da1")),s=a("97af"),o=function(){var t=this,e=t.$createElement,a=t._self._c||e;return t.showModal?a("div",{staticClass:"rating-modal"},[a("div",{staticClass:"rating-modal-header"},[a("div",[t._v(t._s(t.editMode?"Edit your rating":"Add your rating"))]),a("span",{staticClass:"close rating-modal-close",on:{click:function(e){return t.hideModal()}}},[t._v("×")])]),a("div",{staticClass:"rating-modal-body"},[a("form",{on:{submit:function(e){return e.preventDefault(),t.submitRating()}}},[a("input",{directives:[{name:"model",rawName:"v-model",value:t.title,expression:"title"}],staticClass:"form-control my-2",attrs:{type:"text",placeholder:"title"},domProps:{value:t.title},on:{input:function(e){e.target.composing||(t.title=e.target.value)}}}),a("textarea",{directives:[{name:"model",rawName:"v-model",value:t.description,expression:"description"}],staticClass:"form-control",attrs:{placeholder:"description"},domProps:{value:t.description},on:{input:function(e){e.target.composing||(t.description=e.target.value)}}}),t._v(" "),a("RatingStars",{attrs:{editMode:"",rating:t.rating},on:{update:function(e){t.rating=e}}}),a("button",{staticClass:"primary-button ",attrs:{type:"submit"}},[t._v(" "+t._s(t.editMode?"Save Changes":"Submit")+" ")])],1)])]):t._e()},u=[],d=(a("a4d3"),a("e01a"),a("7691")),c={emits:["ratingChange"],props:{showModal:{type:Boolean,default:!1},forUserId:{type:Number},editMode:{type:Boolean,default:!1},oldRating:{type:Object,default:function(){return null}}},data:function(){return{title:"",description:"",rating:0}},components:{RatingStars:d["a"]},mounted:function(){var t=this;return Object(i["a"])(regeneratorRuntime.mark((function e(){var a,n,r,i;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:t.editMode&&(a=t.oldRating,a.id,n=a.title,r=a.description,i=a.rating,t.title=n,t.description=r,t.rating=i);case 1:case"end":return e.stop()}}),e)})))()},methods:{submitRating:function(){var t=this;return Object(i["a"])(regeneratorRuntime.mark((function e(){var a,n;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:if(t.title&&t.description&&!(!t.rating>0)){e.next=2;break}return e.abrupt("return",t.$toasted("Please fill up all the fields properly and rate the user."));case 2:if(!t.editMode){e.next=18;break}return e.prev=3,e.next=6,s["a"].post("/material-testers/rating/update",{id:t.oldRating.id,title:t.title,description:t.description,rating:t.rating});case 6:a=e.sent,t.$toasted.success(a.data.message),t.$emit("ratingChange"),t.hideModal(),e.next=16;break;case 12:e.prev=12,e.t0=e["catch"](3),console.log("error in updating rating",e.t0),t.$toasted.error(e.t0.response&&e.t0.response.data&&e.t0.response.data.message);case 16:e.next=31;break;case 18:return e.prev=18,e.next=21,s["a"].post("/material-testers/rating",{for_user_id:t.forUserId,title:t.title,description:t.description,rating:t.rating});case 21:n=e.sent,t.$toasted.success(n.data.message),t.$emit("ratingChange"),t.hideModal(),e.next=31;break;case 27:e.prev=27,e.t1=e["catch"](18),console.log("error in posting rating",e.t1),t.$toasted.error(e.t1.response&&e.t1.response.data&&e.t1.response.data.message);case 31:case"end":return e.stop()}}),e,null,[[3,12],[18,27]])})))()},hideModal:function(){this.$emit("hideModal")}}},l=c,g=(a("01e6"),a("2877")),f=Object(g["a"])(l,o,u,!1,null,"7fda3e81",null),p=f.exports,m={emits:["update","ratingChange"],props:{title:{type:String,default:"Rate the Material Inspector"},forUserId:{type:Number},allowForOtherUsers:{type:Boolean,default:!1}},data:function(){return{showModal:!1,showRatingButton:!1,editMode:!1,oldRating:null,btnTitle:this.title}},components:{RatingModal:p},mounted:function(){var t=this;return Object(i["a"])(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.next=2,t.checkRatingAllowed();case 2:case"end":return e.stop()}}),e)})))()},methods:{checkRatingAllowed:function(){var t=this;return Object(i["a"])(regeneratorRuntime.mark((function e(){var a,n,r;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.prev=0,a="/material-testers/check-rating-allowed?for_user_id="+t.forUserId,t.allowForOtherUsers&&(a+="&allowForOtherUsers=true"),e.next=5,s["a"].get(a);case 5:n=e.sent,r=n.data,console.log("rating allowed",n),t.editMode=!1,r.allowRating?t.showRatingButton=!0:r.allowEditRating?(t.editMode=!0,t.showRatingButton=!0,t.oldRating=r.result,t.btnTitle="Edit My Rating"):t.showRatingButton=!1,e.next=16;break;case 12:e.prev=12,e.t0=e["catch"](0),console.log("error in checking rating allowed",e.t0),t.showRatingButton=!1;case 16:case"end":return e.stop()}}),e,null,[[0,12]])})))()},hideModal:function(){var t=this;return Object(i["a"])(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return t.showModal=!1,console.log("emitting update rating"),t.$emit("updateRating"),e.next=5,t.checkRatingAllowed();case 5:case"end":return e.stop()}}),e)})))()}}},h=m,v=Object(g["a"])(h,n,r,!1,null,null,null);e["a"]=v.exports},"3f5d":function(t,e,a){"use strict";var n=function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",[a("div",{staticClass:"ratings-title"},[t._v(t._s(t.title))]),a("hr"),t.ratings.length||t.isLoading?t.hideAverageRating?t._e():a("div",[a("div",[t._v("Average rating")]),a("div",{staticClass:"small my-2"},[t._v(t._s(t.materialTester.average_rating||t.averageRating)+" Stars")]),a("div",{staticClass:"small my-2"},[a("RatingStars",{attrs:{rating:t.materialTester.average_rating||t.averageRating}})],1)]):a("div",[t._v(" Not rated by any user. ")]),a("div",{staticClass:"row"},t._l(t.ratings,(function(e){return a("div",{key:e.id,staticClass:"col-md-6"},[a("RatingItem",{key:e.id,attrs:{hideRatingButton:t.hideRatingButton,rating:e,forUserId:t.forUserId,byUserId:t.byUserId},on:{update:t.updateRatings}})],1)})),0)])},r=[],i=(a("99af"),a("a9e3"),a("96cf"),a("1da1")),s=function(){var t=this,e=t.$createElement,a=t._self._c||e;return t.rating?a("div",{staticClass:"rating-item"},[a("div",{staticClass:"font-weight-bold"},[t._v(t._s(t.rating.title))]),a("RatingStars",{attrs:{rating:t.rating.rating}}),a("div",[t._v(t._s(t.rating.description))]),t.byUserId?a("div",{staticClass:"small mt-2"},[t._v(" To- "+t._s(t.rating.for_user&&t.rating.for_user.name)+" ")]):a("div",{staticClass:"small mt-2"},[t._v("By- "+t._s(t.rating.by_user&&t.rating.by_user.name))]),t.hideRatingButton?t._e():a("RatingButton",{attrs:{forUserId:t.forUserId},on:{updateRating:function(e){return t.emitUpdate()}}})],1):t._e()},o=[],u=a("7691"),d=a("261e"),c={emits:["update"],props:{hideRatingButton:{type:Boolean,default:!1},rating:{type:Object,default:function(){return null}},forUserId:{type:Number},byUserId:{type:Number}},components:{RatingStars:u["a"],RatingButton:d["a"]},methods:{emitUpdate:function(){console.log("rating item update"),this.$emit("update")}}},l=c,g=(a("a50f"),a("2877")),f=Object(g["a"])(l,s,o,!1,null,"a595e24c",null),p=f.exports,m=a("97af"),h={props:{title:{type:String,default:"Ratings"},forUserId:{type:Number},byUserId:{type:Number},materialTester:{type:Object},hideRatingButton:{type:Boolean,default:!1},notIsMaterialTester:{type:Boolean,default:!1},isMaterialTester:{type:Boolean,default:!1},hideAverageRating:{type:Boolean,default:!1}},components:{RatingItem:p,RatingStars:u["a"]},data:function(){return{ratings:[],isLoading:!1,averageRating:0}},mounted:function(){var t=this;return Object(i["a"])(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return t.isLoading=!0,e.next=3,t.fetchRatings();case 3:t.isLoading=!1;case 4:case"end":return e.stop()}}),e)})))()},methods:{fetchRatings:function(){var t=this;return Object(i["a"])(regeneratorRuntime.mark((function e(){var a,n,r;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:if(n="&is_material_tester=".concat(t.isMaterialTester,"¬_is_material_tester=").concat(t.notIsMaterialTester),!t.forUserId){e.next=5;break}return e.next=4,m["a"].get("/material-testers/ratings?for_user_id="+t.forUserId+n);case 4:a=e.sent;case 5:if(!t.byUserId){e.next=9;break}return e.next=8,m["a"].get("/material-testers/ratings?by_user_id="+t.byUserId+n);case 8:a=e.sent;case 9:r=a.data,t.ratings=r.result,t.averageRating=r.average_rating;case 12:case"end":return e.stop()}}),e)})))()},updateRatings:function(){var t=this;return Object(i["a"])(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return console.log("update ratings running"),e.next=3,t.fetchRatings();case 3:case"end":return e.stop()}}),e)})))()}}},v=h,R=(a("c87e"),Object(g["a"])(v,n,r,!1,null,"85c1e694",null));e["a"]=R.exports},"45bb":function(t,e,a){},7691:function(t,e,a){"use strict";var n=function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{class:["my-1",{"my-3":t.editMode}]},[t.editMode?a("div",{staticClass:"mb-2"},[t._v("Rate out of 5 stars")]):t._e(),a("div",{on:{mouseenter:function(e){t.hoverMode=!0},mouseleave:function(e){t.hoverMode=!1}}},[t._l(t.max,(function(e){return[e<=t.showRating?a("i",{key:e,class:["rating-star","rating-star-active","fa","fa-star",{"fa-2x":t.editMode},"mr-1"],on:{mouseover:function(a){return t.updateRatingStar(e)},click:function(a){return t.setRatingStar(e)}}}):a("i",{key:e,class:["rating-star","fa","fa-star-o",{"fa-2x":t.editMode},"text-secondary","mr-1"],on:{mouseover:function(a){return t.updateRatingStar(e)},click:function(a){return t.setRatingStar(e)}}})]}))],2)])},r=[],i=(a("a9e3"),{props:{rating:{type:Number,default:0},max:{type:Number,default:5},editMode:{type:Boolean,default:!1}},data:function(){return{hoverMode:!1,hoverRating:0}},methods:{updateRatingStar:function(t){this.editMode&&(this.hoverRating=t+1)},setRatingStar:function(t){this.$emit("update",t+1)}},computed:{showRating:function(){return this.hoverMode&&this.editMode?this.hoverRating:this.rating}}}),s=i,o=(a("15e5"),a("2877")),u=Object(o["a"])(s,n,r,!1,null,"7ed4bb68",null);e["a"]=u.exports},"8a3e":function(t,e,a){},"99af":function(t,e,a){"use strict";var n=a("23e7"),r=a("d039"),i=a("e8b5"),s=a("861d"),o=a("7b0b"),u=a("50c4"),d=a("8418"),c=a("65f0"),l=a("1dde"),g=a("b622"),f=a("2d00"),p=g("isConcatSpreadable"),m=9007199254740991,h="Maximum allowed index exceeded",v=f>=51||!r((function(){var t=[];return t[p]=!1,t.concat()[0]!==t})),R=l("concat"),b=function(t){if(!s(t))return!1;var e=t[p];return void 0!==e?!!e:i(t)},w=!v||!R;n({target:"Array",proto:!0,forced:w},{concat:function(t){var e,a,n,r,i,s=o(this),l=c(s,0),g=0;for(e=-1,n=arguments.length;em)throw TypeError(h);for(a=0;a=m)throw TypeError(h);d(l,g++,i)}return l.length=g,l}})},a50f:function(t,e,a){"use strict";a("45bb")},c87e:function(t,e,a){"use strict";a("e195")},e195:function(t,e,a){}}]); //# sourceMappingURL=chunk-567df881.ecbe44bc.js.map