PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.10
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.10
4.4.10 4.4.9.1 4.4.9 4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 All 142 releases
← All changes | assets/js/admin/list-students-enrolled.min.js +1 -1 4.4.2 → 4.4.10 View file →
@@ -1 +1 @@
1 -import*as lpUtils from"lpAssetsJsPath/utils.js";export class ListStudentsEnrolled{constructor(){this.instructorId=null,this.elContainer=null,this.isRequesting=!1}static selectors={elContainer:"#lp-enrolled-students",elForm:".lp-enrolled-students-form",elLPTarget:".lp-target",elCourseNameInput:".lp-enrolled-filter-course-name",elCourseIdInput:"#lp-enrolled-filter-course-id",elCourseList:"#lp-enrolled-course-list",elSearchInput:".lp-enrolled-search-input",elStartDateInput:".lp-enrolled-filter-start-date",elEndDateInput:".lp-enrolled-filter-end-date",elBtnSearch:".lp-enrolled-btn-search",elBtnClear:".lp-enrolled-btn-clear"};init(){if(this.elContainer=document.querySelector(ListStudentsEnrolled.selectors.elContainer),!this.elContainer)return;const e=this.elContainer.querySelector(ListStudentsEnrolled.selectors.elLPTarget),t=this.getAjaxHandle();if(e&&t){const s=t.getDataSetCurrent(e);s&&s.args&&(this.instructorId=s.args.instructor_id)}this.events()}events(){ListStudentsEnrolled._loadedEvents||(ListStudentsEnrolled._loadedEvents=this,lpUtils.eventHandlers("click",[{selector:ListStudentsEnrolled.selectors.elBtnSearch,class:this,callBack:this.searchStudents.name},{selector:ListStudentsEnrolled.selectors.elBtnClear,class:this,callBack:this.clearFilters.name}]),lpUtils.eventHandlers("keydown",[{selector:ListStudentsEnrolled.selectors.elSearchInput,class:this,callBack:this.triggerBtnSearch.name,checkIsEventEnter:!0},{selector:ListStudentsEnrolled.selectors.elCourseNameInput,class:this,callBack:this.triggerBtnSearch.name,checkIsEventEnter:!0},{selector:ListStudentsEnrolled.selectors.elStartDateInput,class:this,callBack:this.triggerBtnSearch.name,checkIsEventEnter:!0},{selector:ListStudentsEnrolled.selectors.elEndDateInput,class:this,callBack:this.triggerBtnSearch.name,checkIsEventEnter:!0}]),lpUtils.eventHandlers("change",[{selector:ListStudentsEnrolled.selectors.elStartDateInput,class:this,callBack:this.checkDatesRange.name},{selector:ListStudentsEnrolled.selectors.elEndDateInput,class:this,callBack:this.checkDatesRange.name}]))}triggerBtnSearch(){const e=this.elContainer.querySelector(ListStudentsEnrolled.selectors.elBtnSearch);e&&e.click()}checkDatesRange(e){const{e:t}=e,s=t?.target;if(!s)return;const l=s.closest(ListStudentsEnrolled.selectors.elForm);if(!l)return;const n=l.querySelector(ListStudentsEnrolled.selectors.elStartDateInput),r=l.querySelector(ListStudentsEnrolled.selectors.elEndDateInput);s===n?n.value?(r.min=n.value,r.value&&r.value<n.value&&(r.value=n.value)):r.min="":s===r&&(r.value?(n.max=r.value,n.value&&n.value>r.value&&(n.value=r.value)):n.max="")}setButtonLoadingState(e,t){e&&(lpUtils.lpSetLoadingEl(e,t?1:0),e.disabled=!!t)}getAjaxHandle(){const e=window.lpAJAXG;return e&&"function"==typeof e.getDataSetCurrent&&"function"==typeof e.setDataSetCurrent&&"function"==typeof e.showHideLoading&&"function"==typeof e.fetchAJAX?e:null}syncCourseIdFromName(e){const t=e?.querySelector(ListStudentsEnrolled.selectors.elCourseIdInput);if(!t)return;t.value="0";const s=e.querySelector(ListStudentsEnrolled.selectors.elCourseNameInput),l=e.querySelector(ListStudentsEnrolled.selectors.elCourseList),n=s?.value.trim()||"";if(!n||!l)return;const r=Array.from(l.options||[]).find(e=>e.value.trim()===n);r&&(t.value=r.dataset.courseId||"0")}getFilterArgsFromForm(e,t={}){return this.syncCourseIdFromName(e),lpUtils.mergeDataWithDatForm(e,t)}searchStudents(e){const{e:t}=e;t&&t.preventDefault();const s=e?.target?.closest(ListStudentsEnrolled.selectors.elBtnSearch);if(s){if(this.isRequesting||s.classList.contains("loading")||s.disabled)return}else if(this.isRequesting)return;const l=s.closest(ListStudentsEnrolled.selectors.elForm),n=this.elContainer.querySelector(ListStudentsEnrolled.selectors.elLPTarget);if(!n||!l)return;const r=this.getAjaxHandle();if(!r)return;this.setButtonLoadingState(s,!0);const o=r.getDataSetCurrent(n);o.args=this.getFilterArgsFromForm(l,o.args||{}),o.args.paged=1,r.setDataSetCurrent(n,o),this.reloadContent(n,o,s)}clearFilters(e){const{e:t}=e;t&&t.preventDefault();const s=e?.target?.closest(ListStudentsEnrolled.selectors.elBtnClear);if(s){if(this.isRequesting||s.classList.contains("loading")||s.disabled)return}else if(this.isRequesting)return;const l=s.closest(ListStudentsEnrolled.selectors.elForm),n=this.elContainer.querySelector(ListStudentsEnrolled.selectors.elLPTarget);if(!n||!l)return;const r=this.getAjaxHandle();if(!r)return;this.setButtonLoadingState(s,!0),l.reset(),this.syncCourseIdFromName(l);const o=r.getDataSetCurrent(n);o.args=lpUtils.mergeDataWithDatForm(l,o.args||{}),o.args.paged=1,r.setDataSetCurrent(n,o),this.reloadContent(n,o,s)}reloadContent(e,t,s=null){const l=this.getAjaxHandle();if(!l)return this.isRequesting=!1,void this.setButtonLoadingState(s,!1);this.isRequesting=!0,l.showHideLoading(e,1);const n={success:t=>{const{status:s,data:l}=t;"success"===s&&(e.innerHTML=l.content)},error:e=>console.error(e),completed:()=>{this.isRequesting=!1,l.showHideLoading(e,0),this.setButtonLoadingState(s,!1)}};l.fetchAJAX(t,n)}}const listStudentsEnrolled=new ListStudentsEnrolled;lpUtils.lpOnElementReady(ListStudentsEnrolled.selectors.elContainer,()=>{listStudentsEnrolled.init()});
1 +import*as lpUtils from"lpAssetsJsPath/utils.js";export class ListStudentsEnrolled{constructor(){this.instructorId=null,this.elContainer=null}static selectors={elContainer:".lp-enrolled-students",elLayout:".lp-students-enrolled-layout",elForm:".lp-enrolled-students-form",elLPTarget:".lp-target",elCourseNameInput:".lp-enrolled-filter-course-name",elCourseIdInput:"#lp-enrolled-filter-course-id",elCourseList:"#lp-enrolled-course-list",elSearchInput:".lp-enrolled-search-input",elStartDateInput:".lp-enrolled-filter-start-date",elEndDateInput:".lp-enrolled-filter-end-date",elBtnSearch:".lp-enrolled-btn-search",elBtnClear:".lp-enrolled-btn-clear"};init(){if(this.elContainer=document.querySelector(ListStudentsEnrolled.selectors.elContainer),!this.elContainer)return;const e=this.elContainer.querySelector(ListStudentsEnrolled.selectors.elLPTarget),t=this.getAjaxHandle();if(e&&t){const s=t.getDataSetCurrent(e);s&&s.args&&(this.instructorId=s.args.instructor_id)}this.events()}events(){ListStudentsEnrolled._loadedEvents||(ListStudentsEnrolled._loadedEvents=this,lpUtils.eventHandlers("click",[{selector:ListStudentsEnrolled.selectors.elBtnSearch,callBack:this.searchStudents.bind(this)},{selector:ListStudentsEnrolled.selectors.elBtnClear,callBack:this.clearFilters.bind(this)}]),lpUtils.eventHandlers("keydown",[{selector:ListStudentsEnrolled.selectors.elSearchInput,callBack:this.triggerBtnSearch.bind(this),checkIsEventEnter:!0},{selector:ListStudentsEnrolled.selectors.elCourseNameInput,callBack:this.triggerBtnSearch.bind(this),checkIsEventEnter:!0},{selector:ListStudentsEnrolled.selectors.elStartDateInput,callBack:this.triggerBtnSearch.bind(this),checkIsEventEnter:!0},{selector:ListStudentsEnrolled.selectors.elEndDateInput,callBack:this.triggerBtnSearch.bind(this),checkIsEventEnter:!0}]),lpUtils.eventHandlers("change",[{selector:ListStudentsEnrolled.selectors.elStartDateInput,callBack:this.checkDatesRange.bind(this)},{selector:ListStudentsEnrolled.selectors.elEndDateInput,callBack:this.checkDatesRange.bind(this)}]))}triggerBtnSearch(){const e=this.elContainer.querySelector(ListStudentsEnrolled.selectors.elBtnSearch);e&&e.click()}checkDatesRange(e){const{e:t}=e,s=t?.target;if(!s)return;const l=s.closest(ListStudentsEnrolled.selectors.elForm);if(!l)return;const r=l.querySelector(ListStudentsEnrolled.selectors.elStartDateInput),n=l.querySelector(ListStudentsEnrolled.selectors.elEndDateInput);s===r?r.value?(n.min=r.value,n.value&&n.value<r.value&&(n.value=r.value)):n.min="":s===n&&(n.value?(r.max=n.value,r.value&&r.value>n.value&&(r.value=n.value)):r.max="")}setButtonLoadingState(e,t){e&&lpUtils.lpSetLoadingEl(e,t?1:0)}getAjaxHandle(){const e=window.lpAJAXG;return e&&"function"==typeof e.getDataSetCurrent&&"function"==typeof e.setDataSetCurrent&&"function"==typeof e.showHideLoading&&"function"==typeof e.fetchAJAX?e:null}syncCourseIdFromName(e){const t=e?.querySelector(ListStudentsEnrolled.selectors.elCourseIdInput);if(!t)return;t.value="0";const s=e.querySelector(ListStudentsEnrolled.selectors.elCourseNameInput),l=e.querySelector(ListStudentsEnrolled.selectors.elCourseList),r=s?.value.trim()||"";if(!r||!l)return;const n=Array.from(l.options||[]).find(e=>e.value.trim()===r);n&&(t.value=n.dataset.courseId||"0")}getFilterArgsFromForm(e,t={}){return this.syncCourseIdFromName(e),lpUtils.mergeDataWithDatForm(e,t)}searchStudents(e){const{e:t}=e;t&&t.preventDefault();const s=e?.target?.closest(ListStudentsEnrolled.selectors.elBtnSearch);if(!s)return;const l=s.closest(ListStudentsEnrolled.selectors.elForm),r=l.closest(ListStudentsEnrolled.selectors.elLayout).querySelector(ListStudentsEnrolled.selectors.elLPTarget);if(!r||!l)return;const n=this.getAjaxHandle();if(!n)return;this.setButtonLoadingState(s,!0);const o=n.getDataSetCurrent(r);o.args=this.getFilterArgsFromForm(l,o.args||{}),o.args.paged=1,n.setDataSetCurrent(r,o),this.reloadContent(r,o,s)}clearFilters(e){const{e:t}=e;t&&t.preventDefault();const s=e?.target?.closest(ListStudentsEnrolled.selectors.elBtnClear);if(!s)return;const l=s.closest(ListStudentsEnrolled.selectors.elForm),r=l.closest(ListStudentsEnrolled.selectors.elLayout).querySelector(ListStudentsEnrolled.selectors.elLPTarget);if(!r||!l)return;const n=this.getAjaxHandle();if(!n)return;this.setButtonLoadingState(s,!0),l.reset(),this.syncCourseIdFromName(l);const o=n.getDataSetCurrent(r);o.args=lpUtils.mergeDataWithDatForm(l,o.args||{}),o.args.paged=1,n.setDataSetCurrent(r,o),this.reloadContent(r,o,s)}reloadContent(e,t,s=null){const l=this.getAjaxHandle();if(!l)return void this.setButtonLoadingState(s,!1);l.showHideLoading(e,1);const r={success:t=>{const{status:s,data:l}=t;"success"===s&&(e.innerHTML=l.content)},error:e=>console.error(e),completed:()=>{l.showHideLoading(e,0),this.setButtonLoadingState(s,!1)}};l.fetchAJAX(t,r)}}const listStudentsEnrolled=new ListStudentsEnrolled;lpUtils.lpOnElementReady(ListStudentsEnrolled.selectors.elContainer,()=>{listStudentsEnrolled.init()});