Fix MyIssues (#2195)

This commit is contained in:
Alex 2022-07-03 18:15:31 +07:00 committed by GitHub
parent e96a08187b
commit 90042ba352
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,7 +14,7 @@
--> -->
<script lang="ts"> <script lang="ts">
import core, { DocumentQuery, getCurrentAccount, Ref, TxCollectionCUD } from '@anticrm/core' import core, { DocumentQuery, getCurrentAccount, Ref, TxCollectionCUD } from '@anticrm/core'
import type { Issue } from '@anticrm/tracker' import type { Issue, IssueStatus } from '@anticrm/tracker'
import type { EmployeeAccount } from '@anticrm/contact' import type { EmployeeAccount } from '@anticrm/contact'
import type { IntlString } from '@anticrm/platform' import type { IntlString } from '@anticrm/platform'
import { createQuery } from '@anticrm/presentation' import { createQuery } from '@anticrm/presentation'
@ -30,10 +30,18 @@
['subscribed', tracker.string.Subscribed] ['subscribed', tracker.string.Subscribed]
] ]
const currentUser = getCurrentAccount() as EmployeeAccount const currentUser = getCurrentAccount() as EmployeeAccount
const assigned = { assignee: currentUser.employee } let assigned = { assignee: currentUser.employee, status: { $in: [] as Ref<IssueStatus>[] } }
const created = { _id: { $in: [] as Ref<Issue>[] } } let created = { _id: { $in: [] as Ref<Issue>[] } }
const subscribed = { _id: { $in: [] as Ref<Issue>[] } } let subscribed = { _id: { $in: [] as Ref<Issue>[] } }
const statusQuery = createQuery()
$: statusQuery.query(
tracker.class.IssueStatus,
{ category: { $in: [tracker.issueStatusCategory.Started, tracker.issueStatusCategory.Unstarted] } },
(result) => {
assigned = { ...assigned, status: { $in: result.map(({ _id }) => _id) } }
}
)
const createdQuery = createQuery() const createdQuery = createQuery()
$: createdQuery.query<TxCollectionCUD<Issue, Issue>>( $: createdQuery.query<TxCollectionCUD<Issue, Issue>>(
core.class.TxCollectionCUD, core.class.TxCollectionCUD,
@ -44,7 +52,7 @@
'tx._class': core.class.TxCreateDoc 'tx._class': core.class.TxCreateDoc
}, },
(result) => { (result) => {
created._id.$in = result.map(({ tx: { objectId } }) => objectId) created = { ...created, _id: { $in: result.map(({ tx: { objectId } }) => objectId) } }
}, },
{ sort: { _id: 1 } } { sort: { _id: 1 } }
) )
@ -57,7 +65,7 @@
const newSub = result.map(({ attachedTo }) => attachedTo as Ref<Issue>) const newSub = result.map(({ attachedTo }) => attachedTo as Ref<Issue>)
const curSub = subscribed._id.$in const curSub = subscribed._id.$in
if (curSub.length !== newSub.length || curSub.some((id, i) => newSub[i] !== id)) { if (curSub.length !== newSub.length || curSub.some((id, i) => newSub[i] !== id)) {
subscribed._id.$in = newSub subscribed = { ...subscribed, _id: { $in: newSub } }
} }
}, },
{ sort: { _id: 1 } } { sort: { _id: 1 } }