@gisce/react-ooui 1.2.0-rc.11 → 1.2.0-rc.12
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.
package/dist/react-ooui.umd.js
CHANGED
|
@@ -281,6 +281,6 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
281
281
|
.ant-transfer-list-body-customize-wrapper {
|
|
282
282
|
min-height: ${300}px;
|
|
283
283
|
}
|
|
284
|
-
`,cn=({targetKeys:e,locale:o,onGetFields:r,onGetFieldChilds:a,onChange:s,...c})=>{const[l,d]=React.useState(),[u,f]=React.useState(!0),[p,m]=React.useState(),[I,h]=React.useState();React.useEffect(()=>{g()},[]);const g=React.useCallback(async()=>{f(!0);try{const v=await r();d(v)}catch(v){console.error(v),Ze({title:"Error",centered:!0,content:jsxRuntime.jsx(jsxRuntime.Fragment,{children:JSON.stringify(v,null,2)})})}f(!1)},[]),C=React.useCallback(async({key:v})=>{try{const O=Z(l).find(A=>A.key===v),w=await a({key:v,title:O.title}),_=Ht(l,v,w);d(_)}catch(O){console.error(O),Ze({title:"Error",centered:!0,content:jsxRuntime.jsx(jsxRuntime.Fragment,{children:JSON.stringify(O,null,2)})})}},[l]),b=React.useCallback((v,O)=>{v==="left"?m(O.trim()===""?void 0:O.trim()):h(O.trim()===""?void 0:O.trim())},[]),y=React.useCallback(({checkedKeys:v,onItemSelect:O})=>(w,{node:{key:_}})=>{var A;O(_,(A=_,!v.includes(A)))},[]);return jsxRuntime.jsx(sn,{...c,showSearch:!0,targetKeys:e,dataSource:Z(l),className:"tree-transfer",render:v=>v.title,onChange:s,showSelectAll:!0,locale:{itemUnit:S("exportModalItemsUnit",o),itemsUnit:S("exportModalItemsUnit",o),notFoundContent:S("notFoundContent",o),searchPlaceholder:S("searchPlaceholder",o)},filterOption:Le,onSearch:b,titles:[S("availableFields",o),S("fieldsToExport",o)],children:({direction:v,onItemSelect:O,selectedKeys:w})=>{if(u)return jsxRuntime.jsx("div",{style:{display:"flex",paddingTop:"2em",justifyContent:"center"},children:jsxRuntime.jsx(antd.Spin,{})});if(v==="left"){const _=[...e,...w];return jsxRuntime.jsx(antd.Tree,{height:300,blockNode:!0,checkable:!0,checkStrictly:!0,checkedKeys:_,loadData:C,treeData:Pt({treeNodes:l,checkedKeys:e,searchText:p}),onCheck:y({checkedKeys:_,onItemSelect:O}),onSelect:y({checkedKeys:_,onItemSelect:O}),titleRender:A=>jsxRuntime.jsx(Xe,{node:A})})}return jsxRuntime.jsx(antd.Tree,{height:300,blockNode:!0,checkable:!0,checkStrictly:!0,checkedKeys:w,onCheck:y({checkedKeys:w,onItemSelect:O}),onSelect:y({checkedKeys:w,onItemSelect:O}),treeData:Ie({treeNodes:l,checkedKeys:e,searchText:I}),titleRender:_=>jsxRuntime.jsx(Xe,{node:_})})}})},et=()=>jsxRuntime.jsx("div",{style:{padding:"0.5em"}}),{error:dn}=antd.Modal,Yn=e=>{const{visible:o,locale:r,onCancel:a,onSucceed:s,totalRegisters:c,selectedRegistersToExport:l,selectedKeys:d}=e,{modalWidth:u}=jt(),[f,p]=React.useState(!1),[m,I]=React.useState("xlsx"),[h,g]=React.useState("all"),[C,b]=React.useState(d);React.useEffect(()=>{o||(b(void 0),I("xlsx"),g(l?"selected":"all"))},[o]),React.useEffect(()=>{g(l?"selected":"all")},[l]),React.useEffect(()=>{d===void 0||C||b(d)},[d,C]);const y=React.useCallback(O=>{b(O)},[]),v=React.useCallback(async()=>{p(!0);try{await s({exportType:m,selectedKeys:C,registersAmount:h})}catch(O){console.error(O),dn({title:"Error",centered:!0,content:jsxRuntime.jsx(jsxRuntime.Fragment,{children:JSON.stringify(O,null,2)})})}p(!1)},[m,C,h]);return jsxRuntime.jsxs(antd.Modal,{title:S("export",r),centered:!0,width:u,visible:o,closable:!f,onCancel:a,footer:null,destroyOnClose:!0,children:[jsxRuntime.jsx(cn,{targetKeys:C||[],onChange:y,locale:r,onGetFieldChilds:e.onGetFieldChilds,onGetFields:e.onGetFields}),jsxRuntime.jsx(et,{}),jsxRuntime.jsx(an,{locale:r,value:m,onChange:I}),l&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(et,{}),jsxRuntime.jsx(on,{locale:r,totalRegisters:c,selectedRegistersToExport:l,value:h,onChange:g})]}),jsxRuntime.jsx(antd.Divider,{}),jsxRuntime.jsx(qt,{locale:r,onClose:a,onConfirm:v,loading:f,left:S("exportRegisters",r).replace("{total}",h==="selected"?l==null?void 0:l.toString():c.toString())})]})},ExportModal=e=>{const{visible:o,locale:r,onClose:a,model:s,context:c,selectedRegistersToExport:l,totalRegisters:d,domain:u,limit:f}=e,p=React.useRef({}),m=React.useCallback(async g=>{if(g.selectedKeys.length===0){showDialog$7(tForLang("selectAtLeastOneField",r));return}const{datas:C}=await ConnectionProvider.getHandler().exportData({model:s,fields:g.selectedKeys,domain:g.registersAmount==="all"?[]:u,limit:g.registersAmount==="all"?void 0:f,context:c,format:g.exportType});a(),await new Promise(y=>setTimeout(y,200));const b=await getMimeType(C);openBase64InNewTab(C,b.mime)},[r,s,u,f,c,a]),I=React.useCallback(async()=>{const g=await ConnectionProvider.getHandler().getFields({model:s,context:c,fields:[]});return p.current["/"]=g,convertToExportField({fields:g})},[s,c,p]),h=React.useCallback(async({key:g,title:C})=>{let b;const y=g.split("/")[g.split("/").length-1]==="id"?g.split("/").slice(0,-1).join("/"):g;y.indexOf("/")===-1?b=p.current["/"]:b=p.current[getParentKey(y)];const O=b[getChildKey(y)].relation,w=await ConnectionProvider.getHandler().getFields({model:O,context:c,fields:[]});return p.current[y]=w,convertToExportField({fields:w,parentTitle:C,parentKey:y})},[p,s,c]);return jsxRuntime.jsx(Yn,{visible:o,locale:r,onSucceed:m,onCancel:a,selectedRegistersToExport:l,totalRegisters:d,onGetFieldChilds:h,onGetFields:I})},convertToExportField=({fields:e,parentKey:o,parentTitle:r})=>{const a=[];for(const s of Object.keys(e)){const c=e[s];if(c.relation&&c.is_function===!0)continue;const l=c.type==="many2one"||c.type==="one2many"||c.type==="many2many";let d=`${o?o+"/":""}${s}`;l&&(d+="/id"),a.push({key:d,title:`${r?r+"/":""}${c.string}`,tooltip:c.help,required:c.required,isLeaf:!l})}return a},getParentKey=e=>e.indexOf("/")===-1?e:e.split("/").slice(0,-1).join("/"),getChildKey=e=>{if(e.indexOf("/")===-1)return e;const o=e.split("/");return o[o.length-1]},DatePickerConfig={date:{placeholder:"__/__/____",dateDisplayFormat:"YYYY-MM-DD",dateInternalFormat:"YYYY-MM-DD"},time:{placeholder:"__/__/____ __:__:__",dateDisplayFormat:"YYYY-MM-DD HH:mm:ss",dateInternalFormat:"YYYY-MM-DD HH:mm:ss"}},DatePicker=e=>{const{ooui:o,showTime:r=!1}=e,{required:a}=o;return jsxRuntime.jsx(Field$1,{required:a,...e,children:jsxRuntime.jsx(DatePickerInput,{ooui:o,showTime:r})})},DatePickerInput=e=>{const{value:o,onChange:r,ooui:a,showTime:s}=e,{id:c,readOnly:l,required:d}=a,u=d&&!l?Config.requiredClass:void 0,f=s?"time":"date",p=g=>{r==null||r(g)},m=g=>{if(g===null){p(void 0);return}p(g.format(DatePickerConfig[f].dateInternalFormat))},I=s?{defaultValue:hooks("00:00:00","HH:mm:ss")}:void 0,h=o?hooks(o,DatePickerConfig[f].dateInternalFormat):void 0;return jsxRuntime.jsx(antd.DatePicker,{style:{width:"100%"},placeholder:s?DatePickerConfig.time.placeholder:DatePickerConfig.date.placeholder,disabled:l,id:c,showTime:I,className:u,format:DatePickerConfig[f].dateDisplayFormat,value:h,onChange:m})},Date$1=e=>{const{ooui:o}=e;return jsxRuntime.jsx(DatePicker,{ooui:o})},DateTime=e=>{const{ooui:o}=e;return jsxRuntime.jsx(DatePicker,{ooui:o,showTime:!0})},Reference=e=>{const{ooui:o}=e,{required:r}=o;return jsxRuntime.jsx(Field$1,{required:r,...e,children:jsxRuntime.jsx(ReferenceInput,{ooui:o})})},ReferenceInput=e=>{const{value:o,onChange:r,ooui:a}=e,{required:s,selectionValues:c,readOnly:l}=a,d=o==null?void 0:o.split(","),[u,f]=React.useState([]),[p,m]=React.useState();return React.useEffect(()=>{if(!o)return;const I=o&&d&&d[0],h=o&&d&&d[1]&&parseInt(d[1]);f([h,void 0]),m(I)},[o]),jsxRuntime.jsxs(antd.Row,{gutter:8,wrap:!1,children:[jsxRuntime.jsx(antd.Col,{flex:"1",children:jsxRuntime.jsx(SelectionInput$1,{ooui:new ooui.Selection({name:"model_selection",selection:c,readOnly:l,required:s}),onChange:I=>{m(I),f([]),r==null||r(void 0)},value:p})}),jsxRuntime.jsx(antd.Col,{flex:"3",children:jsxRuntime.jsx(Many2oneInput,{ooui:new ooui.Many2one({name:"object_value",relation:p,readOnly:l,required:s}),value:u,onChange:I=>{f(I);const h=`${p},${I[0]}`;h!==o&&(r==null||r(h))}})})]})},Binary=e=>{const{ooui:o}=e,{required:r}=o;return jsxRuntime.jsx(Field$1,{required:r,...e,children:jsxRuntime.jsx(BinaryInput,{ooui:o})})},BinaryInput=e=>{const{ooui:o,value:r,onChange:a}=e,{readOnly:s,required:c,filenameField:l}=o,d=c&&!s?Config.requiredClass:void 0,u=React.useRef(null),{setFieldValue:f,getFieldValue:p}=React.useContext(FormContext$1)||{},{t:m}=React.useContext(LocaleContext),I=r?getFilesize(r):"",h=v=>{a==null||a(v)};async function g(){const v=await getMimeType(r),O=`data:${v==null?void 0:v.mime};base64,${r}`,w=document.createElement("a"),_=p(l),A=p("name");w.href=O,w.download=_||A,w.click()}async function C(){const v=await getMimeType(r);openBase64InNewTab(r,v.mime)}async function b(v){v.stopPropagation(),v.preventDefault();const O=v.target.files[0],w=await toBase64(O);h(w),l&&f(l,O.name)}function y(){f(l,void 0),h(void 0)}return jsxRuntime.jsxs(antd.Row,{gutter:8,children:[jsxRuntime.jsxs(antd.Col,{style:{paddingBottom:5},children:[jsxRuntime.jsx("input",{type:"file",id:"file",ref:u,style:{display:"none"},onChange:b}),jsxRuntime.jsx(antd.Input,{type:"text",disabled:!0,className:d,value:I})]}),jsxRuntime.jsx(antd.Col,{children:jsxRuntime.jsxs(antd.Space,{children:[jsxRuntime.jsx(antd.Button,{icon:jsxRuntime.jsx(Icon.FolderOpenOutlined,{}),disabled:s,onClick:()=>{u.current.click()},children:"Select"}),jsxRuntime.jsx(antd.Button,{icon:jsxRuntime.jsx(Icon.EyeOutlined,{}),disabled:!r,onClick:C,children:m("open")}),jsxRuntime.jsx(ButtonWithTooltip,{tooltip:m("download"),disabled:!r,onClick:g,icon:jsxRuntime.jsx(Icon.DownloadOutlined,{})}),jsxRuntime.jsx(ButtonWithTooltip,{tooltip:m("clear"),disabled:s||!r,onClick:y,icon:jsxRuntime.jsx(Icon.ClearOutlined,{})})]})})]})},iconsForViewTypes={tree:jsxRuntime.jsx(Icon.TableOutlined,{}),form:jsxRuntime.jsx(Icon.FormOutlined,{}),graph:jsxRuntime.jsx(Icon.AreaChartOutlined,{}),calendar:jsxRuntime.jsx(Icon.CalendarOutlined,{})};function getIconForView(e){return e?(iconsForViewTypes==null?void 0:iconsForViewTypes[e.type])||jsxRuntime.jsx(Icon.FormOutlined,{}):jsxRuntime.jsx(Icon.FormOutlined,{})}function ChangeViewButton(e){const{currentView:o,availableViews:r,onChangeView:a,disabled:s=!1,formHasChanges:c=!1,previousView:l}=e,{t:d,lang:u}=React.useContext(LocaleContext);function f(){const I=r.map((h,g)=>jsxRuntime.jsx(antd.Menu.Item,{children:jsxRuntime.jsxs(antd.Row,{wrap:!1,children:[jsxRuntime.jsx(antd.Col,{flex:"none",style:{paddingRight:20},children:getIconForView(h)}),jsxRuntime.jsx(antd.Col,{flex:"auto",style:{paddingRight:20},children:h.type==="graph"?h.name:h.type.charAt(0).toUpperCase()+h.type.slice(1)}),jsxRuntime.jsx(antd.Col,{flex:"none",children:jsxRuntime.jsx(Icon.CheckOutlined,{style:{opacity:o.view_id===h.view_id?1:0}})})]})},h.view_id||g));return jsxRuntime.jsx(antd.Menu,{onClick:m,children:jsxRuntime.jsx(antd.Menu.ItemGroup,{title:d("viewAs"),children:I})})}function p(I){if(c){showDialog$6({lang:u,onOk:()=>{I()}});return}I()}function m(I){p(()=>{const h=r.find(g=>g.view_id===parseInt(I.key));a(h)})}return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ButtonWithTooltip,{tooltip:l?d("viewAs")+" "+d(l.type):"",icon:getIconForView(l),style:{width:50},onClick:()=>{m({key:l==null?void 0:l.view_id})},disabled:s||r.length===1}),jsxRuntime.jsx(antd.Dropdown,{overlay:f(),disabled:s||r.length===1,children:jsxRuntime.jsx(antd.Button,{style:{width:25},icon:jsxRuntime.jsx(Icon.DownOutlined,{style:{fontSize:"0.5em"}}),onClick:I=>I.preventDefault()})})]})}function DropdownButton(e){const{icon:o,tooltip:r,items:a=[],onItemClick:s,label:c,disabled:l=!1}=e;function d(){const f=a==null?void 0:a.map((p,m)=>p.name==="divider"?jsxRuntime.jsx(antd.Menu.Divider,{},"divider"+m):jsxRuntime.jsx(antd.Menu.Item,{children:p.name},p.id));return jsxRuntime.jsx(antd.Menu,{onClick:u,children:jsxRuntime.jsx(antd.Menu.ItemGroup,{title:r,children:f})})}function u(f){const p=a.find(m=>isNaN(f.key)?m.id===f.key:m.id===parseInt(f.key));s(p)}return jsxRuntime.jsx(antd.Dropdown,{overlay:d(),disabled:l||!a||a.length===0,children:jsxRuntime.jsxs(antd.Button,{children:[o," ",c," ",jsxRuntime.jsx(Icon.DownOutlined,{})]})})}function ActionButton(e){const{onClick:o,disabled:r=!1,loading:a=!1,tooltip:s,icon:c,label:l,type:d="default"}=e,u=a?jsxRuntime.jsx(Icon.LoadingOutlined,{}):c;return jsxRuntime.jsxs(ButtonWithTooltip,{type:d,tooltip:s,onClick:o,disabled:r,children:[u,l]})}function NewButton(e){const{disabled:o=!1}=e,{formHasChanges:r,onNewClicked:a}=React.useContext(ActionViewContext),{t:s,lang:c}=React.useContext(LocaleContext),l=()=>{if(r){showDialog$6({lang:c,onOk:()=>{a()}});return}a()};return jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.FileAddOutlined,{}),tooltip:s("new"),onClick:l,disabled:o})}const{confirm}=antd.Modal,showDialog=({onOk:e,onCancel:o,lang:r})=>{confirm({title:tForLang("unsavedChanges",r),icon:jsxRuntime.jsx(Icon.ExclamationCircleOutlined,{}),centered:!0,content:tForLang("confirmRefreshWithoutSave",r),okText:tForLang("discardAndRefresh",r),cancelText:tForLang("cancel",r),onOk:e,onCancel:o})};async function showLogInfo(e,o,r){const a=(await ConnectionProvider.getHandler().getLogInfo({model:e,ids:[o]}))[0],{create_date:s,create_uid:c,id:l,write_date:d,write_uid:u}=a;showDialog$7(jsxRuntime.jsxs("div",{children:["ID: "+l," ",jsxRuntime.jsx("br",{}),r("createdBy")+": "+c[1]," ",jsxRuntime.jsx("br",{}),r("creationDate")+": "+s," ",jsxRuntime.jsx("br",{}),r("lastUpdatedBy")+": "+u[1]," ",jsxRuntime.jsx("br",{}),r("lastUpdatedDate")+": "+d]}))}const AttachmentsButtonWrapper=e=>{const{numberOfAttachments:o,disabled:r}=e,{t:a}=React.useContext(LocaleContext),[s,c]=React.useState(!1),l=jsxRuntime.jsxs(antd.Button,{disabled:r,children:[jsxRuntime.jsx(Icon.LinkOutlined,{}),`(${o})`,jsxRuntime.jsx(Icon.DownOutlined,{style:{fontSize:12}})]});return r?l:jsxRuntime.jsx(antd.Popover,{onVisibleChange:d=>c(d),visible:s,placement:"bottom",content:Content$1(e,c),title:a("attachments"),arrowContent:null,children:l})},Content$1=(e,o)=>{const{attachments:r=[],loading:a,onAddNewAttachment:s,onopenAttachmentLink:c,onOpenAttachmentDetail:l,onListAllAttachments:d}=e,{t:u}=React.useContext(LocaleContext);return a?jsxRuntime.jsx(antd.Spin,{style:{padding:20}}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("a",{style:{display:"block",paddingBottom:5},href:"#",onClick:()=>{o(!1),d()},children:[jsxRuntime.jsx(Icon.TableOutlined,{})," ",u("listAllAttachments")]}),jsxRuntime.jsxs("a",{style:{display:"block"},href:"#",onClick:()=>{o(!1),s()},children:[jsxRuntime.jsx(Icon.FileAddOutlined,{})," ",u("addNewAttachment")]}),r.length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("li",{className:" ant-dropdown-menu-item-divider"}),r.map(f=>{const p=f.link?Icon.LinkOutlined:Icon.DownloadOutlined;return jsxRuntime.jsxs(antd.Row,{style:{paddingTop:4,paddingBottom:4},wrap:!1,align:"middle",children:[jsxRuntime.jsx(antd.Col,{flex:"auto",children:f.name}),jsxRuntime.jsx(antd.Col,{flex:"25px",style:{textAlign:"center"},children:(f.datas_fname||f.link)&&jsxRuntime.jsx(antd.Tooltip,{title:f.link?u("openAttachmentLink"):u("download"),children:jsxRuntime.jsx(p,{style:{cursor:"pointer"},onClick:()=>{o(!1),c(f)}})})}),jsxRuntime.jsx(antd.Col,{flex:"25px",style:{textAlign:"center"},children:jsxRuntime.jsx(antd.Tooltip,{title:u("openAttachment"),children:jsxRuntime.jsx(Icon.FormOutlined,{style:{cursor:"pointer"},onClick:()=>{o(!1),l(f)}})})})]},f.id)})]})]})};function AttachmentsButton(e){const{attachments:o,disabled:r=!1,onAddNewAttachment:a,onListAllAttachments:s,onViewAttachmentDetails:c}=e,{formRef:l}=React.useContext(ActionViewContext),[d,u]=React.useState(!1),[f,p]=React.useState([]),[m,I]=React.useState(!1),{t:h}=React.useContext(LocaleContext),g=React.useCallback(async()=>{u(!0);try{const y=await ConnectionProvider.getHandler().readObjects({model:"ir.attachment",ids:o.map(v=>v.id),fieldsToRetrieve:["name","datas_fname","link"],context:l.current.getContext()});p(y.map(v=>({id:v.id,name:v.name,datas_fname:v.datas_fname,link:v.link})))}catch(y){showDialog$8(y)}u(!1)},o),C=React.useCallback(async y=>{if(y.link){window.open(y.link);return}I(!0);let v;try{v=(await ConnectionProvider.getHandler().readObjects({model:"ir.attachment",ids:[y.id],context:l.current.getContext()}))[0]}catch(O){showDialog$8(O)}if(I(!1),!!v)if(v.datas){const O=await getMimeType(v.datas);openBase64InNewTab(v.datas,O.mime)}else c(v)},[]),b=React.useCallback(async y=>{c(y)},[]);return React.useEffect(()=>{g()},[g]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(AttachmentsButtonWrapper,{numberOfAttachments:o.length,attachments:f,disabled:r,loading:d,onAddNewAttachment:a,onListAllAttachments:s,onopenAttachmentLink:C,onOpenAttachmentDetail:b}),jsxRuntime.jsx(antd.Modal,{title:h("downloadingAttachment"),visible:m,footer:null,closable:!1,centered:!0,maskClosable:!1,children:jsxRuntime.jsx(antd.Spin,{})})]})}function FormActionBar({toolbar:e}){const{availableViews:o,currentView:r,setCurrentView:a,onFormSave:s,formHasChanges:c,formIsSaving:l,currentId:d,results:u,setCurrentItemIndex:f,currentItemIndex:p,setCurrentId:m,currentModel:I,setRemovingItem:h,removingItem:g,duplicatingItem:C,setDuplicatingItem:b,setResults:y,formIsLoading:v,attachments:O,formRef:w,setFormHasChanges:_,searchTreeRef:A,previousView:L,setPreviousView:E,goToResourceId:P}=React.useContext(ActionViewContext),{t:F,lang:W}=React.useContext(LocaleContext),J=React.useContext(ContentRootContext),{processAction:z}=J||{},Y=React.useContext(TabManagerContext),{openRelate:Q,openDefaultActionForModel:re}=Y||{};function ee(N){if(c){showDialog({lang:W,onOk:()=>{N()}});return}N()}function X(N){if(c){showDialog$6({lang:W,onOk:()=>{N()}});return}N()}function ue(){u&&u.length>p+1?(f==null||f(p+1),m==null||m(u[p+1].id)):u&&p+1===u.length&&(f==null||f(0),m==null||m(u[0].id))}function Re(){u&&p>0?(f==null||f(p-1),m==null||m(u[p-1].id)):u&&p===0&&(f==null||f(u.length-1),m==null||m(u[u.length-1].id))}function xe(){showDialog$9({confirmMessage:F("confirmRemoveItem"),lang:W,onOk:()=>{ce()}})}async function ce(){try{h==null||h(!0),await ConnectionProvider.getHandler().delete({model:I,ids:[d]});const N=u==null?void 0:u.filter(oe=>oe.id!==d);y==null||y(N);let U=0;p>0&&p<=u.length-1&&(U=p-1),N!=null&&N[U]?(m==null||m(N==null?void 0:N[U].id),f==null||f(U)):(m==null||m(void 0),f==null||f(void 0))}catch(N){showDialog$3(JSON.stringify(N))}finally{h==null||h(!1)}}async function Ce(){try{b==null||b(!0);const N=await ConnectionProvider.getHandler().duplicate({id:d,model:I,context:w.current.getContext()});N&&await(P==null?void 0:P(N))}catch(N){showDialog$3(JSON.stringify(N))}finally{b==null||b(!1)}}const te=l||g||v||C;function de(N){z==null||z({actionData:N,values:w.current.getValues(),fields:w.current.getFields(),context:w.current.getContext(),onRefreshParentValues:()=>{w.current.fetchValues()}})}return r?jsxRuntime.jsxs(antd.Space,{wrap:!0,children:[v&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(antd.Spin,{}),separator$2(),separator$2()]}),jsxRuntime.jsx(NewButton,{disabled:l||v||g||C}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.SaveOutlined,{}),tooltip:F("save"),disabled:!c||te,loading:l,onClick:s}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.CopyOutlined,{}),tooltip:F("duplicate"),disabled:c||l||d===void 0||C||v,loading:C,onClick:Ce}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.DeleteOutlined,{}),tooltip:F("delete"),disabled:l||d===void 0||g||C||v,loading:g,onClick:xe}),separator$2(),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.InfoCircleOutlined,{}),tooltip:F("showLogs"),disabled:l||d===void 0||g||C||v,loading:!1,onClick:()=>{showLogInfo(I,d,F)}}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.ReloadOutlined,{}),tooltip:F("refresh"),disabled:l||d===void 0||g||C||v,loading:!1,onClick:()=>{ee(()=>{w.current.fetchValues()})}}),separator$2(),jsxRuntime.jsx(ChangeViewButton,{currentView:r,previousView:L,availableViews:o,onChangeView:N=>{E==null||E(r),_==null||_(!1),a==null||a(N)},disabled:te,formHasChanges:c}),separator$2(),jsxRuntime.jsxs(antd.Space,{children:[jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.LeftOutlined,{}),tooltip:F("previous"),disabled:te,loading:!1,onClick:()=>{X(Re)}}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.RightOutlined,{}),tooltip:F("next"),disabled:te,loading:!1,onClick:()=>{X(ue)}})]}),separator$2(),jsxRuntime.jsx(DropdownButton,{icon:jsxRuntime.jsx(Icon.ThunderboltOutlined,{}),disabled:te,tooltip:F("actions"),items:e==null?void 0:e.action,onItemClick:N=>{!N||de(N)}}),jsxRuntime.jsx(DropdownButton,{icon:jsxRuntime.jsx(Icon.PrinterOutlined,{}),disabled:te,tooltip:F("reports"),items:e==null?void 0:e.print,onItemClick:N=>{!N||de({...N,datas:{...N.datas||{},ids:[d]}})}}),jsxRuntime.jsx(DropdownButton,{icon:jsxRuntime.jsx(Icon.EnterOutlined,{}),disabled:te,tooltip:F("related"),items:e==null?void 0:e.relate,onItemClick:async N=>{!N||Q({relateData:N,values:w.current.getValues(),fields:w.current.getFields(),action_id:N.id,action_type:N.type})}}),jsxRuntime.jsx(AttachmentsButton,{disabled:te,attachments:O,onAddNewAttachment:()=>{const N=d,U=I;re({model:"ir.attachment",values:{selection_associated_object:`${U},${N}`},forced_values:{res_model:U,res_id:N},initialViewType:"form"})},onListAllAttachments:()=>{const N=d;re({model:"ir.attachment",domain:[["res_model","=",`${I}`],["res_id","=",`${N}`]],initialViewType:"tree"})},onViewAttachmentDetails:N=>{re({model:"ir.attachment",res_id:N.id,initialViewType:"form"})}})]}):null}function separator$2(){return jsxRuntime.jsx("div",{className:"inline-block w-2"})}const LinkInput=e=>{const{ooui:o,value:r,onChange:a,valueValidator:s,linkPrefix:c=""}=e,{id:l,readOnly:d,required:u}=o,f=u&&!d?Config.requiredClass:void 0,p=React.useContext(FormContext$1),{elementHasLostFocus:m}=p||{},[I,h]=React.useState(!1),[g,C]=React.useState(!1);React.useEffect(()=>{d&&!I&&C(!1),!r&&!d&&(h(!0),C(!0))},[I,d]);const b=y=>{a==null||a(y.target.value)};return jsxRuntime.jsxs(antd.Row,{gutter:8,wrap:!1,align:"middle",children:[d?null:jsxRuntime.jsx(antd.Col,{flex:"32px",children:I?jsxRuntime.jsx(antd.Button,{icon:jsxRuntime.jsx(Icon.CheckOutlined,{}),onClick:()=>{s(r)&&(h(!1),C(!1))},tabIndex:-1}):jsxRuntime.jsx(antd.Button,{icon:jsxRuntime.jsx(Icon.EditOutlined,{}),onClick:()=>{h(!0),C(!0)},tabIndex:-1})}),jsxRuntime.jsx(antd.Col,{flex:"auto",children:g?jsxRuntime.jsx(antd.Input,{id:l,onChange:b,className:f,value:r,onBlur:()=>{s(r)&&(h(!1),C(!1),m==null||m())}}):jsxRuntime.jsx("a",{href:`${c}${r}`,style:{color:"#1890ff",paddingRight:15},target:"_blank",children:r})})]})},Url=e=>{const{ooui:o}=e,{required:r}=o;return jsxRuntime.jsx(Field$1,{required:r,...e,children:jsxRuntime.jsx(LinkInput,{ooui:o,valueValidator:a=>a?isURL(a):!1})})},Email=e=>{const{ooui:o}=e,{required:r}=o;return jsxRuntime.jsx(Field$1,{required:r,...e,children:jsxRuntime.jsx(LinkInput,{ooui:o,linkPrefix:"mailto:",valueValidator:a=>a?isEmail(a):!1})})},GoToResourceModal=e=>{const{visible:o,onIdSubmitted:r,onCancel:a,isSearching:s}=e,{t:c}=React.useContext(LocaleContext);function l(d){r(d.id)}return jsxRuntime.jsx(antd.Modal,{title:c("goToResourceId"),centered:!0,visible:o,footer:null,destroyOnClose:!0,onCancel:a,maskClosable:!1,children:jsxRuntime.jsxs(antd.Form,{layout:"vertical",onFinish:l,autoComplete:"off",children:[jsxRuntime.jsx(antd.Form.Item,{name:"id",label:c("searchId"),rules:[{required:!0,type:"number"}],children:jsxRuntime.jsx(antd.InputNumber,{style:{width:"100%"},autoFocus:!0})}),jsxRuntime.jsx(antd.Row,{align:"middle",justify:"end",children:jsxRuntime.jsx(antd.Col,{children:jsxRuntime.jsxs(antd.Space,{children:[jsxRuntime.jsx(antd.Button,{icon:jsxRuntime.jsx(Icon.CloseOutlined,{}),htmlType:"button",onClick:a,disabled:s,children:c("cancel")}),jsxRuntime.jsx(antd.Button,{loading:s,style:{marginLeft:15},icon:jsxRuntime.jsx(Icon.CheckOutlined,{}),htmlType:"submit",type:"primary",disabled:s,children:c("ok")})]})})})]})})};function ButtonWithBadge(e){const{badgeNumber:o=0,...r}=e;return jsxRuntime.jsxs("div",{style:{position:"relative"},children:[o>0&&jsxRuntime.jsx("div",{style:{position:"absolute",left:-10,top:-10,zIndex:2},children:jsxRuntime.jsx("span",{style:{display:"inline-block",minWidth:"22px",padding:"2px",borderRadius:"50%",fontSize:"12px",textAlign:"center",background:"#1890FF",color:"#fefefe"},children:o})}),jsxRuntime.jsx(ButtonWithTooltip,{...r,style:{width:46,zIndex:0}})]})}function GraphActionBar({refreshGraph:e}){const{t:o}=React.useContext(LocaleContext),{availableViews:r,currentView:a,setCurrentView:s,searchParams:c,searchVisible:l,setSearchVisible:d,graphIsLoading:u,previousView:f,setPreviousView:p}=React.useContext(ActionViewContext);return jsxRuntime.jsxs(antd.Space,{wrap:!0,children:[jsxRuntime.jsx(ButtonWithBadge,{icon:jsxRuntime.jsx(Icon.FilterOutlined,{style:{color:l?"white":void 0}}),tooltip:o("advanced_search"),type:l?"primary":"default",onClick:()=>{d==null||d(!l)},disabled:u,badgeNumber:c==null?void 0:c.length}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.ReloadOutlined,{}),tooltip:o("refresh"),disabled:u,loading:!1,onClick:()=>{e()}}),jsxRuntime.jsx(ChangeViewButton,{currentView:a,availableViews:r,onChangeView:m=>{p==null||p(a),s==null||s(m)},disabled:!1,previousView:f})]})}const{Title:Title$1,Text:Text$1}=antd.Typography;function TitleHeader(e){const{title:o,children:r}=e,{title:a,currentView:s,currentId:c,currentItemIndex:l,results:d,totalItems:u,selectedRowItems:f}=React.useContext(ActionViewContext),{t:p}=React.useContext(LocaleContext);function m(){if((s==null?void 0:s.type)==="form")return c?u===0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[p("editingDocument")," (id: ",jsxRuntime.jsx(Text$1,{copyable:!0,children:c}),")"]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[p("register")," ",l===void 0?1:l+1," /"," ",d.length," ",p("of")," ",u," - ",p("editingDocument")," (id:"," ",jsxRuntime.jsx(Text$1,{copyable:!0,children:c}),")"]}):"";if((s==null?void 0:s.type)==="tree"&&f){if(f.length===1)return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:["1 ",p("selectedRegisters")," - (id:"," ",jsxRuntime.jsx(Text$1,{copyable:!0,children:f[0].id}),")"]});if(f.length>1)return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[f.length," ",p("selectedRegisters"),jsxRuntime.jsx(Text$1,{copyable:{text:f.map(I=>I.id).join(", ")}})]})}return null}return jsxRuntime.jsxs("div",{style:{position:"sticky",top:80,zIndex:3},children:[jsxRuntime.jsxs(antd.Row,{className:"rounded shadow-md bg-blueGray-100",style:{padding:"1em"},align:"middle",children:[jsxRuntime.jsxs(antd.Col,{flex:2,children:[jsxRuntime.jsx(Title$1,{level:3,style:{marginBottom:0},children:o||a}),m()]}),jsxRuntime.jsx(antd.Col,{flex:3,children:jsxRuntime.jsx(antd.Row,{justify:"end",children:r})})]}),jsxRuntime.jsx("div",{className:"pb-5"})]})}const GraphActionView=e=>{const{viewData:o,visible:r,model:a,context:s,domain:c,formView:l,treeView:d}=e,u=React.useRef(),f=React.useContext(ActionViewContext),{setResults:p=void 0,setCurrentItemIndex:m=void 0,currentId:I=void 0,results:h=void 0,setSelectedRowItems:g=void 0,setSearchParams:C=void 0,searchVisible:b=!0,setSearchVisible:y=void 0,sorter:v=void 0,setSorter:O=void 0,setTotalItems:w=void 0,setSearchTreeNameSearch:_=void 0,setTreeIsLoading:A=void 0,limit:L,setLimit:E,searchParams:P,searchValues:F,setSearchValues:W,currentView:J}=f||{},[z,Y]=React.useState(!0);React.useEffect(()=>{var Re;(Re=u.current)==null||Re.refresh()},[P]),React.useEffect(()=>{o.view_id!==J.view_id&&Y(!0)},[J]);const{clear:Q,searchFilterLoading:re,searchError:ee,offset:X,tableRefreshing:ue}=useSearch({model:a,setSearchTreeNameSearch:_,setSelectedRowItems:g,searchParams:P,setSearchValues:W,setSearchParams:C,setSearchVisible:y,setTreeIsLoading:A,context:s,formView:l,treeView:d,sorter:v,setSorter:O,setCurrentItemIndex:m,setResultsActionView:p,resultsActionView:h,domain:c,currentId:I,setActionViewTotalItems:w,limit:L,setLimit:E});return!r||!o?null:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(TitleHeader,{title:o.name,children:jsxRuntime.jsx(GraphActionBar,{refreshGraph:()=>{u.current.refresh()}})}),jsxRuntime.jsx(SearchFilter,{fields:{...d.fields,...l.fields},searchFields:mergeSearchFields([l.search_fields,d.search_fields]),limit:L,onClear:Q,offset:X,isSearching:re,onSubmit:Re=>{Y(!1),C==null||C(Re.params),y==null||y(!1)},searchError:ee,searchVisible:b,searchValues:F,showLimitOptions:!1}),ue?jsxRuntime.jsx(antd.Spin,{}):jsxRuntime.jsx(Graph,{ref:u,view_id:o.view_id,model:a,context:s,domain:mergeParams(P||[],c),limit:z?L:void 0,manualIds:z?h==null?void 0:h.map(Re=>Re.id):void 0})]})},FormActionView=e=>{const{visible:o,formRef:r,model:a,currentId:s,domain:c,formView:l,context:d,defaultValues:u,forcedValues:f,results:p,setResults:m,setCurrentItemIndex:I}=e;return o?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(TitleHeader,{children:jsxRuntime.jsx(FormActionBar,{toolbar:l==null?void 0:l.toolbar})}),jsxRuntime.jsx(Form$1,{rootForm:!0,ref:r,model:a,defaultValues:u,forcedValues:f,formView:l,actionDomain:c,id:s,parentContext:d,onSubmitSucceed:(h,g)=>{p.findIndex(b=>b.id===h)===-1&&(p.push(g),m(p),I(p.length-1))}})]}):null};function SearchBar(e){const{onSearch:o,disabled:r=!1,searchText:a}=e,{t:s}=React.useContext(LocaleContext),[c]=antd.Form.useForm(),[l,d]=React.useState(!1);function u(p){o(p.search)}React.useEffect(()=>{c.setFieldsValue({search:a})},[a]);function f(){d(!1),c.setFieldsValue({search:void 0}),o(void 0)}return jsxRuntime.jsx(antd.Form,{form:c,onFinish:u,autoComplete:"off",children:jsxRuntime.jsxs(antd.Row,{align:"middle",justify:"end",children:[jsxRuntime.jsx(antd.Col,{children:jsxRuntime.jsx(antd.Form.Item,{name:"search",noStyle:!0,children:jsxRuntime.jsx(antd.Input,{autoFocus:!0,disabled:r,onChange:p=>{d(p.target.value.length>0)},suffix:(l||a&&a.length>0)&&jsxRuntime.jsx(antd.Tooltip,{title:s("clear"),children:jsxRuntime.jsx(Icon.CloseCircleFilled,{style:{color:"rgba(0,0,0,.45)"},onClick:f})})})})}),jsxRuntime.jsx(antd.Col,{children:jsxRuntime.jsx(antd.Button,{htmlType:"submit",disabled:r,children:s("search")})})]})})}function TreeActionBar(e){var xe;const{availableViews:o,currentView:r,setCurrentView:a,selectedRowItems:s,setRemovingItem:c,removingItem:l,duplicatingItem:d,setDuplicatingItem:u,currentModel:f,searchTreeRef:p,setCurrentId:m,setCurrentItemIndex:I,searchParams:h,searchVisible:g,setSearchVisible:C,setSearchTreeNameSearch:b,searchTreeNameSearch:y,treeIsLoading:v,setPreviousView:O,previousView:w,results:_,limit:A}=React.useContext(ActionViewContext),{parentContext:L={},treeExpandable:E,toolbar:P}=e,{t:F,lang:W}=React.useContext(LocaleContext),J=React.useContext(ContentRootContext),{processAction:z}=J||{},[Y,Q]=React.useState(!1),re=y!==void 0&&y.trim().length>0;function ee(){showDialog$9({confirmMessage:F("confirmRemove"),lang:W,onOk:()=>{X()}})}async function X(){var ce;try{c==null||c(!0),await ConnectionProvider.getHandler().delete({model:f,ids:s.map(Ce=>Ce.id)}),m==null||m(void 0),I==null||I(void 0),(ce=p==null?void 0:p.current)==null||ce.refreshResults()}catch(Ce){showDialog$8(Ce)}finally{c==null||c(!1)}}async function ue(){var ce;try{u==null||u(!0);const Ce=s[0].id;await ConnectionProvider.getHandler().duplicate({id:Ce,model:f,context:{...L}})&&((ce=p==null?void 0:p.current)==null||ce.refreshResults())}catch(Ce){showDialog$8(Ce)}finally{u==null||u(!1)}}function Re(ce){z==null||z({actionData:ce,values:{active_id:s==null?void 0:s.map(Ce=>Ce.id)[0],active_ids:s==null?void 0:s.map(Ce=>Ce.id)},fields:{},context:{...L,active_id:s==null?void 0:s.map(Ce=>Ce.id)[0],active_ids:s==null?void 0:s.map(Ce=>Ce.id)},onRefreshParentValues:()=>{var Ce;(Ce=p==null?void 0:p.current)==null||Ce.refreshResults()}})}return jsxRuntime.jsxs(antd.Space,{wrap:!0,children:[E?null:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(SearchBar,{disabled:d||l||v,searchText:y,onSearch:ce=>{ce&&ce.trim().length>0?b==null||b(ce):b==null||b(void 0)}}),separator$1(),jsxRuntime.jsx(NewButton,{disabled:v}),separator$1(),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.CopyOutlined,{}),tooltip:F("duplicate"),disabled:!s||(s==null?void 0:s.length)!==1||d||v,loading:d,onClick:ue}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.DeleteOutlined,{}),tooltip:F("delete"),disabled:!(s&&(s==null?void 0:s.length)>0)||v,loading:l,onClick:ee}),separator$1()]}),!E&&jsxRuntime.jsx(ButtonWithBadge,{icon:jsxRuntime.jsx(Icon.FilterOutlined,{style:{color:g?"white":void 0}}),tooltip:F("advanced_search"),type:g?"primary":"default",onClick:()=>{C==null||C(!g)},disabled:d||l||v,badgeNumber:h==null?void 0:h.length}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.InfoCircleOutlined,{}),tooltip:F("showLogs"),disabled:!(s&&(s==null?void 0:s.length)>0)||v,loading:!1,onClick:()=>{showLogInfo(f,s[0].id,F)}}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.ReloadOutlined,{}),tooltip:F("refresh"),disabled:d||l||v,loading:!1,onClick:()=>{var ce;(ce=p==null?void 0:p.current)==null||ce.refreshResults()}}),!E&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[separator$1(),jsxRuntime.jsx(ChangeViewButton,{currentView:r,availableViews:o,onChangeView:ce=>{O==null||O(r),a==null||a(ce)},previousView:w,disabled:v})]}),separator$1(),jsxRuntime.jsx(DropdownButton,{icon:jsxRuntime.jsx(Icon.ThunderboltOutlined,{}),disabled:!(s&&(s==null?void 0:s.length)>0)||v,tooltip:F("actions"),items:P==null?void 0:P.action,onItemClick:ce=>{!ce||Re(ce)}}),jsxRuntime.jsx(DropdownButton,{icon:jsxRuntime.jsx(Icon.PrinterOutlined,{}),disabled:!(s&&(s==null?void 0:s.length)>0)||v,tooltip:F("reports"),items:P==null?void 0:P.print,onItemClick:ce=>{!ce||Re({...ce,datas:{...ce.datas||{},ids:s.map(Ce=>Ce.id)}})}}),separator$1(),jsxRuntime.jsx(DropdownButton,{icon:jsxRuntime.jsx(Icon__default.default,{component:()=>jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"icon icon-tabler icon-tabler-database-export",width:"1em",height:"1em",viewBox:"0 0 24 24","stroke-width":"1.5",fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round",children:[jsxRuntime.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),jsxRuntime.jsx("ellipse",{cx:"12",cy:"6",rx:"8",ry:"3"}),jsxRuntime.jsx("path",{d:"M4 6v6c0 1.657 3.582 3 8 3a19.84 19.84 0 0 0 3.302 -.267m4.698 -2.733v-6"}),jsxRuntime.jsx("path",{d:"M4 12v6c0 1.599 3.335 2.905 7.538 2.995m8.462 -6.995v-2m-6 7h7m-3 -3l3 3l-3 3"})]})}),tooltip:F("export"),items:[{id:"print_screen",name:F("printScreen")},{id:"export",name:F("advancedExport")}],onItemClick:ce=>{if(ce.id==="print_screen"){let Ce=(s==null?void 0:s.map(te=>te.id))||[];Ce.length===0&&(Ce=(_==null?void 0:_.map(te=>te.id))||[]),Re({id:-1,model:f,report_name:"printscreen.list",type:"ir.actions.report.xml",datas:{model:f,ids:Ce}});return}Q(!0)},disabled:d||l||v||re}),jsxRuntime.jsx(ExportModal,{visible:Y,locale:W,onClose:()=>Q(!1),model:f,domain:mergeParams(((xe=p==null?void 0:p.current)==null?void 0:xe.getDomain())||[],h||[]),limit:A,totalRegisters:(_==null?void 0:_.length)||0,selectedRegistersToExport:s&&s.length&&s.length>0?s.length:void 0,context:L})]})}function separator$1(){return jsxRuntime.jsx("div",{className:"inline-block w-2"})}const TreeActionView=e=>{const{visible:o,searchTreeRef:r,model:a,context:s,formView:c,treeView:l,domain:d,setCurrentItemIndex:u,results:f,setCurrentId:p,setCurrentView:m,availableViews:I,searchTreeNameSearch:h}=e;return o?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(TitleHeader,{children:jsxRuntime.jsx(TreeActionBar,{toolbar:l==null?void 0:l.toolbar,parentContext:s,treeExpandable:(l==null?void 0:l.isExpandable)||!1})}),jsxRuntime.jsx(SearchTree$1,{ref:r,rootTree:!0,model:a,parentContext:s,nameSearch:h,formView:c,treeView:l,domain:d,onRowClicked:g=>{const{id:C}=g;p(C);const b=f.findIndex(v=>v.id===C);u(b);const y=I.find(v=>v.type==="form");m(y)}})]}):null},DashboardActionContext=React__default.default.createContext(null),DashboardActionProvider=e=>{const[o,r]=React.useState(!1),[a,s]=React.useState(!1),{children:c,dashboardRef:l,openAction:d}=e;return jsxRuntime.jsx(DashboardActionContext.Provider,{value:{isLoading:o,setIsLoading:r,dashboardRef:l,openAction:d,moveItemsEnabled:a,setMoveItemsEnabled:s},children:c})};function DashboardActionBar(){const{isLoading:e,dashboardRef:o,moveItemsEnabled:r,setMoveItemsEnabled:a}=React.useContext(DashboardActionContext),{t:s}=React.useContext(LocaleContext);return jsxRuntime.jsxs(antd.Space,{wrap:!0,children:[jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.BorderOuterOutlined,{style:{color:r?"white":void 0}}),type:r?"primary":"default",tooltip:s("moveDashboard"),disabled:e,loading:!1,onClick:()=>{a(!r)}}),separator(),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.SettingOutlined,{}),tooltip:s("configDashboard"),disabled:e,loading:!1,onClick:()=>{o==null||o.current.configDashboard()}}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.ReloadOutlined,{}),tooltip:s("refresh"),disabled:e,loading:!1,onClick:()=>{o==null||o.current.refresh()}})]})}function separator(){return jsxRuntime.jsx("div",{className:"inline-block w-2"})}const DashboardActionView=e=>{const{dashboardData:o}=e,r=React.useRef(),a=React.useContext(TabManagerContext),{openShortcut:s}=a||{};return o?jsxRuntime.jsxs(DashboardActionProvider,{dashboardRef:r,openAction:c=>{s(c)},children:[jsxRuntime.jsx(TitleHeader,{children:jsxRuntime.jsx(DashboardActionBar,{})}),jsxRuntime.jsx(Dashboard$1,{ref:r,model:o.model,id:o.id,context:o==null?void 0:o.context,configAction:o==null?void 0:o.configAction})]}):null};function ActionView(e,o){const{domain:r,model:a,context:s,views:c,title:l,setCanWeClose:d,tabKey:u,initialView:f,formDefaultValues:p,formForcedValues:m={},res_id:I=!1,action_id:h,action_type:g,treeExpandable:C=!1,limit:b}=e,[y,v]=React.useState(),[O,w]=React.useState([]),[_,A]=React.useState(!0),L=I||void 0,[E,P]=React.useState(L),[F,W]=React.useState([]),[J,z]=React.useState(),[Y,Q]=React.useState([]),[re,ee]=React.useState(),[X,ue]=React.useState(0),[Re,xe]=React.useState(!1),[ce,Ce]=React.useState(!1),[te,de]=React.useState(),{t:N}=React.useContext(LocaleContext),U=React.useRef(),oe=React.useRef(),Te=React.useContext(TabManagerContext),{setCurrentView:Fe,setCurrentId:M,tabs:j,activeKey:we,openAction:je}=Te||{};reactHotkeysHook.useHotkeys("ctrl+g,command+g",Ct=>{Ct.preventDefault(),Tt()},[we,j,y,J,Y]);function tt(Ct){P(Ct),M==null||M(Ct)}function Ne(Ct){v(Ct),Fe==null||Fe(Ct)}React.useImperativeHandle(o,()=>({canWeClose:yt}));const Ge=async()=>{A(!0);const Ct=[];for(const zt of c){const[Ut,Kt]=zt;let Gt;try{Kt!=="dashboard"&&(Gt=await ConnectionProvider.getHandler().getView({model:a,type:Kt,id:Ut,context:s}))}catch(fn){console.error(`${a} - ${Kt}\xA0- ${JSON.stringify(fn,null,2)}`);continue}switch(Kt){case"dashboard":{const fn=c.find(_t=>{const[,Ft]=_t;return Ft==="form"});let nn;fn&&(nn={action_id:h,action_type:g,name:l,res_id:s.active_id,res_model:a,view_id:fn[0],view_type:fn[1]}),Ct.push({type:"dashboard",id:s.active_id,model:a,context:s,configAction:nn});break}case"form":{Ct.push({...Gt,type:Kt});break}case"tree":{Ct.push({...Gt,isExpandable:C,type:Kt});break}case"graph":{Ct.push({...Gt,type:Kt});break}}}let Dt;!f&&Ct.find(zt=>zt.type==="tree")?Dt=Ct.find(Ut=>Ut.type==="tree"):f?Dt=Ct.find(Ut=>f.id?Ut.type===f.type&&Ut.view_id===f.id:Ut.type===f.type):Dt=Ct.find(Ut=>Ut.type==="form"),Dt||showDialog$8(`Error determining the first view to show.
|
|
284
|
+
`,cn=({targetKeys:e,locale:o,onGetFields:r,onGetFieldChilds:a,onChange:s,...c})=>{const[l,d]=React.useState(),[u,f]=React.useState(!0),[p,m]=React.useState(),[I,h]=React.useState();React.useEffect(()=>{g()},[]);const g=React.useCallback(async()=>{f(!0);try{const v=await r();d(v)}catch(v){console.error(v),Ze({title:"Error",centered:!0,content:jsxRuntime.jsx(jsxRuntime.Fragment,{children:JSON.stringify(v,null,2)})})}f(!1)},[]),C=React.useCallback(async({key:v})=>{try{const O=Z(l).find(A=>A.key===v),w=await a({key:v,title:O.title}),_=Ht(l,v,w);d(_)}catch(O){console.error(O),Ze({title:"Error",centered:!0,content:jsxRuntime.jsx(jsxRuntime.Fragment,{children:JSON.stringify(O,null,2)})})}},[l]),b=React.useCallback((v,O)=>{v==="left"?m(O.trim()===""?void 0:O.trim()):h(O.trim()===""?void 0:O.trim())},[]),y=React.useCallback(({checkedKeys:v,onItemSelect:O})=>(w,{node:{key:_}})=>{var A;O(_,(A=_,!v.includes(A)))},[]);return jsxRuntime.jsx(sn,{...c,showSearch:!0,targetKeys:e,dataSource:Z(l),className:"tree-transfer",render:v=>v.title,onChange:s,showSelectAll:!0,locale:{itemUnit:S("exportModalItemsUnit",o),itemsUnit:S("exportModalItemsUnit",o),notFoundContent:S("notFoundContent",o),searchPlaceholder:S("searchPlaceholder",o)},filterOption:Le,onSearch:b,titles:[S("availableFields",o),S("fieldsToExport",o)],children:({direction:v,onItemSelect:O,selectedKeys:w})=>{if(u)return jsxRuntime.jsx("div",{style:{display:"flex",paddingTop:"2em",justifyContent:"center"},children:jsxRuntime.jsx(antd.Spin,{})});if(v==="left"){const _=[...e,...w];return jsxRuntime.jsx(antd.Tree,{height:300,blockNode:!0,checkable:!0,checkStrictly:!0,checkedKeys:_,loadData:C,treeData:Pt({treeNodes:l,checkedKeys:e,searchText:p}),onCheck:y({checkedKeys:_,onItemSelect:O}),onSelect:y({checkedKeys:_,onItemSelect:O}),titleRender:A=>jsxRuntime.jsx(Xe,{node:A})})}return jsxRuntime.jsx(antd.Tree,{height:300,blockNode:!0,checkable:!0,checkStrictly:!0,checkedKeys:w,onCheck:y({checkedKeys:w,onItemSelect:O}),onSelect:y({checkedKeys:w,onItemSelect:O}),treeData:Ie({treeNodes:l,checkedKeys:e,searchText:I}),titleRender:_=>jsxRuntime.jsx(Xe,{node:_})})}})},et=()=>jsxRuntime.jsx("div",{style:{padding:"0.5em"}}),{error:dn}=antd.Modal,Yn=e=>{const{visible:o,locale:r,onCancel:a,onSucceed:s,totalRegisters:c,selectedRegistersToExport:l,selectedKeys:d}=e,{modalWidth:u}=jt(),[f,p]=React.useState(!1),[m,I]=React.useState("xlsx"),[h,g]=React.useState("all"),[C,b]=React.useState(d);React.useEffect(()=>{o||(b(void 0),I("xlsx"),g(l?"selected":"all"))},[o]),React.useEffect(()=>{g(l?"selected":"all")},[l]),React.useEffect(()=>{d===void 0||C||b(d)},[d,C]);const y=React.useCallback(O=>{b(O)},[]),v=React.useCallback(async()=>{p(!0);try{await s({exportType:m,selectedKeys:C,registersAmount:h})}catch(O){console.error(O),dn({title:"Error",centered:!0,content:jsxRuntime.jsx(jsxRuntime.Fragment,{children:JSON.stringify(O,null,2)})})}p(!1)},[m,C,h]);return jsxRuntime.jsxs(antd.Modal,{title:S("export",r),centered:!0,width:u,visible:o,closable:!f,onCancel:a,footer:null,destroyOnClose:!0,children:[jsxRuntime.jsx(cn,{targetKeys:C||[],onChange:y,locale:r,onGetFieldChilds:e.onGetFieldChilds,onGetFields:e.onGetFields}),jsxRuntime.jsx(et,{}),jsxRuntime.jsx(an,{locale:r,value:m,onChange:I}),l&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(et,{}),jsxRuntime.jsx(on,{locale:r,totalRegisters:c,selectedRegistersToExport:l,value:h,onChange:g})]}),jsxRuntime.jsx(antd.Divider,{}),jsxRuntime.jsx(qt,{locale:r,onClose:a,onConfirm:v,loading:f,left:S("exportRegisters",r).replace("{total}",h==="selected"?l==null?void 0:l.toString():c.toString())})]})},ExportModal=e=>{const{visible:o,locale:r,onClose:a,model:s,context:c,selectedRegistersToExport:l,totalRegisters:d,domain:u,limit:f}=e,p=React.useRef({}),m=React.useCallback(async g=>{if(g.selectedKeys.length===0){showDialog$7(tForLang("selectAtLeastOneField",r));return}const{datas:C}=await ConnectionProvider.getHandler().exportData({model:s,fields:g.selectedKeys,domain:g.registersAmount==="all"?[]:u,limit:g.registersAmount==="all"?void 0:f,context:c,format:g.exportType});a(),await new Promise(y=>setTimeout(y,200));const b=await getMimeType(C);openBase64InNewTab(C,b.mime)},[r,s,u,f,c,a]),I=React.useCallback(async()=>{const g=await ConnectionProvider.getHandler().getFields({model:s,context:c,fields:[]});return p.current["/"]=g,convertToExportField({fields:g})},[s,c,p]),h=React.useCallback(async({key:g,title:C})=>{let b;const y=g.split("/")[g.split("/").length-1]==="id"?g.split("/").slice(0,-1).join("/"):g;y.indexOf("/")===-1?b=p.current["/"]:b=p.current[getParentKey(y)];const O=b[getChildKey(y)].relation,w=await ConnectionProvider.getHandler().getFields({model:O,context:c,fields:[]});return p.current[y]=w,convertToExportField({fields:w,parentTitle:C,parentKey:y})},[p,s,c]);return jsxRuntime.jsx(Yn,{visible:o,locale:r,onSucceed:m,onCancel:a,selectedRegistersToExport:l,totalRegisters:d,onGetFieldChilds:h,onGetFields:I})},convertToExportField=({fields:e,parentKey:o,parentTitle:r})=>{const a=[];for(const s of Object.keys(e)){const c=e[s];if(c.relation&&c.is_function===!0)continue;const l=c.type==="many2one"||c.type==="one2many"||c.type==="many2many";let d=`${o?o+"/":""}${s}`;l&&(d+="/id"),a.push({key:d,title:`${r?r+"/":""}${c.string}`,tooltip:c.help,required:c.required,isLeaf:!l})}return a},getParentKey=e=>e.indexOf("/")===-1?e:e.split("/").slice(0,-1).join("/"),getChildKey=e=>{if(e.indexOf("/")===-1)return e;const o=e.split("/");return o[o.length-1]},DatePickerConfig={date:{placeholder:"__/__/____",dateDisplayFormat:"YYYY-MM-DD",dateInternalFormat:"YYYY-MM-DD"},time:{placeholder:"__/__/____ __:__:__",dateDisplayFormat:"YYYY-MM-DD HH:mm:ss",dateInternalFormat:"YYYY-MM-DD HH:mm:ss"}},DatePicker=e=>{const{ooui:o,showTime:r=!1}=e,{required:a}=o;return jsxRuntime.jsx(Field$1,{required:a,...e,children:jsxRuntime.jsx(DatePickerInput,{ooui:o,showTime:r})})},DatePickerInput=e=>{const{value:o,onChange:r,ooui:a,showTime:s}=e,{id:c,readOnly:l,required:d}=a,u=d&&!l?Config.requiredClass:void 0,f=s?"time":"date",p=g=>{r==null||r(g)},m=g=>{if(g===null){p(void 0);return}p(g.format(DatePickerConfig[f].dateInternalFormat))},I=s?{defaultValue:hooks("00:00:00","HH:mm:ss")}:void 0,h=o?hooks(o,DatePickerConfig[f].dateInternalFormat):void 0;return jsxRuntime.jsx(antd.DatePicker,{style:{width:"100%"},placeholder:s?DatePickerConfig.time.placeholder:DatePickerConfig.date.placeholder,disabled:l,id:c,showTime:I,className:u,format:DatePickerConfig[f].dateDisplayFormat,value:h,onChange:m})},Date$1=e=>{const{ooui:o}=e;return jsxRuntime.jsx(DatePicker,{ooui:o})},DateTime=e=>{const{ooui:o}=e;return jsxRuntime.jsx(DatePicker,{ooui:o,showTime:!0})},Reference=e=>{const{ooui:o}=e,{required:r}=o;return jsxRuntime.jsx(Field$1,{required:r,...e,children:jsxRuntime.jsx(ReferenceInput,{ooui:o})})},ReferenceInput=e=>{const{value:o,onChange:r,ooui:a}=e,{required:s,selectionValues:c,readOnly:l}=a,d=o==null?void 0:o.split(","),[u,f]=React.useState([]),[p,m]=React.useState();return React.useEffect(()=>{if(!o)return;const I=o&&d&&d[0],h=o&&d&&d[1]&&parseInt(d[1]);f([h,void 0]),m(I)},[o]),jsxRuntime.jsxs(antd.Row,{gutter:8,wrap:!1,children:[jsxRuntime.jsx(antd.Col,{flex:"1",children:jsxRuntime.jsx(SelectionInput$1,{ooui:new ooui.Selection({name:"model_selection",selection:c,readOnly:l,required:s}),onChange:I=>{m(I),f([]),r==null||r(void 0)},value:p})}),jsxRuntime.jsx(antd.Col,{flex:"3",children:jsxRuntime.jsx(Many2oneInput,{ooui:new ooui.Many2one({name:"object_value",relation:p,readOnly:l,required:s}),value:u,onChange:I=>{f(I);const h=`${p},${I[0]}`;h!==o&&(r==null||r(h))}})})]})},Binary=e=>{const{ooui:o}=e,{required:r}=o;return jsxRuntime.jsx(Field$1,{required:r,...e,children:jsxRuntime.jsx(BinaryInput,{ooui:o})})},BinaryInput=e=>{const{ooui:o,value:r,onChange:a}=e,{readOnly:s,required:c,filenameField:l}=o,d=c&&!s?Config.requiredClass:void 0,u=React.useRef(null),{setFieldValue:f,getFieldValue:p}=React.useContext(FormContext$1)||{},{t:m}=React.useContext(LocaleContext),I=r?getFilesize(r):"",h=v=>{a==null||a(v)};async function g(){const v=await getMimeType(r),O=`data:${v==null?void 0:v.mime};base64,${r}`,w=document.createElement("a"),_=p(l),A=p("name");w.href=O,w.download=_||A,w.click()}async function C(){const v=await getMimeType(r);openBase64InNewTab(r,v.mime)}async function b(v){v.stopPropagation(),v.preventDefault();const O=v.target.files[0],w=await toBase64(O);h(w),l&&f(l,O.name)}function y(){f(l,void 0),h(void 0)}return jsxRuntime.jsxs(antd.Row,{gutter:8,children:[jsxRuntime.jsxs(antd.Col,{style:{paddingBottom:5},children:[jsxRuntime.jsx("input",{type:"file",id:"file",ref:u,style:{display:"none"},onChange:b}),jsxRuntime.jsx(antd.Input,{type:"text",disabled:!0,className:d,value:I})]}),jsxRuntime.jsx(antd.Col,{children:jsxRuntime.jsxs(antd.Space,{children:[jsxRuntime.jsx(antd.Button,{icon:jsxRuntime.jsx(Icon.FolderOpenOutlined,{}),disabled:s,onClick:()=>{u.current.click()},children:"Select"}),jsxRuntime.jsx(antd.Button,{icon:jsxRuntime.jsx(Icon.EyeOutlined,{}),disabled:!r,onClick:C,children:m("open")}),jsxRuntime.jsx(ButtonWithTooltip,{tooltip:m("download"),disabled:!r,onClick:g,icon:jsxRuntime.jsx(Icon.DownloadOutlined,{})}),jsxRuntime.jsx(ButtonWithTooltip,{tooltip:m("clear"),disabled:s||!r,onClick:y,icon:jsxRuntime.jsx(Icon.ClearOutlined,{})})]})})]})},iconsForViewTypes={tree:jsxRuntime.jsx(Icon.TableOutlined,{}),form:jsxRuntime.jsx(Icon.FormOutlined,{}),graph:jsxRuntime.jsx(Icon.AreaChartOutlined,{}),calendar:jsxRuntime.jsx(Icon.CalendarOutlined,{})};function getIconForView(e){return e?(iconsForViewTypes==null?void 0:iconsForViewTypes[e.type])||jsxRuntime.jsx(Icon.FormOutlined,{}):jsxRuntime.jsx(Icon.FormOutlined,{})}function ChangeViewButton(e){const{currentView:o,availableViews:r,onChangeView:a,disabled:s=!1,formHasChanges:c=!1,previousView:l}=e,{t:d,lang:u}=React.useContext(LocaleContext);function f(){const I=r.map((h,g)=>jsxRuntime.jsx(antd.Menu.Item,{children:jsxRuntime.jsxs(antd.Row,{wrap:!1,children:[jsxRuntime.jsx(antd.Col,{flex:"none",style:{paddingRight:20},children:getIconForView(h)}),jsxRuntime.jsx(antd.Col,{flex:"auto",style:{paddingRight:20},children:h.type==="graph"?h.name:h.type.charAt(0).toUpperCase()+h.type.slice(1)}),jsxRuntime.jsx(antd.Col,{flex:"none",children:jsxRuntime.jsx(Icon.CheckOutlined,{style:{opacity:o.view_id===h.view_id?1:0}})})]})},h.view_id||g));return jsxRuntime.jsx(antd.Menu,{onClick:m,children:jsxRuntime.jsx(antd.Menu.ItemGroup,{title:d("viewAs"),children:I})})}function p(I){if(c){showDialog$6({lang:u,onOk:()=>{I()}});return}I()}function m(I){p(()=>{const h=r.find(g=>g.view_id===parseInt(I.key));a(h)})}return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ButtonWithTooltip,{tooltip:l?d("viewAs")+" "+d(l.type):"",icon:getIconForView(l),style:{width:50},onClick:()=>{m({key:l==null?void 0:l.view_id})},disabled:s||r.length===1}),jsxRuntime.jsx(antd.Dropdown,{overlay:f(),disabled:s||r.length===1,children:jsxRuntime.jsx(antd.Button,{style:{width:25},icon:jsxRuntime.jsx(Icon.DownOutlined,{style:{fontSize:"0.5em"}}),onClick:I=>I.preventDefault()})})]})}function DropdownButton(e){const{icon:o,tooltip:r,items:a=[],onItemClick:s,label:c,disabled:l=!1}=e;function d(){const f=a==null?void 0:a.map((p,m)=>p.name==="divider"?jsxRuntime.jsx(antd.Menu.Divider,{},"divider"+m):jsxRuntime.jsx(antd.Menu.Item,{children:p.name},p.id));return jsxRuntime.jsx(antd.Menu,{onClick:u,children:jsxRuntime.jsx(antd.Menu.ItemGroup,{title:r,children:f})})}function u(f){const p=a.find(m=>isNaN(f.key)?m.id===f.key:m.id===parseInt(f.key));s(p)}return jsxRuntime.jsx(antd.Dropdown,{overlay:d(),disabled:l||!a||a.length===0,children:jsxRuntime.jsxs(antd.Button,{children:[o," ",c," ",jsxRuntime.jsx(Icon.DownOutlined,{})]})})}function ActionButton(e){const{onClick:o,disabled:r=!1,loading:a=!1,tooltip:s,icon:c,label:l,type:d="default"}=e,u=a?jsxRuntime.jsx(Icon.LoadingOutlined,{}):c;return jsxRuntime.jsxs(ButtonWithTooltip,{type:d,tooltip:s,onClick:o,disabled:r,children:[u,l]})}function NewButton(e){const{disabled:o=!1}=e,{formHasChanges:r,onNewClicked:a}=React.useContext(ActionViewContext),{t:s,lang:c}=React.useContext(LocaleContext),l=()=>{if(r){showDialog$6({lang:c,onOk:()=>{a()}});return}a()};return jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.FileAddOutlined,{}),tooltip:s("new"),onClick:l,disabled:o})}const{confirm}=antd.Modal,showDialog=({onOk:e,onCancel:o,lang:r})=>{confirm({title:tForLang("unsavedChanges",r),icon:jsxRuntime.jsx(Icon.ExclamationCircleOutlined,{}),centered:!0,content:tForLang("confirmRefreshWithoutSave",r),okText:tForLang("discardAndRefresh",r),cancelText:tForLang("cancel",r),onOk:e,onCancel:o})};async function showLogInfo(e,o,r){const a=(await ConnectionProvider.getHandler().getLogInfo({model:e,ids:[o]}))[0],{create_date:s,create_uid:c,id:l,write_date:d,write_uid:u}=a;showDialog$7(jsxRuntime.jsxs("div",{children:["ID: "+l," ",jsxRuntime.jsx("br",{}),r("createdBy")+": "+c[1]," ",jsxRuntime.jsx("br",{}),r("creationDate")+": "+s," ",jsxRuntime.jsx("br",{}),r("lastUpdatedBy")+": "+u[1]," ",jsxRuntime.jsx("br",{}),r("lastUpdatedDate")+": "+d]}))}const AttachmentsButtonWrapper=e=>{const{numberOfAttachments:o,disabled:r}=e,{t:a}=React.useContext(LocaleContext),[s,c]=React.useState(!1),l=jsxRuntime.jsxs(antd.Button,{disabled:r,children:[jsxRuntime.jsx(Icon.LinkOutlined,{}),`(${o})`,jsxRuntime.jsx(Icon.DownOutlined,{style:{fontSize:12}})]});return r?l:jsxRuntime.jsx(antd.Popover,{onVisibleChange:d=>c(d),visible:s,placement:"bottom",content:Content$1(e,c),title:a("attachments"),arrowContent:null,children:l})},Content$1=(e,o)=>{const{attachments:r=[],loading:a,onAddNewAttachment:s,onopenAttachmentLink:c,onOpenAttachmentDetail:l,onListAllAttachments:d}=e,{t:u}=React.useContext(LocaleContext);return a?jsxRuntime.jsx(antd.Spin,{style:{padding:20}}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("a",{style:{display:"block",paddingBottom:5},href:"#",onClick:()=>{o(!1),d()},children:[jsxRuntime.jsx(Icon.TableOutlined,{})," ",u("listAllAttachments")]}),jsxRuntime.jsxs("a",{style:{display:"block"},href:"#",onClick:()=>{o(!1),s()},children:[jsxRuntime.jsx(Icon.FileAddOutlined,{})," ",u("addNewAttachment")]}),r.length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("li",{className:" ant-dropdown-menu-item-divider"}),r.map(f=>{const p=f.link?Icon.LinkOutlined:Icon.DownloadOutlined;return jsxRuntime.jsxs(antd.Row,{style:{paddingTop:4,paddingBottom:4},wrap:!1,align:"middle",children:[jsxRuntime.jsx(antd.Col,{flex:"auto",children:f.name}),jsxRuntime.jsx(antd.Col,{flex:"25px",style:{textAlign:"center"},children:(f.datas_fname||f.link)&&jsxRuntime.jsx(antd.Tooltip,{title:f.link?u("openAttachmentLink"):u("download"),children:jsxRuntime.jsx(p,{style:{cursor:"pointer"},onClick:()=>{o(!1),c(f)}})})}),jsxRuntime.jsx(antd.Col,{flex:"25px",style:{textAlign:"center"},children:jsxRuntime.jsx(antd.Tooltip,{title:u("openAttachment"),children:jsxRuntime.jsx(Icon.FormOutlined,{style:{cursor:"pointer"},onClick:()=>{o(!1),l(f)}})})})]},f.id)})]})]})};function AttachmentsButton(e){const{attachments:o,disabled:r=!1,onAddNewAttachment:a,onListAllAttachments:s,onViewAttachmentDetails:c}=e,{formRef:l}=React.useContext(ActionViewContext),[d,u]=React.useState(!1),[f,p]=React.useState([]),[m,I]=React.useState(!1),{t:h}=React.useContext(LocaleContext),g=React.useCallback(async()=>{u(!0);try{const y=await ConnectionProvider.getHandler().readObjects({model:"ir.attachment",ids:o.map(v=>v.id),fieldsToRetrieve:["name","datas_fname","link"],context:l.current.getContext()});p(y.map(v=>({id:v.id,name:v.name,datas_fname:v.datas_fname,link:v.link})))}catch(y){showDialog$8(y)}u(!1)},o),C=React.useCallback(async y=>{if(y.link){window.open(y.link);return}I(!0);let v;try{v=(await ConnectionProvider.getHandler().readObjects({model:"ir.attachment",ids:[y.id],context:l.current.getContext()}))[0]}catch(O){showDialog$8(O)}if(I(!1),!!v)if(v.datas){const O=await getMimeType(v.datas);openBase64InNewTab(v.datas,O.mime)}else c(v)},[]),b=React.useCallback(async y=>{c(y)},[]);return React.useEffect(()=>{g()},[g]),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(AttachmentsButtonWrapper,{numberOfAttachments:o.length,attachments:f,disabled:r,loading:d,onAddNewAttachment:a,onListAllAttachments:s,onopenAttachmentLink:C,onOpenAttachmentDetail:b}),jsxRuntime.jsx(antd.Modal,{title:h("downloadingAttachment"),visible:m,footer:null,closable:!1,centered:!0,maskClosable:!1,children:jsxRuntime.jsx(antd.Spin,{})})]})}function FormActionBar({toolbar:e}){const{availableViews:o,currentView:r,setCurrentView:a,onFormSave:s,formHasChanges:c,formIsSaving:l,currentId:d,results:u,setCurrentItemIndex:f,currentItemIndex:p,setCurrentId:m,currentModel:I,setRemovingItem:h,removingItem:g,duplicatingItem:C,setDuplicatingItem:b,setResults:y,formIsLoading:v,attachments:O,formRef:w,setFormHasChanges:_,searchTreeRef:A,previousView:L,setPreviousView:E,goToResourceId:P}=React.useContext(ActionViewContext),{t:F,lang:W}=React.useContext(LocaleContext),J=React.useContext(ContentRootContext),{processAction:z}=J||{},Y=React.useContext(TabManagerContext),{openRelate:Q,openDefaultActionForModel:re}=Y||{};function ee(N){if(c){showDialog({lang:W,onOk:()=>{N()}});return}N()}function X(N){if(c){showDialog$6({lang:W,onOk:()=>{N()}});return}N()}function ue(){u&&u.length>p+1?(f==null||f(p+1),m==null||m(u[p+1].id)):u&&p+1===u.length&&(f==null||f(0),m==null||m(u[0].id))}function Re(){u&&p>0?(f==null||f(p-1),m==null||m(u[p-1].id)):u&&p===0&&(f==null||f(u.length-1),m==null||m(u[u.length-1].id))}function xe(){showDialog$9({confirmMessage:F("confirmRemoveItem"),lang:W,onOk:()=>{ce()}})}async function ce(){try{h==null||h(!0),await ConnectionProvider.getHandler().delete({model:I,ids:[d]});const N=u==null?void 0:u.filter(oe=>oe.id!==d);y==null||y(N);let U=0;p>0&&p<=u.length-1&&(U=p-1),N!=null&&N[U]?(m==null||m(N==null?void 0:N[U].id),f==null||f(U)):(m==null||m(void 0),f==null||f(void 0))}catch(N){showDialog$3(JSON.stringify(N))}finally{h==null||h(!1)}}async function Ce(){try{b==null||b(!0);const N=await ConnectionProvider.getHandler().duplicate({id:d,model:I,context:w.current.getContext()});N&&await(P==null?void 0:P(N))}catch(N){showDialog$3(JSON.stringify(N))}finally{b==null||b(!1)}}const te=l||g||v||C;function de(N){z==null||z({actionData:N,values:w.current.getValues(),fields:w.current.getFields(),context:w.current.getContext(),onRefreshParentValues:()=>{w.current.fetchValues()}})}return r?jsxRuntime.jsxs(antd.Space,{wrap:!0,children:[v&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(antd.Spin,{}),separator$2(),separator$2()]}),jsxRuntime.jsx(NewButton,{disabled:l||v||g||C}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.SaveOutlined,{}),tooltip:F("save"),disabled:!c||te,loading:l,onClick:s}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.CopyOutlined,{}),tooltip:F("duplicate"),disabled:c||l||d===void 0||C||v,loading:C,onClick:Ce}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.DeleteOutlined,{}),tooltip:F("delete"),disabled:l||d===void 0||g||C||v,loading:g,onClick:xe}),separator$2(),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.InfoCircleOutlined,{}),tooltip:F("showLogs"),disabled:l||d===void 0||g||C||v,loading:!1,onClick:()=>{showLogInfo(I,d,F)}}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.ReloadOutlined,{}),tooltip:F("refresh"),disabled:l||d===void 0||g||C||v,loading:!1,onClick:()=>{ee(()=>{w.current.fetchValues()})}}),separator$2(),jsxRuntime.jsx(ChangeViewButton,{currentView:r,previousView:L,availableViews:o,onChangeView:N=>{E==null||E(r),_==null||_(!1),a==null||a(N)},disabled:te,formHasChanges:c}),separator$2(),jsxRuntime.jsxs(antd.Space,{children:[jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.LeftOutlined,{}),tooltip:F("previous"),disabled:te,loading:!1,onClick:()=>{X(Re)}}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.RightOutlined,{}),tooltip:F("next"),disabled:te,loading:!1,onClick:()=>{X(ue)}})]}),separator$2(),jsxRuntime.jsx(DropdownButton,{icon:jsxRuntime.jsx(Icon.ThunderboltOutlined,{}),disabled:te,tooltip:F("actions"),items:e==null?void 0:e.action,onItemClick:N=>{!N||de(N)}}),jsxRuntime.jsx(DropdownButton,{icon:jsxRuntime.jsx(Icon.PrinterOutlined,{}),disabled:te,tooltip:F("reports"),items:e==null?void 0:e.print,onItemClick:N=>{!N||de({...N,datas:{...N.datas||{},ids:[d]}})}}),jsxRuntime.jsx(DropdownButton,{icon:jsxRuntime.jsx(Icon.EnterOutlined,{}),disabled:te,tooltip:F("related"),items:e==null?void 0:e.relate,onItemClick:async N=>{!N||Q({relateData:N,values:w.current.getValues(),fields:w.current.getFields(),action_id:N.id,action_type:N.type})}}),jsxRuntime.jsx(AttachmentsButton,{disabled:te,attachments:O,onAddNewAttachment:()=>{const N=d,U=I;re({model:"ir.attachment",values:{selection_associated_object:`${U},${N}`},forced_values:{res_model:U,res_id:N},initialViewType:"form"})},onListAllAttachments:()=>{const N=d;re({model:"ir.attachment",domain:[["res_model","=",`${I}`],["res_id","=",`${N}`]],initialViewType:"tree"})},onViewAttachmentDetails:N=>{re({model:"ir.attachment",res_id:N.id,initialViewType:"form"})}})]}):null}function separator$2(){return jsxRuntime.jsx("div",{className:"inline-block w-2"})}const LinkInput=e=>{const{ooui:o,value:r,onChange:a,valueValidator:s,linkPrefix:c=""}=e,{id:l,readOnly:d,required:u}=o,f=u&&!d?Config.requiredClass:void 0,p=React.useContext(FormContext$1),{elementHasLostFocus:m}=p||{},[I,h]=React.useState(!1),[g,C]=React.useState(!1);React.useEffect(()=>{d&&!I&&C(!1),!r&&!d&&(h(!0),C(!0))},[I,d]);const b=y=>{a==null||a(y.target.value)};return jsxRuntime.jsxs(antd.Row,{gutter:8,wrap:!1,align:"middle",children:[d?null:jsxRuntime.jsx(antd.Col,{flex:"32px",children:I?jsxRuntime.jsx(antd.Button,{icon:jsxRuntime.jsx(Icon.CheckOutlined,{}),onClick:()=>{s(r)&&(h(!1),C(!1))},tabIndex:-1}):jsxRuntime.jsx(antd.Button,{icon:jsxRuntime.jsx(Icon.EditOutlined,{}),onClick:()=>{h(!0),C(!0)},tabIndex:-1})}),jsxRuntime.jsx(antd.Col,{flex:"auto",children:g?jsxRuntime.jsx(antd.Input,{id:l,onChange:b,className:f,value:r,onBlur:()=>{s(r)&&(h(!1),C(!1),m==null||m())}}):jsxRuntime.jsx("a",{href:`${c}${r}`,style:{color:"#1890ff",paddingRight:15},target:"_blank",children:r})})]})},Url=e=>{const{ooui:o}=e,{required:r}=o;return jsxRuntime.jsx(Field$1,{required:r,...e,children:jsxRuntime.jsx(LinkInput,{ooui:o,valueValidator:a=>a?isURL(a):!1})})},Email=e=>{const{ooui:o}=e,{required:r}=o;return jsxRuntime.jsx(Field$1,{required:r,...e,children:jsxRuntime.jsx(LinkInput,{ooui:o,linkPrefix:"mailto:",valueValidator:a=>a?isEmail(a):!1})})},GoToResourceModal=e=>{const{visible:o,onIdSubmitted:r,onCancel:a,isSearching:s}=e,{t:c}=React.useContext(LocaleContext);function l(d){r(d.id)}return jsxRuntime.jsx(antd.Modal,{title:c("goToResourceId"),centered:!0,visible:o,footer:null,destroyOnClose:!0,onCancel:a,maskClosable:!1,children:jsxRuntime.jsxs(antd.Form,{layout:"vertical",onFinish:l,autoComplete:"off",children:[jsxRuntime.jsx(antd.Form.Item,{name:"id",label:c("searchId"),rules:[{required:!0,type:"number"}],children:jsxRuntime.jsx(antd.InputNumber,{style:{width:"100%"},autoFocus:!0})}),jsxRuntime.jsx(antd.Row,{align:"middle",justify:"end",children:jsxRuntime.jsx(antd.Col,{children:jsxRuntime.jsxs(antd.Space,{children:[jsxRuntime.jsx(antd.Button,{icon:jsxRuntime.jsx(Icon.CloseOutlined,{}),htmlType:"button",onClick:a,disabled:s,children:c("cancel")}),jsxRuntime.jsx(antd.Button,{loading:s,style:{marginLeft:15},icon:jsxRuntime.jsx(Icon.CheckOutlined,{}),htmlType:"submit",type:"primary",disabled:s,children:c("ok")})]})})})]})})};function ButtonWithBadge(e){const{badgeNumber:o=0,...r}=e;return jsxRuntime.jsxs("div",{style:{position:"relative"},children:[o>0&&jsxRuntime.jsx("div",{style:{position:"absolute",left:-10,top:-10,zIndex:2},children:jsxRuntime.jsx("span",{style:{display:"inline-block",minWidth:"22px",padding:"2px",borderRadius:"50%",fontSize:"12px",textAlign:"center",background:"#1890FF",color:"#fefefe"},children:o})}),jsxRuntime.jsx(ButtonWithTooltip,{...r,style:{width:46,zIndex:0}})]})}function GraphActionBar({refreshGraph:e}){const{t:o}=React.useContext(LocaleContext),{availableViews:r,currentView:a,setCurrentView:s,searchParams:c,searchVisible:l,setSearchVisible:d,graphIsLoading:u,previousView:f,setPreviousView:p}=React.useContext(ActionViewContext);return jsxRuntime.jsxs(antd.Space,{wrap:!0,children:[jsxRuntime.jsx(ButtonWithBadge,{icon:jsxRuntime.jsx(Icon.FilterOutlined,{style:{color:l?"white":void 0}}),tooltip:o("advanced_search"),type:l?"primary":"default",onClick:()=>{d==null||d(!l)},disabled:u,badgeNumber:c==null?void 0:c.length}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.ReloadOutlined,{}),tooltip:o("refresh"),disabled:u,loading:!1,onClick:()=>{e()}}),jsxRuntime.jsx(ChangeViewButton,{currentView:a,availableViews:r,onChangeView:m=>{p==null||p(a),s==null||s(m)},disabled:!1,previousView:f})]})}const{Title:Title$1,Text:Text$1}=antd.Typography;function TitleHeader(e){const{title:o,children:r}=e,{title:a,currentView:s,currentId:c,currentItemIndex:l,results:d,totalItems:u,selectedRowItems:f}=React.useContext(ActionViewContext),{t:p}=React.useContext(LocaleContext);function m(){if((s==null?void 0:s.type)==="form")return c?u===0?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[p("editingDocument")," (id: ",jsxRuntime.jsx(Text$1,{copyable:!0,children:c}),")"]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[p("register")," ",l===void 0?1:l+1," /"," ",d.length," ",p("of")," ",u," - ",p("editingDocument")," (id:"," ",jsxRuntime.jsx(Text$1,{copyable:!0,children:c}),")"]}):"";if((s==null?void 0:s.type)==="tree"&&f){if(f.length===1)return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:["1 ",p("selectedRegisters")," - (id:"," ",jsxRuntime.jsx(Text$1,{copyable:!0,children:f[0].id}),")"]});if(f.length>1)return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[f.length," ",p("selectedRegisters"),jsxRuntime.jsx(Text$1,{copyable:{text:f.map(I=>I.id).join(", ")}})]})}return null}return jsxRuntime.jsxs("div",{style:{position:"sticky",top:80,zIndex:3},children:[jsxRuntime.jsxs(antd.Row,{className:"rounded shadow-md bg-blueGray-100",style:{padding:"1em"},align:"middle",children:[jsxRuntime.jsxs(antd.Col,{flex:2,children:[jsxRuntime.jsx(Title$1,{level:3,style:{marginBottom:0},children:o||a}),m()]}),jsxRuntime.jsx(antd.Col,{flex:3,children:jsxRuntime.jsx(antd.Row,{justify:"end",children:r})})]}),jsxRuntime.jsx("div",{className:"pb-5"})]})}const GraphActionView=e=>{const{viewData:o,visible:r,model:a,context:s,domain:c,formView:l,treeView:d}=e,u=React.useRef(),f=React.useContext(ActionViewContext),{setResults:p=void 0,setCurrentItemIndex:m=void 0,currentId:I=void 0,results:h=void 0,setSelectedRowItems:g=void 0,setSearchParams:C=void 0,searchVisible:b=!0,setSearchVisible:y=void 0,sorter:v=void 0,setSorter:O=void 0,setTotalItems:w=void 0,setSearchTreeNameSearch:_=void 0,setTreeIsLoading:A=void 0,limit:L,setLimit:E,searchParams:P,searchValues:F,setSearchValues:W,currentView:J}=f||{},[z,Y]=React.useState(!0);React.useEffect(()=>{var Re;(Re=u.current)==null||Re.refresh()},[P]),React.useEffect(()=>{o.view_id!==J.view_id&&Y(!0)},[J]);const{clear:Q,searchFilterLoading:re,searchError:ee,offset:X,tableRefreshing:ue}=useSearch({model:a,setSearchTreeNameSearch:_,setSelectedRowItems:g,searchParams:P,setSearchValues:W,setSearchParams:C,setSearchVisible:y,setTreeIsLoading:A,context:s,formView:l,treeView:d,sorter:v,setSorter:O,setCurrentItemIndex:m,setResultsActionView:p,resultsActionView:h,domain:c,currentId:I,setActionViewTotalItems:w,limit:L,setLimit:E});return!r||!o?null:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(TitleHeader,{title:o.name,children:jsxRuntime.jsx(GraphActionBar,{refreshGraph:()=>{u.current.refresh()}})}),jsxRuntime.jsx(SearchFilter,{fields:{...d.fields,...l.fields},searchFields:mergeSearchFields([l.search_fields,d.search_fields]),limit:L,onClear:Q,offset:X,isSearching:re,onSubmit:Re=>{Y(!1),C==null||C(Re.params),y==null||y(!1)},searchError:ee,searchVisible:b,searchValues:F,showLimitOptions:!1}),ue?jsxRuntime.jsx(antd.Spin,{}):jsxRuntime.jsx(Graph,{ref:u,view_id:o.view_id,model:a,context:s,domain:mergeParams(P||[],c),limit:z?L:void 0,manualIds:z?h==null?void 0:h.map(Re=>Re.id):void 0})]})},FormActionView=e=>{const{visible:o,formRef:r,model:a,currentId:s,domain:c,formView:l,context:d,defaultValues:u,forcedValues:f,results:p,setResults:m,setCurrentItemIndex:I}=e;return o?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(TitleHeader,{children:jsxRuntime.jsx(FormActionBar,{toolbar:l==null?void 0:l.toolbar})}),jsxRuntime.jsx(Form$1,{rootForm:!0,ref:r,model:a,defaultValues:u,forcedValues:f,formView:l,actionDomain:c,id:s,parentContext:d,onSubmitSucceed:(h,g)=>{p.findIndex(b=>b.id===h)===-1&&(p.push(g),m(p),I(p.length-1))}})]}):null};function SearchBar(e){const{onSearch:o,disabled:r=!1,searchText:a}=e,{t:s}=React.useContext(LocaleContext),[c]=antd.Form.useForm(),[l,d]=React.useState(!1);function u(p){o(p.search)}React.useEffect(()=>{c.setFieldsValue({search:a})},[a]);function f(){d(!1),c.setFieldsValue({search:void 0}),o(void 0)}return jsxRuntime.jsx(antd.Form,{form:c,onFinish:u,autoComplete:"off",children:jsxRuntime.jsxs(antd.Row,{align:"middle",justify:"end",children:[jsxRuntime.jsx(antd.Col,{children:jsxRuntime.jsx(antd.Form.Item,{name:"search",noStyle:!0,children:jsxRuntime.jsx(antd.Input,{autoFocus:!0,disabled:r,onChange:p=>{d(p.target.value.length>0)},suffix:(l||a&&a.length>0)&&jsxRuntime.jsx(antd.Tooltip,{title:s("clear"),children:jsxRuntime.jsx(Icon.CloseCircleFilled,{style:{color:"rgba(0,0,0,.45)"},onClick:f})})})})}),jsxRuntime.jsx(antd.Col,{children:jsxRuntime.jsx(antd.Button,{htmlType:"submit",disabled:r,children:s("search")})})]})})}function TreeActionBar(e){var xe;const{availableViews:o,currentView:r,setCurrentView:a,selectedRowItems:s,setRemovingItem:c,removingItem:l,duplicatingItem:d,setDuplicatingItem:u,currentModel:f,searchTreeRef:p,setCurrentId:m,setCurrentItemIndex:I,searchParams:h,searchVisible:g,setSearchVisible:C,setSearchTreeNameSearch:b,searchTreeNameSearch:y,treeIsLoading:v,setPreviousView:O,previousView:w,results:_,limit:A}=React.useContext(ActionViewContext),{parentContext:L={},treeExpandable:E,toolbar:P}=e,{t:F,lang:W}=React.useContext(LocaleContext),J=React.useContext(ContentRootContext),{processAction:z}=J||{},[Y,Q]=React.useState(!1),re=y!==void 0&&y.trim().length>0;function ee(){showDialog$9({confirmMessage:F("confirmRemove"),lang:W,onOk:()=>{X()}})}async function X(){var ce;try{c==null||c(!0),await ConnectionProvider.getHandler().delete({model:f,ids:s.map(Ce=>Ce.id)}),m==null||m(void 0),I==null||I(void 0),(ce=p==null?void 0:p.current)==null||ce.refreshResults()}catch(Ce){showDialog$8(Ce)}finally{c==null||c(!1)}}async function ue(){var ce;try{u==null||u(!0);const Ce=s[0].id;await ConnectionProvider.getHandler().duplicate({id:Ce,model:f,context:{...L}})&&((ce=p==null?void 0:p.current)==null||ce.refreshResults())}catch(Ce){showDialog$8(Ce)}finally{u==null||u(!1)}}function Re(ce){z==null||z({actionData:ce,values:{active_id:s==null?void 0:s.map(Ce=>Ce.id)[0],active_ids:s==null?void 0:s.map(Ce=>Ce.id)},fields:{},context:{...L,active_id:s==null?void 0:s.map(Ce=>Ce.id)[0],active_ids:s==null?void 0:s.map(Ce=>Ce.id)},onRefreshParentValues:()=>{var Ce;(Ce=p==null?void 0:p.current)==null||Ce.refreshResults()}})}return jsxRuntime.jsxs(antd.Space,{wrap:!0,children:[E?null:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(SearchBar,{disabled:d||l||v,searchText:y,onSearch:ce=>{ce&&ce.trim().length>0?b==null||b(ce):b==null||b(void 0)}}),separator$1(),jsxRuntime.jsx(NewButton,{disabled:v}),separator$1(),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.CopyOutlined,{}),tooltip:F("duplicate"),disabled:!s||(s==null?void 0:s.length)!==1||d||v,loading:d,onClick:ue}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.DeleteOutlined,{}),tooltip:F("delete"),disabled:!(s&&(s==null?void 0:s.length)>0)||v,loading:l,onClick:ee}),separator$1()]}),!E&&jsxRuntime.jsx(ButtonWithBadge,{icon:jsxRuntime.jsx(Icon.FilterOutlined,{style:{color:g?"white":void 0}}),tooltip:F("advanced_search"),type:g?"primary":"default",onClick:()=>{C==null||C(!g)},disabled:d||l||v,badgeNumber:h==null?void 0:h.length}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.InfoCircleOutlined,{}),tooltip:F("showLogs"),disabled:!(s&&(s==null?void 0:s.length)>0)||v,loading:!1,onClick:()=>{showLogInfo(f,s[0].id,F)}}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.ReloadOutlined,{}),tooltip:F("refresh"),disabled:d||l||v,loading:!1,onClick:()=>{var ce;(ce=p==null?void 0:p.current)==null||ce.refreshResults()}}),!E&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[separator$1(),jsxRuntime.jsx(ChangeViewButton,{currentView:r,availableViews:o,onChangeView:ce=>{O==null||O(r),a==null||a(ce)},previousView:w,disabled:v})]}),separator$1(),jsxRuntime.jsx(DropdownButton,{icon:jsxRuntime.jsx(Icon.ThunderboltOutlined,{}),disabled:!(s&&(s==null?void 0:s.length)>0)||v,tooltip:F("actions"),items:P==null?void 0:P.action,onItemClick:ce=>{!ce||Re(ce)}}),jsxRuntime.jsx(DropdownButton,{icon:jsxRuntime.jsx(Icon.PrinterOutlined,{}),disabled:!(s&&(s==null?void 0:s.length)>0)||v,tooltip:F("reports"),items:P==null?void 0:P.print,onItemClick:ce=>{!ce||Re({...ce,datas:{...ce.datas||{},ids:s.map(Ce=>Ce.id)}})}}),separator$1(),jsxRuntime.jsx(DropdownButton,{icon:jsxRuntime.jsx(Icon__default.default,{component:()=>jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"icon icon-tabler icon-tabler-database-export",width:"1em",height:"1em",viewBox:"0 0 24 24","stroke-width":"1.5",fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round",children:[jsxRuntime.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),jsxRuntime.jsx("ellipse",{cx:"12",cy:"6",rx:"8",ry:"3"}),jsxRuntime.jsx("path",{d:"M4 6v6c0 1.657 3.582 3 8 3a19.84 19.84 0 0 0 3.302 -.267m4.698 -2.733v-6"}),jsxRuntime.jsx("path",{d:"M4 12v6c0 1.599 3.335 2.905 7.538 2.995m8.462 -6.995v-2m-6 7h7m-3 -3l3 3l-3 3"})]})}),tooltip:F("export"),items:[{id:"print_screen",name:F("printScreen")},{id:"export",name:F("advancedExport")}],onItemClick:ce=>{if(ce.id==="print_screen"){let Ce=(s==null?void 0:s.map(te=>te.id))||[];Ce.length===0&&(Ce=(_==null?void 0:_.map(te=>te.id))||[]),Re({id:-1,model:f,report_name:"printscreen.list",type:"ir.actions.report.xml",datas:{model:f,ids:Ce}});return}Q(!0)},disabled:d||l||v||re}),jsxRuntime.jsx(ExportModal,{visible:Y,locale:W,onClose:()=>Q(!1),model:f,domain:mergeParams(((xe=p==null?void 0:p.current)==null?void 0:xe.getDomain())||[],h||[]),limit:A,totalRegisters:(_==null?void 0:_.length)||0,selectedRegistersToExport:s&&s.length&&s.length>0?s.length:void 0,context:L})]})}function separator$1(){return jsxRuntime.jsx("div",{className:"inline-block w-2"})}const TreeActionView=e=>{const{visible:o,searchTreeRef:r,model:a,context:s,formView:c,treeView:l,domain:d,setCurrentItemIndex:u,results:f,setCurrentId:p,setCurrentView:m,availableViews:I,searchTreeNameSearch:h}=e,{currentView:g,setPreviousView:C}=React.useContext(ActionViewContext);return o?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(TitleHeader,{children:jsxRuntime.jsx(TreeActionBar,{toolbar:l==null?void 0:l.toolbar,parentContext:s,treeExpandable:(l==null?void 0:l.isExpandable)||!1})}),jsxRuntime.jsx(SearchTree$1,{ref:r,rootTree:!0,model:a,parentContext:s,nameSearch:h,formView:c,treeView:l,domain:d,onRowClicked:b=>{const{id:y}=b;p(y);const v=f.findIndex(w=>w.id===y);C==null||C(g),u(v);const O=I.find(w=>w.type==="form");m(O)}})]}):null},DashboardActionContext=React__default.default.createContext(null),DashboardActionProvider=e=>{const[o,r]=React.useState(!1),[a,s]=React.useState(!1),{children:c,dashboardRef:l,openAction:d}=e;return jsxRuntime.jsx(DashboardActionContext.Provider,{value:{isLoading:o,setIsLoading:r,dashboardRef:l,openAction:d,moveItemsEnabled:a,setMoveItemsEnabled:s},children:c})};function DashboardActionBar(){const{isLoading:e,dashboardRef:o,moveItemsEnabled:r,setMoveItemsEnabled:a}=React.useContext(DashboardActionContext),{t:s}=React.useContext(LocaleContext);return jsxRuntime.jsxs(antd.Space,{wrap:!0,children:[jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.BorderOuterOutlined,{style:{color:r?"white":void 0}}),type:r?"primary":"default",tooltip:s("moveDashboard"),disabled:e,loading:!1,onClick:()=>{a(!r)}}),separator(),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.SettingOutlined,{}),tooltip:s("configDashboard"),disabled:e,loading:!1,onClick:()=>{o==null||o.current.configDashboard()}}),jsxRuntime.jsx(ActionButton,{icon:jsxRuntime.jsx(Icon.ReloadOutlined,{}),tooltip:s("refresh"),disabled:e,loading:!1,onClick:()=>{o==null||o.current.refresh()}})]})}function separator(){return jsxRuntime.jsx("div",{className:"inline-block w-2"})}const DashboardActionView=e=>{const{dashboardData:o}=e,r=React.useRef(),a=React.useContext(TabManagerContext),{openShortcut:s}=a||{};return o?jsxRuntime.jsxs(DashboardActionProvider,{dashboardRef:r,openAction:c=>{s(c)},children:[jsxRuntime.jsx(TitleHeader,{children:jsxRuntime.jsx(DashboardActionBar,{})}),jsxRuntime.jsx(Dashboard$1,{ref:r,model:o.model,id:o.id,context:o==null?void 0:o.context,configAction:o==null?void 0:o.configAction})]}):null};function ActionView(e,o){const{domain:r,model:a,context:s,views:c,title:l,setCanWeClose:d,tabKey:u,initialView:f,formDefaultValues:p,formForcedValues:m={},res_id:I=!1,action_id:h,action_type:g,treeExpandable:C=!1,limit:b}=e,[y,v]=React.useState(),[O,w]=React.useState([]),[_,A]=React.useState(!0),L=I||void 0,[E,P]=React.useState(L),[F,W]=React.useState([]),[J,z]=React.useState(),[Y,Q]=React.useState([]),[re,ee]=React.useState(),[X,ue]=React.useState(0),[Re,xe]=React.useState(!1),[ce,Ce]=React.useState(!1),[te,de]=React.useState(),{t:N}=React.useContext(LocaleContext),U=React.useRef(),oe=React.useRef(),Te=React.useContext(TabManagerContext),{setCurrentView:Fe,setCurrentId:M,tabs:j,activeKey:we,openAction:je}=Te||{};reactHotkeysHook.useHotkeys("ctrl+g,command+g",Ct=>{Ct.preventDefault(),Tt()},[we,j,y,J,Y]);function tt(Ct){P(Ct),M==null||M(Ct)}function Ne(Ct){v(Ct),Fe==null||Fe(Ct)}React.useImperativeHandle(o,()=>({canWeClose:yt}));const Ge=async()=>{A(!0);const Ct=[];for(const zt of c){const[Ut,Kt]=zt;let Gt;try{Kt!=="dashboard"&&(Gt=await ConnectionProvider.getHandler().getView({model:a,type:Kt,id:Ut,context:s}))}catch(fn){console.error(`${a} - ${Kt}\xA0- ${JSON.stringify(fn,null,2)}`);continue}switch(Kt){case"dashboard":{const fn=c.find(_t=>{const[,Ft]=_t;return Ft==="form"});let nn;fn&&(nn={action_id:h,action_type:g,name:l,res_id:s.active_id,res_model:a,view_id:fn[0],view_type:fn[1]}),Ct.push({type:"dashboard",id:s.active_id,model:a,context:s,configAction:nn});break}case"form":{Ct.push({...Gt,type:Kt});break}case"tree":{Ct.push({...Gt,isExpandable:C,type:Kt});break}case"graph":{Ct.push({...Gt,type:Kt});break}}}let Dt;!f&&Ct.find(zt=>zt.type==="tree")?Dt=Ct.find(Ut=>Ut.type==="tree"):f?Dt=Ct.find(Ut=>f.id?Ut.type===f.type&&Ut.view_id===f.id:Ut.type===f.type):Dt=Ct.find(Ut=>Ut.type==="form"),Dt||showDialog$8(`Error determining the first view to show.
|
|
285
285
|
Please, make sure the view ids on the fields_view_get responses are the same as the ones defined in the action`),Ne(Dt),w(Ct),A(!1)};d({tabKey:u,canWeClose:yt}),React.useEffect(()=>{const Ct=O.find(zt=>zt.type==="tree"),Dt=O.find(zt=>f.id?zt.type===f.type&&zt.view_id===f.id:zt.type===f.type);Ne(Dt||Ct),I?M==null||M(L):(tt(void 0),z(void 0)),Ge()},[a,c,I]),React.useEffect(()=>{we===u&&(M==null||M(E),Fe==null||Fe(y))},[j,we]);async function yt(){return y.type==="form"?await U.current.cancelUnsavedChanges():!0}async function Tt(){we===u&&(y.type==="form"&&!await U.current.cancelUnsavedChanges()||xe(!0))}async function Ot(Ct){var Kt;Ce(!0);const Dt=Y.findIndex(Gt=>Gt.id===Ct);let zt;if(Dt===-1){try{zt=(Kt=await ConnectionProvider.getHandler().readObjects({model:a,ids:[Ct],context:s}))==null?void 0:Kt[0]}catch{}if(!zt){Ce(!1),xe(!1),showDialog$7(N("idNotFound"));return}}else zt=Y[Dt];Ce(!1),xe(!1);const Ut=c.find(Gt=>Gt[1]==="form");je({domain:[],context:s,model:a,views:c,title:l,target:"current",initialView:{id:Ut==null?void 0:Ut[0],type:"form"},action_id:h,action_type:g,res_id:Ct})}function $t(){return O.map(Ct=>{switch(Ct.type){case"form":return jsxRuntime.jsx(FormActionView,{formRef:U,currentId:E,visible:y.type===Ct.type&&y.view_id===Ct.view_id,formView:Ct,model:a,context:s,domain:r,defaultValues:p,forcedValues:m,results:Y,setResults:Q,setCurrentItemIndex:z},`${Ct.type}-${Ct.view_id}`);case"tree":return jsxRuntime.jsx(TreeActionView,{visible:y.type===Ct.type&&y.view_id===Ct.view_id,limit:b,model:a,context:s,domain:r,formView:O.find(Dt=>Dt.type==="form"),treeView:Ct,searchTreeRef:oe,searchTreeNameSearch:te,availableViews:O,results:Y,setCurrentItemIndex:z,setCurrentId:tt,setCurrentView:Ne},`${Ct.type}-${Ct.view_id}`);case"graph":return jsxRuntime.jsx(GraphActionView,{visible:y.type===Ct.type&&y.view_id===Ct.view_id,viewData:Ct,model:a,context:s,domain:r,treeView:O.find(Dt=>Dt.type==="tree"),formView:O.find(Dt=>Dt.type==="form")},`${Ct.type}-${Ct.view_id}`);case"dashboard":return jsxRuntime.jsx(DashboardActionView,{dashboardData:Ct},`${Ct.type}-${Ct.view_id}`)}})}function Vt(){if(E===void 0&&y.type==="form")U.current.clearAndReload();else{tt(void 0);const Ct=O.find(Dt=>Dt.type==="form");Ne(Ct)}}return _?jsxRuntime.jsx(antd.Spin,{}):y?jsxRuntime.jsxs(ActionViewProvider,{title:l,currentView:y,setCurrentView:Ne,availableViews:O,formRef:U,searchTreeRef:oe,onNewClicked:Vt,currentId:E,setCurrentId:tt,setCurrentItemIndex:z,currentItemIndex:J,results:Y,setResults:Q,currentModel:a,sorter:re,setSorter:ee,totalItems:X,setTotalItems:ue,selectedRowItems:F,setSelectedRowItems:W,setSearchTreeNameSearch:de,searchTreeNameSearch:te,goToResourceId:Ot,limit:b,children:[$t(),jsxRuntime.jsx(GoToResourceModal,{visible:Re,onIdSubmitted:Ot,isSearching:ce,onCancel:()=>{xe(!1)}})]}):null}const ActionView$1=React.forwardRef(ActionView);var getRandomValues,rnds8=new Uint8Array(16);function rng(){if(!getRandomValues&&(getRandomValues=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!getRandomValues))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return getRandomValues(rnds8)}const REGEX=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function validate(e){return typeof e=="string"&®EX.test(e)}for(var byteToHex=[],i=0;i<256;++i)byteToHex.push((i+256).toString(16).substr(1));function stringify(e){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=(byteToHex[e[o+0]]+byteToHex[e[o+1]]+byteToHex[e[o+2]]+byteToHex[e[o+3]]+"-"+byteToHex[e[o+4]]+byteToHex[e[o+5]]+"-"+byteToHex[e[o+6]]+byteToHex[e[o+7]]+"-"+byteToHex[e[o+8]]+byteToHex[e[o+9]]+"-"+byteToHex[e[o+10]]+byteToHex[e[o+11]]+byteToHex[e[o+12]]+byteToHex[e[o+13]]+byteToHex[e[o+14]]+byteToHex[e[o+15]]).toLowerCase();if(!validate(r))throw TypeError("Stringified UUID is invalid");return r}function v4(e,o,r){e=e||{};var a=e.random||(e.rng||rng)();if(a[6]=a[6]&15|64,a[8]=a[8]&63|128,o){r=r||0;for(var s=0;s<16;++s)o[r+s]=a[s];return o}return stringify(a)}async function fetchAction({actionId:e,rootContext:o={},globalValues:r={}}){const a="ir.actions.act_window",s=`${a},${e}`,c=await ConnectionProvider.getHandler().getActionData({action:s,context:o}),l=ooui.parseContext({context:c.context,values:r,fields:{}}),d=c.domain?await ConnectionProvider.getHandler().evalDomain({domain:c.domain,values:r,context:{...o,...l}}):[],{res_model:u,views:f,name:p,limit:m,view_type:I}=c,h=I==="tree",g=[];for(const v of f){const[O,w]=v;if(O)g.push(v);else{const{view_id:_}=await ConnectionProvider.getHandler().getView({model:u,type:w,id:O,context:{...o,...l}});g.push([_,w])}}const[C,b]=g[0],y={id:C,type:b};return{title:p,actionId:e,actionType:a,key:v4(),views:f,model:u,context:{...o,...l},domain:d,initialView:y,limit:m,treeExpandable:h}}const styles$1="",styles="",ResponsiveReactGridLayout=reactGridLayout.WidthProvider(reactGridLayout.Responsive),DashboardGrid=e=>{const{children:o=[],onPositionItemsChanged:r}=e,a=React__default.default.Children.map(o,s=>{const{parms:c,id:l}=s.props;return jsxRuntime.jsx("div",{"data-grid":c,children:s},l)});return jsxRuntime.jsx(ResponsiveReactGridLayout,{className:"layout",cols:{lg:12,md:10,sm:6,xs:4,xxs:2},draggableHandle:".draggable-head",rowHeight:30,onLayoutChange:s=>{r==null||r(s.map(c=>({id:parseInt(c.i.replace(".$",""),10),x:c.x,y:c.y,w:c.w,h:c.h})))},children:a})},{Text}=antd.Typography,DashboardGridItem=e=>{const{id:o,title:r,children:a,action:s,openAction:c}=e;return jsxRuntime.jsxs("div",{className:"shadow-md rounded",style:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden",border:"1px solid #eee",backgroundColor:"white"},children:[jsxRuntime.jsxs(antd.Row,{className:"bg-blueGray-100",align:"middle",style:{borderBottom:"1px solid #ddd"},wrap:!1,children:[jsxRuntime.jsx(antd.Col,{flex:"auto",className:"draggable-head",style:{fontWeight:"bold",padding:"0.5rem",cursor:"grab",overflow:"hidden"},children:jsxRuntime.jsx(Text,{ellipsis:!0,children:r})}),s&&jsxRuntime.jsx(antd.Col,{flex:"25px",style:{padding:"0.5rem"},children:jsxRuntime.jsx(antd.Row,{justify:"end",align:"middle",children:jsxRuntime.jsx(Icon.ExportOutlined,{style:{cursor:"pointer"},onClick:()=>{c==null||c(s)}})})})]}),a]})},DEFAULT_SEARCH_LIMIT=80;function DashboardTree(e){const{action:o,model:r,view_id:a,onRowClicked:s,domain:c=[],visible:l=!0,parentContext:d={}}=e,[u,f]=React.useState(!1),[p,m]=React.useState(!1),[I,h]=React.useState(),[g,C]=React.useState(),[b,y]=React.useState(),[v,O]=React.useState(1),[w,_]=React.useState(0),A=React.useRef(DEFAULT_SEARCH_LIMIT),L=React.useRef([]),[E,P]=React.useState(0),[F,W]=React.useState([]),[J,z]=React.useState(void 0),[Y,Q]=React.useState(),[re,ee]=React.useState(),[X,ue]=React.useState(),[Re,xe]=React.useState(!1),ce=React.useRef([]),Ce=M=>{xe(!0),O(M),_((M-1)*A.current)},te=async()=>{const M=ce.current.length>0?ce.current:c,j=mergeParams(L.current,M),{colors:we}=getTree(g),{totalItems:je,results:tt,attrsEvaluated:Ne}=await ConnectionProvider.getHandler().searchForTree({params:j,limit:A.current,offset:w,model:I,fields:g.fields,context:d,attrs:we&&{colors:we}}),Ge=await je;P(Ge),z(getColorMap(Ne));const yt=sortResults({resultsToSort:tt,sorter:Y,fields:{...g.fields,...b.fields}});W(yt)},de=async()=>{try{xe(!0),await te()}catch(M){ee(JSON.stringify(M))}finally{xe(!1)}};React.useEffect(()=>{!p||l&&de()},[v,w,p,l]);const N=async M=>{m(!1),f(!0),ue(void 0);try{M==="action"?await U():await oe(),m(!0)}catch(j){ue(j)}finally{f(!1)}},U=async()=>{const M=await ConnectionProvider.getHandler().getViewsForAction({action:o,context:d});ce.current=M.domain,y(M.views.get("form")),C(M.views.get("tree")),h(M.model),A.current=M.limit},oe=async()=>{h(r);const M=await ConnectionProvider.getHandler().getView({model:r,type:"form",context:d});y(M);const j=await ConnectionProvider.getHandler().getView({model:r,type:"tree",id:a,context:d});C(j)};React.useEffect(()=>{o?N("action"):r&&N("model")},[o,r]);const Te=M=>{const{id:j}=M;s({id:j,model:I,treeView:g})},Fe=()=>!g||!b?null:jsxRuntime.jsxs("div",{style:{overflowY:"scroll"},children:[re&&jsxRuntime.jsx(antd.Alert,{className:"mt-10",message:re,type:"error",banner:!0}),jsxRuntime.jsx(Tree,{showPagination:!1,total:E,limit:A.current,page:v,treeView:g,results:F,onRequestPageChange:Ce,loading:Re,onRowClicked:Te,colorsForResults:J,sorter:Y,onChangeSort:M=>{Q==null||Q(M);const j=sortResults({resultsToSort:F,sorter:M,fields:{...g.fields,...b.fields}});W(j)}})]});return X?jsxRuntime.jsx(antd.Alert,{className:"mt-10",message:X,type:"error",banner:!0}):u?jsxRuntime.jsx(antd.Spin,{style:{padding:"2rem"}}):Fe()}const DashboardForm=e=>{const{model:o}=e,[r,a]=React.useState();React.useEffect(()=>{s()},[o]);async function s(){const c=await ConnectionProvider.getHandler().search({params:[],model:o,limit:1});c.length>0&&a(c[0].id)}return jsxRuntime.jsx("div",{style:{padding:"0.5rem",overflowY:"scroll"},children:jsxRuntime.jsx(Form$1,{...e,model:o,id:r,readOnly:!0})})},itemsField="line_ids";function Dashboard(e,o){const{model:r,context:a={},id:s,configAction:c}=e,[l,d]=React.useState([]),[u,f]=React.useState(!1),[p,m]=React.useState(),{setIsLoading:I,openAction:h,moveItemsEnabled:g}=React.useContext(DashboardActionContext),C=React.useRef(),b=React.useRef();React.useEffect(()=>{y()},[r,s,a]),React.useImperativeHandle(o,()=>({refresh:()=>{y()},configDashboard:L}));async function y(){f(!0),I(!0),m(void 0);try{const E=await v(),P=await w(E),F=E.fields[itemsField].relation,W=P[itemsField].items;b.current=E.fields;const J=await O({items:W,model:F,context:a}),z=await _(J);d(z),f(!1),I(!1)}catch(E){m(JSON.stringify(E))}}async function v(){return await ConnectionProvider.getHandler().getView({model:r,type:"form",context:a})}async function O({items:E,model:P,context:F}){return C.current=(await ConnectionProvider.getHandler().getView({model:P,type:"form",context:F})).fields,await readObjectValues({treeFields:C.current,formFields:C.current,model:P,items:E,context:F})}async function w(E){return(await ConnectionProvider.getHandler().readObjects({model:r,ids:[s],fields:E.fields,context:a}))[0]}async function _(E){const P=[];for(const F of E){const{values:W}=F;if(W.action_id&&W.action_id.length>0){const J=parseInt(W.action_id[0],10),z=await fetchAction({actionId:J,rootContext:a});P.push({...F,actionData:z})}}return P}async function A(E){if(!g)return;const P=E.filter(z=>{const Y=l.find(re=>re.id===z.id);if(!Y)return!1;if(!Y.position)return!0;const Q={...JSON.parse(Y.position.replace(/'/g,'"')),id:Y.id};return JSON.stringify(z)!==JSON.stringify(Q)});if(P.length===0)return;const W=l.filter(z=>P.map(Y=>Y.id).includes(z.id)).map(z=>{const Y={...P.find(Q=>Q.id===z.id)};return delete Y.id,{...z},{...z,operation:"pendingUpdate",values:{...z.values,position:JSON.stringify(Y).replace(/"/g,"'")}}}),J={fields:C.current,items:W};await ConnectionProvider.getHandler().update({model:r,id:s,values:{[itemsField]:J},fields:b.current,context:a})}async function L(){h(c)}return p?jsxRuntime.jsx(antd.Alert,{className:"mt-10 mb-20",message:p,type:"error",banner:!0}):u?jsxRuntime.jsx(Icon.LoadingOutlined,{}):jsxRuntime.jsx(DashboardGrid,{onPositionItemsChanged:A,children:l.map((E,P)=>{const{actionData:F,values:W}=E,{position:J,id:z}=W,{actionId:Y,actionType:Q,key:re,title:ee,views:X,model:ue,context:Re,domain:xe,initialView:ce,limit:Ce}=F;let te={};try{te=JSON.parse(J.replace(/'/g,'"'))}catch{te={x:P*2,y:0,w:2,h:3}}let de=null;if((ce==null?void 0:ce.type)==="graph")de=jsxRuntime.jsx(Graph,{view_id:X.filter(oe=>oe[1]==="graph")[0][0],model:ue,context:Re,domain:xe,limit:Ce});else if((ce==null?void 0:ce.type)==="form")de=jsxRuntime.jsx(DashboardForm,{model:ue,actionDomain:xe});else if((ce==null?void 0:ce.type)==="tree")de=jsxRuntime.jsx(DashboardTree,{model:ue,domain:xe,view_id:X.filter(oe=>oe[1]==="tree")[0][0],onRowClicked:oe=>{const Te=X.find(Fe=>{const[,M]=Fe;return M==="form"});if(Te){const[Fe,M]=Te,{actionId:j,actionType:we,title:je,model:tt}=F,Ne={action_id:j,action_type:we,name:je,res_id:oe.id,res_model:tt,view_id:Fe,view_type:M};h(Ne)}}});else if(ce!==void 0){const oe=ce&&Array.isArray(ce.id)?{...ce,id:ce.id[0]}:ce;de=jsxRuntime.jsx(ActionView$1,{action_id:Y,action_type:Q,tabKey:re,title:ee,views:X,model:ue,context:Re,domain:xe,setCanWeClose:()=>{},initialView:oe,limit:Ce})}let N;const U=X.find(oe=>{const[,Te]=oe;return Te==="tree"});if(U){const[oe,Te]=U,{actionId:Fe,actionType:M,title:j,model:we}=F;N={action_id:Fe,action_type:M,name:j,res_id:!1,res_model:we,view_id:oe,view_type:Te}}return jsxRuntime.jsx(DashboardGridItem,{id:z,title:ee,parms:te,action:N,openAction:h,children:de},z)})})}const Dashboard$1=React.forwardRef(Dashboard),MultiCheckbox=e=>{const{ooui:o}=e;return jsxRuntime.jsx(Field$1,{type:"array",...e,children:jsxRuntime.jsx(MultiCheckboxInput,{ooui:o})})},MultiCheckboxInput=e=>{const{value:o,ooui:r,onChange:a}=e,{items:s=[]}=o||{},c=s.filter(E=>E.operation!=="pendingRemove").map(E=>E.id),[l,d]=React.useState([]),[u,f]=React.useState(),[p,m]=React.useState(!1),{relation:I,context:h,readOnly:g,field:C,columns:b}=r,y=React.useContext(FormContext$1),{getContext:v}=y||{};useDeepCompareEffect__default.default(()=>{w()},[s]);const O=E=>{a==null||a({items:E})};async function w(){m(!0);let E=[];if(r.domain){const P=await ConnectionProvider.getHandler().evalDomain({domain:r.domain,values:transformPlainMany2Ones({fields:y==null?void 0:y.getFields(),values:y.getPlainValues()}),context:y.getContext()});E=[...E,...P]}try{const F=(await ConnectionProvider.getHandler().search({model:I,params:E,fields:[C],context:{...v==null?void 0:v(),...h}})).map(W=>{const J=W[C];let z=J;return Array.isArray(J)&&(z=J[1]),{label:z,value:W.id}});d(F)}catch(P){f(P)}finally{m(!1)}if(u)return jsxRuntime.jsx(antd.Alert,{className:"mt-10",message:u,type:"error",banner:!0})}const _=()=>{L(l.map(E=>E.value))},A=()=>{L([])},L=E=>{const P=s.map(W=>E.includes(W.id)?W.operation=="pendingRemove"?{...W,operation:"original"}:W:{id:W.id,operation:"pendingRemove"}),F=P.map(W=>W.id);E.filter(W=>!F.includes(W)).map(W=>{P.push({id:W,operation:"pendingLink"})}),O(P)};return p&&l.length===0?jsxRuntime.jsx(antd.Spin,{}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsxs("div",{className:"flex flex-row",children:[jsxRuntime.jsx(antd.Checkbox.Group,{value:l.length?c:[],disabled:g,onChange:L,style:{width:"100%"},children:jsxRuntime.jsx(antd.Row,{children:l.map(E=>jsxRuntime.jsx(antd.Col,{span:Math.floor(24/b),children:jsxRuntime.jsx(antd.Checkbox,{value:E.value,children:E.label})}))})}),!g&&jsxRuntime.jsxs(antd.Space,{children:[jsxRuntime.jsx(antd.Button,{onClick:_,disabled:c.length==l.length,children:"Check all"}),jsxRuntime.jsx(antd.Button,{onClick:A,disabled:c.length===0,children:"Uncheck all"})]})]})})},Radio=e=>{const{ooui:o}=e,{required:r}=o;return jsxRuntime.jsx(Field$1,{required:r,type:"any",...e,children:jsxRuntime.jsx(SelectionInput,{...e})})},SelectionInput=e=>{const{ooui:o,onChange:r,value:a}=e,{selectionValues:s,readOnly:c,direction:l}=o,d=Array.from(s.entries()),u=d&&d.length&&d.map(f=>{const[p,m]=f;return jsxRuntime.jsx(antd.Radio,{value:p,children:m},p)});return jsxRuntime.jsx(antd.Radio.Group,{disabled:c,onChange:r,value:a,children:jsxRuntime.jsx(antd.Space,{direction:l,children:u})})},Switch=e=>{const{ooui:o}=e,{id:r,readOnly:a,required:s}=o;return jsxRuntime.jsx(Field$1,{...e,valuePropName:"checked",children:jsxRuntime.jsx(SwitchInput,{id:r,readOnly:a,required:s})})},SwitchInput=e=>{const{required:o,readOnly:r,...a}=e;return jsxRuntime.jsx("div",{className:"flex flex-row",children:jsxRuntime.jsx(antd.Switch,{disabled:r,...a})})},Steps=e=>{const{ooui:o}=e,{required:r}=o;return jsxRuntime.jsx(Field$1,{required:r,type:"any",...e,children:jsxRuntime.jsx(StepsInput,{...e})})},StepsInput=e=>{const{ooui:o,value:r}=e,{selectionValues:a,errorField:s}=o,c=React.useContext(FormContext$1),l=Array.from(a.entries()),d=l.map(p=>p[0]).indexOf(r);let u="process",f="";return s&&(f=c.getFieldValue(s),f&&(u="error")),jsxRuntime.jsx(antd.Steps,{current:d,status:u,children:l.map((p,m)=>jsxRuntime.jsx(antd.Steps.Step,{title:p[1],description:m===d&&u==="error"?f:null}))})},CodeEditor=e=>{const{ooui:o}=e,{lang:r,height:a}=o,s=React.useContext(FormContext$1),{elementHasLostFocus:c}=s||{},l=d=>{d.onDidBlurEditorWidget(c)};return jsxRuntime.jsx(Field$1,{...e,children:jsxRuntime.jsx(Editor__default.default,{defaultLanguage:r||"",height:a||300,onMount:l})})},{Content}=antd.Layout,{Title}=antd.Typography;function Welcome(){const{t:e}=React.useContext(LocaleContext);return jsxRuntime.jsx(Content,{className:"m-5 select-none",children:jsxRuntime.jsx(Title,{level:5,children:e("welcome")})})}function RootView(e,o){const{children:r,globalValues:a={},rootContext:s={},lang:c}=e,[l,d]=React.useState("welcome"),[u,f]=React.useState([{title:tForLang("welcome",c),key:"welcome",closable:!0,content:jsxRuntime.jsx(Welcome,{})}]),p=React.useRef(new Map),m=React.useRef();React.useImperativeHandle(o,()=>({retrieveAndOpenAction:g,openShortcut:y}));function I(w){if(w===l){const _=u.findIndex(A=>A.key===w);u[_-1]&&d(u[_-1].key),u[_+1]&&d(u[_+1].key)}f(u.filter(_=>_.key!==w)),p.current.delete(w)}function h({tabKey:w,canWeClose:_}){p.current.set(w,_)}async function g({action:w,values:_,forced_values:A,initialViewType:L,res_id:E,domain:P=[]}){const F=await ConnectionProvider.getHandler().getActionData({action:w,context:s});if(F.type==="ir.actions.wizard"){showDialog$8("Action type not supported");return}const[W,J]=w.split(","),z=parseInt(J),Y=ooui.parseContext({context:F.context,values:a,fields:{}}),Q=F.domain?await ConnectionProvider.getHandler().evalDomain({domain:F.domain,values:a,context:{...s,...Y}}):[],{res_model:re,views:ee,name:X,target:ue,view_type:Re,limit:xe}=F,ce=Re==="tree",Ce=[];for(const de of ee){const[N,U]=de;if(N)Ce.push(de);else if(U==="dashboard")Ce.push([void 0,"dashboard"]);else{const{view_id:oe}=await ConnectionProvider.getHandler().getView({model:re,type:U,id:N,context:{...s,...Y}});Ce.push([oe,U])}}let te;if(L){const[de,N]=Ce.find(([U,oe])=>oe===L);te={id:de,type:N}}else{const[de,N]=Ce[0];te={id:de,type:N}}O({domain:[...Q,...P],context:{...s,...Y},model:re,views:Ce,title:X,target:ue,initialView:te,action_type:W,action_id:z,values:_,forced_values:A,res_id:E,treeExpandable:ce,limit:xe})}function C({title:w,content:_,key:A,action:L}){let E=[...u];u.length===1&&u[0].key==="welcome"&&(E=[...u.filter(P=>P.key!=="welcome")]),f([...E,{title:w,key:A,closable:!0,content:_,action:L}]),d(A)}async function b({relateData:w,fields:_,values:A,action_id:L,action_type:E}){const{res_model:P,context:F,domain:W,views:J,target:z,string:Y,limit:Q}=w,[re,ee]=J[0],X={id:re,type:ee},ue=ooui.parseContext({context:F,values:{...A,...a},fields:_}),Re=W?await ConnectionProvider.getHandler().evalDomain({domain:W,values:transformPlainMany2Ones({fields:_,values:{...A,...a}}),context:{...s,...ue}}):[];O({model:P,target:z,views:J,context:{...s,...ue},domain:Re,title:Y,initialView:X,action_id:L,action_type:E,limit:Q})}async function y(w){const{action_id:_,action_type:A,res_id:L,view_id:E}=w,P=`${A},${_}`,F=await ConnectionProvider.getHandler().getActionData({action:P,context:s}),W=ooui.parseContext({context:F.context,values:a,fields:{}}),J=F.domain?await ConnectionProvider.getHandler().evalDomain({domain:F.domain,values:a,context:{...s,...W}}):[],{res_model:z,views:Y,name:Q,target:re,view_type:ee,limit:X}=F,ue=ee==="tree",Re=[];for(const te of Y){const[de,N]=te;if(de)Re.push(te);else if(N==="dashboard")Re.push([void 0,"dashboard"]);else{const{view_id:U}=await ConnectionProvider.getHandler().getView({model:z,type:N,id:de,context:{...s,...W}});Re.push([U,N])}}let xe,ce;if(E==null){const te=Re.find(de=>de[0]===void 0);xe=void 0,ce=te[1]}else[xe,ce]=Re.find(te=>te[0]===void 0?!1:te[0]===E);const Ce={id:xe,type:ce};O({domain:J,context:{...s,...W},model:z,views:Re,title:Q,target:re,initialView:Ce,action_id:_,action_type:A,res_id:L,treeExpandable:ue,limit:X})}async function v({model:w,values:_,forced_values:A,initialViewType:L,res_id:E,domain:P}){const F=await ConnectionProvider.getHandler().getActionStringForModel(w);await g({action:F,values:_,forced_values:A,initialViewType:L,res_id:E,domain:P})}async function O({domain:w,context:_,model:A,views:L,title:E,target:P,initialView:F,action_id:W,action_type:J,res_id:z,values:Y,forced_values:Q,treeExpandable:re=!1,limit:ee}){const X=v4();if(P!=="current"){const ue=await ConnectionProvider.getHandler().getView({model:A,type:"form",id:F.type==="form"?F.id:void 0,context:{...s,..._}});m.current.openActionModal({domain:w,model:A,formView:ue,context:{...s,..._},actionData:{action_id:W,action_type:J,res_id:z,view_id:ue.view_id}})}else{const ue=F&&Array.isArray(F.id)?{...F,id:F.id[0]}:F;C({title:E,action:{id:W,type:J},content:jsxRuntime.jsx(ActionView$1,{action_id:W,action_type:J,tabKey:X,title:E,views:L,model:A,context:{...s,..._},domain:w,setCanWeClose:h,initialView:ue,res_id:z,formDefaultValues:Y,formForcedValues:Q,treeExpandable:re,limit:ee}),key:X})}}return jsxRuntime.jsx(LocaleContextProvider,{lang:c,children:jsxRuntime.jsx(TabManagerProvider,{openShortcut:y,openAction:O,openRelate:b,openDefaultActionForModel:v,tabs:u,activeKey:l,onRemoveTab:async w=>{const _=p.current.get(w);(await(_==null?void 0:_())||l==="welcome")&&I(w)},onChangeTab:w=>{d(w)},children:jsxRuntime.jsx(ContentRootProvider$1,{ref:m,globalValues:a,children:r})})})}const RootView$1=React.forwardRef(RootView);function Tab(e){const{label:o,onClose:r,tabKey:a,isActive:s,onSelected:c}=e,l=s?"#ffffff":"#F1F5F9";return jsxRuntime.jsxs("div",{onClick:()=>{!s&&c(a)},style:{cursor:"pointer",height:40,paddingTop:7,paddingBottom:5,paddingLeft:10,paddingRight:10,backgroundColor:l,display:"inline-flex",flex:1,flexDirection:"row",alignItems:"center",justifyContent:"center",borderTopLeftRadius:8,borderTopRightRadius:8,marginLeft:2},children:[jsxRuntime.jsx("div",{style:{color:s?"#001529":"#ADB0B3",userSelect:"none",height:40,display:"flex",justifyContent:"center",alignItems:"center",paddingLeft:5,paddingRight:5,marginBottom:2},children:o}),jsxRuntime.jsx("div",{style:{paddingLeft:5,height:40,display:"flex",justifyContent:"center",alignItems:"center"},children:jsxRuntime.jsx(Icon.CloseOutlined,{style:{color:s?"#001529":"#ADB0B3"},onClick:d=>{d.stopPropagation(),r(a)}})})]})}function TabSelector(){const e=React.useContext(TabManagerContext),{activeKey:o,tabs:r,onRemoveTab:a,onChangeTab:s}=e||{};return jsxRuntime.jsx(jsxRuntime.Fragment,{children:r.map(c=>jsxRuntime.jsx(Tab,{tabKey:c.key,label:c.title,onClose:a,isActive:o===c.key,onSelected:s},c.key))})}function TabContent(e){const{tab:o}=e,r=React.useContext(TabManagerContext),{activeKey:a}=r||{},s={display:"none"};return jsxRuntime.jsx("div",{style:o.key!==a?s:void 0,children:o.content})}const TabContent$1=React__default.default.memo(TabContent,()=>!0);function CurrentTabContent(){const e=React.useContext(TabManagerContext),{tabs:o}=e||{},r=(o==null?void 0:o.map(a=>jsxRuntime.jsx(TabContent$1,{tab:a},a.key)))||null;return jsxRuntime.jsx(jsxRuntime.Fragment,{children:r})}const FavouriteButton=e=>{const{onRetrieveShortcuts:o,onCheckIsFavourite:r,onAddFavourite:a,onRemoveFavourite:s}=e,[c,l]=React.useState(!1),[d,u]=React.useState(!1),[f,p]=React.useState([]),[m,I]=React.useState(!0),[h,g]=React.useState(),{t:C}=React.useContext(LocaleContext),b=React.useContext(TabManagerContext),{openShortcut:y,tabs:v,activeKey:O,currentView:w,currentId:_,openDefaultActionForModel:A}=b||{};React.useEffect(()=>{L()},[]),React.useEffect(()=>{F()},[v,O,w,_]);async function L(){try{I(!0);const Q=await o();p(Q)}catch(Q){showDialog$8(Q)}finally{I(!1)}}function E(Q){const{key:re}=Q,ee=f.find(X=>X.id===Number(re));(ee==null?void 0:ee.action_type)!=="ir.actions.wizard"&&(ee&&y(ee),u(!1))}function P(Q){Q&&L(),u(Q)}async function F(){if(!w)return;const Q=v.find(xe=>xe.key===O),{id:re,type:ee}=(Q==null?void 0:Q.action)||{};if(!re||!ee){l(!1);return}const X=w.view_id;let ue=!1;w.type==="form"&&(ue=_||!1);const Re=await r({action_id:re,action_type:ee,view_id:X,res_id:ue});Re!==!1&&g(Re),l(Re!==!1)}async function W(){u(!1),A==null||A({model:"ir.ui.view_sc"})}const J=jsxRuntime.jsxs(antd.Menu,{onClick:E,children:[jsxRuntime.jsxs("div",{style:{width:300,padding:5,display:"flex"},children:[jsxRuntime.jsx("div",{style:{paddingLeft:15,color:"#ccc"},children:C("favorites").toUpperCase()}),jsxRuntime.jsx("div",{style:{flexGrow:1,paddingLeft:10},children:jsxRuntime.jsx(antd.Tooltip,{title:C("edit_favorites"),children:jsxRuntime.jsx(Icon.EditOutlined,{style:{color:"#1890FF",cursor:"pointer"},onClick:W})})})]}),jsxRuntime.jsx(antd.Menu.Divider,{}),m?jsxRuntime.jsx(antd.Spin,{style:{padding:"1rem"}}):f.length>0?jsxRuntime.jsx(jsxRuntime.Fragment,{children:f.map(Q=>jsxRuntime.jsx(antd.Menu.Item,{children:jsxRuntime.jsx(z,{title:Q.name,type:Q.view_type})},Q.id))}):jsxRuntime.jsx("div",{style:{width:300,padding:5,paddingLeft:15},children:C("no_favorites")})]});function z({title:Q,type:re}){const ee=re==="tree"?jsxRuntime.jsx(Icon.TableOutlined,{}):jsxRuntime.jsx(Icon.FormOutlined,{});return jsxRuntime.jsxs(antd.Row,{wrap:!1,children:[jsxRuntime.jsx(antd.Col,{flex:"none",style:{paddingRight:20},children:ee}),jsxRuntime.jsx(antd.Col,{flex:"auto",children:Q})]})}async function Y(){if(c&&h)await s(h);else{if(!w)return;const Q=v.find(Re=>Re.key===O),{id:re,type:ee}=(Q==null?void 0:Q.action)||{},X=w.view_id;let ue=!1;if(!re||!ee){l(!1);return}w.type==="form"&&(ue=_||!1),await a({action_id:re,action_type:ee,view_id:X,res_id:ue})}await L(),l(!c)}return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(antd.Button,{type:c?"primary":"default",icon:c?jsxRuntime.jsx(Icon.StarFilled,{style:{color:"white"}}):jsxRuntime.jsx(Icon.StarOutlined,{}),style:{width:50},onClick:Y}),jsxRuntime.jsx(antd.Dropdown,{overlay:J,onVisibleChange:P,visible:d,children:jsxRuntime.jsx(antd.Button,{style:{width:25},icon:jsxRuntime.jsx(Icon.DownOutlined,{style:{fontSize:"0.5em"}}),onClick:Q=>Q.preventDefault()})})]})};exports.ActionBar=FormActionBar,exports.Binary=Binary,exports.Boolean=Boolean$1,exports.Button=Button,exports.ButtonGroup=ButtonGroup,exports.Char=Char,exports.CodeEditor=CodeEditor,exports.ConnectionProvider=ConnectionProvider,exports.ContentRootProvider=ContentRootProvider$1,exports.CurrentTabContent=CurrentTabContent,exports.Dashboard=Dashboard$1,exports.DashboardGrid=DashboardGrid,exports.DashboardGridItem=DashboardGridItem,exports.Date=Date$1,exports.DateTime=DateTime,exports.Email=Email,exports.ExportModal=ExportModal,exports.FavouriteButton=FavouriteButton,exports.Float=Float,exports.FloatTime=FloatTime,exports.Form=Form$1,exports.FormModal=FormModal,exports.GraphIndicator=GraphIndicator,exports.Group=Group,exports.Image=Image,exports.Integer=Integer,exports.Label=Label,exports.Many2one=Many2one,exports.MultiCheckbox=MultiCheckbox,exports.Notebook=Notebook,exports.One2many=One2many,exports.ProgressBar=ProgressBar,exports.Radio=Radio,exports.Reference=Reference,exports.RootView=RootView$1,exports.SearchFilter=SearchFilter,exports.SearchModal=SearchModal,exports.SearchTree=SearchTree$1,exports.Selection=Selection,exports.Separator=Separator,exports.Steps=Steps,exports.Switch=Switch,exports.TabSelector=TabSelector,exports.Tags=Tags,exports.Text=Text$2,exports.Tree=Tree,exports.Url=Url,exports.iconMapper=iconMapper,exports.showConfirmDialog=showDialog$9,Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
286
286
|
//# sourceMappingURL=react-ooui.umd.js.map
|