TSK-1148: Mixin button for Vacancy and NPE fixes (#2965)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev 2023-04-12 23:10:03 +07:00 committed by GitHub
parent 9224a6c8e0
commit b88e878a42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 34 additions and 6 deletions

View File

@ -164,6 +164,9 @@ export async function createClient (
let lastTx: number
function txHandler (tx: Tx): void {
if (tx === null) {
return
}
if (client === null) {
txBuffer?.push(tx)
} else {

View File

@ -65,6 +65,9 @@
})
function computeSize (t: HTMLInputElement | EventTarget | null) {
if (t == null) {
return
}
const target = t as HTMLInputElement
const value = target.value
text.innerHTML = (value === '' ? phTraslate : value)

View File

@ -21,7 +21,7 @@
import { Vacancy } from '@hcengineering/recruit'
import { FullDescriptionBox } from '@hcengineering/text-editor'
import tracker from '@hcengineering/tracker'
import { Button, Component, EditBox, Grid, IconMoreH, showPopup } from '@hcengineering/ui'
import { Button, Component, EditBox, Grid, IconMixin, IconMoreH, showPopup } from '@hcengineering/ui'
import { ContextMenu, DocAttributeBar } from '@hcengineering/view-resources'
import { createEventDispatcher } from 'svelte'
import recruit from '../plugin'
@ -34,6 +34,8 @@
let rawName: string = ''
let rawDesc: string = ''
let showAllMixins = false
const dispatch = createEventDispatcher()
const client = getClient()
@ -65,16 +67,20 @@
const hierarchy = client.getHierarchy()
let mixins: Mixin<Doc>[] = []
function getMixins (object: Doc): void {
function getMixins (object: Doc, showAllMixins: boolean): void {
if (object === undefined) return
const descendants = hierarchy.getDescendants(core.class.Doc).map((p) => hierarchy.getClass(p))
mixins = descendants.filter(
(m) => m.kind === ClassifierKind.MIXIN && !ignoreMixins.has(m._id) && hierarchy.hasMixin(object, m._id)
(m) =>
m.kind === ClassifierKind.MIXIN &&
!ignoreMixins.has(m._id) &&
(hierarchy.hasMixin(object, m._id) ||
(showAllMixins && hierarchy.isDerived(object._class, hierarchy.getBaseClass(m._id))))
)
}
$: getMixins(object)
$: getMixins(object, showAllMixins)
</script>
{#if object}
@ -101,6 +107,20 @@
{/if}
</svelte:fragment>
<svelte:fragment slot="attributes" let:direction={dir}>
<div class="flex flex-reverse flex-no-shrink clear-mins">
<Button
kind={'transparent'}
shape={'round'}
selected={showAllMixins}
on:click={() => {
showAllMixins = !showAllMixins
}}
>
<svelte:fragment slot="content">
<IconMixin size={'small'} />
</svelte:fragment>
</Button>
</div>
{#if dir === 'column'}
<DocAttributeBar
{object}

View File

@ -62,7 +62,9 @@
async function update (viewlets: WithLookup<Viewlet>[], active: Ref<Viewlet> | null): Promise<void> {
viewlet = viewlets.find((viewlet) => viewlet._id === active) ?? viewlets[0]
setActiveViewletId(viewlet._id)
if (viewlet !== undefined) {
setActiveViewletId(viewlet._id)
}
}
$: if (!label && title) {

View File

@ -25,7 +25,7 @@
const listProvider = new ListSelectionProvider((offset: 1 | -1 | 0, of?: Doc, dir?: SelectDirection) => {
if (dir === 'vertical') {
// Select next
list.select(offset, of)
list?.select(offset, of)
}
})