Skip to content

Commit fea10ad

Browse files
authored
Some calendar view improvements (#1175)
1 parent 1db5547 commit fea10ad

File tree

6 files changed

+108
-45
lines changed

6 files changed

+108
-45
lines changed

Diff for: models/recruit/src/review.ts

+10-3
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,16 @@ export function createReviewModel (builder: Builder): void {
9393
company: contact.class.Organization
9494
}
9595
} as FindOptions<Doc>,
96-
config: []
96+
config: [
97+
'',
98+
'title',
99+
'$lookup.attachedTo',
100+
'verdict',
101+
{ key: '', presenter: recruit.component.OpinionsPresenter, label: recruit.string.Opinions, sortingKey: 'opinions' },
102+
{ key: '$lookup.participants', presenter: calendar.component.PersonsPresenter, label: calendar.string.Participants, sortingKey: '$lookup.participants' },
103+
'$lookup.company',
104+
'modifiedOn'
105+
]
97106
})
98107
}
99108

@@ -119,8 +128,6 @@ function createTableViewlet (builder: Builder): void {
119128
'$lookup.company',
120129
'date',
121130
'dueDate',
122-
// { presenter: attachment.component.AttachmentsPresenter, label: attachment.string.Files, sortingKey: 'attachments' },
123-
// { presenter: chunter.component.CommentsPresenter, label: chunter.string.Comments, sortingKey: 'comments' },
124131
'modifiedOn'
125132
]
126133
})

Diff for: packages/ui/src/components/Tooltip.svelte

+7-2
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,15 @@
2222
export let component: AnySvelteComponent | AnyComponent | undefined = undefined
2323
export let props: any | undefined = undefined
2424
export let anchor: HTMLElement | undefined = undefined
25+
export let fill = false
2526
2627
let triggerHTML: HTMLElement
2728
let shown: boolean = false
2829
$: shown = !!($tooltip.label || $tooltip.component)
2930
</script>
3031

