import{_ as T,c as p,o as n,a as o,b as C,t as c,m as x,g as M,h as $,e as w,T as z,N as D,i as B,j as I,k as O,C as P,l as U,f as A,n as E,r as l,p as k,w as d,q as t,u as f,v as b,x as m}from"./index-Md6Dd2Tg.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"],q=["fill","width","height"],W={d:"M4,5V7H21V5M4,11H21V9H4M4,19H21V17H4M4,15H21V13H4V15Z"},Z={key:0};function F(i,r,s,_,e,a){return n(),p("span",x(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",W,[s.title?(n(),p("title",Z,c(s.title),1)):C("",!0)])],8,q))],16,j)}const G=T(L,[["render",F]]),J={name:"TaskCreateDialog",components:{CalendarPickerItem:U,Check:P,NcButton:O,NcEmptyContent:I,NcLoadingIcon:B,NcModal:D,TextBoxOutline:z,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:{...$({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:{...M(["createTask"]),t:w,changeCalendar(i){this.pendingCalendar=i},close(){this.$emit("close"),this.$root.$emit("close")},async fetchCalendars(){this.loading=!0,await E.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=A("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(),k(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})])):C("",!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(),k(y,{key:"creating",description:a.t("tasks","Creating the new task…")},{icon:d(()=>[t(g)]),_:1},8,["description"])):e.created?(n(),k(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"])):C("",!0)]))]),_:1},8,["onClose"])}const se=T(J,[["render",ne],["__scopeId","data-v-e688878b"]]);export{se as T};
//# sourceMappingURL=TaskCreateDialog-oz4N92Ds.chunk.mjs.map
