mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-23 16:56:07 +00:00
UBERF-4348: Mentions. Fix render props types and component props types (#4022)
Signed-off-by: Maxim Karmatskikh <mkarmatskih@gmail.com>
This commit is contained in:
parent
273f3de0a3
commit
d36dcdc7da
@ -38,10 +38,15 @@
|
|||||||
|
|
||||||
const client = getClient()
|
const client = getClient()
|
||||||
|
|
||||||
client.findAll(presentation.class.ObjectSearchCategory, { context: 'mention' }).then(async (results) => {
|
client
|
||||||
categories = results
|
.findAll(presentation.class.ObjectSearchCategory, { context: 'mention' })
|
||||||
updateItems(query)
|
.then(async (results) => {
|
||||||
})
|
categories = results
|
||||||
|
await updateItems(query)
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
console.error(e)
|
||||||
|
})
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
@ -76,8 +81,8 @@
|
|||||||
if (key.key === 'Enter' || key.key === 'Tab') {
|
if (key.key === 'Enter' || key.key === 'Tab') {
|
||||||
key.preventDefault()
|
key.preventDefault()
|
||||||
key.stopPropagation()
|
key.stopPropagation()
|
||||||
const searchItem = items[selection]
|
if (selection < items.length) {
|
||||||
if (searchItem) {
|
const searchItem = items[selection]
|
||||||
dispatchItem(searchItem.item)
|
dispatchItem(searchItem.item)
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
@ -87,8 +92,6 @@
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
export function done () {}
|
|
||||||
|
|
||||||
function packSearchResultsForListView (sections: SearchSection[]): SearchItem[] {
|
function packSearchResultsForListView (sections: SearchSection[]): SearchItem[] {
|
||||||
let results: SearchItem[] = []
|
let results: SearchItem[] = []
|
||||||
for (const section of sections) {
|
for (const section of sections) {
|
||||||
@ -161,10 +164,11 @@
|
|||||||
const sections = await doFulltextSearch(classesToSearch, query)
|
const sections = await doFulltextSearch(classesToSearch, query)
|
||||||
items = packSearchResultsForListView(sections)
|
items = packSearchResultsForListView(sections)
|
||||||
}
|
}
|
||||||
$: updateItems(query)
|
$: void updateItems(query)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if (items.length === 0 && query !== '') || items.length > 0}
|
{#if (items.length === 0 && query !== '') || items.length > 0}
|
||||||
|
<!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
|
||||||
<form class="antiPopup mentionPoup" on:keydown={onKeyDown} use:resizeObserver={() => dispatch('changeSize')}>
|
<form class="antiPopup mentionPoup" on:keydown={onKeyDown} use:resizeObserver={() => dispatch('changeSize')}>
|
||||||
<div class="ap-scroll" bind:this={scrollContainer}>
|
<div class="ap-scroll" bind:this={scrollContainer}>
|
||||||
<div class="ap-box">
|
<div class="ap-box">
|
||||||
@ -185,6 +189,7 @@
|
|||||||
<svelte:fragment slot="item" let:item={num}>
|
<svelte:fragment slot="item" let:item={num}>
|
||||||
{@const item = items[num]}
|
{@const item = items[num]}
|
||||||
{@const doc = item.item}
|
{@const doc = item.item}
|
||||||
|
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
||||||
<div
|
<div
|
||||||
class="ap-menuItem withComp"
|
class="ap-menuItem withComp"
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
|
@ -34,15 +34,15 @@ function createIndexedReader (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function readAndMapProps (reader: IndexedReader, props: ClassSearchConfigProps[]): Record<string, string> {
|
function readAndMapProps (reader: IndexedReader, props: ClassSearchConfigProps[]): Record<string, any> {
|
||||||
const res: Record<string, string> = {}
|
const res: Record<string, any> = {}
|
||||||
for (const prop of props) {
|
for (const prop of props) {
|
||||||
if (typeof prop === 'string') {
|
if (typeof prop === 'string') {
|
||||||
res[prop] = reader.get(prop)
|
res[prop] = reader.get(prop)
|
||||||
} else {
|
} else {
|
||||||
for (const [propName, rest] of Object.entries(prop)) {
|
for (const [propName, rest] of Object.entries(prop)) {
|
||||||
if (rest.length > 1) {
|
if (rest.length > 1) {
|
||||||
const val = reader.getDoc(rest[0])?.get(rest[1]) ?? ''
|
const val = reader.getDoc(rest[0])?.get(rest[1])
|
||||||
res[propName] = Array.isArray(val) ? val[0] : val
|
res[propName] = Array.isArray(val) ? val[0] : val
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -135,6 +135,6 @@ export function mapSearchResultDoc (hierarchy: Hierarchy, raw: IndexedDoc): Sear
|
|||||||
return doc
|
return doc
|
||||||
}
|
}
|
||||||
|
|
||||||
function fillTemplate (tmpl: string, props: Record<string, string>): string {
|
function fillTemplate (tmpl: string, props: Record<string, any>): string {
|
||||||
return tmpl.replace(/{(.*?)}/g, (_, key: string) => props[key])
|
return tmpl.replace(/{(.*?)}/g, (_, key: string) => props[key])
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user