Signed-off-by: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com>
This commit is contained in:
Denis Bykhov
2022-01-18 11:21:32 +01:00
committed by GitHub
parent 3d21b2de1e
commit b56f3bba7c
37 changed files with 576 additions and 650 deletions
@@ -1,120 +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 core, { Class, Doc, Ref } from '@anticrm/core'
import { Panel } from '@anticrm/panel'
import { createQuery, getAttributePresenterClass, getClient } from '@anticrm/presentation'
import type { Task } from '@anticrm/task'
import { AnyComponent, Component } from '@anticrm/ui'
import view from '@anticrm/view'
import { createEventDispatcher } from 'svelte'
import task from '../plugin'
import TaskHeader from './TaskHeader.svelte'
import { Asset } from '@anticrm/platform'
export let _id: Ref<Task>
let object: Task
const client = getClient()
const hierarchy = client.getHierarchy()
const docKeys: Set<string> = new Set<string>(hierarchy.getAllAttributes(core.class.AttachedDoc).keys())
let keys: string[] = []
let collectionKeys: string[] = []
const query = createQuery()
$: _id &&
query.query(task.class.Task, { _id }, (result) => {
object = result[0]
})
const dispatch = createEventDispatcher()
function getFiltredKeys (ignoreKeys: string[]): string[] {
let keys = [...hierarchy.getAllAttributes(object._class).entries()]
.filter(([, value]) => value.hidden !== true)
.map(([key]) => key)
keys = keys.filter((k) => !docKeys.has(k))
keys = keys.filter((k) => !ignoreKeys.includes(k))
return keys
}
function getKeys (ignoreKeys: string[]): void {
const filtredKeys = getFiltredKeys(ignoreKeys)
keys = collectionsFilter(filtredKeys, false)
collectionKeys = collectionsFilter(filtredKeys, true)
}
function collectionsFilter (keys: string[], get: boolean): string[] {
const result: string[] = []
for (const key of keys) {
if (isCollectionAttr(key) === get) result.push(key)
}
return result
}
function isCollectionAttr (key: string): boolean {
const attribute = hierarchy.getAttribute(object._class, key)
return hierarchy.isDerived(attribute.type._class, core.class.Collection)
}
async function getEditor (_class: Ref<Class<Doc>>): Promise<AnyComponent> {
const clazz = hierarchy.getClass(_class)
const editorMixin = hierarchy.as(clazz, view.mixin.ObjectEditor)
if (editorMixin?.editor == null && clazz.extends != null) return getEditor(clazz.extends)
return editorMixin.editor
}
async function getCollectionEditor (key: string): Promise<AnyComponent> {
const attribute = hierarchy.getAttribute(object._class, key)
const attrClass = getAttributePresenterClass(attribute)
const clazz = client.getHierarchy().getClass(attrClass)
const editorMixin = client.getHierarchy().as(clazz, view.mixin.AttributeEditor)
return editorMixin.editor
}
$: icon = object && (hierarchy.getClass(object._class).icon as Asset)
$: title = object && hierarchy.getClass(object._class).label
</script>
{#if object !== undefined}
<Panel
{icon}
{title}
{object}
on:close={() => {
dispatch('close')
}}
>
<TaskHeader {object} {keys} slot="subtitle" />
{#await getEditor(object._class) then is}
<Component
{is}
props={{ object }}
on:open={(ev) => {
getKeys(ev.detail.ignoreKeys)
}}
/>
{/await}
{#each collectionKeys as collection}
<div class="mt-14">
{#await getCollectionEditor(collection) then is}
<Component {is} props={{ objectId: object._id, _class: object._class, space: object.space }} />
{/await}
</div>
{/each}
</Panel>
{/if}
@@ -16,12 +16,12 @@
<script lang="ts">
import contact from '@anticrm/contact'
import core, { Class, Doc, Ref, RefTo } from '@anticrm/core'
import { AttributeBarEditor, AttributesBar, getClient, UserBox } from '@anticrm/presentation'
import { AttributeBarEditor, AttributesBar, getClient, KeyedAttribute, UserBox } from '@anticrm/presentation'
import { Task } from '@anticrm/task'
import task from '../plugin'
export let object: Task
export let keys: string[]
export let keys: KeyedAttribute[]
const client = getClient()
const hierarchy = client.getHierarchy()
@@ -48,7 +48,7 @@
return contact.class.Employee
}
$: filtredKeys = keys.filter((p) => p !== 'state' && p !== 'assignee' && p !== 'doneState') // todo
$: filtredKeys = keys.filter((p) => p.key !== 'state' && p.key !== 'assignee' && p.key !== 'doneState') // todo
</script>
<div class="flex-between header">
@@ -16,9 +16,9 @@
<script lang="ts">
import type { Issue } from '@anticrm/task'
import { closeTooltip, Icon, showPopup } from '@anticrm/ui'
import EditTask from './EditTask.svelte'
import { getClient } from '@anticrm/presentation'
import task from '../plugin'
import { EditDoc } from '@anticrm/view-resources'
export let value: Issue
@@ -27,7 +27,7 @@
function show () {
closeTooltip()
showPopup(EditTask, { _id: value._id }, 'full')
showPopup(EditDoc, { _id: value._id, _class: value._class }, 'full')
}
</script>
@@ -30,7 +30,6 @@
export let _class: Ref<Class<Item>>
export let space: Ref<SpaceWithStates>
export let open: AnyComponent
export let search: string
export let options: FindOptions<Item> | undefined
export let config: string[]
@@ -13,31 +13,30 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-->
<script lang="ts">
import type { State } from '@anticrm/task'
import { getPlatformColor } from '@anticrm/ui'
export let value: State
</script>
{#if value}
<div class="overflow-label state-container" style="background-color: {value.color}">
<div class="overflow-label state-container" style="background-color: {getPlatformColor(value.color)}">
{value.title}
</div>
{/if}
<style lang="scss">
.state-container {
padding: .25rem .5rem;
padding: 0.25rem 0.5rem;
width: 6.25rem;
max-width: 6.25rem;
text-transform: uppercase;
text-align: center;
letter-spacing: .5px;
font-size: .625rem;
letter-spacing: 0.5px;
font-size: 0.625rem;
color: #fff;
border: 1px solid rgba(0, 0, 0, .1);
border-radius: .25rem;
border: 1px solid rgba(0, 0, 0, 0.1);
border-radius: 0.25rem;
}
</style>
@@ -17,6 +17,7 @@
import { Ref, SortingOrder } from '@anticrm/core'
import { createQuery } from '@anticrm/presentation'
import task, { SpaceWithStates, State } from '@anticrm/task'
import { getPlatformColor } from '@anticrm/ui'
import { createEventDispatcher } from 'svelte'
export let space: Ref<SpaceWithStates>
@@ -45,7 +46,7 @@
dispatch('close', state)
}}
>
<div class="color" style="background-color: {state.color}" />
<div class="color" style="background-color: {getPlatformColor(state.color)}" />
{state.title}
</div>
{/each}