3132
<div
32-
class="tooltip-trigger"
33+
class="tooltip-trigger" class:fill={fill}
3334
name={`tooltip-${label}`}
3435
bind:this={triggerHTML}
3536
on:mousemove={() => {
@@ -42,5 +43,9 @@
4243
<style lang="scss">
4344
.tooltip-trigger {
4445
width: fit-content;
45-
}
46+
&.fill {
47+
width: 100%;
48+
height: 100%;
49+
}
50+
}
4651
</style>

Diff for: packages/ui/src/components/calendar/MonthCalendar.svelte

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
const todayDate = new Date()
3232
</script>
3333

34-
<div class="month-calendar">
34+
<div class="month-calendar flex-grow">
3535
<div class="days-of-week-header">
3636
{#each [...Array(7).keys()] as dayOfWeek}
3737
<div class="day-name">{getWeekDayName(day(firstDayOfCurrentMonth, dayOfWeek), weekFormat)}</div>
@@ -52,7 +52,7 @@
5252
currentDate.getMonth()}
5353
on:click={() => onSelect(weekday(firstDayOfCurrentMonth, weekIndex, dayOfWeek))}
5454
>
55-
{#if !$$slots.cell || weekday(firstDayOfCurrentMonth, weekIndex, dayOfWeek).getMonth() !== currentDate.getMonth()}
55+
{#if !$$slots.cell }
5656
{weekday(firstDayOfCurrentMonth, weekIndex, dayOfWeek).getDate()}
5757
{:else}
5858
<slot name="cell" date={weekday(firstDayOfCurrentMonth, weekIndex, dayOfWeek)} />
@@ -89,8 +89,8 @@
8989
color: var(--primary-button-color);
9090
}
9191
.cell {
92-
height: 100%;
93-
width: 100%;
92+
height: calc(100% - 5px);
93+
width: calc(100% - 5px);
9494
border-radius: 0.5rem;
9595
border: 1px solid transparent;
9696
}

Diff for: plugins/calendar-resources/src/components/CalendarView.svelte

+10-8
Original file line numberDiff line numberDiff line change
@@ -211,18 +211,20 @@
211211
</div>
212212

213213

214+
{#if mode === CalendarMode.Year}
214215
<ScrollBox bothScroll>
215-
{#if mode === CalendarMode.Year}
216216
<YearCalendar {mondayStart} cellHeight={'2.5rem'} bind:value={value} currentDate={currentDate(date, shifts)}>
217217
<svelte:fragment slot="cell" let:date>
218-
<Day events={findEvents(objects, date)} {date} />
218+
<Day events={findEvents(objects, date)} {date} {_class} {baseMenuClass} {options} {config} query={resultQuery} />
219219
</svelte:fragment>
220220
</YearCalendar>
221+
</ScrollBox>
221222
{:else if mode === CalendarMode.Month}
222-
<MonthCalendar {mondayStart} cellHeight={'5rem'} bind:value={value} currentDate={currentDate(date, shifts)}>
223-
<svelte:fragment slot="cell" let:date={date}>
224-
<Day events={findEvents(objects, date)} {date} size={'huge'}/>
225-
</svelte:fragment>
226-
</MonthCalendar>
223+
<div class='flex flex-grow'>
224+
<MonthCalendar {mondayStart} cellHeight={'8.5rem'} bind:value={value} currentDate={currentDate(date, shifts)}>
225+
<svelte:fragment slot="cell" let:date={date}>
226+
<Day events={findEvents(objects, date)} {date} size={'huge'} {_class} {baseMenuClass} {options} {config} query={resultQuery}/>
227+
</svelte:fragment>
228+
</MonthCalendar>
229+
</div>
227230
{/if}
228-
</ScrollBox>

Diff for: plugins/calendar-resources/src/components/Day.svelte

+65-16
Original file line numberDiff line numberDiff line change
@@ -14,41 +14,90 @@
1414
-->
1515
<script lang="ts">
1616
import { Event } from '@anticrm/calendar'
17+
import { Class, Doc, DocumentQuery, FindOptions, Ref } from '@anticrm/core'
1718
import { Tooltip } from '@anticrm/ui'
1819
import calendar from '../plugin'
1920
import EventsPopup from './EventsPopup.svelte'
2021
2122
export let events: Event[]
2223
export let date: Date
2324
export let size: 'small' | 'huge' = 'small'
25+
26+
export let _class: Ref<Class<Doc>>
27+
export let query: DocumentQuery<Event> = {}
28+
export let options: FindOptions<Event> | undefined = undefined
29+
export let baseMenuClass: Ref<Class<Event>> | undefined = undefined
30+
export let config: string[]
2431
</script>
2532

2633
{#if events.length > 0}
27-
<Tooltip label={calendar.string.Events} component={EventsPopup} props={{ value: events }}>
28-
<div class="cell" class:huge={size === 'huge'}>
34+
<Tooltip
35+
fill={size === 'huge'}
36+
label={calendar.string.Events}
37+
component={EventsPopup}
38+
props={{ value: events, _class, query, options, baseMenuClass, config }}
39+
>
40+
{#if size === 'huge'}
41+
<div class="cell" class:huge={size === 'huge'}>
42+
<div class="flex flex-reverse fs-title flex-grow">
43+
{date.getDate()}
44+
</div>
45+
</div>
46+
<div class="cell" class:huge={size === 'huge'}>
47+
<div class="flex-col flex-grow">
48+
{#each events.slice(0, 4) as e, ei}
49+
<div class="overflow-label flex flex-between">
50+
{e.title}
51+
<div>
52+
{new Date(e.date).getHours()}:{new Date(e.date).getMinutes()}
53+
</div>
54+
</div>
55+
{/each}
56+
{#if events.length > 4}
57+
And {events.length - 4} more
58+
{/if}
59+
</div>
60+
</div>
61+
{:else}
62+
<div class="cell">
63+
{date.getDate()}
64+
<div class="marker" />
65+
</div>
66+
{/if}
67+
</Tooltip>
68+
{:else if size === 'huge'}
69+
<!-- <div class="cell" class:huge={size === 'huge'}> -->
70+
<div class="flex flex-reverse fs-title flex-grow title">
2971
{date.getDate()}
30-
<div class="marker" />
3172
</div>
32-
</Tooltip>
73+
<!-- </div> -->
3374
{:else}
34-
{date.getDate()}
75+
<div class="cell">
76+
{date.getDate()}
77+
</div>
3578
{/if}
3679

3780
<style lang="scss">
38-
.marker {
39-
// position: relative;
40-
top: -0.25rem;
41-
width: 0.25rem;
42-
height: 0.25rem;
43-
border-radius: 50%;
44-
background-color: var(--highlight-red);
45-
}
46-
.huge {
47-
width: 5rem;
48-
}
4981
.cell {
5082
display: flex;
5183
flex-grow: 1;
5284
justify-content: center;
85+
86+
.marker {
87+
position: relative;
88+
top: -0.25rem;
89+
width: 0.25rem;
90+
height: 0.25rem;
91+
border-radius: 50%;
92+
background-color: var(--highlight-red);
93+
}
94+
&.huge {
95+
padding: 0.25rem;
96+
}
97+
}
98+
.title {
99+
margin-top: 0.25rem;
100+
margin-right: 0.25rem;
101+
align-self: flex-start;
53102
}
54103
</style>

Diff for: plugins/calendar-resources/src/components/EventsPopup.svelte

+12-12
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,23 @@
1616
<script lang="ts">
1717
1818
import type { Event } from '@anticrm/calendar'
19-
import core from '@anticrm/core'
19+
import { Class, Doc, DocumentQuery, FindOptions, Ref } from '@anticrm/core'
2020
import { Table } from '@anticrm/view-resources'
21-
import calendar from '../plugin'
2221
2322
export let value: Event[]
23+
24+
export let _class: Ref<Class<Doc>>
25+
export let query: DocumentQuery<Event> = {}
26+
export let options: FindOptions<Event> | undefined = undefined
27+
export let baseMenuClass: Ref<Class<Event>> | undefined = undefined
28+
export let config: string[]
2429
</script>
2530

2631
<Table
27-
_class={calendar.class.Event}
28-
config={['', 'title', '$lookup.space.name', 'date', 'dueDate', 'modifiedOn']}
29-
options={
30-
{
31-
lookup: {
32-
space: core.class.Space
33-
}
34-
}
35-
}
36-
query={ { _id: { $in: value.map(it => it._id) } } }
32+
_class={_class}
33+
config={config}
34+
{baseMenuClass}
35+
options={ options }
36+
query={ { ...query, _id: { $in: value.map(it => it._id) } } }
3737
loadingProps={{ length: value.length ?? 0 }}
3838
/>

0 commit comments

Comments
 (0)