PageSourceSearch

https://empodera.org/assets/MessagesPage-N-qrXQsi.js

js empodera.org collected 2026-10-02 12:31:56 UTC 8,465 bytes, 1 lines download raw bytes

1import{R as M,l as U,u as $,q as P,m as E,S as x,i as A,Q as I,_ as L,o,c as r,a as s,d as u,t as i,g as m,H as w,n as g,F as c,r as l,a1 as q,C as h,h as z,f as D,j as B,p as F,k as V}from"./index-4U7EqiWw.js";import{c as T,b as R}from"./api-u1-0_OlL.js";import{P as j}from"./Paginator-o2C10_9w.js";import{M as p,U as N,C as Q}from"./collection-59THP8US.js";import{v as H}from"./index-_sQivhel.js";import{c as O}from"./chats-LwdDHXK2.js";import"./initiative-L2FRwg-_.js";class X extends M{markMessageAsRead(e){return this.emptyRequest("custom/chat_room_messages/readed/"+e)}sendMessage(e){return this.createOne(p,"chat_room_messages",e,{groups:["Default"]})}getSuggestedUsers(){return this.fetchMany(N,"custom/users/suggested",{groups:["Default"]})}}const G=U({components:{Paginator:j},setup(){const t=$(),e=P.useLoading({zIndex:1e3}),n=E(),_=new X,f=new O;return{store:t,toast:n,api:T,loading:e,messageRepo:_,chatRepo:f}},data(){return{errors:{},baseURLCDN:R,chatRooms:null,currentChat:null,message:new p,chat:new Q,participants:[],newChatUsersFiltered:null,newChatUsersMaxLength:4,totalPages:1,page:1,totalItems:0}},created(){this.getChatRooms(),this.getSuggestedUsers(),this.store.currentChat&&(this.currentChat=this.store.currentChat,this.chatClicked(this.currentChat),this.store.currentChat={})},methods:{getChatRooms(){const t=this.loading.show();this.chatRepo.getChatRooms(this.page,9).then(e=>{this.chatRooms=e,this.totalItems=e.totalItems,this.totalPages=Math.ceil(this.totalItems/9),t.hide()}).catch(e=>this.errorRequest(e,t))},getUserPicture(t){let e=t.participants.find(n=>n.id!==this.store.user.id);return R+e.image.imageDir},getUsername(t){return t.participants.filter(e=>e.id!==this.store.user.id).map(e=>e.username.toString()).join(", ")},chatClicked(t){if(this.currentChat=t,this.currentChat&&this.currentChat.isUnreadMessages)for(let e of t.messages)e.createdBy.id!==this.store.user.id&&e.isUnread&&this.markMessageAsRead(e.id)},getSuggestedUsers(){const t=this.loading.show();this.messageRepo.getSuggestedUsers().then(e=>{this.newChatUsersFiltered=e,t.hide()}).catch(e=>this.errorRequest(e,t))},createChatRoom(){const t=this.loading.show();H(this.chat,{groups:["step1"]}).then(e=>{e.length>0?this.errors=x(e):this.chatRepo.create(this.chat).then(n=>{n&&(this.toast.success(A.global.t("chat.created")),this.chat.title="",this.chat.participants=[],this.getChatRooms(),t.hide())}).catch(n=>{this.toast.error(n)})})},sendMessage(){const t=this.loading.show();this.message.text&&this.currentChat&&(this.message.chatRoom=this.currentChat["@id"],this.messageRepo.sendMessage(this.message).then(e=>{var n;this.currentChat&&((n=this.currentChat.messages)==null||n.push(e)),this.getChatRooms(),this.message=new p,t.hide()}).catch(e=>{this.toast.error(e.message)}))},markMessageAsRead(t){const e=this.loading.show();this.messageRepo.markMessageAsRead(t).then(n=>{this.getChatRooms(),n.request&&this.store.counters.totalMessage&&this.store.counters.totalMessage--,e.hide()}).catch(n=>this.errorRequest(n,e))},errorRequest(t,e){if(t instanceof I)this.errors=t.getErrors(),e.hide();else throw t}},watch:{page(t,e){this.getChatRooms()}}}),J="/assets/group-0f9Q1aX0.png",b=t=>(F("data-v-8c6ec314"),t=t(),V(),t),K={class:"container py-5"},W={class:"row gy-4"},Y={class:"col-sm"},Z={class:"row flex-column g-4"},tt={class:"col"},et={class:"card"},st={class:"card-body"},at=b(()=>s("i",{class:"fa-regular fa-comment color-primary"},null,-1)),ot={class:"col"},rt=["placeholder"],it={class:"invalid-feedback"},nt={class:"fw-bold mb-2"},ct={class:"row"},lt={class:"dropdown"},dt={class:"invalid-feedback"},ht={style:{"max-height":"250px",overflow:"auto"}},ut={key:0,class:"form-check"},mt=["value","id"],gt=["for"],pt={class:"col-auto d-md-flex justify-content-md-center"},_t={class:"col"},ft={class:"card"},vt={class:"card-body"},Ct=b(()=>s("i",{class:"fa-regular fa-comments color-primary"},null,-1)),yt={key:0,class:"d-flex flex-column"},kt=["onClick"],wt={class:"card-body text-truncate"},Rt={key:0,class:"position-absolute top-1 start-100 translate-middle badge rounded-pill bg-danger"},bt=["src"],St={key:2,class:"img-fluid",src:J,style:{"max-width":"30px"},alt:"group-picture"},Mt={class:"ms-2",style:{"font-size":"12px"}},Ut={class:"ms-2"},$t={class:"ms-2",style:{"font-size":"12px"}},Pt={key:1,class:"text-center"},Et={class:"col-sm"},xt={key:0,class:"card"},At={class:"p-3",style:{"background-color":"#eeeeee"}},It={class:"p-3",style:{"background-color":"#eeeeee"}},Lt={class:"p-3 d-flex flex-column",style:{"max-height":"80vh",overflow:"auto"}},qt={class:"text-end",style:{"font-size":"12px"}},zt={class:"text-break"},Dt={class:"text-end",style:{"font-size":"12px"}},Bt={class:"p-3",style:{"background-color":"#eeeeee"}},Ft={class:"row"},Vt={class:"col"},Tt={class:"col-auto"},jt={type:"submit",class:"btn btn-primary",style:{"font-size":"14px"}};function Nt(t,e,n,_,f,Qt){var v,C,y,k;const S=B("Paginator");return o(),r("div",K,[s("div",W,[s("div",Y,[s("div",Z,[s("div",tt,[s("div",et,[s("div",st,[s("h3",null,[at,u(" "+i(t.$t("chat.new")),1)]),s("div",ot,[m(s("textarea",{"onUpdate:modelValue":e[0]||(e[0]=a=>t.chat.title=a),class:g(["form-control",{invalid:this.errors.title}]),name:"message",onClick:e[1]||(e[1]=a=>this.errors.title=""),rows:"1",placeholder:t.$t("chat.title"),required:""},null,10,rt),[[w,t.chat.title,void 0,{trim:!0}]])]),(o(!0),r(c,null,l(t.errors.title,a=>(o(),r("div",it,i(t.$t(a)),1))),256)),s("p",nt,i(t.$t("chat.select_users")),1),s("div",ct,[s("div",{class:"col",onClick:e[3]||(e[3]=a=>this.errors.participants="")},[s("div",lt,[(o(!0),r(c,null,l(t.errors.participants,a=>(o(),r("div",dt,i(t.$t(a)),1))),256)),s("ul",ht,[(o(!0),r(c,null,l((v=t.newChatUsersFiltered)==null?void 0:v.member,a=>(o(),r("li",{key:a.id,class:"dropdown-item"},[a.username!==t.store.user.username?(o(),r("div",ut,[m(s("input",{class:"form-check-input",type:"checkbox","onUpdate:modelValue":e[2]||(e[2]=d=>this.chat.participants=d),value:a["@id"],id:"newChatUser-"+a.id},null,8,mt),[[q,this.chat.participants]]),s("p",{class:"form-check-label w-100",for:"newChatUser-"+a.id},i(a.username),9,gt)])):h("",!0)]))),128))])])])]),s("div",pt,[s("button",{class:"btn btn-primary",style:{"font-size":"14px"},onClick:e[4]||(e[4]=(...a)=>t.createChatRoom&&t.createChatRoom(...a))},i(t.$t("chat.create")),1)])])])]),s("div",_t,[s("div",ft,[s("div",vt,[s("h3",null,[Ct,u(" "+i(t.$t("chat.chats")),1)]),((y=(C=t.chatRooms)==null?void 0:C.member)==null?void 0:y.length)>0?(o(),r("div",yt,[(o(!0),r(c,null,l((k=t.chatRooms)==null?void 0:k.member,(a,d)=>(o(),r("div",{class:g(["card chat-card mx-3 my-1",{selected:t.currentChat.id===a.id}]),key:d,onClick:Ht=>t.chatClicked(a)},[s("div",wt,[a.isUnreadMessages?(o(),r("span",Rt,i(a.totalUnreadMessages),1)):h("",!0),a.participants.length===2?(o(),r("img",{key:1,class:"img-fluid rounded-circle",src:t.getUserPicture
1(a),style:{"max-width":"30px"},alt:"user-picture"},null,8,bt)):(o(),r("img",St)),s("span",Mt,i(t.getUsername(a)),1),s("span",Ut,i(a.title),1),s("span",$t,i(a.createdAt.toLocaleDateString("sp-ES"))+" "+i(a.createdAt.toLocaleTimeString(["sp-ES"],{hour:"2-digit",minute:"2-digit"})),1)])],10,kt))),128))])):(o(),r("div",Pt,i(t.$t("no_content")),1)),this.totalPages?(o(),z(S,{key:2,total:this.totalPages,onChangePage:e[5]||(e[5]=a=>t.page=a)},null,8,["total"])):h("",!0)])])])])]),s("div",Et,[t.currentChat.id?(o(),r("div",xt,[s("h5",At,i(t.currentChat.title),1),s("h5",It,[u(" Participantes: "),(o(!0),r(c,null,l(t.currentChat.participants,(a,d)=>(o(),r("span",{key:d},i(a.slug)+" ",1))),128))]),s("div",Lt,[t.currentChat?(o(!0),r(c,{key:0},l(t.currentChat.messages,a=>(o(),r("div",{class:g(["p-3 mb-3",a.createdBy.id!==t.store.user.id?"message-partner me-3":"message-user align-self-end ms-3"])},[s("div",qt,i(a.createdBy.username),1),s("div",zt,i(a.text),1),s("div",Dt,i(a.createdAt.toLocaleDateString("sp-ES"))+" "+i(a.createdAt.toLocaleTimeString(["sp-ES"],{hour:"2-digit",minute:"2-digit"})),1)],2))),256)):h("",!0)]),s("div",Bt,[s("form",{onSubmit:e[7]||(e[7]=D((...a)=>t.sendMessage&&t.sendMessage(...a),["prevent"]))},[s("div",Ft,[s("div",Vt,[m(s("textarea",{"onUpdate:modelValue":e[6]||(e[6]=a=>t.message.text=a),class:"form-control",name:"message",rows:"1",placeholder:"* Mensaje"},null,512),[[w,t.message.text,void 0,{trim:!0}]])]),s("div",Tt,[s("button",jt,i(t.$t("chat.send")),1)])])],32)])])):h("",!0)])])])}const Zt=L(G,[["render",Nt],["__scopeId","data-v-8c6ec314"]]);export{Zt 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.