Skip to content

Commit

Permalink
TSK-435: Fix create issue edit focus lost. (#2396)
Browse files Browse the repository at this point in the history
Signed-off-by: Andrey Sobolev <[email protected]>
  • Loading branch information
haiodo authored Nov 24, 2022
1 parent 34c3d07 commit 46b70a2
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 60 deletions.
1 change: 1 addition & 0 deletions packages/platform/src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ async function loadTranslationsForComponent (plugin: Plugin, locale: string): Pr
try {
return (await loader(locale)) as Record<string, IntlString> | Status
} catch (err) {
console.error(err)
const status = unknownError(err)
await setPlatformStatus(status)
return status
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
.ProseMirror {
flex-grow: 1;
overflow: auto;
min-height: 3rem;
min-height: inherit !important;
max-height: inherit !important;
outline: none;
line-height: 150%;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@
<style lang="scss" global>
.ProseMirror {
flex-grow: 1;
min-height: 3rem;
min-height: inherit !important;
max-height: inherit !important;
outline: none;
line-height: 150%;
Expand Down
2 changes: 1 addition & 1 deletion packages/text-editor/src/components/TextEditor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@
<style lang="scss" global>
.ProseMirror {
overflow-y: auto;
min-height: 3rem;
min-height: inherit !important;
max-height: inherit !important;
outline: none;
line-height: 150%;
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/src/components/notifications/Notification.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { NotificationPosition } from './NotificationPosition'
import { NotificationSeverity } from './NotificationSeverity'
import { AnyComponent } from '../../types'
import { AnyComponent, AnySvelteComponent } from '../../types'

export interface Notification {
id: string
title: string
component: AnyComponent
component: AnyComponent | AnySvelteComponent
subTitle?: string
subTitlePostfix?: string
position: NotificationPosition
Expand Down
51 changes: 30 additions & 21 deletions plugins/tracker-resources/src/components/CreateIssue.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@
let labels: TagReference[] = draft?.labels || []
let objectId: Ref<Issue> = draft?.issueId || generateId()
function toIssue (initials: AttachedData<Issue>, draft: IssueDraft | null): AttachedData<Issue> {
if (draft == null) {
return { ...initials }
}
const { labels, subIssues, ...issue } = draft
return { ...initials, ...issue }
}
let object: AttachedData<Issue> = originalIssue
? {
...originalIssue,
Expand All @@ -105,7 +113,8 @@
reports: 0,
childInfo: []
}
: {
: toIssue(
{
title: '',
description: '',
assignee,
Expand All @@ -122,9 +131,10 @@
reportedTime: 0,
estimation: 0,
reports: 0,
childInfo: [],
...(draft || {})
}
childInfo: []
},
draft
)
function resetObject (): void {
templateId = undefined
Expand Down Expand Up @@ -260,7 +270,7 @@
return
}
parentIssue = await client.findOne(tracker.class.Issue, { _id: draft.parentIssue })
parentIssue = await client.findOne(tracker.class.Issue, { _id: draft.parentIssue as Ref<Issue> })
}
$: originalIssue && setPropsFromOriginalIssue()
Expand Down Expand Up @@ -288,7 +298,7 @@
}
async function isDraftEmpty (draft: Data<IssueDraft>): Promise<boolean> {
const emptyDraft = {
const emptyDraft: Partial<IssueDraft> = {
assignee: null,
description: '',
dueDate: null,
Expand All @@ -304,7 +314,7 @@
}
for (const key of Object.keys(emptyDraft)) {
if (!deepEqual(emptyDraft[key], draft[key])) {
if (!deepEqual((emptyDraft as any)[key], (draft as any)[key])) {
return false
}
}
Expand Down Expand Up @@ -509,6 +519,7 @@
}
const notification: Notification = {
id: generateId(),
title: tracker.string.IssueCreated,
subTitle: getTitle(object.title),
severity: NotificationSeverity.Success,
Expand Down Expand Up @@ -695,20 +706,18 @@
<ParentIssue issue={parentIssue} on:close={clearParentIssue} />
{/if}
<EditBox bind:value={object.title} placeholder={tracker.string.IssueTitlePlaceholder} kind={'large-style'} focus />
{#key object.description}
<AttachmentStyledBox
bind:this={descriptionBox}
{objectId}
_class={tracker.class.Issue}
space={_space}
alwaysEdit
showButtons={false}
maxHeight={'20vh'}
bind:content={object.description}
placeholder={tracker.string.IssueDescriptionPlaceholder}
on:changeSize={() => dispatch('changeContent')}
/>
{/key}
<AttachmentStyledBox
bind:this={descriptionBox}
{objectId}
_class={tracker.class.Issue}
space={_space}
alwaysEdit
showButtons={false}
maxHeight={'20vh'}
bind:content={object.description}
placeholder={tracker.string.IssueDescriptionPlaceholder}
on:changeSize={() => dispatch('changeContent')}
/>
<IssueTemplateChilds
bind:children={subIssues}
sprint={object.sprint}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import IssuePresenter from './IssuePresenter.svelte'
import tracker from '../../plugin'
export let notification: Notification = {}
export let notification: Notification
export let onRemove: () => void
const issueQuery = createQuery()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
function resetToDefaults () {
newIssue = getIssueDefaults()
labels = []
focusIssueTitle?.()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,21 +212,21 @@
kind="large-style"
/>
<div class="flex-between mt-6">
{#key description}
<div class="flex-grow">
<AttachmentStyledBox
bind:this={descriptionBox}
objectId={_id}
_class={tracker.class.Issue}
space={template.space}
alwaysEdit
showButtons
maxHeight={'card'}
bind:content={description}
placeholder={tracker.string.IssueDescriptionPlaceholder}
/>
</div>
{/key}
<div class="flex-grow">
<AttachmentStyledBox
bind:this={descriptionBox}
objectId={_id}
_class={tracker.class.Issue}
space={template.space}
alwaysEdit
showButtons
maxHeight={'card'}
bind:content={description}
placeholder={tracker.string.IssueDescriptionPlaceholder}
/>
</div>

<!-- svelte-ignore a11y-click-events-have-key-events -->
<div
class="tool"
on:click={() => {
Expand All @@ -242,6 +242,7 @@
<span class="title select-text">{title}</span>
<div class="mt-6 description-preview select-text">
{#if isDescriptionEmpty}
<!-- svelte-ignore a11y-click-events-have-key-events -->
<div class="placeholder" on:click={edit}>
<Label label={tracker.string.IssueDescriptionPlaceholder} />
</div>
Expand Down
15 changes: 2 additions & 13 deletions plugins/tracker/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,7 @@
//

import { Employee } from '@hcengineering/contact'
import type {
AttachedDoc,
Class,
Doc,
Markup,
Obj,
Ref,
RelatedDocument,
Space,
Timestamp,
Type
} from '@hcengineering/core'
import type { AttachedDoc, Class, Doc, Markup, Ref, RelatedDocument, Space, Timestamp, Type } from '@hcengineering/core'
import type { Asset, IntlString, Plugin, Resource } from '@hcengineering/platform'
import { plugin } from '@hcengineering/platform'
import type { TagCategory, TagElement } from '@hcengineering/tags'
Expand Down Expand Up @@ -197,7 +186,7 @@ export interface Issue extends AttachedDoc {
/**
* @public
*/
export interface IssueDraft extends Obj {
export interface IssueDraft extends Doc {
issueId: Ref<Issue>
title: string
description: Markup
Expand Down
8 changes: 3 additions & 5 deletions pods/account/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
//

import { AccountMethod, ACCOUNT_DB } from '@hcengineering/account'
import platform, { Request, Response, serialize, setMetadata, Severity, Status } from '@hcengineering/platform'
import platform, { Response, serialize, setMetadata, Severity, Status } from '@hcengineering/platform'
import serverToken from '@hcengineering/server-token'
import toolPlugin from '@hcengineering/server-tool'
import cors from '@koa/cors'
import { IncomingHttpHeaders } from 'http'
import Koa from 'koa'
import bodyParser from 'koa-bodyparser'
import Router from 'koa-router'
import { Db, MongoClient } from 'mongodb'
import { MongoClient } from 'mongodb'

/**
* @public
Expand Down Expand Up @@ -71,9 +71,7 @@ export function serveAccount (methods: Record<string, AccountMethod>, productId
const token = extractToken(ctx.request.headers)

const request = ctx.request.body as any
const method = (
methods as { [key: string]: (db: Db, productId: string, request: Request<any>, token?: string) => Response<any> }
)[request.method]
const method = (methods as { [key: string]: AccountMethod })[request.method]
if (method === undefined) {
const response: Response<void> = {
id: request.id,
Expand Down

0 comments on commit 46b70a2

Please sign in to comment.