Fix fill defaults (#2832)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2023-03-27 12:12:01 +06:00 committed by GitHub
parent 9c56815002
commit db5cb7fba2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 15 deletions

View File

@ -29,6 +29,7 @@
export let items: DropdownTextItem[]
export let multiselect = false
export let selected: DropdownTextItem['id'] | DropdownTextItem['id'][] | undefined = multiselect ? [] : undefined
export let allowDeselect: boolean = false
export let kind: ButtonKind = 'no-border'
export let size: ButtonSize = 'small'
@ -70,8 +71,13 @@
container,
(result) => {
if (result) {
selected = result
dispatch('selected', result)
if (allowDeselect && selected === result) {
selected = undefined
dispatch('selected', undefined)
} else {
selected = result
dispatch('selected', result)
}
}
opened = false
mgr?.setFocusPos(focusIndex)

View File

@ -82,20 +82,20 @@
return name === '' && templateId !== undefined
}
let changed = false
const client = getClient()
const hierarchy = client.getHierarchy()
const templateQ = createQuery()
fillDefaults(hierarchy, vacancyData, recruit.class.Vacancy)
$: templateQ.query(task.class.KanbanTemplate, { _id: templateId }, (result) => {
const { _class, _id, description, ...templateData } = result[0]
vacancyData = { ...(templateData as unknown as Data<VacancyClass>), fullDescription: description }
if (appliedTemplateId !== templateId) {
fullDescription = description ?? ''
appliedTemplateId = templateId
}
})
$: templateId &&
templateQ.query(task.class.KanbanTemplate, { _id: templateId }, (result) => {
const { _class, _id, description, ...templateData } = result[0]
vacancyData = { ...(templateData as unknown as Data<VacancyClass>), fullDescription: description }
if (appliedTemplateId !== templateId) {
fullDescription = description ?? ''
appliedTemplateId = templateId
}
fillDefaults(hierarchy, vacancyData, recruit.class.Vacancy)
})
const issueTemplatesQ = createQuery()
$: issueTemplatesQ.query(tracker.class.IssueTemplate, { 'relations._id': templateId }, async (result) => {
@ -267,9 +267,6 @@
bind:content={fullDescription}
placeholder={recruit.string.FullDescription}
emphasized
on:changeContent={() => {
changed = true
}}
/>
{/key}

View File

@ -85,6 +85,7 @@
label={setting.string.SelectAValue}
kind={'no-border'}
size={'small'}
allowDeselect
{type}
value={defaultValue ?? ''}
onChange={(e) => {

View File

@ -243,6 +243,7 @@
appliedTemplateId = templateId
const tagElements = await client.findAll(tags.class.TagElement, { _id: { $in: labels } })
object.labels = tagElements.map(tagAsRef)
fillDefaults(hierarchy, object, tracker.class.Issue)
}
$: template && updateTemplate(template)

View File

@ -25,6 +25,7 @@
export let onChange: (value: string) => void
export let kind: ButtonKind = 'link'
export let size: ButtonSize = 'large'
export let allowDeselect: boolean = false
let items: DropdownTextItem[] = []
@ -54,6 +55,7 @@
{size}
{kind}
width={'100%'}
{allowDeselect}
autoSelect={false}
on:selected={(e) => {
onChange(e.detail)