From 1db55473181a1a2d9957a8946ac6813c7902e48a Mon Sep 17 00:00:00 2001 From: Andrey Sobolev Date: Fri, 18 Mar 2022 23:07:42 +0700 Subject: [PATCH] Calendar view (#1174) Signed-off-by: Andrey Sobolev --- models/calendar/src/index.ts | 18 ++ models/calendar/src/plugin.ts | 11 +- models/recruit/src/review.ts | 14 ++ packages/ui/lang/en.json | 4 +- packages/ui/lang/ru.json | 4 +- packages/ui/src/components/Button.svelte | 6 +- .../components/calendar/MonthCalendar.svelte | 111 +++++++++ .../components/calendar/YearCalendar.svelte | 68 ++++++ .../components/calendar/internal/DateUtils.ts | 69 ++++++ packages/ui/src/index.ts | 3 + .../src/components/TxView.svelte | 8 +- plugins/calendar-assets/lang/en.json | 10 +- plugins/calendar-assets/lang/ru.json | 10 +- .../src/components/CalendarView.svelte | 228 ++++++++++++++++++ .../src/components/Day.svelte | 54 +++++ .../src/components/EventsPopup.svelte | 38 +++ plugins/calendar-resources/src/index.ts | 4 +- plugins/calendar-resources/src/plugin.ts | 8 +- plugins/calendar-resources/tsconfig.json | 1 + 19 files changed, 654 insertions(+), 15 deletions(-) create mode 100644 packages/ui/src/components/calendar/MonthCalendar.svelte create mode 100644 packages/ui/src/components/calendar/YearCalendar.svelte create mode 100644 packages/ui/src/components/calendar/internal/DateUtils.ts create mode 100644 plugins/calendar-resources/src/components/CalendarView.svelte create mode 100644 plugins/calendar-resources/src/components/Day.svelte create mode 100644 plugins/calendar-resources/src/components/EventsPopup.svelte diff --git a/models/calendar/src/index.ts b/models/calendar/src/index.ts index f35f8387c1..3a0f546b3f 100644 --- a/models/calendar/src/index.ts +++ b/models/calendar/src/index.ts @@ -25,6 +25,7 @@ import core, { TAttachedDoc } from '@anticrm/model-core' import { TSpaceWithStates } from '@anticrm/model-task' import workbench from '@anticrm/model-workbench' import calendar from './plugin' +import view from '@anticrm/model-view' export * from '@anticrm/calendar' @@ -35,6 +36,7 @@ export const DOMAIN_CALENDAR = 'calendar' as Domain export class TCalendar extends TSpaceWithStates implements Calendar {} @Model(calendar.class.Event, core.class.AttachedDoc, DOMAIN_CALENDAR) +@UX(calendar.string.Event, calendar.icon.Calendar) export class TEvent extends TAttachedDoc implements Event { @Prop(TypeString(), calendar.string.Title) @Index(IndexKind.FullText) @@ -85,6 +87,22 @@ export function createModel (builder: Builder): void { ] } }, calendar.app.Calendar) + + builder.createDoc( + view.class.ViewletDescriptor, + core.space.Model, + { + label: calendar.string.Calendar, + icon: calendar.icon.Calendar, + component: calendar.component.CalendarView + }, + calendar.viewlet.Calendar + ) + + // Use generic child presenter + builder.mixin(calendar.class.Event, core.class.Class, view.mixin.AttributePresenter, { + presenter: view.component.ObjectPresenter + }) } export default calendar diff --git a/models/calendar/src/plugin.ts b/models/calendar/src/plugin.ts index 8e06bf53d7..f1bdce8209 100644 --- a/models/calendar/src/plugin.ts +++ b/models/calendar/src/plugin.ts @@ -15,17 +15,22 @@ import { calendarId } from '@anticrm/calendar' import calendar from '@anticrm/calendar-resources/src/plugin' +import { Ref } from '@anticrm/core' import type { IntlString } from '@anticrm/platform' import { mergeIds } from '@anticrm/platform' import { AnyComponent } from '@anticrm/ui' +import { ViewletDescriptor } from '@anticrm/view' export default mergeIds(calendarId, calendar, { component: { - CreateCalendar: '' as AnyComponent + CreateCalendar: '' as AnyComponent, + CalendarView: '' as AnyComponent }, string: { - ApplicationLabelCalendar: '' as IntlString + ApplicationLabelCalendar: '' as IntlString, + Event: '' as IntlString }, - space: { + viewlet: { + Calendar: '' as Ref } }) diff --git a/models/recruit/src/review.ts b/models/recruit/src/review.ts index bd6c19d1b8..65228dea52 100644 --- a/models/recruit/src/review.ts +++ b/models/recruit/src/review.ts @@ -81,6 +81,20 @@ export function createReviewModel (builder: Builder): void { archived: false } }) + + builder.createDoc(view.class.Viewlet, core.space.Model, { + attachTo: recruit.class.Review, + descriptor: calendar.viewlet.Calendar, + // eslint-disable-next-line @typescript-eslint/consistent-type-assertions + options: { + lookup: { + attachedTo: recruit.mixin.Candidate, + participants: contact.class.Employee, + company: contact.class.Organization + } + } as FindOptions, + config: [] + }) } function createTableViewlet (builder: Builder): void { diff --git a/packages/ui/lang/en.json b/packages/ui/lang/en.json index 748aaba17e..566353e06c 100644 --- a/packages/ui/lang/en.json +++ b/packages/ui/lang/en.json @@ -16,6 +16,8 @@ "NotSelected": "Not selected", "Today": "Today", "English": "English", - "Russian": "Russian" + "Russian": "Russian", + "CalendarLeft": "<", + "CalendarRight": ">" } } diff --git a/packages/ui/lang/ru.json b/packages/ui/lang/ru.json index 696987d51f..d9608362bc 100644 --- a/packages/ui/lang/ru.json +++ b/packages/ui/lang/ru.json @@ -16,6 +16,8 @@ "NotSelected": "Не выбрано", "Today": "Сегодня", "English": "Английский", - "Russian": "Русский" + "Russian": "Русский", + "CalendarLeft": "<", + "CalendarRight": ">" } } diff --git a/packages/ui/src/components/Button.svelte b/packages/ui/src/components/Button.svelte index 84f4be208d..0f65740e0b 100644 --- a/packages/ui/src/components/Button.svelte +++ b/packages/ui/src/components/Button.svelte @@ -20,7 +20,7 @@ import Icon from './Icon.svelte' import { onMount } from 'svelte' - export let label: IntlString + export let label: IntlString | undefined = undefined export let primary: boolean = false export let size: 'small' | 'medium' = 'medium' export let icon: Asset | AnySvelteComponent | undefined = undefined @@ -49,7 +49,9 @@ {#if loading} {:else} -