Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Signed-off-by: Denis Bykhov <[email protected]>
  • Loading branch information
BykhovDenis authored May 14, 2024
1 parent 2d92b9a commit 9c22b17
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 64 deletions.
3 changes: 2 additions & 1 deletion models/tracker/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import activity from '@hcengineering/activity'
import chunter from '@hcengineering/chunter'
import { type Builder } from '@hcengineering/model'
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 presentation from '@hcengineering/model-presentation'
import task from '@hcengineering/model-task'
Expand Down Expand Up @@ -330,6 +330,7 @@ function defineApplication (
id: 'all-projects',
component: workbench.component.SpecialView,
icon: view.icon.List,
accessLevel: AccountRole.User,
label: tracker.string.AllProjects,
position: 'bottom',
spaceClass: tracker.class.Project,
Expand Down
74 changes: 44 additions & 30 deletions plugins/contact-resources/src/components/CreateEmployee.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
return firstName === '' && lastName === '' && email === ''
}
let saving: boolean = false
const person: Data<Employee> = {
name: '',
city: '',
Expand All @@ -49,37 +51,49 @@
const client = getClient()
async function createPerson () {
changeEmail()
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.createMixin(id, contact.class.Person, contact.space.Contacts, contact.mixin.Employee, {
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
try {
saving = true
changeEmail()
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.createMixin(id, contact.class.Person, contact.space.Contacts, contact.mixin.Employee, {
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
}
)
}
if (onCreate) {
await onCreate(id)
}
dispatch('close', id)
} finally {
saving = false
}
if (onCreate) {
await onCreate(id)
}
dispatch('close')
}
let channels: AttachedData<Channel>[] = []
Expand Down Expand Up @@ -128,7 +142,7 @@
on:changeContent
>
<svelte:fragment slot="error">
{#if exists !== undefined}
{#if exists !== undefined && !saving}
<div class="flex-row-center error-color">
<IconInfo size={'small'} />
<span class="text-sm overflow-label ml-2">
Expand Down
72 changes: 43 additions & 29 deletions plugins/contact-resources/src/components/CreateGuest.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -36,40 +36,54 @@
return firstName === '' && lastName === '' && email === ''
}
let saving: boolean = false
const dispatch = createEventDispatcher()
const client = getClient()
async function createPerson () {
changeEmail()
const name = combineName(firstName, lastName)
const person: Data<Person> = {
name,
city: ''
}
await client.createDoc(contact.class.Person, contact.space.Contacts, person, id)
const mail = email.trim()
await client.createDoc(contact.class.PersonAccount, core.space.Model, {
email: mail,
person: id,
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
try {
saving = true
changeEmail()
const name = combineName(firstName, lastName)
const person: Data<Person> = {
name,
city: ''
}
await client.createDoc(contact.class.Person, contact.space.Contacts, person, id)
const mail = email.trim()
await client.createDoc(contact.class.PersonAccount, core.space.Model, {
email: mail,
person: id,
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
}
)
}
if (onCreate) {
await onCreate(id)
}
dispatch('close', id)
} finally {
saving = false
}
if (onCreate) {
await onCreate(id)
}
dispatch('close')
}
let channels: AttachedData<Channel>[] = []
Expand Down Expand Up @@ -118,7 +132,7 @@
on:changeContent
>
<svelte:fragment slot="error">
{#if exists !== undefined}
{#if exists !== undefined && !saving}
<div class="flex-row-center error-color">
<IconInfo size={'small'} />
<span class="text-sm overflow-label ml-2">
Expand Down
13 changes: 11 additions & 2 deletions plugins/contact-resources/src/components/SpaceMembersEditor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.
-->
<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 { Button, ButtonKind, ButtonSize } from '@hcengineering/ui'
import view from '@hcengineering/view'
Expand Down Expand Up @@ -41,5 +41,14 @@
{#if !joined && onChange !== undefined}
<Button label={view.string.Join} {size} {width} kind={'primary'} on:click={join} />
{: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}
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@
</div>
<AccountArrayEditor
value={members}
allowGuests
label={documentRes.string.TeamspaceMembers}
onChange={handleMembersChanged}
kind={'regular'}
Expand Down
3 changes: 2 additions & 1 deletion plugins/lead-resources/src/components/CreateFunnel.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
</script>

<SpaceCreateCard
label={funnel ? view.string.EdifFunnel : leadRes.string.CreateFunnel}
label={funnel ? leadRes.string.EditFunnel : leadRes.string.CreateFunnel}
okAction={save}
okLabel={!isNew ? ui.string.Save : undefined}
{canSave}
Expand Down Expand Up @@ -212,6 +212,7 @@
</div>
<AccountArrayEditor
value={members}
allowGuests
label={leadRes.string.Members}
onChange={handleMembersChanged}
kind={'regular'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@
<AccountArrayEditor
value={owners}
label={core.string.Owners}
allowGuests
onChange={handleOwnersChanged}
kind={'regular'}
size={'large'}
Expand Down
2 changes: 1 addition & 1 deletion server/account/src/operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1895,7 +1895,7 @@ export async function sendInvite (
const inviteId = await getInviteLink(ctx, db, productId, token, exp, email, 1)
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 html = await translate(accountPlugin.string.InviteHTML, { link, ws, expHours })
const subject = await translate(accountPlugin.string.InviteSubject, { ws })
Expand Down

0 comments on commit 9c22b17

Please sign in to comment.