mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-16 05:13:06 +00:00
Fix chunter employees (#2698)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
c962cffd69
commit
8e69063994
@ -26,7 +26,7 @@ import type {
|
||||
TemplateField,
|
||||
TemplateFieldCategory,
|
||||
TemplateFieldFunc,
|
||||
TemplateGroup
|
||||
TemplateCategory
|
||||
} from '@hcengineering/templates'
|
||||
import templates from './plugin'
|
||||
|
||||
@ -43,9 +43,9 @@ export class TMessageTemplate extends TDoc implements MessageTemplate {
|
||||
message!: string
|
||||
}
|
||||
|
||||
@Model(templates.class.TemplateGroup, core.class.Space, DOMAIN_SPACE)
|
||||
@UX(templates.string.TemplateGroup)
|
||||
export class TTemplateGroup extends TSpace implements TemplateGroup {}
|
||||
@Model(templates.class.TemplateCategory, core.class.Space, DOMAIN_SPACE)
|
||||
@UX(templates.string.TemplateCategory)
|
||||
export class TTemplateCategory extends TSpace implements TemplateCategory {}
|
||||
|
||||
@Model(templates.class.TemplateFieldCategory, core.class.Doc, DOMAIN_MODEL)
|
||||
export class TTemplateFieldCategory extends TDoc implements TemplateFieldCategory {
|
||||
@ -60,7 +60,7 @@ export class TTemplateField extends TDoc implements TemplateField {
|
||||
}
|
||||
|
||||
export function createModel (builder: Builder): void {
|
||||
builder.createModel(TMessageTemplate, TTemplateFieldCategory, TTemplateField, TTemplateGroup)
|
||||
builder.createModel(TMessageTemplate, TTemplateFieldCategory, TTemplateField, TTemplateCategory)
|
||||
|
||||
builder.createDoc(
|
||||
setting.class.WorkspaceSettingCategory,
|
||||
@ -126,7 +126,7 @@ export function createModel (builder: Builder): void {
|
||||
input: 'focus',
|
||||
icon: view.icon.Open,
|
||||
category: templates.category.MessageTemplate,
|
||||
target: templates.class.TemplateGroup,
|
||||
target: templates.class.TemplateCategory,
|
||||
keyBinding: ['keyE'],
|
||||
context: {
|
||||
mode: ['browser', 'context'],
|
||||
|
@ -29,7 +29,7 @@ export const templatesOperation: MigrateOperation = {
|
||||
})
|
||||
if (current === undefined) {
|
||||
await tx.createDoc(
|
||||
templates.class.TemplateGroup,
|
||||
templates.class.TemplateCategory,
|
||||
core.space.Space,
|
||||
{
|
||||
name: 'Public templates',
|
||||
@ -52,7 +52,7 @@ async function changeClass (client: MigrationClient): Promise<void> {
|
||||
_class: core.class.Space
|
||||
},
|
||||
{
|
||||
_class: templates.class.TemplateGroup,
|
||||
_class: templates.class.TemplateCategory,
|
||||
private: false,
|
||||
name: 'Public templates',
|
||||
description: 'Space for public templates'
|
||||
@ -67,7 +67,7 @@ async function changeClass (client: MigrationClient): Promise<void> {
|
||||
_class: core.class.TxCreateDoc
|
||||
},
|
||||
{
|
||||
objectClass: templates.class.TemplateGroup,
|
||||
objectClass: templates.class.TemplateCategory,
|
||||
'attirbutes.private': false,
|
||||
'attirbutes.name': 'Public templates',
|
||||
'attirbutes.description': 'Space for public templates'
|
||||
|
@ -15,14 +15,13 @@
|
||||
<script lang="ts">
|
||||
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, toIdMap, WithLookup } from '@hcengineering/core'
|
||||
import core, { Doc, Ref, Space, Timestamp, WithLookup } from '@hcengineering/core'
|
||||
import { NotificationClientImpl } from '@hcengineering/notification-resources'
|
||||
import { createQuery } from '@hcengineering/presentation'
|
||||
import { location as locationStore } from '@hcengineering/ui'
|
||||
import { afterUpdate, beforeUpdate, onDestroy } from 'svelte'
|
||||
import chunter from '../plugin'
|
||||
import { getDay, messageIdForScroll, shouldScrollToMessage, isMessageHighlighted, scrollAndHighLight } from '../utils'
|
||||
import { getDay, isMessageHighlighted, messageIdForScroll, scrollAndHighLight, shouldScrollToMessage } from '../utils'
|
||||
import ChannelSeparator from './ChannelSeparator.svelte'
|
||||
import JumpToDateSelector from './JumpToDateSelector.svelte'
|
||||
import MessageComponent from './Message.svelte'
|
||||
@ -70,17 +69,11 @@
|
||||
})
|
||||
|
||||
let messages: WithLookup<Message>[] | undefined
|
||||
let employees: Map<Ref<Employee>, Employee> = new Map<Ref<Employee>, Employee>()
|
||||
const query = createQuery()
|
||||
const employeeQuery = createQuery()
|
||||
|
||||
const notificationClient = NotificationClientImpl.getClient()
|
||||
const lastViews = notificationClient.getLastViews()
|
||||
|
||||
employeeQuery.query(contact.class.Employee, {}, (res) => (employees = toIdMap(res)), {
|
||||
lookup: { _id: { statuses: contact.class.Status } }
|
||||
})
|
||||
|
||||
$: updateQuery(space)
|
||||
|
||||
function updateQuery (space: Ref<Space> | undefined) {
|
||||
@ -220,7 +213,6 @@
|
||||
<MessageComponent
|
||||
isHighlighted={$messageIdForScroll === message._id && $isMessageHighlighted}
|
||||
{message}
|
||||
{employees}
|
||||
on:openThread
|
||||
isPinned={pinnedIds.includes(message._id)}
|
||||
isSaved={savedMessagesIds.includes(message._id)}
|
||||
|
@ -16,26 +16,26 @@
|
||||
import { Attachment } from '@hcengineering/attachment'
|
||||
import { AttachmentList, AttachmentRefInput } from '@hcengineering/attachment-resources'
|
||||
import type { ChunterMessage, Message, Reaction } from '@hcengineering/chunter'
|
||||
import { Employee, EmployeeAccount } from '@hcengineering/contact'
|
||||
import contact, { Employee, EmployeeAccount } from '@hcengineering/contact'
|
||||
import { EmployeePresenter } from '@hcengineering/contact-resources'
|
||||
import { Ref, WithLookup, getCurrentAccount } from '@hcengineering/core'
|
||||
import { getCurrentAccount, Ref, WithLookup } from '@hcengineering/core'
|
||||
import { NotificationClientImpl } from '@hcengineering/notification-resources'
|
||||
import { getResource } from '@hcengineering/platform'
|
||||
import { Avatar, copyTextToClipboard, getClient, MessageViewer } from '@hcengineering/presentation'
|
||||
import { Avatar, copyTextToClipboard, createQuery, getClient, MessageViewer } from '@hcengineering/presentation'
|
||||
import { EmojiPopup } from '@hcengineering/text-editor'
|
||||
import ui, {
|
||||
ActionIcon,
|
||||
IconMoreH,
|
||||
Menu,
|
||||
showPopup,
|
||||
Label,
|
||||
tooltip,
|
||||
Button,
|
||||
getCurrentLocation,
|
||||
locationToUrl
|
||||
IconMoreH,
|
||||
Label,
|
||||
locationToUrl,
|
||||
Menu,
|
||||
showPopup,
|
||||
tooltip
|
||||
} from '@hcengineering/ui'
|
||||
import { Action } from '@hcengineering/view'
|
||||
import { getActions, LinkPresenter } from '@hcengineering/view-resources'
|
||||
import { EmojiPopup } from '@hcengineering/text-editor'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import { AddMessageToSaved, DeleteMessageFromSaved, UnpinMessage } from '../index'
|
||||
import chunter from '../plugin'
|
||||
@ -48,7 +48,6 @@
|
||||
import Replies from './Replies.svelte'
|
||||
|
||||
export let message: WithLookup<ChunterMessage>
|
||||
export let employees: Map<Ref<Employee>, Employee>
|
||||
export let savedAttachmentsIds: Ref<Attachment>[]
|
||||
export let thread: boolean = false
|
||||
export let isPinned: boolean = false
|
||||
@ -57,7 +56,16 @@
|
||||
|
||||
let refInput: AttachmentRefInput
|
||||
|
||||
$: employee = getEmployee(message)
|
||||
let employee: Employee | undefined
|
||||
const employeeQuery = createQuery()
|
||||
$: employeeQuery.query(
|
||||
contact.class.Employee,
|
||||
{
|
||||
_id: (message.$lookup?.createBy as EmployeeAccount)?.employee
|
||||
},
|
||||
(res) => ([employee] = res)
|
||||
)
|
||||
|
||||
$: attachments = (message.$lookup?.attachments ?? []) as Attachment[]
|
||||
|
||||
const client = getClient()
|
||||
@ -168,13 +176,6 @@
|
||||
loading = false
|
||||
}
|
||||
|
||||
function getEmployee (message: WithLookup<ChunterMessage>): Employee | undefined {
|
||||
const employee = (message.$lookup?.createBy as EmployeeAccount).employee
|
||||
if (employee !== undefined) {
|
||||
return employees.get(employee)
|
||||
}
|
||||
}
|
||||
|
||||
function openThread () {
|
||||
dispatch('openThread', message._id)
|
||||
}
|
||||
|
@ -1,14 +1,13 @@
|
||||
<script lang="ts">
|
||||
import attachment, { Attachment } from '@hcengineering/attachment'
|
||||
import chunter, { ChunterMessage } from '@hcengineering/chunter'
|
||||
import contact, { Employee } from '@hcengineering/contact'
|
||||
import core, { DocumentQuery, Ref, SortingOrder, toIdMap } from '@hcengineering/core'
|
||||
import core, { DocumentQuery, Ref, SortingOrder } from '@hcengineering/core'
|
||||
import { createQuery, getClient } from '@hcengineering/presentation'
|
||||
import { Label, Scroller, SearchEdit } from '@hcengineering/ui'
|
||||
import { FilterBar } from '@hcengineering/view-resources'
|
||||
import MessageComponent from './Message.svelte'
|
||||
import plugin from '../plugin'
|
||||
import { openMessageFromSpecial } from '../utils'
|
||||
import MessageComponent from './Message.svelte'
|
||||
|
||||
export let withHeader: boolean = true
|
||||
|
||||
@ -47,13 +46,6 @@
|
||||
|
||||
$: updateMessages(resultQuery)
|
||||
|
||||
let employees: Map<Ref<Employee>, Employee> = new Map<Ref<Employee>, Employee>()
|
||||
const employeeQuery = createQuery()
|
||||
|
||||
employeeQuery.query(contact.class.Employee, {}, (res) => (employees = toIdMap(res)), {
|
||||
lookup: { _id: { statuses: contact.class.Status } }
|
||||
})
|
||||
|
||||
const pinnedQuery = createQuery()
|
||||
const pinnedIds: Ref<ChunterMessage>[] = []
|
||||
|
||||
@ -105,7 +97,6 @@
|
||||
<div on:click={() => openMessageFromSpecial(message)}>
|
||||
<MessageComponent
|
||||
{message}
|
||||
{employees}
|
||||
on:openThread
|
||||
isPinned={pinnedIds.includes(message._id)}
|
||||
isSaved={savedMessagesIds.includes(message._id)}
|
||||
|
@ -1,15 +1,15 @@
|
||||
<script lang="ts">
|
||||
import attachment, { Attachment } from '@hcengineering/attachment'
|
||||
import { createQuery, getClient } from '@hcengineering/presentation'
|
||||
import { ChunterMessage } from '@hcengineering/chunter'
|
||||
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'
|
||||
import Bookmark from './icons/Bookmark.svelte'
|
||||
import Message from './Message.svelte'
|
||||
import { ChunterMessage } from '@hcengineering/chunter'
|
||||
import { EmployeeAccount, formatName } from '@hcengineering/contact'
|
||||
import core, { Ref, WithLookup } from '@hcengineering/core'
|
||||
import { createQuery, getClient } from '@hcengineering/presentation'
|
||||
import { Label, Scroller } from '@hcengineering/ui'
|
||||
import chunter from '../plugin'
|
||||
import { getTime, openMessageFromSpecial } from '../utils'
|
||||
import Bookmark from './icons/Bookmark.svelte'
|
||||
import Message from './Message.svelte'
|
||||
|
||||
const client = getClient()
|
||||
let savedMessagesIds: Ref<ChunterMessage>[] = []
|
||||
@ -59,13 +59,6 @@
|
||||
}
|
||||
)
|
||||
|
||||
let employees: IdMap<Employee> = new Map()
|
||||
const employeeQuery = createQuery()
|
||||
|
||||
employeeQuery.query(contact.class.Employee, {}, (res) => (employees = toIdMap(res)), {
|
||||
lookup: { _id: { statuses: contact.class.Status } }
|
||||
})
|
||||
|
||||
const pinnedQuery = createQuery()
|
||||
const pinnedIds: Ref<ChunterMessage>[] = []
|
||||
|
||||
@ -108,7 +101,6 @@
|
||||
<div on:click={() => openMessageFromSpecial(message)}>
|
||||
<Message
|
||||
{message}
|
||||
{employees}
|
||||
on:openThread
|
||||
thread
|
||||
isPinned={pinnedIds.includes(message._id)}
|
||||
|
@ -184,7 +184,7 @@
|
||||
</div>
|
||||
<div class="flex-col content">
|
||||
{#if parent}
|
||||
<MsgView message={parent} {employees} thread {savedAttachmentsIds} />
|
||||
<MsgView message={parent} thread {savedAttachmentsIds} />
|
||||
{#if total > comments.length}
|
||||
<div
|
||||
class="label pb-2 pt-2 pl-8 over-underline"
|
||||
@ -196,7 +196,7 @@
|
||||
</div>
|
||||
{/if}
|
||||
{#each comments as comment (comment._id)}
|
||||
<MsgView message={comment} {employees} thread {savedAttachmentsIds} />
|
||||
<MsgView message={comment} thread {savedAttachmentsIds} />
|
||||
{/each}
|
||||
<div class="mr-4 ml-4 mb-4 mt-2">
|
||||
<AttachmentRefInput
|
||||
|
@ -15,16 +15,15 @@
|
||||
<script lang="ts">
|
||||
import attachment, { Attachment } from '@hcengineering/attachment'
|
||||
import { AttachmentRefInput } from '@hcengineering/attachment-resources'
|
||||
import type { ThreadMessage, Message, ChunterMessage } from '@hcengineering/chunter'
|
||||
import contact, { Employee } from '@hcengineering/contact'
|
||||
import type { ChunterMessage, Message, ThreadMessage } from '@hcengineering/chunter'
|
||||
import core, { Doc, generateId, getCurrentAccount, Ref, Space } from '@hcengineering/core'
|
||||
import { NotificationClientImpl } from '@hcengineering/notification-resources'
|
||||
import { createQuery, getClient } from '@hcengineering/presentation'
|
||||
import { IconClose, Label, getCurrentLocation, navigate } from '@hcengineering/ui'
|
||||
import { getCurrentLocation, IconClose, Label, navigate } from '@hcengineering/ui'
|
||||
import { afterUpdate, beforeUpdate, createEventDispatcher } from 'svelte'
|
||||
import { createBacklinks } from '../backlinks'
|
||||
import chunter from '../plugin'
|
||||
import { messageIdForScroll, shouldScrollToMessage, isMessageHighlighted, scrollAndHighLight } from '../utils'
|
||||
import { isMessageHighlighted, messageIdForScroll, scrollAndHighLight, shouldScrollToMessage } from '../utils'
|
||||
import ChannelSeparator from './ChannelSeparator.svelte'
|
||||
import MsgView from './Message.svelte'
|
||||
|
||||
@ -119,23 +118,6 @@
|
||||
)
|
||||
}
|
||||
|
||||
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]
|
||||
})
|
||||
)),
|
||||
{
|
||||
lookup: { _id: { statuses: contact.class.Status } }
|
||||
}
|
||||
)
|
||||
|
||||
const savedMessagesQuery = createQuery()
|
||||
let savedMessagesIds: Ref<ChunterMessage>[] = []
|
||||
|
||||
@ -210,7 +192,7 @@
|
||||
</div>
|
||||
<div class="flex-col vScroll content" bind:this={div}>
|
||||
{#if message}
|
||||
<MsgView {message} {employees} thread isSaved={savedMessagesIds.includes(message._id)} {savedAttachmentsIds} />
|
||||
<MsgView {message} thread isSaved={savedMessagesIds.includes(message._id)} {savedAttachmentsIds} />
|
||||
{#if comments.length}
|
||||
<ChannelSeparator title={chunter.string.RepliesCount} line params={{ replies: comments.length }} />
|
||||
{/if}
|
||||
@ -221,7 +203,6 @@
|
||||
<MsgView
|
||||
isHighlighted={$messageIdForScroll === comment._id && $isMessageHighlighted}
|
||||
message={comment}
|
||||
{employees}
|
||||
thread
|
||||
isPinned={pinnedIds.includes(comment._id)}
|
||||
isSaved={savedMessagesIds.includes(comment._id)}
|
||||
|
@ -13,8 +13,8 @@
|
||||
"Title": "Title",
|
||||
"Message": "Message",
|
||||
"Field": "Field",
|
||||
"TemplateGroup": "Template group",
|
||||
"CreateTemplateGroup": "Create group",
|
||||
"TemplateCategory": "Template group",
|
||||
"CreateTemplateCategory": "Create group",
|
||||
"Copy": "Copy"
|
||||
}
|
||||
}
|
@ -13,8 +13,8 @@
|
||||
"Title": "Заголовок",
|
||||
"Message": "Сообщение",
|
||||
"Field": "Поле",
|
||||
"TemplateGroup": "Группа шаблонов",
|
||||
"CreateTemplateGroup": "Создать группу",
|
||||
"TemplateCategory": "Группа шаблонов",
|
||||
"CreateTemplateCategory": "Создать группу",
|
||||
"Copy": "Копировать"
|
||||
}
|
||||
}
|
@ -15,7 +15,7 @@
|
||||
<script lang="ts">
|
||||
import { Ref } from '@hcengineering/core'
|
||||
import presentation, { Card, getClient, SpaceSelector } from '@hcengineering/presentation'
|
||||
import { MessageTemplate, TemplateGroup } from '@hcengineering/templates'
|
||||
import { MessageTemplate, TemplateCategory } from '@hcengineering/templates'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import templates from '../plugin'
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
})
|
||||
}
|
||||
|
||||
let space: Ref<TemplateGroup>
|
||||
let space: Ref<TemplateCategory>
|
||||
const dispatch = createEventDispatcher()
|
||||
</script>
|
||||
|
||||
@ -42,5 +42,5 @@
|
||||
fullSize
|
||||
canSave={space !== undefined && value.space !== space}
|
||||
>
|
||||
<SpaceSelector bind:space _class={templates.class.TemplateGroup} label={templates.string.Copy} />
|
||||
<SpaceSelector bind:space _class={templates.class.TemplateCategory} label={templates.string.Copy} />
|
||||
</Card>
|
||||
|
@ -32,7 +32,7 @@
|
||||
const client = getClient()
|
||||
|
||||
async function create (): Promise<void> {
|
||||
await client.createDoc(templates.class.TemplateGroup, core.space.Space, {
|
||||
await client.createDoc(templates.class.TemplateCategory, core.space.Space, {
|
||||
name,
|
||||
description,
|
||||
private: isPrivate,
|
||||
@ -44,7 +44,7 @@
|
||||
</script>
|
||||
|
||||
<SpaceCreateCard
|
||||
label={templates.string.CreateTemplateGroup}
|
||||
label={templates.string.CreateTemplateCategory}
|
||||
okAction={create}
|
||||
canSave={name.length > 0}
|
||||
on:close={() => {
|
||||
@ -53,10 +53,10 @@
|
||||
>
|
||||
<Grid column={1} rowGap={1.5}>
|
||||
<EditBox
|
||||
label={templates.string.TemplateGroup}
|
||||
label={templates.string.TemplateCategory}
|
||||
icon={IconFolder}
|
||||
bind:value={name}
|
||||
placeholder={templates.string.TemplateGroup}
|
||||
placeholder={templates.string.TemplateCategory}
|
||||
focus
|
||||
/>
|
||||
<ToggleWithLabel
|
@ -16,13 +16,13 @@
|
||||
<script lang="ts">
|
||||
import core from '@hcengineering/core'
|
||||
import presentation, { Card, getClient, Members } from '@hcengineering/presentation'
|
||||
import { TemplateGroup } from '@hcengineering/templates'
|
||||
import { TemplateCategory } from '@hcengineering/templates'
|
||||
import { EditBox, Grid, Label } from '@hcengineering/ui'
|
||||
import { BooleanPresenter } from '@hcengineering/view-resources'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import templates from '../plugin'
|
||||
|
||||
export let object: TemplateGroup
|
||||
export let object: TemplateCategory
|
||||
|
||||
const dispatch = createEventDispatcher()
|
||||
|
||||
@ -37,7 +37,7 @@
|
||||
</script>
|
||||
|
||||
<Card
|
||||
label={templates.string.TemplateGroup}
|
||||
label={templates.string.TemplateCategory}
|
||||
okAction={() => {
|
||||
dispatch('close')
|
||||
}}
|
||||
|
@ -15,7 +15,7 @@
|
||||
<script lang="ts">
|
||||
import { Ref } from '@hcengineering/core'
|
||||
import presentation, { Card, getClient, SpaceSelector } from '@hcengineering/presentation'
|
||||
import { MessageTemplate, TemplateGroup } from '@hcengineering/templates'
|
||||
import { MessageTemplate, TemplateCategory } from '@hcengineering/templates'
|
||||
import templates from '../plugin'
|
||||
import view from '@hcengineering/view'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
@ -30,7 +30,7 @@
|
||||
})
|
||||
}
|
||||
|
||||
let space: Ref<TemplateGroup>
|
||||
let space: Ref<TemplateCategory>
|
||||
const dispatch = createEventDispatcher()
|
||||
</script>
|
||||
|
||||
@ -42,5 +42,5 @@
|
||||
on:close={() => dispatch('close')}
|
||||
canSave={space !== value.space}
|
||||
>
|
||||
<SpaceSelector bind:space _class={templates.class.TemplateGroup} label={view.string.Move} />
|
||||
<SpaceSelector bind:space _class={templates.class.TemplateCategory} label={view.string.Move} />
|
||||
</Card>
|
||||
|
@ -15,7 +15,7 @@
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { createQuery } from '@hcengineering/presentation'
|
||||
import { MessageTemplate, TemplateGroup } from '@hcengineering/templates'
|
||||
import { MessageTemplate, TemplateCategory } from '@hcengineering/templates'
|
||||
import { TextEditorHandler } from '@hcengineering/text-editor'
|
||||
import { closePopup, deviceOptionsStore, EditWithIcon, IconSearch } from '@hcengineering/ui'
|
||||
import { groupBy } from '@hcengineering/view-resources'
|
||||
@ -24,14 +24,14 @@
|
||||
|
||||
export let editor: TextEditorHandler
|
||||
let items: MessageTemplate[] = []
|
||||
let groups: TemplateGroup[] = []
|
||||
let groups: TemplateCategory[] = []
|
||||
|
||||
let query: string = ''
|
||||
|
||||
const liveQuery = createQuery()
|
||||
const catQuery = createQuery()
|
||||
|
||||
$: catQuery.query(templates.class.TemplateGroup, {}, (res) => {
|
||||
$: catQuery.query(templates.class.TemplateCategory, {}, (res) => {
|
||||
res.sort((a, b) => {
|
||||
return a.name.localeCompare(b.name)
|
||||
})
|
||||
@ -78,7 +78,7 @@
|
||||
return false
|
||||
}
|
||||
|
||||
function getInitIndex (groups: TemplateGroup[], i: number): number {
|
||||
function getInitIndex (groups: TemplateCategory[], i: number): number {
|
||||
let res = 0
|
||||
for (let index = 0; index < i; index++) {
|
||||
const cat = groups[index]
|
||||
|
@ -2,7 +2,7 @@
|
||||
import core, { Data, Ref } from '@hcengineering/core'
|
||||
import { getEmbeddedLabel, getResource } from '@hcengineering/platform'
|
||||
import { createQuery, getClient, MessageViewer, SpaceSelector } from '@hcengineering/presentation'
|
||||
import { MessageTemplate, TemplateGroup } from '@hcengineering/templates'
|
||||
import { MessageTemplate, TemplateCategory } from '@hcengineering/templates'
|
||||
import { StyledTextEditor } from '@hcengineering/text-editor'
|
||||
import {
|
||||
Action,
|
||||
@ -17,7 +17,7 @@
|
||||
} from '@hcengineering/ui'
|
||||
import { getActions as getContributedActions, TreeItem, TreeNode } from '@hcengineering/view-resources'
|
||||
import templatesPlugin from '../plugin'
|
||||
import CreateTemplateGroup from './CreateTemplateGroup.svelte'
|
||||
import CreateTemplateCategory from './CreateTemplateCategory.svelte'
|
||||
import FieldPopup from './FieldPopup.svelte'
|
||||
|
||||
const client = getClient()
|
||||
@ -37,9 +37,9 @@
|
||||
loading = false
|
||||
})
|
||||
|
||||
let spaces: TemplateGroup[] = []
|
||||
let spaces: TemplateCategory[] = []
|
||||
|
||||
spaceQ.query(templatesPlugin.class.TemplateGroup, {}, (res) => {
|
||||
spaceQ.query(templatesPlugin.class.TemplateCategory, {}, (res) => {
|
||||
spaces = res
|
||||
space = res[0]?._id
|
||||
})
|
||||
@ -95,7 +95,7 @@
|
||||
})
|
||||
}
|
||||
|
||||
function getTemplates (templates: MessageTemplate[], space: Ref<TemplateGroup>): MessageTemplate[] {
|
||||
function getTemplates (templates: MessageTemplate[], space: Ref<TemplateCategory>): MessageTemplate[] {
|
||||
return templates.filter((p) => p.space === space)
|
||||
}
|
||||
|
||||
@ -116,14 +116,14 @@
|
||||
}
|
||||
|
||||
const addSpace: Action = {
|
||||
label: templatesPlugin.string.CreateTemplateGroup,
|
||||
label: templatesPlugin.string.CreateTemplateCategory,
|
||||
icon: IconAdd,
|
||||
action: async (): Promise<void> => {
|
||||
showPopup(CreateTemplateGroup, {}, 'top')
|
||||
showPopup(CreateTemplateCategory, {}, 'top')
|
||||
}
|
||||
}
|
||||
|
||||
async function getSpaceActions (space: TemplateGroup): Promise<Action[]> {
|
||||
async function getSpaceActions (space: TemplateCategory): Promise<Action[]> {
|
||||
const result: Action[] = [addSpace]
|
||||
const extraActions = await getContributedActions(client, space, core.class.Space)
|
||||
for (const act of extraActions) {
|
||||
@ -139,7 +139,7 @@
|
||||
return result
|
||||
}
|
||||
|
||||
let space: Ref<TemplateGroup> | undefined = undefined
|
||||
let space: Ref<TemplateCategory> | undefined = undefined
|
||||
</script>
|
||||
|
||||
<div class="antiComponent">
|
||||
@ -201,12 +201,12 @@
|
||||
</span>
|
||||
{#if mode === Mode.Create}
|
||||
<SpaceSelector
|
||||
_class={templatesPlugin.class.TemplateGroup}
|
||||
label={templatesPlugin.string.TemplateGroup}
|
||||
_class={templatesPlugin.class.TemplateCategory}
|
||||
label={templatesPlugin.string.TemplateCategory}
|
||||
bind:space
|
||||
create={{
|
||||
component: templatesPlugin.component.CreateTemplateGroup,
|
||||
label: templatesPlugin.string.CreateTemplateGroup
|
||||
component: templatesPlugin.component.CreateTemplateCategory,
|
||||
label: templatesPlugin.string.CreateTemplateCategory
|
||||
}}
|
||||
/>
|
||||
{/if}
|
||||
|
@ -19,7 +19,7 @@ import Templates from './components/Templates.svelte'
|
||||
import { TextEditorHandler } from '@hcengineering/text-editor'
|
||||
import { showPopup } from '@hcengineering/ui'
|
||||
import TemplatePopup from './components/TemplatePopup.svelte'
|
||||
import CreateTemplateGroup from './components/CreateTemplateGroup.svelte'
|
||||
import CreateTemplateCategory from './components/CreateTemplateCategory.svelte'
|
||||
import Move from './components/Move.svelte'
|
||||
import Copy from './components/Copy.svelte'
|
||||
import EditGroup from './components/EditGroup.svelte'
|
||||
@ -32,7 +32,7 @@ function ShowTemplates (element: HTMLElement, editor: TextEditorHandler): void {
|
||||
export default async (): Promise<Resources> => ({
|
||||
component: {
|
||||
Templates,
|
||||
CreateTemplateGroup,
|
||||
CreateTemplateCategory,
|
||||
Move,
|
||||
Copy,
|
||||
EditGroup
|
||||
|
@ -31,12 +31,12 @@ export default mergeIds(templatesId, templates, {
|
||||
SearchTemplate: '' as IntlString,
|
||||
TemplatePlaceholder: '' as IntlString,
|
||||
Field: '' as IntlString,
|
||||
TemplateGroup: '' as IntlString,
|
||||
CreateTemplateGroup: '' as IntlString,
|
||||
TemplateCategory: '' as IntlString,
|
||||
CreateTemplateCategory: '' as IntlString,
|
||||
Copy: '' as IntlString
|
||||
},
|
||||
component: {
|
||||
Templates: '' as AnyComponent,
|
||||
CreateTemplateGroup: '' as AnyComponent
|
||||
CreateTemplateCategory: '' as AnyComponent
|
||||
}
|
||||
})
|
||||
|
@ -20,13 +20,13 @@ import { Asset, plugin } from '@hcengineering/platform'
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface TemplateGroup extends Space {}
|
||||
export interface TemplateCategory extends Space {}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface MessageTemplate extends Doc {
|
||||
space: Ref<TemplateGroup>
|
||||
space: Ref<TemplateCategory>
|
||||
title: string
|
||||
message: string
|
||||
}
|
||||
@ -78,12 +78,12 @@ export const templatesId = 'templates' as Plugin
|
||||
export default plugin(templatesId, {
|
||||
class: {
|
||||
MessageTemplate: '' as Ref<Class<MessageTemplate>>,
|
||||
TemplateGroup: '' as Ref<Class<TemplateGroup>>,
|
||||
TemplateCategory: '' as Ref<Class<TemplateCategory>>,
|
||||
TemplateField: '' as Ref<Class<TemplateField>>,
|
||||
TemplateFieldCategory: '' as Ref<Class<TemplateFieldCategory>>
|
||||
},
|
||||
space: {
|
||||
Templates: '' as Ref<TemplateGroup>
|
||||
Templates: '' as Ref<TemplateCategory>
|
||||
},
|
||||
icon: {
|
||||
Templates: '' as Asset,
|
||||
|
@ -145,7 +145,8 @@ class SessionManager {
|
||||
private async setStatus (ctx: MeasureContext, session: Session, online: boolean): Promise<void> {
|
||||
try {
|
||||
const user = (
|
||||
await session.pipeline().modelDb.findAll(
|
||||
await session.findAll(
|
||||
ctx,
|
||||
core.class.Account,
|
||||
{
|
||||
email: session.getUser()
|
||||
|
Loading…
Reference in New Issue
Block a user