mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-26 02:10:07 +00:00
Board: fix card live updates (#1403)
This commit is contained in:
parent
b6156fa52e
commit
140132bf38
@ -35,20 +35,18 @@
|
|||||||
export let _class: Ref<Class<Card>>
|
export let _class: Ref<Class<Card>>
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
const client = getClient()
|
const client = getClient()
|
||||||
const query = createQuery()
|
const cardQuery = createQuery()
|
||||||
|
const stateQuery = createQuery()
|
||||||
|
|
||||||
let object: Card | undefined
|
let object: Card | undefined
|
||||||
let state: State | undefined
|
let state: State | undefined
|
||||||
let handleMove: () => void
|
let handleMove: () => void
|
||||||
|
|
||||||
$: _id &&
|
$: cardQuery.query(_class, { _id }, async (result) => {
|
||||||
_class &&
|
|
||||||
query.query(_class, { _id }, async (result) => {
|
|
||||||
object = result[0]
|
object = result[0]
|
||||||
})
|
})
|
||||||
|
|
||||||
$: object &&
|
$: object?.state && stateQuery.query(task.class.State, { _id: object.state }, async (result) => {
|
||||||
query.query(task.class.State, { _id: object.state }, async (result) => {
|
|
||||||
state = result[0]
|
state = result[0]
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -103,7 +101,7 @@
|
|||||||
<div class="flex-grow mr-4">
|
<div class="flex-grow mr-4">
|
||||||
<div class="flex-row-streach">
|
<div class="flex-row-streach">
|
||||||
<div class="w-9" />
|
<div class="w-9" />
|
||||||
<CardDetails value={object} />
|
<CardDetails bind:value={object} />
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-row-streach mt-4 mb-2">
|
<div class="flex-row-streach mt-4 mb-2">
|
||||||
<div class="w-9">
|
<div class="w-9">
|
||||||
@ -127,10 +125,10 @@
|
|||||||
</div>
|
</div>
|
||||||
<!-- TODO attachments-->
|
<!-- TODO attachments-->
|
||||||
<!-- TODO checklists -->
|
<!-- TODO checklists -->
|
||||||
<CardActivity value={object} />
|
<CardActivity bind:value={object} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<CardActions value={object} />
|
<CardActions bind:value={object} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Scroller>
|
</Scroller>
|
||||||
@ -138,11 +136,6 @@
|
|||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.close-button {
|
|
||||||
position: absolute;
|
|
||||||
top: 0.7rem;
|
|
||||||
right: 0.7rem;
|
|
||||||
}
|
|
||||||
.state-name {
|
.state-name {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
|
|
||||||
|
@ -27,14 +27,15 @@
|
|||||||
export let value: Card
|
export let value: Card
|
||||||
const client = getClient()
|
const client = getClient()
|
||||||
|
|
||||||
|
let actionGroups: { label: IntlString; actions: CardAction[] }[] = []
|
||||||
|
|
||||||
|
async function fetch() {
|
||||||
const suggestedActions: CardAction[] = []
|
const suggestedActions: CardAction[] = []
|
||||||
const addToCardActions: CardAction[] = []
|
const addToCardActions: CardAction[] = []
|
||||||
const automationActions: CardAction[] = []
|
const automationActions: CardAction[] = []
|
||||||
const actions: CardAction[] = []
|
const actions: CardAction[] = []
|
||||||
|
const result = await getCardActions(client)
|
||||||
|
|
||||||
let actionGroups: { label: IntlString; actions: CardAction[] }[] = []
|
|
||||||
|
|
||||||
getCardActions(client).then(async (result) => {
|
|
||||||
for (const action of result) {
|
for (const action of result) {
|
||||||
let supported = true
|
let supported = true
|
||||||
if (action.supported) {
|
if (action.supported) {
|
||||||
@ -74,7 +75,14 @@
|
|||||||
actions: actions.sort(cardActionSorter)
|
actions: actions.sort(cardActionSorter)
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
}
|
||||||
|
|
||||||
|
fetch()
|
||||||
|
|
||||||
|
$: value.members && fetch()
|
||||||
|
$: value.isArchived && fetch()
|
||||||
|
$: !value.isArchived && fetch()
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if value}
|
{#if value}
|
||||||
|
@ -36,12 +36,12 @@ export function hasDate (card: Card): boolean {
|
|||||||
|
|
||||||
export function addCurrentUser (card: Card, client: Client): void {
|
export function addCurrentUser (card: Card, client: Client): void {
|
||||||
const employee = (getCurrentAccount() as EmployeeAccount).employee
|
const employee = (getCurrentAccount() as EmployeeAccount).employee
|
||||||
card.members = card.members ?? []
|
const members = card.members ?? []
|
||||||
|
|
||||||
if (card.members.includes(employee)) {
|
if (members.includes(employee)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
card.members.push(employee)
|
members.push(employee)
|
||||||
updateCard(client, card, 'members', card.members)
|
updateCard(client, card, 'members', members)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user