diff --git a/crates/frontend/js-components/lib/create-addressbook-form.ts b/crates/frontend/js-components/lib/create-addressbook-form.ts index 158898a..2ace40d 100644 --- a/crates/frontend/js-components/lib/create-addressbook-form.ts +++ b/crates/frontend/js-components/lib/create-addressbook-form.ts @@ -36,27 +36,27 @@ export class CreateAddressbookForm extends LitElement {




diff --git a/crates/frontend/js-components/lib/create-birthday-calendar-form.ts b/crates/frontend/js-components/lib/create-birthday-calendar-form.ts index a99ec9a..fb55141 100644 --- a/crates/frontend/js-components/lib/create-birthday-calendar-form.ts +++ b/crates/frontend/js-components/lib/create-birthday-calendar-form.ts @@ -34,17 +34,17 @@ export class CreateCalendarForm extends LitElement {


diff --git a/crates/frontend/js-components/lib/create-calendar-form.ts b/crates/frontend/js-components/lib/create-calendar-form.ts index 8cbfd3b..91b5448 100644 --- a/crates/frontend/js-components/lib/create-calendar-form.ts +++ b/crates/frontend/js-components/lib/create-calendar-form.ts @@ -1,16 +1,30 @@ import { html, LitElement } from "lit"; import { customElement, property } from "lit/decorators.js"; import { Ref, createRef, ref } from 'lit/directives/ref.js'; -import { escapeXml } from "."; +import { escapeXml, SVG_ICON_CALENDAR, SVG_ICON_INTERNET } from "."; import { getTimezones } from "./timezones.ts"; @customElement("create-calendar-form") export class CreateCalendarForm extends LitElement { constructor() { super() + this.resetForm() this.fetchTimezones() } + resetForm() { + this.form.value?.reset() + this.principal = this.user + this.cal_id = self.crypto.randomUUID() + this.displayname = '' + this.description = '' + this.timezone_id = '' + this.color = '' + this.isSubscription = false + this.subscriptionUrl = null + this.components = new Set(["VEVENT", "VTODO"]) + } + async fetchTimezones() { this.timezones = await getTimezones() } @@ -22,23 +36,23 @@ export class CreateCalendarForm extends LitElement { @property() user: string = '' @property() - principal: string = '' + principal: string @property() - cal_id: string = self.crypto.randomUUID() + cal_id: string @property() - displayname: string = '' + displayname: string @property() - description: string = '' + description: string @property() - timezone_id: string = '' + timezone_id: string @property() - color: string = '' + color: string @property() - isSubscription: boolean = false + isSubscription: boolean @property() - subscriptionUrl: string = '' + subscriptionUrl: string @property() - components: Set<"VEVENT" | "VTODO" | "VJOURNAL"> = new Set() + components: Set<"VEVENT" | "VTODO" | "VJOURNAL"> dialog: Ref = createRef() form: Ref = createRef() @@ -47,13 +61,13 @@ export class CreateCalendarForm extends LitElement { override render() { return html` - - + + this.resetForm()}>

Create calendar

` } async submit(e: SubmitEvent) { - console.log(this.displayname) e.preventDefault() if (!this.cal_id) { alert("Empty id") @@ -135,6 +161,10 @@ export class CreateCalendarForm extends LitElement { alert("No calendar components selected") return } + if (this.isSubscription && !this.subscriptionUrl) { + alert("Invalid subscription url") + return + } let response = await fetch(`/caldav/principal/${this.principal || this.user}/${this.cal_id}`, { method: 'MKCOL', diff --git a/crates/frontend/js-components/lib/edit-addressbook-form.ts b/crates/frontend/js-components/lib/edit-addressbook-form.ts index 3560119..bc69a41 100644 --- a/crates/frontend/js-components/lib/edit-addressbook-form.ts +++ b/crates/frontend/js-components/lib/edit-addressbook-form.ts @@ -34,12 +34,12 @@ export class EditAddressbookForm extends LitElement {


diff --git a/crates/frontend/js-components/lib/edit-calendar-form.ts b/crates/frontend/js-components/lib/edit-calendar-form.ts index 2f41c63..4024a85 100644 --- a/crates/frontend/js-components/lib/edit-calendar-form.ts +++ b/crates/frontend/js-components/lib/edit-calendar-form.ts @@ -53,12 +53,12 @@ export class EditCalendarForm extends LitElement {