diff --git a/models/lead/src/index.ts b/models/lead/src/index.ts index 46780a4807..adba28560d 100644 --- a/models/lead/src/index.ts +++ b/models/lead/src/index.ts @@ -231,6 +231,54 @@ export function createModel (builder: Builder): void { builder.mixin(lead.mixin.Customer, core.class.Mixin, view.mixin.ObjectFactory, { component: lead.component.CreateCustomer }) + + builder.createDoc( + view.class.ActionCategory, + core.space.Model, + { label: lead.string.LeadApplication, visible: true }, + lead.category.Lead + ) + + createAction(builder, { + action: view.actionImpl.ShowPopup, + actionProps: { + component: lead.component.CreateLead, + _id: 'customer', + element: 'top', + props: { + preserveCustomer: true + } + }, + label: lead.string.CreateLead, + icon: lead.icon.Lead, + input: 'focus', + category: lead.category.Lead, + target: contact.class.Person, + context: { mode: ['context', 'browser'] }, + override: [lead.action.CreateGlobalLead] + }) + + createAction( + builder, + { + action: view.actionImpl.ShowPopup, + actionProps: { + component: lead.component.CreateLead, + element: 'top' + }, + label: lead.string.CreateLead, + icon: lead.icon.Lead, + keyBinding: [], + input: 'none', + category: lead.category.Lead, + target: core.class.Doc, + context: { + mode: ['workbench', 'browser'], + application: lead.app.Lead + } + }, + lead.action.CreateGlobalLead + ) } export { leadOperation } from './migration' diff --git a/models/lead/src/plugin.ts b/models/lead/src/plugin.ts index e4e8f68330..200dff17b8 100644 --- a/models/lead/src/plugin.ts +++ b/models/lead/src/plugin.ts @@ -21,7 +21,7 @@ import type { IntlString } from '@anticrm/platform' import { mergeIds } from '@anticrm/platform' import { KanbanTemplate } from '@anticrm/task' import type { AnyComponent } from '@anticrm/ui' -import { Viewlet } from '@anticrm/view' +import { Action, ActionCategory, Viewlet } from '@anticrm/view' export default mergeIds(leadId, lead, { string: { @@ -53,5 +53,11 @@ export default mergeIds(leadId, lead, { viewlet: { TableCustomer: '' as Ref, TableLead: '' as Ref + }, + category: { + Lead: '' as Ref + }, + action: { + CreateGlobalLead: '' as Ref } }) diff --git a/plugins/lead-assets/lang/en.json b/plugins/lead-assets/lang/en.json index af84825596..149b65922b 100644 --- a/plugins/lead-assets/lang/en.json +++ b/plugins/lead-assets/lang/en.json @@ -1,7 +1,7 @@ { "string": { - "CreateFunnel": "Create funnel", - "CreateLead": "Create lead", + "CreateFunnel": "New Funnel", + "CreateLead": "New Lead", "Funnel": "Funnel", "FunnelName": "Funnel name", "Funnels": "Funnels", diff --git a/plugins/lead-resources/src/components/CreateLead.svelte b/plugins/lead-resources/src/components/CreateLead.svelte index 8827548f1b..e773d78c88 100644 --- a/plugins/lead-resources/src/components/CreateLead.svelte +++ b/plugins/lead-resources/src/components/CreateLead.svelte @@ -20,17 +20,17 @@ import { OK, Status } from '@anticrm/platform' import { Card, getClient, SpaceSelector, UserBox } from '@anticrm/presentation' import task, { calcRank } from '@anticrm/task' - import { EditBox, Status as StatusControl } from '@anticrm/ui' + import { createFocusManager, EditBox, FocusHandler, Label, Status as StatusControl } from '@anticrm/ui' import { createEventDispatcher } from 'svelte' import lead from '../plugin' export let space: Ref + export let customer: Ref | null = null + export let preserveCustomer = false let _space = space const status: Status = OK - let customer: Ref | null = null - let title: string = '' const dispatch = createEventDispatcher() @@ -38,9 +38,15 @@ const leadId = generateId() as Ref export function canClose (): boolean { - return title !== '' + return (preserveCustomer || customer === undefined) && title === '' } + $: client.findAll(lead.class.Funnel, {}).then((r) => { + if (r.find((it) => it._id === _space) === undefined) { + _space = r.shift()?._id as Ref + } + }) + async function createLead () { const state = await client.findOne(task.class.State, { space: _space }) if (state === undefined) { @@ -86,8 +92,12 @@ await client.addCollection(lead.class.Lead, _space, customer!, lead.mixin.Customer, 'leads', value, leadId) dispatch('close') } + + const manager = createFocusManager() + + + +
+ {#if preserveCustomer} + + {/if} +
+
- + {#if !preserveCustomer} + + {/if}