diff --git a/models/activity/package.json b/models/activity/package.json index 54b00354b8..dec0bc9db2 100644 --- a/models/activity/package.json +++ b/models/activity/package.json @@ -31,6 +31,7 @@ "@hcengineering/platform": "^0.6.8", "@hcengineering/model-core": "^0.6.0", "@hcengineering/activity": "^0.6.0", - "@hcengineering/ui": "^0.6.3" + "@hcengineering/ui": "^0.6.3", + "@hcengineering/activity-resources": "^0.6.1" } } diff --git a/models/activity/src/index.ts b/models/activity/src/index.ts index 6938a71ac8..b58ff74121 100644 --- a/models/activity/src/index.ts +++ b/models/activity/src/index.ts @@ -14,7 +14,7 @@ // import type { ActivityFilter, DisplayTx, TxViewlet } from '@hcengineering/activity' -import activity from '@hcengineering/activity' +import activity from './plugin' import core, { Class, Doc, DocumentQuery, DOMAIN_MODEL, Ref, Tx } from '@hcengineering/core' import { Builder, Model } from '@hcengineering/model' import { TDoc } from '@hcengineering/model-core' @@ -39,9 +39,16 @@ export class TTxViewlet extends TDoc implements TxViewlet { @Model(activity.class.ActivityFilter, core.class.Class, DOMAIN_MODEL) export class TActivityFilter extends TDoc implements ActivityFilter { label!: IntlString - filter!: Resource<(tx: DisplayTx) => boolean> + filter!: Resource<(tx: DisplayTx, _class?: Ref) => boolean> } export function createModel (builder: Builder): void { builder.createModel(TTxViewlet, TActivityFilter) + + builder.createDoc(activity.class.ActivityFilter, core.space.Model, { + label: activity.string.Attributes, + filter: activity.filter.AttributeFilter + }) } + +export default activity diff --git a/models/activity/src/plugin.ts b/models/activity/src/plugin.ts new file mode 100644 index 0000000000..05150a22d7 --- /dev/null +++ b/models/activity/src/plugin.ts @@ -0,0 +1,29 @@ +// +// Copyright © 2022 Hardcore Engineering Inc. +// +// Licensed under the Eclipse Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. You may +// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +import type { DisplayTx } from '@hcengineering/activity' +import { activityId } from '@hcengineering/activity' +import activity from '@hcengineering/activity-resources/src/plugin' +import type { Resource, IntlString } from '@hcengineering/platform' +import { mergeIds } from '@hcengineering/platform' +import { Doc, Ref } from '@hcengineering/core' + +export default mergeIds(activityId, activity, { + filter: { + AttributeFilter: '' as Resource<(tx: DisplayTx, _class?: Ref) => boolean> + }, + string: { + Attributes: '' as IntlString + } +}) diff --git a/models/attachment/src/plugin.ts b/models/attachment/src/plugin.ts index 4a32472e57..85306b51d2 100644 --- a/models/attachment/src/plugin.ts +++ b/models/attachment/src/plugin.ts @@ -16,7 +16,7 @@ import type { DisplayTx, TxViewlet } from '@hcengineering/activity' import { attachmentId } from '@hcengineering/attachment' import attachment from '@hcengineering/attachment-resources/src/plugin' -import type { Ref } from '@hcengineering/core' +import type { Ref, Doc } from '@hcengineering/core' import type { IntlString, Resource } from '@hcengineering/platform' import { mergeIds } from '@hcengineering/platform' import type { AnyComponent } from '@hcengineering/ui' @@ -51,6 +51,6 @@ export default mergeIds(attachmentId, attachment, { Attachments: '' as Ref }, filter: { - AttachmentsFilter: '' as Resource<(tx: DisplayTx) => boolean> + AttachmentsFilter: '' as Resource<(tx: DisplayTx, _class?: Ref) => boolean> } }) diff --git a/models/chunter/src/plugin.ts b/models/chunter/src/plugin.ts index f33e3f94d0..4029b3f777 100644 --- a/models/chunter/src/plugin.ts +++ b/models/chunter/src/plugin.ts @@ -16,7 +16,7 @@ import type { DisplayTx, TxViewlet } from '@hcengineering/activity' import { Channel, chunterId } from '@hcengineering/chunter' import chunter from '@hcengineering/chunter-resources/src/plugin' -import type { Ref, Space } from '@hcengineering/core' +import type { Ref, Space, Doc } from '@hcengineering/core' import type { IntlString, Resource } from '@hcengineering/platform' import { mergeIds } from '@hcengineering/platform' import type { AnyComponent } from '@hcengineering/ui' @@ -93,7 +93,7 @@ export default mergeIds(chunterId, chunter, { ChunterBrowserVisible: '' as Resource<(spaces: Space[]) => boolean> }, filter: { - CommentsFilter: '' as Resource<(tx: DisplayTx) => boolean>, - BacklinksFilter: '' as Resource<(tx: DisplayTx) => boolean> + CommentsFilter: '' as Resource<(tx: DisplayTx, _class?: Ref) => boolean>, + BacklinksFilter: '' as Resource<(tx: DisplayTx, _class?: Ref) => boolean> } }) diff --git a/plugins/activity-assets/lang/en.json b/plugins/activity-assets/lang/en.json index 4d74656f22..a20ae459a5 100644 --- a/plugins/activity-assets/lang/en.json +++ b/plugins/activity-assets/lang/en.json @@ -14,6 +14,7 @@ "Added": "added", "Removed": "removed", "From": "from", - "All": "All" + "All": "All", + "Attributes": "Attributes" } } \ No newline at end of file diff --git a/plugins/activity-assets/lang/ru.json b/plugins/activity-assets/lang/ru.json index c96ec72e0c..413c0e49f3 100644 --- a/plugins/activity-assets/lang/ru.json +++ b/plugins/activity-assets/lang/ru.json @@ -14,6 +14,7 @@ "Added": "добавила(а)", "Removed": "удалил(а)", "From": "из", - "All": "Все" + "All": "Все", + "Attributes": "Атрибуты" } } \ No newline at end of file diff --git a/plugins/activity-resources/src/components/Activity.svelte b/plugins/activity-resources/src/components/Activity.svelte index 826cb7ebe3..7eae703ab8 100644 --- a/plugins/activity-resources/src/components/Activity.svelte +++ b/plugins/activity-resources/src/components/Activity.svelte @@ -117,8 +117,8 @@ ) } - let filterActions: ((tx: DisplayTx) => boolean)[] = [] // Enabled filters - const updateFiltered = () => (filtered = txes.filter((it) => filterActions.some((f) => f(it)))) + let filterActions: ((tx: DisplayTx, _class?: Ref) => boolean)[] = [] // Enabled filters + const updateFiltered = () => (filtered = txes.filter((it) => filterActions.some((f) => f(it, object._class)))) async function updateFilterActions (fls: ActivityFilter[], selected: Ref[] | 'All'): Promise { if (selected === 'All' || !Array.isArray(selected)) filterActions = [() => true] else { @@ -133,7 +133,7 @@ setTimeout(() => updateFiltered(), 0) } $: updateFilterActions(filters, selectedFilter) - $: filtered = txes.filter((it) => filterActions.some((f) => f(it))) + $: filtered = txes.filter((it) => filterActions.some((f) => f(it, object._class))) {#if !integrate || transparent} diff --git a/plugins/activity-resources/src/index.ts b/plugins/activity-resources/src/index.ts index 52462c5380..fac8b9cce3 100644 --- a/plugins/activity-resources/src/index.ts +++ b/plugins/activity-resources/src/index.ts @@ -13,7 +13,9 @@ // limitations under the License. // +import { Doc, Ref } from '@hcengineering/core' import { Resources } from '@hcengineering/platform' +import type { DisplayTx } from '@hcengineering/activity' import Activity from './components/Activity.svelte' import TxView from './components/TxView.svelte' @@ -22,7 +24,14 @@ export { TxView } export * from './activity' export * from './utils' +export function attributeFilter (tx: DisplayTx, _class?: Ref): boolean { + return tx.tx.objectClass === _class +} + export default async (): Promise => ({ + filter: { + AttributeFilter: attributeFilter + }, component: { Activity } diff --git a/plugins/activity/src/index.ts b/plugins/activity/src/index.ts index 78e4e3a9b2..562f242e80 100644 --- a/plugins/activity/src/index.ts +++ b/plugins/activity/src/index.ts @@ -97,7 +97,7 @@ export interface DisplayTx { */ export interface ActivityFilter extends Doc { label: IntlString - filter: Resource<(tx: DisplayTx) => boolean> + filter: Resource<(tx: DisplayTx, _class?: Ref) => boolean> } /** diff --git a/plugins/attachment-resources/src/index.ts b/plugins/attachment-resources/src/index.ts index 54ae9fb377..12f13b6fc3 100644 --- a/plugins/attachment-resources/src/index.ts +++ b/plugins/attachment-resources/src/index.ts @@ -14,7 +14,7 @@ // import attachment, { Attachment } from '@hcengineering/attachment' -import { ObjQueryType, SortingOrder, SortingQuery, Markup } from '@hcengineering/core' +import { ObjQueryType, SortingOrder, SortingQuery, Markup, Ref, Doc } from '@hcengineering/core' import { IntlString, Resources } from '@hcengineering/platform' import preference from '@hcengineering/preference' import { getClient } from '@hcengineering/presentation' @@ -228,7 +228,7 @@ export async function DeleteAttachment (attach: Attachment): Promise { ) } -export function attachmentsFilter (tx: DisplayTx): boolean { +export function attachmentsFilter (tx: DisplayTx, _class?: Ref): boolean { return tx.tx.objectClass === attachment.class.Attachment } diff --git a/plugins/chunter-resources/src/index.ts b/plugins/chunter-resources/src/index.ts index 1f4cb482e5..8f3545981c 100644 --- a/plugins/chunter-resources/src/index.ts +++ b/plugins/chunter-resources/src/index.ts @@ -207,11 +207,11 @@ async function update (source: Doc, key: string, target: RelatedDocument[], msg: await updateBacklinksList(getClient(), q, backlinks) } -export function commentsFilter (tx: DisplayTx): boolean { +export function commentsFilter (tx: DisplayTx, _class?: Ref): boolean { return tx.tx.objectClass === chunter.class.Comment } -export function backlinksFilter (tx: DisplayTx): boolean { +export function backlinksFilter (tx: DisplayTx, _class?: Ref): boolean { return tx.tx.objectClass === chunter.class.Backlink }