Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Board: fix card live updates #1403

Merged
merged 1 commit into from
Apr 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions plugins/board-resources/src/components/EditCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,18 @@
export let _class: Ref<Class<Card>>
const dispatch = createEventDispatcher()
const client = getClient()
const query = createQuery()
const cardQuery = createQuery()
const stateQuery = createQuery()

let object: Card | undefined
let state: State | undefined
let handleMove: () => void

$: _id &&
_class &&
query.query(_class, { _id }, async (result) => {
$: cardQuery.query(_class, { _id }, async (result) => {
object = result[0]
})

$: object &&
query.query(task.class.State, { _id: object.state }, async (result) => {
$: object?.state && stateQuery.query(task.class.State, { _id: object.state }, async (result) => {
state = result[0]
})

Expand Down Expand Up @@ -103,7 +101,7 @@
<div class="flex-grow mr-4">
<div class="flex-row-streach">
<div class="w-9" />
<CardDetails value={object} />
<CardDetails bind:value={object} />
</div>
<div class="flex-row-streach mt-4 mb-2">
<div class="w-9">
Expand All @@ -127,22 +125,17 @@
</div>
<!-- TODO attachments-->
<!-- TODO checklists -->
<CardActivity value={object} />
<CardActivity bind:value={object} />
</div>

<CardActions value={object} />
<CardActions bind:value={object} />
</div>
</div>
</Scroller>
</Panel>
{/if}

<style lang="scss">
.close-button {
position: absolute;
top: 0.7rem;
right: 0.7rem;
}
.state-name {
text-decoration: underline;

Expand Down
22 changes: 15 additions & 7 deletions plugins/board-resources/src/components/editor/CardActions.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@
export let value: Card
const client = getClient()

const suggestedActions: CardAction[] = []
const addToCardActions: CardAction[] = []
const automationActions: CardAction[] = []
const actions: CardAction[] = []

let actionGroups: { label: IntlString; actions: CardAction[] }[] = []

getCardActions(client).then(async (result) => {
async function fetch() {
const suggestedActions: CardAction[] = []
const addToCardActions: CardAction[] = []
const automationActions: CardAction[] = []
const actions: CardAction[] = []
const result = await getCardActions(client)

for (const action of result) {
let supported = true
if (action.supported) {
Expand Down Expand Up @@ -74,7 +75,14 @@
actions: actions.sort(cardActionSorter)
}
]
})
}

fetch()

$: value.members && fetch()
$: value.isArchived && fetch()
$: !value.isArchived && fetch()

</script>

{#if value}
Expand Down
8 changes: 4 additions & 4 deletions plugins/board-resources/src/utils/CardUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ export function hasDate (card: Card): boolean {

export function addCurrentUser (card: Card, client: Client): void {
const employee = (getCurrentAccount() as EmployeeAccount).employee
card.members = card.members ?? []
const members = card.members ?? []

if (card.members.includes(employee)) {
if (members.includes(employee)) {
return
}

card.members.push(employee)
updateCard(client, card, 'members', card.members)
members.push(employee)
updateCard(client, card, 'members', members)
}