PageSourceSearch

https://treff.tech/assets/ResourceFolder-BCpUtcIq.js

js treff.tech collected 2026-10-04 11:52:24 UTC 17,313 bytes, 2 lines download raw bytes

1import{ci as ne,eV as ue,dv as X,f2 as fe,fj as Z,cb as h,c7 as f,ey as c,eD as r,cf as u,ce as _,c9 as b,af as J,dC as he,de as be,c8 as $,fl as i,c2 as x,dx as L,ei as C,dn as n,aj as Q,bL as ie,f5 as Ge,e$ as H,E as Be,b1 as We,Q as He,bD as Ye,bd as G,cU as Ke,fo as se,fe as Y,dc as K,f8 as Je,cj as Xe}from"./main-CewiQn3z.js";import{F as Re,D as Ze,R as _e,a as et,m as tt,r as me}from"./FolderItem-Bhz8iO6f.js";import ge from"./Link-C88Ufcc7.js";import ve from"./ChevronUp-RJIk5srU.js";import{u as rt,i as at}from"./index-BNf_5DNJ.js";import{u as ot}from"./head-H5ADEur-.js";import{_ as st}from"./EmptyContent.vue_vue_type_script_setup_true_lang-DOgIn6WL.js";import"./Pencil-BA_3i_xG.js";import"./Delete-BiRVD83g.js";import"./DotsHorizontal-DHX9sfx2.js";const lt={key:0},nt={class:""},ut={class:"mb-2"},it=["onClick"],ct={class:"truncate flex gap-1 items-center"},dt={key:0},pt={key:0},mt={key:1},vt={key:3,class:""},ft={class:"flex gap-2 mt-2"},le=10,ht=ne({__name:"ResourceSelector",props:{initialResource:{},username:{}},emits:["update-resource","close-move-modal"],setup(U,{emit:M}){const k=U,S=M,{t:m}=ue({useScope:"global"}),w=x(()=>k.initialResource),l=x(()=>k.username),d=X({id:w.value.parent?.id,path:w.value.parent?.path,username:l.value}),a=L(1),{result:o,refetch:g}=fe(Q,()=>d?.path?{path:d?.path,username:l.value,page:a.value,limit:le}:{path:"/",username:l.value}),s=x(()=>o.value?.resource),P=R=>{R.type==="folder"&&R.id!==w.value.id&&(d.id=R.id,d.path=R.path,console.debug("Gone into folder",d))};Z(w,()=>{w.value&&(d.id=k.initialResource?.parent?.id,d.path=k.initialResource?.parent?.path,g())});const N=()=>{console.debug("Emitting updateResource from folder",d);const R=d?.path==="/"?null:d;S("update-resource",{id:w.value.id,title:w.value.title,parent:R,path:R?.path??"/"},w.value.parent)},E=x(()=>w.value.parent&&d&&w.value.parent.path===d.path||w.value.parent===void 0&&d&&d.path==="/"),v=()=>{d.id=s.value?.parent?.id,d.path=s.value?.parent?.path};return(R,V)=>{const q=C("o-pagination"),z=C("o-button");return s.value?(n(),h("div",lt,[f("article",nt,[f("h2",ut,c(r(m)('Move "{resourceName}"',{resourceName:U.initialResource.title})),1),s.value.parent?(n(),h("a",{key:0,class:"cursor-pointer flex gap-1 items-center border p-2",onClick:V[0]||(V[0]=y=>v())},[u(ve,{size:16}),_(" "+c(r(m)("Parent folder")),1)])):d?.path&&d?.path.length>1?(n(),h("a",{key:1,class:"cursor-pointer flex gap-1 items-center border p-2",onClick:V[1]||(V[1]=y=>d.path="/")},[u(ve,{size:16}),_(" "+c(r(m)("Parent folder")),1)])):b("",!0),s.value.children?(n(!0),h(J,{key:2},he(s.value.children.elements,y=>(n(),h("a",{class:be(["cursor-pointer flex flex-wrap gap-1 p-2 border",{clickable:y.type==="folder"&&y.id!==U.initialResource.id}]),key:y.id,onClick:ee=>P(y)},[f("p",ct,[y.type==="folder"?(n(),$(Re,{key:0,size:16})):(n(),$(ge,{key:1,size:16})),f("span",null,c(y.title),1)]),y.id===U.initialResource.id?(n(),h("span",dt,[y.type==="folder"?(n(),h("em",pt,c(r(m)("(this folder)")),1)):(n(),h("em",mt,c(r(m)("(this link)")),1))])):b("",!0)],10,it))),128)):b("",!0),s.value.children&&s.value.children.total===0?(n(),h("p",vt,c(r(m)("No resources in this folder")),1)):b("",!0),s.value.children&&s.value.children.total>le?(n(),$(q,{key:4,total:s.value.children.total,current:a.value,"onUpdate:current":V[2]||(V[2]=y=>a.value=y),size:"small","per-page":le,"aria-next-label":r(m)("Next page"),"aria-previous-label":r(m)("Previous page"),"aria-page-label":r(m)("Page"),"aria-current-label":r(m)("Current page")},null,8,["total","current","aria-next-label","aria-previous-label","aria-page-label","aria-current-label"])):b("",!0)]),f("div",ft,[u(z,{variant:"text",onClick:V[3]||(V[3]=y=>S("close-move-modal"))},{default:i(()=>[_(c(r(m)("Cancel")),1)]),_:1}),u(z,{variant:"primary",onClick:N,disabled:E.value},{default:i(()=>[s.value.path==="/"?(n(),h(J,{key:0},[_(c(r(m)("Move resource to the root folder")),1)],64)):(n(),h(J,{key:1},[_(c(r(m)("Move resource to {folder}",{folder:s.value.title})),1)],64))]),_:1},8,["disabled"])])])):b("",!0)}}}),bt=ie(ht,[["__scopeId","data-v-fe716578"]]),Rt={class:"bg-white dark:bg-zinc-700 p-2 pt-0.5"},_t={key:0},gt={class:"pl-6 mt-2 flex items-center gap-3"},yt={class:"sr-only"},kt={key:1,class:"flex items-center gap-3"},wt={class:"flex border m-2 p-2 items-center"},Et={class:"sr-only"},Ut=ne({__name:"DraggableList",props:{resources:{},isRoot:{type:Boolean,default:!1},group:{}},emits:["move","rename","delete"],setup(U,{emit:M}){const k=U,S=M,{t:m}=ue({useScope:"global"}),w={name:"resources",pull:"clone",put:!0},l=X({}),d=L([]),a=L(!1),o=async()=>{d.value.forEach(g=>{S("delete",g)})};return Z(a,()=>
1{k.resources.forEach(({id:g})=>{g&&(l[g]=a.value)})}),Z(l,g=>{const s=[];Object.entries(g).forEach(([P,N])=>{N&&s.push(P)}),d.value=s}),(g,s)=>{const P=C("o-checkbox"),N=C("o-button");return n(),h("section",Rt,[f("h1",null,c(r(m)("Resources")),1),U.isRoot?(n(),h("p",_t,c(r(m)("A place to store links to documents or resources of any type.")),1)):b("",!0),f("div",gt,[U.resources.length>0?(n(),$(P,{key:0,modelValue:a.value,"onUpdate:modelValue":s[0]||(s[0]=E=>a.value=E)},{default:i(()=>[f("span",yt,c(r(m)("Select all resources")),1)]),_:1},8,["modelValue"])):b("",!0),d.value.length>0?(n(),h("div",kt,[f("small",null,c(r(m)("No resources selected",{count:d.value.length},d.value.length)),1),u(N,{variant:"danger","icon-right":"delete",size:"small",onClick:o},{default:i(()=>[_(c(r(m)("Delete")),1)]),_:1})])):b("",!0)]),U.resources.length>0?(n(),$(r(Ze),{key:1,list:U.resources,sort:!1,group:w,tag:"transition-group","item-key":"id"},{item:i(({element:E})=>[f("div",wt,[f("div",{class:be(["resource-checkbox px-2",{checked:l[E.id]}])},[u(P,{modelValue:l[E.id],"onUpdate:modelValue":v=>l[E.id]=v},{default:i(()=>[f("span",Et,c(r(m)("Select this resource")),1)]),_:1},8,["modelValue","onUpdate:modelValue"])],2),E.type!=="folder"?(n(),$(_e,{key:0,resource:E,onDelete:s[1]||(s[1]=v=>S("delete",v)),onRename:s[2]||(s[2]=v=>S("rename",v)),onMove:s[3]||(s[3]=v=>S("move",v))},null,8,["resource"])):(n(),$(et,{key:1,resource:E,group:U.group,onDelete:s[4]||(s[4]=v=>S("delete",v)),onRename:s[5]||(s[5]=v=>S("rename",v)),onMove:s[6]||(s[6]=v=>S("move",v))},null,8,["resource","group"]))])]),_:1},8,["list"])):b("",!0),U.resources.length===0?(n(),$(st,{key:2,icon:"link",inline:!0},{desc:i(()=>[_(c(r(m)("You can add resources by using the button above.")),1)]),default:i(()=>[_(c(r(m)("No resources in this folder"))+" ",1)]),_:1})):b("",!0)])}}}),Ct=ie(Ut,[["__scopeId","data-v-8d9a50df"]]),xt={key:0,class:"container mx-auto"},$t={key:0,role:"presentation",class:"dropdown-divider"},St={class:"w-full md:w-[640px]"},Vt={class:"w-full"},Dt={class:"w-full md:w-[640px]"},Lt={key:0},Mt={key:1},Pt={key:2},Nt={class:"w-full md:w-[640px]"},Ft={class:"p-10"},Ot={key:0,class:"new-resource-preview"},B=10,It=ne({__name:"ResourceFolder",props:{path:{},preferredUsername:{}},setup(U){const M=rt("page",1,at),k=U,{result:S,onError:m,fetchMore:w}=fe(Q,()=>{let e=Array.isArray(k.path)?k.path.join("/"):k.path;return e=e[0]!=="/"?`/${e}`:e,{path:e,username:k.preferredUsername,page:M.value,limit:B}}),l=x(()=>S.value?.resource);m(({graphQLErrors:e})=>{qe(e)});const{resourceProviders:d}=Ge(),{t:a}=ue({useScope:"global"}),o=X({title:"",summary:"",resourceUrl:"",children:{elements:[],total:0},metadata:{},type:"link"}),g=L({title:"",resourceUrl:"",metadata:{},children:{elements:[],total:0},path:void 0}),s=L(!1),P=L(!1),N=L(!1),E=L(!1),v=L(""),R=X({}),V=L(),q=L(),z=L(),y=x(()=>{const e=Array.isArray(k.path)?k.path.join("/"):k.path;return e[0]!=="/"?`/${e}`:e}),ee=x(()=>l.value?.path!=="/"?me(l.value):[]),ye=x(()=>y.value==="/"),ke=x(()=>ee.value.slice(-1)[0]),{mutate:we,onDone:Ee,onError:Ue}=H(Be,()=>({refetchQueries:()=>te()}));Ee(()=>{P.value=!1,s.value=!1,o.title="",o.summary="",o.resourceUrl=""}),Ue(e=>{console.error(e);const t=e.graphQLErrors[0];t.field?R[t.field]=t.message.join(","):v.value=t.message.join(",")});const ce=()=>{l.value?.actor&&(v.value="",we({title:o.title,summary:o.summary,actorId:l.value.actor?.id,resourceUrl:o.resourceUrl,parentId:l.value?.id?.startsWith("root_")?null:l.value?.id,type:o.type}))},{mutate:Ce,onDone:xe,onError:$e}=H(We);xe(({data:e})=>{e?.previewResourceLink&&(o.title=e?.previewResourceLink.title??"",o.summary=e?.previewResourceLink?.description?.substring(0,390),o.metadata=e?.previewResourceLink,o.type="link")}),$e(e=>{console.error(e);const t=e.graphQLErrors[0];t.field?R[t.field]=t.message:v.value=e.graphQLErrors[0].message});const Se=async()=>{v.value="",o.resourceUrl!==""&&Ce({resourceUrl:o.resourceUrl})},de=e=>{switch(e){case"folder":return a("Create a folder");case"pad":return a("Create a pad");case"calc":return a("Create a calc");case"visio":return a("Create a videoconference");default:return""}},Ve=async()=>{P.value=!0,await K(),z.value?.$refs.inputRef?.focus()},De=async()=>{o.type="folder",s.value=!0,await K(),q.value?.$refs.inputRef?.focus()},Le=async e=>{o.resourceUrl=Me(e),o.type=e.software,s.value=!0,await K(),q.value?.$refs.inputRef?.focus()},Me=e=>{const t=[...Array(10)].map(()=>Math.random().toString(36)[3]).join("").replace(/(.|$)/g,D=>D[Math.round(Math.random())?"toLowerCase":"toString"]());switch(e.type){default:return`${e.endpoint}${t}`}},Pe=x(()=>o.type?de(o.type):""),te=()=>[{query:Q,variables:{path:y.value,username:k.preferredUsername,page:M.value,limit:B}}],{mutate:Ne,onError:Fe}=H(He,()=>({refetchQueries:()=>te()}));Fe(e=>console.error(e));const Oe=async e=>{E.value=!0,g.value={...e},await K(),V.value?.$el.focus(),V.value?.$el.querySelector("input")?.select()},Ie=e=>{N.value=!0,g.value={...e}},Ae=async(e,t)=>{const D=t&&t.path&&t.path||"/";await re(e,D),N.value=!1},Qe=async()=>{await re(g.value),E.value=!1},{mutate:Te}=H(Ye,()=>({refetchQueries:()=>te(),update:(e,{data:t},{context:D})=>{const O=D?.parentPath;if(!t||t.updateResource==null||O==null||!l.value?.actor)return;console.debug("Removing ressource from old parent");const W=e.readQuery({query:Q,variables:{path:O,username:l.value.actor.preferredUsername}});if(W==null)return;const{resource:T}=W;
1if(T==null){console.error("Cannot update resource cache, because of null value.");return}const A=t.updateResource,oe=T.children.elements.filter(j=>j.id!==A.id);if(e.writeQuery({query:Q,variables:{path:O,username:l.value.actor.preferredUsername},data:{resource:{...T,children:{...T.children,elements:[...oe]}}}}),console.debug("Finished removing ressource from old parent"),console.debug("Adding resource to new parent"),!A.parent||!A.parent.path){console.debug("No cache found for new parent");return}const I=e.readQuery({query:Q,variables:{path:A.parent.path,username:l.value.actor.preferredUsername}});if(I==null)return;const{resource:F}=I;if(F==null){console.error("Cannot update resource cache, because of null value.");return}e.writeQuery({query:Q,variables:{path:A.parent.path,username:l.value.actor.preferredUsername},data:{resource:{...F,children:{...F.children,elements:[...F.children.elements,l]}}}}),console.debug("Finished adding resource to new parent")}})),re=async(e,t=null)=>{console.debug(`Update resource « ${e.title} » at path ${e.path}`),Te({id:e.id,title:e.title,parentId:e.parent?e.parent.id:null,path:e.path},{context:{parentPath:t}})};Z(M,()=>{w({variables:{page:M.value,limit:B}})});const je=Je(),qe=e=>{e.some(t=>t.status_code===404)&&je.replace({name:G.PAGE_NOT_FOUND})},ze=x(()=>{if(!l.value?.actor)return[];const e=l.value.actor,t=[{name:G.MY_GROUPS,text:a("My groups")},{name:G.GROUP,params:{preferredUsername:Y(l.value.actor)},text:Xe(l.value.actor)},{name:G.RESOURCE_FOLDER_ROOT,params:{preferredUsername:Y(l.value.actor)},text:a("Resources")}];return t.push(...ee.value.map((D,O)=>({name:G.RESOURCE_FOLDER,params:{path:me(l.value).slice(0,O+1),preferredUsername:Y(e)},text:D}))),t}),ae=x(()=>{if(o.resourceUrl)return new URL(o.resourceUrl).host});return ot({title:x(()=>ye.value?a("Resources"):a("{folder} - Resources",{folder:ke.value}))}),(e,t)=>{const D=C("o-button"),O=C("o-dropdown-item"),W=C("o-icon"),T=C("o-dropdown"),A=C("breadcrumbs-nav"),oe=C("o-pagination"),I=C("o-input"),F=C("o-field"),j=C("o-modal"),pe=C("o-notification");return l.value?(n(),h("div",xt,[u(A,{links:ze.value},{default:i(()=>[f("li",null,[u(T,{"aria-role":"list"},{trigger:i(()=>[u(D,{variant:"primary"},{default:i(()=>[...t[12]||(t[12]=[_("+",-1)])]),_:1})]),default:i(()=>[u(O,{"aria-role":"listitem",onClick:De},{default:i(()=>[u(Re),_(" "+c(r(a)("New folder")),1)]),_:1}),u(O,{"aria-role":"listitem",onClick:Ve},{default:i(()=>[u(ge),_(" "+c(r(a)("New link")),1)]),_:1}),r(d)?.length?(n(),h("hr",$t)):b("",!0),(n(!0),h(J,null,he(r(d),p=>(n(),$(O,{"aria-role":"listitem",key:p.software,onClick:At=>Le(p)},{default:i(()=>[u(W,{icon:r(tt)[p.software]},null,8,["icon"]),_(" "+c(de(p.software)),1)]),_:2},1032,["onClick"]))),128))]),_:1})])]),_:1},8,["links"]),l.value.actor?(n(),$(Ct,{key:0,resources:l.value.children.elements,isRoot:l.value.path==="/",group:l.value.actor,onDelete:t[0]||(t[0]=p=>r(Ne)({id:p})),onUpdate:re,onRename:Oe,onMove:Ie},null,8,["resources","isRoot","group"])):b("",!0),l.value.children.total>B?(n(),$(oe,{key:1,total:l.value.children.total,current:r(M),"onUpdate:current":t[1]||(t[1]=p=>Ke(M)?M.value=p:null),"per-page":B,"aria-next-label":r(a)("Next page"),"aria-previous-label":r(a)("Previous page"),"aria-page-label":r(a)("Page"),"aria-current-label":r(a)("Current page")},null,8,["total","current","aria-next-label","aria-previous-label","aria-page-label","aria-current-label"])):b("",!0),u(j,{active:E.value,"onUpdate:active":t[3]||(t[3]=p=>E.value=p),"has-modal-card":"","close-button-aria-label":r(a)("Close")},{default:i(()=>[f("div",St,[f("section",null,[f("form",{onSubmit:se(Qe,["prevent"])},[u(F,{label:r(a)("Title")},{default:i(()=>[u(I,{ref_key:"resourceRenameInput",ref:V,"aria-required":"true",modelValue:g.value.title,"onUpdate:modelValue":t[2]||(t[2]=p=>g.value.title=p),expanded:""},null,8,["modelValue"])]),_:1},8,["label"]),u(D,{type:"submit"},{default:i(()=>[_(c(r(a)("Rename resource")),1)]),_:1})],32)])])]),_:1},8,["active","close-button-aria-label"]),u(j,{active:N.value,"onUpdate:active":t[5]||(t[5]=p=>N.value=p),"has-modal-card":"","close-button-aria-label":r(a)("Close")},{default:i(()=>[f("div",Vt,[f("section",null,[u(bt,{initialResource:g.value,username:r(Y)(l.value.actor),onUpdateResource:Ae,onCloseMoveModal:t[4]||(t[4]=p=>N.value=!1)},null,8,["initialResource","username"])])])]),_:1},8,["active","close-button-aria-label"]),u(j,{active:s.value,"onUpdate:active":t[7]||(t[7]=p=>s.value=p),"has-modal-card":"","close-button-aria-label":r(a)("Close"),autoFocus:!1},{default:i(()=>[f("section",Dt,[v.value?(n(),$(pe,{key:0,variant:"danger"},{default:i(()=>[_(c(v.value),1)]),_:1})):b("",!0),f("form",{onSubmit:se(ce,["prevent"])},[o.type==="pad"?(n(),h("p",Lt,c(r(a)("The pad will be created on {service}",{service:ae.value})),1)):o.type==="calc"?(n(),h("p",Mt,c(r(a)("The calc will be created on {service}",{service:ae.value})),1)):o.type==="visio"?(n(),h("p",Pt,c(r(a)("The videoconference will be created on {service}",{service:ae.value})),1)):b("",!0),u(F,{label:r(a)("Title"),"label-for":"new-resource-title"},{default:i(()=>
1[u(I,{ref_key:"modalNewResourceInput",ref:q,"aria-required":"true",modelValue:o.title,"onUpdate:modelValue":t[6]||(t[6]=p=>o.title=p),id:"new-resource-title",expanded:""},null,8,["modelValue"])]),_:1},8,["label"]),u(D,{class:"mt-2",type:"submit"},{default:i(()=>[_(c(Pe.value),1)]),_:1})],32)])]),_:1},8,["active","close-button-aria-label"]),u(j,{active:P.value,"onUpdate:active":t[11]||(t[11]=p=>P.value=p),"has-modal-card":"","aria-modal":"","close-button-aria-label":r(a)("Close"),autoFocus:!1,width:640},{default:i(()=>[f("div",Nt,[f("section",Ft,[v.value?(n(),$(pe,{key:0,variant:"danger"},{default:i(()=>[_(c(v.value),1)]),_:1})):b("",!0),f("form",{onSubmit:se(ce,["prevent"])},[u(F,{expanded:"",label:r(a)("URL"),"label-for":"new-resource-url",variant:R.resource_url?"danger":void 0,message:R.resource_url},{default:i(()=>[u(I,{id:"new-resource-url",type:"url",required:"",expanded:"",modelValue:o.resourceUrl,"onUpdate:modelValue":t[8]||(t[8]=p=>o.resourceUrl=p),onBlur:Se,ref_key:"modalNewResourceLinkInput",ref:z},null,8,["modelValue"])]),_:1},8,["label","variant","message"]),o.title?(n(),h("div",Ot,[u(_e,{resource:o,preview:!0},null,8,["resource"])])):b("",!0),u(F,{label:r(a)("Title"),"label-for":"new-resource-link-title",variant:R.title?"danger":void 0,message:R.title},{default:i(()=>[u(I,{"aria-required":"true",modelValue:o.title,"onUpdate:modelValue":t[9]||(t[9]=p=>o.title=p),id:"new-resource-link-title",expanded:""},null,8,["modelValue"])]),_:1},8,["label","variant","message"]),u(F,{label:r(a)("Description"),"label-for":"new-resource-summary",variant:R.summary?"danger":void 0,message:R.summary},{default:i(()=>[u(I,{type:"textarea",modelValue:o.summary,"onUpdate:modelValue":t[10]||(t[10]=p=>o.summary=p),id:"new-resource-summary",expanded:""},null,8,["modelValue"])]),_:1},8,["label","variant","message"]),u(D,{type:"submit",class:"mt-2"},{default:i(()=>[_(c(r(a)("Create resource")),1)]),_:1})],32)])])]),_:1},8,["active","close-button-aria-label"])])):b("",!0)}}}),Kt=ie(It,[["__scopeId","data-v-0f90794c"]]);export{Kt as default};
2//# sourceMappingURL=ResourceFolder-BCpUtcIq.js.map

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.