Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2024-05-14 18:48:07 +05:00 committed by GitHub
parent 2d92b9aa46
commit 9c22b1732f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 101 additions and 60 deletions

View File

@ -17,7 +17,7 @@ import activity from '@hcengineering/activity'
import chunter from '@hcengineering/chunter' import chunter from '@hcengineering/chunter'
import { type Builder } from '@hcengineering/model' import { type Builder } from '@hcengineering/model'
import core from '@hcengineering/model-core' import core from '@hcengineering/model-core'
import { type Ref, type Status } from '@hcengineering/core' import { AccountRole, type Ref, type Status } from '@hcengineering/core'
import { generateClassNotificationTypes } from '@hcengineering/model-notification' import { generateClassNotificationTypes } from '@hcengineering/model-notification'
import presentation from '@hcengineering/model-presentation' import presentation from '@hcengineering/model-presentation'
import task from '@hcengineering/model-task' import task from '@hcengineering/model-task'
@ -330,6 +330,7 @@ function defineApplication (
id: 'all-projects', id: 'all-projects',
component: workbench.component.SpecialView, component: workbench.component.SpecialView,
icon: view.icon.List, icon: view.icon.List,
accessLevel: AccountRole.User,
label: tracker.string.AllProjects, label: tracker.string.AllProjects,
position: 'bottom', position: 'bottom',
spaceClass: tracker.class.Project, spaceClass: tracker.class.Project,

View File

@ -39,6 +39,8 @@
return firstName === '' && lastName === '' && email === '' return firstName === '' && lastName === '' && email === ''
} }
let saving: boolean = false
const person: Data<Employee> = { const person: Data<Employee> = {
name: '', name: '',
city: '', city: '',
@ -49,37 +51,49 @@
const client = getClient() const client = getClient()
async function createPerson () { async function createPerson () {
changeEmail() try {
const name = combineName(firstName, lastName) saving = true
person.name = name changeEmail()
person.avatar = await avatarEditor.createAvatar() const name = combineName(firstName, lastName)
person.name = name
person.avatar = await avatarEditor.createAvatar()
await client.createDoc(contact.class.Person, contact.space.Contacts, person, id) await client.createDoc(contact.class.Person, contact.space.Contacts, person, id)
await client.createMixin(id, contact.class.Person, contact.space.Contacts, contact.mixin.Employee, { await client.createMixin(id, contact.class.Person, contact.space.Contacts, contact.mixin.Employee, {
active: true active: true
})
const mail = email.trim()
await client.createDoc(contact.class.PersonAccount, core.space.Model, {
email: mail,
person: id,
role: AccountRole.User
})
const sendInvite = await getResource(login.function.SendInvite)
await sendInvite(email.trim(), id, AccountRole.User)
for (const channel of channels) {
await client.addCollection(contact.class.Channel, contact.space.Contacts, id, contact.class.Person, 'channels', {
value: channel.value,
provider: channel.provider
}) })
const mail = email.trim()
await client.createDoc(contact.class.PersonAccount, core.space.Model, {
email: mail,
person: id,
role: AccountRole.User
})
const sendInvite = await getResource(login.function.SendInvite)
await sendInvite(email.trim(), id, AccountRole.User)
for (const channel of channels) {
await client.addCollection(
contact.class.Channel,
contact.space.Contacts,
id,
contact.class.Person,
'channels',
{
value: channel.value,
provider: channel.provider
}
)
}
if (onCreate) {
await onCreate(id)
}
dispatch('close', id)
} finally {
saving = false
} }
if (onCreate) {
await onCreate(id)
}
dispatch('close')
} }
let channels: AttachedData<Channel>[] = [] let channels: AttachedData<Channel>[] = []
@ -128,7 +142,7 @@
on:changeContent on:changeContent
> >
<svelte:fragment slot="error"> <svelte:fragment slot="error">
{#if exists !== undefined} {#if exists !== undefined && !saving}
<div class="flex-row-center error-color"> <div class="flex-row-center error-color">
<IconInfo size={'small'} /> <IconInfo size={'small'} />
<span class="text-sm overflow-label ml-2"> <span class="text-sm overflow-label ml-2">

View File

@ -36,40 +36,54 @@
return firstName === '' && lastName === '' && email === '' return firstName === '' && lastName === '' && email === ''
} }
let saving: boolean = false
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher()
const client = getClient() const client = getClient()
async function createPerson () { async function createPerson () {
changeEmail() try {
const name = combineName(firstName, lastName) saving = true
const person: Data<Person> = { changeEmail()
name, const name = combineName(firstName, lastName)
city: '' const person: Data<Person> = {
} name,
city: ''
}
await client.createDoc(contact.class.Person, contact.space.Contacts, person, id) await client.createDoc(contact.class.Person, contact.space.Contacts, person, id)
const mail = email.trim() const mail = email.trim()
await client.createDoc(contact.class.PersonAccount, core.space.Model, { await client.createDoc(contact.class.PersonAccount, core.space.Model, {
email: mail, email: mail,
person: id, person: id,
role: AccountRole.Guest role: AccountRole.Guest
})
const sendInvite = await getResource(login.function.SendInvite)
await sendInvite(email.trim(), id, AccountRole.Guest)
for (const channel of channels) {
await client.addCollection(contact.class.Channel, contact.space.Contacts, id, contact.class.Person, 'channels', {
value: channel.value,
provider: channel.provider
}) })
const sendInvite = await getResource(login.function.SendInvite)
await sendInvite(email.trim(), id, AccountRole.Guest)
for (const channel of channels) {
await client.addCollection(
contact.class.Channel,
contact.space.Contacts,
id,
contact.class.Person,
'channels',
{
value: channel.value,
provider: channel.provider
}
)
}
if (onCreate) {
await onCreate(id)
}
dispatch('close', id)
} finally {
saving = false
} }
if (onCreate) {
await onCreate(id)
}
dispatch('close')
} }
let channels: AttachedData<Channel>[] = [] let channels: AttachedData<Channel>[] = []
@ -118,7 +132,7 @@
on:changeContent on:changeContent
> >
<svelte:fragment slot="error"> <svelte:fragment slot="error">
{#if exists !== undefined} {#if exists !== undefined && !saving}
<div class="flex-row-center error-color"> <div class="flex-row-center error-color">
<IconInfo size={'small'} /> <IconInfo size={'small'} />
<span class="text-sm overflow-label ml-2"> <span class="text-sm overflow-label ml-2">

View File

@ -13,7 +13,7 @@
// limitations under the License. // limitations under the License.
--> -->
<script lang="ts"> <script lang="ts">
import { Account, Ref, getCurrentAccount } from '@hcengineering/core' import { Account, AccountRole, Ref, getCurrentAccount, hasAccountRole } from '@hcengineering/core'
import { IntlString } from '@hcengineering/platform' import { IntlString } from '@hcengineering/platform'
import { Button, ButtonKind, ButtonSize } from '@hcengineering/ui' import { Button, ButtonKind, ButtonSize } from '@hcengineering/ui'
import view from '@hcengineering/view' import view from '@hcengineering/view'
@ -41,5 +41,14 @@
{#if !joined && onChange !== undefined} {#if !joined && onChange !== undefined}
<Button label={view.string.Join} {size} {width} kind={'primary'} on:click={join} /> <Button label={view.string.Join} {size} {width} kind={'primary'} on:click={join} />
{:else} {:else}
<AccountArrayEditor {label} {value} {onChange} {readonly} {kind} {size} {width} allowGuests /> <AccountArrayEditor
{label}
{value}
{onChange}
readonly={readonly || !hasAccountRole(getCurrentAccount(), AccountRole.User)}
{kind}
{size}
{width}
allowGuests
/>
{/if} {/if}

View File

@ -375,6 +375,7 @@
</div> </div>
<AccountArrayEditor <AccountArrayEditor
value={members} value={members}
allowGuests
label={documentRes.string.TeamspaceMembers} label={documentRes.string.TeamspaceMembers}
onChange={handleMembersChanged} onChange={handleMembersChanged}
kind={'regular'} kind={'regular'}

View File

@ -164,7 +164,7 @@
</script> </script>
<SpaceCreateCard <SpaceCreateCard
label={funnel ? view.string.EdifFunnel : leadRes.string.CreateFunnel} label={funnel ? leadRes.string.EditFunnel : leadRes.string.CreateFunnel}
okAction={save} okAction={save}
okLabel={!isNew ? ui.string.Save : undefined} okLabel={!isNew ? ui.string.Save : undefined}
{canSave} {canSave}
@ -212,6 +212,7 @@
</div> </div>
<AccountArrayEditor <AccountArrayEditor
value={members} value={members}
allowGuests
label={leadRes.string.Members} label={leadRes.string.Members}
onChange={handleMembersChanged} onChange={handleMembersChanged}
kind={'regular'} kind={'regular'}

View File

@ -471,6 +471,7 @@
<AccountArrayEditor <AccountArrayEditor
value={owners} value={owners}
label={core.string.Owners} label={core.string.Owners}
allowGuests
onChange={handleOwnersChanged} onChange={handleOwnersChanged}
kind={'regular'} kind={'regular'}
size={'large'} size={'large'}

View File

@ -1895,7 +1895,7 @@ export async function sendInvite (
const inviteId = await getInviteLink(ctx, db, productId, token, exp, email, 1) const inviteId = await getInviteLink(ctx, db, productId, token, exp, email, 1)
const link = concatLink(front, `/login/join?inviteId=${inviteId.toString()}`) const link = concatLink(front, `/login/join?inviteId=${inviteId.toString()}`)
const ws = workspace.workspace const ws = workspace.workspaceName ?? workspace.workspace
const text = await translate(accountPlugin.string.InviteText, { link, ws, expHours }) const text = await translate(accountPlugin.string.InviteText, { link, ws, expHours })
const html = await translate(accountPlugin.string.InviteHTML, { link, ws, expHours }) const html = await translate(accountPlugin.string.InviteHTML, { link, ws, expHours })
const subject = await translate(accountPlugin.string.InviteSubject, { ws }) const subject = await translate(accountPlugin.string.InviteSubject, { ws })