List extract (#2505)

This commit is contained in:
Denis Bykhov
2023-01-14 17:54:54 +07:00
committed by GitHub
parent 1c01925ed4
commit 6a5f1ed479
124 changed files with 2382 additions and 1445 deletions
@@ -88,16 +88,7 @@
<TableBrowser
{_class}
config={[
'',
'$lookup.attachedTo',
'$lookup.assignee',
'$lookup.state',
'$lookup.doneState',
'attachments',
'comments',
'modifiedOn'
]}
config={['', 'attachedTo', 'assignee', 'state', 'doneState', 'attachments', 'comments', 'modifiedOn']}
query={resultQuery}
showNotification
/>
@@ -18,11 +18,11 @@
import type { DoneState, SpaceWithStates, State, Task } from '@hcengineering/task'
import task from '@hcengineering/task'
import { BarDashboard, DashboardItem } from '@hcengineering/ui'
import { FilterBar } from '@hcengineering/view-resources'
import CreateFilter from './CreateFilter.svelte'
export let _class: Ref<Class<Task>>
export let space: Ref<SpaceWithStates>
export let query: DocumentQuery<Task>
const client = getClient()
const hieararchy = client.getHierarchy()
@@ -85,15 +85,12 @@
const docQuery = createQuery()
$: query = modified
$: resultQuery = modified
? {
space,
_id: { $in: ids }
_id: { $in: ids },
...query
}
: { space }
let resultQuery = {
space
}
: query
function updateDocs (_class: Ref<Class<Task>>, states: State[], query: DocumentQuery<Task>): void {
if (states.length === 0) {
@@ -146,7 +143,6 @@
</script>
<CreateFilter bind:value={modified} />
<FilterBar {_class} {query} on:change={(e) => (resultQuery = e.detail)} />
<div class="ml-10 mt-4">
<BarDashboard {items} />
@@ -15,7 +15,7 @@
-->
<script lang="ts">
import { Class, DocumentQuery, FindOptions, Ref, SortingOrder } from '@hcengineering/core'
import { createQuery } from '@hcengineering/presentation'
import { createQuery, getClient } from '@hcengineering/presentation'
import { DoneState, SpaceWithStates, State, Task } from '@hcengineering/task'
import { TabList } from '@hcengineering/ui'
import type { TabItem } from '@hcengineering/ui'
@@ -27,26 +27,26 @@
export let _class: Ref<Class<Task>>
export let space: Ref<SpaceWithStates>
export let query: DocumentQuery<Task>
export let options: FindOptions<Task> | undefined
export let config: string[]
export let search: string
let doneStatusesView: boolean = false
let state: Ref<State> | undefined = undefined
const selectedDoneStates: Set<Ref<DoneState>> = new Set<Ref<DoneState>>()
$: resConfig = updateConfig(config)
let query = {}
let doneStates: DoneState[] = []
let itemsDS: TabItem[] = []
let selectedDS: string[] = []
let withoutDone: boolean = false
let resultQuery: DocumentQuery<Task>
function updateConfig (config: string[]): string[] {
if (state !== undefined) {
return config.filter((p) => p !== '$lookup.state')
return config.filter((p) => p !== 'state')
}
if (selectedDoneStates.size === 1) {
return config.filter((p) => p !== '$lookup.doneState')
return config.filter((p) => p !== 'doneState')
}
return config
}
@@ -77,12 +77,11 @@
}
)
async function updateQuery (search: string, selectedDoneStates: Set<Ref<DoneState>>): Promise<void> {
const client = getClient()
async function updateQuery (query: DocumentQuery<Task>, selectedDoneStates: Set<Ref<DoneState>>): Promise<void> {
resConfig = updateConfig(config)
const result = {} as DocumentQuery<Task>
if (search !== '') {
result.$search = search
}
const result = client.getHierarchy().clone(query)
result.space = space
if (state) {
result.state = state
@@ -94,7 +93,7 @@
} else if (withoutDone) {
result.doneState = null
}
query = result
resultQuery = result
}
function doneStateClick (id: Ref<DoneState>): void {
@@ -108,17 +107,17 @@
selectedDS = ['NoDoneState']
withoutDone = true
}
updateQuery(search, selectedDoneStates)
updateQuery(query, selectedDoneStates)
}
function noDoneClick (): void {
withoutDone = true
selectedDS = ['NoDoneState']
selectedDoneStates.clear()
updateQuery(search, selectedDoneStates)
updateQuery(query, selectedDoneStates)
}
$: updateQuery(search, selectedDoneStates)
$: updateQuery(query, selectedDoneStates)
const handleSelect = (result: any) => {
if (result.type === 'select') {
const res = result.detail
@@ -127,12 +126,12 @@
state = undefined
withoutDone = false
selectedDoneStates.clear()
updateQuery(search, selectedDoneStates)
updateQuery(query, selectedDoneStates)
} else if (res.id === 'DoneStates') {
doneStatusesView = true
state = undefined
selectedDoneStates.clear()
updateQuery(search, selectedDoneStates)
updateQuery(query, selectedDoneStates)
}
}
}
@@ -158,11 +157,11 @@
{#if doneStatusesView}
<TabList items={itemsDS} bind:selected={selectedDS} multiselect on:select={handleDoneSelect} size={'small'} />
{:else}
<StatesBar bind:state {space} gap={'none'} on:change={() => updateQuery(search, selectedDoneStates)} />
<StatesBar bind:state {space} gap={'none'} on:change={() => updateQuery(query, selectedDoneStates)} />
{/if}
</div>
<div class="statustableview-container">
<TableBrowser {_class} bind:query config={resConfig} {options} showNotification />
<TableBrowser {_class} bind:query={resultQuery} config={resConfig} {options} showNotification />
</div>
<style lang="scss">
@@ -14,7 +14,7 @@
// limitations under the License.
-->
<script lang="ts">
import { Class, Doc, FindOptions, Ref, SortingOrder } from '@hcengineering/core'
import { Class, Doc, DocumentQuery, FindOptions, Ref, SortingOrder } from '@hcengineering/core'
import { Kanban as KanbanUI } from '@hcengineering/kanban'
import { getResource } from '@hcengineering/platform'
import { createQuery, getClient } from '@hcengineering/presentation'
@@ -23,7 +23,6 @@
import { getEventPositionElement, showPopup } from '@hcengineering/ui'
import {
ActionContext,
FilterBar,
focusStore,
ListSelectionProvider,
SelectDirection,
@@ -35,8 +34,7 @@
export let _class: Ref<Class<Task>>
export let space: Ref<SpaceWithStates>
// export let open: AnyComponent
export let search: string
export let query: DocumentQuery<Task>
export let options: FindOptions<Task> | undefined
export let baseMenuClass: Ref<Class<Doc>> | undefined = undefined
// export let config: string[]
@@ -96,7 +94,8 @@
listProvider.updateSelection(evt.detail.docs, evt.detail.value)
}
const onContextMenu = (evt: any) => showMenu(evt.detail.evt, evt.detail.objects)
let resultQuery = { doneState: null, space }
$: resultQuery = { ...query, doneState: null }
</script>
{#await cardPresenter then presenter}
@@ -105,22 +104,13 @@
mode: 'browser'
}}
/>
<FilterBar
{_class}
query={{ doneState: null, space }}
on:change={(e) => {
resultQuery = e.detail
}}
/>
<KanbanUI
bind:this={kanbanUI}
{_class}
{search}
{options}
query={resultQuery}
{states}
fieldName={'state'}
rankFieldName={'rank'}
on:content={onContent}
on:obj-focus={onObjFocus}
checked={$selectionStore ?? []}
@@ -0,0 +1,33 @@
<!--
// Copyright © 2020, 2021 Anticrm Platform Contributors.
// Copyright © 2021 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.
-->
<script lang="ts">
import { Ref } from '@hcengineering/core'
import { createQuery } from '@hcengineering/presentation'
import type { DoneState } from '@hcengineering/task'
import task from '@hcengineering/task'
import DoneStatePresenter from './DoneStatePresenter.svelte'
export let value: Ref<DoneState>
export let showTitle: boolean = true
let state: DoneState | undefined
const query = createQuery()
$: query.query(task.class.DoneState, { _id: value }, (res) => ([state] = res), { limit: 1 })
</script>
{#if state}
<DoneStatePresenter value={state} {showTitle} />
{/if}
@@ -0,0 +1,31 @@
<!--
// Copyright © 2020, 2021 Anticrm Platform Contributors.
// Copyright © 2021 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.
-->
<script lang="ts">
import { Ref } from '@hcengineering/core'
import { createQuery } from '@hcengineering/presentation'
import task, { State } from '@hcengineering/task'
import StatePresenter from './StatePresenter.svelte'
export let value: Ref<State>
let state: State | undefined
const query = createQuery()
$: query.query(task.class.State, { _id: value }, (res) => ([state] = res), { limit: 1 })
</script>
{#if state}
<StatePresenter value={state} />
{/if}