import{_ as T,o as n,c as p,a as o,t as c,b as k,m as z,f as D,h as M,e as w,T as $,y as x,z as B,A as I,j as A,C as E,B as O,g as P,u as U,r as l,n as C,w as d,l as t,D as f,E as b,p as m}from"./index-VLl5aIR_.chunk.mjs";const L={name:"ViewHeadlineIcon",emits:["click"],props:{title:{type:String},fillColor:{type:String,default:"currentColor"},size:{type:Number,default:24}}},j=["aria-hidden","aria-label"],W=["fill","width","height"],Z={d:"M4,5V7H21V5M4,11H21V9H4M4,19H21V17H4M4,15H21V13H4V15Z"},q={key:0};function F(i,r,s,_,e,a){return n(),p("span",z(i.$attrs,{"aria-hidden":s.title?null:"true","aria-label":s.title,class:"material-design-icon view-headline-icon",role:"img",onClick:r[0]||(r[0]=g=>i.$emit("click",g))}),[(n(),p("svg",{fill:s.fillColor,class:"material-design-icon__svg",width:s.size,height:s.size,viewBox:"0 0 24 24"},[o("path",Z,[s.title?(n(),p("title",q,c(s.title),1)):k("",!0)])],8,W))],16,j)}const G=T(L,[["render",F]]),J={name:"TaskCreateDialog",components:{CalendarPickerItem:O,Check:E,NcButton:A,NcEmptyContent:I,NcLoadingIcon:B,NcModal:x,TextBoxOutline:$,ViewHeadline:G},props:{summary:{type:String,default:""},description:{type:String,default:""}},emits:["close"],data(){return{pendingSummary:"",pendingDescription:"",pendingCalendar:null,loading:!0,creating:!1,created:!1,newTask:null}},computed:{...M({writableCalendars:"getSortedWritableCalendars",defaultCalendar:"getDefaultCalendar"}),createdMessage(){return w("tasks",'"{task}" was added to "{calendar}"',{task:this.pendingSummary,calendar:this.pendingCalendar.displayName},void 0,{sanitize:!1,escape:!1})}},beforeMount(){this.fetchCalendars()},mounted(){this.pendingSummary=this.summary,this.pendingDescription=this.description},methods:{...D(["createTask"]),t:w,changeCalendar(i){this.pendingCalendar=i},close(){this.$emit("close"),this.$root.$emit("close")},async fetchCalendars(){this.loading=!0,await U.connect({enableCalDAV:!0}),await this.$store.dispatch("fetchCurrentUserPrincipal"),await this.$store.dispatch("getCalendarsAndTrashBin"),this.pendingCalendar=this.writableCalendars[0],this.loading=!1},async addTask(){this.creating=!0;const i={summary:this.pendingSummary,note:this.pendingDescription,calendar:this.pendingCalendar};this.newTask=await this.createTask(i),this.creating=!1,this.created=!0},openNewTask(){window.location=P("apps/tasks")+`/#/calendars/${this.pendingCalendar.id}/tasks/${this.newTask.uri}`}}},K={key:0,id:"modal-inner"},Q={key:0,class:"loading-overlay"},R={class:"property property__summary"},X=["placeholder","disabled"],Y={class:"property property__notes"},ee=["disabled"],ae={class:"modal-buttons"},te={key:1,id:"modal-inner"};function ne(i,r,s,_,e,a){const g=l("NcLoadingIcon"),v=l("CalendarPickerItem"),N=l("ViewHeadline"),V=l("TextBoxOutline"),h=l("NcButton"),y=l("NcEmptyContent"),S=l("Check"),H=l("NcModal");return n(),C(H,{class:"task-selector",size:"small",onClose:a.close},{default:d(()=>[!e.creating&&!e.created?(n(),p("div",K,[e.loading?(n(),p("div",Q,[t(g,{size:40})])):k("",!0),o("h3",null,c(a.t("tasks","Create a new task")),1),t(v,{disabled:e.loading,calendar:e.pendingCalendar,calendars:i.writableCalendars,onChangeCalendar:a.changeCalendar},null,8,["disabled","calendar","calendars","onChangeCalendar"]),o("div",R,[t(N,{size:20}),f(o("input",{"onUpdate:modelValue":r[0]||(r[0]=u=>e.pendingSummary=u),type:"text",placeholder:a.t("tasks","Task summary"),disabled:e.loading},null,8,X),[[b,e.pendingSummary]])]),o("div",Y,[t(V,{size:20}),f(o("textarea",{"onUpdate:modelValue":r[1]||(r[1]=u=>e.pendingDescription=u),disabled:e.loading},null,8,ee),[[b,e.pendingDescription]])]),o("div",ae,[t(h,{onClick:a.close},{default:d(()=>[m(c(a.t("tasks","Cancel")),1)]),_:1},8,["onClick"]),t(h,{disabled:e.loading,variant:"primary",onClick:a.addTask},{default:d(()=>[m(c(a.t("tasks","Create task")),1)]),_:1},8,["disabled","onClick"])])])):(n(),p("div",te,[e.creating?(n(),C(y,{key:"creating",description:a.t("tasks","Creating the new task…")},{icon:d(()=>[t(g)]),_:1},8,["description"])):e.created?(n(),C(y,{key:"created",description:a.createdMessage},{icon:d(()=>[t(S)]),action:d(()=>[t(h,{onClick:a.close},{default:d(()=>[m(c(a.t("tasks","Close")),1)]),_:1},8,["onClick"]),t(h,{type:"primary",onClick:a.openNewTask},{default:d(()=>[m(c(a.t("tasks","Open task")),1)]),_:1},8,["onClick"])]),_:1},8,["description"])):k("",!0)]))]),_:1},8,["onClose"])}const se=T(J,[["render",ne],["__scopeId","data-v-e688878b"]]);export{se as T};
//# sourceMappingURL=TaskCreateDialog-BSGqPjjd.chunk.mjs.map
