PageSourceSearch

https://app.causalytics.ai/src/assets/MessageTemplatesSettings-zd4PWU9W.js

js causalytics.ai collected 2026-10-05 12:56:05 UTC 8,981 bytes, 1 lines download raw bytes

1import{g as E}from"./templateSubstitution-CWrL08qq.js";import{_ as S,c as u,o as m,f as o,a,b,t as i,w as s,h as n,l as h,k as g,G as v,H as T,d as z,aD as A,at as P,q as y,O as $,j as C,x as w,K as I,aq as N,N as V,v as _,y as D}from"./index-Ds9SPvAZ.js";import{V as B}from"./VTextarea-CjQAIrLY.js";const F={name:"MessageTemplatesSettings",data:()=>({loading:!1,saving:!1,dialog:!1,deleteDialog:!1,editingTemplate:null,deletingTemplate:null,templates:[],form:{name:"",body:""},formErrors:{name:"",body:""},placeholders:E()}),mounted(){this.loadTemplates()},methods:{loadTemplates(){var t;this.loading=!0;const e=((t=this.$team)==null?void 0:t.settings)||{};this.templates=e.messageTemplates||[],this.loading=!1},openCreateDialog(){this.editingTemplate=null,this.form={name:"",body:""},this.formErrors={name:"",body:""},this.dialog=!0},openEditDialog(e){this.editingTemplate=e,this.form={name:e.name,body:e.body},this.formErrors={name:"",body:""},this.dialog=!0},closeDialog(){this.dialog=!1,this.editingTemplate=null,this.form={name:"",body:""},this.formErrors={name:"",body:""}},insertPlaceholder(e){var f,c;const t=`{{${e}}}`,d=(c=(f=this.$refs.bodyTextarea)==null?void 0:f.$el)==null?void 0:c.querySelector("textarea");if(d){const r=d.selectionStart||0,l=d.selectionEnd||0,p=this.form.body||"";this.form.body=p.substring(0,r)+t+p.substring(l),this.$nextTick(()=>{const k=r+t.length;d.focus(),d.setSelectionRange(k,k)})}else this.form.body=(this.form.body||"")+t},validateForm(){this.formErrors={name:"",body:""};let e=!0;return this.form.name.trim()||(this.formErrors.name=this.$t("Template name is required"),e=!1),this.form.body.trim()||(this.formErrors.body=this.$t("Message body is required"),e=!1),e},async saveTemplate(){if(this.validateForm()){this.saving=!0;try{let e;if(this.editingTemplate)e=this.templates.map(d=>d.id===this.editingTemplate.id?{...d,name:this.form.name.trim(),body:this.form.body.trim(),updatedAt:new Date().toISOString()}:d);else{const d={id:this.generateId(),name:this.form.name.trim(),body:this.form.body.trim(),createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};e=[...this.templates,d]}await this.persistTemplates(e),this.templates=e;const t=!!this.editingTemplate;this.closeDialog(),this.$toast({type:"success",message:t?this.$t("Template updated"):this.$t("Template created")})}catch(e){console.error("Error saving template:",e),this.$toast({type:"error",message:this.$t("Failed to save template")})}finally{this.saving=!1}}},confirmDelete(e){this.deletingTemplate=e,this.deleteDialog=!0},async deleteTemplate(){if(this.deletingTemplate){this.saving=!0;try{const e=this.templates.filter(t=>t.id!==this.deletingTemplate.id);await this.persistTemplates(e),this.templates=e,this.deleteDialog=!1,this.deletingTemplate=null,this.$toast({type:"success",message:this.$t("Template deleted")})}catch(e){console.error("Error deleting template:",e),this.$toast({type:"error",message:this.$t("Failed to delete template")})}finally{this.saving=!1}}},async persistTemplates(e){const[t]=await this.$api.find("teams",{query:{id:this.$team.id,$select:["settings"]}}),f={...(t==null?void 0:t.settings)||{},messageTemplates:e},c=await this.$api.patch("teams",this.$team.id,{settings:f});this.$store.commit("STORE_MAP_UPDATE",{key:"teams",entity:c})},truncateBody(e){return e?e.length>150?e.substring(0,150)+"...":e:""},formatPlaceholder(e){return`{{${e}}}`},generateId(){return Date.now().toString(36)+Math.random().toString(36).substring(2,9)}}},U={class:"message-templates-settings"},q={class:"d-flex align-center justify-space-between mb-4"},M={class:"text-body-2 text-grey-darken-1"},O={class:"text-body-2"},j={key:0},x={key:0,class:"text-center py-8"},R={class:"text-body-1 text-grey-darken-1"},G={key:2,class:"templates-list"},H={class:"d-flex align-start justify-space-between"},K={class:"flex-grow-1 mr-4"},L={class:"text-subtitle-1 font-weight-medium mb-1"},W={class:"text-body-2 text-grey-darken-1 template-preview"},J={class:"d-flex ga-1"},Q={class:"text-h6 font-weight-bold"},X={class:"font-weight-bold mb-1"},Y={class:"font-weight-bold mb-1"},Z={class:"text-caption text-grey-darken-1 mb-2"},ee={class:"d-flex flex-wrap ga-1"},te={class:"ml-1 text-grey-darken-1"};function ae(e,t,d,f,c,r){return m(),u("div",U,[o("div",q,[o("p",M,i(e.$t("Create reusable templates for outreach messages. Use placeholders to personalize each message.")),1),a(g,{variant:"flat",class:"ca-primary-btn",onClick:r.openCreateDialog},{default:s(()=>[a(h,{start:""},{default:s(()=>t[5]||(t[5]=[n(" mdi-plus ")])),_:1,__:[5]}),n(" "+i(e.$t("New template")),1)]),_:1},8,["onClick"])]),a(A,{type:"info",variant:"tonal",density:"compact",class:"mb-4"},{default:s(()=>[o("div",O,[o("strong",null,i(e.$t("Available placeholders:")),1),(m(!0),u(v,null,T(e.placeholders,(l,p)=>(m(),u("span",{key:l.key},[o("code",null,i(r.formatPlaceholder(l.key)),1),n(" ("+i(l.label)+")",1),p<e.placeholders.length-1?(m(),u("span",j,", ")):z("",!0)]))),128))])]),_:1}),e.loading?(m(),u("div",x,[a(P,{indeterminate:""})])):e.templates.length===0?(m(),b(y,{key:1,variant:"outlined",rounded:"lg",class:"pa-8 text-center"},{default:s(()=>[a(h,{size:"48",color:"grey-lighten-1",class:"mb-3"},{default:s(()=>t[6]||(t[6]=[n(" mdi-file-document-edit-outline ")])),_:1,__:[6]}),o("p",R,i(e.$t("No templates yet. Create your first message template to speed up outreach.")),1)]),_:1})):(m(),u("div",G,[(m(!0),u(v,null,T(e.templates,l=>(m(),b(y,{key:l.id,variant:"outlined",rounded:"lg",class:"mb-3 pa-4"},{default:s(()=>[o("div",H,[o("div",K,[o("div",L,i(l.name),1),o("div",W,i(r.truncateBody(l.body)),1)]),o("div",J,[a(g,{icon:"",variant:"text",size:"small",title:e.$t("Edit"),onClick:p=>r.openEditDialog(l)},{default:s(()=>[a(h,{size:"18"},{default:s(()=>t[7]||(t[7]=[n(" mdi-pencil ")])),_:1,__:[7]})]),_:2},1032,["title","onClick"]),a(g,{icon:"",variant:"text",size:"small",color:"error",title:e.$t("Delete"),onClick:p=>r.confirmDelete(l)},{default:s(()=>[a(h,{size:"18"},{default:s(()=>t[8]||(t[8]=[n(" mdi-delete ")])),_:1,__:[8]})]),_:2},1032,["title","onClick"])])])]),_:2},1024))),128))])),a(D,{modelValue:e.dialog,"onUpdate:modelValue":t[2]||(t[2]=l=>e.dialog=l),"max-width":"700",persistent:""},{default:s(()=>[a(y,{rounded:"lg"},{default:s(()=>[a($,{class:"d-flex align-center justify-space-between pa-5 pb-2"},{default:s(()=>[o("span",Q,i(e.editingTemplate?e.$t("Edit Template"):e.$t("New Template")),1),a(g,{icon:"",variant:"text",size:"small",onClick:r.closeDialog},{default:s(()=>[a(h,{size:"20"},{default:s(()=>t[9]||(t[9]=[n(" mdi-close ")])),_:1,__:[9]})]),_:1},8,["onClick"])]),_:1}),a(C),a(w,{class:"pa-5",style:{"font-size":"14px"}},{default:s(()=>[o("p",X,i(e.$t("Template name")),1),a(I,{modelValue:e.form.name,"onUpdate:modelValue":t[0]||(t[0]=l=>e.form.name=l),class:"mb-5 rounded border-sm",flat:"",density:"compact",variant:"solo","hide-details":"auto",placeholder:e.$t("E.g. Cold outreach, Follow-up, Re-engage..."),"error-messages":e.formErrors.name},null,8,["modelValue","placeholder","error-messages"]),o("p",Y,i(e.$t("Message body")),1),a(B,{ref:"bodyTextarea",modelValue:e.form.body,"onUpdate:modelValue":t[1]||(t[1]=l=>e.form.body=l),class:"mb-3 rounded border-sm",flat:"",density:"compact",variant:"solo",rows:"10","auto-grow":"","hide-details":"auto",placeholder:e.$t("Write your message template here. Use {{first_name}}, {{company}}, etc. for personalization."),"error-messages":e.formErrors.body},null,8,["modelValue","placeholder","error-messages"]),o("p",Z,i(e.$t("Insert placeholder at cursor:")),1),o("div",ee,[(m(!0),u(v,null,T(e.placeholders,l=>(m(),b(N,{key:l.key,size:"small",variant:"tonal",color:"primary",class:"cursor-pointer",onClick:p=>r.insertPlaceholder(l.key)},{default:s(()=>[n(i(r.formatPlaceholder(l.key))+" ",1),o("span",te,"("+i(l.label)+")",1)]),_:2},1032,["onClick"]))),128))])]),_:1}),a(C),a(V,{class:"pa-4"},{default:s(()=>[a(_),a(g,{variant:"text",onClick:r.closeDialog},{default:s(()=>[n(i(e.$t("Cancel")),1)]),_:1},8,["onClick"]),a(g,{variant:"flat",class:"ca-primary-btn",loading:e.s
1aving,disabled:e.saving,onClick:r.saveTemplate},{default:s(()=>[n(i(e.$t("Save")),1)]),_:1},8,["loading","disabled","onClick"])]),_:1})]),_:1})]),_:1},8,["modelValue"]),a(D,{modelValue:e.deleteDialog,"onUpdate:modelValue":t[4]||(t[4]=l=>e.deleteDialog=l),"max-width":"400"},{default:s(()=>[a(y,null,{default:s(()=>[a($,{class:"text-h6"},{default:s(()=>[n(i(e.$t("Delete Template")),1)]),_:1}),a(w,null,{default:s(()=>[n(i(e.$t("Are you sure you want to delete this template? This action cannot be undone.")),1)]),_:1}),a(V,null,{default:s(()=>[a(_),a(g,{variant:"text",onClick:t[3]||(t[3]=l=>e.deleteDialog=!1)},{default:s(()=>[n(i(e.$t("Cancel")),1)]),_:1}),a(g,{variant:"flat",color:"error",loading:e.saving,onClick:r.deleteTemplate},{default:s(()=>[n(i(e.$t("Delete")),1)]),_:1},8,["loading","onClick"])]),_:1})]),_:1})]),_:1},8,["modelValue"])])}const oe=S(F,[["render",ae],["__scopeId","data-v-28071a46"]]);export{oe as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.