mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-25 09:50:19 +00:00
Extract id map (#2518)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
fac31c2508
commit
8322bd649a
@ -23,7 +23,7 @@ import {
|
||||
checkHasGravatar,
|
||||
getAvatarColorForId
|
||||
} from '@hcengineering/contact'
|
||||
import { AccountRole, DOMAIN_TX, TxCreateDoc, TxOperations } from '@hcengineering/core'
|
||||
import { AccountRole, DOMAIN_TX, toIdMap, TxCreateDoc, TxOperations } from '@hcengineering/core'
|
||||
import { MigrateOperation, MigrationClient, MigrationUpgradeClient } from '@hcengineering/model'
|
||||
import core from '@hcengineering/model-core'
|
||||
import contact from './index'
|
||||
@ -96,7 +96,7 @@ async function setRole (client: MigrationClient): Promise<void> {
|
||||
async function updateEmployeeAvatar (tx: TxOperations): Promise<void> {
|
||||
const accounts = await tx.findAll(contact.class.EmployeeAccount, {})
|
||||
const employees = await tx.findAll(contact.class.Employee, { _id: { $in: accounts.map((a) => a.employee) } })
|
||||
const employeesById = new Map(employees.map((it) => [it._id, it]))
|
||||
const employeesById = toIdMap(employees)
|
||||
|
||||
// set gravatar for users without avatar
|
||||
const promises = accounts.map(async (account) => {
|
||||
|
@ -13,7 +13,16 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import core, { Doc, DocumentUpdate, generateId, Ref, SortingOrder, TxOperations, TxResult } from '@hcengineering/core'
|
||||
import core, {
|
||||
Doc,
|
||||
DocumentUpdate,
|
||||
generateId,
|
||||
Ref,
|
||||
SortingOrder,
|
||||
toIdMap,
|
||||
TxOperations,
|
||||
TxResult
|
||||
} from '@hcengineering/core'
|
||||
import { createOrUpdate, MigrateOperation, MigrationClient, MigrationUpgradeClient } from '@hcengineering/model'
|
||||
import {
|
||||
IssueStatus,
|
||||
@ -212,7 +221,7 @@ async function upgradeIssueTimeReportSettings (tx: TxOperations): Promise<void>
|
||||
const teams = await tx.findAll(tracker.class.Team, {
|
||||
_id: { $in: Array.from(new Set(issues.map((issue) => issue.space))) }
|
||||
})
|
||||
const teamsById = new Map(teams.map((team) => [team._id, team]))
|
||||
const teamsById = toIdMap(teams)
|
||||
|
||||
await Promise.all(
|
||||
issues.map((issue) => {
|
||||
|
@ -173,3 +173,15 @@ export function extractDocKey (key: string): {
|
||||
export function isFullTextAttribute (attr: AnyAttribute): boolean {
|
||||
return attr.index === IndexKind.FullText || attr.type._class === core.class.TypeAttachment
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface IdMap<T extends Doc> extends Map<Ref<T>, T> {}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export function toIdMap<T extends Doc> (arr: T[]): IdMap<T> {
|
||||
return new Map(arr.map((p) => [p._id, p]))
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
import attachment from '../plugin'
|
||||
import { IntlString, setPlatformStatus, unknownError, Asset } from '@hcengineering/platform'
|
||||
import { createEventDispatcher, onDestroy } from 'svelte'
|
||||
import { Account, Class, Doc, generateId, Ref, Space } from '@hcengineering/core'
|
||||
import { Account, Class, Doc, generateId, IdMap, Ref, Space, toIdMap } from '@hcengineering/core'
|
||||
import type { AnySvelteComponent } from '@hcengineering/ui'
|
||||
import { Attachment } from '@hcengineering/attachment'
|
||||
import AttachmentPresenter from './AttachmentPresenter.svelte'
|
||||
@ -33,7 +33,7 @@
|
||||
export let labelSend: IntlString | undefined = undefined
|
||||
export let showSend = true
|
||||
export let shouldSaveDraft: boolean = false
|
||||
export let attachments: Map<Ref<Attachment>, Attachment> = new Map<Ref<Attachment>, Attachment>()
|
||||
export let attachments: IdMap<Attachment> = new Map()
|
||||
export function submit (): void {
|
||||
refInput.submit()
|
||||
}
|
||||
@ -79,7 +79,7 @@
|
||||
},
|
||||
(res) => {
|
||||
originalAttachments = new Set(res.map((p) => p._id))
|
||||
attachments = new Map(res.map((p) => [p._id, p]))
|
||||
attachments = toIdMap(res)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { Attachment } from '@hcengineering/attachment'
|
||||
import { Account, Class, Doc, generateId, Ref, Space } from '@hcengineering/core'
|
||||
import { Account, Class, Doc, generateId, Ref, Space, toIdMap } from '@hcengineering/core'
|
||||
import { IntlString, setPlatformStatus, unknownError } from '@hcengineering/platform'
|
||||
import { createQuery, getClient, draftStore, updateDraftStore } from '@hcengineering/presentation'
|
||||
import { StyledTextBox } from '@hcengineering/text-editor'
|
||||
@ -96,7 +96,7 @@
|
||||
},
|
||||
(res) => {
|
||||
originalAttachments = new Set(res.map((p) => p._id))
|
||||
attachments = new Map(res.map((p) => [p._id, p]))
|
||||
attachments = toIdMap(res)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
import attachment, { Attachment } from '@hcengineering/attachment'
|
||||
import type { ChunterMessage, Message } from '@hcengineering/chunter'
|
||||
import contact, { Employee } from '@hcengineering/contact'
|
||||
import core, { Doc, Ref, Space, Timestamp, WithLookup } from '@hcengineering/core'
|
||||
import core, { Doc, Ref, Space, Timestamp, toIdMap, WithLookup } from '@hcengineering/core'
|
||||
import { NotificationClientImpl } from '@hcengineering/notification-resources'
|
||||
import { createQuery } from '@hcengineering/presentation'
|
||||
import { location as locationStore } from '@hcengineering/ui'
|
||||
@ -77,19 +77,9 @@
|
||||
const notificationClient = NotificationClientImpl.getClient()
|
||||
const lastViews = notificationClient.getLastViews()
|
||||
|
||||
employeeQuery.query(
|
||||
contact.class.Employee,
|
||||
{},
|
||||
(res) =>
|
||||
(employees = new Map(
|
||||
res.map((r) => {
|
||||
return [r._id, r]
|
||||
})
|
||||
)),
|
||||
{
|
||||
employeeQuery.query(contact.class.Employee, {}, (res) => (employees = toIdMap(res)), {
|
||||
lookup: { _id: { statuses: contact.class.Status } }
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
$: updateQuery(space)
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
import attachment, { Attachment } from '@hcengineering/attachment'
|
||||
import chunter, { ChunterMessage } from '@hcengineering/chunter'
|
||||
import contact, { Employee } from '@hcengineering/contact'
|
||||
import core, { DocumentQuery, Ref, SortingOrder } from '@hcengineering/core'
|
||||
import core, { DocumentQuery, Ref, SortingOrder, toIdMap } from '@hcengineering/core'
|
||||
import { createQuery, getClient } from '@hcengineering/presentation'
|
||||
import { Label, Scroller, SearchEdit } from '@hcengineering/ui'
|
||||
import { FilterBar } from '@hcengineering/view-resources'
|
||||
@ -50,19 +50,9 @@
|
||||
let employees: Map<Ref<Employee>, Employee> = new Map<Ref<Employee>, Employee>()
|
||||
const employeeQuery = createQuery()
|
||||
|
||||
employeeQuery.query(
|
||||
contact.class.Employee,
|
||||
{},
|
||||
(res) =>
|
||||
(employees = new Map(
|
||||
res.map((r) => {
|
||||
return [r._id, r]
|
||||
})
|
||||
)),
|
||||
{
|
||||
employeeQuery.query(contact.class.Employee, {}, (res) => (employees = toIdMap(res)), {
|
||||
lookup: { _id: { statuses: contact.class.Status } }
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
const pinnedQuery = createQuery()
|
||||
const pinnedIds: Ref<ChunterMessage>[] = []
|
||||
|
@ -2,7 +2,7 @@
|
||||
import attachment, { Attachment } from '@hcengineering/attachment'
|
||||
import { createQuery, getClient } from '@hcengineering/presentation'
|
||||
import { ChunterMessage } from '@hcengineering/chunter'
|
||||
import core, { Ref, WithLookup } from '@hcengineering/core'
|
||||
import core, { IdMap, Ref, toIdMap, WithLookup } from '@hcengineering/core'
|
||||
import contact, { Employee, EmployeeAccount, formatName } from '@hcengineering/contact'
|
||||
import { Label, Scroller } from '@hcengineering/ui'
|
||||
import AttachmentPreview from '@hcengineering/attachment-resources/src/components/AttachmentPreview.svelte'
|
||||
@ -59,22 +59,12 @@
|
||||
}
|
||||
)
|
||||
|
||||
let employees: Map<Ref<Employee>, Employee> = new Map<Ref<Employee>, Employee>()
|
||||
let employees: IdMap<Employee> = new Map()
|
||||
const employeeQuery = createQuery()
|
||||
|
||||
employeeQuery.query(
|
||||
contact.class.Employee,
|
||||
{},
|
||||
(res) =>
|
||||
(employees = new Map(
|
||||
res.map((r) => {
|
||||
return [r._id, r]
|
||||
})
|
||||
)),
|
||||
{
|
||||
employeeQuery.query(contact.class.Employee, {}, (res) => (employees = toIdMap(res)), {
|
||||
lookup: { _id: { statuses: contact.class.Status } }
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
const pinnedQuery = createQuery()
|
||||
const pinnedIds: Ref<ChunterMessage>[] = []
|
||||
|
@ -17,7 +17,16 @@
|
||||
import { AttachmentRefInput } from '@hcengineering/attachment-resources'
|
||||
import type { ChunterSpace, Message, ThreadMessage } from '@hcengineering/chunter'
|
||||
import contact, { Employee, EmployeeAccount, formatName } from '@hcengineering/contact'
|
||||
import core, { FindOptions, generateId, getCurrentAccount, Ref, SortingOrder, TxFactory } from '@hcengineering/core'
|
||||
import core, {
|
||||
FindOptions,
|
||||
generateId,
|
||||
getCurrentAccount,
|
||||
IdMap,
|
||||
Ref,
|
||||
SortingOrder,
|
||||
toIdMap,
|
||||
TxFactory
|
||||
} from '@hcengineering/core'
|
||||
import { NotificationClientImpl } from '@hcengineering/notification-resources'
|
||||
import { createQuery, getClient } from '@hcengineering/presentation'
|
||||
import { Label } from '@hcengineering/ui'
|
||||
@ -93,24 +102,15 @@
|
||||
)
|
||||
}
|
||||
|
||||
let employees: Map<Ref<Employee>, Employee> = new Map<Ref<Employee>, Employee>()
|
||||
let employees: IdMap<Employee> = new Map()
|
||||
const employeeQuery = createQuery()
|
||||
|
||||
employeeQuery.query(
|
||||
contact.class.Employee,
|
||||
{},
|
||||
(res) =>
|
||||
(employees = new Map(
|
||||
res.map((r) => {
|
||||
return [r._id, r]
|
||||
})
|
||||
))
|
||||
)
|
||||
employeeQuery.query(contact.class.Employee, {}, (res) => (employees = toIdMap(res)))
|
||||
|
||||
async function getParticipants (
|
||||
comments: ThreadMessage[],
|
||||
parent: Message | undefined,
|
||||
employees: Map<Ref<Employee>, Employee>
|
||||
employees: IdMap<Employee>
|
||||
): Promise<string[]> {
|
||||
const refs = new Set(comments.map((p) => p.createBy))
|
||||
if (parent !== undefined) {
|
||||
|
@ -15,7 +15,7 @@
|
||||
//
|
||||
|
||||
import contact, { ChannelProvider, Employee, formatName } from '@hcengineering/contact'
|
||||
import { Ref, Timestamp } from '@hcengineering/core'
|
||||
import { Ref, Timestamp, toIdMap } from '@hcengineering/core'
|
||||
import { createQuery, getClient } from '@hcengineering/presentation'
|
||||
|
||||
const client = getClient()
|
||||
@ -43,7 +43,7 @@ export async function employeeSort (value: Array<Ref<Employee>>): Promise<Array<
|
||||
return await new Promise((resolve) => {
|
||||
const query = createQuery(true)
|
||||
query.query(contact.class.Employee, { _id: { $in: value } }, (res) => {
|
||||
const employees = new Map(res.map((x) => [x._id, x]))
|
||||
const employees = toIdMap(res)
|
||||
value.sort((a, b) => {
|
||||
const employeeId1 = a as Ref<Employee> | null | undefined
|
||||
const employeeId2 = b as Ref<Employee> | null | undefined
|
||||
|
@ -17,11 +17,20 @@
|
||||
import { DocumentQuery, Ref, WithLookup } from '@hcengineering/core'
|
||||
import type { Department, Staff } from '@hcengineering/hr'
|
||||
import { createQuery } from '@hcengineering/presentation'
|
||||
import { Button, eventToHTMLElement, Icon, IconAdd, Label, Scroller, SearchEdit, showPopup } from '@hcengineering/ui'
|
||||
import {
|
||||
Button,
|
||||
deviceOptionsStore as deviceInfo,
|
||||
eventToHTMLElement,
|
||||
Icon,
|
||||
IconAdd,
|
||||
Label,
|
||||
Scroller,
|
||||
SearchEdit,
|
||||
showPopup
|
||||
} from '@hcengineering/ui'
|
||||
import hr from '../plugin'
|
||||
import CreateDepartment from './CreateDepartment.svelte'
|
||||
import DepartmentCard from './DepartmentCard.svelte'
|
||||
import { deviceOptionsStore as deviceInfo } from '@hcengineering/ui'
|
||||
|
||||
let search = ''
|
||||
let resultQuery: DocumentQuery<Department> = {}
|
||||
|
@ -26,6 +26,7 @@
|
||||
generateId,
|
||||
MixinData,
|
||||
Ref,
|
||||
toIdMap,
|
||||
TxProcessor,
|
||||
WithLookup
|
||||
} from '@hcengineering/core'
|
||||
@ -297,11 +298,8 @@
|
||||
|
||||
const categories = await client.findAll(tags.class.TagCategory, { targetClass: recruit.mixin.Candidate })
|
||||
// Tag elements
|
||||
const skillTagElements = new Map(
|
||||
(await client.findAll(tags.class.TagElement, { _id: { $in: skills.map((it) => it.tag) } })).map((it) => [
|
||||
it._id,
|
||||
it
|
||||
])
|
||||
const skillTagElements = toIdMap(
|
||||
await client.findAll(tags.class.TagElement, { _id: { $in: skills.map((it) => it.tag) } })
|
||||
)
|
||||
for (const skill of skills) {
|
||||
// Create update tag if missing
|
||||
@ -397,7 +395,7 @@
|
||||
await elementsPromise
|
||||
|
||||
const categories = await client.findAll(tags.class.TagCategory, { targetClass: recruit.mixin.Candidate })
|
||||
const categoriesMap = new Map(Array.from(categories.map((it) => [it._id, it])))
|
||||
const categoriesMap = toIdMap(categories)
|
||||
|
||||
const newSkills: TagReference[] = []
|
||||
|
||||
|
@ -13,7 +13,16 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import type { Client, Doc, DocumentQuery, FindResult, ObjQueryType, Ref, RelatedDocument } from '@hcengineering/core'
|
||||
import {
|
||||
Client,
|
||||
Doc,
|
||||
DocumentQuery,
|
||||
FindResult,
|
||||
ObjQueryType,
|
||||
Ref,
|
||||
RelatedDocument,
|
||||
toIdMap
|
||||
} from '@hcengineering/core'
|
||||
import { IntlString, OK, Resources, Severity, Status, translate } from '@hcengineering/platform'
|
||||
import { ObjectSearchResult } from '@hcengineering/presentation'
|
||||
import { Applicant, Candidate, Vacancy } from '@hcengineering/recruit'
|
||||
@ -151,7 +160,7 @@ export async function queryVacancy (
|
||||
q._id.$nin = filter.nin?.map((it) => it._id as Ref<Vacancy>)
|
||||
}
|
||||
}
|
||||
const named = new Map((await client.findAll(_class, q, { limit: 200 })).map((e) => [e._id, e]))
|
||||
const named = toIdMap(await client.findAll(_class, q, { limit: 200 }))
|
||||
|
||||
if (named.size === 0) {
|
||||
const q2: DocumentQuery<Vacancy> = {}
|
||||
|
@ -32,7 +32,7 @@
|
||||
</script>
|
||||
|
||||
{#if object !== undefined}
|
||||
<div class="flex gap-1 mb-2">
|
||||
<div class="flex-row-center gap-1 mb-2">
|
||||
<span class="mr-1"><Label label={request.string.For} /></span>
|
||||
<ObjectPresenter objectId={object.tx.objectId} _class={object.tx.objectClass} />
|
||||
<TxView tx={object.tx} />
|
||||
|
@ -14,15 +14,16 @@
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { TxViewlet } from '@hcengineering/activity'
|
||||
import { ActivityKey, DisplayTx, newDisplayTx, getValue, updateViewlet } from '@hcengineering/activity-resources'
|
||||
import { ActivityKey, DisplayTx, getValue, newDisplayTx, updateViewlet } from '@hcengineering/activity-resources'
|
||||
import activity from '@hcengineering/activity-resources/src/plugin'
|
||||
import contact, { EmployeeAccount } from '@hcengineering/contact'
|
||||
import core, { AnyAttribute, Ref, Tx } from '@hcengineering/core'
|
||||
import { Asset } from '@hcengineering/platform'
|
||||
import { createQuery, getClient } from '@hcengineering/presentation'
|
||||
import { Label } from '@hcengineering/ui'
|
||||
import request from '../plugin'
|
||||
import type { AttributeModel } from '@hcengineering/view'
|
||||
import { ObjectPresenter } from '@hcengineering/view-resources'
|
||||
import request from '../plugin'
|
||||
|
||||
export let tx: Tx
|
||||
const viewlets: Map<ActivityKey, TxViewlet> = new Map<ActivityKey, TxViewlet>()
|
||||
@ -106,7 +107,11 @@
|
||||
<div class="strong">
|
||||
<div class="flex flex-wrap gap-2" class:emphasized={value.added.length > 1}>
|
||||
{#each value.added as cvalue}
|
||||
{#if value.isObjectAdded}
|
||||
<ObjectPresenter value={cvalue} />
|
||||
{:else}
|
||||
<svelte:component this={m.presenter} value={cvalue} />
|
||||
{/if}
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
@ -119,7 +124,11 @@
|
||||
<div class="strong">
|
||||
<div class="flex flex-wrap gap-2 flex-grow" class:emphasized={value.removed.length > 1}>
|
||||
{#each value.removed as cvalue}
|
||||
{#if value.isObjectRemoved}
|
||||
<ObjectPresenter value={cvalue} />
|
||||
{:else}
|
||||
<svelte:component this={m.presenter} value={cvalue} />
|
||||
{/if}
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
@ -129,16 +138,19 @@
|
||||
<Label label={m.label} />
|
||||
<Label label={activity.string.To} />
|
||||
</span>
|
||||
{#if isMessageType(m.attribute)}
|
||||
<div class="strong message emphasized">
|
||||
<svelte:component this={m.presenter} value={value.set} />
|
||||
</div>
|
||||
<div
|
||||
class="strong message emphasized"
|
||||
class:message={isMessageType(m.attribute)}
|
||||
class:emphasized={isMessageType(m.attribute)}
|
||||
>
|
||||
{#if value.isObjectSet}
|
||||
<ObjectPresenter value={value.set} />
|
||||
{:else}
|
||||
<div class="strong">
|
||||
<svelte:component this={m.presenter} value={value.set} />
|
||||
{/if}
|
||||
<svelte:component this={m.presenter} value={value.set} />
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
{/await}
|
||||
{/each}
|
||||
{:else if ptx?.mixinTx}
|
||||
|
@ -15,7 +15,7 @@
|
||||
<script lang="ts">
|
||||
import contact, { Employee, EmployeeAccount, formatName } from '@hcengineering/contact'
|
||||
import { PersonPresenter } from '@hcengineering/contact-resources'
|
||||
import { AccountRole, getCurrentAccount, Ref, SortingOrder } from '@hcengineering/core'
|
||||
import { AccountRole, getCurrentAccount, IdMap, SortingOrder, toIdMap } from '@hcengineering/core'
|
||||
import { createQuery, getClient } from '@hcengineering/presentation'
|
||||
import { DropdownIntlItem, DropdownLabelsIntl, Icon, Label } from '@hcengineering/ui'
|
||||
import setting from '../plugin'
|
||||
@ -35,7 +35,7 @@
|
||||
|
||||
let accounts: EmployeeAccount[] = []
|
||||
$: owners = accounts.filter((p) => p.role === AccountRole.Owner)
|
||||
let employees: Map<Ref<Employee>, Employee> = new Map<Ref<Employee>, Employee>()
|
||||
let employees: IdMap<Employee> = new Map()
|
||||
|
||||
query.query(
|
||||
contact.class.EmployeeAccount,
|
||||
@ -49,11 +49,7 @@
|
||||
)
|
||||
|
||||
employeeQuery.query(contact.class.Employee, {}, (res) => {
|
||||
employees = new Map(
|
||||
res.map((p) => {
|
||||
return [p._id, p]
|
||||
})
|
||||
)
|
||||
employees = toIdMap(res)
|
||||
})
|
||||
|
||||
async function change (account: EmployeeAccount, value: AccountRole): Promise<void> {
|
||||
|
@ -14,7 +14,7 @@
|
||||
// limitations under the License.
|
||||
-->
|
||||
<script lang="ts">
|
||||
import type { Doc, Ref, Space } from '@hcengineering/core'
|
||||
import { Doc, Ref, Space, toIdMap } from '@hcengineering/core'
|
||||
import { AttributeEditor, createQuery, getClient } from '@hcengineering/presentation'
|
||||
import setting from '@hcengineering/setting'
|
||||
import task, { genRanks, KanbanTemplate, KanbanTemplateSpace } from '@hcengineering/task'
|
||||
@ -40,7 +40,7 @@
|
||||
selectedId = templates[0]._id
|
||||
}
|
||||
|
||||
$: templateMap = new Map(templates.map((x) => [x._id, x]))
|
||||
$: templateMap = toIdMap(templates)
|
||||
$: template = selectedId !== undefined ? templateMap.get(selectedId) : undefined
|
||||
|
||||
const client = getClient()
|
||||
|
@ -13,7 +13,7 @@
|
||||
// limitations under the License.
|
||||
-->
|
||||
<script lang="ts">
|
||||
import type { Class, Doc, Ref } from '@hcengineering/core'
|
||||
import { Class, Doc, IdMap, Ref, toIdMap } from '@hcengineering/core'
|
||||
import { createQuery, getClient, KeyedAttribute } from '@hcengineering/presentation'
|
||||
import { TagElement, TagReference } from '@hcengineering/tags'
|
||||
import tags from '../plugin'
|
||||
@ -53,10 +53,10 @@
|
||||
await client.update(tag, { weight })
|
||||
}
|
||||
|
||||
let elements: Map<Ref<TagElement>, TagElement> = new Map()
|
||||
let elements: IdMap<TagElement> = new Map()
|
||||
const elementQuery = createQuery()
|
||||
$: elementQuery.query(tags.class.TagElement, {}, (result) => {
|
||||
elements = new Map(result.map((it) => [it._id, it]))
|
||||
elements = toIdMap(result)
|
||||
})
|
||||
</script>
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
// limitations under the License.
|
||||
-->
|
||||
<script lang="ts">
|
||||
import type { Class, Doc, Ref } from '@hcengineering/core'
|
||||
import { Class, Doc, IdMap, Ref, toIdMap } from '@hcengineering/core'
|
||||
import { createQuery } from '@hcengineering/presentation'
|
||||
import { TagElement, TagReference } from '@hcengineering/tags'
|
||||
import tags from '../plugin'
|
||||
@ -24,11 +24,11 @@
|
||||
export let object: Doc
|
||||
export let _class: Ref<Class<Doc>>
|
||||
|
||||
let elements: Map<Ref<TagElement>, TagElement> = new Map()
|
||||
let elements: IdMap<TagElement> = new Map()
|
||||
const elementQuery = createQuery()
|
||||
|
||||
$: elementQuery.query(tags.class.TagElement, { _id: { $in: items.map((it) => it.tag) } }, (result) => {
|
||||
elements = new Map(result.map((it) => [it._id, it]))
|
||||
elements = toIdMap(result)
|
||||
})
|
||||
|
||||
let items: TagReference[] = []
|
||||
|
@ -1,5 +1,15 @@
|
||||
<script lang="ts">
|
||||
import core, { Ref, Timestamp, Tx, TxCollectionCUD, TxCreateDoc, TxUpdateDoc, WithLookup } from '@hcengineering/core'
|
||||
import core, {
|
||||
IdMap,
|
||||
Ref,
|
||||
Timestamp,
|
||||
toIdMap,
|
||||
Tx,
|
||||
TxCollectionCUD,
|
||||
TxCreateDoc,
|
||||
TxUpdateDoc,
|
||||
WithLookup
|
||||
} from '@hcengineering/core'
|
||||
import { createQuery } from '@hcengineering/presentation'
|
||||
import { Issue, IssueStatus } from '@hcengineering/tracker'
|
||||
import { Label, ticker } from '@hcengineering/ui'
|
||||
@ -20,13 +30,13 @@
|
||||
|
||||
const stQuery = createQuery()
|
||||
|
||||
let statuses = new Map<Ref<IssueStatus>, WithLookup<IssueStatus>>()
|
||||
let statuses: IdMap<IssueStatus> = new Map()
|
||||
|
||||
stQuery.query(
|
||||
tracker.class.IssueStatus,
|
||||
{},
|
||||
(res) => {
|
||||
statuses = new Map(res.map((it) => [it._id, it]))
|
||||
statuses = toIdMap(res)
|
||||
},
|
||||
{
|
||||
lookup: {
|
||||
|
@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { DocumentQuery, Ref, SortingOrder, Space, WithLookup } from '@hcengineering/core'
|
||||
import { DocumentQuery, Ref, SortingOrder, Space, toIdMap, WithLookup } from '@hcengineering/core'
|
||||
import { IntlString, translate } from '@hcengineering/platform'
|
||||
import { createQuery, getClient } from '@hcengineering/presentation'
|
||||
import { Issue, IssueStatus, Team } from '@hcengineering/tracker'
|
||||
@ -70,12 +70,7 @@
|
||||
let _result: any
|
||||
$: teamQuery.query(tracker.class.Team, {}, (result) => {
|
||||
_result = JSON.stringify(result, undefined, 2)
|
||||
console.log('#RESULT 124', _result)
|
||||
const t = new Map<Ref<Team>, Team>()
|
||||
for (const r of result) {
|
||||
t.set(r._id, r)
|
||||
}
|
||||
_teams = t
|
||||
_teams = toIdMap(result)
|
||||
})
|
||||
|
||||
let issueStatuses: Map<Ref<Team>, WithLookup<IssueStatus>[]>
|
||||
|
@ -13,7 +13,7 @@
|
||||
// limitations under the License.
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { Ref, SortingOrder, WithLookup } from '@hcengineering/core'
|
||||
import { Ref, SortingOrder, toIdMap, WithLookup } from '@hcengineering/core'
|
||||
import { createQuery } from '@hcengineering/presentation'
|
||||
import { Issue, IssueStatus, Team } from '@hcengineering/tracker'
|
||||
import { Button, Chevron, closeTooltip, ExpandCollapse, IconAdd, Label } from '@hcengineering/ui'
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
$: if (teams === undefined) {
|
||||
teamsQuery.query(tracker.class.Team, {}, async (result) => {
|
||||
_teams = new Map(result.map((it) => [it._id, it]))
|
||||
_teams = toIdMap(result)
|
||||
})
|
||||
} else {
|
||||
teamsQuery.unsubscribe()
|
||||
|
@ -13,7 +13,7 @@
|
||||
// limitations under the License.
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { Ref, WithLookup } from '@hcengineering/core'
|
||||
import { IdMap, Ref, toIdMap } from '@hcengineering/core'
|
||||
import { createQuery } from '@hcengineering/presentation'
|
||||
import { Issue, IssueStatus, WorkDayLength } from '@hcengineering/tracker'
|
||||
import { floorFractionDigits, Label } from '@hcengineering/ui'
|
||||
@ -33,10 +33,10 @@
|
||||
)
|
||||
|
||||
const statuses = createQuery()
|
||||
let issueStatuses: Map<Ref<IssueStatus>, WithLookup<IssueStatus>> = new Map()
|
||||
let issueStatuses: IdMap<IssueStatus> = new Map()
|
||||
$: if (noParents !== undefined) {
|
||||
statuses.query(tracker.class.IssueStatus, { _id: { $in: Array.from(noParents.map((it) => it.status)) } }, (res) => {
|
||||
issueStatuses = new Map(res.map((it) => [it._id, it]))
|
||||
issueStatuses = toIdMap(res)
|
||||
})
|
||||
} else {
|
||||
statuses.unsubscribe()
|
||||
|
@ -13,7 +13,7 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import { Class, Client, DocumentQuery, Ref, RelatedDocument, TxOperations } from '@hcengineering/core'
|
||||
import { Class, Client, DocumentQuery, Ref, RelatedDocument, toIdMap, TxOperations } from '@hcengineering/core'
|
||||
import { Resources, translate } from '@hcengineering/platform'
|
||||
import { getClient, MessageBox, ObjectSearchResult } from '@hcengineering/presentation'
|
||||
import { Issue, Sprint, Team } from '@hcengineering/tracker'
|
||||
@ -125,13 +125,11 @@ export async function queryIssue<D extends Issue> (
|
||||
}
|
||||
}
|
||||
|
||||
const named = new Map(
|
||||
(
|
||||
const named = toIdMap(
|
||||
await client.findAll<Issue>(_class, q, {
|
||||
limit: 200,
|
||||
lookup: { space: tracker.class.Team }
|
||||
})
|
||||
).map((e) => [e._id, e])
|
||||
)
|
||||
for (const currentTeam of teams) {
|
||||
const nids: number[] = []
|
||||
|
@ -13,7 +13,7 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import { Doc, DocumentQuery, Ref, SortingOrder, TxOperations, WithLookup } from '@hcengineering/core'
|
||||
import { Doc, DocumentQuery, Ref, SortingOrder, toIdMap, TxOperations, WithLookup } from '@hcengineering/core'
|
||||
import { TypeState } from '@hcengineering/kanban'
|
||||
import { Asset, IntlString, translate } from '@hcengineering/platform'
|
||||
import { createQuery } from '@hcengineering/presentation'
|
||||
@ -332,7 +332,7 @@ export async function sprintSort (value: Array<Ref<Sprint>>): Promise<Array<Ref<
|
||||
return await new Promise((resolve) => {
|
||||
const query = createQuery(true)
|
||||
query.query(tracker.class.Sprint, { _id: { $in: value } }, (res) => {
|
||||
const sprints = new Map(res.map((x) => [x._id, x]))
|
||||
const sprints = toIdMap(res)
|
||||
value.sort((a, b) => (sprints.get(b)?.startDate ?? 0) - (sprints.get(a)?.startDate ?? 0))
|
||||
resolve(value)
|
||||
query.unsubscribe()
|
||||
|
Loading…
Reference in New Issue
Block a user