2 lines
17 KiB
JavaScript
2 lines
17 KiB
JavaScript
import{a3 as e,a6 as t,a4 as s,D as i,ay as o,k as n,e as a,az as l,aT as r}from"../../../../vendor-element-plus.js?ver=3.1.8";import{aQ as d,a6 as c,W as h,X as _,Z as p,aa as u,a0 as m,ab as f,a5 as g,b2 as v,Y as b,a8 as y,a9 as k,J as w,az as N,ax as x,ac as C}from"../../../../vendor.js?ver=3.1.8";import{P as $}from"../../../../PaginationBar.js?ver=3.1.8";import{C as S}from"../../../../Confirm.js?ver=3.1.8";import{F as V}from"../../../../_FormBuilder2.js?ver=3.1.8";import{_ as M,I as L}from"../../../../fc-bits-ui.js?ver=3.1.8";import{c as j}from"../../../../clipboard.js?ver=3.1.8";import{F as B}from"../../../../FloatingBulkActionShell.js?ver=3.1.8";import"../../../../PhotoWidget.js?ver=3.1.8";import"../../../../input-popover-dropdown.js?ver=3.1.8";import"../../../../data_config.js?ver=3.1.8";import"../../../../_OptionSelector.js?ver=3.1.8";import"../../../../_AjaxSelector.js?ver=3.1.8";import"../../../../_VerifiedEmailInput.js?ver=3.1.8";const H={class:"fcrm_notes_wrapper_inner fcrm_object_notes_template"},D={class:"fcrm_notes_header"},A={class:"fcrm_notes_header_title"},T={class:"fcrm_notes_header_actions"},z={class:"icon"},I={class:"icon"},Z={class:"icon"},E={class:"fcrm_notes_body"},U={class:"fcrm_notes_list"},F=["data-note-id"],P=["onClick"],Y={class:"fcrm_note_header_left"},q={class:"fcrm_note_avatar"},O=["src","alt"],K={key:1,class:"fcrm_note_avatar_initials"},Q={class:"fcrm_note_info"},W={class:"fcrm_note_title"},G={class:"fcrm_note_meta"},J={key:0},X={key:1},R=["title"],ee={class:"fcrm_note_header_right"},te=["innerHTML"],se={key:1,class:"fcrm_empty_state"},ie={class:"fcrm_empty_state_text"},oe={class:"fc_company_save_wrap"},ne={class:"fcrm_bulk_action_bar"},ae={class:"fcrm_bulk_action_left"},le={class:"icon"},re={class:"fc_bulk_selection_count"},de={key:0,class:"fcrm_bulk_divider"},ce={class:"icon"};const he={class:"fc_notes_wrapper fcrm_notes_wrapper"};const _e=M({name:"ProfileNotes",props:["subscriber_id"],components:{ObjectNotesTemplate:M({name:"ObjectNoteTemplate",props:["subscriber_id","route_prefix","section_title","target_note_id"],emits:["added","deleted","updated"],components:{PaginationBar:$,Confirm:S,FormBuilder:V,Search:i,Download:s,Delete:t,Edit:e,FloatingBulkActionShell:B,Icons:L},data:()=>({direction:"rtl",loading:!1,notes:[],types:window.fcAdmin.activity_types,pagination:{total:0,per_page:10,current_page:1},editing_note:{title:"",description:"",type:"note",created_at:""},is_editing_note:!1,search:"",updating:!1,is_changed:!1,note_syncing_fields:{},showSearchBar:!1,expandedNotes:{},targetedNoteId:null,bulkMode:!1,selectedNotes:[]}),watch:{"editing_note.type"(e,t){this.handleValueUpdate(e,t)},"editing_note.title"(e,t){this.handleValueUpdate(e,t)},"editing_note.description"(e,t){this.handleValueUpdate(e,t)},"editing_note.created_at"(e,t){this.handleValueUpdate(e,t)}},computed:{isSubscriberNotesContext(){return"subscribers"===this.route_prefix},allSelected(){return this.notes.length>0&&this.selectedNotes.length===this.notes.length},someSelected(){return this.selectedNotes.length>0&&this.selectedNotes.length<this.notes.length}},methods:{toggleNote(e){this.expandedNotes={...this.expandedNotes,[e]:!this.expandedNotes[e]}},toggleAllNotes(){const e=this.notes.every(e=>this.expandedNotes[e.id]),t={};this.notes.forEach(s=>{t[s.id]=!e}),this.expandedNotes=t},toggleBulkMode(){this.bulkMode=!this.bulkMode,this.bulkMode||(this.selectedNotes=[])},toggleNoteSelection(e){if(!this.isSubscriberNotesContext||!this.bulkMode)return;const t=this.selectedNotes.indexOf(e);-1===t?this.selectedNotes.push(e):this.selectedNotes.splice(t,1)},toggleAllSelection(){this.isSubscriberNotesContext&&this.bulkMode&&(this.allSelected?this.selectedNotes=[]:this.selectedNotes=this.notes.map(e=>e.id))},getInitials:e=>e&&e.display_name?e.display_name.split(" ").map(e=>e[0]).join("").toUpperCase().substring(0,2):"A",handleValueUpdate(e,t){e!==t&&(this.is_changed=!0)},handleClose(e){this.is_changed?this.$confirm(this.$t("You have unsaved data, proceed?")).then(t=>{this.is_changed=!1,this.is_editing_note=!1,this.resetNoteData(),e()}).catch(e=>{console.log(e)}):e()},fetch(){this.loading=!0;const e={per_page:this.pagination.per_page,page:this.pagination.current_page,search:this.search};this.target_note_id&&1===this.pagination.current_page&&!this.search&&(e.include_id=this.target_note_id),this.$get(`${this.route_prefix}/${this.subscriber_id}/notes`,e).then(e=>{if(this.notes=e.notes.data,this.selectedNotes=[],this.pagination.total=e.notes.total,this.note_syncing_fields=e.fields,this.resetNoteData(),this.is_editing_note=!1,e.included_note&&this.notes.unshift(e.included_note),this.target_note_id){const e=parseInt(this.target_note_id);this.notes.some(t=>t.id===e)&&(this.expandedNotes={...this.expandedNotes,[e]:!0},this.targetedNoteId=e,this.$nextTick(()=>{const t=this.$el.querySelector('[data-note-id="'+e+'"]');t&&t.scrollIntoView({behavior:"smooth",block:"center"}),setTimeout(()=>{this.targetedNoteId=null},3e3)}))}}).catch(e=>{this.handleError(e)}).finally(()=>{this.loading=!1})},bulkDelete(){this.selectedNotes.length&&this.$confirm(this.$t("Are you sure you want to delete the selected notes? This action cannot be undone."),this.$t("Delete Notes"),{confirmButtonText:this.$t("Yes, Delete"),cancelButtonText:this.$t("Cancel"),type:"warning"}).then(()=>{this.loading=!0,this.$post(`${this.route_prefix}/${this.subscriber_id}/notes/bulk-delete`,{note_ids:this.selectedNotes}).then(e=>{this.$notify.success({title:this.$t("Done!"),message:e.message,offset:19}),this.selectedNotes=[],this.bulkMode=!1,this.fetch(),this.$emit("deleted",null)}).catch(e=>{this.handleError(e)}).finally(()=>{this.loading=!1})}).catch(()=>{})},onSearchBarAppendClick(){this.showSearchBar?this.fetch():(this.showSearchBar=!0,this.$nextTick(()=>{var e;return null==(e=this.$refs.notesSearchInput)?void 0:e.focus()}))},initAddNote(){this.resetNoteData(),this.is_editing_note=!0},resetNoteData(){this.editing_note={title:"",description:"",type:"note",created_at:""}},saveNote(){this.$post(`${this.route_prefix}/${this.subscriber_id}/notes`,{note:this.editing_note}).then(e=>{this.$notify.success(e.message),this.fetch(),this.$emit("added",e.note),this.resetNoteData(),this.is_editing_note=!1}).catch(e=>{e.title&&this.$notify.error({title:this.$t("Error"),message:e.title.required}),e.description&&this.$notify.error({title:this.$t("Error"),message:e.description.required})}).finally(()=>{this.loading=!1})},remove(e){this.$del(`${this.route_prefix}/${this.subscriber_id}/notes/${e}`).then(t=>{this.fetch(),this.$notify.success({title:this.$t("Great!"),message:t.message,offset:19}),this.$emit("deleted",e)}).catch(e=>{this.handleError(e)})},editNote(e){this.editing_note=e,this.is_editing_note=!0},updateNote(){this.updating=!0,this.$put(`${this.route_prefix}/${this.subscriber_id}/notes/${this.editing_note.id}`,{note:this.editing_note}).then(e=>{this.$notify.success(e.message),this.is_editing_note=!1,this.resetNoteData(),this.$emit("updated",e.note)}).catch(e=>{this.handleError(e)}).finally(()=>{this.updating=!1})},copyNoteLink(e){const t=window.location.href.split("#")[0]+"#/"+this.route_prefix+"/"+this.subscriber_id+"/notes?note_id="+e;j(t)&&this.$notify.success(this.$t("Copied to clipboard"))},exportNotes(){if(!this.has_campaign_pro)return this.$notify.error(this.$t("Notes export feature is only available on pro version")),!1;location.href=window.ajaxurl+"?"+jQuery.param({action:"fluentcrm_export_notes",route_prefix:this.route_prefix,subscriber_id:this.subscriber_id})}},mounted(){window.fcAdmin&&window.fcAdmin.is_rtl&&(this.direction="ltr"),this.fetch()}},[["render",function(e,t,s,i,$,S){const V=d("Icons"),M=n,L=a,j=l,B=d("confirm"),he=d("pagination-bar"),_e=d("icons"),pe=d("form-builder"),ue=r,me=d("floating-bulk-action-shell"),fe=o;return c((h(),_("div",H,[p("div",D,[p("div",A,u(s.section_title),1),p("div",T,[p("div",{class:m(["fcrm_notes_search_bar",{"fcrm_notes_search_bar-is_expanded":$.showSearchBar}])},[f(L,{ref:"notesSearchInput",onKeyup:v(S.fetch,["enter"]),clearable:"",size:"small",onClear:t[0]||(t[0]=e=>S.fetch()),placeholder:e.$t("Search"),modelValue:$.search,"onUpdate:modelValue":t[1]||(t[1]=e=>$.search=e),class:m(["fcrm_notes_search_input",{"fcrm_notes_search_input-is_expanded":$.showSearchBar}])},{append:g(()=>[f(M,{class:"only-icon-btn small",size:"small",onClick:S.onSearchBarAppendClick},{default:g(()=>[p("span",z,[f(V,{"icon-name":"search"})])],void 0,!0),_:1},8,["onClick"])]),_:1},8,["onKeyup","placeholder","modelValue","class"])],2),$.notes.length?(h(),b(M,{key:0,size:"small",class:"small only-icon-btn",onClick:t[2]||(t[2]=e=>S.toggleAllNotes()),"aria-label":e.$t("Toggle all notes"),title:e.$t("Toggle all notes")},{default:g(()=>[...t[13]||(t[13]=[p("span",{class:"icon"},[p("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[p("path",{d:"M5 4L10 9L15 4M5 11L10 16L15 11",stroke:"var(--fc-secondary-text)","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"})])],-1)])],void 0),_:1},8,["aria-label","title"])):y("",!0),S.isSubscriberNotesContext&&$.notes.length?(h(),b(M,{key:1,size:"small",class:m(["small only-icon-btn",{"is-active":$.bulkMode}]),onClick:t[3]||(t[3]=e=>S.toggleBulkMode()),"aria-label":e.$t("Select notes"),title:e.$t("Select notes")},{default:g(()=>[...t[14]||(t[14]=[p("span",{class:"icon"},[p("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[p("rect",{x:"3",y:"3",width:"6",height:"6",rx:"1",stroke:"var(--fc-secondary-text)","stroke-width":"1.5"}),p("rect",{x:"11",y:"3",width:"6",height:"6",rx:"1",stroke:"var(--fc-secondary-text)","stroke-width":"1.5"}),p("rect",{x:"3",y:"11",width:"6",height:"6",rx:"1",stroke:"var(--fc-secondary-text)","stroke-width":"1.5"}),p("path",{d:"M11 14L13 16L17 12",stroke:"var(--fc-secondary-text)","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"})])],-1)])],void 0),_:1},8,["class","aria-label","title"])):y("",!0),f(M,{size:"small",class:"small only-icon-btn",onClick:t[4]||(t[4]=e=>S.exportNotes())},{default:g(()=>[p("span",I,[f(V,{"icon-name":"export"})])],void 0),_:1}),f(M,{size:"small",onClick:t[5]||(t[5]=e=>S.initAddNote()),type:"primary"},{default:g(()=>[p("span",Z,[f(V,{"icon-name":"plus"})]),k(" "+u(e.$t("Add Note")),1)],void 0),_:1})])]),p("div",E,[$.pagination.total?(h(),_(w,{key:0},[p("div",U,[(h(!0),_(w,null,N($.notes,s=>(h(),_("div",{key:s.id,class:m(["fcrm_note_row",{"is-expanded":$.expandedNotes[s.id],"is-targeted":$.targetedNoteId===s.id}]),"data-note-id":s.id},[p("div",{class:"fcrm_note_header",onClick:e=>$.bulkMode?S.toggleNoteSelection(s.id):S.toggleNote(s.id)},[p("div",Y,[S.isSubscriberNotesContext&&$.bulkMode?(h(),b(j,{key:0,"model-value":$.selectedNotes.includes(s.id),onClick:x(e=>S.toggleNoteSelection(s.id),["stop"]),class:"fcrm_note_select_checkbox"},null,8,["model-value","onClick"])):y("",!0),t[16]||(t[16]=p("svg",{class:"fcrm_note_chevron",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[p("path",{d:"M10.4001 8L5.6001 12V4L10.4001 8Z",fill:"var(--fc-secondary-text)"})],-1)),p("div",q,[s.added_by&&s.added_by.photo?(h(),_("img",{key:0,src:s.added_by.photo,alt:s.added_by.display_name},null,8,O)):(h(),_("span",K,u(S.getInitials(s.added_by)),1))]),p("div",Q,[p("div",W,u(s.title||$.types[s.type]||s.type),1),p("div",G,[s.added_by&&s.added_by.display_name?(h(),_("span",J,u(s.added_by.display_name),1)):(h(),_("span",X,"Admin")),t[15]||(t[15]=p("span",{class:"fcrm_note_meta_dot"},"·",-1)),p("span",{title:s.created_at},u(e.nsHumanDiffTime(s.created_at)),9,R)])])]),p("div",ee,[e.hasPermission("fcrm_manage_contacts")?(h(),_("div",{key:0,class:"fcrm_note_actions",onClick:t[6]||(t[6]=x(()=>{},["stop"]))},[f(M,{onClick:e=>S.copyNoteLink(s.id),title:e.$t("Copy")},{default:g(()=>[...t[17]||(t[17]=[p("span",{class:"icon"},[p("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[p("path",{fill:"var(--fc-secondary-text)",d:"M5.993,12.781 C4.748,10.564 5.068,7.706 6.954,5.82 L9.82,2.954 C12.092,0.682 15.775,0.682 18.046,2.954 C20.318,5.225 20.318,8.908 18.046,11.18 L18.007,11.219 C19.252,13.436 18.932,16.294 17.046,18.18 L14.18,21.046 C11.908,23.318 8.225,23.318 5.954,21.046 C3.682,18.775 3.682,15.092 5.954,12.82 Z M10.881,4.014 L8.014,6.881 C6.329,8.566 6.329,11.3 8.014,12.986 C9.7,14.672 12.434,14.672 14.119,12.986 L14.326,12.779 L15.387,13.839 L15.18,14.046 C12.908,16.318 9.225,16.318 6.954,14.046 C6.937,14.029 6.92,14.012 6.904,13.995 C5.329,15.689 5.366,18.338 7.014,19.986 C8.7,21.671 11.434,21.671 13.119,19.986 L15.986,17.119 C17.671,15.434 17.671,12.7 15.986,11.014 C14.3,9.329 11.566,9.329 9.881,11.014 L9.674,11.221 L8.613,10.161 L8.82,9.954 C11.092,7.682 14.775,7.682 17.046,9.954 C17.063,9.971 17.08,9.987 17.096,10.005 C18.671,8.312 18.634,5.662 16.986,4.014 C15.3,2.329 12.566,2.329 10.881,4.014 Z"})])],-1)])],void 0),_:1},8,["onClick","title"]),f(M,{onClick:e=>S.editNote(s)},{default:g(()=>[...t[18]||(t[18]=[p("span",{class:"icon"},[p("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[p("path",{d:"M5.8105 13.0001L13.417 5.39356L12.3565 4.33306L4.75 11.9396V13.0001H5.8105ZM6.43225 14.5001H3.25V11.3178L11.8263 2.74156C11.9669 2.60096 12.1576 2.52197 12.3565 2.52197C12.5554 2.52197 12.7461 2.60096 12.8868 2.74156L15.0085 4.86331C15.1491 5.00396 15.2281 5.19469 15.2281 5.39356C15.2281 5.59244 15.1491 5.78317 15.0085 5.92381L6.43225 14.5001ZM3.25 16.0001H16.75V17.5001H3.25V16.0001Z",fill:"var(--fc-secondary-text)"})])],-1)])],void 0),_:1},8,["onClick"]),f(B,{onYes:e=>S.remove(s.id)},{default:g(()=>[f(M,null,{default:g(()=>[...t[19]||(t[19]=[p("span",{class:"icon"},[p("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[p("path",{d:"M13.75 5.5H17.5V7H16V16.75C16 16.9489 15.921 17.1397 15.7803 17.2803C15.6397 17.421 15.4489 17.5 15.25 17.5H4.75C4.55109 17.5 4.36032 17.421 4.21967 17.2803C4.07902 17.1397 4 16.9489 4 16.75V7H2.5V5.5H6.25V3.25C6.25 3.05109 6.32902 2.86032 6.46967 2.71967C6.61032 2.57902 6.80109 2.5 7 2.5H13C13.1989 2.5 13.3897 2.57902 13.5303 2.71967C13.671 2.86032 13.75 3.05109 13.75 3.25V5.5ZM14.5 7H5.5V16H14.5V7ZM7.75 9.25H9.25V13.75H7.75V9.25ZM10.75 9.25H12.25V13.75H10.75V9.25ZM7.75 4V5.5H12.25V4H7.75Z",fill:"var(--fc-secondary-text)"})])],-1)])],void 0,!0),_:1})],void 0),_:1},8,["onYes"])])):y("",!0)])],8,P),c(p("div",{class:"fcrm_note_description",innerHTML:s.description},null,8,te),[[C,$.expandedNotes[s.id]]])],10,F))),128))]),f(he,{pagination:$.pagination,onFetch:S.fetch},null,8,["pagination","onFetch"])],64)):(h(),_("div",se,[f(_e,{"icon-name":"common-empty-state"}),p("div",ie,[p("span",null,u(e.$t("Pro_No_NfPatfn")),1)])]))]),f(ue,{direction:$.direction,class:"fc_company_info_drawer","with-header":!0,size:e.globalDrawerSize,title:$.is_editing_note&&$.editing_note.id?e.$t("Edit Note"):e.$t("Create a note"),"append-to-body":!0,"before-close":S.handleClose,"modal-class":"fcrm_drawer fcrm_note_drawer",modelValue:$.is_editing_note,"onUpdate:modelValue":t[9]||(t[9]=e=>$.is_editing_note=e)},{default:g(()=>[$.is_editing_note?(h(),_("div",{key:0,class:m(["fc_note_type_"+$.editing_note.type,"fc_company_unsaved fc_company_info_wrapper"])},[f(pe,{formData:$.editing_note,fields:$.note_syncing_fields.fields},null,8,["formData","fields"]),p("div",oe,[$.editing_note.id?(h(),b(M,{key:0,onClick:t[7]||(t[7]=e=>S.updateNote()),size:"small",type:"primary"},{default:g(()=>[k(u(e.$t("Update Note")),1)],void 0,!0),_:1})):(h(),b(M,{key:1,onClick:t[8]||(t[8]=e=>S.saveNote()),size:"small",type:"primary"},{default:g(()=>[k(u(e.$t("Create")),1)],void 0,!0),_:1}))])],2)):y("",!0)],void 0),_:1},8,["direction","size","title","before-close","modelValue"]),f(me,{visible:S.isSubscriberNotesContext&&$.bulkMode,"custom-layout":!0},{default:g(()=>[p("div",ne,[p("div",ae,[f(M,{link:"","aria-label":e.$t("Deselect"),onClick:t[10]||(t[10]=e=>S.toggleBulkMode())},{default:g(()=>[p("span",le,[f(V,{"icon-name":"close"})])],void 0,!0),_:1},8,["aria-label"]),p("span",re,[p("strong",null,u($.selectedNotes.length),1),k(" "+u(e.$t("selected")),1)]),t[20]||(t[20]=p("div",{class:"fcrm_bulk_divider"},null,-1)),f(j,{"model-value":S.allSelected,indeterminate:S.someSelected,onChange:t[11]||(t[11]=e=>S.toggleAllSelection())},{default:g(()=>[k(u(e.$t("Select all")),1)],void 0,!0),_:1},8,["model-value","indeterminate"]),$.selectedNotes.length?(h(),_("div",de)):y("",!0),$.selectedNotes.length?(h(),b(M,{key:1,size:"small",type:"danger",plain:"",onClick:t[12]||(t[12]=e=>S.bulkDelete())},{default:g(()=>[p("span",ce,[f(V,{"icon-name":"delete"})]),k(" "+u(e.$t("Delete selected")),1)],void 0,!0),_:1})):y("",!0)])])],void 0),_:1},8,["visible"])])),[[fe,$.loading]])}]])},mounted(){this.changeTitle(this.$t("Notes"))}},[["render",function(e,t,s,i,o,n){const a=d("object-notes-template");return h(),_("div",he,[f(a,{subscriber_id:s.subscriber_id,route_prefix:"subscribers",section_title:e.$t("Contact Notes & Activities"),target_note_id:e.$route.query.note_id},null,8,["subscriber_id","section_title","target_note_id"])])}]]);export{_e as default};
|