Files
docker-invoiceninja/docker/app/public/bundle.b74ae089.js
2024-10-19 18:17:42 +00:00

8 lines
17 KiB
JavaScript

import{p as y,R as D,P as T,u as Q,Z as ve,bp as ye,x as $e,c0 as De,d as Ve,f as _e,_ as R,j as p,bs as we,c as o,bQ as Me,H as K,bt as F,en as Se,eo as Ae,N as Be,bu as xe,m as Te,ep as E,eq as Re,cy as We,e as te,cz as He,a7 as U,et as Fe,ah as Oe,ck as z,J,ch as Ke,cA as Ue,ev as Qe,ew as qe,bc as A,ex as Ge,r as je,O as Je,z as Ze,as as Xe,ey as Ye,ez as et,eA as tt,eB as st,h as pe,T as ot,bk as rt,ba as at,eC as nt,bf as it,C as lt,b5 as ct,b6 as he,b9 as me,eD as dt,c4 as ut,eE as pt,bD as ht,bb as be,be as fe,G as mt}from"./bundle.7539e3c6.js";import{u as Ne,c as se,a as bt,b as ft,i as gt}from"./bundle.571d0bdd.js";import{T as Z}from"./bundle.9e58e57d.js";import{S as kt}from"./bundle.3b6cbf4c.js";import{P as Ie}from"./bundle.24df3a1e.js";import{u as Ct,a as vt,p as ge,L as w,b as ke,d as yt,T as $t,h as _t,c as wt,e as St}from"./bundle.66a38911.js";import"./bundle.bc220abc.js";function X(){return X=Object.assign||function(t){for(var s=1;s<arguments.length;s++){var e=arguments[s];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},X.apply(this,arguments)}function xt(t,s){if(t==null)return{};var e=Tt(t,s),r,n;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n<i.length;n++)r=i[n],!(s.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(e[r]=t[r])}return e}function Tt(t,s){if(t==null)return{};var e={},r=Object.keys(t),n,i;for(i=0;i<r.length;i++)n=r[i],!(s.indexOf(n)>=0)&&(e[n]=t[n]);return e}var oe=y.forwardRef(function(t,s){var e=t.color,r=e===void 0?"currentColor":e,n=t.size,i=n===void 0?24:n,_=xt(t,["color","size"]);return D.createElement("svg",X({ref:s,xmlns:"http://www.w3.org/2000/svg",width:i,height:i,viewBox:"0 0 24 24",fill:"none",stroke:r,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},_),D.createElement("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),D.createElement("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"}))});oe.propTypes={color:T.string,size:T.oneOfType([T.string,T.number])};oe.displayName="Edit";const Ot=oe;function Y(){return Y=Object.assign||function(t){for(var s=1;s<arguments.length;s++){var e=arguments[s];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},Y.apply(this,arguments)}function jt(t,s){if(t==null)return{};var e=Nt(t,s),r,n;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n<i.length;n++)r=i[n],!(s.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(e[r]=t[r])}return e}function Nt(t,s){if(t==null)return{};var e={},r=Object.keys(t),n,i;for(i=0;i<r.length;i++)n=r[i],!(s.indexOf(n)>=0)&&(e[n]=t[n]);return e}var re=y.forwardRef(function(t,s){var e=t.color,r=e===void 0?"currentColor":e,n=t.size,i=n===void 0?24:n,_=jt(t,["color","size"]);return D.createElement("svg",Y({ref:s,xmlns:"http://www.w3.org/2000/svg",width:i,height:i,viewBox:"0 0 24 24",fill:"none",stroke:r,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},_),D.createElement("rect",{x:"6",y:"4",width:"4",height:"16"}),D.createElement("rect",{x:"14",y:"4",width:"4",height:"16"}))});re.propTypes={color:T.string,size:T.oneOfType([T.string,T.number])};re.displayName="Pause";const It=re;function ee(){return ee=Object.assign||function(t){for(var s=1;s<arguments.length;s++){var e=arguments[s];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},ee.apply(this,arguments)}function Et(t,s){if(t==null)return{};var e=Pt(t,s),r,n;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n<i.length;n++)r=i[n],!(s.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(e[r]=t[r])}return e}function Pt(t,s){if(t==null)return{};var e={},r=Object.keys(t),n,i;for(i=0;i<r.length;i++)n=r[i],!(s.indexOf(n)>=0)&&(e[n]=t[n]);return e}var ae=y.forwardRef(function(t,s){var e=t.color,r=e===void 0?"currentColor":e,n=t.size,i=n===void 0?24:n,_=Et(t,["color","size"]);return D.createElement("svg",ee({ref:s,xmlns:"http://www.w3.org/2000/svg",width:i,height:i,viewBox:"0 0 24 24",fill:"none",stroke:r,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},_),D.createElement("polygon",{points:"5 3 19 12 5 21 5 3"}))});ae.propTypes={color:T.string,size:T.oneOfType([T.string,T.number])};ae.displayName="Play";const Lt=ae;function zt(){var O,m;const[t]=Q(),s=ve(),e=ye(),r=$e(),n=De(),i=Ve(),_=Ne(),{dateFormat:b}=_e(),[a]=R(se),x=a&&_(a.time_log),g=()=>{U(["tasks"])};return p(we,{tabs:[t("overview"),t("documents")],width:"full",formatTabLabel:v=>{if(v===1)return o(Me,{numberOfDocuments:a==null?void 0:a.documents.length})},children:[o("div",{children:a&&p(K,{children:[o(F,{leftSide:t("duration"),children:Se(a.time_log.toString())}),o(F,{leftSide:t("rate"),children:i(a.rate||r.settings.default_task_rate,(O=a.client)==null?void 0:O.country_id,(m=a.client)==null?void 0:m.settings.currency_id)}),o(F,{leftSide:t("status"),children:o(Ae,{entity:a})}),o(Be,{style:{backgroundColor:n,color:"white"},children:o("div",{className:"inline-flex items-center",children:o("span",{children:a.description})})}),x==null?void 0:x.map(([v,I,V],P)=>o(xe,{children:p("div",{className:"flex items-center justify-between",children:[p("div",{className:"flex flex-col",children:[o("p",{children:Te(v,b)}),p("small",{children:[I," - ",V]})]}),o("div",{children:E(a)&&P===x.length-1?o(Z,{task:a,calculateLastTimeLog:!0}):Re(a.time_log,P)})]})},P))]})}),p("div",{className:"px-4",children:[o(We,{endpoint:te("/api/v1/tasks/:id/upload",{id:a==null?void 0:a.id}),onSuccess:g,widgetOnly:!0,disableUpload:!s("edit_task")&&!e(a)}),o(He,{documents:(a==null?void 0:a.documents)||[],onDocumentDelete:g,disableEditableOptions:!e(a,!0)&&!s("edit_task")})]})]})}function Dt(){const[t]=Q(),[s,e]=R(se),{dateFormat:r}=_e(),n=Ct(),i=vt(),[_,b]=y.useState(!1),[a,x]=y.useState(),[g,O]=y.useState([]),m=(l,j)=>{e(S=>S&&{...S,[l]:j})},v=$e(),I=Qe(),V=Ne();y.useEffect(()=>{s!=null&&s.time_log&&O(Fe(s.time_log))},[a,s==null?void 0:s.time_log]);const P=(l,j,S,L)=>{m("time_log",i(s.time_log,l,j,S,L))},W=(l,j,S,L)=>{m("time_log",n(s.time_log,l,j,L,S))},B=(l,j,S)=>{m("time_log",_t(s.time_log,l,j,S))};return p(K,{children:[p(Oe,{title:t("time_log"),visible:_&&g.length>0,onClose:()=>{b(!1),x(void 0)},overflowVisible:!0,children:[g[Number(a)]&&p(K,{children:[o(z,{label:t("start_date"),type:"date",value:ge(g[a][w.Start]),onValueChange:l=>P(g[a][w.Start],l,a,w.Start)}),o(z,{label:t("start_time"),type:"time",step:"1",value:ke(g[a][w.Start]),onValueChange:l=>W(g[a][w.Start],l,w.Start,a)}),(v==null?void 0:v.show_task_end_date)&&o(z,{label:t("end_date"),type:"date",value:ge(g[a][w.End]),onValueChange:l=>P(g[a][w.End],l,a,w.End)}),o(z,{type:"time",step:"1",label:t("end_time"),value:ke(g[a][w.End]),onValueChange:l=>W(g[a][w.End],l,a,w.End)}),o(z,{label:t("duration"),debounceTimeout:1e3,value:yt(g[a][w.Start],g[a][w.End],v==null?void 0:v.show_task_end_date),onValueChange:l=>B(l,g[a][w.Start],a)})]}),o("div",{className:"flex justify-end",children:o(J,{onClick:()=>b(!1),children:t("done")})})]}),p(we,{tabs:[t("details"),t("times")],width:"full",children:[o("div",{children:p("div",{className:"px-4 space-y-4",children:[o(Ke,{inputLabel:t("client"),value:s==null?void 0:s.client_id,onChange:l=>m("client_id",l.id)}),o(Ie,{inputLabel:t("project"),value:s==null?void 0:s.project_id,onChange:l=>m("project_id",l.id)}),o(Ue,{inputLabel:t("user"),value:s==null?void 0:s.assigned_user_id,onChange:l=>m("assigned_user_id",l.id)}),o(z,{label:t("task_number"),value:s==null?void 0:s.number,onValueChange:l=>m("number",l)}),o(z,{label:t("rate"),value:s==null?void 0:s.rate,onValueChange:l=>m("rate",l)}),o($t,{inputLabel:t("status"),value:s==null?void 0:s.status_id,onChange:l=>l&&m("status_id",l.id),onClearButtonClick:()=>m("status_id","")}),o(z,{element:"textarea",value:s==null?void 0:s.description,onValueChange:l=>m("description",l)})]})}),o("div",{children:s&&V(s.time_log).map(([l,j,S],L)=>o(xe,{onClick:()=>{b(!0),x(L)},children:p("div",{children:[o("p",{children:Te(l,r)}),p("small",{children:[j," - ",S]})]})},L))})]}),o("div",{className:"flex justify-end p-4",children:o(J,{onClick:()=>s&&I(s),children:t("save")})})]})}function Vt(t){const[s]=Q(),{data:e}=qe(),[r,n]=y.useState(),[i,_]=y.useState(),[b,a]=y.useState(!1),x=(O,m)=>{n(v=>v&&{...v,[O]:m})},g=O=>{if(O.preventDefault(),r&&!b){if(a(!0),A.processing(),Ge(r))return A.error("task_errors");je("POST",te("/api/v1/tasks"),r).then(()=>{A.success("created_task"),U(["tasks"]),n(e),t.setVisible(!1)}).catch(m=>{var v;((v=m.response)==null?void 0:v.status)===422&&(A.dismiss(),_(m.response.data))}).finally(()=>a(!1))}};return y.useEffect(()=>{e&&t.details&&n({...e,status_id:t.details.taskStatusId,project_id:t.details.projectId?t.details.projectId:""})},[e,t.details]),p(Oe,{title:s("new_task"),visible:t.visible,onClose:()=>t.setVisible(!1),size:"large",children:[r&&o(wt,{task:r,handleChange:x,errors:i,taskModal:!0}),r&&o(St,{task:r,handleChange:x}),o(J,{className:"self-end",onClick:g,disabled:!r||b,disableWithoutIcon:!0,children:s("save")})]})}const Ce=ht.div`
min-width: ${t=>t.theme.minWidth}px;
background-color: ${t=>t.theme.backgroundColor};
color: ${t=>t.theme.color};
color-scheme: ${t=>t.theme.colorScheme};
border-color: ${t=>t.theme.borderColor};
`;function Kt(){const{documentTitle:t}=Je("kanban"),[s]=Q(),e=Ze(),{isAdmin:r,isOwner:n}=Xe(),i=Ye(),_=et(),b=ve(),a=ye(),x=[{name:s("tasks"),href:"/tasks"},{name:s("kanban"),href:"/tasks/kanban"}],[g,O]=y.useState("/api/v1/tasks?per_page=1000&status=active&without_deleted_clients=true"),[m,v]=y.useState(),[I,V]=y.useState(),[P,W]=y.useState(),[B,l]=y.useState("view"),[j,S]=y.useState(!1),[L,ne]=y.useState(!1),{data:q}=tt({status:"active"}),{data:G}=st({endpoint:g}),[f]=R(se),[ie,le]=R(ft),[ce,de]=R(gt);bt(ie),y.useEffect(()=>{if(q&&G){const c=[];[...q.data].sort((u,$)=>u.status_order-$.status_order).map(u=>c.push({id:u.id,title:u.name,cards:[]})),G.data.filter(({invoice_id:u})=>!u).map(u=>{const $=c.findIndex(k=>k.id===u.status_id);$>=0&&c[$].cards.push({id:u.id,title:u.description,description:Se(u.time_log).toString(),sortOrder:u.status_order,task:u})}),c.map(u=>u.cards=u.cards.sort(($,k)=>$.sortOrder-k.sortOrder)),v(u=>({...u,columns:c}))}},[q,G]);const ue=c=>{const d={},u=mt(c.columns).pluck("id").toArray();u.forEach(k=>d[k]=[]),c.columns.forEach(k=>{k.cards.map(C=>d[k.id].push(C.id))});const $={status_ids:u,task_ids:d};A.processing(),je("POST",te("/api/v1/tasks/sort"),$).then(()=>A.success()).finally(()=>{U(["tasks"]),U(["task_statuses"])})},Ee=c=>{var M;const d=be.cloneDeep(m),u=d.columns.find(h=>h.title===c.source.droppableId),$=d.columns.findIndex(h=>h.title===c.source.droppableId),k=d.columns.find(h=>{var N;return h.title===((N=c.destination)==null?void 0:N.droppableId)}),C=d.columns.findIndex(h=>{var N;return h.title===((N=c.destination)==null?void 0:N.droppableId)});if(u&&$>-1&&k&&C>-1){const h=u.cards.find(N=>N.id===c.draggableId);h&&(d.columns[$].cards=u.cards.filter(N=>N.id!==c.draggableId),d.columns[C].cards.push(h),d.columns[C].cards=fe(d.columns[C].cards,d.columns[C].cards.length-1,(M=c.destination)==null?void 0:M.index),v(d),ue(d))}},Pe=c=>{var $,k;const d=be.cloneDeep(m),u=fe(d.columns,c.source.index,($=c.destination)==null?void 0:$.index);c.source.index!==((k=c.destination)==null?void 0:k.index)&&(d.columns=u,v(d),ue(d))},Le=c=>{if(!c.destination)return;const d=c.source,u=c.destination;if(!(d.droppableId===u.droppableId&&d.index===u.index)){if(c.type==="COLUMN"){Pe(c);return}Ee(c)}},H=(c,d)=>{if(d==="edit"&&l("edit"),d==="view"&&l("view"),ie===c)return de(!0);le(c)},ze=()=>{de(!1),le(void 0)};return y.useEffect(()=>{O(I?pe("/api/v1/tasks?project_tasks=:projectId&per_page=1000&status=active&without_deleted_clients=true",{projectId:I}):"/api/v1/tasks?per_page=1000&status=active&without_deleted_clients=true")},[I]),p(ot,{title:t,breadcrumbs:x,navigationTopRight:o(rt,{to:"/tasks",children:p(at,{children:[o(nt,{size:20}),o("span",{children:s("tasks")})]})}),children:[p(kt,{title:f?`${s("task")} ${f.number}`:s("task"),visible:ce,onClose:ze,actionChildren:p("div",{className:"flex w-full divide-x-2",style:{color:e.$3,colorScheme:e.$0,backgroundColor:e.$1,borderColor:e.$4},children:[B==="view"&&(b("edit_task")||a(f))&&p(it,{to:pe("/tasks/:id/edit",{id:f==null?void 0:f.id}),className:"flex justify-center items-center text-sm p-4 space-x-2 w-full",children:[o(Ot,{size:18}),o("span",{children:s("edit_task")})]}),f&&!E(f)&&(b("edit_task")||a(f))&&p("button",{style:{color:e.$3,colorScheme:e.$0,backgroundColor:e.$1,borderColor:e.$4},className:"flex justify-center items-center text-sm p-4 space-x-2 w-full",onClick:()=>_(f),children:[o(Lt,{size:18}),o("span",{children:s("start")})]}),f&&E(f)&&(b("edit_task")||a(f))&&p("button",{style:{color:e.$3,colorScheme:e.$0,backgroundColor:e.$1,borderColor:e.$4},className:"flex justify-center items-center text-sm p-4 space-x-2 w-full",onClick:()=>i(f),children:[o(It,{size:18}),o("span",{children:s("stop")})]})]}),size:"regular",withoutActionContainer:!0,children:[B==="view"&&o(zt,{}),B==="edit"&&o(Dt,{})]}),o("div",{className:"grid grid-cols-12 gap-4",style:{color:e.$3,colorScheme:e.$0,backgroundColor:e.$1,borderColor:e.$4},children:o(lt,{className:"col-span-12 xl:col-span-4",children:o(F,{leftSide:s("project"),children:o(Ie,{value:I,onChange:c=>V(c.id),onClearButtonClick:()=>V(void 0),clearButton:!0})})})}),m&&p("div",{style:{color:e.$3,colorScheme:e.$0,backgroundColor:e.$1,borderColor:e.$4,paddingRight:ce?512:0},className:"flex pb-6 space-x-4 overflow-x-auto mt-4",children:[o(ct,{onDragEnd:Le,children:o(he,{droppableId:"columns",type:"COLUMN",direction:"horizontal",children:c=>p("div",{className:"flex space-x-4",ref:c.innerRef,...c.droppableProps,children:[m.columns.map((d,u)=>o(me,{draggableId:d.title,index:u,children:$=>p(Ce,{className:"bg-white rounded border shadow select-none h-max",ref:$.innerRef,...$.draggableProps,theme:{minWidth:360,color:e.$3,colorScheme:e.$0,backgroundColor:e.$1,borderColor:e.$4},children:[p("div",{...$.dragHandleProps,className:"flex items-center justify-between border-b px-4 py-5",style:{color:e.$3,colorScheme:e.$0,backgroundColor:e.$1,borderColor:e.$4},children:[o("h3",{className:"leading-6 font-medium",children:d.title}),b("create_task")&&o(dt,{className:"cursor-pointer",fontSize:22,onClick:()=>{W({taskStatusId:d.id,projectId:I}),S(!0)}})]}),o(he,{droppableId:d.title,type:"CARD",renderClone:(k,C,M)=>{const h=d.cards.find(({id:N})=>N===M.draggableId);return h?p("div",{className:"w-full text-leftblock rounded text-sm cursor-pointer",...k.draggableProps,...k.dragHandleProps,ref:k.innerRef,children:[p("div",{className:"px-4 sm:px-6 py-4",style:{color:e.$3,colorScheme:e.$0,backgroundColor:e.$4,borderColor:e.$4},children:[o("p",{children:h.title}),o("small",{children:E(h.task)?o(Z,{task:h.task}):h.description})]}),p("div",{className:"flex border-t justify-center items-center",style:{color:e.$3,colorScheme:e.$0,backgroundColor:e.$1,borderColor:e.$4},children:[(b("view_task")||b("edit_task")||a(f))&&o("button",{style:{color:e.$3,colorScheme:e.$0,backgroundColor:e.$1,borderColor:e.$4},className:"w-full py-2 rounded-bl",onClick:()=>H(h.id,"view"),children:s("view")}),(b("edit_task")||a(f))&&o("button",{style:{color:e.$3,colorScheme:e.$0,backgroundColor:e.$1,borderColor:e.$4},className:"w-full text-center py-2",onClick:()=>H(h.id,"edit"),children:s("edit")}),E(h.task)&&(b("edit_task")||a(f))&&o("button",{style:{color:e.$3,colorScheme:e.$0,backgroundColor:e.$1,borderColor:e.$4},className:"w-full py-2 rounded-br",onClick:()=>i(h.task),children:s("stop")}),!E(h.task)&&(b("edit_task")||a(f))&&o("button",{style:{color:e.$3,colorScheme:e.$0,backgroundColor:e.$1,borderColor:e.$4},className:"w-full py-2 rounded-br",onClick:()=>_(h.task),children:s("start")})]})]}):o(K,{})},children:k=>o("div",{...k.droppableProps,children:p("div",{ref:k.innerRef,className:"p-4 space-y-4",style:{color:e.$3,colorScheme:e.$0,backgroundColor:e.$1,borderColor:e.$3},children:[d.cards.map((C,M)=>o(me,{draggableId:C.id,index:M,children:h=>p(Ce,{className:"w-full text-leftblock rounded text-sm group",ref:h.innerRef,...h.draggableProps,...h.dragHandleProps,theme:{backgroundColor:e.$7,color:e.$3},children:[p("div",{className:"px-4 sm:px-6 py-4",children:[o("p",{children:C.title}),o("small",{children:E(C.task)?o(Z,{task:C.task}):C.description})]}),p("div",{className:"hidden group-hover:flex border-t justify-center items-center",style:{color:e.$3,colorScheme:e.$0,backgroundColor:e.$1,borderColor:e.$4},children:[(b("view_task")||b("edit_task")||a(f))&&o("button",{style:{color:e.$3,colorScheme:e.$0,backgroundColor:e.$1,borderColor:e.$4},className:"w-full py-2 rounded-bl",onClick:()=>H(C.id,"view"),children:s("view")}),(b("edit_task")||a(f))&&o("button",{style:{color:e.$3,colorScheme:e.$0,backgroundColor:e.$1,borderColor:e.$4},className:"w-full text-center py-2",onClick:()=>H(C.id,"edit"),children:s("edit")}),E(C.task)&&(b("edit_task")||a(f))&&o("button",{style:{color:e.$3,colorScheme:e.$0,backgroundColor:e.$1,borderColor:e.$4},className:"w-full py-2 rounded-br",onClick:()=>i(C.task),children:s("stop")}),!E(C.task)&&(b("edit_task")||a(f))&&o("button",{style:{color:e.$3,colorScheme:e.$0,backgroundColor:e.$1,borderColor:e.$4},className:"w-full py-2 rounded-br",onClick:()=>_(C.task),children:s("start")})]})]})},C.id)),k.placeholder]})})})]})},d.id)),c.placeholder]})})}),(r||n)&&o("div",{children:o("div",{className:"bg-white shadow rounded p-1",style:{color:e.$3,colorScheme:e.$0,backgroundColor:e.$1,borderColor:e.$4},children:o(ut,{style:{color:e.$3,colorScheme:e.$0,backgroundColor:e.$1,borderColor:e.$4},className:"cursor-pointer",fontSize:28,onClick:()=>ne(!0)})})})]}),o(pt,{visible:L,setVisible:ne}),o(Vt,{visible:j,setVisible:S,details:P,apiEndPoint:g})]})}export{Kt as default};