mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-13 05:07:43 +02:00
Keyboard popup (#1625)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
import tags, { selectedTagElements, TagCategory, TagElement } from '@anticrm/tags'
|
||||
import { DoneState, Task } from '@anticrm/task'
|
||||
import { Component, Icon, Label, Scroller, SearchEdit } from '@anticrm/ui'
|
||||
import { Table } from '@anticrm/view-resources'
|
||||
import { TableBrowser } from '@anticrm/view-resources'
|
||||
import task from '../plugin'
|
||||
|
||||
export let _class: Ref<Class<Task>> = task.class.Task
|
||||
@@ -100,7 +100,7 @@
|
||||
/>
|
||||
|
||||
<Scroller tableFade>
|
||||
<Table
|
||||
<TableBrowser
|
||||
{_class}
|
||||
config={[
|
||||
'',
|
||||
@@ -125,6 +125,5 @@
|
||||
options={taskOptions}
|
||||
query={resultQuery}
|
||||
showNotification
|
||||
highlightRows
|
||||
/>
|
||||
</Scroller>
|
||||
|
||||
@@ -1,136 +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 contact, { Employee } from '@anticrm/contact'
|
||||
import { AttachedData, Data, Doc, Ref, SortingOrder, Space } from '@anticrm/core'
|
||||
import { generateId } from '@anticrm/core'
|
||||
import { OK, Status } from '@anticrm/platform'
|
||||
import { Card, getClient, UserBox } from '@anticrm/presentation'
|
||||
import task, { calcRank, Issue, State } from '@anticrm/task'
|
||||
import { EditBox, Grid, Status as StatusControl } from '@anticrm/ui'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import plugin from '../plugin'
|
||||
|
||||
export let space: Ref<Space>
|
||||
export let parent: Pick<Doc, '_id' | '_class'> | undefined
|
||||
|
||||
let _space = space
|
||||
|
||||
$: _space = space
|
||||
const status: Status = OK
|
||||
|
||||
let assignee: Ref<Employee> | null = null
|
||||
|
||||
const object: Data<Issue> = {
|
||||
name: '',
|
||||
description: '',
|
||||
assignee: null,
|
||||
number: 0,
|
||||
attachedTo: task.global.Task,
|
||||
attachedToClass: task.class.Issue,
|
||||
collection: 'tasks',
|
||||
state: '' as Ref<State>,
|
||||
doneState: null,
|
||||
rank: ''
|
||||
}
|
||||
|
||||
const dispatch = createEventDispatcher()
|
||||
const client = getClient()
|
||||
const taskId: Ref<Issue> = generateId()
|
||||
|
||||
export function canClose (): boolean {
|
||||
return object.name !== ''
|
||||
}
|
||||
|
||||
async function createTask () {
|
||||
const state = await client.findOne(task.class.State, { space: _space })
|
||||
if (state === undefined) {
|
||||
throw new Error('create task: state not found')
|
||||
}
|
||||
|
||||
const sequence = await client.findOne(task.class.Sequence, { attachedTo: task.class.Issue })
|
||||
if (sequence === undefined) {
|
||||
throw new Error('sequence object not found')
|
||||
}
|
||||
|
||||
const lastOne = await client.findOne(
|
||||
task.class.Task,
|
||||
{ state: state._id },
|
||||
{ sort: { rank: SortingOrder.Descending } }
|
||||
)
|
||||
const incResult = await client.updateDoc(
|
||||
task.class.Sequence,
|
||||
task.space.Sequence,
|
||||
sequence._id,
|
||||
{
|
||||
$inc: { sequence: 1 }
|
||||
},
|
||||
true
|
||||
)
|
||||
|
||||
const value: AttachedData<Issue> = {
|
||||
name: object.name,
|
||||
description: object.description,
|
||||
assignee,
|
||||
number: (incResult as any).object.sequence,
|
||||
doneState: null,
|
||||
state: state._id,
|
||||
rank: calcRank(lastOne, undefined)
|
||||
}
|
||||
|
||||
await client.addCollection(
|
||||
task.class.Issue,
|
||||
_space,
|
||||
parent?._id ?? task.global.Task,
|
||||
parent?._class ?? task.class.Issue,
|
||||
'tasks',
|
||||
value,
|
||||
taskId
|
||||
)
|
||||
}
|
||||
</script>
|
||||
|
||||
<Card
|
||||
label={plugin.string.CreateTask}
|
||||
okAction={createTask}
|
||||
canSave={object.name.length > 0 && _space != null}
|
||||
spaceClass={task.class.Project}
|
||||
spaceLabel={plugin.string.ProjectName}
|
||||
spacePlaceholder={plugin.string.SelectProject}
|
||||
bind:space={_space}
|
||||
on:close={() => {
|
||||
dispatch('close')
|
||||
}}
|
||||
>
|
||||
<StatusControl slot="error" {status} />
|
||||
<Grid column={1} rowGap={1.5}>
|
||||
<EditBox
|
||||
label={plugin.string.TaskName}
|
||||
bind:value={object.name}
|
||||
icon={task.icon.Task}
|
||||
placeholder={plugin.string.TaskNamePlaceholder}
|
||||
maxWidth={'16rem'}
|
||||
focus
|
||||
/>
|
||||
<UserBox
|
||||
_class={contact.class.Employee}
|
||||
label={plugin.string.TaskAssignee}
|
||||
placeholder={plugin.string.AssignThisTask}
|
||||
bind:value={assignee}
|
||||
allowDeselect
|
||||
titleDeselect={plugin.string.TaskUnAssign}
|
||||
/>
|
||||
</Grid>
|
||||
</Card>
|
||||
@@ -72,7 +72,6 @@
|
||||
/* eslint-disable no-undef */
|
||||
|
||||
let kanbanUI: KanbanUI
|
||||
let objects: Doc[] = []
|
||||
const listProvider = new ListSelectionProvider((offset: 1 | -1 | 0, of?: Doc, dir?: SelectDirection) => {
|
||||
kanbanUI.select(offset, of, dir)
|
||||
})
|
||||
@@ -114,7 +113,6 @@
|
||||
rankFieldName={'rank'}
|
||||
on:content={(evt) => {
|
||||
listProvider.update(evt.detail)
|
||||
objects = evt.detail
|
||||
}}
|
||||
on:obj-focus={(evt) => {
|
||||
listProvider.updateFocus(evt.detail)
|
||||
|
||||
Reference in New Issue
Block a user