Board: Fix cover presenter (#1872)

* Fix cover presenter

Signed-off-by: Anna No <anna.no@xored.com>

* Fix cover presenter

Signed-off-by: Anna No <anna.no@xored.com>
This commit is contained in:
Anna No 2022-05-26 00:17:37 +07:00 committed by GitHub
parent 5c1c528a9d
commit ad4af2025b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 75 additions and 59 deletions

View File

@ -56,7 +56,17 @@
let handleMove: (e: Event) => void let handleMove: (e: Event) => void
let checklists: TodoItem[] = [] let checklists: TodoItem[] = []
const mixins: Mixin<Doc>[] = [] const mixins: Mixin<Doc>[] = []
const ignoreKeys = ['isArchived', 'location', 'title', 'description', 'state', 'members', 'number', 'assignee'] const ignoreKeys = [
'isArchived',
'location',
'title',
'description',
'state',
'members',
'number',
'assignee',
'doneState'
]
function change (field: string, value: any) { function change (field: string, value: any) {
if (object) { if (object) {

View File

@ -20,10 +20,8 @@
import { Ref } from '@anticrm/core' import { Ref } from '@anticrm/core'
import { getClient } from '@anticrm/presentation' import { getClient } from '@anticrm/presentation'
import { CheckBox, Label } from '@anticrm/ui' import { CheckBox, Label } from '@anticrm/ui'
import { invokeAction } from '@anticrm/view-resources'
import plugin from '../../plugin' import plugin from '../../plugin'
import { getCardActions } from '../../utils/CardActionUtils'
import { updateCardMembers } from '../../utils/CardUtils' import { updateCardMembers } from '../../utils/CardUtils'
import UserBoxList from '../UserBoxList.svelte' import UserBoxList from '../UserBoxList.svelte'
import CardLabels from './CardLabels.svelte' import CardLabels from './CardLabels.svelte'
@ -31,8 +29,6 @@
export let value: Card export let value: Card
const client = getClient() const client = getClient()
let coverHandler: (e: Event) => void
function updateMembers (e: CustomEvent<Ref<Employee>[]>) { function updateMembers (e: CustomEvent<Ref<Employee>[]>) {
updateCardMembers(value, client, e.detail) updateCardMembers(value, client, e.detail)
} }
@ -43,37 +39,40 @@
client.update(value, { doneState: null }) client.update(value, { doneState: null })
} }
} }
getCardActions(client, {
_id: { $in: [board.action.Cover] }
}).then(async (result) => {
for (const action of result) {
if (action._id === board.action.Cover) {
coverHandler = (e: Event) => invokeAction(value, e, action.action, action.actionProps)
}
}
})
</script> </script>
{#if value} {#if value}
<div class="flex-col flex-gap-3 mt-4"> <div class="attributes-bar-container">
<div class="flex-row-stretch flex-gap-1 items-center"> <div class="label fs-bold">
<div class="label w-24">
<Label label={plugin.string.Completed} /> <Label label={plugin.string.Completed} />
</div> </div>
<div class="ml-4">
<CheckBox checked={value.doneState === board.state.Completed} on:value={updateState} /> <CheckBox checked={value.doneState === board.state.Completed} on:value={updateState} />
</div> </div>
<div class="flex-row-stretch flex-gap-1 items-center"> <div class="label fs-bold">
<div class="label w-24">
<Label label={plugin.string.Members} /> <Label label={plugin.string.Members} />
</div> </div>
<div class="ml-4">
<UserBoxList value={value.members ?? []} on:update={updateMembers} /> <UserBoxList value={value.members ?? []} on:update={updateMembers} />
</div> </div>
<div class="flex-row-stretch flex-gap-1 items-center"> <div class="label fs-bold">
<div class="label w-24">
<Label label={plugin.string.Labels} /> <Label label={plugin.string.Labels} />
</div> </div>
<CardLabels {value} /> <CardLabels {value} />
</div> </div>
</div>
{/if} {/if}
<style lang="scss">
.attributes-bar-container {
height: 100%;
display: grid;
grid-template-columns: 1fr 1.5fr;
grid-auto-flow: row;
justify-content: start;
align-items: center;
gap: 0.5rem;
padding-bottom: 0.5rem;
width: 100%;
height: min-content;
}
</style>

View File

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { CardCover } from '@anticrm/board' import { CardCover } from '@anticrm/board'
import { Button, eventToHTMLElement, IconAdd, showPopup } from '@anticrm/ui' import { Button, eventToHTMLElement, Icon, IconAdd, showPopup } from '@anticrm/ui'
import CardCoverPicker from '../popups/CardCoverPicker.svelte' import CardCoverPicker from '../popups/CardCoverPicker.svelte'
import CardCoverPresenter from '../presenters/CardCoverPresenter.svelte' import CardCoverPresenter from '../presenters/CardCoverPresenter.svelte'
@ -12,8 +12,12 @@
} }
</script> </script>
<Button kind="link" on:click={coverHandler}>
<div slot="content">
{#if value} {#if value}
<CardCoverPresenter {value} on:click={coverHandler} /> <CardCoverPresenter {value} on:click={coverHandler} />
{:else} {:else}
<Button icon={IconAdd} kind="no-border" on:click={coverHandler} /> <Icon icon={IconAdd} size="small" />
{/if} {/if}
</div>
</Button>

View File

@ -15,7 +15,7 @@
<script lang="ts"> <script lang="ts">
import type { Card, CardLabel } from '@anticrm/board' import type { Card, CardLabel } from '@anticrm/board'
import { getClient } from '@anticrm/presentation' import { getClient } from '@anticrm/presentation'
import { Button, IconAdd } from '@anticrm/ui' import { Button, Icon, IconAdd } from '@anticrm/ui'
import { invokeAction } from '@anticrm/view-resources' import { invokeAction } from '@anticrm/view-resources'
import board from '../../plugin' import board from '../../plugin'
@ -68,9 +68,8 @@
} }
</script> </script>
{#if labels}
<div <div
class="flex-row-center flex-wrap flex-gap-1 mb-1" class="flex mb-1"
class:labels-inline-container={isInline} class:labels-inline-container={isInline}
on:click={toggleCompact} on:click={toggleCompact}
on:mouseover={hoverIn} on:mouseover={hoverIn}
@ -78,6 +77,8 @@
on:mouseout={hoverOut} on:mouseout={hoverOut}
on:blur={hoverOut} on:blur={hoverOut}
> >
{#if labels && labels.length > 0}
<div class="flex-row-center flex-wrap flex-gap-1 ml-4">
{#each labels as label} {#each labels as label}
<LabelPresenter <LabelPresenter
value={label} value={label}
@ -86,8 +87,10 @@
on:click={labelsHandler} on:click={labelsHandler}
/> />
{/each} {/each}
{#if !isInline} </div>
<Button icon={IconAdd} kind="no-border" size="large" on:click={labelsHandler} /> {:else if !isInline}
<Button kind="link" size="large" on:click={labelsHandler}>
<Icon slot="content" icon={IconAdd} size="small" />
</Button>
{/if} {/if}
</div> </div>
{/if}