1import{M as A}from"./MessageBoardPost-f203d5f4.js";import{_ as P}from"./lodash-b5ace6a0.js";import{_ as z,b as v,r as d,o as r,c as f,a,t as m,g as c,f as i,w as u,h,e as b,n as B,d as w,F as O,l as I,u as T,v as N}from"./app-346e2910.js";import{m as V}from"./index-42957e6c.js";import"./moment-e9e012b5.js";const j={props:["filterOptions","dateOptions","defaultDate"],inject:["user","managedWorkshop"],data(){return{showSelectedPostModal:!1,filterBy:"",newFilterBy:"",filterDate:"",newFilterDate:"",order:"desc",orderBy:"created_at",search:"",action:"",selectedPosts:[],selectedPost:{},isBusy:!1,pagination:null}},components:{MessageBoardPost:A},watch:{order(){this.fetchPosts()},orderBy(){this.fetchPosts()}},created(){if(this.defaultDate&&(this.filterDate=this.defaultDate),this.user&&this.user.dashboard_settings){const e=JSON.parse(this.user.dashboard_settings);e.message_board_inbox&&Object.entries(e.message_board_inbox).forEach(([t,n])=>{n&&(this[t]=n)})}this.filterBy||(this.filterBy=this.filterByList[0].value),this.action||(this.action=this.actionList[0].value),this.fetchPosts(),this.emitter.on("update_mb_posts",P.debounce(this.fetchPosts,200))},computed:{filterByList(){return P.map(JSON.parse(this.filterOptions),(e,t)=>({label:e,value:t}))},dateFiltersList(){return P.map(JSON.parse(this.dateOptions),(e,t)=>({value:t,label:e}))},hasPagination(){return this.pagination},unreadPosts(){return!this.pagination||!this.pagination.data||!Array.isArray(this.pagination.data)?[]:this.pagination.data.filter(e=>e.unread)},newFilterByList(){return[{label:"Unread",value:"unread"},{label:"Read",value:"read"},{label:"Unread / Read",value:""},{label:"Flagged",value:"flagged"},{label:"Deleted",value:"deleted"}]},actionList(){return[{label:"Select...",value:""},{label:"Mark as Read",value:"read"},{label:"Mark as Unread",value:"unread"},{label:"Flag",value:"flag"},{label:"Unflag",value:"unflag"},{label:"Delete",value:"delete"}]},isAllSelected(){return!this.pagination||!this.pagination.data?!1:this.selectedPosts.length===this.pagination.data.length}},methods:{getTitle(e){return e?e.message_board_type=="Lesson"?e.module_order&&e.lesson_module_order?`Lesson ${e.module_order}-${e.lesson_module_order}`:e.module_order?`Lesson ${e.module_order}-${e.lesson_order}`:`Lesson ${e.lesson_order}`:e.message_board_type:""},formatDate(e){const t=V(e),n=V();return n.diff(t,"minutes")<1?"just now":n.diff(t,"hours")<1?n.diff(t,"minutes")+"m ago":n.diff(t,"days")<1?n.diff(t,"hours")+"h ago":n.diff(t,"weeks")<1?n.diff(t,"days")+"d ago":t.format("MM/DD/YY")},updatePost(e){if(!this.pagination||!this.pagination.data)return;const t=this.pagination.data.findIndex(n=>n.id==e.id);t>-1&&(this.pagination.data[t].unread=e.unread,this.pagination.data[t].flagged=e.flagged)},postModalShown(){this.$refs.messageBoardPost.focusReply()},triggerFetchPosts(){this.fetchPosts()},async fetchPosts(e){let t="/api/message-boards/search-posts";typeof e>"u"?e=1:e=="reload"&&(e=this.pagination.current_page),e>1&&(t+="?page="+e),this.isBusy=!0;const n={workshopId:this.managedWorkshop.id,filterBy:this.filterBy,newFilterBy:this.newFilterBy,filterDate:this.filterDate,order:this.order,orderBy:this.orderBy,search:this.search};try{const{data:p}=await v.post(t,n);this.pagination={...p}}catch(p){console.log("err",p)}this.isBusy=!1},updateOrder(e){this.orderBy==e?this.order=this.order=="desc"?"asc":"desc":this.orderBy=e},onSelectAll(e){this.isAllSelected?this.selectedPosts=[]:this.selectedPosts=this.pagination.data.map(t=>t.id)},async onSelectPost(e){this.selectedPost=e,await this.$nextTick(),this.showSelectedPostModal=!0},async onApplyAction(){if(this.action=="delete"){if(window.confirm("Are you sure you'd like to delete the selected message board posts?")){this.isBusy=!0;const t={bulk_action:this.action,bulk_items:this.selectedPosts};await v.post("/api/message-boards/bulk-action",t),await this.fetchPosts(),this.isBusy=!1}}else{this.isBusy=!0;const e={bulk_action:this.action,bulk_items:this.selectedPosts};await v.post("/api/message-boards/bulk-action",e),await this.fetchPosts(),this.isBusy=!1,this.selectedPosts=[]}}},mounted(){}},C=e=>(T("data-v-914e0be2"),e=e(),N(),e),H={class:"bg-white rounded shadow card-overview mb-4"},R={class:"p-4 pt-3"},J={key:0,class:"font-bold mb-2"},E={class:"grid gap-4 md:grid-cols-12"},W={class:"md:col-span-4 lg:col-span-3"},Y={class:"md:col-span-4 lg:col-span-2"},q={class:"md:col-span-4 lg:col-span-2"},G={class:"md:col-span-6 lg:col-span-3"},K={class:"flex gap-1"},Q={class:"md:col-span-6 lg:col-span-2"},X={class:"flex gap-1"},Z={class:"t-border-default rounded bg-white mb-4 relative overflow-x-auto"},$={key:0,class:"absolute start-0 top-0 w-full h-full z-10 bg-white/50 flex justify-center items-center"},ee={class:"t-table text-sm min-w-full"},te={class:"border-b-2 border-dark-100 text-left"},se={style:{"vertical-align":"middle"},class:""},oe=C(()=>a("th",null,"User",-1)),ae=C(()=>a("th",null,"Message",-1)),le={class:"whitespace-nowrap"},ie={class:"whitespace-nowrap"},ne=["onClick"],re=["innerHTML"],de={key:0,class:"mb-3"},ce=["innerHTML"];function ue(e,t,n,p,s,o){const _=d("t-label"),y=d("t-select"),M=d("t-input"),g=d("font-awesome-icon"),k=d("t-button"),F=d("loading"),x=d("t-checkbox"),L=d("pagination"),D=d("message-board-post"),U=d("Modal");return r(),f("div",null,[a("div",H,[a("div",R,[o.unreadPosts.length?(r(),f("p",J,m(o.unreadPosts.length>=50?"50+":o.unreadPosts.length)+" "+m(o.unreadPosts.length==1?"Unread Post":"Unread Posts"),1)):c("",!0),a("div",E,[a("div",W,[i(_,{for:"filter-select"},{default:u(()=>[h("Select Section")]),_:1}),i(y,{size:"sm",modelValue:s.filterBy,"onUpdate:modelValue":t[0]||(t[0]=l=>s.filterBy=l),onChange:o.fetchPosts,options:o.filterByList},null,8,["modelValue","onChange","options"])]),a("div",Y,[i(_,{for:"filter-select"},{default:u(()=>
1[h("Filter By")]),_:1}),i(y,{size:"sm",modelValue:s.newFilterBy,"onUpdate:modelValue":t[1]||(t[1]=l=>s.newFilterBy=l),onChange:o.fetchPosts,options:o.newFilterByList},null,8,["modelValue","onChange","options"])]),a("div",q,[i(_,{for:"filter-select"},{default:u(()=>[h("Date")]),_:1}),i(y,{onChange:o.triggerFetchPosts,size:"sm",modelValue:s.filterDate,"onUpdate:modelValue":t[2]||(t[2]=l=>s.filterDate=l),options:o.dateFiltersList},null,8,["onChange","modelValue","options"])]),a("div",G,[i(_,{for:"search-input"},{default:u(()=>[h("Search")]),_:1}),a("div",K,[i(M,{lazy:!0,size:"sm",modelValue:s.search,"onUpdate:modelValue":t[3]||(t[3]=l=>s.search=l),onChange:o.triggerFetchPosts,placeholder:"Search..."},null,8,["modelValue","onChange"]),i(k,{size:"sm",onClick:b(o.fetchPosts,["prevent"]),variant:"primary"},{default:u(()=>[i(g,{icon:"fa-solid fa-magnifying-glass"})]),_:1},8,["onClick"])])]),a("div",Q,[i(_,{for:"bulk-action-select"},{default:u(()=>[h("Bulk Action")]),_:1}),a("div",X,[i(y,{modelValue:s.action,"onUpdate:modelValue":t[4]||(t[4]=l=>s.action=l),size:"sm",options:o.actionList},null,8,["modelValue","options"]),i(k,{variant:"primary",size:"sm",onClick:o.onApplyAction},{default:u(()=>[i(g,{icon:"fa-solid fa-arrow-right"})]),_:1},8,["onClick"])])])])])]),a("div",Z,[s.isBusy?(r(),f("div",$,[i(F,{class:"dark"})])):c("",!0),a("div",null,[a("table",ee,[a("thead",te,[a("tr",null,[a("th",se,[i(x,{size:"sm",onChange:o.onSelectAll,checked:o.isAllSelected},null,8,["onChange","checked"])]),oe,ae,a("th",le,[a("a",{class:B({"text-primary-500":s.orderBy=="created_at"}),href:"#",onClick:t[5]||(t[5]=b(l=>o.updateOrder("created_at"),["prevent"]))},[h(" Posted "),s.orderBy=="created_at"?(r(),w(g,{key:0,icon:`fa-solid fa-${s.order=="desc"?"caret-down":"caret-up"}`},null,8,["icon"])):c("",!0)],2)]),a("th",ie,[a("a",{class:B({"text-primary-500":s.orderBy=="board"}),href:"#",onClick:t[6]||(t[6]=b(l=>o.updateOrder("board"),["prevent"]))},[h(" Board "),s.orderBy=="board"?(r(),w(g,{key:0,icon:`fa-solid fa-${s.order=="desc"?"caret-down":"caret-up"}`},null,8,["icon"])):c("",!0)],2)])])]),a("tbody",null,[s.pagination&&s.pagination.data?(r(!0),f(O,{key:0},I(s.pagination.data,l=>(r(),f("tr",{key:l.id,class:B(["cursor-pointer hover:bg-dark-50 transition-colors",[l.flagged?"bg-warning-100":"",l.unread?"font-bold":""]]),onClick:S=>o.onSelectPost(l)},[a("td",{style:{"vertical-align":"middle"},class:"",onClick:b(()=>!0,["stop"])},[i(x,{modelValue:s.selectedPosts,"onUpdate:modelValue":t[7]||(t[7]=S=>s.selectedPosts=S),size:"sm",value:l.id},null,8,["modelValue","value"])]),a("td",null,m(l.full_name),1),a("td",null,[l.flagged?(r(),w(g,{key:0,icon:"fa-solid fa-flag",class:"text-warning-500 me-1"})):c("",!0),h(" "+m(l.short_message),1)]),a("td",null,m(o.formatDate(l.created_at)),1),a("td",{class:"whitespace-nowrap",innerHTML:o.getTitle(l)},null,8,re)],10,ne))),128)):c("",!0)])])])]),o.hasPagination?(r(),w(L,{key:0,"item-name":"posts",pagination:s.pagination,onFetch:o.fetchPosts},null,8,["pagination","onFetch"])):c("",!0),i(U,{"body-classes":"p-4 sm:p-6","wrapper-classes":"max-w-screen-md",modelValue:s.showSelectedPostModal,"onUpdate:modelValue":t[8]||(t[8]=l=>s.showSelectedPostModal=l),onShown:o.postModalShown},{default:u(()=>[o.getTitle(s.selectedPost)?(r(),f("h3",de,"Posted in "+m(o.getTitle(s.selectedPost)),1)):c("",!0),s.selectedPost.message_board_type=="Lesson"?(r(),f("p",{key:1,class:"text-lg mb-4",innerHTML:s.selectedPost.prompt},null,8,ce)):c("",!0),i(D,{ref:"messageBoardPost",onUpdatePost:o.updatePost,"board-user":o.user,"show-deleted":s.newFilterBy=="deleted","mark-as-read":!0,"unread-buttons":!0,"post-id":s.selectedPost.post_reply_id?s.selectedPost.post_reply_id:s.selectedPost.id,"target-post-id":s.selectedPost.id},null,8,["onUpdatePost","board-user","show-deleted","post-id","target-post-id"])]),_:1},8,["modelValue","onShown"])])}const pe=z(j,[["render",ue],["__scopeId","data-v-914e0be2"],["__file","MessageBoardInbox.vue"]]);export{pe 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.