From 1091ced274331ed84b2c82c59c6af3386694d6e3 Mon Sep 17 00:00:00 2001 From: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com> Date: Mon, 20 Jun 2022 21:59:56 +0600 Subject: [PATCH] Hr ui fix (#2112) Signed-off-by: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com> --- models/hr/package.json | 2 + models/hr/src/index.ts | 36 +++++- models/view/src/index.ts | 3 +- .../src/components/AttributeBarEditor.svelte | 3 + plugins/hr-resources/package.json | 1 + .../src/components/DepartmentCard.svelte | 50 +++----- .../src/components/DepartmentEditor.svelte | 4 +- .../src/components/DepartmentStaff.svelte | 114 +++++++++++------- .../src/components/EditDepartment.svelte | 101 ++++++---------- .../src/components/StaffPresenter.svelte | 36 ------ plugins/hr/src/index.ts | 16 ++- .../src/components/DocAttributeBar.svelte | 20 +-- .../src/components/EditDoc.svelte | 23 +++- plugins/view-resources/src/utils.ts | 13 +- plugins/view/src/index.ts | 3 +- server-plugins/hr-resources/src/index.ts | 6 +- 16 files changed, 214 insertions(+), 217 deletions(-) delete mode 100644 plugins/hr-resources/src/components/StaffPresenter.svelte diff --git a/models/hr/package.json b/models/hr/package.json index a4d3d0b9d4..23ef616680 100644 --- a/models/hr/package.json +++ b/models/hr/package.json @@ -34,6 +34,8 @@ "@anticrm/model-view": "~0.6.0", "@anticrm/model-workbench": "~0.6.1", "@anticrm/model-contact": "~0.6.1", + "@anticrm/model-chunter": "~0.6.0", + "@anticrm/model-attachment": "~0.6.0", "@anticrm/hr": "~0.6.0", "@anticrm/hr-resources": "~0.6.0", "@anticrm/view": "~0.6.0" diff --git a/models/hr/src/index.ts b/models/hr/src/index.ts index b356a7870d..0c30dca9d6 100644 --- a/models/hr/src/index.ts +++ b/models/hr/src/index.ts @@ -14,14 +14,16 @@ // import { Employee } from '@anticrm/contact' -import contact, { TEmployee } from '@anticrm/model-contact' -import { IndexKind, Ref } from '@anticrm/core' -import type { Department, Staff } from '@anticrm/hr' -import { Builder, Index, Mixin, Model, Prop, TypeRef, TypeString, UX } from '@anticrm/model' +import contact, { TEmployee, TEmployeeAccount } from '@anticrm/model-contact' +import { Arr, IndexKind, Ref } from '@anticrm/core' +import type { Department, DepartmentMember, Staff } from '@anticrm/hr' +import { Builder, Index, Mixin, Model, Prop, TypeRef, Collection, TypeString, UX, ArrOf } from '@anticrm/model' import core, { TSpace } from '@anticrm/model-core' import workbench from '@anticrm/model-workbench' import hr from './plugin' import view, { createAction } from '@anticrm/model-view' +import attachment from '@anticrm/model-attachment' +import chunter from '@anticrm/model-chunter' @Model(hr.class.Department, core.class.Space) @UX(hr.string.Department, hr.icon.Department) @@ -33,12 +35,28 @@ export class TDepartment extends TSpace implements Department { @Index(IndexKind.FullText) name!: string + @Prop(Collection(contact.class.Channel), contact.string.ContactInfo) + channels?: number + + @Prop(Collection(attachment.class.Attachment), attachment.string.Attachments, undefined, attachment.string.Files) + attachments?: number + + @Prop(Collection(chunter.class.Comment), chunter.string.Comments) + comments?: number + avatar?: string | null @Prop(TypeRef(contact.class.Employee), hr.string.TeamLead) teamLead!: Ref | null + + @Prop(ArrOf(TypeRef(hr.class.DepartmentMember)), contact.string.Members) + declare members: Arr> } +@Model(hr.class.DepartmentMember, contact.class.EmployeeAccount) +@UX(contact.string.Employee, hr.icon.HR) +export class TDepartmentMember extends TEmployeeAccount implements DepartmentMember {} + @Mixin(hr.mixin.Staff, contact.class.Employee) @UX(contact.string.Employee, hr.icon.HR) export class TStaff extends TEmployee implements Staff { @@ -47,7 +65,7 @@ export class TStaff extends TEmployee implements Staff { } export function createModel (builder: Builder): void { - builder.createModel(TDepartment, TStaff) + builder.createModel(TDepartment, TDepartmentMember, TStaff) builder.createDoc( workbench.class.Application, @@ -76,6 +94,14 @@ export function createModel (builder: Builder): void { inlineEditor: hr.component.DepartmentEditor }) + builder.mixin(hr.class.Department, core.class.Class, view.mixin.ObjectEditor, { + editor: hr.component.EditDepartment + }) + + builder.mixin(hr.class.DepartmentMember, core.class.Class, view.mixin.ArrayEditor, { + editor: hr.component.DepartmentStaff + }) + createAction( builder, { diff --git a/models/view/src/index.ts b/models/view/src/index.ts index 4da7a9679f..1f6ba0e817 100644 --- a/models/view/src/index.ts +++ b/models/view/src/index.ts @@ -118,7 +118,8 @@ export class TCollectionEditor extends TClass implements CollectionEditor { @Mixin(view.mixin.ArrayEditor, core.class.Class) export class TArrayEditor extends TClass implements ArrayEditor { - inlineEditor!: AnyComponent + inlineEditor?: AnyComponent + editor?: AnyComponent } @Mixin(view.mixin.AttributePresenter, core.class.Class) diff --git a/packages/presentation/src/components/AttributeBarEditor.svelte b/packages/presentation/src/components/AttributeBarEditor.svelte index d6d13f300a..6e0dc5b91f 100644 --- a/packages/presentation/src/components/AttributeBarEditor.svelte +++ b/packages/presentation/src/components/AttributeBarEditor.svelte @@ -55,6 +55,9 @@ const typeClass = hierarchy.getClass(presenterClass.attrClass) const editorMixin = hierarchy.as(typeClass, mixinRef) + if (category === 'array' && editorMixin.inlineEditor === undefined) { + return + } editor = getResource(editorMixin.inlineEditor).catch((cause) => { console.error(`failed to find editor for ${_class} ${attribute} ${presenterClass.attrClass} cause: ${cause}`) }) diff --git a/plugins/hr-resources/package.json b/plugins/hr-resources/package.json index a852a6d244..ae4cb55e4e 100644 --- a/plugins/hr-resources/package.json +++ b/plugins/hr-resources/package.json @@ -38,6 +38,7 @@ "@anticrm/core": "~0.6.16", "@anticrm/panel": "~0.6.0", "@anticrm/contact": "~0.6.5", + "@anticrm/view": "~0.6.0", "@anticrm/view-resources": "~0.6.0", "@anticrm/contact-resources": "~0.6.0", "@anticrm/setting": "~0.6.1", diff --git a/plugins/hr-resources/src/components/DepartmentCard.svelte b/plugins/hr-resources/src/components/DepartmentCard.svelte index 6462c7fc0b..f20f645261 100644 --- a/plugins/hr-resources/src/components/DepartmentCard.svelte +++ b/plugins/hr-resources/src/components/DepartmentCard.svelte @@ -19,25 +19,19 @@ import CreateDepartment from './CreateDepartment.svelte' import DepartmentCard from './DepartmentCard.svelte' import hr from '../plugin' - import { IconAdd, IconMoreV, Button, eventToHTMLElement, Label, showPopup, ActionIcon } from '@anticrm/ui' + import { IconAdd, IconMoreV, Button, eventToHTMLElement, Label, showPopup, ActionIcon, showPanel } from '@anticrm/ui' import contact, { Employee } from '@anticrm/contact' import { EmployeePresenter } from '@anticrm/contact-resources' - import DepartmentStaff from './DepartmentStaff.svelte' import { Menu } from '@anticrm/view-resources' + import view from '@anticrm/view' export let value: WithLookup export let descendants: Map, WithLookup[]> $: currentDescendants = descendants.get(value._id) ?? [] - let expand = false const client = getClient() - function toggle () { - if (currentDescendants.length === 0) return - expand = !expand - } - async function changeLead (result: Employee | null | undefined): Promise { if (result === undefined) { return @@ -50,6 +44,8 @@ } function openLeadEditor (event: MouseEvent) { + event?.preventDefault() + event?.stopPropagation() showPopup( UsersPopup, { @@ -64,13 +60,7 @@ } function createChild (e: MouseEvent) { - showPopup(CreateDepartment, { space: value._id }, eventToHTMLElement(e), (res) => { - if (res && !expand) expand = true - }) - } - - function editMembers (e: MouseEvent) { - showPopup(DepartmentStaff, { _id: value._id }, 'float') + showPopup(CreateDepartment, { space: value._id }, eventToHTMLElement(e)) } function showMenu (e: MouseEvent) { @@ -82,29 +72,30 @@ } ) } + + function edit (e: MouseEvent): void { + showPanel(view.component.EditDoc, value._id, value._class, 'content') + }
- {#if currentDescendants.length} -
-
- {/if}
+
+
{value.name}
-
-
+
@@ -122,19 +113,16 @@ onEmployeeEdit={openLeadEditor} />
-
-{#if expand && currentDescendants.length} -
- {#each descendants.get(value._id) ?? [] as nested} - - {/each} -
-{/if} +
+ {#each currentDescendants as nested} + + {/each} +
diff --git a/plugins/hr-resources/src/components/EditDepartment.svelte b/plugins/hr-resources/src/components/EditDepartment.svelte index 6752fba7d4..005ad841d0 100644 --- a/plugins/hr-resources/src/components/EditDepartment.svelte +++ b/plugins/hr-resources/src/components/EditDepartment.svelte @@ -14,11 +14,9 @@ --> - + onMount(() => { + dispatch('open', { + ignoreKeys: ['comments', 'name', 'channels', 'private', 'archived'], + collectionArrays: ['members'] + }) + }) + {#if object !== undefined} - _update(ev.detail)} - on:close={() => { - dispatch('close') - }} - > -
-
- {#key object} - - {/key} +
+
+ {#key object} + + {/key} +
+
+
+
-
-
- -
-
-
- -
+
+
+
- +
{/if}