From 6739ce302df928dbe309442cfe20c0b1c17c40a4 Mon Sep 17 00:00:00 2001 From: budaeva <47611627+budaeva@users.noreply.github.com> Date: Tue, 31 May 2022 20:01:24 +0700 Subject: [PATCH] Messages search (#1935) Signed-off-by: budaeva --- models/chunter/src/index.ts | 12 ++ models/chunter/src/plugin.ts | 13 +- plugins/chunter-assets/lang/en.json | 5 +- plugins/chunter-assets/lang/ru.json | 5 +- .../src/components/CreateDirectMessage.svelte | 1 - .../src/components/DmHeader.svelte | 18 ++- .../src/components/Header.svelte | 18 ++- .../src/components/MessagesBrowser.svelte | 128 ++++++++++++++++++ .../src/components/SavedMessages.svelte | 30 ++-- plugins/chunter-resources/src/index.ts | 14 +- plugins/chunter-resources/src/plugin.ts | 3 +- plugins/chunter-resources/src/utils.ts | 17 ++- plugins/view-resources/src/index.ts | 2 + 13 files changed, 233 insertions(+), 33 deletions(-) create mode 100644 plugins/chunter-resources/src/components/MessagesBrowser.svelte diff --git a/models/chunter/src/index.ts b/models/chunter/src/index.ts index 605de85b48..67fcfb919e 100644 --- a/models/chunter/src/index.ts +++ b/models/chunter/src/index.ts @@ -93,6 +93,7 @@ export class TChunterMessage extends TAttachedDoc implements ChunterMessage { } @Model(chunter.class.ThreadMessage, chunter.class.ChunterMessage) +@UX(chunter.string.ThreadMessage) export class TThreadMessage extends TChunterMessage implements ThreadMessage { declare attachedTo: Ref @@ -100,6 +101,7 @@ export class TThreadMessage extends TChunterMessage implements ThreadMessage { } @Model(chunter.class.Message, chunter.class.ChunterMessage) +@UX(chunter.string.Message) export class TMessage extends TChunterMessage implements Message { declare attachedTo: Ref @@ -347,6 +349,12 @@ export function createModel (builder: Builder): void { componentProps: { requestedSpaceClasses: [chunter.class.Channel, chunter.class.DirectMessage] } + }, + { + id: 'messagesBrowser', + label: chunter.string.MessagesBrowser, + component: chunter.component.MessagesBrowser, + visibleIf: chunter.function.MessageBrowserVisible } ], spaces: [ @@ -437,6 +445,10 @@ export function createModel (builder: Builder): void { }, chunter.ids.TxBacklinkRemove ) + + builder.mixin(chunter.class.ChunterMessage, core.class.Class, view.mixin.ClassFilters, { + filters: ['space', 'modifiedOn', 'createBy', '_class'] + }) } export { chunterOperation } from './migration' diff --git a/models/chunter/src/plugin.ts b/models/chunter/src/plugin.ts index 3eaf6ec341..1ec84e2a10 100644 --- a/models/chunter/src/plugin.ts +++ b/models/chunter/src/plugin.ts @@ -16,8 +16,8 @@ import type { TxViewlet } from '@anticrm/activity' import { Channel, chunterId } from '@anticrm/chunter' import chunter from '@anticrm/chunter-resources/src/plugin' -import type { Ref } from '@anticrm/core' -import type { IntlString } from '@anticrm/platform' +import type { Ref, Space } from '@anticrm/core' +import type { IntlString, Resource } from '@anticrm/platform' import { mergeIds } from '@anticrm/platform' import type { AnyComponent } from '@anticrm/ui' import type { Action, ActionCategory, ViewAction, ViewletDescriptor } from '@anticrm/view' @@ -29,7 +29,8 @@ export default mergeIds(chunterId, chunter, { DmPresenter: '' as AnyComponent, Threads: '' as AnyComponent, ThreadView: '' as AnyComponent, - SavedMessages: '' as AnyComponent + SavedMessages: '' as AnyComponent, + MessagesBrowser: '' as AnyComponent }, action: { MarkCommentUnread: '' as Ref, @@ -63,7 +64,8 @@ export default mergeIds(chunterId, chunter, { MarkUnread: '' as IntlString, LastMessage: '' as IntlString, PinnedMessages: '' as IntlString, - SavedMessages: '' as IntlString + SavedMessages: '' as IntlString, + ThreadMessage: '' as IntlString }, viewlet: { Chat: '' as Ref @@ -82,5 +84,8 @@ export default mergeIds(chunterId, chunter, { space: { General: '' as Ref, Random: '' as Ref + }, + function: { + MessageBrowserVisible: '' as Resource<(spaces: Space[]) => boolean> } }) diff --git a/plugins/chunter-assets/lang/en.json b/plugins/chunter-assets/lang/en.json index 967517f736..72459fe2a7 100644 --- a/plugins/chunter-assets/lang/en.json +++ b/plugins/chunter-assets/lang/en.json @@ -59,6 +59,9 @@ "ChannelBrowser": "Channel browser", "SavedItems": "Saved items", "AddMembersHeader": "Add members to {channel}:", - "ConvertToPrivate": "Convert to private channel" + "ConvertToPrivate": "Convert to private channel", + "MessagesBrowser": "Messages browser", + "CreateBy": "Create by", + "ThreadMessage": "Thread message" } } \ No newline at end of file diff --git a/plugins/chunter-assets/lang/ru.json b/plugins/chunter-assets/lang/ru.json index f710feffe1..af3fb5ba0b 100644 --- a/plugins/chunter-assets/lang/ru.json +++ b/plugins/chunter-assets/lang/ru.json @@ -58,6 +58,9 @@ "ChannelBrowser": "Браузер каналов", "SavedItems": "Сохраненные объекты", "AddMembersHeader": "Добавить пользователей в {channel}:", - "ConvertToPrivate": "Конвертировать в закрытый канал" + "ConvertToPrivate": "Конвертировать в закрытый канал", + "MessagesBrowser": "Браузер сообщений", + "CreateBy": "Создано пользователем", + "ThreadMessage": "Сообщение в обсуждении" } } \ No newline at end of file diff --git a/plugins/chunter-resources/src/components/CreateDirectMessage.svelte b/plugins/chunter-resources/src/components/CreateDirectMessage.svelte index d31283e432..56911203c5 100644 --- a/plugins/chunter-resources/src/components/CreateDirectMessage.svelte +++ b/plugins/chunter-resources/src/components/CreateDirectMessage.svelte @@ -43,7 +43,6 @@ mode: 'space', space: dm._id }) - return } } diff --git a/plugins/chunter-resources/src/components/DmHeader.svelte b/plugins/chunter-resources/src/components/DmHeader.svelte index 0762627328..5ebec0d0e0 100644 --- a/plugins/chunter-resources/src/components/DmHeader.svelte +++ b/plugins/chunter-resources/src/components/DmHeader.svelte @@ -18,12 +18,16 @@ import { getCurrentAccount } from '@anticrm/core' import { createQuery, getClient, CombineAvatars } from '@anticrm/presentation' import contact, { EmployeeAccount } from '@anticrm/contact' - import { showPanel } from '@anticrm/ui' + import { getCurrentLocation, navigate, SearchEdit, showPanel } from '@anticrm/ui' import chunter from '../plugin' import { getDmName } from '../utils' + import { userSearch } from '../index' export let spaceId: Ref | undefined + let userSearch_: string = '' + userSearch.subscribe((v) => (userSearch_ = v)) + const client = getClient() const query = createQuery() const myAccId = getCurrentAccount()._id @@ -62,6 +66,18 @@ {/await} {/await} {/if} + { + userSearch.set(ev.detail) + + if (ev.detail !== '') { + const loc = getCurrentLocation() + loc.path[2] = 'messagesBrowser' + navigate(loc) + } + }} + />