template name as subject (#2892)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2023-04-05 15:53:14 +06:00 committed by GitHub
parent febbb0cd08
commit 95568ef948
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 27 additions and 3 deletions

View File

@ -165,6 +165,9 @@
const editorHandler: TextEditorHandler = {
insertText: (text) => {
textEditor.insertText(text)
},
insertTemplate: (name, text) => {
textEditor.insertText(text)
}
}
function handleAction (a: RefAction, evt?: Event): void {

View File

@ -217,6 +217,10 @@
const editorHandler: TextEditorHandler = {
insertText: (text) => {
textEditor.insertText(text)
},
insertTemplate: (name, text) => {
textEditor.insertText(text)
dispatch('template', name)
}
}
function handleAction (a: RefAction, evt?: Event): void {

View File

@ -7,6 +7,7 @@ import type { AnySvelteComponent } from '@hcengineering/ui'
*/
export interface TextEditorHandler {
insertText: (html: string) => void
insertTemplate: (name: string, html: string) => void
}
/**
* @public

View File

@ -148,6 +148,14 @@
},
(res) => (attachments = res)
)
function onTemplate (e: CustomEvent<string>): void {
if (e.detail !== undefined) {
if (obj.subject.trim() === '') {
obj.subject = e.detail
}
}
}
</script>
<input
@ -215,7 +223,7 @@
</div>
{/if}
<div class="input mt-4 clear-mins">
<StyledTextEditor full bind:content={obj.content} maxHeight="panel" />
<StyledTextEditor full bind:content={obj.content} maxHeight="panel" on:template={onTemplate} />
</div>
</div>
</Scroller>

View File

@ -212,6 +212,14 @@
integrations = res.filter((p) => p.createdBy === me || p.shared?.includes(me))
selectedIntegration = integrations.find((p) => p.createdBy === me) ?? integrations[0]
})
function onTemplate (e: CustomEvent<string>): void {
if (e.detail !== undefined) {
if (subject.trim() === '') {
subject = e.detail
}
}
}
</script>
<Panel
@ -325,7 +333,7 @@
</div>
{/if}
<div class="input mt-4 clear-mins">
<StyledTextEditor full bind:content />
<StyledTextEditor full bind:content on:template={onTemplate} />
</div>
</div>
</Scroller>

View File

@ -49,7 +49,7 @@
const provider = getTemplateDataProvider()
async function dispatchItem (item: MessageTemplate): Promise<void> {
const message = await provider.fillTemplate(item.message)
editor.insertText(message)
editor.insertTemplate(item.title, message)
closePopup()
}