diff --git a/models/contact/package.json b/models/contact/package.json index 9d03eb30d5..54f76d5b6f 100644 --- a/models/contact/package.json +++ b/models/contact/package.json @@ -39,6 +39,7 @@ "@hcengineering/contact": "^0.6.11", "@hcengineering/contact-resources": "^0.6.0", "@hcengineering/view": "^0.6.2", - "cross-fetch": "^3.1.5" + "cross-fetch": "^3.1.5", + "@hcengineering/templates": "^0.6.0" } } diff --git a/models/contact/src/index.ts b/models/contact/src/index.ts index 0d184be0ea..d80c92bdcd 100644 --- a/models/contact/src/index.ts +++ b/models/contact/src/index.ts @@ -55,6 +55,7 @@ import workbench from '@hcengineering/model-workbench' import type { Asset, IntlString, Resource } from '@hcengineering/platform' import setting from '@hcengineering/setting' import { AnyComponent } from '@hcengineering/ui' +import templates from '@hcengineering/templates' import contact from './plugin' export const DOMAIN_CONTACT = 'contact' as Domain @@ -576,6 +577,57 @@ export function createModel (builder: Builder): void { }, contact.filter.FilterChannelNin ) + + builder.createDoc( + templates.class.TemplateFieldCategory, + core.space.Model, + { + label: contact.string.CurrentEmployee + }, + contact.templateFieldCategory.CurrentEmployee + ) + + builder.createDoc( + templates.class.TemplateField, + core.space.Model, + { + label: contact.string.Name, + category: contact.templateFieldCategory.CurrentEmployee, + func: contact.function.GetCurrentEmployeeName + }, + contact.templateField.CurrentEmployeeName + ) + + builder.createDoc( + templates.class.TemplateField, + core.space.Model, + { + label: contact.string.Email, + category: contact.templateFieldCategory.CurrentEmployee, + func: contact.function.GetCurrentEmployeeEmail + }, + contact.templateField.CurrentEmployeeEmail + ) + + builder.createDoc( + templates.class.TemplateFieldCategory, + core.space.Model, + { + label: contact.string.Contact + }, + contact.templateFieldCategory.Contact + ) + + builder.createDoc( + templates.class.TemplateField, + core.space.Model, + { + label: contact.string.Name, + category: contact.templateFieldCategory.Contact, + func: contact.function.GetContactName + }, + contact.templateField.ContactName + ) } export { contactOperation } from './migration' diff --git a/models/contact/src/plugin.ts b/models/contact/src/plugin.ts index 1014678772..8cd0f2246c 100644 --- a/models/contact/src/plugin.ts +++ b/models/contact/src/plugin.ts @@ -19,6 +19,7 @@ import type { Ref } from '@hcengineering/core' import {} from '@hcengineering/core' import { ObjectSearchCategory, ObjectSearchFactory } from '@hcengineering/model-presentation' import { IntlString, mergeIds, Resource } from '@hcengineering/platform' +import { TemplateFieldFunc } from '@hcengineering/templates' import type { AnyComponent } from '@hcengineering/ui' import { Action, ActionCategory, ViewAction } from '@hcengineering/view' @@ -75,7 +76,8 @@ export default mergeIds(contactId, contact, { Birthday: '' as IntlString, CreatedOn: '' as IntlString, Whatsapp: '' as IntlString, - WhatsappPlaceholder: '' as IntlString + WhatsappPlaceholder: '' as IntlString, + CurrentEmployee: '' as IntlString }, completion: { PersonQuery: '' as Resource, @@ -94,5 +96,10 @@ export default mergeIds(contactId, contact, { actionImpl: { KickEmployee: '' as ViewAction, OpenChannel: '' as ViewAction + }, + function: { + GetCurrentEmployeeName: '' as Resource, + GetCurrentEmployeeEmail: '' as Resource, + GetContactName: '' as Resource } }) diff --git a/models/setting/package.json b/models/setting/package.json index 622bf2f6be..91e0e17f4b 100644 --- a/models/setting/package.json +++ b/models/setting/package.json @@ -36,6 +36,7 @@ "@hcengineering/model-view": "^0.6.0", "@hcengineering/model-workbench": "^0.6.1", "@hcengineering/task": "^0.6.1", + "@hcengineering/templates": "^0.6.0", "@hcengineering/activity": "^0.6.0" } } diff --git a/models/setting/src/index.ts b/models/setting/src/index.ts index d7c639b8e5..3b67c8965a 100644 --- a/models/setting/src/index.ts +++ b/models/setting/src/index.ts @@ -31,6 +31,7 @@ import { } from '@hcengineering/setting' import task from '@hcengineering/task' import setting from './plugin' +import templates from '@hcengineering/templates' import workbench from '@hcengineering/model-workbench' import { AnyComponent } from '@hcengineering/ui' @@ -411,6 +412,37 @@ export function createModel (builder: Builder): void { group: 'edit' } }) + + builder.createDoc( + templates.class.TemplateFieldCategory, + core.space.Model, + { + label: setting.string.Integrations + }, + setting.templateFieldCategory.Integration + ) + + builder.createDoc( + templates.class.TemplateField, + core.space.Model, + { + label: setting.string.IntegrationWith, + category: setting.templateFieldCategory.Integration, + func: setting.function.GetValue + }, + setting.templateField.Value + ) + + builder.createDoc( + templates.class.TemplateField, + core.space.Model, + { + label: setting.string.Owner, + category: setting.templateFieldCategory.Integration, + func: setting.function.GetOwnerName + }, + setting.templateField.OwnerName + ) } export { settingOperation } from './migration' diff --git a/models/setting/src/plugin.ts b/models/setting/src/plugin.ts index 4d418c5c60..242b5808c4 100644 --- a/models/setting/src/plugin.ts +++ b/models/setting/src/plugin.ts @@ -15,11 +15,12 @@ import type { TxViewlet } from '@hcengineering/activity' import { Doc, Ref } from '@hcengineering/core' -import { mergeIds } from '@hcengineering/platform' +import { IntlString, mergeIds, Resource } from '@hcengineering/platform' import { settingId } from '@hcengineering/setting' import setting from '@hcengineering/setting-resources/src/plugin' import { AnyComponent } from '@hcengineering/ui' import { Action, ActionCategory, ViewAction } from '@hcengineering/view' +import { TemplateFieldFunc } from '@hcengineering/templates' export default mergeIds(settingId, setting, { activity: { @@ -52,5 +53,12 @@ export default mergeIds(settingId, setting, { }, actionImpl: { DeleteMixin: '' as ViewAction> + }, + string: { + Value: '' as IntlString + }, + function: { + GetValue: '' as Resource, + GetOwnerName: '' as Resource } }) diff --git a/models/templates/src/index.ts b/models/templates/src/index.ts index bb54c936c0..ba4e62dfed 100644 --- a/models/templates/src/index.ts +++ b/models/templates/src/index.ts @@ -14,12 +14,13 @@ // limitations under the License. // -import { Domain, IndexKind } from '@hcengineering/core' +import { Domain, DOMAIN_MODEL, IndexKind, Ref } from '@hcengineering/core' import { Builder, Index, Model, Prop, TypeString } from '@hcengineering/model' import core, { TDoc } from '@hcengineering/model-core' import textEditor from '@hcengineering/model-text-editor' +import { IntlString, Resource } from '@hcengineering/platform' import setting from '@hcengineering/setting' -import type { MessageTemplate } from '@hcengineering/templates' +import type { MessageTemplate, TemplateField, TemplateFieldCategory, TemplateFieldFunc } from '@hcengineering/templates' import templates from './plugin' export const DOMAIN_TEMPLATES = 'templates' as Domain @@ -35,8 +36,20 @@ export class TMessageTemplate extends TDoc implements MessageTemplate { message!: string } +@Model(templates.class.TemplateFieldCategory, core.class.Doc, DOMAIN_MODEL) +export class TTemplateFieldCategory extends TDoc implements TemplateFieldCategory { + label!: IntlString +} + +@Model(templates.class.TemplateField, core.class.Doc, DOMAIN_MODEL) +export class TTemplateField extends TDoc implements TemplateField { + category!: Ref + label!: IntlString + func!: Resource +} + export function createModel (builder: Builder): void { - builder.createModel(TMessageTemplate) + builder.createModel(TMessageTemplate, TTemplateFieldCategory, TTemplateField) builder.createDoc( setting.class.WorkspaceSettingCategory, diff --git a/packages/text-editor/src/components/StyledTextEditor.svelte b/packages/text-editor/src/components/StyledTextEditor.svelte index b4ac857d0c..697021327d 100644 --- a/packages/text-editor/src/components/StyledTextEditor.svelte +++ b/packages/text-editor/src/components/StyledTextEditor.svelte @@ -13,47 +13,46 @@ // limitations under the License. --> -
(needFocus = true)}> +
(needFocus = true)} +> {#if isFormatting}
{#if showButtons} - {#if $$slots.right} -
-
- {#each defActions.filter((it) => it.hidden === undefined || it.hidden === false) as a} - handleAction(a, evt)} /> - {/each} - -
-
- -
-
- {:else} +
- {#each defActions.filter((it) => it.hidden === undefined || it.hidden === false) as a} + {#each actions.filter((it) => it.hidden !== true) as a} handleAction(a, evt)} /> {/each}
- {/if} + {#if $$slots.right} +
+ +
+ {/if} +
{/if}
diff --git a/plugins/contact-assets/lang/en.json b/plugins/contact-assets/lang/en.json index ad996bf8ac..362bfb0657 100644 --- a/plugins/contact-assets/lang/en.json +++ b/plugins/contact-assets/lang/en.json @@ -76,6 +76,7 @@ "NotSpecified": "Not specified", "CreatedOn": "Created", "Whatsapp": "Whatsapp", - "WhatsappPlaceholder": "Whatsapp" + "WhatsappPlaceholder": "Whatsapp", + "CurrentEmployee": "Current employee" } } \ No newline at end of file diff --git a/plugins/contact-assets/lang/ru.json b/plugins/contact-assets/lang/ru.json index 05769c6eb2..c4fc9acf53 100644 --- a/plugins/contact-assets/lang/ru.json +++ b/plugins/contact-assets/lang/ru.json @@ -76,6 +76,7 @@ "NotSpecified": "Не указан", "CreatedOn": "Создан", "Whatsapp": "Whatsapp", - "WhatsappPlaceholder": "Whatsapp" + "WhatsappPlaceholder": "Whatsapp", + "CurrentEmployee": "Текущий сотрудник" } } \ No newline at end of file diff --git a/plugins/contact-resources/package.json b/plugins/contact-resources/package.json index 7aa231e3c4..57e0b93339 100644 --- a/plugins/contact-resources/package.json +++ b/plugins/contact-resources/package.json @@ -45,6 +45,7 @@ "@hcengineering/panel": "^0.6.0", "@hcengineering/view-resources": "^0.6.0", "@hcengineering/attachment": "^0.6.1", - "@hcengineering/login-resources": "^0.6.2" + "@hcengineering/login-resources": "^0.6.2", + "@hcengineering/templates": "^0.6.0" } } diff --git a/plugins/contact-resources/src/index.ts b/plugins/contact-resources/src/index.ts index 90df4123e5..e35352b1d7 100644 --- a/plugins/contact-resources/src/index.ts +++ b/plugins/contact-resources/src/index.ts @@ -56,7 +56,14 @@ import PersonRefPresenter from './components/PersonRefPresenter.svelte' import EmployeeRefPresenter from './components/EmployeeRefPresenter.svelte' import ChannelFilter from './components/ChannelFilter.svelte' import contact from './plugin' -import { employeeSort, filterChannelInResult, filterChannelNinResult } from './utils' +import { + employeeSort, + filterChannelInResult, + filterChannelNinResult, + getContactName, + getCurrentEmployeeEmail, + getCurrentEmployeeName +} from './utils' export { Channels, @@ -192,6 +199,9 @@ export default async (): Promise => ({ GetColorUrl: (uri: string) => uri, EmployeeSort: employeeSort, FilterChannelInResult: filterChannelInResult, - FilterChannelNinResult: filterChannelNinResult + FilterChannelNinResult: filterChannelNinResult, + GetCurrentEmployeeName: getCurrentEmployeeName, + GetCurrentEmployeeEmail: getCurrentEmployeeEmail, + GetContactName: getContactName } }) diff --git a/plugins/contact-resources/src/utils.ts b/plugins/contact-resources/src/utils.ts index 6846b2bb33..0b877ddf52 100644 --- a/plugins/contact-resources/src/utils.ts +++ b/plugins/contact-resources/src/utils.ts @@ -14,11 +14,13 @@ // limitations under the License. // -import contact, { ChannelProvider, Employee, formatName } from '@hcengineering/contact' -import { Doc, ObjQueryType, Ref, Timestamp, toIdMap } from '@hcengineering/core' +import { ChannelProvider, Contact, Employee, EmployeeAccount, formatName } from '@hcengineering/contact' +import { Doc, getCurrentAccount, ObjQueryType, Ref, Timestamp, toIdMap } from '@hcengineering/core' import { createQuery, getClient } from '@hcengineering/presentation' +import { TemplateDataProvider } from '@hcengineering/templates' import view, { Filter } from '@hcengineering/view' import { FilterQuery } from '@hcengineering/view-resources' +import contact from './plugin' const client = getClient() const channelProviders = client.findAll(contact.class.ChannelProvider, {}) @@ -107,3 +109,25 @@ export async function getRefs (filter: Filter, onUpdate: () => void): Promise { + const me = getCurrentAccount() as EmployeeAccount + return formatName(me.name) +} + +export async function getCurrentEmployeeEmail (): Promise { + const me = getCurrentAccount() as EmployeeAccount + return me.email +} + +export async function getContactName (provider: TemplateDataProvider): Promise { + const value = provider.get(contact.templateFieldCategory.Contact) as Contact + if (value === undefined) return + const client = getClient() + const hierarchy = client.getHierarchy() + if (hierarchy.isDerived(value._class, contact.class.Person)) { + return formatName(value.name) + } else { + return value.name + } +} diff --git a/plugins/contact/package.json b/plugins/contact/package.json index cda66e61a2..00b4dc02f4 100644 --- a/plugins/contact/package.json +++ b/plugins/contact/package.json @@ -30,6 +30,7 @@ "@hcengineering/platform": "^0.6.8", "@hcengineering/ui": "^0.6.3", "@hcengineering/core": "^0.6.21", + "@hcengineering/templates": "^0.6.0", "@hcengineering/view": "^0.6.2", "crypto-js": "^4.1.1" }, diff --git a/plugins/contact/src/index.ts b/plugins/contact/src/index.ts index a389bac2ed..f412d13a36 100644 --- a/plugins/contact/src/index.ts +++ b/plugins/contact/src/index.ts @@ -33,6 +33,7 @@ import type { Asset, Plugin, Resource } from '@hcengineering/platform' import { IntlString, plugin } from '@hcengineering/platform' import type { AnyComponent, IconSize } from '@hcengineering/ui' import { FilterMode, ViewAction, Viewlet } from '@hcengineering/view' +import { TemplateFieldCategory, TemplateField } from '@hcengineering/templates' /** * @public @@ -287,6 +288,15 @@ const contactPlugin = plugin(contactId, { filter: { FilterChannelIn: '' as Ref, FilterChannelNin: '' as Ref + }, + templateFieldCategory: { + CurrentEmployee: '' as Ref, + Contact: '' as Ref + }, + templateField: { + CurrentEmployeeName: '' as Ref, + CurrentEmployeeEmail: '' as Ref, + ContactName: '' as Ref } }) diff --git a/plugins/gmail-resources/package.json b/plugins/gmail-resources/package.json index 83d8f63ade..50d1b432b5 100644 --- a/plugins/gmail-resources/package.json +++ b/plugins/gmail-resources/package.json @@ -47,6 +47,7 @@ "@hcengineering/attachment-resources": "^0.6.0", "@hcengineering/login": "^0.6.1", "@hcengineering/core": "^0.6.21", - "@hcengineering/panel": "^0.6.0" + "@hcengineering/panel": "^0.6.0", + "@hcengineering/templates": "^0.6.0" } } diff --git a/plugins/gmail-resources/src/components/Chats.svelte b/plugins/gmail-resources/src/components/Chats.svelte index 1efae697c8..44a97e1d3d 100644 --- a/plugins/gmail-resources/src/components/Chats.svelte +++ b/plugins/gmail-resources/src/components/Chats.svelte @@ -14,17 +14,15 @@ // limitations under the License. --> {#if channel && object} @@ -97,7 +123,7 @@ - {#if !enabled} + {#if !integration}
@@ -262,7 +317,7 @@ {/if}
- +
@@ -291,7 +346,8 @@ color: #d6d6d6; caret-color: var(--caret-color); min-height: 0; - height: calc(100% - 12rem); + height: 100%; + margin-bottom: 2rem; border-radius: 0.25rem; :global(.ProseMirror) { diff --git a/plugins/setting-assets/lang/en.json b/plugins/setting-assets/lang/en.json index eb688f5fe6..303d91ea33 100644 --- a/plugins/setting-assets/lang/en.json +++ b/plugins/setting-assets/lang/en.json @@ -17,7 +17,7 @@ "Saving": "Saving...", "Saved": "Saved", "Add": "Add", - "LearnMore": "Learn more", + "Value": "Value", "EnterCurrentPassword": "Enter current password", "EnterNewPassword": "Enter new password", "RepeatNewPassword": "Repeat new password", diff --git a/plugins/setting-assets/lang/ru.json b/plugins/setting-assets/lang/ru.json index 996584de33..bcf52902d0 100644 --- a/plugins/setting-assets/lang/ru.json +++ b/plugins/setting-assets/lang/ru.json @@ -17,7 +17,7 @@ "Saving": "Сохранение...", "Saved": "Сохранено", "Add": "Добавить", - "LearnMore": "Узнать больше", + "Value": "Значение", "EnterCurrentPassword": "Введите текущий пароль", "EnterNewPassword": "Введите новый пароль", "RepeatNewPassword": "Повторите новый пароль", diff --git a/plugins/setting-resources/package.json b/plugins/setting-resources/package.json index cf72b8aca2..616b9adc71 100644 --- a/plugins/setting-resources/package.json +++ b/plugins/setting-resources/package.json @@ -47,6 +47,7 @@ "@hcengineering/contact-resources": "^0.6.0", "@hcengineering/login": "^0.6.1", "@hcengineering/model": "^0.6.0", + "@hcengineering/templates": "^0.6.0", "@hcengineering/workbench": "^0.6.2", "@hcengineering/workbench-resources": "^0.6.1" } diff --git a/plugins/setting-resources/src/index.ts b/plugins/setting-resources/src/index.ts index f9299ae664..86ece8a52c 100644 --- a/plugins/setting-resources/src/index.ts +++ b/plugins/setting-resources/src/index.ts @@ -44,6 +44,7 @@ import StringTypeEditor from './components/typeEditors/StringTypeEditor.svelte' import WorkspaceSettings from './components/WorkspaceSettings.svelte' import InviteSetting from './components/InviteSetting.svelte' import setting from './plugin' +import { getOwnerName, getValue } from './utils' export { ClassSetting } @@ -101,5 +102,9 @@ export default async (): Promise => ({ }, actionImpl: { DeleteMixin + }, + function: { + GetOwnerName: getOwnerName, + GetValue: getValue } }) diff --git a/plugins/setting-resources/src/utils.ts b/plugins/setting-resources/src/utils.ts index adfc60293d..56ebe19ba3 100644 --- a/plugins/setting-resources/src/utils.ts +++ b/plugins/setting-resources/src/utils.ts @@ -1,5 +1,8 @@ +import contact, { EmployeeAccount, formatName } from '@hcengineering/contact' import { Class, Doc, Hierarchy, Ref } from '@hcengineering/core' -import setting from '@hcengineering/setting' +import { getClient } from '@hcengineering/presentation' +import setting, { Integration } from '@hcengineering/setting' +import { TemplateDataProvider } from '@hcengineering/templates' function isEditable (hierarchy: Hierarchy, p: Class): boolean { let ancestors = [p._id] @@ -45,3 +48,19 @@ export function filterDescendants ( return _classes.map((p) => p._id) } + +export async function getValue (provider: TemplateDataProvider): Promise { + const value = provider.get(setting.templateFieldCategory.Integration) as Integration + if (value === undefined) return + return value.value +} + +export async function getOwnerName (provider: TemplateDataProvider): Promise { + const value = provider.get(setting.templateFieldCategory.Integration) as Integration + if (value === undefined) return + const client = getClient() + const employeeAccount = await client.findOne(contact.class.EmployeeAccount, { + _id: value.modifiedBy as Ref + }) + return employeeAccount != null ? formatName(employeeAccount.name) : undefined +} diff --git a/plugins/setting/package.json b/plugins/setting/package.json index 9d4ca80f2b..25c18ccc93 100644 --- a/plugins/setting/package.json +++ b/plugins/setting/package.json @@ -28,6 +28,7 @@ "dependencies": { "@hcengineering/platform": "^0.6.8", "@hcengineering/core": "^0.6.21", + "@hcengineering/templates": "^0.6.0", "@hcengineering/ui": "^0.6.3" }, "repository": "https://github.com/hcengineering/anticrm", diff --git a/plugins/setting/src/index.ts b/plugins/setting/src/index.ts index 8b9087d422..4b1421797d 100644 --- a/plugins/setting/src/index.ts +++ b/plugins/setting/src/index.ts @@ -17,6 +17,7 @@ import type { Class, Configuration, Doc, Mixin, Ref, Space } from '@hcengineerin import type { Plugin } from '@hcengineering/platform' import { Asset, IntlString, plugin, Resource } from '@hcengineering/platform' import { AnyComponent } from '@hcengineering/ui' +import { TemplateFieldCategory, TemplateField } from '@hcengineering/templates' /** * @public @@ -145,7 +146,6 @@ export default plugin(settingId, { Delete: '' as IntlString, Disconnect: '' as IntlString, Add: '' as IntlString, - LearnMore: '' as IntlString, EditProfile: '' as IntlString, ChangePassword: '' as IntlString, CurrentPassword: '' as IntlString, @@ -175,5 +175,12 @@ export default plugin(settingId, { SelectWorkspace: '' as Asset, Clazz: '' as Asset, Enums: '' as Asset + }, + templateFieldCategory: { + Integration: '' as Ref + }, + templateField: { + OwnerName: '' as Ref, + Value: '' as Ref } }) diff --git a/plugins/telegram-resources/package.json b/plugins/telegram-resources/package.json index b4ceff7662..b499f6f173 100644 --- a/plugins/telegram-resources/package.json +++ b/plugins/telegram-resources/package.json @@ -45,6 +45,7 @@ "@hcengineering/notification-resources": "^0.6.0", "@hcengineering/attachment": "^0.6.1", "@hcengineering/attachment-resources": "^0.6.0", - "@hcengineering/panel": "^0.6.0" + "@hcengineering/panel": "^0.6.0", + "@hcengineering/templates": "^0.6.0" } } diff --git a/plugins/telegram-resources/src/components/Chat.svelte b/plugins/telegram-resources/src/components/Chat.svelte index 1c36c0b5ed..1ab82f04e1 100644 --- a/plugins/telegram-resources/src/components/Chat.svelte +++ b/plugins/telegram-resources/src/components/Chat.svelte @@ -29,6 +29,9 @@ import TelegramIcon from './icons/Telegram.svelte' import Messages from './Messages.svelte' import Reconnect from './Reconnect.svelte' + import templates, { TemplateDataProvider } from '@hcengineering/templates' + import { getResource } from '@hcengineering/platform' + import { onDestroy } from 'svelte' export let _id: Ref export let _class: Ref> @@ -54,6 +57,19 @@ } ) + let templateProvider: TemplateDataProvider | undefined + + getResource(templates.function.GetTemplateDataProvider).then((p) => { + templateProvider = p() + }) + + onDestroy(() => { + templateProvider?.destroy() + }) + + $: templateProvider && object && templateProvider.set(contact.templateFieldCategory.Contact, object) + $: templateProvider && integration && templateProvider.set(setting.templateFieldCategory.Integration, integration) + const query = createQuery() $: _id && _class && diff --git a/plugins/templates-assets/lang/en.json b/plugins/templates-assets/lang/en.json index 925665c70e..c595bb8563 100644 --- a/plugins/templates-assets/lang/en.json +++ b/plugins/templates-assets/lang/en.json @@ -11,6 +11,7 @@ "SearchTemplate": "search for template", "TemplatePlaceholder": "New template", "Title": "Title", - "Message": "Message" + "Message": "Message", + "Field": "Field" } } \ No newline at end of file diff --git a/plugins/templates-assets/lang/ru.json b/plugins/templates-assets/lang/ru.json index f05d5fa3e3..94984294b8 100644 --- a/plugins/templates-assets/lang/ru.json +++ b/plugins/templates-assets/lang/ru.json @@ -11,6 +11,7 @@ "SearchTemplate": "Поиск шаблона", "TemplatePlaceholder": "Новый шаблон", "Title": "Заголовок", - "Message": "Сообщение" + "Message": "Сообщение", + "Field": "Поле" } } \ No newline at end of file diff --git a/plugins/templates-resources/src/components/FieldPopup.svelte b/plugins/templates-resources/src/components/FieldPopup.svelte new file mode 100644 index 0000000000..deb7895966 --- /dev/null +++ b/plugins/templates-resources/src/components/FieldPopup.svelte @@ -0,0 +1,65 @@ + + + + + +
+
+
+ + +
+ + +
+
+
diff --git a/plugins/templates-resources/src/components/TemplatePopup.svelte b/plugins/templates-resources/src/components/TemplatePopup.svelte index 48cd32c5ca..3f5988370e 100644 --- a/plugins/templates-resources/src/components/TemplatePopup.svelte +++ b/plugins/templates-resources/src/components/TemplatePopup.svelte @@ -19,6 +19,7 @@ import { TextEditorHandler } from '@hcengineering/text-editor' import { closePopup, EditWithIcon, IconSearch, Label, deviceOptionsStore } from '@hcengineering/ui' import templates from '../plugin' + import { getTemplateDataProvider } from '../utils' export let editor: TextEditorHandler let items: MessageTemplate[] = [] @@ -33,8 +34,10 @@ let selected = 0 - function dispatchItem (item: MessageTemplate): void { - editor.insertText(item.message) + const provider = getTemplateDataProvider() + async function dispatchItem (item: MessageTemplate): Promise { + const message = await provider.fillTemplate(item.message) + editor.insertText(message) closePopup() } diff --git a/plugins/templates-resources/src/components/Templates.svelte b/plugins/templates-resources/src/components/Templates.svelte index 7d9e92ea3c..3a6b164bf7 100644 --- a/plugins/templates-resources/src/components/Templates.svelte +++ b/plugins/templates-resources/src/components/Templates.svelte @@ -3,8 +3,9 @@ import { getClient, LiveQuery, MessageViewer } from '@hcengineering/presentation' import { MessageTemplate } from '@hcengineering/templates' import { StyledTextEditor } from '@hcengineering/text-editor' - import { Button, CircleButton, EditBox, Icon, IconAdd, Label } from '@hcengineering/ui' + import { Button, CircleButton, EditBox, eventToHTMLElement, Icon, IconAdd, Label, showPopup } from '@hcengineering/ui' import templatesPlugin from '../plugin' + import FieldPopup from './FieldPopup.svelte' import TemplateElement from './TemplateElement.svelte' const client = getClient() @@ -69,6 +70,14 @@ const updateTemplate = (evt: any) => { newTemplate = { title: newTemplate?.title ?? '', message: evt.detail } } + + function addField (ev: MouseEvent) { + showPopup(FieldPopup, {}, eventToHTMLElement(ev), (res) => { + if (res !== undefined) { + textEditor.insertText(`\${${res._id}}`) + } + }) + }
@@ -132,15 +141,18 @@ on:click={saveNewTemplate} />
-