mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-27 03:54:57 +02:00
UBERF-4928: Indexing fixes (#4357)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
@@ -1,88 +0,0 @@
|
||||
<!--
|
||||
// Copyright © 2020 Anticrm Platform Contributors.
|
||||
//
|
||||
// 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 type { Class, Ref, Space } from '@hcengineering/core'
|
||||
import { Card, createQuery, getClient } from '@hcengineering/presentation'
|
||||
import type { Task, TodoItem } from '@hcengineering/task'
|
||||
import task, { calcRank } from '@hcengineering/task'
|
||||
import { DatePicker, EditBox, Grid } from '@hcengineering/ui'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import plugin from '../../plugin'
|
||||
|
||||
export let objectId: Ref<Task>
|
||||
export let _class: Ref<Class<Task>>
|
||||
export let space: Ref<Space>
|
||||
|
||||
let name: string
|
||||
const done = false
|
||||
let dueTo: number | null = null
|
||||
let latestItem: TodoItem | undefined = undefined
|
||||
|
||||
const dispatch = createEventDispatcher()
|
||||
const client = getClient()
|
||||
const todoItemsQuery = createQuery()
|
||||
|
||||
export function canClose (): boolean {
|
||||
return objectId === undefined
|
||||
}
|
||||
|
||||
async function createTodo () {
|
||||
await client.addCollection(task.class.TodoItem, space, objectId, _class, 'todoItems', {
|
||||
name,
|
||||
assignee: null,
|
||||
done,
|
||||
dueTo: dueTo ?? null,
|
||||
rank: calcRank(latestItem)
|
||||
})
|
||||
}
|
||||
|
||||
$: todoItemsQuery.query(
|
||||
task.class.TodoItem,
|
||||
{ attachedTo: objectId },
|
||||
(result) => {
|
||||
latestItem = undefined
|
||||
if (result && result.length > 0) {
|
||||
latestItem = result[result.length - 1]
|
||||
}
|
||||
},
|
||||
{
|
||||
sort: {
|
||||
rank: 1
|
||||
}
|
||||
}
|
||||
)
|
||||
</script>
|
||||
|
||||
<Card
|
||||
label={plugin.string.TodoCreate}
|
||||
okAction={createTodo}
|
||||
canSave={name?.length > 0}
|
||||
on:close={() => {
|
||||
dispatch('close')
|
||||
}}
|
||||
okLabel={plugin.string.TodoSave}
|
||||
on:changeContent
|
||||
>
|
||||
<Grid column={1} rowGap={1.75}>
|
||||
<EditBox
|
||||
label={plugin.string.TodoDescription}
|
||||
bind:value={name}
|
||||
icon={task.icon.Task}
|
||||
placeholder={plugin.string.TodoDescriptionPlaceholder}
|
||||
autoFocus
|
||||
/>
|
||||
<DatePicker title={plugin.string.TodoDueDate} bind:value={dueTo} />
|
||||
</Grid>
|
||||
</Card>
|
||||
@@ -1,85 +0,0 @@
|
||||
<!--
|
||||
// Copyright © 2020 Anticrm Platform Contributors.
|
||||
//
|
||||
// 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 type { DocumentUpdate, Ref, Timestamp } from '@hcengineering/core'
|
||||
import { Card, getClient } from '@hcengineering/presentation'
|
||||
import type { TodoItem } from '@hcengineering/task'
|
||||
import task from '@hcengineering/task'
|
||||
import { DatePicker, EditBox, Grid } from '@hcengineering/ui'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import plugin from '../../plugin'
|
||||
|
||||
export let item: TodoItem
|
||||
|
||||
let name: string = ''
|
||||
let dueTo: number | null | undefined = null
|
||||
|
||||
let _itemId: Ref<TodoItem>
|
||||
|
||||
$: if (_itemId !== item._id) {
|
||||
_itemId = item._id
|
||||
name = item.name
|
||||
if (item.dueTo != null) {
|
||||
dueTo = item.dueTo
|
||||
} else {
|
||||
dueTo = null
|
||||
}
|
||||
}
|
||||
|
||||
const dispatch = createEventDispatcher()
|
||||
const client = getClient()
|
||||
|
||||
export function canClose (): boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
async function editTodo () {
|
||||
const ops: DocumentUpdate<TodoItem> = {}
|
||||
if (item.name !== name) {
|
||||
ops.name = name
|
||||
}
|
||||
if (item.dueTo !== dueTo) {
|
||||
ops.dueTo = (dueTo ?? null) as unknown as Timestamp
|
||||
}
|
||||
|
||||
if (Object.keys(ops).length === 0) {
|
||||
return
|
||||
}
|
||||
|
||||
await client.update(item, ops)
|
||||
}
|
||||
</script>
|
||||
|
||||
<Card
|
||||
label={plugin.string.TodoEdit}
|
||||
okAction={editTodo}
|
||||
canSave={name.length > 0}
|
||||
on:close={() => {
|
||||
dispatch('close')
|
||||
}}
|
||||
okLabel={plugin.string.TodoSave}
|
||||
on:changeContent
|
||||
>
|
||||
<Grid column={1} rowGap={1.75}>
|
||||
<EditBox
|
||||
label={plugin.string.TodoDescription}
|
||||
bind:value={name}
|
||||
icon={task.icon.Task}
|
||||
placeholder={plugin.string.TodoDescriptionPlaceholder}
|
||||
autoFocus
|
||||
/>
|
||||
<DatePicker title={plugin.string.TodoDueDate} bind:value={dueTo} />
|
||||
</Grid>
|
||||
</Card>
|
||||
@@ -1,46 +0,0 @@
|
||||
<!--
|
||||
// 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 type { TodoItem } from '@hcengineering/task'
|
||||
import { closeTooltip, Icon, showPopup } from '@hcengineering/ui'
|
||||
import task from '../../plugin'
|
||||
import EditTodo from './EditTodo.svelte'
|
||||
|
||||
export let value: TodoItem
|
||||
export let inline: boolean = false
|
||||
|
||||
function show (elm: EventTarget | null) {
|
||||
closeTooltip()
|
||||
showPopup(EditTodo, { item: value }, elm as HTMLElement)
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if value}
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
||||
<div
|
||||
class="flex-presenter"
|
||||
class:inline-presenter={inline}
|
||||
on:click={(ev) => {
|
||||
show(ev.target)
|
||||
}}
|
||||
>
|
||||
<div class="icon">
|
||||
<Icon icon={task.icon.Task} size={'small'} />
|
||||
</div>
|
||||
<span class="label">{value.name}</span>
|
||||
</div>
|
||||
{/if}
|
||||
@@ -1,40 +0,0 @@
|
||||
<!--
|
||||
// Copyright © 2020 Anticrm Platform Contributors.
|
||||
//
|
||||
// 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 type { WithLookup } from '@hcengineering/core'
|
||||
import type { Task, TodoItem } from '@hcengineering/task'
|
||||
import task from '@hcengineering/task'
|
||||
import { Table } from '@hcengineering/view-resources'
|
||||
import plugin from '../../plugin'
|
||||
|
||||
export let value: WithLookup<Task>
|
||||
|
||||
$: todos = (value.$lookup?.todoItems as TodoItem[]) ?? []
|
||||
</script>
|
||||
|
||||
<div class="flex-col">
|
||||
{#if todos.length > 0}
|
||||
<Table
|
||||
_class={task.class.TodoItem}
|
||||
config={[
|
||||
{ key: 'name', label: plugin.string.TodoName },
|
||||
'dueTo',
|
||||
{ key: 'done', presenter: plugin.component.TodoStatePresenter, label: plugin.string.TodoState }
|
||||
]}
|
||||
options={{}}
|
||||
query={{ attachedTo: value._id }}
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
@@ -1,44 +0,0 @@
|
||||
<!--
|
||||
// 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 { getPlatformColor, Label, themeStore } from '@hcengineering/ui'
|
||||
import task from '../../plugin'
|
||||
export let value: boolean
|
||||
|
||||
$: color = value ? getPlatformColor(2, $themeStore.dark) : getPlatformColor(16, $themeStore.dark)
|
||||
$: text = value ? task.string.DoneState : task.string.UndoneState
|
||||
</script>
|
||||
|
||||
{#if value !== undefined}
|
||||
<div class="overflow-label state-container" style="background-color: {color};">
|
||||
<Label label={text} />
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<style lang="scss">
|
||||
.state-container {
|
||||
padding: 0.25rem 0.5rem;
|
||||
width: 6.25rem;
|
||||
max-width: 6.25rem;
|
||||
text-transform: uppercase;
|
||||
text-align: center;
|
||||
letter-spacing: 0.5px;
|
||||
font-size: 0.625rem;
|
||||
color: #fff;
|
||||
border: 1px solid rgba(0, 0, 0, 0.1);
|
||||
border-radius: 0.25rem;
|
||||
}
|
||||
</style>
|
||||
@@ -1,93 +0,0 @@
|
||||
<!--
|
||||
// Copyright © 2020 Anticrm Platform Contributors.
|
||||
//
|
||||
// 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 type { Ref, Space, Doc, Class } from '@hcengineering/core'
|
||||
import type { TodoItem } from '@hcengineering/task'
|
||||
import { createQuery } from '@hcengineering/presentation'
|
||||
import { Button, IconAdd, showPopup, Label, resizeObserver, Scroller } from '@hcengineering/ui'
|
||||
import CreateTodo from './CreateTodo.svelte'
|
||||
import { Table } from '@hcengineering/view-resources'
|
||||
|
||||
import task from '@hcengineering/task'
|
||||
import plugin from '../../plugin'
|
||||
|
||||
export let objectId: Ref<Doc>
|
||||
export let space: Ref<Space>
|
||||
export let _class: Ref<Class<Doc>>
|
||||
|
||||
let todos: TodoItem[] = []
|
||||
|
||||
const query = createQuery()
|
||||
$: query.query(task.class.TodoItem, { attachedTo: objectId }, (result) => {
|
||||
todos = result
|
||||
})
|
||||
|
||||
const createApp = (ev: MouseEvent): void => {
|
||||
showPopup(CreateTodo, { objectId, _class, space }, ev.target as HTMLElement)
|
||||
}
|
||||
let wSection: number
|
||||
</script>
|
||||
|
||||
<div class="antiSection" use:resizeObserver={(element) => (wSection = element.clientWidth)}>
|
||||
<div class="antiSection-header">
|
||||
<span class="antiSection-header__title">
|
||||
<Label label={plugin.string.Todos} />
|
||||
</span>
|
||||
<Button icon={IconAdd} kind={'ghost'} on:click={createApp} />
|
||||
</div>
|
||||
{#if todos.length > 0}
|
||||
{#if wSection < 640}
|
||||
<Scroller horizontal>
|
||||
<Table
|
||||
_class={task.class.TodoItem}
|
||||
config={[
|
||||
{ key: '', label: plugin.string.TodoName },
|
||||
'dueTo',
|
||||
{ key: 'done', presenter: plugin.component.TodoStatePresenter, label: plugin.string.TodoState }
|
||||
]}
|
||||
options={{
|
||||
sort: {
|
||||
rank: 1
|
||||
}
|
||||
}}
|
||||
query={{ attachedTo: objectId }}
|
||||
/>
|
||||
</Scroller>
|
||||
{:else}
|
||||
<Table
|
||||
_class={task.class.TodoItem}
|
||||
config={[
|
||||
{ key: '', label: plugin.string.TodoName },
|
||||
'dueTo',
|
||||
{ key: 'done', presenter: plugin.component.TodoStatePresenter, label: plugin.string.TodoState }
|
||||
]}
|
||||
options={{
|
||||
sort: {
|
||||
rank: 1
|
||||
}
|
||||
}}
|
||||
query={{ attachedTo: objectId }}
|
||||
/>
|
||||
{/if}
|
||||
{:else}
|
||||
<div class="antiSection-empty solid flex-col-center mt-3">
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
||||
<span class="text-sm over-underline" on:click={createApp}>
|
||||
<Label label={plugin.string.NoTodoItems} />
|
||||
</span>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
Reference in New Issue
Block a user