Set particular date for reminder (#1801)

Signed-off-by: Anna No <anna.no@xored.com>
This commit is contained in:
Anna No
2022-05-19 17:36:45 +07:00
committed by GitHub
parent 59e86ce484
commit fa22aa5f7e
9 changed files with 76 additions and 26 deletions
@@ -16,7 +16,7 @@
import contact, { Employee, EmployeeAccount } from '@anticrm/contact'
import { Class, Doc, getCurrentAccount, Ref } from '@anticrm/core'
import { Card, getClient, UserBoxList } from '@anticrm/presentation'
import { TimeShiftPicker, Grid, StylishEdit } from '@anticrm/ui'
import { DateOrShift, TimeShiftPicker, Grid, StylishEdit } from '@anticrm/ui'
import { createEventDispatcher } from 'svelte'
import calendar from '../plugin'
@@ -24,7 +24,7 @@
export let attachedToClass: Ref<Class<Doc>>
export let title: string = ''
let shift = 30 * 60 * 1000
let value: DateOrShift = { shift: 30 * 60 * 1000 }
const currentUser = getCurrentAccount() as EmployeeAccount
let participants: Ref<Employee>[] = [currentUser.employee]
const space = calendar.space.PersonalEvents
@@ -37,7 +37,15 @@
}
async function saveReminder () {
const date = new Date().getTime() + shift
let date: number | undefined = undefined
if (value.date !== undefined) {
date = new Date(value.date).getTime()
} else if (value.shift !== undefined) {
date = new Date().getTime() + value.shift
}
if (date === undefined) {
return
}
const _id = await client.createDoc(calendar.class.Event, space, {
attachedTo,
attachedToClass,
@@ -58,7 +66,10 @@
<Card
label={calendar.string.CreateReminder}
okAction={saveReminder}
canSave={title !== undefined && title.trim().length > 0 && participants.length > 0}
canSave={title !== undefined &&
title.trim().length > 0 &&
participants.length > 0 &&
(value.date !== undefined || value.shift !== undefined)}
on:close={() => {
dispatch('close')
}}
@@ -66,7 +77,7 @@
<Grid column={1} rowGap={1.75}>
<StylishEdit bind:value={title} label={calendar.string.Title} />
<div class="antiComponentBox">
<TimeShiftPicker title={calendar.string.Date} bind:value={shift} direction="after" />
<TimeShiftPicker title={calendar.string.Date} bind:value direction="after" />
</div>
<UserBoxList
_class={contact.class.Employee}
@@ -14,9 +14,9 @@
-->
<script lang="ts">
import { Event } from '@anticrm/calendar'
import { Class, Ref, Timestamp } from '@anticrm/core'
import { Class, Ref } from '@anticrm/core'
import presentation, { Card, createQuery, getClient } from '@anticrm/presentation'
import { Grid, TimeShiftPicker } from '@anticrm/ui'
import { DateOrShift, Grid, TimeShiftPicker } from '@anticrm/ui'
import { createEventDispatcher } from 'svelte'
import calendar from '../plugin'
@@ -28,7 +28,7 @@
query.query(objectClass, { _id: objectId }, (res) => {
event = res[0]
})
let shift: Timestamp = -30 * 60 * 1000
let value: DateOrShift = { shift: -30 * 60 * 1000 }
let event: Event | undefined
const dispatch = createEventDispatcher()
@@ -38,7 +38,12 @@
}
async function saveReminder () {
if (event === undefined) return
if (event === undefined || (value.shift === undefined && value.date === undefined)) return
const shift = value.date !== undefined ? value.date - event.date : value.shift
if (shift === undefined) {
return
}
await client.updateMixin(event._id, event._class, event.space, calendar.mixin.Reminder, {
shift,
state: 'active'
@@ -57,7 +62,7 @@
>
<Grid column={1} rowGap={1.75}>
<div class="antiComponentBox">
<TimeShiftPicker title={calendar.string.RemindMeAt} bind:value={shift} />
<TimeShiftPicker title={calendar.string.RemindMeAt} direction="before" bind:value />
</div>
</Grid>
</Card>
+11 -11
View File
@@ -1,11 +1,11 @@
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
// It should be published with your NPM package. It should not be tracked by Git.
{
"tsdocVersion": "0.12",
"toolPackages": [
{
"packageName": "@microsoft/api-extractor",
"packageVersion": "7.23.0"
}
]
}
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
// It should be published with your NPM package. It should not be tracked by Git.
{
"tsdocVersion": "0.12",
"toolPackages": [
{
"packageName": "@microsoft/api-extractor",
"packageVersion": "7.23.0"
}
]
}