text: (window.webpackJsonp=window.webpackJsonp||[]).push([[3],{338:function(e,t,i){e.exports=i(339)},339:function(e,t,i){"use strict";i.r(t);var n=i(56);document.getElementById("lecture_management")&&Object(n.a)()},56:function(e,t,i){"use strict";var n=i(10),s=i.n(n),o={data:function(){return{file:{file_name:"",file_extension:""},i18n:i18n}},props:{type:{default:"image"},value:""},computed:{fileName:function(){return this.file.file_extension?this.file.file_name+"."+this.file.file_extension:this.file.file_name}},mounted:function(){this.value&&this.getFile(this.value)},methods:{openUploader:function(){var e=this;uploaderModal.show({multiple:!1,file_type:e.type,onSelect:function(t){e.file=t[0],e.$emit("input",e.file.id)}})},clearFile:function(){this.file={file_name:"",file_extension:""},this.$emit("input","")},getFile:function(e){var t=this;this.file={file_name:"",file_extension:""},$.ajax({url:bookingCore.media.get_file+"?id="+e,dataType:"json",success:function(e){e.id?t.file=e:(t.file.file_name="(ERROR: File not found)",t.$emit("input",""))},error:function(e){console.log(e),t.file.file_name="(ERROR: File not found)",t.$emit("input","")}})}},watch:{value:function(e){e?this.getFile(this.value):this.file={file_name:"",file_extension:""}}}},a=i(5),r=Object(a.a)(o,(function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("div",{staticClass:"bravo-file-picker input-group"},[i("input",{directives:[{name:"model",rawName:"v-model",value:e.fileName,expression:"fileName"}],staticClass:"form-control",staticStyle:{background:"white"},attrs:{type:"text",readonly:"",placeholder:e.i18n.choose_file},domProps:{value:e.fileName},on:{input:function(t){t.target.composing||(e.fileName=t.target.value)}}}),e._v(" "),i("div",{staticClass:"input-group-append"},[i("span",{staticClass:"input-group-text",on:{click:e.openUploader}},[e._v(e._s(e.i18n.browse))]),e._v(" "),e.value?i("span",{staticClass:"input-group-text text-danger",on:{click:e.clearFile}},[e._v(e._s(e.i18n.clear))]):e._e()])])}),[],!1,null,null,null).exports;t.a=function(){window.courseLecturesManagement=new s.a({el:"#lecture_management",data:{onEdit:!1,options:{},sections:course_sections_data.sections,lecture_form:{type:"",id:"",name:"",duration:"",url:"",preview_url:"",file_id:"",active:1,display_order:0},section_form:{id:"",name:"",active:1,display_order:0},i18n:course_sections_data.i18n,error:[],routes:course_sections_data.routes,onSaving:!1,lastSection:!1,course_id:course_sections_data.id,lastEditObject:{}},mounted:function(){},computed:{fileIdType:function(){return this.lecture_form.type,this.lecture_form.type},add_lecture_title:function(){return this.i18n.add_lecture[this.lecture_form.type]}},methods:{addLesson:function(e,t){this.lecture_form={type:e,id:"",name:"",duration:"",url:"",preview_url:"",file_id:"",active:1,display_order:0},this.lastSection=t,this.error=[],$("#add_lecture_modal").modal("show")},editLesson:function(e,t){this.lastSection=t,this.lecture_form=Object.assign({},e),this.lastEditObject=e,this.error=[],$("#add_lecture_modal").modal("show")},openSectionForm:function(e,t){this.error=[],t?(this.section_form=Object.assign({},t),this.lastSection=t):this.section_form={id:"",name:"",active:1,display_order:0},$("#add_section_modal").modal("show")},saveLesson:function(){var e=this;if(!e.onSaving){if(!this.validateLecture())return!1;e.onSaving=!0;var t=Object.assign({},this.lecture_form);t.section_id=e.lastSection?e.lastSection.id:"",t.course_id=e.course_id,$.ajax({url:this.routes.store,data:t,dataType:"json",type:"post",success:function(i){e.onSaving=!1,i.message&&bookingCoreApp.showAjaxMessage(i),i.lecture?(void 0===e.lastSection.lessons&&(e.lastSection.lessons=[]),e.lastSection.lessons.push(i.lecture)):(e.lastEditObject&&(e.lastEditObject=t),e.updateLectureData(t.section_id,t.id,t)),i.status&&$("#add_lecture_modal").modal("hide")},error:function(t){e.onSaving=!1,bookingCoreApp.showAjaxError(t)}})}},updateLectureData:function(e,t,i){var n=_.findIndex(this.sections,{id:e});if(n>-1){var s=_.findIndex(this.sections[n].lessons,{id:t});if(s>-1)for(var o in i)this.$set(this.sections[n].lessons[s],o,i[o])}},validateLecture:function(){this.error=[];var e=[];return this.lecture_form.name||e.push(this.i18n.validate.name),this.lecture_form.duration||e.push(this.i18n.validate.duration),this.error=e,!e.length},saveSection:function(){var e=this;if(!e.onSaving){if(!this.validateSection())return!1;e.onSaving=!0;var t=Object.assign({},this.section_form);t.course_id=e.course_id,$.ajax({url:this.routes.store_section,data:t,dataType:"json",type:"post",success:function(i){if(e.onSaving=!1,i.message&&bookingCoreApp.showAjaxMessage(i),i.section)e.sections.push(i.section);else for(var n in t)e.$set(e.lastSection,n,t[n]);i.status&&$("#add_lecture_modal").modal("hide")},error:function(t){e.onSaving=!1,bookingCoreApp.showAjaxError(t)}})}},validateSection:function(){this.error=[];var e=[];return this.section_form.name||e.push(this.i18n.validate.section_title),this.error=e,!e.length}},components:{filePicker:r}})}}},[[338,0,1]]]);
  //# sourceMappingURL=frontend_lectures.js.map