ode-explorer 1.0.2-dev.202309271434 → 1.0.2-dev.202309271551

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{u as d,D as u,E as x,G as p,o as m,A as j,a as f,j as e,M as n,B as i}from"./index.js";import"/assets/js/edifice-ts-client/index.js";function y({onSuccess:o}){const{t:l}=d(),s=u(),t=x(),r=p(),{hotToast:a}=m(j);async function c(){try{r?(await s.mutate(),a.success(l("explorer.removed.from.trash"))):(await t.mutate(),a.success(l("explorer.trash.title"))),o==null||o()}catch(h){console.error(h)}}return{isTrashFolder:r,onDelete:c}}function T({isOpen:o,onSuccess:l=()=>({}),onCancel:s=()=>({})}){const{t}=d(),{isTrashFolder:r,onDelete:a}=y({onSuccess:l});return f.createPortal(e.jsxs(n,{isOpen:o,onModalClose:s,id:"deleteModal",children:[e.jsx(n.Header,{onModalClose:s,children:t(r?"explorer.delete.title":"explorer.trash.title")}),e.jsx(n.Body,{children:e.jsx("p",{className:"body",children:t(r?"explorer.delete.subtitle":"explorer.trash.subtitle")})}),e.jsxs(n.Footer,{children:[e.jsx(i,{color:"tertiary",onClick:s,type:"button",variant:"ghost",children:t("explorer.cancel")}),e.jsx(i,{color:"danger",onClick:a,type:"button",variant:"filled",children:t(r?"explorer.delete":"explorer.trash")})]})]}),document.getElementById("portal"))}export{T as default};
1
+ import{u as d,D as h,E as u,G as x,o as p,A as m,a as j,j as e,M as n,B as i}from"./index.js";import"/assets/js/edifice-ts-client/index.js";function f({onSuccess:o}){const{t:l}=d(),s=h(),t=u(),r=x(),{hotToast:a}=p(m);async function c(){try{r?(await s.mutate(),a.success(l("explorer.removed.from.trash"))):(await t.mutate(),a.success(l("explorer.trash.title"))),o==null||o()}catch{}}return{isTrashFolder:r,onDelete:c}}function T({isOpen:o,onSuccess:l=()=>({}),onCancel:s=()=>({})}){const{t}=d(),{isTrashFolder:r,onDelete:a}=f({onSuccess:l});return j.createPortal(e.jsxs(n,{isOpen:o,onModalClose:s,id:"deleteModal",children:[e.jsx(n.Header,{onModalClose:s,children:t(r?"explorer.delete.title":"explorer.trash.title")}),e.jsx(n.Body,{children:e.jsx("p",{className:"body",children:t(r?"explorer.delete.subtitle":"explorer.trash.subtitle")})}),e.jsxs(n.Footer,{children:[e.jsx(i,{color:"tertiary",onClick:s,type:"button",variant:"ghost",children:t("explorer.cancel")}),e.jsx(i,{color:"danger",onClick:a,type:"button",variant:"filled",children:t(r?"explorer.delete":"explorer.trash")})]})]}),document.getElementById("portal"))}export{T as default};
@@ -1 +1 @@
1
- import{J as D,P as B,Q as q,U as L,r as C,u as R,a as U,j as r,M as s,F as w,W as P,y as T,B as b}from"./index.js";import{FOLDER as V}from"/assets/js/edifice-ts-client/index.js";import{u as _}from"./index.esm.js";function k({edit:a,onSuccess:e,onClose:i}){var F;const l=D(),t=B(),m=q(),c=L(),u=a?(F=l[0])==null?void 0:F.name:void 0,{reset:o,register:f,handleSubmit:n,setFocus:p,formState:{errors:x,isSubmitting:h,isDirty:I,isValid:E}}=_({mode:"onChange",values:{name:u||""}}),g=C.useId(),M=async function({name:j}){var y;try{if(a){const d=(y=l[0])==null?void 0:y.parentId,$=l[0].id;await c.mutate({folderId:$,parentId:d,name:j}),o(),e==null||e()}else{const d=(t==null?void 0:t.id)||V.DEFAULT;await m.mutate({name:j,parentId:d}),o(),e==null||e()}}catch(d){console.error(d)}};function v(){o(),i()}return{formId:`createModal_${g}`,errors:x,isSubmitting:h,isDirty:I,isValid:E,register:f,setFocus:p,handleSubmit:n,onCancel:v,onSubmit:M}}function W({isOpen:a,edit:e,onSuccess:i,onCancel:l}){const{t}=R(),{isDirty:m,isValid:c,isSubmitting:u,formId:o,onSubmit:f,onCancel:n,handleSubmit:p,register:x,setFocus:h}=k({edit:e,onSuccess:i,onClose:l});return C.useEffect(()=>{a&&h("name")},[a]),U.createPortal(r.jsxs(s,{isOpen:a,onModalClose:n,id:"modal_"+o,children:[r.jsx(s.Header,{onModalClose:n,children:t(e?"explorer.rename.folder":"explorer.create.folder")}),r.jsx(s.Body,{children:r.jsx("form",{id:o,onSubmit:p(f),children:r.jsxs(w,{id:"nameFolder",isRequired:!0,children:[r.jsx(P,{children:t("explorer.create.folder.name")}),r.jsx(T,{type:"text",...x("name",{required:!0,pattern:{value:/[^ ]/,message:"invalid title"}}),placeholder:t("explorer.create.folder.name"),size:"md","aria-required":!0})]})})}),r.jsxs(s.Footer,{children:[r.jsx(b,{color:"tertiary",onClick:n,type:"button",variant:"ghost",children:t("explorer.cancel")}),r.jsx(b,{form:o,type:"submit",color:"primary",variant:"filled",disabled:!m||!c||u,children:t(e?"explorer.rename":"explorer.create")})]})]}),document.getElementById("portal"))}export{W as default};
1
+ import{J as D,P as B,Q as q,U as L,r as C,u as R,a as U,j as r,M as s,F as w,W as P,y as T,B as b}from"./index.js";import{FOLDER as V}from"/assets/js/edifice-ts-client/index.js";import{u as _}from"./index.esm.js";function k({edit:a,onSuccess:e,onClose:i}){var F;const l=D(),t=B(),m=q(),c=L(),u=a?(F=l[0])==null?void 0:F.name:void 0,{reset:o,register:f,handleSubmit:n,setFocus:p,formState:{errors:x,isSubmitting:h,isDirty:I,isValid:E}}=_({mode:"onChange",values:{name:u||""}}),g=C.useId(),M=async function({name:j}){var y;try{if(a){const d=(y=l[0])==null?void 0:y.parentId,$=l[0].id;await c.mutate({folderId:$,parentId:d,name:j}),o(),e==null||e()}else{const d=(t==null?void 0:t.id)||V.DEFAULT;await m.mutate({name:j,parentId:d}),o(),e==null||e()}}catch{}};function v(){o(),i()}return{formId:`createModal_${g}`,errors:x,isSubmitting:h,isDirty:I,isValid:E,register:f,setFocus:p,handleSubmit:n,onCancel:v,onSubmit:M}}function W({isOpen:a,edit:e,onSuccess:i,onCancel:l}){const{t}=R(),{isDirty:m,isValid:c,isSubmitting:u,formId:o,onSubmit:f,onCancel:n,handleSubmit:p,register:x,setFocus:h}=k({edit:e,onSuccess:i,onClose:l});return C.useEffect(()=>{a&&h("name")},[a]),U.createPortal(r.jsxs(s,{isOpen:a,onModalClose:n,id:"modal_"+o,children:[r.jsx(s.Header,{onModalClose:n,children:t(e?"explorer.rename.folder":"explorer.create.folder")}),r.jsx(s.Body,{children:r.jsx("form",{id:o,onSubmit:p(f),children:r.jsxs(w,{id:"nameFolder",isRequired:!0,children:[r.jsx(P,{children:t("explorer.create.folder.name")}),r.jsx(T,{type:"text",...x("name",{required:!0,pattern:{value:/[^ ]/,message:"invalid title"}}),placeholder:t("explorer.create.folder.name"),size:"md","aria-required":!0})]})})}),r.jsxs(s.Footer,{children:[r.jsx(b,{color:"tertiary",onClick:n,type:"button",variant:"ghost",children:t("explorer.cancel")}),r.jsx(b,{form:o,type:"submit",color:"primary",variant:"filled",disabled:!m||!c||u,children:t(e?"explorer.rename":"explorer.create")})]})]}),document.getElementById("portal"))}export{W as default};
@@ -1 +1 @@
1
- import{u as B,j as e,A as V,F as g,y as H,X as ne,B as A,Y as ce,d as U,m as de,Z as ue,l as G,h as pe,r as x,P as me,o as he,N as xe,$ as ge,a as be,M as C,W as O,a0 as fe}from"./index.js";import{APP as Q}from"/assets/js/edifice-ts-client/index.js";import{H as K}from"./Heading.js";import{u as je}from"./index.esm.js";import{I as ve,T as ye}from"./TextArea.js";const Se=({appCode:r,correctSlug:l,disableSlug:o,onPublicChange:c,onSlugChange:m,refPublic:d,refSlug:v,register:t,resource:u,slug:h,onCopyToClipBoard:b})=>{const{t:i}=B();return e.jsxs(e.Fragment,{children:[e.jsxs(K,{headingStyle:"h4",level:"h3",className:"mb-16",children:[i("explorer.resource.editModal.heading.access"),r]}),e.jsx(V,{type:"info",children:i("explorer.resource.editModal.access.alert")}),e.jsxs(g,{id:"flexSwitchCheckDefault",className:"form-switch d-flex gap-8 mt-16 mb-8",children:[e.jsx(g.Input,{type:"checkbox",role:"switch",...t("enablePublic",{value:u&&u.public,onChange:n=>c(n.target.checked)}),className:"form-check-input mt-0",size:"md"},d),e.jsx(g.Label,{className:"form-check-label mb-0",children:i("explorer.resource.editModal.access.flexSwitchCheckDefault.label")})]}),e.jsx(g,{id:"slug",status:l?"invalid":void 0,children:e.jsxs("div",{className:"d-flex flex-wrap align-items-center gap-4",children:[e.jsxs("div",{children:[window.location.origin,window.location.pathname,"/pub/"]}),e.jsxs("div",{className:"flex-fill",children:[e.jsx(H,{type:"text",...t("safeSlug",{validate:{required:n=>!n&&!o?i("explorer.slug.name.mandatory"):!0},disabled:o,value:h,onChange:n=>m(n.target.value)}),size:"md",placeholder:i("explorer.resource.editModal.access.url.extension")},v),l&&e.jsx("div",{className:"position-absolute",children:e.jsx(ne,{children:i("explorer.slug.name.error")})})]}),e.jsx(A,{color:"primary",disabled:o,onClick:()=>{b()},type:"button",leftIcon:e.jsx(ce,{}),variant:"ghost",className:"text-nowrap",children:i("explorer.resource.editModal.access.url.button")})]})})]})};function Ce({resource:r,edit:l,onSuccess:o,onCancel:c}){var _;const{appCode:m}=U(),{t:d}=B(),v=de(),t=ue(),u=G(),h=pe(),{reset:b,register:i,handleSubmit:n,setFocus:w,formState:{errors:I,isSubmitting:f,isValid:$}}=je({mode:"onChange"}),M=x.useId(),p=me(),[P,N]=x.useState(new Date().getTime()),[k,R]=x.useState(!(r!=null&&r.public)),[y,a]=x.useState((r==null?void 0:r.slug)||""),[W,E]=x.useState(!1),{hotToast:F}=he(V),[L,q]=x.useState({name:"",image:(_=u[0])==null?void 0:_.thumbnail}),X=s=>{q(s)},Y=()=>{q({name:"",image:""})};function Z(s){R(!s),s||(a(""),N(new Date().getTime()))}function D(s){if(!s)return"";const j="àáäâãåăæçèéëêǵḧìíïîḿńǹñòóöôœøṕŕßśșțùúüûǘẃẍÿź·/_,:;",S="aaaaaaaaceeeeghiiiimnnnooooooprssstuuuuuwxyz------",T=new RegExp(j.split("").join("|"),"g"),re=s.toString().toLowerCase().replace(/\s+/g,"-").replace(T,oe=>S.charAt(j.indexOf(oe))).replace(/&/g,"-and-").replace(/[^\w\\-]+/g,"").replace(/\\-\\-+/g,"-").replace(/^-+/,"").replace(/-+$/,"");a(re)}const J=xe(),{filters:z,trashed:ee}=h,se=["context",{folderId:z.folder,filters:z,trashed:ee}],te=async function(s){var j,S;try{l?(await v.mutateAsync({description:s.description||"",entId:(j=u[0])==null?void 0:j.assetId,name:s.title,public:s.enablePublic,slug:s.safeSlug,trashed:(S=u[0])==null?void 0:S.trashed,thumbnail:L.image}),E(!1)):(J.invalidateQueries(se),t.mutateAsync({name:s.title,description:s.description||"",thumbnail:L.image,folder:(p==null?void 0:p.id)==="default"?void 0:parseInt((p==null?void 0:p.id)||""),public:s.enablePublic,slug:s.safeSlug,app:m})),F.success(e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:d("explorer.resource.updated")}),e.jsxs("p",{children:["Titre: ",s.title]}),e.jsxs("p",{children:["Description: ",s.description]}),l&&m===Q.BLOG&&e.jsxs("p",{children:["Public:"," ",s.enablePublic?d("explorer.enable.public.yes"):d("explorer.enable.public.no")]})]})),o==null||o()}catch(T){E(!0),console.error(T)}};function ae(){navigator.clipboard.writeText(`${window.location.origin}${window.location.pathname}/pub/${y}`),F.success(d("explorer.copy.clipboard"))}function le(){b(),c()}const ie=`resource_edit_modal_${M}`;return{slug:y,disableSlug:k,formId:ie,errors:I,isSubmitting:f,isValid:$,versionSlug:P,correctSlug:W,onPublicChange:Z,onSlugChange:D,register:i,setFocus:w,handleSubmit:n,onFormCancel:le,onSubmit:te,handleUploadImage:X,handleDeleteImage:Y,onCopyToClipBoard:ae}}function Ne({isOpen:r,edit:l,onSuccess:o,onCancel:c}){const{appCode:m,currentApp:d}=U(),t=G()[0],{slug:u,formId:h,isValid:b,isSubmitting:i,disableSlug:n,versionSlug:w,correctSlug:I,register:f,handleSubmit:$,onSubmit:M,handleUploadImage:p,handleDeleteImage:P,onCopyToClipBoard:N,onSlugChange:k,onPublicChange:R}=Ce({resource:t,edit:l,onSuccess:o,onCancel:c}),{data:y}=ge(),{t:a}=B();return be.createPortal(e.jsxs(C,{id:"resource_edit_modal",size:"lg",isOpen:r,onModalClose:c,children:[e.jsx(C.Header,{onModalClose:c,children:a(l?"explorer.resource.editModal.header.edit":"explorer.resource.editModal.header.create")}),e.jsxs(C.Body,{children:[e.jsx(K,{headingStyle:"h4",level:"h3",className:"mb-16",children:a("explorer.resource.editModal.heading.general")}),e.jsxs("form",{id:h,onSubmit:$(M),children:[e.jsxs("div",{className:"d-flex gap-16 mb-24",children:[e.jsx("div",{children:e.jsx(ve,{app:d,src:t==null?void 0:t.thumbnail,label:a("explorer.imagepicker.label"),addButtonLabel:a("explorer.imagepicker.button.add"),deleteButtonLabel:a("explorer.imagepicker.button.delete"),onUploadImage:p,onDeleteImage:P,className:"align-self-center mt-8"})}),e.jsxs("div",{className:"col",children:[e.jsxs(g,{id:"title",className:"mb-16",isRequired:!0,children:[e.jsx(O,{children:a("title")}),e.jsx(H,{type:"text",defaultValue:l?t==null?void 0:t.name:"",...f("title",{required:!0,pattern:{value:/[^ ]/,message:"invalid title"}}),placeholder:a("explorer.resource.editModal.title.placeholder"),size:"md","aria-required":!0})]}),e.jsxs(g,{id:"description",isOptional:!0,children:[e.jsx(O,{children:a("description")}),e.jsx(ye,{defaultValue:l?t==null?void 0:t.description:"",...f("description"),placeholder:a("explorer.resource.editModal.description.placeholder"),size:"md"})]})]})]}),m===Q.BLOG&&fe({workflow:"createPublic",actions:y})&&e.jsx(Se,{appCode:m,correctSlug:I,disableSlug:n,onCopyToClipBoard:N,onPublicChange:R,onSlugChange:k,resource:t,slug:u,versionSlug:w,register:f})]})]}),e.jsxs(C.Footer,{children:[e.jsx(A,{color:"tertiary",onClick:c,type:"button",variant:"ghost",children:a("explorer.cancel")}),e.jsx(A,{form:h,type:"submit",color:"primary",variant:"filled",disabled:!b||i,children:a(l?"save":"explorer.create")})]})]}),document.getElementById("portal"))}export{Ne as default};
1
+ import{u as A,j as e,A as V,F as g,y as H,X as ne,B as T,Y as ce,d as U,m as de,Z as ue,l as G,h as pe,r as x,P as me,o as he,N as xe,$ as ge,a as be,M as C,W as O,a0 as fe}from"./index.js";import{APP as Q}from"/assets/js/edifice-ts-client/index.js";import{H as K}from"./Heading.js";import{u as je}from"./index.esm.js";import{I as ve,T as ye}from"./TextArea.js";const Se=({appCode:r,correctSlug:l,disableSlug:o,onPublicChange:c,onSlugChange:m,refPublic:d,refSlug:v,register:t,resource:u,slug:h,onCopyToClipBoard:b})=>{const{t:i}=A();return e.jsxs(e.Fragment,{children:[e.jsxs(K,{headingStyle:"h4",level:"h3",className:"mb-16",children:[i("explorer.resource.editModal.heading.access"),r]}),e.jsx(V,{type:"info",children:i("explorer.resource.editModal.access.alert")}),e.jsxs(g,{id:"flexSwitchCheckDefault",className:"form-switch d-flex gap-8 mt-16 mb-8",children:[e.jsx(g.Input,{type:"checkbox",role:"switch",...t("enablePublic",{value:u&&u.public,onChange:n=>c(n.target.checked)}),className:"form-check-input mt-0",size:"md"},d),e.jsx(g.Label,{className:"form-check-label mb-0",children:i("explorer.resource.editModal.access.flexSwitchCheckDefault.label")})]}),e.jsx(g,{id:"slug",status:l?"invalid":void 0,children:e.jsxs("div",{className:"d-flex flex-wrap align-items-center gap-4",children:[e.jsxs("div",{children:[window.location.origin,window.location.pathname,"/pub/"]}),e.jsxs("div",{className:"flex-fill",children:[e.jsx(H,{type:"text",...t("safeSlug",{validate:{required:n=>!n&&!o?i("explorer.slug.name.mandatory"):!0},disabled:o,value:h,onChange:n=>m(n.target.value)}),size:"md",placeholder:i("explorer.resource.editModal.access.url.extension")},v),l&&e.jsx("div",{className:"position-absolute",children:e.jsx(ne,{children:i("explorer.slug.name.error")})})]}),e.jsx(T,{color:"primary",disabled:o,onClick:()=>{b()},type:"button",leftIcon:e.jsx(ce,{}),variant:"ghost",className:"text-nowrap",children:i("explorer.resource.editModal.access.url.button")})]})})]})};function Ce({resource:r,edit:l,onSuccess:o,onCancel:c}){var z;const{appCode:m}=U(),{t:d}=A(),v=de(),t=ue(),u=G(),h=pe(),{reset:b,register:i,handleSubmit:n,setFocus:w,formState:{errors:I,isSubmitting:f,isValid:$}}=je({mode:"onChange"}),M=x.useId(),p=me(),[P,N]=x.useState(new Date().getTime()),[k,R]=x.useState(!(r!=null&&r.public)),[y,a]=x.useState((r==null?void 0:r.slug)||""),[W,B]=x.useState(!1),{hotToast:E}=he(V),[F,L]=x.useState({name:"",image:(z=u[0])==null?void 0:z.thumbnail}),X=s=>{L(s)},Y=()=>{L({name:"",image:""})};function Z(s){R(!s),s||(a(""),N(new Date().getTime()))}function D(s){if(!s)return"";const j="àáäâãåăæçèéëêǵḧìíïîḿńǹñòóöôœøṕŕßśșțùúüûǘẃẍÿź·/_,:;",S="aaaaaaaaceeeeghiiiimnnnooooooprssstuuuuuwxyz------",_=new RegExp(j.split("").join("|"),"g"),re=s.toString().toLowerCase().replace(/\s+/g,"-").replace(_,oe=>S.charAt(j.indexOf(oe))).replace(/&/g,"-and-").replace(/[^\w\\-]+/g,"").replace(/\\-\\-+/g,"-").replace(/^-+/,"").replace(/-+$/,"");a(re)}const J=xe(),{filters:q,trashed:ee}=h,se=["context",{folderId:q.folder,filters:q,trashed:ee}],te=async function(s){var j,S;try{l?(await v.mutateAsync({description:s.description||"",entId:(j=u[0])==null?void 0:j.assetId,name:s.title,public:s.enablePublic,slug:s.safeSlug,trashed:(S=u[0])==null?void 0:S.trashed,thumbnail:F.image}),B(!1)):(J.invalidateQueries(se),t.mutateAsync({name:s.title,description:s.description||"",thumbnail:F.image,folder:(p==null?void 0:p.id)==="default"?void 0:parseInt((p==null?void 0:p.id)||""),public:s.enablePublic,slug:s.safeSlug,app:m})),E.success(e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:d("explorer.resource.updated")}),e.jsxs("p",{children:["Titre: ",s.title]}),e.jsxs("p",{children:["Description: ",s.description]}),l&&m===Q.BLOG&&e.jsxs("p",{children:["Public:"," ",s.enablePublic?d("explorer.enable.public.yes"):d("explorer.enable.public.no")]})]})),o==null||o()}catch{B(!0)}};function ae(){navigator.clipboard.writeText(`${window.location.origin}${window.location.pathname}/pub/${y}`),E.success(d("explorer.copy.clipboard"))}function le(){b(),c()}const ie=`resource_edit_modal_${M}`;return{slug:y,disableSlug:k,formId:ie,errors:I,isSubmitting:f,isValid:$,versionSlug:P,correctSlug:W,onPublicChange:Z,onSlugChange:D,register:i,setFocus:w,handleSubmit:n,onFormCancel:le,onSubmit:te,handleUploadImage:X,handleDeleteImage:Y,onCopyToClipBoard:ae}}function Ne({isOpen:r,edit:l,onSuccess:o,onCancel:c}){const{appCode:m,currentApp:d}=U(),t=G()[0],{slug:u,formId:h,isValid:b,isSubmitting:i,disableSlug:n,versionSlug:w,correctSlug:I,register:f,handleSubmit:$,onSubmit:M,handleUploadImage:p,handleDeleteImage:P,onCopyToClipBoard:N,onSlugChange:k,onPublicChange:R}=Ce({resource:t,edit:l,onSuccess:o,onCancel:c}),{data:y}=ge(),{t:a}=A();return be.createPortal(e.jsxs(C,{id:"resource_edit_modal",size:"lg",isOpen:r,onModalClose:c,children:[e.jsx(C.Header,{onModalClose:c,children:a(l?"explorer.resource.editModal.header.edit":"explorer.resource.editModal.header.create")}),e.jsxs(C.Body,{children:[e.jsx(K,{headingStyle:"h4",level:"h3",className:"mb-16",children:a("explorer.resource.editModal.heading.general")}),e.jsxs("form",{id:h,onSubmit:$(M),children:[e.jsxs("div",{className:"d-flex gap-16 mb-24",children:[e.jsx("div",{children:e.jsx(ve,{app:d,src:t==null?void 0:t.thumbnail,label:a("explorer.imagepicker.label"),addButtonLabel:a("explorer.imagepicker.button.add"),deleteButtonLabel:a("explorer.imagepicker.button.delete"),onUploadImage:p,onDeleteImage:P,className:"align-self-center mt-8"})}),e.jsxs("div",{className:"col",children:[e.jsxs(g,{id:"title",className:"mb-16",isRequired:!0,children:[e.jsx(O,{children:a("title")}),e.jsx(H,{type:"text",defaultValue:l?t==null?void 0:t.name:"",...f("title",{required:!0,pattern:{value:/[^ ]/,message:"invalid title"}}),placeholder:a("explorer.resource.editModal.title.placeholder"),size:"md","aria-required":!0})]}),e.jsxs(g,{id:"description",isOptional:!0,children:[e.jsx(O,{children:a("description")}),e.jsx(ye,{defaultValue:l?t==null?void 0:t.description:"",...f("description"),placeholder:a("explorer.resource.editModal.description.placeholder"),size:"md"})]})]})]}),m===Q.BLOG&&fe({workflow:"createPublic",actions:y})&&e.jsx(Se,{appCode:m,correctSlug:I,disableSlug:n,onCopyToClipBoard:N,onPublicChange:R,onSlugChange:k,resource:t,slug:u,versionSlug:w,register:f})]})]}),e.jsxs(C.Footer,{children:[e.jsx(T,{color:"tertiary",onClick:c,type:"button",variant:"ghost",children:a("explorer.cancel")}),e.jsx(T,{form:h,type:"submit",color:"primary",variant:"filled",disabled:!b||i,children:a(l?"save":"explorer.create")})]})]}),document.getElementById("portal"))}export{Ne as default};
package/dist/MoveModal.js CHANGED
@@ -1 +1 @@
1
- import{r as I,H as v,J as T,l as M,K as y,N as j,u as b,O as F,a as S,j as o,M as n,T as w,B as h}from"./index.js";import"/assets/js/edifice-ts-client/index.js";function E({onSuccess:a}){const[s,r]=I.useState(),l=v(),d=T(),i=M(),{foldTreeItem:c,unfoldTreeItem:m}=y(),u=j();async function f(){try{if(!s)throw new Error("explorer.move.selection.empty");await l.mutate(s),await(a==null?void 0:a())}catch(e){console.error(e)}}const p=e=>{var x;for(const t of d)if(e===t.id||e===t.parentId)return!1;for(const t of i)if(e===((t==null?void 0:t.folderIds)&&t.folderIds[0])||((x=t==null?void 0:t.folderIds)==null?void 0:x.length)===0&&e==="default")return!1;return!0};return{disableSubmit:!s,handleTreeItemSelect:e=>{p(e)?r(e):r(void 0)},handleTreeItemFold:c,handleTreeItemUnfold:async e=>await m(e,u),onMove:()=>{f()}}}function C({isOpen:a,onSuccess:s,onCancel:r}){const{t:l}=b(),{handleTreeItemFold:d,handleTreeItemSelect:i,handleTreeItemUnfold:c,onMove:m,disableSubmit:u}=E({onSuccess:s}),f=F();return S.createPortal(o.jsxs(n,{isOpen:a,onModalClose:r,id:"moveModal",children:[o.jsx(n.Header,{onModalClose:r,children:l("explorer.move.title")}),o.jsx(n.Subtitle,{children:l("explorer.move.subtitle")}),o.jsx(n.Body,{children:o.jsx(w,{data:f,onTreeItemSelect:i,onTreeItemFold:d,onTreeItemUnfold:c})}),o.jsxs(n.Footer,{children:[o.jsx(h,{color:"tertiary",onClick:r,type:"button",variant:"ghost",children:l("explorer.cancel")}),o.jsx(h,{color:"primary",onClick:m,type:"button",variant:"filled",disabled:u,children:l("explorer.move")})]})]}),document.getElementById("portal"))}export{C as default};
1
+ import{r as I,H as v,J as T,l as M,K as y,N as j,u as b,O as F,a as S,j as o,M as n,T as w,B as h}from"./index.js";import"/assets/js/edifice-ts-client/index.js";function E({onSuccess:a}){const[s,r]=I.useState(),l=v(),d=T(),i=M(),{foldTreeItem:c,unfoldTreeItem:m}=y(),u=j();async function f(){try{if(!s)throw new Error("explorer.move.selection.empty");await l.mutate(s),await(a==null?void 0:a())}catch{}}const p=e=>{var x;for(const t of d)if(e===t.id||e===t.parentId)return!1;for(const t of i)if(e===((t==null?void 0:t.folderIds)&&t.folderIds[0])||((x=t==null?void 0:t.folderIds)==null?void 0:x.length)===0&&e==="default")return!1;return!0};return{disableSubmit:!s,handleTreeItemSelect:e=>{p(e)?r(e):r(void 0)},handleTreeItemFold:c,handleTreeItemUnfold:async e=>await m(e,u),onMove:()=>{f()}}}function C({isOpen:a,onSuccess:s,onCancel:r}){const{t:l}=b(),{handleTreeItemFold:d,handleTreeItemSelect:i,handleTreeItemUnfold:c,onMove:m,disableSubmit:u}=E({onSuccess:s}),f=F();return S.createPortal(o.jsxs(n,{isOpen:a,onModalClose:r,id:"moveModal",children:[o.jsx(n.Header,{onModalClose:r,children:l("explorer.move.title")}),o.jsx(n.Subtitle,{children:l("explorer.move.subtitle")}),o.jsx(n.Body,{children:o.jsx(w,{data:f,onTreeItemSelect:i,onTreeItemFold:d,onTreeItemUnfold:c})}),o.jsxs(n.Footer,{children:[o.jsx(h,{color:"tertiary",onClick:r,type:"button",variant:"ghost",children:l("explorer.cancel")}),o.jsx(h,{color:"primary",onClick:m,type:"button",variant:"filled",disabled:u,children:l("explorer.move")})]})]}),document.getElementById("portal"))}export{C as default};
@@ -1,2 +1 @@
1
- import{r as v,a1 as X,g as ee,j as e,d as Z,l as K,o as ae,K as re,a2 as D,a3 as Y,A as L,u as C,a as te,M as S,F as g,W as R,y as H,a4 as U,a5 as V,C as W,B as G,b as le}from"./index.js";import{TransportFrameworkFactory as se,RESOURCE as ie}from"/assets/js/edifice-ts-client/index.js";import{u as ce}from"./index.esm.js";import{H as $}from"./Heading.js";import{I as oe,T as ne}from"./TextArea.js";const Q=v.forwardRef(({options:a,model:t,disabled:l=!1,placeholderOption:s=!1,...u},r)=>{const{isRequired:n,status:d}=X(),m=v.useId(),x={...u,id:m,disabled:l,ref:r,className:ee(u.className,"form-select c-pointer",{"is-invalid":d==="invalid","is-valid":d==="valid"})};return e.jsx(e.Fragment,{children:e.jsxs("select",{...x,required:n,children:[s&&e.jsx("option",{disabled:!0,selected:t===void 0,children:s}),a==null?void 0:a.map(b=>{const h=typeof b=="object"?b.value:b,c=typeof b=="object"?b.label:b;return e.jsx("option",{value:h,selected:t===h,children:c},h)})]})})});Q.displayName="Select";const k=Q,{http:M}=se.instance();function be({onSuccess:a}){const{user:t,currentApp:l}=Z(),s=K(),[u,r]=v.useState({name:"",image:s[0].thumbnail}),[n,d]=v.useState(!1),{hotToast:m}=ae(L),{publishApi:x}=re(),{register:b,handleSubmit:h,formState:{errors:c,isSubmitting:O,isDirty:p,isValid:P}}=ce({mode:"onChange"}),[T,I]=v.useState([]),[y,w]=v.useState([]);function F(i){r(i)}const f=t?t==null?void 0:t.userId:"";return{selectedResources:s,register:b,handleSubmit:h,formState:{errors:c,isSubmitting:O,isDirty:p,isValid:P},publish:async i=>{try{d(!0);let j=new Blob;u.image?j=await M.get(u.image,{responseType:"blob"}):s[0].thumbnail&&(j=await M.get(s[0].thumbnail,{responseType:"blob"}));const E=await M.get(`/userbook/avatar/${f}?thumbnail=48x48`,{responseType:"blob"}),_=await M.get(`/directory/user/${f}/attachment-school`,{responseType:"json"});let A="";l!=null&&l.displayName&&(A=D(l==null?void 0:l.displayName));const o={activityType:T,age:[i.ageMin,i.ageMax],application:Y().libraryAppFilter??D(A),cover:j,description:i.description,keyWords:i.keyWords,language:i.language,licence:"CC-BY",resourceId:s[0].assetId,resourceEntId:s[0].assetId,subjectArea:y,teacherAvatar:E,title:i.title,userId:f,userStructureName:_.name||(t==null?void 0:t.structureNames[0])},N=[ie.BLOG][0],B=await x(N,o);B.success?m.success(e.jsx(pe,{result:B}),{duration:1e4}):m.error(e.jsx(J,{formData:i})),a==null||a()}catch{m.error(e.jsx(J,{formData:i}))}finally{d(!1)}},handleDeleteImage:()=>{r({name:"",image:""})},handleUploadImage:F,selectedActivities:T,setSelectedActivities:I,selectedSubjectAreas:y,setSelectedSubjectAreas:w,loaderPublish:n,cover:u}}function ue(){const{t:a}=C(),t=[{value:"bpr.activityType.classroomActivity",label:a("bpr.activityType.classroomActivity")},{value:"bpr.activityType.groupActivity",label:a("bpr.activityType.groupActivity")},{value:"bpr.activityType.personalActivity",label:a("bpr.activityType.personalActivity")},{value:"bpr.activityType.homework",label:a("bpr.activityType.homework")},{value:"bpr.activityType.exercize",label:a("bpr.activityType.exercize")},{value:"bpr.activityType.learningPath",label:a("bpr.activityType.learningPath")},{value:"bpr.activityType.courseElement",label:a("bpr.activityType.courseElement")},{value:"bpr.other",label:a("bpr.other")}],l=[{value:"bpr.subjectArea.artActivity",label:a("bpr.subjectArea.artActivity")},{value:"bpr.subjectArea.readLearning",label:a("bpr.subjectArea.readLearning")},{value:"bpr.subjectArea.chemistry",label:a("bpr.subjectArea.chemistry")},{value:"bpr.subjectArea.law",label:a("bpr.subjectArea.law")},{value:"bpr.subjectArea.worldDiscovery",label:a("bpr.subjectArea.worldDiscovery")},{value:"bpr.subjectArea.economy",label:a("bpr.subjectArea.economy")},{value:"bpr.subjectArea.mediaEducation",label:a("bpr.subjectArea.mediaEducation")},{value:"bpr.subjectArea.musicEducation",label:a("bpr.subjectArea.musicEducation")},{value:"bpr.subjectArea.sportEducation",label:a("bpr.subjectArea.sportEducation")},{value:"bpr.subjectArea.citizenshipEducation",label:a("bpr.subjectArea.citizenshipEducation")},{value:"bpr.subjectArea.geography",label:a("bpr.subjectArea.geography")},{value:"bpr.subjectArea.history",label:a("bpr.subjectArea.history")},{value:"bpr.subjectArea.artHistory",label:a("bpr.subjectArea.artHistory")},{value:"bpr.subjectArea.ComputerScience",label:a("bpr.subjectArea.ComputerScience")},{value:"bpr.subjectArea.languages",label:a("bpr.subjectArea.languages")},{value:"bpr.subjectArea.italian",label:a("bpr.subjectArea.italian")},{value:"bpr.subjectArea.spanish",label:a("bpr.subjectArea.spanish")},{value:"bpr.subjectArea.french",label:a("bpr.subjectArea.french")},{value:"bpr.subjectArea.german",label:a("bpr.subjectArea.german")},{value:"bpr.subjectArea.english",label:a("bpr.subjectArea.english")},{value:"bpr.subjectArea.ancientLanguages",label:a("bpr.subjectArea.ancientLanguages")},{value:"bpr.subjectArea.literature",label:a("bpr.subjectArea.literature")},{value:"bpr.subjectArea.mathematics",label:a("bpr.subjectArea.mathematics")},{value:"bpr.subjectArea.vocationalGuidance",label:a("bpr.subjectArea.vocationalGuidance")},{value:"bpr.subjectArea.philosohppy",label:a("bpr.subjectArea.philosohppy")},{value:"bpr.subjectArea.physics",label:a("bpr.subjectArea.physics")},{value:"bpr.subjectArea.politicalSscience",label:a("bpr.subjectArea.politicalSscience")},{value:"bpr.subjectArea.sociology",label:a("bpr.subjectArea.sociology")},{value:"bpr.subjectArea.biology",label:a("bpr.subjectArea.biology")},{value:"bpr.subjectArea.geology",label:a("bpr.subjectArea.geology")},{value:"bpr.subjectArea.technology",label:a("bpr.subjectArea.technology")},{value:"bpr.other",label:a("bpr.other")}],s=[{value:"de_DE",label:a("de_DE")},{value:"en_EN",label:a("en_EN")},{value:"ar_DZ",label:a("ar_DZ")},{value:"es_ES",label:a("es_ES")},{value:"fr_FR",label:a("fr_FR")},{value:"it_IT",label:a("it_IT")},{value:"ja_JP",label:a("ja_JP")},{value:"zh_CN",label:a("zh_CN")},{value:"pt_PT",label:a("pt_PT")},{value:"ru_RU",label:a("ru_RU")},{value:"bpr.other",label:a("bpr.other")}];return{activityTypeOptions:t,subjectAreaOptions:l,languageOptions:s,ageOptions:["3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18"]}}function ve({isOpen:a,onSuccess:t,onCancel:l}){var _,A;const{currentApp:s}=Z(),[u]=le(),{t:r}=C(),{register:n,handleSubmit:d,publish:m,formState:{isDirty:x,isValid:b},handleUploadImage:h,selectedActivities:c,setSelectedActivities:O,selectedSubjectAreas:p,setSelectedSubjectAreas:P,handleDeleteImage:T,loaderPublish:I,cover:y}=be({onSuccess:t}),w=K(),{activityTypeOptions:F,subjectAreaOptions:f,languageOptions:z,ageOptions:q}=ue(),i=r("bpr.form.publication.language"),j=r("bpr.form.publication.age.min"),E=r("bpr.form.publication.age.max");return te.createPortal(e.jsxs(S,{isOpen:a,onModalClose:l,id:"libraryModal",size:"lg",children:[e.jsx(S.Header,{onModalClose:l,children:r("bpr.publish")}),e.jsx(S.Subtitle,{children:r("bpr.form.tip")}),e.jsxs(S.Body,{children:[e.jsx($,{headingStyle:"h4",level:"h3",className:"mb-16",children:r("bpr.form.publication.heading.general")}),e.jsxs("form",{id:"libraryModalForm",onSubmit:d(m),children:[e.jsxs("div",{className:"d-flex mb-24 gap-24",children:[e.jsxs("div",{style:{maxWidth:"160px"},children:[e.jsx("div",{className:"form-label",children:r("bpr.form.publication.cover.title")}),e.jsx(oe,{app:Y().libraryAppFilter??s,src:(_=w[0])==null?void 0:_.thumbnail,label:r("bpr.form.publication.cover.upload.label"),addButtonLabel:r("bpr.form.publication.cover.upload.add"),deleteButtonLabel:r("bpr.form.publication.cover.upload.remove"),onUploadImage:h,onDeleteImage:T,className:"align-self-center"}),!y.image&&e.jsx("p",{className:"form-text is-invalid",children:e.jsx("em",{children:r("bpr.form.publication.cover.upload.required.image")})})]}),e.jsxs("div",{className:"flex-fill",children:[e.jsxs(g,{id:"title",className:"mb-16",isRequired:!0,children:[e.jsx(R,{children:r("bpr.form.publication.title")}),e.jsx(H,{type:"text",defaultValue:(A=w[0])==null?void 0:A.name,...n("title",{required:!0}),placeholder:r("bpr.form.publication.title.placeholder"),size:"md","aria-required":!0})]}),e.jsxs(g,{id:"description",isRequired:!0,children:[e.jsx(R,{children:r("bpr.form.publication.description")}),e.jsx(ne,{...n("description",{required:!0}),placeholder:r("bpr.form.publication.description.placeholder"),size:"md"})]})]})]}),e.jsx("hr",{}),e.jsx($,{headingStyle:"h4",level:"h3",className:"mb-16",children:r("bpr.form.publication.heading.infos")}),e.jsxs("div",{className:"d-flex flex-column flex-md-row gap-16 row mb-24",children:[e.jsx("div",{className:"col d-flex",children:e.jsx(U,{trigger:e.jsx(V,{title:r("bpr.form.publication.type"),size:"md",grow:!0,badgeContent:c==null?void 0:c.length}),content:e.jsx(W,{options:F,model:c,onChange:o=>O(o)})})}),e.jsx("div",{className:"col d-flex",children:e.jsx(U,{trigger:e.jsx(V,{title:r("bpr.form.publication.discipline"),size:"md",grow:!0,badgeContent:p==null?void 0:p.length}),content:e.jsx(W,{options:f,model:p,onChange:o=>P(o)})})}),e.jsx("div",{className:"col",children:e.jsx(g,{id:"language",isRequired:!0,children:e.jsx(k,{...n("language",{required:!0,validate:o=>o!==i}),options:z,placeholderOption:i,defaultValue:i,"aria-required":!0})})})]}),e.jsxs("div",{className:"mb-24",children:[e.jsx("label",{htmlFor:"",className:"form-label",children:r("bpr.form.publication.age")}),e.jsxs("div",{className:"d-flex",children:[e.jsx("div",{className:"me-16",children:e.jsx(g,{id:"ageMin",isRequired:!0,children:e.jsx(k,{...n("ageMin",{required:!0,validate:(o,N)=>parseInt(o)<=parseInt(N.ageMax)}),options:q,placeholderOption:j,defaultValue:j,"aria-required":!0})})}),e.jsx("div",{children:e.jsx(g,{id:"ageMax",isRequired:!0,children:e.jsx(k,{...n("ageMax",{required:!0,validate:(o,N)=>parseInt(o)>=parseInt(N.ageMin)}),options:q,placeholderOption:E,defaultValue:E,"aria-required":!0})})})]})]}),e.jsx("div",{className:"mb-24",children:e.jsxs(g,{id:"keywords",isOptional:!0,children:[e.jsx(R,{children:r("bpr.form.publication.keywords")}),e.jsx(H,{type:"text",...n("keyWords"),size:"md",placeholder:r("bpr.form.publication.keywords.placeholder")})]})}),e.jsx("hr",{}),e.jsx($,{headingStyle:"h4",level:"h3",className:"mb-16",children:r("bpr.form.publication.licence.text")}),e.jsxs("ul",{className:"mb-12",children:[e.jsxs("li",{children:[r("bpr.form.publication.licence.text.1"),e.jsx("img",{className:"ms-8 d-inline-block",src:`${u}/image-cc-by-nc-sa.svg`,alt:`Icone licence Creative
2
- Commons`})]}),e.jsx("li",{children:r("bpr.form.publication.licence.text.2")})]}),e.jsx(L,{type:"info",className:"mb-12",children:r("bpr.form.publication.licence.text.3")}),e.jsx(L,{type:"warning",children:r("bpr.form.publication.licence.text.4")})]})]}),e.jsxs(S.Footer,{children:[e.jsx(G,{color:"tertiary",onClick:l,type:"button",variant:"ghost",children:r("cancel")}),e.jsx(G,{form:"libraryModalForm",type:"submit",color:"primary",variant:"filled",isLoading:I,disabled:!y.image||I||!x||!b||(c==null?void 0:c.length)===0||(p==null?void 0:p.length)===0,children:r("bpr.form.submit")})]})]}),document.getElementById("portal"))}function pe({result:a}){const{t}=C();return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"pt-24",children:t("bpr.form.publication.response.success.title")}),e.jsx("p",{className:"pt-24",children:t("bpr.form.publication.response.success.content.1")}),e.jsx("p",{className:"pt-24",children:t("bpr.form.publication.response.success.content.2")}),a.details.front_url&&e.jsx("p",{className:"pt-24 pb-24",children:e.jsx("a",{className:"button right-magnet",href:a.details.front_url,target:"_blank",rel:"noreferrer",children:t("bpr.form.publication.response.success.button")})})]})}function J({formData:a}){const{t}=C(),l=s=>s.match(/^\s/);return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"pt-24",children:t("bpr.form.publication.response.error.title")}),e.jsx("p",{className:"pt-24 pb-24",children:e.jsx("strong",{children:t("bpr.form.publication.response.error.content")})}),e.jsxs("ul",{children:[l(a.title)&&e.jsx("li",{className:"pt-2 pb-2",children:e.jsx("strong",{children:t("bpr.form.publication.response.empty.title")})}),l(a.description)&&e.jsx("li",{className:"pt-2 pb-2",children:e.jsx("strong",{children:t("bpr.form.publication.response.empty.description")})})]})]})}export{J as PublishModalError,pe as PublishModalSuccess,ve as default};
1
+ import{r as v,a1 as X,g as ee,j as e,d as Z,l as K,o as ae,K as re,a2 as D,a3 as Y,A as L,u as O,a as te,M as S,F as g,W as R,y as H,a4 as U,a5 as V,C as W,B as G,b as le}from"./index.js";import{TransportFrameworkFactory as se,RESOURCE as ie}from"/assets/js/edifice-ts-client/index.js";import{u as ce}from"./index.esm.js";import{H as $}from"./Heading.js";import{I as oe,T as ne}from"./TextArea.js";const Q=v.forwardRef(({options:a,model:t,disabled:l=!1,placeholderOption:s=!1,...p},r)=>{const{isRequired:n,status:d}=X(),m=v.useId(),x={...p,id:m,disabled:l,ref:r,className:ee(p.className,"form-select c-pointer",{"is-invalid":d==="invalid","is-valid":d==="valid"})};return e.jsx(e.Fragment,{children:e.jsxs("select",{...x,required:n,children:[s&&e.jsx("option",{disabled:!0,selected:t===void 0,children:s}),a==null?void 0:a.map(b=>{const h=typeof b=="object"?b.value:b,c=typeof b=="object"?b.label:b;return e.jsx("option",{value:h,selected:t===h,children:c},h)})]})})});Q.displayName="Select";const k=Q,{http:M}=se.instance();function be({onSuccess:a}){const{user:t,currentApp:l}=Z(),s=K(),[p,r]=v.useState({name:"",image:s[0].thumbnail}),[n,d]=v.useState(!1),{hotToast:m}=ae(L),{publishApi:x}=re(),{register:b,handleSubmit:h,formState:{errors:c,isSubmitting:P,isDirty:u,isValid:C}}=ce({mode:"onChange"}),[T,I]=v.useState([]),[y,w]=v.useState([]);function F(i){r(i)}const f=t?t==null?void 0:t.userId:"";return{selectedResources:s,register:b,handleSubmit:h,formState:{errors:c,isSubmitting:P,isDirty:u,isValid:C},publish:async i=>{try{d(!0);let j=new Blob;p.image?j=await M.get(p.image,{responseType:"blob"}):s[0].thumbnail&&(j=await M.get(s[0].thumbnail,{responseType:"blob"}));const E=await M.get(`/userbook/avatar/${f}?thumbnail=48x48`,{responseType:"blob"}),_=await M.get(`/directory/user/${f}/attachment-school`,{responseType:"json"});let A="";l!=null&&l.displayName&&(A=D(l==null?void 0:l.displayName));const o={activityType:T,age:[i.ageMin,i.ageMax],application:Y().libraryAppFilter??D(A),cover:j,description:i.description,keyWords:i.keyWords,language:i.language,licence:"CC-BY",resourceId:s[0].assetId,resourceEntId:s[0].assetId,subjectArea:y,teacherAvatar:E,title:i.title,userId:f,userStructureName:_.name||(t==null?void 0:t.structureNames[0])},N=[ie.BLOG][0],B=await x(N,o);B.success?m.success(e.jsx(ue,{result:B}),{duration:1e4}):m.error(e.jsx(J,{formData:i})),a==null||a()}catch{m.error(e.jsx(J,{formData:i}))}finally{d(!1)}},handleDeleteImage:()=>{r({name:"",image:""})},handleUploadImage:F,selectedActivities:T,setSelectedActivities:I,selectedSubjectAreas:y,setSelectedSubjectAreas:w,loaderPublish:n,cover:p}}function pe(){const{t:a}=O(),t=[{value:"bpr.activityType.classroomActivity",label:a("bpr.activityType.classroomActivity")},{value:"bpr.activityType.groupActivity",label:a("bpr.activityType.groupActivity")},{value:"bpr.activityType.personalActivity",label:a("bpr.activityType.personalActivity")},{value:"bpr.activityType.homework",label:a("bpr.activityType.homework")},{value:"bpr.activityType.exercize",label:a("bpr.activityType.exercize")},{value:"bpr.activityType.learningPath",label:a("bpr.activityType.learningPath")},{value:"bpr.activityType.courseElement",label:a("bpr.activityType.courseElement")},{value:"bpr.other",label:a("bpr.other")}],l=[{value:"bpr.subjectArea.artActivity",label:a("bpr.subjectArea.artActivity")},{value:"bpr.subjectArea.readLearning",label:a("bpr.subjectArea.readLearning")},{value:"bpr.subjectArea.chemistry",label:a("bpr.subjectArea.chemistry")},{value:"bpr.subjectArea.law",label:a("bpr.subjectArea.law")},{value:"bpr.subjectArea.worldDiscovery",label:a("bpr.subjectArea.worldDiscovery")},{value:"bpr.subjectArea.economy",label:a("bpr.subjectArea.economy")},{value:"bpr.subjectArea.mediaEducation",label:a("bpr.subjectArea.mediaEducation")},{value:"bpr.subjectArea.musicEducation",label:a("bpr.subjectArea.musicEducation")},{value:"bpr.subjectArea.sportEducation",label:a("bpr.subjectArea.sportEducation")},{value:"bpr.subjectArea.citizenshipEducation",label:a("bpr.subjectArea.citizenshipEducation")},{value:"bpr.subjectArea.geography",label:a("bpr.subjectArea.geography")},{value:"bpr.subjectArea.history",label:a("bpr.subjectArea.history")},{value:"bpr.subjectArea.artHistory",label:a("bpr.subjectArea.artHistory")},{value:"bpr.subjectArea.ComputerScience",label:a("bpr.subjectArea.ComputerScience")},{value:"bpr.subjectArea.languages",label:a("bpr.subjectArea.languages")},{value:"bpr.subjectArea.italian",label:a("bpr.subjectArea.italian")},{value:"bpr.subjectArea.spanish",label:a("bpr.subjectArea.spanish")},{value:"bpr.subjectArea.french",label:a("bpr.subjectArea.french")},{value:"bpr.subjectArea.german",label:a("bpr.subjectArea.german")},{value:"bpr.subjectArea.english",label:a("bpr.subjectArea.english")},{value:"bpr.subjectArea.ancientLanguages",label:a("bpr.subjectArea.ancientLanguages")},{value:"bpr.subjectArea.literature",label:a("bpr.subjectArea.literature")},{value:"bpr.subjectArea.mathematics",label:a("bpr.subjectArea.mathematics")},{value:"bpr.subjectArea.vocationalGuidance",label:a("bpr.subjectArea.vocationalGuidance")},{value:"bpr.subjectArea.philosohppy",label:a("bpr.subjectArea.philosohppy")},{value:"bpr.subjectArea.physics",label:a("bpr.subjectArea.physics")},{value:"bpr.subjectArea.politicalSscience",label:a("bpr.subjectArea.politicalSscience")},{value:"bpr.subjectArea.sociology",label:a("bpr.subjectArea.sociology")},{value:"bpr.subjectArea.biology",label:a("bpr.subjectArea.biology")},{value:"bpr.subjectArea.geology",label:a("bpr.subjectArea.geology")},{value:"bpr.subjectArea.technology",label:a("bpr.subjectArea.technology")},{value:"bpr.other",label:a("bpr.other")}],s=[{value:"de_DE",label:a("de_DE")},{value:"en_EN",label:a("en_EN")},{value:"ar_DZ",label:a("ar_DZ")},{value:"es_ES",label:a("es_ES")},{value:"fr_FR",label:a("fr_FR")},{value:"it_IT",label:a("it_IT")},{value:"ja_JP",label:a("ja_JP")},{value:"zh_CN",label:a("zh_CN")},{value:"pt_PT",label:a("pt_PT")},{value:"ru_RU",label:a("ru_RU")},{value:"bpr.other",label:a("bpr.other")}];return{activityTypeOptions:t,subjectAreaOptions:l,languageOptions:s,ageOptions:["3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18"]}}function ve({isOpen:a,onSuccess:t,onCancel:l}){var _,A;const{currentApp:s}=Z(),[p]=le(),{t:r}=O(),{register:n,handleSubmit:d,publish:m,formState:{isDirty:x,isValid:b},handleUploadImage:h,selectedActivities:c,setSelectedActivities:P,selectedSubjectAreas:u,setSelectedSubjectAreas:C,handleDeleteImage:T,loaderPublish:I,cover:y}=be({onSuccess:t}),w=K(),{activityTypeOptions:F,subjectAreaOptions:f,languageOptions:z,ageOptions:q}=pe(),i=r("bpr.form.publication.language"),j=r("bpr.form.publication.age.min"),E=r("bpr.form.publication.age.max");return te.createPortal(e.jsxs(S,{isOpen:a,onModalClose:l,id:"libraryModal",size:"lg",children:[e.jsx(S.Header,{onModalClose:l,children:r("bpr.publish")}),e.jsx(S.Subtitle,{children:r("bpr.form.tip")}),e.jsxs(S.Body,{children:[e.jsx($,{headingStyle:"h4",level:"h3",className:"mb-16",children:r("bpr.form.publication.heading.general")}),e.jsxs("form",{id:"libraryModalForm",onSubmit:d(m),children:[e.jsxs("div",{className:"d-flex mb-24 gap-24",children:[e.jsxs("div",{style:{maxWidth:"160px"},children:[e.jsx("div",{className:"form-label",children:r("bpr.form.publication.cover.title")}),e.jsx(oe,{app:Y().libraryAppFilter??s,src:(_=w[0])==null?void 0:_.thumbnail,label:r("bpr.form.publication.cover.upload.label"),addButtonLabel:r("bpr.form.publication.cover.upload.add"),deleteButtonLabel:r("bpr.form.publication.cover.upload.remove"),onUploadImage:h,onDeleteImage:T,className:"align-self-center"}),!y.image&&e.jsx("p",{className:"form-text is-invalid",children:e.jsx("em",{children:r("bpr.form.publication.cover.upload.required.image")})})]}),e.jsxs("div",{className:"flex-fill",children:[e.jsxs(g,{id:"title",className:"mb-16",isRequired:!0,children:[e.jsx(R,{children:r("bpr.form.publication.title")}),e.jsx(H,{type:"text",defaultValue:(A=w[0])==null?void 0:A.name,...n("title",{required:!0}),placeholder:r("bpr.form.publication.title.placeholder"),size:"md","aria-required":!0})]}),e.jsxs(g,{id:"description",isRequired:!0,children:[e.jsx(R,{children:r("bpr.form.publication.description")}),e.jsx(ne,{...n("description",{required:!0}),placeholder:r("bpr.form.publication.description.placeholder"),size:"md"})]})]})]}),e.jsx("hr",{}),e.jsx($,{headingStyle:"h4",level:"h3",className:"mb-16",children:r("bpr.form.publication.heading.infos")}),e.jsxs("div",{className:"d-flex flex-column flex-md-row gap-16 row mb-24",children:[e.jsx("div",{className:"col d-flex",children:e.jsx(U,{trigger:e.jsx(V,{title:r("bpr.form.publication.type"),size:"md",grow:!0,badgeContent:c==null?void 0:c.length}),content:e.jsx(W,{options:F,model:c,onChange:o=>P(o)})})}),e.jsx("div",{className:"col d-flex",children:e.jsx(U,{trigger:e.jsx(V,{title:r("bpr.form.publication.discipline"),size:"md",grow:!0,badgeContent:u==null?void 0:u.length}),content:e.jsx(W,{options:f,model:u,onChange:o=>C(o)})})}),e.jsx("div",{className:"col",children:e.jsx(g,{id:"language",isRequired:!0,children:e.jsx(k,{...n("language",{required:!0,validate:o=>o!==i}),options:z,placeholderOption:i,defaultValue:i,"aria-required":!0})})})]}),e.jsxs("div",{className:"mb-24",children:[e.jsx("label",{htmlFor:"",className:"form-label",children:r("bpr.form.publication.age")}),e.jsxs("div",{className:"d-flex",children:[e.jsx("div",{className:"me-16",children:e.jsx(g,{id:"ageMin",isRequired:!0,children:e.jsx(k,{...n("ageMin",{required:!0,validate:(o,N)=>parseInt(o)<=parseInt(N.ageMax)}),options:q,placeholderOption:j,defaultValue:j,"aria-required":!0})})}),e.jsx("div",{children:e.jsx(g,{id:"ageMax",isRequired:!0,children:e.jsx(k,{...n("ageMax",{required:!0,validate:(o,N)=>parseInt(o)>=parseInt(N.ageMin)}),options:q,placeholderOption:E,defaultValue:E,"aria-required":!0})})})]})]}),e.jsx("div",{className:"mb-24",children:e.jsxs(g,{id:"keywords",isOptional:!0,children:[e.jsx(R,{children:r("bpr.form.publication.keywords")}),e.jsx(H,{type:"text",...n("keyWords"),size:"md",placeholder:r("bpr.form.publication.keywords.placeholder")})]})}),e.jsx("hr",{}),e.jsx($,{headingStyle:"h4",level:"h3",className:"mb-16",children:r("bpr.form.publication.licence.text")}),e.jsxs("ul",{className:"mb-12",children:[e.jsxs("li",{children:[r("bpr.form.publication.licence.text.1"),e.jsx("img",{className:"ms-8 d-inline-block",src:`${p}/common/image-creative-commons.png`,alt:"licence creative commons"})]}),e.jsx("li",{children:r("bpr.form.publication.licence.text.2")})]}),e.jsx(L,{type:"info",className:"mb-12",children:r("bpr.form.publication.licence.text.3")}),e.jsx(L,{type:"warning",children:r("bpr.form.publication.licence.text.4")})]})]}),e.jsxs(S.Footer,{children:[e.jsx(G,{color:"tertiary",onClick:l,type:"button",variant:"ghost",children:r("cancel")}),e.jsx(G,{form:"libraryModalForm",type:"submit",color:"primary",variant:"filled",isLoading:I,disabled:!y.image||I||!x||!b||(c==null?void 0:c.length)===0||(u==null?void 0:u.length)===0,children:r("bpr.form.submit")})]})]}),document.getElementById("portal"))}function ue({result:a}){const{t}=O();return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"pt-24",children:t("bpr.form.publication.response.success.title")}),e.jsx("p",{className:"pt-24",children:t("bpr.form.publication.response.success.content.1")}),e.jsx("p",{className:"pt-24",children:t("bpr.form.publication.response.success.content.2")}),a.details.front_url&&e.jsx("p",{className:"pt-24 pb-24",children:e.jsx("a",{className:"button right-magnet",href:a.details.front_url,target:"_blank",rel:"noreferrer",children:t("bpr.form.publication.response.success.button")})})]})}function J({formData:a}){const{t}=O(),l=s=>s.match(/^\s/);return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"pt-24",children:t("bpr.form.publication.response.error.title")}),e.jsx("p",{className:"pt-24 pb-24",children:e.jsx("strong",{children:t("bpr.form.publication.response.error.content")})}),e.jsxs("ul",{children:[l(a.title)&&e.jsx("li",{className:"pt-2 pb-2",children:e.jsx("strong",{children:t("bpr.form.publication.response.empty.title")})}),l(a.description)&&e.jsx("li",{className:"pt-2 pb-2",children:e.jsx("strong",{children:t("bpr.form.publication.response.empty.description")})})]})]})}export{J as PublishModalError,ue as PublishModalSuccess,ve as default};
@@ -1 +1 @@
1
- import{r,g as G,j as e,d as ce,u as ae,h as be,i as ye,k as je,l as de,m as ve,n as Se,o as Ne,p as ee,A as we,a as Ie,M as O,V as Y,q as oe,B as L,s as ie,t as Be,v as Ae,F as Z,w as Ce,x as Re,y as Me,z as Te,C as $e}from"./index.js";import{odeServices as E,APP as Ee}from"/assets/js/edifice-ts-client/index.js";import{H as se}from"./Heading.js";import{T as Pe}from"./Tooltip.js";function Fe(){const[h,m]=r.useState(!1);r.useEffect(()=>{u()},[]);const u=r.useCallback(async()=>{const p=await E.session().isAdml();m(p)},[]);return{isAdml:h}}const he=r.forwardRef(({label:h,disabled:m=!1,checked:u=!1,indeterminate:p=!1,...d},v)=>{const f=r.useRef(null);r.useImperativeHandle(v,()=>({...f.current})),r.useEffect(()=>{f.current.indeterminate=p},[f,p]);const S=r.useId(),i={type:"checkbox",checked:u,disabled:m,ref:f,className:G(d.className,"form-check-input c-pointer"),id:S},x={...d,...i};return e.jsxs("div",{className:"form-check d-flex align-items-center gap-8",children:[e.jsx("input",{...x}),h&&e.jsx("label",{className:"form-check-label",htmlFor:x.id,children:h})]})});he.displayName="Checkbox";const ne=he,ue=r.forwardRef(({model:h,icon:m,label:u=!1,disabled:p=!1,...d},v)=>{const f=r.useMemo(()=>d.id?d.id:(Math.floor(Math.random()*999999999999)+1e12).toString(),[d.id]),i={...{type:"radio",checked:h===d.value,disabled:p,ref:v,className:G(d.className,"form-check-input c-pointer",m&&"d-none"),id:f},...d};return e.jsxs("div",{className:G("form-check d-flex align-items-center gap-8",m&&"ps-0"),children:[e.jsx("input",{...i}),m&&e.jsx("label",{htmlFor:i.id,className:G("c-pointer",h!==d.value&&"text-muted"),children:m}),!m&&u&&e.jsx("label",{className:"form-check-label",htmlFor:i.id,children:u})]})});ue.displayName="Radio";const le=ue;function Ue({radioPublicationValue:h,onRadioPublicationChange:m}){const{appCode:u}=ce(),{t:p}=ae(u);return e.jsxs(e.Fragment,{children:[e.jsx("hr",{}),e.jsx(se,{headingStyle:"h4",level:"h3",className:"mb-16",children:p("explorer.publication.steps")}),e.jsx(le,{label:p("explorer.immediat.publication"),id:"publication-now",name:"publication",value:"IMMEDIATE",model:h,onChange:d=>m(d.target.value)}),e.jsx(le,{label:p("explorer.validate.publication"),id:"publication-validate",name:"publication",value:"RESTRAINT",model:h,onChange:d=>m(d.target.value)})]})}function ze({radioPublicationValue:h,onRadioPublicationChange:m}){const{app:u}=be();return u===Ee.BLOG?e.jsx(Ue,{radioPublicationValue:h,onRadioPublicationChange:m}):e.jsx(e.Fragment,{})}function De({onSuccess:h,payloadUpdatePublishType:m}){const{appCode:u}=ce(),{t:p}=ae(),{user:d,avatar:v}=ye(),[f,S]=r.useState(r.useId()),[i,x]=r.useState({rights:[],visibleBookmarks:[],visibleGroups:[],visibleUsers:[]}),[y,N]=r.useState([]),[P,H]=r.useState(""),[w,V]=r.useState(!1),[C,W]=r.useState(""),I=je(C,500),[_,J]=r.useState([]),[R,F]=r.useState([]),[U,K]=r.useState(!1),[M,q]=r.useState(!1),{isAdml:B}=Fe(),A=de(),Q=ve(),X=Se(),{hotToast:n}=Ne(we);r.useEffect(()=>{z()},[]),r.useEffect(()=>{fe(I)},[I]);const z=r.useCallback(async()=>{var a;const t=await E.share().getActionsForApp(u);N(t);const c=await E.share().getRightsForResource(u,(a=A[0])==null?void 0:a.assetId);x(c)},[]),l=(t,c)=>{x(({rights:a,...g})=>{var te,re;const s=[...a],o=s.findIndex(k=>k.id===t.id),T=y.filter(k=>k.id===c)[0];if(s[o].actions.findIndex(k=>k.id===c)>-1){let k=s[o].actions.filter(b=>b.id!==c);const j=y.filter(b=>{var $;return($=b.requires)==null?void 0:$.includes(c)});k=k.filter(b=>!j.find($=>$.id===b.id)),s[o]={...s[o],actions:k}}else{const k=y.filter(j=>{var b;return((b=T.requires)==null?void 0:b.includes(j.id))&&!s[o].actions.find($=>$.id===j.id)});s[o]={...s[o],actions:[...s[o].actions,T,...k]}}return t.type==="sharebookmark"&&((te=s[o].users)==null||te.forEach(k=>{const j=s.findIndex(b=>b.id===k.id);s[j]={...s[j],actions:s[o].actions}}),(re=s[o].groups)==null||re.forEach(k=>{const j=s.findIndex(b=>b.id===k.id);s[j]={...s[j],actions:s[o].actions}})),{rights:s,...g}})},D=async()=>{var t;try{await Q.mutateAsync(m),await X.mutateAsync({entId:(t=A[0])==null?void 0:t.assetId,shares:i.rights}),n.success(p("explorer.shared.status.saved")),h==null||h()}catch(c){console.error("Failed to save share",c),n.error(p("explorer.shared.status.error"))}},me=t=>{x(c=>({...c,rights:i.rights.filter(a=>{var g,s;return a.id!==t.id&&!((g=t.users)!=null&&g.find(o=>o.id===a.id))&&!((s=t.groups)!=null&&s.find(o=>o.id===a.id))})}))},pe=t=>{W(t.target.value)},xe=()=>!M&&!B&&I.length>0&&R.length===0||!M&&B&&I.length>3&&R.length===0,ke=()=>B&&C.length<3,ge=()=>M&&C.length>0,fe=async t=>{var c;if(q(!0),!B&&t.length>=1||B&&t.length>=3){const a=await E.share().searchShareSubjects(u,(c=A[0])==null?void 0:c.assetId,t);J(a);const g=a.filter(s=>!i.rights.find(o=>o.id===s.id)).filter(s=>!(s.type==="user"&&s.id===A[0].creatorId)).map(s=>({value:s.id,label:s.displayName,icon:s.type==="sharebookmark"?ee:null}));F(g)}else F([]),Promise.resolve();q(!1)};return{currentIsAuthor:()=>{for(const t of A)if(t.creatorId!==(d==null?void 0:d.userId))return!1;return!0},idBookmark:f,myAvatar:v,shareRights:i,shareRightActions:y,showBookmarkInput:w,searchInputValue:C,searchResults:R,bookmarkName:P,showBookmarkMembers:U,debouncedSearchInputValue:I,searchPending:M,setBookmarkName:H,saveBookmark:async t=>{try{const c=await E.directory().saveBookmarks(t,{users:i.rights.filter(a=>a.type==="user").map(a=>a.id),groups:i.rights.filter(a=>a.type==="group").map(a=>a.id),bookmarks:i.rights.filter(a=>a.type==="sharebookmark").map(a=>a.id)});n.success(p("explorer.bookmarked.status.saved")),x(a=>({...a,visibleBookmarks:[...a.visibleBookmarks,{displayName:t,id:c.id}]})),S(f+new Date().getTime().toString()),V(!1)}catch(c){console.error("Failed to save bookmark",c),n.error(p("explorer.bookmarked.status.error"))}},canSave:()=>!0,toggleBookmarkInput:V,handleActionCheckbox:l,handleShare:D,handleDeleteRow:me,handleSearchInputChange:pe,handleSearchResultsChange:async t=>{const c=_.find(g=>g.id===t[0]),a=[{id:"read",displayName:"read"},{id:"comment",displayName:"comment"}];if(c){let g=[];if(c.type==="sharebookmark"){const s=await E.directory().getBookMarkById(c.id);g.push({...s,type:"sharebookmark",avatarUrl:"",directoryUrl:"",actions:a}),s==null||s.users.filter(o=>!i.rights.find(T=>T.id===o.id)).forEach(o=>{g.push({...o,type:"user",avatarUrl:"",directoryUrl:"",actions:a,isBookmarkMember:!0})}),s.groups.filter(o=>!i.rights.find(T=>T.id===o.id)).forEach(o=>{g.push({...o,type:"group",avatarUrl:"",directoryUrl:"",actions:a,isBookmarkMember:!0})})}else g=[{...c,actions:[{id:"read",displayName:"read"},{id:"comment",displayName:"comment"}]}];x({...i,rights:[...i.rights,...g]}),F(R.filter(s=>s.value!==t[0]))}},showSearchNoResults:xe,showSearchAdmlHint:ke,showSearchLoading:ge,handleBookmarkMembersToggle:()=>{K(!U)},hasRight:(t,c)=>t.actions.filter(a=>c.id===a.id).length>0,showShareRightLine:t=>t.isBookmarkMember&&U||!t.isBookmarkMember}}function Le(){const h=de(),{assetId:m,description:u,thumbnail:p,name:d,public:v,trashed:f,slug:S,"publish-type":i}=h.length>0?h[0]:{"publish-type":"",assetId:"",description:"",name:"",public:!1,slug:"",thumbnail:"",trashed:!1},[x,y]=r.useState(i||"RESTRAINT"),[N,P]=r.useState({description:u||"",entId:m,name:d,public:!!v,slug:S||"",thumbnail:p,trashed:f,"publish-type":i});return r.useEffect(()=>{x&&P(w=>({...w,"publish-type":x}))},[x]),{radioPublicationValue:x,payloadUpdatePublishType:N,handleRadioPublicationChange:async w=>{y(w)}}}function Ze({isOpen:h,onSuccess:m,onCancel:u}){const{payloadUpdatePublishType:p,radioPublicationValue:d,handleRadioPublicationChange:v}=Le(),{myAvatar:f,idBookmark:S,shareRights:i,shareRightActions:x,showBookmarkInput:y,searchResults:N,bookmarkName:P,showBookmarkMembers:H,searchPending:w,currentIsAuthor:V,setBookmarkName:C,saveBookmark:W,canSave:I,toggleBookmarkInput:_,handleActionCheckbox:J,handleShare:R,handleDeleteRow:F,handleSearchInputChange:U,handleSearchResultsChange:K,showSearchNoResults:M,showSearchAdmlHint:q,showSearchLoading:B,handleBookmarkMembersToggle:A,hasRight:Q,showShareRightLine:X}=De({payloadUpdatePublishType:p,onSuccess:m,onCancel:u}),{t:n}=ae(),z=r.useRef(null);return Ie.createPortal(e.jsxs(O,{id:"share_modal",size:"lg",isOpen:h,onModalClose:u,children:[e.jsx(O.Header,{onModalClose:u,children:n("share.title")}),e.jsxs(O.Body,{children:[e.jsx(se,{headingStyle:"h4",level:"h3",className:"mb-16",children:n("explorer.modal.share.usersWithAccess")}),e.jsx("div",{className:"table-responsive",children:e.jsxs("table",{className:"table border align-middle mb-0",children:[e.jsx("thead",{className:"bg-secondary",children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"w-32",children:e.jsx(Y,{children:n("explorer.modal.share.avatar.shared.alt")})}),e.jsx("th",{scope:"col",children:e.jsx(Y,{children:n("explorer.modal.share.search.placeholder")})}),x.map(l=>e.jsx("th",{scope:"col",className:"text-center text-white",children:n(l.displayName)},l.displayName)),e.jsx("th",{scope:"col",children:e.jsx(Y,{children:n("close")})})]})}),e.jsxs("tbody",{children:[V()&&e.jsxs("tr",{children:[e.jsx("th",{scope:"row",children:e.jsx(oe,{alt:n("explorer.modal.share.avatar.me.alt"),size:"xs",src:f,variant:"circle"})}),e.jsx("td",{children:n("share.me")}),x.map(l=>e.jsx("td",{style:{width:"80px"},className:"text-center text-white",children:e.jsx(ne,{checked:!0,disabled:!0})},l.displayName)),e.jsx("td",{})]}),i==null?void 0:i.rights.map(l=>X(l)&&e.jsxs("tr",{className:l.isBookmarkMember?"bg-light":"",children:[e.jsxs("td",{children:[l.type!=="sharebookmark"&&e.jsx(oe,{alt:n("explorer.modal.share.avatar.shared.alt"),size:"xs",src:l.avatarUrl,variant:"circle"}),l.type==="sharebookmark"&&e.jsx(ee,{})]}),e.jsx("td",{children:e.jsxs("div",{className:"d-flex",children:[l.type==="sharebookmark"&&e.jsx(L,{color:"tertiary",rightIcon:e.jsx(ie,{title:"Show",className:"w-16 min-w-0",style:{transition:"rotate 0.2s ease-out",rotate:H?"-180deg":"0deg"}}),type:"button",variant:"ghost",className:"fw-normal ps-0",onClick:A,children:l.displayName}),l.type!=="sharebookmark"&&l.displayName]})}),x.map(D=>e.jsx("td",{style:{width:"80px"},className:"text-center text-white",children:e.jsx(ne,{checked:Q(l,D),onChange:()=>J(l,D.id)})},D.displayName)),e.jsx("td",{children:!l.isBookmarkMember&&e.jsx(Be,{"aria-label":"Delete",color:"tertiary",icon:e.jsx(Ae,{}),type:"button",variant:"ghost",title:"Delete",onClick:()=>F(l)})})]},l.id))]})]})}),e.jsxs("div",{className:"mt-16",children:[e.jsx(L,{color:"tertiary",leftIcon:e.jsx(ee,{}),rightIcon:e.jsx(ie,{title:"Show",className:"w-16 min-w-0",style:{transition:"rotate 0.2s ease-out",rotate:y?"-180deg":"0deg"}}),type:"button",variant:"ghost",className:"fw-normal",onClick:()=>_(!y),children:n("share.save.sharebookmark")}),y&&e.jsx("div",{className:"mt-16",children:e.jsxs(Z,{id:"bookmarkName",className:"d-flex flex-wrap align-items-center gap-16",children:[e.jsx("div",{className:"flex-fill",children:e.jsx(Z.Input,{ref:z,onChange:()=>{C(()=>{var l;return((l=z.current)==null?void 0:l.value)||""})},placeholder:n("explorer.modal.share.sharebookmark.placeholder"),size:"sm",type:"text"},S)}),e.jsx(L,{type:"button",color:"primary",variant:"ghost",disabled:P.length===0,leftIcon:e.jsx(Ce,{}),onClick:()=>{W(z.current.value)},className:"text-nowrap",children:n("explorer.modal.share.sharebookmark.save")})]})})]}),e.jsx("hr",{}),e.jsxs(se,{headingStyle:"h4",level:"h3",className:"mb-16 d-flex align-items-center",children:[e.jsx("div",{className:"me-8",children:n("explorer.modal.share.search")}),e.jsx(Pe,{message:"Vos favoris de partage s’affichent en priorité dans votre liste lorsque vous recherchez un groupe ou une personne, vous pouvez les retrouver dans l’annuaire.",placement:"top",children:e.jsx(Re,{className:"c-pointer",height:"18"})})]}),e.jsxs(Z,{className:"d-flex align-items-center",id:"search",children:[e.jsx(Me,{className:"max-w-512",noValidationIcon:!0,placeholder:q()?n("explorer.search.adml.hint"):n("explorer.modal.share.search.placeholder"),size:"md",type:"search",onChange:U}),B()&&e.jsxs("div",{className:"d-flex align-items-center p-4",children:[e.jsx(Te,{isLoading:w}),e.jsx("span",{className:"ps-4",children:n("explorer.search.pending")})]}),M()&&e.jsx("div",{className:"p-4",children:n("portal.no.result")})]}),(N==null?void 0:N.length)>0&&e.jsx("div",{className:"position-absolute w-100 max-w-512 z-1 bg-white shadow rounded-4 d-block show py-12 px-8",children:e.jsx($e,{options:N,hideCheckbox:!0,isMonoSelection:!0,onChange:K})}),e.jsx(ze,{radioPublicationValue:d,onRadioPublicationChange:v})]}),e.jsxs(O.Footer,{children:[e.jsx(L,{type:"button",color:"tertiary",variant:"ghost",onClick:u,children:n("explorer.cancel")}),e.jsx(L,{type:"button",color:"primary",variant:"filled",onClick:R,disabled:!I(),children:n("share")})]})]}),document.getElementById("portal"))}export{Ze as default};
1
+ import{r,g as G,j as e,d as ce,u as ae,h as be,i as ye,k as je,l as de,m as ve,n as Se,o as Ne,p as ee,A as we,a as Ie,M as O,V as Y,q as oe,B as L,s as ie,t as Be,v as Ae,F as Z,w as Ce,x as Re,y as Me,z as Te,C as $e}from"./index.js";import{odeServices as E,APP as Ee}from"/assets/js/edifice-ts-client/index.js";import{H as se}from"./Heading.js";import{T as Pe}from"./Tooltip.js";function Fe(){const[h,m]=r.useState(!1);r.useEffect(()=>{u()},[]);const u=r.useCallback(async()=>{const p=await E.session().isAdml();m(p)},[]);return{isAdml:h}}const he=r.forwardRef(({label:h,disabled:m=!1,checked:u=!1,indeterminate:p=!1,...c},v)=>{const f=r.useRef(null);r.useImperativeHandle(v,()=>({...f.current})),r.useEffect(()=>{f.current.indeterminate=p},[f,p]);const S=r.useId(),i={type:"checkbox",checked:u,disabled:m,ref:f,className:G(c.className,"form-check-input c-pointer"),id:S},x={...c,...i};return e.jsxs("div",{className:"form-check d-flex align-items-center gap-8",children:[e.jsx("input",{...x}),h&&e.jsx("label",{className:"form-check-label",htmlFor:x.id,children:h})]})});he.displayName="Checkbox";const ne=he,ue=r.forwardRef(({model:h,icon:m,label:u=!1,disabled:p=!1,...c},v)=>{const f=r.useMemo(()=>c.id?c.id:(Math.floor(Math.random()*999999999999)+1e12).toString(),[c.id]),i={...{type:"radio",checked:h===c.value,disabled:p,ref:v,className:G(c.className,"form-check-input c-pointer",m&&"d-none"),id:f},...c};return e.jsxs("div",{className:G("form-check d-flex align-items-center gap-8",m&&"ps-0"),children:[e.jsx("input",{...i}),m&&e.jsx("label",{htmlFor:i.id,className:G("c-pointer",h!==c.value&&"text-muted"),children:m}),!m&&u&&e.jsx("label",{className:"form-check-label",htmlFor:i.id,children:u})]})});ue.displayName="Radio";const le=ue;function Ue({radioPublicationValue:h,onRadioPublicationChange:m}){const{appCode:u}=ce(),{t:p}=ae(u);return e.jsxs(e.Fragment,{children:[e.jsx("hr",{}),e.jsx(se,{headingStyle:"h4",level:"h3",className:"mb-16",children:p("explorer.publication.steps")}),e.jsx(le,{label:p("explorer.immediat.publication"),id:"publication-now",name:"publication",value:"IMMEDIATE",model:h,onChange:c=>m(c.target.value)}),e.jsx(le,{label:p("explorer.validate.publication"),id:"publication-validate",name:"publication",value:"RESTRAINT",model:h,onChange:c=>m(c.target.value)})]})}function ze({radioPublicationValue:h,onRadioPublicationChange:m}){const{app:u}=be();return u===Ee.BLOG?e.jsx(Ue,{radioPublicationValue:h,onRadioPublicationChange:m}):e.jsx(e.Fragment,{})}function De({onSuccess:h,payloadUpdatePublishType:m}){const{appCode:u}=ce(),{t:p}=ae(),{user:c,avatar:v}=ye(),[f,S]=r.useState(r.useId()),[i,x]=r.useState({rights:[],visibleBookmarks:[],visibleGroups:[],visibleUsers:[]}),[y,N]=r.useState([]),[P,H]=r.useState(""),[w,V]=r.useState(!1),[C,W]=r.useState(""),I=je(C,500),[_,J]=r.useState([]),[R,F]=r.useState([]),[U,K]=r.useState(!1),[M,q]=r.useState(!1),{isAdml:B}=Fe(),A=de(),Q=ve(),X=Se(),{hotToast:n}=Ne(we);r.useEffect(()=>{z()},[]),r.useEffect(()=>{fe(I)},[I]);const z=r.useCallback(async()=>{var a;const t=await E.share().getActionsForApp(u);N(t);const d=await E.share().getRightsForResource(u,(a=A[0])==null?void 0:a.assetId);x(d)},[]),l=(t,d)=>{x(({rights:a,...g})=>{var te,re;const s=[...a],o=s.findIndex(k=>k.id===t.id),T=y.filter(k=>k.id===d)[0];if(s[o].actions.findIndex(k=>k.id===d)>-1){let k=s[o].actions.filter(b=>b.id!==d);const j=y.filter(b=>{var $;return($=b.requires)==null?void 0:$.includes(d)});k=k.filter(b=>!j.find($=>$.id===b.id)),s[o]={...s[o],actions:k}}else{const k=y.filter(j=>{var b;return((b=T.requires)==null?void 0:b.includes(j.id))&&!s[o].actions.find($=>$.id===j.id)});s[o]={...s[o],actions:[...s[o].actions,T,...k]}}return t.type==="sharebookmark"&&((te=s[o].users)==null||te.forEach(k=>{const j=s.findIndex(b=>b.id===k.id);s[j]={...s[j],actions:s[o].actions}}),(re=s[o].groups)==null||re.forEach(k=>{const j=s.findIndex(b=>b.id===k.id);s[j]={...s[j],actions:s[o].actions}})),{rights:s,...g}})},D=async()=>{var t;try{await Q.mutateAsync(m),await X.mutateAsync({entId:(t=A[0])==null?void 0:t.assetId,shares:i.rights}),n.success(p("explorer.shared.status.saved")),h==null||h()}catch{n.error(p("explorer.shared.status.error"))}},me=t=>{x(d=>({...d,rights:i.rights.filter(a=>{var g,s;return a.id!==t.id&&!((g=t.users)!=null&&g.find(o=>o.id===a.id))&&!((s=t.groups)!=null&&s.find(o=>o.id===a.id))})}))},pe=t=>{W(t.target.value)},xe=()=>!M&&!B&&I.length>0&&R.length===0||!M&&B&&I.length>3&&R.length===0,ke=()=>B&&C.length<3,ge=()=>M&&C.length>0,fe=async t=>{var d;if(q(!0),!B&&t.length>=1||B&&t.length>=3){const a=await E.share().searchShareSubjects(u,(d=A[0])==null?void 0:d.assetId,t);J(a);const g=a.filter(s=>!i.rights.find(o=>o.id===s.id)).filter(s=>!(s.type==="user"&&s.id===A[0].creatorId)).map(s=>({value:s.id,label:s.displayName,icon:s.type==="sharebookmark"?ee:null}));F(g)}else F([]),Promise.resolve();q(!1)};return{currentIsAuthor:()=>{for(const t of A)if(t.creatorId!==(c==null?void 0:c.userId))return!1;return!0},idBookmark:f,myAvatar:v,shareRights:i,shareRightActions:y,showBookmarkInput:w,searchInputValue:C,searchResults:R,bookmarkName:P,showBookmarkMembers:U,debouncedSearchInputValue:I,searchPending:M,setBookmarkName:H,saveBookmark:async t=>{try{const d=await E.directory().saveBookmarks(t,{users:i.rights.filter(a=>a.type==="user").map(a=>a.id),groups:i.rights.filter(a=>a.type==="group").map(a=>a.id),bookmarks:i.rights.filter(a=>a.type==="sharebookmark").map(a=>a.id)});n.success(p("explorer.bookmarked.status.saved")),x(a=>({...a,visibleBookmarks:[...a.visibleBookmarks,{displayName:t,id:d.id}]})),S(f+new Date().getTime().toString()),V(!1)}catch{n.error(p("explorer.bookmarked.status.error"))}},canSave:()=>!0,toggleBookmarkInput:V,handleActionCheckbox:l,handleShare:D,handleDeleteRow:me,handleSearchInputChange:pe,handleSearchResultsChange:async t=>{const d=_.find(g=>g.id===t[0]),a=[{id:"read",displayName:"read"},{id:"comment",displayName:"comment"}];if(d){let g=[];if(d.type==="sharebookmark"){const s=await E.directory().getBookMarkById(d.id);g.push({...s,type:"sharebookmark",avatarUrl:"",directoryUrl:"",actions:a}),s==null||s.users.filter(o=>!i.rights.find(T=>T.id===o.id)).forEach(o=>{g.push({...o,type:"user",avatarUrl:"",directoryUrl:"",actions:a,isBookmarkMember:!0})}),s.groups.filter(o=>!i.rights.find(T=>T.id===o.id)).forEach(o=>{g.push({...o,type:"group",avatarUrl:"",directoryUrl:"",actions:a,isBookmarkMember:!0})})}else g=[{...d,actions:[{id:"read",displayName:"read"},{id:"comment",displayName:"comment"}]}];x({...i,rights:[...i.rights,...g]}),F(R.filter(s=>s.value!==t[0]))}},showSearchNoResults:xe,showSearchAdmlHint:ke,showSearchLoading:ge,handleBookmarkMembersToggle:()=>{K(!U)},hasRight:(t,d)=>t.actions.filter(a=>d.id===a.id).length>0,showShareRightLine:t=>t.isBookmarkMember&&U||!t.isBookmarkMember}}function Le(){const h=de(),{assetId:m,description:u,thumbnail:p,name:c,public:v,trashed:f,slug:S,"publish-type":i}=h.length>0?h[0]:{"publish-type":"",assetId:"",description:"",name:"",public:!1,slug:"",thumbnail:"",trashed:!1},[x,y]=r.useState(i||"RESTRAINT"),[N,P]=r.useState({description:u||"",entId:m,name:c,public:!!v,slug:S||"",thumbnail:p,trashed:f,"publish-type":i});return r.useEffect(()=>{x&&P(w=>({...w,"publish-type":x}))},[x]),{radioPublicationValue:x,payloadUpdatePublishType:N,handleRadioPublicationChange:async w=>{y(w)}}}function Ze({isOpen:h,onSuccess:m,onCancel:u}){const{payloadUpdatePublishType:p,radioPublicationValue:c,handleRadioPublicationChange:v}=Le(),{myAvatar:f,idBookmark:S,shareRights:i,shareRightActions:x,showBookmarkInput:y,searchResults:N,bookmarkName:P,showBookmarkMembers:H,searchPending:w,currentIsAuthor:V,setBookmarkName:C,saveBookmark:W,canSave:I,toggleBookmarkInput:_,handleActionCheckbox:J,handleShare:R,handleDeleteRow:F,handleSearchInputChange:U,handleSearchResultsChange:K,showSearchNoResults:M,showSearchAdmlHint:q,showSearchLoading:B,handleBookmarkMembersToggle:A,hasRight:Q,showShareRightLine:X}=De({payloadUpdatePublishType:p,onSuccess:m,onCancel:u}),{t:n}=ae(),z=r.useRef(null);return Ie.createPortal(e.jsxs(O,{id:"share_modal",size:"lg",isOpen:h,onModalClose:u,children:[e.jsx(O.Header,{onModalClose:u,children:n("share.title")}),e.jsxs(O.Body,{children:[e.jsx(se,{headingStyle:"h4",level:"h3",className:"mb-16",children:n("explorer.modal.share.usersWithAccess")}),e.jsx("div",{className:"table-responsive",children:e.jsxs("table",{className:"table border align-middle mb-0",children:[e.jsx("thead",{className:"bg-secondary",children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"w-32",children:e.jsx(Y,{children:n("explorer.modal.share.avatar.shared.alt")})}),e.jsx("th",{scope:"col",children:e.jsx(Y,{children:n("explorer.modal.share.search.placeholder")})}),x.map(l=>e.jsx("th",{scope:"col",className:"text-center text-white",children:n(l.displayName)},l.displayName)),e.jsx("th",{scope:"col",children:e.jsx(Y,{children:n("close")})})]})}),e.jsxs("tbody",{children:[V()&&e.jsxs("tr",{children:[e.jsx("th",{scope:"row",children:e.jsx(oe,{alt:n("explorer.modal.share.avatar.me.alt"),size:"xs",src:f,variant:"circle"})}),e.jsx("td",{children:n("share.me")}),x.map(l=>e.jsx("td",{style:{width:"80px"},className:"text-center text-white",children:e.jsx(ne,{checked:!0,disabled:!0})},l.displayName)),e.jsx("td",{})]}),i==null?void 0:i.rights.map(l=>X(l)&&e.jsxs("tr",{className:l.isBookmarkMember?"bg-light":"",children:[e.jsxs("td",{children:[l.type!=="sharebookmark"&&e.jsx(oe,{alt:n("explorer.modal.share.avatar.shared.alt"),size:"xs",src:l.avatarUrl,variant:"circle"}),l.type==="sharebookmark"&&e.jsx(ee,{})]}),e.jsx("td",{children:e.jsxs("div",{className:"d-flex",children:[l.type==="sharebookmark"&&e.jsx(L,{color:"tertiary",rightIcon:e.jsx(ie,{title:"Show",className:"w-16 min-w-0",style:{transition:"rotate 0.2s ease-out",rotate:H?"-180deg":"0deg"}}),type:"button",variant:"ghost",className:"fw-normal ps-0",onClick:A,children:l.displayName}),l.type!=="sharebookmark"&&l.displayName]})}),x.map(D=>e.jsx("td",{style:{width:"80px"},className:"text-center text-white",children:e.jsx(ne,{checked:Q(l,D),onChange:()=>J(l,D.id)})},D.displayName)),e.jsx("td",{children:!l.isBookmarkMember&&e.jsx(Be,{"aria-label":"Delete",color:"tertiary",icon:e.jsx(Ae,{}),type:"button",variant:"ghost",title:"Delete",onClick:()=>F(l)})})]},l.id))]})]})}),e.jsxs("div",{className:"mt-16",children:[e.jsx(L,{color:"tertiary",leftIcon:e.jsx(ee,{}),rightIcon:e.jsx(ie,{title:"Show",className:"w-16 min-w-0",style:{transition:"rotate 0.2s ease-out",rotate:y?"-180deg":"0deg"}}),type:"button",variant:"ghost",className:"fw-normal",onClick:()=>_(!y),children:n("share.save.sharebookmark")}),y&&e.jsx("div",{className:"mt-16",children:e.jsxs(Z,{id:"bookmarkName",className:"d-flex flex-wrap align-items-center gap-16",children:[e.jsx("div",{className:"flex-fill",children:e.jsx(Z.Input,{ref:z,onChange:()=>{C(()=>{var l;return((l=z.current)==null?void 0:l.value)||""})},placeholder:n("explorer.modal.share.sharebookmark.placeholder"),size:"sm",type:"text"},S)}),e.jsx(L,{type:"button",color:"primary",variant:"ghost",disabled:P.length===0,leftIcon:e.jsx(Ce,{}),onClick:()=>{W(z.current.value)},className:"text-nowrap",children:n("explorer.modal.share.sharebookmark.save")})]})})]}),e.jsx("hr",{}),e.jsxs(se,{headingStyle:"h4",level:"h3",className:"mb-16 d-flex align-items-center",children:[e.jsx("div",{className:"me-8",children:n("explorer.modal.share.search")}),e.jsx(Pe,{message:"Vos favoris de partage s’affichent en priorité dans votre liste lorsque vous recherchez un groupe ou une personne, vous pouvez les retrouver dans l’annuaire.",placement:"top",children:e.jsx(Re,{className:"c-pointer",height:"18"})})]}),e.jsxs(Z,{className:"d-flex align-items-center",id:"search",children:[e.jsx(Me,{className:"max-w-512",noValidationIcon:!0,placeholder:q()?n("explorer.search.adml.hint"):n("explorer.modal.share.search.placeholder"),size:"md",type:"search",onChange:U}),B()&&e.jsxs("div",{className:"d-flex align-items-center p-4",children:[e.jsx(Te,{isLoading:w}),e.jsx("span",{className:"ps-4",children:n("explorer.search.pending")})]}),M()&&e.jsx("div",{className:"p-4",children:n("portal.no.result")})]}),(N==null?void 0:N.length)>0&&e.jsx("div",{className:"position-absolute w-100 max-w-512 z-1 bg-white shadow rounded-4 d-block show py-12 px-8",children:e.jsx($e,{options:N,hideCheckbox:!0,isMonoSelection:!0,onChange:K})}),e.jsx(ze,{radioPublicationValue:c,onRadioPublicationChange:v})]}),e.jsxs(O.Footer,{children:[e.jsx(L,{type:"button",color:"tertiary",variant:"ghost",onClick:u,children:n("explorer.cancel")}),e.jsx(L,{type:"button",color:"primary",variant:"filled",onClick:R,disabled:!I(),children:n("share")})]})]}),document.getElementById("portal"))}export{Ze as default};