Board: Update Date Presenter to reuse as presenter

Signed-off-by: Anna No <anna.no@xored.com>
This commit is contained in:
Anna No 2022-04-18 23:28:59 +07:00
parent 6552eec72d
commit fc7605f279
No known key found for this signature in database
GPG Key ID: 08C11FFC23177C87
2 changed files with 22 additions and 18 deletions

View File

@ -14,7 +14,7 @@
// limitations under the License. // limitations under the License.
--> -->
<script lang="ts"> <script lang="ts">
import type { Card, CardLabel } from '@anticrm/board' import type { Card, CardDate, CardLabel } from '@anticrm/board'
import contact, { Employee } from '@anticrm/contact' import contact, { Employee } from '@anticrm/contact'
import { getResource } from '@anticrm/platform' import { getResource } from '@anticrm/platform'
@ -53,6 +53,10 @@
labels = [] labels = []
} }
function updateDate (e: CustomEvent<CardDate>) {
client.update(value, { date: e.detail })
}
getCardActions(client, { getCardActions(client, {
_id: { $in: [board.cardAction.Dates, board.cardAction.Labels, board.cardAction.Members] } _id: { $in: [board.cardAction.Dates, board.cardAction.Labels, board.cardAction.Members] }
}).then(async (result) => { }).then(async (result) => {
@ -105,7 +109,7 @@
<Label label={board.string.Dates} /> <Label label={board.string.Dates} />
</div> </div>
{#key value.date} {#key value.date}
<DatePresenter {value} on:click={dateHandler} /> <DatePresenter value={value.date} on:click={dateHandler} on:update={updateDate} />
{/key} {/key}
</div> </div>
{/if} {/if}

View File

@ -1,31 +1,31 @@
<script lang="ts"> <script lang="ts">
import type { Card } from '@anticrm/board' import type { CardDate } from '@anticrm/board'
import { getClient } from '@anticrm/presentation'
import { CheckBox, DatePresenter } from '@anticrm/ui' import { CheckBox, DatePresenter } from '@anticrm/ui'
import { createEventDispatcher } from 'svelte'
export let value: Card export let value: CardDate
export let isInline: boolean = false
const client = getClient() let isChecked = value?.isChecked
const {date} = value const dispatch = createEventDispatcher()
let isChecked = date?.isChecked
function update(){ function check() {
if (isChecked === undefined) return if (isInline || isChecked === undefined) return
client.update(value, {date: {...date, isChecked}}) dispatch('update', { ...value, isChecked })
} }
</script> </script>
{#if date} {#if value}
<div class="flex-presenter flex-gap-1 h-full"> <div class="flex-presenter flex-gap-1 h-full">
<CheckBox bind:checked={isChecked} on:value={update}/> <CheckBox bind:checked={isChecked} on:value={check} />
<div class="flex-center h-full" on:click> <div class="flex-center h-full" on:click>
<div class="flex-row-center background-button-bg-color border-radius-1 w-full"> <div class="flex-row-center background-button-bg-color border-radius-1 w-full">
{#if date.startDate} {#if value.startDate}
<DatePresenter bind:value={date.startDate} /> <DatePresenter bind:value={value.startDate} />
{/if} {/if}
{#if date.startDate && date.dueDate}-{/if} {#if value.startDate && value.dueDate}-{/if}
{#if date.dueDate} {#if value.dueDate}
<DatePresenter bind:value={date.dueDate} withTime={true} showIcon={false} /> <DatePresenter bind:value={value.dueDate} withTime={true} showIcon={false} />
{/if} {/if}
</div> </div>
</div> </div>