mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-13 11:50:56 +00:00
accounts update
Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
parent
944f8fbef8
commit
590124f668
@ -13,7 +13,7 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import type { Doc, Ref } from './classes'
|
||||
import type { Doc, Ref, Account } from './classes'
|
||||
|
||||
function toHex (value: number, chars: number): string {
|
||||
const result = value.toString(16)
|
||||
@ -43,3 +43,19 @@ function count (): string {
|
||||
export function generateId<T extends Doc> (): Ref<T> {
|
||||
return (timestamp() + random + count()) as Ref<T>
|
||||
}
|
||||
|
||||
let currentAccount: Account
|
||||
|
||||
/**
|
||||
* @public
|
||||
* @returns
|
||||
*/
|
||||
export function getCurrentAccount (): Account { return currentAccount }
|
||||
|
||||
/**
|
||||
* @public
|
||||
* @param account -
|
||||
*/
|
||||
export function setCurrentAccount (account: Account): void {
|
||||
currentAccount = account
|
||||
}
|
||||
|
@ -15,18 +15,34 @@
|
||||
|
||||
<script lang="ts">
|
||||
import type { Comment } from '@anticrm/chunter'
|
||||
import MessageViewer from '@anticrm/presentation/src/components/MessageViewer.svelte'
|
||||
import { getClient } from '@anticrm/presentation'
|
||||
import type { Ref } from '@anticrm/core'
|
||||
|
||||
import MessageViewer from '@anticrm/presentation/src/components/MessageViewer.svelte'
|
||||
import Avatar from '@anticrm/presentation/src/components/Avatar.svelte'
|
||||
|
||||
import contact, { Employee, EmployeeAccount } from '@anticrm/contact'
|
||||
|
||||
export let comment: Comment
|
||||
|
||||
let employee: Employee | undefined
|
||||
|
||||
console.log('comment modified by', comment.modifiedBy)
|
||||
|
||||
const client = getClient()
|
||||
client.findOne(contact.class.EmployeeAccount, { _id: comment.modifiedBy as Ref<EmployeeAccount> })
|
||||
.then(account => client.findOne(contact.class.Employee, { _id: account?.employee }))
|
||||
.then(result => {
|
||||
console.log('comment', result)
|
||||
employee = result
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<div class="flex-nowrap">
|
||||
<div class="avatar"><Avatar size={'medium'} /></div>
|
||||
<div class="flex-col-stretch message">
|
||||
<div class="header">Rosamund Chen<span>July 28th</span></div>
|
||||
<div class="header">{#if employee}{employee.firstName} {employee.lastName}{/if}<span>July 28th</span></div>
|
||||
<div class="text"><MessageViewer message={comment.message} /></div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
import { getResource } from '@anticrm/platform'
|
||||
import type { Client } from '@anticrm/core'
|
||||
import { setCurrentAccount } from '@anticrm/core'
|
||||
import { navigate, Loading, fetchMetadataLocalStorage } from '@anticrm/ui'
|
||||
|
||||
import client from '@anticrm/client'
|
||||
@ -24,7 +25,6 @@ import login from '@anticrm/login'
|
||||
import contact from '@anticrm/contact'
|
||||
|
||||
import Workbench from './Workbench.svelte'
|
||||
import { setCurrentAccount } from '../utils'
|
||||
|
||||
async function connect(): Promise<Client | undefined> {
|
||||
const token = fetchMetadataLocalStorage(login.metadata.LoginToken)
|
||||
|
@ -22,11 +22,3 @@ import type { EmployeeAccount } from '@anticrm/contact'
|
||||
export function classIcon(client: Client, _class: Ref<Class<Obj>>): Asset | undefined {
|
||||
return client.getHierarchy().getClass(_class).icon
|
||||
}
|
||||
|
||||
let currentAccount: EmployeeAccount
|
||||
|
||||
export function getCurrentAccount(): EmployeeAccount { return currentAccount }
|
||||
|
||||
export function setCurrentAccount(account: EmployeeAccount): void {
|
||||
currentAccount = account
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user