2 lines
12 KiB
JavaScript
2 lines
12 KiB
JavaScript
import{k as e,av as t,c as s,aH as i,aI as a,aO as n,ay as r,E as l,a_ as c,aZ as o,ap as d}from"../../../../vendor-element-plus.js?ver=3.1.8";import{aQ as u,W as _,X as b,Y as h,a5 as m,Z as g,aa as f,ab as p,a9 as v,J as S,a6 as y,ac as w,a8 as $,av as q}from"../../../../vendor.js?ver=3.1.8";import{R as k}from"../../../../RecipientTaggerForm.js?ver=3.1.8";import{_ as C,I as T,a as x,T as E}from"../../../../fc-bits-ui.js?ver=3.1.8";import{P as D}from"../../../../PaginationBar.js?ver=3.1.8";import{D as P}from"../../../../DataTable.js?ver=3.1.8";import{F as j}from"../../../../FloatingBulkActionShell.js?ver=3.1.8";import{C as B}from"../../../../Confirm.js?ver=3.1.8";import{B as A}from"../../../../Badge.js?ver=3.1.8";import{P as F}from"../../../../PageHeader.js?ver=3.1.8";import"../../../../fc-bits.js?ver=3.1.8";const I={class:"fluentcrm_sequence_sub_adder"},V={class:"text-align-center"},R={class:"text-align-center"},H={key:1,class:"text-align-center fluentcrm_hero_box"};const O={class:"fcrm_sequence_subscribers_table_wrap"},L={class:"fcrm_table_header_inner_left_title"},N=["title","src"],z={class:"fcrm_contact_info"},J={class:"fcrm_contact_name"},U={class:"fcrm_contact_email"},Y={class:"fcrm_sequence_date_with_note"},Z=["title"],G=["aria-label"],Q=["title"],W={key:1},X={class:"fcrm_bulk_action_bar"},K={class:"fcrm_bulk_action_left"},M={class:"fc_bulk_selection_count"},ee={class:"icon"};const te={class:"fcrm_email_sequences_view"},se={class:"fcrm-layout-width"},ie={class:"fcrm_sequence_subscribers_body"},ae={key:1,class:"fluentcrm_sequence_subs"};const ne=C({name:"SequenceSubscribers",props:["id"],components:{SubscribersAdder:C({name:"sequence_sub_adder",props:["sequence_id"],components:{RecipientTaggerForm:k},data:()=>({settings:{subscribers:[{list:null,tag:"all"}],excludedSubscribers:[{list:null,tag:null}],sending_filter:"list_tag",dynamic_segment:{id:"",slug:""}},ready_tagger:!0,inserting_page:1,inserting_total_page:0,inserting_now:!1,btnSubscribing:!1,batch_completed:!1,in_total:0,estimated_count:0}),watch:{},methods:{processSubscribers(){const e=this.settings,t=e.subscribers.filter(e=>e.list&&e.tag),s=e.excludedSubscribers.filter(e=>e.list&&e.tag);if("list_tag"===e.sending_filter){if(t.length!==e.subscribers.length||s.length&&s.length!==e.excludedSubscribers.length)return void this.$notify.error({title:this.$t("Oops!"),message:this.$t("_Su_Invalid_solatisi"),offset:19})}else if("dynamic_segment"==e.sending_filter){if(!e.dynamic_segment.uid)return void this.$notify.error({title:this.$t("Oops!"),message:this.$t("Please select the segment"),offset:19})}else if("advanced_filters"==e.sending_filter){let t=!1;if(this.each(e.advanced_filters,e=>{this.isEmptyValue(e)||(t=!0)}),!t)return void this.$notify.error({title:this.$t("Oops!"),message:this.$t("Please select the filters"),offset:19})}const i={subscribers:t,excludedSubscribers:s,sending_filter:e.sending_filter,dynamic_segment:e.dynamic_segment,page:this.inserting_page,advanced_filters:JSON.stringify(e.advanced_filters)};this.btnSubscribing=!0,this.inserting_now=!0,this.ready_tagger=!1,this.$post(`sequences/${this.sequence_id}/subscribers`,i).then(e=>{e.remaining?(1===this.inserting_page&&(this.inserting_total_page=e.page_total),this.inserting_page=e.next_page,this.$nextTick(()=>{this.processSubscribers()})):(this.batch_completed=!0,this.$notify.success({title:this.$t("Great!"),message:this.$t("_Su_Subscribers_hbas"),offset:19}),this.in_total=e.in_total)}).catch(e=>{this.handleError(e),this.btnSubscribing=!1,this.inserting_now=!1}).finally(()=>{})},resetSettings(){this.$emit("completed"),this.ready_tagger=!1,this.batch_completed=!1,this.inserting_now=!1,this.btnSubscribing=!1,this.inserting_page=1,this.inserting_total_page=0,this.settings={subscribers:[{list:null,tag:"all"}],excludedSubscribers:[{list:null,tag:null}],sending_filter:"list_tag",dynamic_segment:{id:"",slug:""}},this.$nextTick(()=>{this.ready_tagger=!0})}}},[["render",function(s,i,a,n,r,l){const c=e,o=u("recipient-tagger-form"),d=t;return _(),b("div",I,[r.ready_tagger?(_(),h(o,{key:0,modelValue:r.settings,"onUpdate:modelValue":i[1]||(i[1]=e=>r.settings=e)},{fc_tagger_bottom:m(()=>[g("div",V,[g("p",null,f(s.$t("_Su_Please_ntsewbstt")),1)]),g("div",R,[p(c,{onClick:i[0]||(i[0]=e=>l.processSubscribers()),type:"primary"},{default:m(()=>[v(f(s.$t("Add to this Sequence")),1)],void 0,!0),_:1})])]),_:1},8,["modelValue"])):(_(),b("div",H,[r.batch_completed?(_(),b(S,{key:0},[g("h3",null,f(s.$t("Completed")),1),g("h4",null,f(s.$t("_Su_All_SLashbaSttsE")),1),y(p(c,{onClick:i[2]||(i[2]=e=>l.resetSettings()),type:"primary",size:"small"},{default:m(()=>[v(f(s.$t("Back")),1)],void 0),_:1},512),[[w,r.batch_completed]]),g("p",null,[g("b",null,f(r.in_total),1),v(" "+f(s.$t("_Su_Subscribers_hbat")),1)])],64)):(_(),b(S,{key:1},[g("h3",null,f(s.$t("Processing now...")),1),g("h4",null,f(s.$t("Rec_Please_dnctw")),1),r.inserting_total_page?(_(),b(S,{key:0},[g("h2",null,f(r.inserting_page)+"/"+f(r.inserting_total_page),1),p(d,{"text-inside":!0,"stroke-width":24,percentage:parseInt(r.inserting_page/r.inserting_total_page*100),status:"success"},null,8,["percentage"])],64)):$("",!0)],64))]))])}]]),SequenceSubscribersView:C({name:"SequenceSubscribers",components:{Icons:T,PaginationBar:D,DataTable:P,FloatingBulkActionShell:j,Confirm:B,Badge:A,Close:s},props:["sequence_id","reload_count"],data:()=>({loading:!1,subscribers:[],pagination:{total:0,per_page:20,current_page:1},selected_subscribers:[],removing:!1,current_mode:"system"===E.getCurrentTheme()?E.getSystemTheme():E.getCurrentTheme()}),watch:{reload_count(){this.pagination.current_page=1,this.fetch()}},methods:{fetch(){this.loading=!0,this.selected_subscribers=[];const e={per_page:this.pagination.per_page,page:this.pagination.current_page};this.$get(`sequences/${this.sequence_id}/subscribers`,e).then(e=>{this.subscribers=e.data,this.pagination.total=e.total}).catch(e=>{this.handleError(e)}).finally(()=>{this.loading=!1})},removeSubscribers(){const e=this.selected_subscribers.map(e=>e.id);this.removing=!0,this.$del(`sequences/${this.sequence_id}/subscribers`,{tracker_ids:e}).then(e=>{this.$notify.success(e.message),this.fetch()}).catch(e=>{this.handleError(e)}).finally(()=>{this.removing=!1})},handleSelectionChange(e){this.selected_subscribers=e},clearSubscriberSelection(){this.$refs.subscribersTable&&this.$refs.subscribersTable.clearSelection(),this.selected_subscribers=[]},onThemeChanged(e){var t;this.current_mode=(null==(t=e.detail)?void 0:t.effective)||("system"===E.getCurrentTheme()?E.getSystemTheme():E.getCurrentTheme())}},mounted(){window.addEventListener(x,this.onThemeChanged),this.fetch()},beforeUnmount(){window.removeEventListener(x,this.onThemeChanged)}},[["render",function(t,s,c,o,d,S){const w=a,q=u("router-link"),k=u("badge"),C=i,T=u("Icons"),x=n,E=u("pagination-bar"),D=u("data-table"),P=u("Close"),j=l,B=e,A=u("confirm"),F=u("floating-bulk-action-shell"),I=r;return _(),b("div",O,[p(D,{"has-selection":!1},{"header-left":m(()=>[g("h3",L,f(t.$t("Sequence Subscribers")),1)]),table:m(()=>[y((_(),h(C,{ref:"subscribersTable",class:"fcrm_contacts_table","empty-text":t.$t("No Data Found"),onSelectionChange:S.handleSelectionChange,border:"",data:d.subscribers,style:{width:"100%"}},{default:m(()=>[p(w,{type:"selection",width:"40"}),p(w,{label:t.$t("Contact"),"min-width":"300"},{default:m(e=>[p(q,{class:"fcrm_contact_cell",to:{name:"subscriber",params:{id:e.row.subscriber_id}}},{default:m(()=>[g("img",{title:t.$t("Contact ID: %s",e.row.subscriber_id),class:"fcrm_contact_photo",src:e.row.subscriber.photo,alt:""},null,8,N),g("div",z,[g("div",J,f(e.row.subscriber.full_name),1),g("div",U,f(e.row.subscriber.email),1)])],void 0,!0),_:2},1032,["to"])]),_:1},8,["label"]),p(w,{label:t.$t("Status"),"min-width":"140"},{default:m(e=>[p(k,{type:e.row.status},null,8,["type"])]),_:1},8,["label"]),p(w,{label:t.$t("Started At"),"min-width":"220"},{default:m(e=>[g("div",Y,[g("span",{class:"fcrm_secondary_text",title:e.row.created_at},f(t.nsHumanDiffTime(e.row.created_at)),9,Z),e.row.notes&&e.row.notes.length?(_(),h(x,{key:0,width:"500",placement:"bottom",trigger:"click"},{reference:m(()=>[g("button",{type:"button",class:"fcrm_sequence_note_btn","aria-label":t.$t("View email schedule")},[p(T,{"icon-name":"info","icon-class":"fcrm_sequence_note_icon"})],8,G)]),default:m(()=>[p(C,{border:"",data:e.row.notes},{default:m(()=>[p(w,{label:t.$t("Email"),prop:"email"},null,8,["label"]),p(w,{width:160,label:t.$t("Date Time"),prop:"scheduled_at"},null,8,["label"])],void 0,!0),_:1},8,["data"])],void 0,!0),_:2},1024)):$("",!0)])]),_:1},8,["label"]),p(w,{label:t.$t("Next Email"),"min-width":"180"},{default:m(e=>["active"===e.row.status?(_(),b("span",{key:0,class:"fcrm_secondary_text",title:e.row.next_execution_time},f(t.nsHumanDiffTime(e.row.next_execution_time)),9,Q)):(_(),b("span",W,"--"))]),_:1},8,["label"])],void 0,!0),_:1},8,["empty-text","onSelectionChange","data"])),[[I,d.loading]])]),pagination:m(()=>[p(E,{pagination:d.pagination,hide_on_single:!1,"wrapper-class":["fcrm-contacts-pagination","fcrm-contacts-pagination-bar"],onFetch:S.fetch},null,8,["pagination","onFetch"])]),_:1}),p(F,{visible:!!d.selected_subscribers.length,"theme-mode":d.current_mode,"custom-layout":!0},{default:m(()=>[g("div",X,[g("div",K,[p(B,{link:"","aria-label":t.$t("Deselect"),onClick:S.clearSubscriberSelection},{default:m(()=>[p(j,null,{default:m(()=>[p(P)],void 0,!0),_:1})],void 0,!0),_:1},8,["aria-label","onClick"]),g("span",M,[g("strong",null,f(d.selected_subscribers.length),1),v(" "+f(t.$t("selected")),1)]),s[1]||(s[1]=g("div",{class:"fcrm_bulk_divider"},null,-1)),y((_(),h(A,{message:t.$t("SequenceSubscribers.DeleteInfo"),onYes:s[0]||(s[0]=e=>S.removeSubscribers())},{reference:m(()=>[p(B,{type:"danger",size:"small",plain:""},{default:m(()=>[g("span",ee,[p(T,{"icon-name":"delete"})]),v(" "+f(t.$t("Delete")),1)],void 0,!0),_:1})]),_:1},8,["message"])),[[I,d.removing]])])])],void 0),_:1},8,["visible","theme-mode"])])}]]),PageHeader:F},data:()=>({ArrowRightBold:q(d),loading:!1,sequence:{},reload_count:0,show_adder:!1}),methods:{fetchSequence(){this.loading=!0,this.$get(`sequences/${this.id}`).then(e=>{this.sequence=e.sequence}).catch(e=>{this.handleError(e)}).finally(()=>{this.loading=!1})},backToEmails(){this.$router.push({name:"edit-sequence",params:{id:this.id},query:{t:(new Date).getTime()}})},reloadSubscribers(){this.show_adder=!1,this.reload_count+=1}},mounted(){this.fetchSequence()}},[["render",function(t,s,i,a,n,l){const d=o,w=c,q=e,k=u("page-header"),C=u("subscribers-adder"),T=u("sequence-subscribers-view"),x=r;return y((_(),b("div",te,[g("div",se,[p(k,null,{breadcrumb:m(()=>[p(w,{"separator-icon":n.ArrowRightBold},{default:m(()=>[p(d,{to:{name:"email-sequences"}},{default:m(()=>[v(f(t.$t("Email Sequences")),1)],void 0,!0),_:1}),p(d,{to:{name:"edit-sequence",params:{id:i.id}}},{default:m(()=>[v(f(n.sequence.title),1)],void 0,!0),_:1},8,["to"]),p(d,null,{default:m(()=>[v(f(t.$t("Subscribers")),1)],void 0,!0),_:1})],void 0,!0),_:1},8,["separator-icon"])]),actions:m(()=>[p(q,{onClick:s[0]||(s[0]=e=>l.backToEmails())},{default:m(()=>[v(f(t.$t("View Emails")),1)],void 0,!0),_:1}),t.hasPermission("fcrm_manage_emails")?(_(),h(q,{key:0,onClick:s[1]||(s[1]=e=>n.show_adder=!n.show_adder),type:"primary","aria-pressed":n.show_adder},{default:m(()=>[n.show_adder?(_(),b(S,{key:1},[v(f(t.$t("Show Subscribers")),1)],64)):(_(),b(S,{key:0},[v(f(t.$t("Add Subscribers")),1)],64))],void 0,!0),_:1},8,["aria-pressed"])):$("",!0)]),_:1}),g("div",ie,[n.show_adder?(_(),h(C,{key:0,onCompleted:s[2]||(s[2]=e=>l.reloadSubscribers()),sequence_id:i.id},null,8,["sequence_id"])):(_(),b("div",ae,[p(T,{reload_count:n.reload_count,sequence_id:i.id},null,8,["reload_count","sequence_id"])]))])])])),[[x,n.loading]])}]]);export{ne as default};
|