mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-27 21:43:20 +03:00
TSK-1599 Search key model (#3514)
Add filtering key model to be used instead of sorting key as it is not always searchable. Signed-off-by: Alexander Onnikov <alexander.onnikov@xored.com>
This commit is contained in:
parent
cc80202d48
commit
0206a44176
@ -67,7 +67,7 @@ export { default } from './plugin'
|
||||
export const DOMAIN_TASK = 'task' as Domain
|
||||
export const DOMAIN_KANBAN = 'kanban' as Domain
|
||||
@Model(task.class.State, core.class.Status)
|
||||
@UX(task.string.TaskState, task.icon.TaskState, undefined, 'rank')
|
||||
@UX(task.string.TaskState, task.icon.TaskState, undefined, 'rank', 'name')
|
||||
export class TState extends TStatus implements State {
|
||||
isArchived!: boolean
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ export const DOMAIN_TRACKER = 'tracker' as Domain
|
||||
* @public
|
||||
*/
|
||||
@Model(tracker.class.IssueStatus, core.class.Status)
|
||||
@UX(tracker.string.IssueStatuses, undefined, undefined, 'rank')
|
||||
@UX(tracker.string.IssueStatuses, undefined, undefined, 'rank', 'name')
|
||||
export class TIssueStatus extends TStatus implements IssueStatus {}
|
||||
|
||||
/**
|
||||
|
@ -166,6 +166,7 @@ export interface Class<T extends Obj> extends Classifier {
|
||||
domain?: Domain
|
||||
shortLabel?: string
|
||||
sortingKey?: string
|
||||
filteringKey?: string
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -77,6 +77,7 @@ interface ClassTxes {
|
||||
kind: ClassifierKind
|
||||
shortLabel?: string | IntlString
|
||||
sortingKey?: string
|
||||
filteringKey?: string
|
||||
}
|
||||
|
||||
const transactions = new Map<any, ClassTxes>()
|
||||
@ -226,13 +227,20 @@ export function Mixin<T extends Obj> (_class: Ref<Class<T>>, _extends: Ref<Class
|
||||
* @param icon -
|
||||
* @returns
|
||||
*/
|
||||
export function UX<T extends Obj> (label: IntlString, icon?: Asset, shortLabel?: string, sortingKey?: string) {
|
||||
export function UX<T extends Obj> (
|
||||
label: IntlString,
|
||||
icon?: Asset,
|
||||
shortLabel?: string,
|
||||
sortingKey?: string,
|
||||
filteringKey?: string
|
||||
) {
|
||||
return function classDecorator<C extends new () => T> (constructor: C): void {
|
||||
const txes = getTxes(constructor.prototype)
|
||||
txes.label = label
|
||||
txes.icon = icon
|
||||
txes.shortLabel = shortLabel
|
||||
txes.sortingKey = sortingKey
|
||||
txes.filteringKey = filteringKey ?? sortingKey
|
||||
}
|
||||
}
|
||||
|
||||
@ -269,7 +277,8 @@ function _generateTx (tx: ClassTxes): Tx[] {
|
||||
label: tx.label,
|
||||
icon: tx.icon,
|
||||
shortLabel: tx.shortLabel,
|
||||
sortingKey: tx.sortingKey
|
||||
sortingKey: tx.sortingKey,
|
||||
filteringKey: tx.filteringKey
|
||||
},
|
||||
objectId
|
||||
)
|
||||
|
@ -84,9 +84,9 @@
|
||||
}
|
||||
|
||||
const resultQuery =
|
||||
search !== '' && clazz.sortingKey
|
||||
search !== '' && clazz.filteringKey
|
||||
? {
|
||||
[clazz.sortingKey]: { $like: '%' + search + '%' },
|
||||
[clazz.filteringKey]: { $like: '%' + search + '%' },
|
||||
_id: { $in: Array.from(targets.keys()) }
|
||||
}
|
||||
: {
|
||||
@ -155,7 +155,7 @@
|
||||
</script>
|
||||
|
||||
<div class="selectPopup" use:resizeObserver={() => dispatch('changeContent')}>
|
||||
{#if clazz.sortingKey}
|
||||
{#if clazz.filteringKey}
|
||||
<div class="header">
|
||||
<EditWithIcon
|
||||
icon={IconSearch}
|
||||
|
Loading…
Reference in New Issue
Block a user