Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion models/activity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
11 changes: 9 additions & 2 deletions models/activity/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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<Doc>) => 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
29 changes: 29 additions & 0 deletions models/activity/src/plugin.ts
Original file line number Diff line number Diff line change
@@ -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<Doc>) => boolean>
},
string: {
Attributes: '' as IntlString
}
})
4 changes: 2 additions & 2 deletions models/attachment/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -51,6 +51,6 @@ export default mergeIds(attachmentId, attachment, {
Attachments: '' as Ref<ActionCategory>
},
filter: {
AttachmentsFilter: '' as Resource<(tx: DisplayTx) => boolean>
AttachmentsFilter: '' as Resource<(tx: DisplayTx, _class?: Ref<Doc>) => boolean>
}
})
6 changes: 3 additions & 3 deletions models/chunter/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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<Doc>) => boolean>,
BacklinksFilter: '' as Resource<(tx: DisplayTx, _class?: Ref<Doc>) => boolean>
}
})
3 changes: 2 additions & 1 deletion plugins/activity-assets/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"Added": "added",
"Removed": "removed",
"From": "from",
"All": "All"
"All": "All",
"Attributes": "Attributes"
}
}
3 changes: 2 additions & 1 deletion plugins/activity-assets/lang/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"Added": "добавила(а)",
"Removed": "удалил(а)",
"From": "из",
"All": "Все"
"All": "Все",
"Attributes": "Атрибуты"
}
}
6 changes: 3 additions & 3 deletions plugins/activity-resources/src/components/Activity.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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<Doc>) => boolean)[] = [] // Enabled filters
const updateFiltered = () => (filtered = txes.filter((it) => filterActions.some((f) => f(it, object._class))))
async function updateFilterActions (fls: ActivityFilter[], selected: Ref<Doc>[] | 'All'): Promise<void> {
if (selected === 'All' || !Array.isArray(selected)) filterActions = [() => true]
else {
Expand All @@ -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)))
</script>

{#if !integrate || transparent}
Expand Down
9 changes: 9 additions & 0 deletions plugins/activity-resources/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -22,7 +24,14 @@ export { TxView }
export * from './activity'
export * from './utils'

export function attributeFilter (tx: DisplayTx, _class?: Ref<Doc>): boolean {
return tx.tx.objectClass === _class
}

export default async (): Promise<Resources> => ({
filter: {
AttributeFilter: attributeFilter
},
component: {
Activity
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/activity/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Doc>) => boolean>
}

/**
Expand Down
4 changes: 2 additions & 2 deletions plugins/attachment-resources/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -228,7 +228,7 @@ export async function DeleteAttachment (attach: Attachment): Promise<void> {
)
}

export function attachmentsFilter (tx: DisplayTx): boolean {
export function attachmentsFilter (tx: DisplayTx, _class?: Ref<Doc>): boolean {
return tx.tx.objectClass === attachment.class.Attachment
}

Expand Down
4 changes: 2 additions & 2 deletions plugins/chunter-resources/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Doc>): boolean {
return tx.tx.objectClass === chunter.class.Comment
}

export function backlinksFilter (tx: DisplayTx): boolean {
export function backlinksFilter (tx: DisplayTx, _class?: Ref<Doc>): boolean {
return tx.tx.objectClass === chunter.class.Backlink
}

Expand Down