mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-17 05:47:32 +00:00
Query update fix (#728)
Signed-off-by: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com>
This commit is contained in:
parent
ceaadd65ff
commit
a40b9331df
@ -42,7 +42,7 @@ By default docker volumes `dev_db` `dev_elastic` `dev_files` will be created for
|
||||
Before we could start we need to create workspace/account and associate it with workspace.
|
||||
|
||||
```bash
|
||||
cd ./dev/tools
|
||||
cd ./dev/tool
|
||||
rushx run-local create-workspace ws1 -o DevWorkspace # Create workspace
|
||||
rushx run-local create-account user1 -p 1234 -f John -l Appleseed # Create account
|
||||
rushx run-local assign-workspace user1 ws1 # Assign worksapce to user
|
||||
|
@ -112,6 +112,7 @@ specifiers:
|
||||
'@types/koa-bodyparser': ^4.3.3
|
||||
'@types/koa-router': ^7.4.4
|
||||
'@types/koa__cors': ^3.0.3
|
||||
'@types/mime-types': ~2.1.1
|
||||
'@types/minio': ^7.0.10
|
||||
'@types/pdfkit': ~0.12.3
|
||||
'@types/toposort': ^2.0.3
|
||||
@ -284,6 +285,7 @@ dependencies:
|
||||
'@types/koa-bodyparser': 4.3.4
|
||||
'@types/koa-router': 7.4.4
|
||||
'@types/koa__cors': 3.1.0
|
||||
'@types/mime-types': 2.1.1
|
||||
'@types/minio': 7.0.11
|
||||
'@types/pdfkit': 0.12.3
|
||||
'@types/toposort': 2.0.3
|
||||
@ -11928,7 +11930,7 @@ packages:
|
||||
dev: false
|
||||
|
||||
file:projects/presentation.tgz_096c09b0b673a57c275d9767a12070b1:
|
||||
resolution: {integrity: sha512-tpa5gk8H/quPYXkpBhp5jS0bp/E+Jk7mTGhfE54q4RTr5LOYGTCg2HKmxZWqRV1N3g1Jk7nKAZHWMxMSGHCuKw==, tarball: file:projects/presentation.tgz}
|
||||
resolution: {integrity: sha512-KbCYAGG7rz+Ov6f0yICsx0yzzufqd0RcVJ6XVLzYxLTurJiTeYNYSthU045vLXkRURpz4gEICQ0RHv9dvckMMA==, tarball: file:projects/presentation.tgz}
|
||||
id: file:projects/presentation.tgz
|
||||
name: '@rush-temp/presentation'
|
||||
version: 0.0.0
|
||||
@ -11941,6 +11943,7 @@ packages:
|
||||
eslint-plugin-node: 11.1.0_eslint@7.32.0
|
||||
eslint-plugin-promise: 5.2.0_eslint@7.32.0
|
||||
eslint-plugin-svelte3: 3.2.1_eslint@7.32.0+svelte@3.44.3
|
||||
fast-equals: 2.0.4
|
||||
prettier: 2.5.1
|
||||
prettier-plugin-svelte: 2.5.1_prettier@2.5.1+svelte@3.44.3
|
||||
sass: 1.45.0
|
||||
@ -12527,7 +12530,7 @@ packages:
|
||||
dev: false
|
||||
|
||||
file:projects/tool.tgz:
|
||||
resolution: {integrity: sha512-kxAczrVzjVh47GTnScTkjjXIpSAkovYmCIxJSznbPqT4XOdtQ0F8eadl3h2mhqjKzgE7VoFOdTB5JJ3oy4+TUg==, tarball: file:projects/tool.tgz}
|
||||
resolution: {integrity: sha512-qHMgirlUUHe5dhM4Ebp1jCkPR759Wec5zhDTLNt4y0eKhQIVeshkraGGp0mGdUmvIDN+e+CbJMCXDXY35r0BqQ==, tarball: file:projects/tool.tgz}
|
||||
name: '@rush-temp/tool'
|
||||
version: 0.0.0
|
||||
dependencies:
|
||||
@ -12609,7 +12612,7 @@ packages:
|
||||
dev: false
|
||||
|
||||
file:projects/view-resources.tgz_096c09b0b673a57c275d9767a12070b1:
|
||||
resolution: {integrity: sha512-oT79PCOUvwaL6QgjuwTNVJJqyE82WDmBx37jF5/c6SpSrYNF14+hN41rrPReKQyhhxkyrBts73IePyHxIn653Q==, tarball: file:projects/view-resources.tgz}
|
||||
resolution: {integrity: sha512-Ec9uQXBdFop5UPSMzA6UQaryHWmVTWVsDnWOzCH7BYtq7Zvw+763oJMFChaDsoGgeE2znn5zgam4sUn/1alqxQ==, tarball: file:projects/view-resources.tgz}
|
||||
id: file:projects/view-resources.tgz
|
||||
name: '@rush-temp/view-resources'
|
||||
version: 0.0.0
|
||||
@ -12622,6 +12625,7 @@ packages:
|
||||
eslint-plugin-node: 11.1.0_eslint@7.32.0
|
||||
eslint-plugin-promise: 5.2.0_eslint@7.32.0
|
||||
eslint-plugin-svelte3: 3.2.1_eslint@7.32.0+svelte@3.44.3
|
||||
fast-equals: 2.0.4
|
||||
prettier: 2.5.1
|
||||
prettier-plugin-svelte: 2.5.1_prettier@2.5.1+svelte@3.44.3
|
||||
sass: 1.45.0
|
||||
|
@ -37,14 +37,18 @@
|
||||
let objects: Doc[]
|
||||
|
||||
const q = createQuery()
|
||||
$: q.query(
|
||||
_class,
|
||||
query,
|
||||
(result) => {
|
||||
objects = result
|
||||
},
|
||||
{ sort: { [sortKey]: sortOrder }, ...options, limit: 200 }
|
||||
)
|
||||
|
||||
async function update(_class: Ref<Class<Doc>>, query: DocumentQuery<Doc>, sortKey: string, sortOrder: SortingOrder, options?: FindOptions<Doc>) {
|
||||
q.query(
|
||||
_class,
|
||||
query,
|
||||
(result) => {
|
||||
objects = result
|
||||
},
|
||||
{ sort: { [sortKey]: sortOrder }, ...options, limit: 200 }
|
||||
)
|
||||
}
|
||||
$: update(_class, query, sortKey, sortOrder, options)
|
||||
|
||||
function getValue (doc: Doc, key: string): any {
|
||||
if (key.length === 0) {
|
||||
|
@ -26,12 +26,12 @@
|
||||
export let config: string[]
|
||||
export let search: string = ''
|
||||
|
||||
$: query = search === '' ? { space } : { $search: search, space }
|
||||
$: resultQuery = search === '' ? { space, ...query } : { $search: search, space, ...query }
|
||||
</script>
|
||||
|
||||
<div class="tableview-container">
|
||||
<ScrollBox vertical stretch noShift>
|
||||
<Table {_class} {config} {options} {query} {baseMenuClass} enableChecking />
|
||||
<Table {_class} {config} {options} query={resultQuery} {baseMenuClass} enableChecking />
|
||||
</ScrollBox>
|
||||
</div>
|
||||
|
||||
|
@ -19,7 +19,6 @@
|
||||
import type { Viewlet } from '@anticrm/view'
|
||||
import { Component } from '@anticrm/ui'
|
||||
|
||||
|
||||
export let _class: Ref<Class<Doc>>
|
||||
export let space: Ref<Space>
|
||||
export let search: string
|
||||
@ -27,16 +26,18 @@
|
||||
</script>
|
||||
|
||||
{#if viewlet}
|
||||
<div class="container">
|
||||
<Component is={viewlet.$lookup?.descriptor?.component} props={ {
|
||||
_class,
|
||||
space,
|
||||
open: viewlet.open,
|
||||
options: viewlet.options,
|
||||
config: viewlet.config,
|
||||
search
|
||||
} } />
|
||||
</div>
|
||||
{#key space}
|
||||
<div class="container">
|
||||
<Component is={viewlet.$lookup?.descriptor?.component} props={ {
|
||||
_class,
|
||||
space,
|
||||
open: viewlet.open,
|
||||
options: viewlet.options,
|
||||
config: viewlet.config,
|
||||
search
|
||||
} } />
|
||||
</div>
|
||||
{/key}
|
||||
{/if}
|
||||
|
||||
<style lang="scss">
|
||||
|
@ -32,6 +32,7 @@
|
||||
export let createItemDialog: AnyComponent | undefined
|
||||
export let search: string
|
||||
export let viewlet: WithLookup<Viewlet> | undefined
|
||||
export let viewlets: WithLookup<Viewlet>[] = []
|
||||
|
||||
const client = getClient()
|
||||
const query = createQuery()
|
||||
@ -39,27 +40,6 @@
|
||||
|
||||
$: query.query(core.class.Space, { _id: spaceId }, result => { space = result[0] })
|
||||
|
||||
function onSearch(ev: Event) {
|
||||
search = (ev.target as HTMLInputElement).value
|
||||
}
|
||||
|
||||
let viewlets: WithLookup<Viewlet>[] = []
|
||||
async function getViewlets(attachTo: Ref<Class<Doc>>): Promise<void> {
|
||||
viewlets = await client.findAll(view.class.Viewlet, { attachTo }, { lookup: {
|
||||
descriptor: core.class.Class
|
||||
}})
|
||||
}
|
||||
|
||||
$: if (_class) {
|
||||
getViewlets(_class)
|
||||
}
|
||||
|
||||
function resetSelectedViewlet (_space: Ref<Space> | undefined) {
|
||||
selectedViewlet = 0
|
||||
}
|
||||
|
||||
$: resetSelectedViewlet(spaceId)
|
||||
|
||||
function showCreateDialog(ev: Event) {
|
||||
showPopup(createItemDialog as AnyComponent, { space: spaceId }, ev.target as HTMLElement)
|
||||
}
|
||||
@ -82,7 +62,7 @@
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
<EditWithIcon icon={IconSearch} placeholder={'Search'} on:change={onSearch}/>
|
||||
<EditWithIcon icon={IconSearch} placeholder={'Search'} bind:value={search} />
|
||||
{#if createItemDialog}
|
||||
<Button label={workbench.string.Create} primary={true} size={'small'} on:click={(ev) => showCreateDialog(ev)}/>
|
||||
{/if}
|
||||
|
@ -14,9 +14,10 @@
|
||||
-->
|
||||
|
||||
<script lang="ts">
|
||||
import type { Ref, Space, WithLookup } from '@anticrm/core'
|
||||
import core, { Class, Doc, Ref, Space, WithLookup } from '@anticrm/core'
|
||||
import { getClient } from '@anticrm/presentation'
|
||||
import type { AnyComponent } from '@anticrm/ui'
|
||||
import type { Viewlet } from '@anticrm/view'
|
||||
import view, { Viewlet } from '@anticrm/view'
|
||||
import type { ViewConfiguration } from '@anticrm/workbench'
|
||||
|
||||
import SpaceContent from './SpaceContent.svelte'
|
||||
@ -28,7 +29,25 @@
|
||||
|
||||
let search: string = ''
|
||||
let viewlet: WithLookup<Viewlet> | undefined = undefined
|
||||
let space: Ref<Space> | undefined = undefined
|
||||
let _class: Ref<Class<Doc>> | undefined = undefined
|
||||
|
||||
const client = getClient()
|
||||
|
||||
let viewlets: WithLookup<Viewlet>[] = []
|
||||
|
||||
async function update(attachTo?: Ref<Class<Doc>>, currentSpace?: Ref<Space>): Promise<void> {
|
||||
if (attachTo) {
|
||||
viewlets = await client.findAll(view.class.Viewlet, { attachTo }, { lookup: {
|
||||
descriptor: core.class.Class
|
||||
}})
|
||||
_class = attachTo
|
||||
}
|
||||
viewlet = viewlets[0]
|
||||
space = currentSpace
|
||||
}
|
||||
|
||||
$: update(currentView?.class, currentSpace)
|
||||
|
||||
function resetSearch (_space: Ref<Space> | undefined): void {
|
||||
search = ''
|
||||
@ -37,7 +56,7 @@
|
||||
$: resetSearch(currentSpace)
|
||||
</script>
|
||||
|
||||
<SpaceHeader spaceId={currentSpace} _class={currentView?.class} {createItemDialog} bind:search={search} bind:viewlet={viewlet} />
|
||||
{#if currentView && currentSpace}
|
||||
<SpaceContent space={currentSpace} _class={currentView.class} {search} {viewlet} />
|
||||
<SpaceHeader spaceId={space} {_class} {viewlets} {createItemDialog} bind:search={search} bind:viewlet={viewlet} />
|
||||
{#if _class && space}
|
||||
<SpaceContent {space} {_class} {search} {viewlet} />
|
||||
{/if}
|
||||
|
@ -65,8 +65,8 @@
|
||||
return
|
||||
}
|
||||
|
||||
const space = (await client.findAll(core.class.Space, { _id: currentFolder }))[0]
|
||||
currentSpace = currentFolder
|
||||
const space = (await client.findAll(core.class.Space, { _id: currentSpace }))[0]
|
||||
if (space) {
|
||||
const spaceClass = client.getHierarchy().getClass(space._class) // (await client.findAll(core.class.Class, { _id: space._class }))[0]
|
||||
const view = client.getHierarchy().as(spaceClass, workbench.mixin.SpaceView)
|
||||
|
Loading…
Reference in New Issue
Block a user