mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-28 12:35:02 +02:00
Owners (#2183)
Signed-off-by: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com>
This commit is contained in:
@@ -14,10 +14,10 @@
|
||||
-->
|
||||
<script lang="ts">
|
||||
import contact, { Employee, EmployeeAccount, formatName } from '@anticrm/contact'
|
||||
import { getCurrentAccount } from '@anticrm/core'
|
||||
import { AccountRole, getCurrentAccount } from '@anticrm/core'
|
||||
import login from '@anticrm/login'
|
||||
import { Avatar, createQuery, getClient } from '@anticrm/presentation'
|
||||
import setting, { SettingsCategory, settingId } from '@anticrm/setting'
|
||||
import { Avatar, createQuery } from '@anticrm/presentation'
|
||||
import setting, { settingId, SettingsCategory } from '@anticrm/setting'
|
||||
import {
|
||||
closePanel,
|
||||
closePopup,
|
||||
@@ -26,17 +26,20 @@
|
||||
Label,
|
||||
navigate,
|
||||
setMetadataLocalStorage,
|
||||
showPopup,
|
||||
Submenu,
|
||||
locationToUrl
|
||||
showPopup
|
||||
} from '@anticrm/ui'
|
||||
import type { Action } from '@anticrm/ui'
|
||||
import view from '@anticrm/view'
|
||||
|
||||
const client = getClient()
|
||||
async function getItems (): Promise<SettingsCategory[]> {
|
||||
return await client.findAll(setting.class.SettingsCategory, {}, { sort: { order: 1 } })
|
||||
}
|
||||
let items: SettingsCategory[] = []
|
||||
|
||||
const settingsQuery = createQuery()
|
||||
settingsQuery.query(
|
||||
setting.class.SettingsCategory,
|
||||
{},
|
||||
(res) => {
|
||||
items = account.role > AccountRole.User ? res : res.filter((p) => p.secured === false)
|
||||
},
|
||||
{ sort: { order: 1 } }
|
||||
)
|
||||
|
||||
const account = getCurrentAccount() as EmployeeAccount
|
||||
let employee: Employee | undefined
|
||||
@@ -80,84 +83,61 @@
|
||||
}
|
||||
|
||||
function filterItems (items: SettingsCategory[]): SettingsCategory[] {
|
||||
return items?.filter((p) => p.name !== 'profile' && p.name !== 'password')
|
||||
return items.filter((p) => p._id !== setting.ids.Profile && p._id !== setting.ids.Password)
|
||||
}
|
||||
|
||||
function editProfile (items: SettingsCategory[] | undefined): void {
|
||||
const profile = items?.find((p) => p.name === 'profile')
|
||||
function editProfile (items: SettingsCategory[]): void {
|
||||
const profile = items.find((p) => p._id === setting.ids.Profile)
|
||||
if (profile === undefined) return
|
||||
selectCategory(profile)
|
||||
}
|
||||
|
||||
function getURLCategory (sp: SettingsCategory): string {
|
||||
const loc = getCurrentLocation()
|
||||
loc.path[1] = settingId
|
||||
loc.path[2] = sp.name
|
||||
loc.path.length = 3
|
||||
return locationToUrl(loc)
|
||||
}
|
||||
|
||||
const getSubmenu = (items: SettingsCategory[]): Action[] => {
|
||||
const actions: Action[] = filterItems(items).map((i) => {
|
||||
return {
|
||||
icon: i.icon,
|
||||
label: i.label,
|
||||
action: async () => selectCategory(i),
|
||||
link: getURLCategory(i),
|
||||
inline: true
|
||||
}
|
||||
})
|
||||
return actions
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="selectPopup autoHeight">
|
||||
<div class="scroll">
|
||||
<div class="box">
|
||||
{#await getItems() then items}
|
||||
<div
|
||||
class="menu-item high flex-row-center"
|
||||
on:click={() => {
|
||||
editProfile(items)
|
||||
}}
|
||||
>
|
||||
{#if employee}
|
||||
<Avatar avatar={employee.avatar} size={'medium'} />
|
||||
{/if}
|
||||
<div class="ml-2 flex-col">
|
||||
{#if account}
|
||||
<div class="overflow-label fs-bold caption-color">{formatName(account.name)}</div>
|
||||
<div class="overflow-label text-sm content-dark-color">{account.email}</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{#if items}
|
||||
<Submenu
|
||||
icon={view.icon.Setting}
|
||||
label={setting.string.Settings}
|
||||
props={{ actions: getSubmenu(items) }}
|
||||
withHover
|
||||
/>
|
||||
<div
|
||||
class="menu-item high flex-row-center"
|
||||
on:click={() => {
|
||||
editProfile(items)
|
||||
}}
|
||||
>
|
||||
{#if employee}
|
||||
<Avatar avatar={employee.avatar} size={'medium'} />
|
||||
{/if}
|
||||
<button class="menu-item" on:click={selectWorkspace}>
|
||||
<div class="icon mr-3">
|
||||
<Icon icon={setting.icon.SelectWorkspace} size={'small'} />
|
||||
<div class="ml-2 flex-col">
|
||||
{#if account}
|
||||
<div class="overflow-label fs-bold caption-color">{formatName(account.name)}</div>
|
||||
<div class="overflow-label text-sm content-dark-color">{account.email}</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{#each filterItems(items) as item}
|
||||
<button class="menu-item" on:click={() => selectCategory(item)}>
|
||||
<div class="mr-2">
|
||||
<Icon icon={item.icon} size={'small'} />
|
||||
</div>
|
||||
<Label label={setting.string.SelectWorkspace} />
|
||||
<Label label={item.label} />
|
||||
</button>
|
||||
<button class="menu-item" on:click={inviteWorkspace}>
|
||||
<div class="icon mr-3">
|
||||
<Icon icon={login.icon.InviteWorkspace} size={'small'} />
|
||||
</div>
|
||||
<Label label={setting.string.InviteWorkspace} />
|
||||
</button>
|
||||
<button class="menu-item" on:click={signOut}>
|
||||
<div class="icon mr-3">
|
||||
<Icon icon={setting.icon.Signout} size={'small'} />
|
||||
</div>
|
||||
<Label label={setting.string.Signout} />
|
||||
</button>
|
||||
{/await}
|
||||
{/each}
|
||||
<button class="menu-item" on:click={selectWorkspace}>
|
||||
<div class="icon mr-3">
|
||||
<Icon icon={setting.icon.SelectWorkspace} size={'small'} />
|
||||
</div>
|
||||
<Label label={setting.string.SelectWorkspace} />
|
||||
</button>
|
||||
<button class="menu-item" on:click={inviteWorkspace}>
|
||||
<div class="icon mr-3">
|
||||
<Icon icon={login.icon.InviteWorkspace} size={'small'} />
|
||||
</div>
|
||||
<Label label={setting.string.InviteWorkspace} />
|
||||
</button>
|
||||
<button class="menu-item" on:click={signOut}>
|
||||
<div class="icon mr-3">
|
||||
<Icon icon={setting.icon.Signout} size={'small'} />
|
||||
</div>
|
||||
<Label label={setting.string.Signout} />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<script lang="ts">
|
||||
import calendar from '@anticrm/calendar'
|
||||
import contact, { Employee, EmployeeAccount } from '@anticrm/contact'
|
||||
import core, { Class, Client, Doc, getCurrentAccount, Ref, Space } from '@anticrm/core'
|
||||
import core, { Class, Client, Doc, getCurrentAccount, Ref, setCurrentAccount, Space } from '@anticrm/core'
|
||||
import notification, { NotificationStatus } from '@anticrm/notification'
|
||||
import { NotificationClientImpl, BrowserNotificatator } from '@anticrm/notification-resources'
|
||||
import { getMetadata, getResource, IntlString } from '@anticrm/platform'
|
||||
@@ -93,7 +93,20 @@
|
||||
}
|
||||
}
|
||||
|
||||
const account = getCurrentAccount() as EmployeeAccount
|
||||
let account = getCurrentAccount() as EmployeeAccount
|
||||
const accountQ = createQuery()
|
||||
accountQ.query(
|
||||
contact.class.EmployeeAccount,
|
||||
{
|
||||
_id: account._id
|
||||
},
|
||||
(res) => {
|
||||
account = res[0]
|
||||
setCurrentAccount(account)
|
||||
},
|
||||
{ limit: 1 }
|
||||
)
|
||||
|
||||
let employee: Employee | undefined
|
||||
const employeeQ = createQuery()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user