| Current Path : /home/juvelize/martine/tmp/install_61b0f5c54c150/media/js/vue/ |
| Current File : /home/juvelize/martine/tmp/install_61b0f5c54c150/media/js/vue/modal_users_summary.min.js |
const acym_userSummaryModal={applications:[],init:function(){jQuery(document).ready(()=>{this.getOpenModalEvent()}),jQuery(document).on("acym__modal__users__summary__ready",()=>{this.getOpenModalEvent()})},getOpenModalEvent:function(){jQuery(".acym__modal__users__summary__container").off("open.zf.reveal").on("open.zf.reveal",function(){let s=jQuery(this).attr("id"),t=acym_helper.parseJson(jQuery(this).find("[acym-data-query]").attr("acym-data-query"));acym_userSummaryModal.setModalUsersSummary(`#${s}`,t)}).on("closed.zf.reveal",function(){let s=jQuery(this).attr("id");acym_userSummaryModal.applications[`#${s}`].listingLoading=!0})},setModalUsersSummary:function(s,t){if(void 0!==this.applications[s])return void this.applications[s].reload();let i="";for(let[s,e]of Object.entries(t))i+=`&${s}=${e}`;let e=`${ACYM_AJAX_URL}${i}`;this.applications[s]=new Vue({directives:{infiniteScroll:infiniteScroll},el:s+" .acym__modal__users__summary",data:{users:{},limit:50,scroll:0,busy:!1,listingError:!1,listingLoading:!0,errorMessage:"",search:"",typingTimer:""},mounted:function(){this.getUsers()},methods:{getUsers(){let s={offset:this.limit*this.scroll,limit:this.limit,modal_search:encodeURIComponent(this.search)},t=jQuery("#acym_form").serialize();for(let[i,e]of Object.entries(s))t+=`&${i}=${e}`;t+=i,acym_helper.post(e,t).then(s=>{if(s.error)return this.errorMessage=s.message,void(this.listingError=!0);this.users={...this.users,...s.data.users},this.listingError=!1,this.listingLoading=!1}).always(s=>{this.listingLoading=!1,this.busy=!1})},loadMoreUsers(){this.busy=!0,this.scroll++,this.getUsers()},reload(){this.scroll=0,this.users={},this.getUsers()}},computed:{displayListing(){return!this.listingError&&!this.listingLoading&&!this.emptyListing},emptyListing(){return 0===Object.keys(this.users).length&&!this.listingLoading&&!this.listingError}},watch:{search(s){clearTimeout(this.typingTimer),this.scroll=0,this.users={},this.listingLoading=!0,""===s?this.getUsers():this.typingTimer=setTimeout(()=>{this.getUsers()},1e3)}}})}};acym_userSummaryModal.init();