mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-30 20:28:20 +00:00
Add AttributeFilter in Activity (#2608)
Signed-off-by: Alexander Platov <sas_lord@mail.ru>
This commit is contained in:
parent
8108f2e59b
commit
96fac678fc
@ -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"
|
||||
}
|
||||
}
|
||||
|
@ -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<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
models/activity/src/plugin.ts
Normal file
29
models/activity/src/plugin.ts
Normal file
@ -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
|
||||
}
|
||||
})
|
@ -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<ActionCategory>
|
||||
},
|
||||
filter: {
|
||||
AttachmentsFilter: '' as Resource<(tx: DisplayTx) => boolean>
|
||||
AttachmentsFilter: '' as Resource<(tx: DisplayTx, _class?: Ref<Doc>) => boolean>
|
||||
}
|
||||
})
|
||||
|
@ -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<Doc>) => boolean>,
|
||||
BacklinksFilter: '' as Resource<(tx: DisplayTx, _class?: Ref<Doc>) => boolean>
|
||||
}
|
||||
})
|
||||
|
@ -14,6 +14,7 @@
|
||||
"Added": "added",
|
||||
"Removed": "removed",
|
||||
"From": "from",
|
||||
"All": "All"
|
||||
"All": "All",
|
||||
"Attributes": "Attributes"
|
||||
}
|
||||
}
|
@ -14,6 +14,7 @@
|
||||
"Added": "добавила(а)",
|
||||
"Removed": "удалил(а)",
|
||||
"From": "из",
|
||||
"All": "Все"
|
||||
"All": "Все",
|
||||
"Attributes": "Атрибуты"
|
||||
}
|
||||
}
|
@ -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 {
|
||||
@ -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}
|
||||
|
@ -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<Doc>): boolean {
|
||||
return tx.tx.objectClass === _class
|
||||
}
|
||||
|
||||
export default async (): Promise<Resources> => ({
|
||||
filter: {
|
||||
AttributeFilter: attributeFilter
|
||||
},
|
||||
component: {
|
||||
Activity
|
||||
}
|
||||
|
@ -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>
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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<void> {
|
||||
)
|
||||
}
|
||||
|
||||
export function attachmentsFilter (tx: DisplayTx): boolean {
|
||||
export function attachmentsFilter (tx: DisplayTx, _class?: Ref<Doc>): boolean {
|
||||
return tx.tx.objectClass === attachment.class.Attachment
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user