PluginProbe
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses / 2.11.0
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses v2.11.0
2.11.0 2.10.0 2.10.01 2.9.1 2.9.0 2.8.1 2.8.0 2.7.7 2.7.5 2.7.0 2.6.01 2.6.0 2.5.0 2.4.01 trunk 1.0.90 1.0.91 1.0.92 1.0.93 1.0.94 1.0.95 1.0.96 1.0.97 1.0.98 1.0.99 All 78 releases
← All changes | assets/ManageSpacePages.js +1 -1 2.10.012.11.0 View file →
@@ -1 +1 @@
1 -import{E as T,a as N,z as U,A,B as z,a0 as j,d as R,N as V,P as M,q as I,g as G,m as L,n as O,r as q}from"./element-plus.js?ver=2.10.01";import"./dayjs.js?ver=2.10.01";import{A as H,u as Y}from"./app.js?ver=2.10.01";import{F as J}from"./FluentDnD.js?ver=2.10.01";import{F as Q}from"./FullEditorFrame.js?ver=2.10.01";import{ae as p,D as c,F as _,S as o,I as r,K as a,Q as i,P as u,O as m,E as y,R as K,L as W,a7 as X,T as Z}from"./vue.js?ver=2.10.01";import{_ as B}from"./emoji-picker.js?ver=2.10.01";import"./fcom-utils.js?ver=2.10.01";import"./vendor.js?ver=2.10.01";import"./vue-router.js?ver=2.10.01";import"./pinia.js?ver=2.10.01";import"./milkdown.js?ver=2.10.01";const x={name:"SpacePageEditor",components:{FullEditorFrame:Q},emits:["close","saved"],props:["page","spaceProfile"],data(){return{loading:!0,saving:!1,baseline:"",removeRouterGuard:null,form:{title:"",slug:"",message:"",status:"draft",privacy:"public",meta:{show_in_nav:"yes",nav_label:"",emoji:"",featured_image_id:0,enable_comments:"no",seo_description:"",layout:"unified",show_title:"yes",show_featured_image:"no"}}}},computed:{isDirty(){return!!this.baseline&&JSON.stringify(this.form)!==this.baseline},editorSettings(){return{...this.form.meta,slug:this.form.slug,privacy:this.form.privacy}}},methods:{applyEditorSettings(e){const{slug:t,privacy:d,...f}=e||{};this.form.slug=t||"",this.form.privacy=d==="members_only"?"members_only":"public",this.form.meta=f},fetchPage(){this.loading=!0,this.$get(`spaces/${this.spaceProfile.slug}/pages/${this.page.slug}`).then(e=>{const t=e.page;this.form={title:t.title||"",slug:t.slug||"",message:t.message||"",status:t.status||"draft",privacy:t.privacy||"public",meta:Object.assign({show_in_nav:"yes",nav_label:"",emoji:"",featured_image_id:0,enable_comments:"no",seo_description:"",layout:"unified",show_title:"yes",show_featured_image:"no"},t.meta||{})},this.baseline=JSON.stringify(this.form)}).catch(e=>{this.$handleError(e),this.$emit("close")}).finally(()=>{this.loading=!1})},save(){if(!this.saving){if(!this.form.title||!this.form.title.trim()){this.$notify.error(this.$t("Page title is required"));return}this.saving=!0,this.$put(`spaces/${this.spaceProfile.slug}/pages/${this.page.id}`,{page:this.form}).then(e=>{this.baseline=JSON.stringify(this.form),this.$notify.success(e.message),this.$emit("saved",e.page)}).catch(e=>{this.$handleError(e)}).finally(()=>{this.saving=!1})}},confirmDiscard(){return this.isDirty?this.$confirm(this.$t("You have unsaved changes. Are you sure you want to close?"),this.$t("Confirm"),{confirmButtonText:this.$t("Yes"),cancelButtonText:this.$t("Cancel"),confirmButtonClass:"fcom_primary_button",cancelButtonClass:"fcom_secondary_button",type:"warning"}).then(()=>!0).catch(()=>!1):Promise.resolve(!0)},requestClose(){this.confirmDiscard().then(e=>{e&&this.$emit("close")})},handleBeforeUnload(e){this.isDirty&&(e.preventDefault(),e.returnValue="")}},mounted(){this.fetchPage(),window.addEventListener("beforeunload",this.handleBeforeUnload);const e=this.$route.name,t=this.$route.params.space;this.removeRouterGuard=this.$router.beforeEach((d,f,n)=>{if(d.name===e&&d.params.space===t){n();return}this.confirmDiscard().then(l=>{n(l?void 0:!1)})})},beforeUnmount(){window.removeEventListener("beforeunload",this.handleBeforeUnload),this.removeRouterGuard&&(this.removeRouterGuard(),this.removeRouterGuard=null)}},ee={class:"fcom_full_editor fcom_space_page_editor"},te={class:"fcom_full_editor_header"},se=["aria-label"],ie={class:"fcom_desktop_only"},ae={class:"full_editor_actions"},oe=["title","href"],ne={key:0,style:{padding:"40px"}};function le(e,t,d,f,n,l){const b=p("ArrowLeft"),g=T,w=p("arrow-down"),$=N,P=U,v=A,k=z,C=p("View"),E=j,S=R,D=p("FullEditorFrame"),F=V,s=M;return c(),_("div",ee,[o(s,null,{default:r(()=>[o(E,{class:"fcom_full_editor_header_wrap"},{default:r(()=>[a("div",te,[a("button",{type:"button",onClick:t[0]||(t[0]=h=>l.requestClose()),class:"fcom_back_header","aria-label":e.$t("Back to Pages")},[o(g,{class:"fcom_arrow_icon"},{default:r(()=>[o(b)]),_:1}),a("span",ie,i(e.$t("Back to Pages")),1)],8,se),a("div",ae,[o(k,{onCommand:t[1]||(t[1]=h=>{n.form.status=h}),trigger:"click"},{dropdown:r(()=>[o(v,null,{default:r(()=>[o(P,{command:"draft"},{default:r(()=>[u(i(e.$t("Draft")),1)]),_:1}),o(P,{command:"published"},{default:r(()=>[u(i(e.$t("Published")),1)]),_:1})]),_:1})]),default:r(()=>[o($,{type:n.form.status=="published"?"success":"info",bg:"",text:"",class:"el-dropdown-link"},{default:r(()=>[u(i(e.$labelize(n.form.status))+" ",1),o(g,{class:"el-icon--right"},{default:r(()=>[o(w)]),_:1})]),_:1},8,["type"])]),_:1}),o($,{style:{"margin-left":"15px"},disabled:n.saving||n.loading,loading:n.saving,onClick:t[2]||(t[2]=h=>l.save()),class:"fcom_primary_button"},{default:r(()=>[u(i(e.$t("Save")),1)]),_:1},8,["disabled","loading"]),d.page.permalink?(c(),_("a",{key:0,title:e.$t("Preview Page"),class:"el-button el-button--text",target:"_blank",rel:"noopener",href:d.page.permalink},[o(g,null,{default:r(()=>[o(C)]),_:1})],8,oe)):m("",!0)])])]),_:1}),o(s,{class:"fcom_full_editor_container"},{default:r(()=>[o(F,{style:{overflow:"hidden",padding:"0"},class:"fcom_full_editor_main"},{default:r(()=>[n.loading?(c(),_("div",ne,[o(S,{rows:8,animated:!0})])):(c(),y(D,{key:1,ref:"fullEditorFrame",editorParams:{context:"space_page",page_id:d.page.id},frameHeight:"calc(100vh - 60px)",documentTitle:n.form.title,metaSettings:l.editorSettings,featured_image_id:n.form.meta.featured_image_id||"",onTitleUpdated:t[3]||(t[3]=h=>{n.form.title=h}),onMetaUpdated:l.applyEditorSettings,onFeaturedMediaUpdated:t[4]||(t[4]=h=>{n.form.meta.featured_image_id=h}),modelValue:n.form.message,"onUpdate:modelValue":t[5]||(t[5]=h=>n.form.message=h)},null,8,["editorParams","documentTitle","metaSettings","featured_image_id","onMetaUpdated","modelValue"]))]),_:1})]),_:1})]),_:1})])}const re=B(x,[["render",le]]),ce={name:"GeneticPromo",props:{placement:{type:String,default:"generic_promo"}}},de={class:"fcom_generic_promo"},_e={style:{"text-align":"center"},class:"fcom_upgrade_banner"},ue={style:{"font-size":"18px","margin-bottom":"10px"}},he=["href"];function me(e,t,d,f,n,l){return c(),_("div",de,[a("div",_e,[a("h3",ue,i(e.$t("This feature is available on the pro version of FluentCommunity")),1),a("a",{class:"el-button fcom_primary_button",href:e.$upgradeUrl(d.placement),target:"_blank"},i(e.$t("Upgrade Now")),9,he)])])}const pe=B(ce,[["render",me]]),fe={name:"ManageSpacePages",components:{FluentDnD:J,ActionPopover:H,SpacePageEditor:re,GenericPromo:pe},emits:["close"],props:["spaceProfile","savingCount"],setup(){return{spaceStore:Y()}},data(){return{loading:!0,saving:!1,creating:!1,pages:[],search:"",statusFilter:"all",editingPage:null}},computed:{counts(){const e={all:this.pages.length,published:0,draft:0};return this.pages.forEach(t=>{t.status==="published"?e.published++:e.draft++}),e},isFiltered(){return this.statusFilter!=="all"||!!this.search.trim()},filteredPages(){if(!this.isFiltered)return this.pages;const e=this.search.trim().toLowerCase();return this.pages.filter(t=>this.statusFilter==="published"&&t.status!=="published"||this.statusFilter==="draft"&&t.status==="published"?!1:e?`${t.title||""} ${t.slug||""}`.toLowerCase().includes(e):!0)},canReorder(){return!this.isFiltered&&!this.saving}},watch:{savingCount(){this.$emit("close")}},methods:{isInNav(e){var t;return((t=e.meta)==null?void 0:t.show_in_nav)==="yes"},pageEmoji(e){var t;return((t=e.meta)==null?void 0:t.emoji)||""},pageInitial(e){return(e.title||"?").trim().charAt(0).toUpperCase()},clearFilters(){this.search="",this.statusFilter="all"},pageRowActions(e){const t=e.status==="published";return[{label:t?this.$t("Switch to Draft"):this.$t("Publish"),action:()=>this.setStatus(e,t?"draft":"published")},{label:this.isInNav(e)?this.$t("Hide from Menu"):this.$t("Show in Menu"),action:()=>this.setNavVisibility(e,!this.isInNav(e))},{label:this.$t("Copy Link"),action:()=>this.$toClipboard(e.permalink,"Page link copied to clipboard")},{label:this.$t("Duplicate"),action:()=>this.duplicatePage(e)},{label:this.$t("Delete"),type:"danger",action:()=>this.deletePage(e)}]},fetchPages(e=null){this.loading=!0,this.$get(`spaces/${this.spaceProfile.slug}/pages`).then(t=>{if(this.pages=t.pages||[],e){const d=this.pages.find(f=>f.id==e);d&&this.openEditor(d)}}).catch(t=>{this.$handleError(t)}).finally(()=>{this.loading=!1})},promptCreate(){this.$promt(this.$t("Give your page a title. You can change it later."),this.$t("New Page"),{confirmButtonText:this.$t("Create Page"),cancelButtonText:this.$t("Cancel"),confirmButtonClass:"fcom_primary_button",cancelButtonClass:"fcom_secondary_button"}).then(e=>{const t=(e.value||"").trim();if(!t){this.$notify.error(this.$t("Page title is required"));return}this.createPage(t)}).catch(()=>{})},createPage(e){this.creating=!0,this.$post(`spaces/${this.spaceProfile.slug}/pages`,{title:e}).then(t=>{this.$notify.success(t.message),this.pages.push(t.page),this.refreshSpace(),this.openEditor(t.page)}).catch(t=>{this.$handleError(t)}).finally(()=>{this.creating=!1})},duplicatePage(e){this.$post(`spaces/${this.spaceProfile.slug}/pages/${e.id}/duplicate`).then(t=>{this.$notify.success(t.message),this.pages.push(t.page),this.refreshSpace()}).catch(t=>{this.$handleError(t)})},setStatus(e,t){this.patchPage(e,{status:t})},setNavVisibility(e,t){this.patchPage(e,{meta:Object.assign({},e.meta,{show_in_nav:t?"yes":"no"})})},patchPage(e,t){this.$put(`spaces/${this.spaceProfile.slug}/pages/${e.id}`,{page:t}).then(d=>{this.$notify.success(d.message),this.replaceRow(d.page),this.refreshSpace()}).catch(d=>{this.$handleError(d)})},deletePage(e){this.$confirm(this.$t("Are you sure you want to delete this page? This cannot be undone."),this.$t("Delete Page"),{confirmButtonText:this.$t("Yes, Delete"),cancelButtonText:this.$t("Cancel"),confirmButtonClass:"fcom_primary_button",cancelButtonClass:"fcom_secondary_button",type:"warning"}).then(()=>{this.$del(`spaces/${this.spaceProfile.slug}/pages/${e.id}`).then(t=>{this.$notify.success(t.message),this.pages=this.pages.filter(d=>d.id!==e.id),this.refreshSpace()}).catch(t=>{this.$handleError(t)})}).catch(()=>{})},onReorder(){this.canReorder&&(this.saving=!0,this.$patch(`spaces/${this.spaceProfile.slug}/pages/re-index`,{page_ids:this.pages.map(e=>e.id)}).then(e=>{this.$notify.success(e.message),this.refreshSpace()}).catch(e=>{this.$handleError(e)}).finally(()=>{this.saving=!1}))},openEditor(e){this.editingPage=e},closeEditor(){this.editingPage=null},replaceRow(e){const t=this.pages.findIndex(d=>d.id===e.id);t!==-1&&this.pages.splice(t,1,Object.assign({},this.pages[t],e))},onPageSaved(e){this.replaceRow(e),this.editingPage&&this.editingPage.id===e.id&&(this.editingPage=Object.assign({},this.editingPage,e)),this.refreshSpace()},refreshSpace(){const e=this.spaceProfile.slug;this.spaceStore.invalidateSpace(e),this.spaceStore.fetchSpace(e,!0).catch(()=>{})}},mounted(){if(!this.has_pro){this.loading=!1;return}this.fetchPages(this.$route.query.page_id||null)}},ge={style:{"max-width":"1200px",padding:"20px",margin:"0 auto"}},ye={class:"fcom_card_sections"},be={class:"fcom_section_primary fcom_space_pages_settings"},ve={class:"fcom_section_primary_item"},$e={class:"fcom_section_primary_item_title"},Pe={class:"fcom_heading_item"},we={class:"fcom_section_subtitle"},ke={key:0,class:"fcom_section_item_actions"},Ce={key:0,class:"fcom_section_items"},Ee={style:{padding:"1rem"}},Se={key:1,class:"fcom_section_items"},De={key:0,style:{padding:"1rem"}},Fe={key:1,style:{padding:"1rem"}},Be={class:"fcom_pages_toolbar"},Ne={key:0,class:"fcom_pages_filter_note"},Re={key:0},Ve={key:1},Te={class:"fcom_pages_table",role:"table"},Ue={class:"fcom_pages_table_head",role:"row"},Ae={class:"fcom_pages_col_main",role:"columnheader"},ze={class:"fcom_pages_col_status",role:"columnheader"},je={class:"fcom_pages_col_layout",role:"columnheader"},Me={class:"fcom_pages_col_updated",role:"columnheader"},Ie={class:"fcom_pages_col_actions",role:"columnheader"},Ge={class:"fcom_visually_hidden"},Le={class:"fcom_pages_col_main",role:"cell"},Oe=["title"],qe=["src"],He=["textContent"],Ye=["textContent"],Je={class:"fcom_page_identity"},Qe=["title","onClick","textContent"],Ke=["href","title"],We={class:"fcom_pages_col_status",role:"cell"},Xe={class:"fcom_pages_col_layout",role:"cell"},Ze=["textContent"],xe={key:0,class:"fcom_page_cell_sub"},et={key:1,class:"fcom_page_cell_sub fcom_page_empty"},tt={class:"fcom_pages_col_updated",role:"cell"},st=["title"],it=["title"],at={class:"fcom_pages_col_actions fcom_section_item_actions",role:"cell"};function ot(e,t,d,f,n,l){const b=I,g=N,w=p("generic-promo"),$=R,P=G,v=L,k=O,C=p("action-popover"),E=p("FluentDnD"),S=q,D=p("space-page-editor"),F=V;return c(),y(F,{class:"fcom_full_editor_main"},{default:r(()=>[o(S,null,{default:r(()=>[a("div",ge,[a("div",ye,[a("div",be,[a("div",ve,[a("div",$e,[a("div",Pe,[a("h4",null,i(e.$t("Pages")),1),n.pages.length?(c(),y(b,{key:0,type:"info",size:"small",round:""},{default:r(()=>[u(i(n.pages.length),1)]),_:1})):m("",!0)]),a("p",we,i(e.$t("Static pages for this space, like rules, an FAQ or current offers.")),1)]),e.has_pro?(c(),_("div",ke,[o(g,{class:"fcom_primary_button",disabled:n.creating,onClick:t[0]||(t[0]=s=>l.promptCreate())},{default:r(()=>[u(i(e.$t("Add New Page")),1)]),_:1},8,["disabled"])])):m("",!0)]),e.has_pro?(c(),_("div",Se,[n.loading?(c(),_("div",De,[o($,{rows:4,animated:!0})])):n.pages.length?(c(),_(K,{key:2},[a("div",Be,[o(P,{modelValue:n.search,"onUpdate:modelValue":t[1]||(t[1]=s=>n.search=s),clearable:"",size:"small",class:"fcom_pages_search",placeholder:e.$t("Search pages")},null,8,["modelValue","placeholder"]),o(k,{modelValue:n.statusFilter,"onUpdate:modelValue":t[2]||(t[2]=s=>n.statusFilter=s),size:"small"},{default:r(()=>[o(v,{value:"all"},{default:r(()=>[u(i(e.$t("All"))+" ("+i(l.counts.all)+") ",1)]),_:1}),o(v,{value:"published"},{default:r(()=>[u(i(e.$t("Published"))+" ("+i(l.counts.published)+") ",1)]),_:1}),o(v,{value:"draft"},{default:r(()=>[u(i(e.$t("Draft"))+" ("+i(l.counts.draft)+") ",1)]),_:1})]),_:1},8,["modelValue"])]),l.isFiltered?(c(),_("div",Ne,[l.filteredPages.length?(c(),_("span",Re,i(e.$t("Showing %1$s of %2$s pages. Clear the filters to reorder.",l.filteredPages.length,n.pages.length)),1)):(c(),_("span",Ve,i(e.$t("No page matches these filters.")),1)),o(g,{link:"",type:"primary",size:"small",onClick:t[3]||(t[3]=s=>l.clearFilters())},{default:r(()=>[u(i(e.$t("Clear")),1)]),_:1})])):m("",!0),a("div",Te,[a("div",Ue,[a("span",Ae,i(e.$t("Page")),1),a("span",ze,i(e.$t("Status")),1),a("span",je,i(e.$t("Template")),1),a("span",Me,i(e.$t("Last Updated")),1),a("span",Ie,[a("span",Ge,i(e.$t("Actions")),1)])]),o(E,{items:l.filteredPages,"row-key":"id",draggable:l.canReorder,handle:".fcom_drag_handle",onDrop:l.onReorder,"item-class":"fcom_pages_row"},{item:r(({data:s})=>[a("div",Le,[l.canReorder?(c(),_("span",{key:0,class:"fcom_drag_handle",title:e.$t("Drag to reorder")},"⋮⋮",8,Oe)):m("",!0),a("span",{class:W(["fcom_page_thumb",{has_image:!!s.featured_image}])},[s.featured_image?(c(),_("img",{key:0,src:s.featured_image,alt:""},null,8,qe)):l.pageEmoji(s)?(c(),_("span",{key:1,class:"fcom_page_thumb_emoji",textContent:i(l.pageEmoji(s))},null,8,He)):(c(),_("span",{key:2,class:"fcom_page_thumb_letter",textContent:i(l.pageInitial(s))},null,8,Ye))],2),a("span",Je,[a("a",{href:"#",class:"fcom_page_title",title:s.title,onClick:X(h=>l.openEditor(s),["prevent"]),textContent:i(s.title)},null,8,Qe),a("a",{class:"fcom_page_slug",href:s.permalink,target:"_blank",rel:"noopener",title:s.status==="published"?e.$t("View page"):e.$t("Preview draft")},"/"+i(s.slug),9,Ke)])]),a("div",We,[o(b,{type:s.status==="published"?"success":"warning",size:"small","disable-transitions":""},{default:r(()=>[u(i(s.status==="published"?e.$t("Published"):e.$t("Draft")),1)]),_:2},1032,["type"]),s.privacy==="members_only"?(c(),y(b,{key:0,type:"info",size:"small","disable-transitions":""},{default:r(()=>[u(i(e.$t("Members Only")),1)]),_:1})):m("",!0),l.isInNav(s)?m("",!0):(c(),y(b,{key:1,type:"info",size:"small","disable-transitions":""},{default:r(()=>[u(i(e.$t("Hidden from menu")),1)]),_:1}))]),a("div",Xe,[a("span",{textContent:i(s.layout_label||e.$labelize(s.meta&&s.meta.layout))},null,8,Ze),s.word_count?(c(),_("span",xe,i(e.$_n("%s word","%s words",s.word_count)),1)):(c(),_("span",et,i(e.$t("No content yet")),1))]),a("div",tt,[a("span",{title:s.updated_at},i(s.updated_at?e.humanDateDiff(s.updated_at):"-"),9,st),s.author?(c(),_("span",{key:0,class:"fcom_page_cell_sub",title:s.author.name},i(e.$t("by %s",s.author.name)),9,it)):m("",!0)]),a("div",at,[o(g,{size:"small",onClick:h=>l.openEditor(s)},{default:r(()=>[u(i(e.$t("Edit")),1)]),_:1},8,["onClick"]),o(C,{items:l.pageRowActions(s),placement:"bottom-end",width:180},null,8,["items"])])]),_:1},8,["items","draggable","onDrop"])])],64)):(c(),_("div",Fe,[a("p",null,i(e.$t("No page has been created for this space yet.")),1)]))])):(c(),_("div",Ce,[a("div",Ee,[o(w,{placement:"feature_lock_space_pages"})])]))])])])]),_:1}),(c(),y(Z,{to:"body"},[n.editingPage?(c(),y(D,{key:0,page:n.editingPage,spaceProfile:d.spaceProfile,onClose:t[4]||(t[4]=s=>l.closeEditor()),onSaved:l.onPageSaved},null,8,["page","spaceProfile","onSaved"])):m("",!0)]))]),_:1})}const yt=B(fe,[["render",ot]]);export{yt as default};
1 +import{E as R,a as V,z as M,A as j,B as I,a0 as G,d as T,N as A,P as L,q as O,g as q,m as H,n as Y,r as J}from"./element-plus.js?ver=2.11.0";import"./dayjs.js?ver=2.11.0";import{bh as Q}from"./vendor.js?ver=2.11.0";import{F as K,A as W,u as X}from"./app.js?ver=2.11.0";import{F as Z}from"./FullEditorFrame.js?ver=2.11.0";import{ae as p,D as c,F as _,S as i,I as n,K as a,Q as s,P as u,O as m,E as y,R as x,L as ee,a7 as te,T as se}from"./vue.js?ver=2.11.0";import{_ as N}from"./emoji-picker.js?ver=2.11.0";import"./fcom-utils.js?ver=2.11.0";import"./vue-router.js?ver=2.11.0";import"./pinia.js?ver=2.11.0";import"./milkdown.js?ver=2.11.0";const ae={name:"SpacePageEditor",components:{FullEditorFrame:Z},emits:["close","saved"],props:["page","spaceProfile"],data(){return{loading:!0,saving:!1,baseline:"",removeRouterGuard:null,form:{title:"",slug:"",message:"",status:"draft",privacy:"public",meta:{show_in_nav:"yes",nav_label:"",emoji:"",featured_image_id:0,enable_comments:"no",seo_description:"",layout:"unified",show_title:"yes",show_featured_image:"no"}}}},computed:{isDirty(){return!!this.baseline&&JSON.stringify(this.form)!==this.baseline},editorSettings(){return{...this.form.meta,slug:this.form.slug,privacy:this.form.privacy}}},methods:{applyEditorSettings(e){const{slug:t,privacy:d,...f}=e||{};this.form.slug=t||"",this.form.privacy=d==="members_only"?"members_only":"public",this.form.meta=f},fetchPage(){this.loading=!0,this.$get(`spaces/${this.spaceProfile.slug}/pages/${this.page.slug}`).then(e=>{const t=e.page;this.form={title:t.title||"",slug:t.slug||"",message:t.message||"",status:t.status||"draft",privacy:t.privacy||"public",meta:Object.assign({show_in_nav:"yes",nav_label:"",emoji:"",featured_image_id:0,enable_comments:"no",seo_description:"",layout:"unified",show_title:"yes",show_featured_image:"no"},t.meta||{})},this.baseline=JSON.stringify(this.form)}).catch(e=>{this.$handleError(e),this.$emit("close")}).finally(()=>{this.loading=!1})},save(){if(!this.saving){if(!this.form.title||!this.form.title.trim()){this.$notify.error(this.$t("Page title is required"));return}this.saving=!0,this.$put(`spaces/${this.spaceProfile.slug}/pages/${this.page.id}`,{page:this.form}).then(e=>{this.baseline=JSON.stringify(this.form),this.$notify.success(e.message),this.$emit("saved",e.page)}).catch(e=>{this.$handleError(e)}).finally(()=>{this.saving=!1})}},confirmDiscard(){return this.isDirty?this.$confirm(this.$t("You have unsaved changes. Are you sure you want to close?"),this.$t("Confirm"),{confirmButtonText:this.$t("Yes"),cancelButtonText:this.$t("Cancel"),confirmButtonClass:"fcom_primary_button",cancelButtonClass:"fcom_secondary_button",type:"warning"}).then(()=>!0).catch(()=>!1):Promise.resolve(!0)},requestClose(){this.confirmDiscard().then(e=>{e&&this.$emit("close")})},handleBeforeUnload(e){this.isDirty&&(e.preventDefault(),e.returnValue="")}},mounted(){this.fetchPage(),window.addEventListener("beforeunload",this.handleBeforeUnload);const e=this.$route.name,t=this.$route.params.space;this.removeRouterGuard=this.$router.beforeEach((d,f,l)=>{if(d.name===e&&d.params.space===t){l();return}this.confirmDiscard().then(r=>{l(r?void 0:!1)})})},beforeUnmount(){window.removeEventListener("beforeunload",this.handleBeforeUnload),this.removeRouterGuard&&(this.removeRouterGuard(),this.removeRouterGuard=null)}},oe={class:"fcom_full_editor fcom_space_page_editor"},ie={class:"fcom_full_editor_header"},ne=["aria-label"],le={class:"fcom_desktop_only"},re={class:"full_editor_actions"},ce=["title","href"],de={key:0,style:{padding:"40px"}};function _e(e,t,d,f,l,r){const b=p("ArrowLeft"),g=R,k=p("arrow-down"),$=V,P=M,S=j,C=I,v=p("View"),E=G,D=T,F=p("FullEditorFrame"),B=A,w=L;return c(),_("div",oe,[i(w,null,{default:n(()=>[i(E,{class:"fcom_full_editor_header_wrap"},{default:n(()=>[a("div",ie,[a("button",{type:"button",onClick:t[0]||(t[0]=h=>r.requestClose()),class:"fcom_back_header","aria-label":e.$t("Back to Pages")},[i(g,{class:"fcom_arrow_icon"},{default:n(()=>[i(b)]),_:1}),a("span",le,s(e.$t("Back to Pages")),1)],8,ne),a("div",re,[i(C,{onCommand:t[1]||(t[1]=h=>{l.form.status=h}),trigger:"click"},{dropdown:n(()=>[i(S,null,{default:n(()=>[i(P,{command:"draft"},{default:n(()=>[u(s(e.$t("Draft")),1)]),_:1}),i(P,{command:"published"},{default:n(()=>[u(s(e.$t("Published")),1)]),_:1})]),_:1})]),default:n(()=>[i($,{type:l.form.status=="published"?"success":"info",bg:"",text:"",class:"el-dropdown-link"},{default:n(()=>[u(s(e.$labelize(l.form.status))+" ",1),i(g,{class:"el-icon--right"},{default:n(()=>[i(k)]),_:1})]),_:1},8,["type"])]),_:1}),i($,{style:{"margin-left":"15px"},disabled:l.saving||l.loading,loading:l.saving,onClick:t[2]||(t[2]=h=>r.save()),class:"fcom_primary_button"},{default:n(()=>[u(s(e.$t("Save")),1)]),_:1},8,["disabled","loading"]),d.page.permalink?(c(),_("a",{key:0,title:e.$t("Preview Page"),class:"el-button el-button--text",target:"_blank",rel:"noopener",href:d.page.permalink},[i(g,null,{default:n(()=>[i(v)]),_:1})],8,ce)):m("",!0)])])]),_:1}),i(w,{class:"fcom_full_editor_container"},{default:n(()=>[i(B,{style:{overflow:"hidden",padding:"0"},class:"fcom_full_editor_main"},{default:n(()=>[l.loading?(c(),_("div",de,[i(D,{rows:8,animated:!0})])):(c(),y(F,{key:1,ref:"fullEditorFrame",editorParams:{context:"space_page",page_id:d.page.id},frameHeight:"calc(100vh - 60px)",documentTitle:l.form.title,metaSettings:r.editorSettings,featured_image_id:l.form.meta.featured_image_id||"",onTitleUpdated:t[3]||(t[3]=h=>{l.form.title=h}),onMetaUpdated:r.applyEditorSettings,onFeaturedMediaUpdated:t[4]||(t[4]=h=>{l.form.meta.featured_image_id=h}),modelValue:l.form.message,"onUpdate:modelValue":t[5]||(t[5]=h=>l.form.message=h)},null,8,["editorParams","documentTitle","metaSettings","featured_image_id","onMetaUpdated","modelValue"]))]),_:1})]),_:1})]),_:1})])}const ue=N(ae,[["render",_e]]),he={name:"GeneticPromo",props:{placement:{type:String,default:"generic_promo"}}},me={class:"fcom_generic_promo"},pe={style:{"text-align":"center"},class:"fcom_upgrade_banner"},fe={style:{"font-size":"18px","margin-bottom":"10px"}},ge=["href"];function ye(e,t,d,f,l,r){return c(),_("div",me,[a("div",pe,[a("h3",fe,s(e.$t("This feature is available on the pro version of FluentCommunity")),1),a("a",{class:"el-button fcom_primary_button",href:e.$upgradeUrl(d.placement),target:"_blank"},s(e.$t("Upgrade Now")),9,ge)])])}const be=N(he,[["render",ye]]),ve={name:"ManageSpacePages",components:{FluentDnD:K,ActionPopover:W,SpacePageEditor:ue,GenericPromo:be,Search:Q},emits:["close"],props:["spaceProfile","savingCount"],setup(){return{spaceStore:X()}},data(){return{loading:!0,saving:!1,creating:!1,pages:[],search:"",statusFilter:"all",editingPage:null}},computed:{counts(){const e={all:this.pages.length,published:0,draft:0};return this.pages.forEach(t=>{t.status==="published"?e.published++:e.draft++}),e},isFiltered(){return this.statusFilter!=="all"||!!this.search.trim()},filteredPages(){if(!this.isFiltered)return this.pages;const e=this.search.trim().toLowerCase();return this.pages.filter(t=>this.statusFilter==="published"&&t.status!=="published"||this.statusFilter==="draft"&&t.status==="published"?!1:e?`${t.title||""} ${t.slug||""}`.toLowerCase().includes(e):!0)},canReorder(){return!this.isFiltered&&!this.saving}},watch:{savingCount(){this.$emit("close")}},methods:{isInNav(e){var t;return((t=e.meta)==null?void 0:t.show_in_nav)==="yes"},pageEmoji(e){var t;return((t=e.meta)==null?void 0:t.emoji)||""},pageInitial(e){return(e.title||"?").trim().charAt(0).toUpperCase()},clearFilters(){this.search="",this.statusFilter="all"},pageRowActions(e){const t=e.status==="published";return[{label:t?this.$t("Switch to Draft"):this.$t("Publish"),action:()=>this.setStatus(e,t?"draft":"published")},{label:this.isInNav(e)?this.$t("Hide from Menu"):this.$t("Show in Menu"),action:()=>this.setNavVisibility(e,!this.isInNav(e))},{label:this.$t("Copy Link"),action:()=>this.$toClipboard(e.permalink,"Page link copied to clipboard")},{label:this.$t("Duplicate"),action:()=>this.duplicatePage(e)},{label:this.$t("Delete"),type:"danger",action:()=>this.deletePage(e)}]},fetchPages(e=null){this.loading=!0,this.$get(`spaces/${this.spaceProfile.slug}/pages`).then(t=>{if(this.pages=t.pages||[],e){const d=this.pages.find(f=>f.id==e);d&&this.openEditor(d)}}).catch(t=>{this.$handleError(t)}).finally(()=>{this.loading=!1})},promptCreate(){this.$promt(this.$t("Give your page a title. You can change it later."),this.$t("New Page"),{confirmButtonText:this.$t("Create Page"),cancelButtonText:this.$t("Cancel"),confirmButtonClass:"fcom_primary_button",cancelButtonClass:"fcom_secondary_button"}).then(e=>{const t=(e.value||"").trim();if(!t){this.$notify.error(this.$t("Page title is required"));return}this.createPage(t)}).catch(()=>{})},createPage(e){this.creating=!0,this.$post(`spaces/${this.spaceProfile.slug}/pages`,{title:e}).then(t=>{this.$notify.success(t.message),this.pages.push(t.page),this.refreshSpace(),this.openEditor(t.page)}).catch(t=>{this.$handleError(t)}).finally(()=>{this.creating=!1})},duplicatePage(e){this.$post(`spaces/${this.spaceProfile.slug}/pages/${e.id}/duplicate`).then(t=>{this.$notify.success(t.message),this.pages.push(t.page),this.refreshSpace()}).catch(t=>{this.$handleError(t)})},setStatus(e,t){this.patchPage(e,{status:t})},setNavVisibility(e,t){this.patchPage(e,{meta:Object.assign({},e.meta,{show_in_nav:t?"yes":"no"})})},patchPage(e,t){this.$put(`spaces/${this.spaceProfile.slug}/pages/${e.id}`,{page:t}).then(d=>{this.$notify.success(d.message),this.replaceRow(d.page),this.refreshSpace()}).catch(d=>{this.$handleError(d)})},deletePage(e){this.$confirm(this.$t("Are you sure you want to delete this page? This cannot be undone."),this.$t("Delete Page"),{confirmButtonText:this.$t("Yes, Delete"),cancelButtonText:this.$t("Cancel"),confirmButtonClass:"fcom_primary_button",cancelButtonClass:"fcom_secondary_button",type:"warning"}).then(()=>{this.$del(`spaces/${this.spaceProfile.slug}/pages/${e.id}`).then(t=>{this.$notify.success(t.message),this.pages=this.pages.filter(d=>d.id!==e.id),this.refreshSpace()}).catch(t=>{this.$handleError(t)})}).catch(()=>{})},onReorder(){this.canReorder&&(this.saving=!0,this.$patch(`spaces/${this.spaceProfile.slug}/pages/re-index`,{page_ids:this.pages.map(e=>e.id)}).then(e=>{this.$notify.success(e.message),this.refreshSpace()}).catch(e=>{this.$handleError(e)}).finally(()=>{this.saving=!1}))},openEditor(e){this.editingPage=e},closeEditor(){this.editingPage=null},replaceRow(e){const t=this.pages.findIndex(d=>d.id===e.id);t!==-1&&this.pages.splice(t,1,Object.assign({},this.pages[t],e))},onPageSaved(e){this.replaceRow(e),this.editingPage&&this.editingPage.id===e.id&&(this.editingPage=Object.assign({},this.editingPage,e)),this.refreshSpace()},refreshSpace(){const e=this.spaceProfile.slug;this.spaceStore.invalidateSpace(e),this.spaceStore.fetchSpace(e,!0).catch(()=>{})}},mounted(){if(!this.has_pro){this.loading=!1;return}this.fetchPages(this.$route.query.page_id||null)}},$e={style:{"max-width":"1200px",margin:"0 auto"}},Pe={class:"fcom_card_sections fcom_space_pages_card"},we={class:"fcom_section_primary fcom_space_pages_settings"},ke={class:"fcom_section_primary_item"},Se={class:"fcom_section_primary_item_title"},Ce={class:"fcom_heading_item"},Ee={class:"fcom_section_subtitle"},De={key:0,class:"fcom_section_item_actions"},Fe={key:0,class:"fcom_section_items"},Be={style:{padding:"1rem"}},Ne={key:1,class:"fcom_section_items"},Re={key:0,style:{padding:"1rem"}},Ve={key:1,style:{padding:"1rem"}},Te={class:"fcom_pages_toolbar"},Ae={key:0,class:"fcom_pages_filter_note"},Ue={key:0},ze={key:1},Me={class:"fcom_pages_table",role:"table"},je={class:"fcom_pages_table_head",role:"row"},Ie={class:"fcom_pages_col_main",role:"columnheader"},Ge={class:"fcom_pages_col_status",role:"columnheader"},Le={class:"fcom_pages_col_layout",role:"columnheader"},Oe={class:"fcom_pages_col_updated",role:"columnheader"},qe={class:"fcom_pages_col_actions",role:"columnheader"},He={class:"fcom_visually_hidden"},Ye={class:"fcom_pages_col_main",role:"cell"},Je=["title"],Qe=["src"],Ke=["textContent"],We=["textContent"],Xe={class:"fcom_page_identity"},Ze=["title","onClick","textContent"],xe=["href","title"],et={class:"fcom_pages_col_status",role:"cell"},tt={class:"fcom_pages_col_layout",role:"cell"},st=["textContent"],at={key:0,class:"fcom_page_cell_sub"},ot={key:1,class:"fcom_page_cell_sub fcom_page_empty"},it={class:"fcom_pages_col_updated",role:"cell"},nt=["title"],lt=["title"],rt={class:"fcom_pages_col_actions fcom_section_item_actions",role:"cell"},ct={key:2,class:"fcom_section_footer_note"};function dt(e,t,d,f,l,r){const b=O,g=V,k=p("generic-promo"),$=T,P=p("Search"),S=R,C=q,v=H,E=Y,D=p("action-popover"),F=p("FluentDnD"),B=p("router-link"),w=J,h=p("space-page-editor"),U=A;return c(),y(U,{class:"fcom_full_editor_main lockscreen_editor"},{default:n(()=>[i(w,null,{default:n(()=>[a("div",$e,[a("div",Pe,[a("div",we,[a("div",ke,[a("div",Se,[a("div",Ce,[a("h4",null,s(e.$t("Pages")),1),l.pages.length?(c(),y(b,{key:0,type:"info",size:"small",round:""},{default:n(()=>[u(s(l.pages.length),1)]),_:1})):m("",!0)]),a("p",Ee,s(e.$t("Static pages for this space, like rules, an FAQ or current offers.")),1)]),e.has_pro?(c(),_("div",De,[i(g,{class:"fcom_primary_button",disabled:l.creating,onClick:t[0]||(t[0]=o=>r.promptCreate())},{default:n(()=>[u(s(e.$t("Add New Page")),1)]),_:1},8,["disabled"])])):m("",!0)]),e.has_pro?(c(),_("div",Ne,[l.loading?(c(),_("div",Re,[i($,{rows:4,animated:!0})])):l.pages.length?(c(),_(x,{key:2},[a("div",Te,[i(C,{modelValue:l.search,"onUpdate:modelValue":t[1]||(t[1]=o=>l.search=o),clearable:"",size:"small",class:"fcom_pages_search",placeholder:e.$t("Search pages")},{prefix:n(()=>[i(S,null,{default:n(()=>[i(P)]),_:1})]),_:1},8,["modelValue","placeholder"]),i(E,{modelValue:l.statusFilter,"onUpdate:modelValue":t[2]||(t[2]=o=>l.statusFilter=o),size:"small"},{default:n(()=>[i(v,{value:"all"},{default:n(()=>[u(s(e.$t("All"))+" ("+s(r.counts.all)+") ",1)]),_:1}),i(v,{value:"published"},{default:n(()=>[u(s(e.$t("Published"))+" ("+s(r.counts.published)+") ",1)]),_:1}),i(v,{value:"draft"},{default:n(()=>[u(s(e.$t("Draft"))+" ("+s(r.counts.draft)+") ",1)]),_:1})]),_:1},8,["modelValue"])]),r.isFiltered?(c(),_("div",Ae,[r.filteredPages.length?(c(),_("span",Ue,s(e.$t("Showing %1$s of %2$s pages. Clear the filters to reorder.",r.filteredPages.length,l.pages.length)),1)):(c(),_("span",ze,s(e.$t("No page matches these filters.")),1)),i(g,{link:"",type:"primary",size:"small",onClick:t[3]||(t[3]=o=>r.clearFilters())},{default:n(()=>[u(s(e.$t("Clear")),1)]),_:1})])):m("",!0),a("div",Me,[a("div",je,[a("span",Ie,s(e.$t("Page")),1),a("span",Ge,s(e.$t("Status")),1),a("span",Le,s(e.$t("Template")),1),a("span",Oe,s(e.$t("Last Updated")),1),a("span",qe,[a("span",He,s(e.$t("Actions")),1)])]),i(F,{items:r.filteredPages,"row-key":"id",draggable:r.canReorder,handle:".fcom_drag_handle",onDrop:r.onReorder,"item-class":"fcom_pages_row"},{item:n(({data:o})=>[a("div",Ye,[r.canReorder?(c(),_("span",{key:0,class:"fcom_drag_handle",title:e.$t("Drag to reorder")},"⋮⋮",8,Je)):m("",!0),a("span",{class:ee(["fcom_page_thumb",{has_image:!!o.featured_image}])},[o.featured_image?(c(),_("img",{key:0,src:o.featured_image,alt:""},null,8,Qe)):r.pageEmoji(o)?(c(),_("span",{key:1,class:"fcom_page_thumb_emoji",textContent:s(r.pageEmoji(o))},null,8,Ke)):(c(),_("span",{key:2,class:"fcom_page_thumb_letter",textContent:s(r.pageInitial(o))},null,8,We))],2),a("span",Xe,[a("a",{href:"#",class:"fcom_page_title",title:o.title,onClick:te(z=>r.openEditor(o),["prevent"]),textContent:s(o.title)},null,8,Ze),a("a",{class:"fcom_page_slug",href:o.permalink,target:"_blank",rel:"noopener",title:o.status==="published"?e.$t("View page"):e.$t("Preview draft")},"/"+s(o.slug),9,xe)])]),a("div",et,[i(b,{type:o.status==="published"?"success":"warning",size:"small","disable-transitions":""},{default:n(()=>[u(s(o.status==="published"?e.$t("Published"):e.$t("Draft")),1)]),_:2},1032,["type"]),o.privacy==="members_only"?(c(),y(b,{key:0,type:"info",size:"small","disable-transitions":""},{default:n(()=>[u(s(e.$t("Members Only")),1)]),_:1})):m("",!0),r.isInNav(o)?m("",!0):(c(),y(b,{key:1,type:"info",size:"small","disable-transitions":""},{default:n(()=>[u(s(e.$t("Hidden from menu")),1)]),_:1}))]),a("div",tt,[a("span",{textContent:s(o.layout_label||e.$labelize(o.meta&&o.meta.layout))},null,8,st),o.word_count?(c(),_("span",at,s(e.$_n("%s word","%s words",o.word_count)),1)):(c(),_("span",ot,s(e.$t("No content yet")),1))]),a("div",it,[a("span",{title:o.updated_at},s(o.updated_at?e.humanDateDiff(o.updated_at):"-"),9,nt),o.author?(c(),_("span",{key:0,class:"fcom_page_cell_sub",title:o.author.name},s(e.$t("by %s",o.author.name)),9,lt)):m("",!0)]),a("div",rt,[i(g,{size:"small",onClick:z=>r.openEditor(o)},{default:n(()=>[u(s(e.$t("Edit")),1)]),_:1},8,["onClick"]),i(D,{items:r.pageRowActions(o),placement:"bottom-end",width:180},null,8,["items"])])]),_:1},8,["items","draggable","onDrop"])])],64)):(c(),_("div",Ve,[a("p",null,s(e.$t("No page has been created for this space yet.")),1)]))])):(c(),_("div",Fe,[a("div",Be,[i(k,{placement:"feature_lock_space_pages"})])])),e.has_pro?(c(),_("div",ct,[a("p",null,[u(s(e.$t("A page with Show in menu on appears in the space tab bar."))+" ",1),i(B,{to:{name:"space_settings_links",params:{space:d.spaceProfile.slug}}},{default:n(()=>[u(s(e.$t("Set its order and label under Menu.")),1)]),_:1},8,["to"])])])):m("",!0)])])])]),_:1}),(c(),y(se,{to:"body"},[l.editingPage?(c(),y(h,{key:0,page:l.editingPage,spaceProfile:d.spaceProfile,onClose:t[4]||(t[4]=o=>r.closeEditor()),onSaved:r.onPageSaved},null,8,["page","spaceProfile","onSaved"])):m("",!0)]))]),_:1})}const Pt=N(ve,[["render",dt]]);export{Pt as default};