From 168ae1cd54b2d7955d0428ab2663e15d8d4f2552 Mon Sep 17 00:00:00 2001 From: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com> Date: Wed, 29 Jun 2022 11:51:29 +0600 Subject: [PATCH] Inactive employee (#2157) Signed-off-by: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com> --- changelog.md | 5 + models/contact/package.json | 3 +- models/contact/src/index.ts | 20 ++- models/contact/src/migration.ts | 18 ++- models/contact/src/plugin.ts | 13 +- models/demo/src/migration.ts | 3 +- .../src/components/EmployeeBox.svelte | 60 +++++++++ .../src/components/ObjectPopup.svelte | 12 +- .../src/components/SpaceSelect.svelte | 11 +- .../src/components/SpaceSelector.svelte | 12 +- .../src/components/SpacesPopup.svelte | 13 +- .../src/components/UserBox.svelte | 80 ++++-------- .../src/components/UserBoxList.svelte | 25 ++-- .../src/components/UsersPopup.svelte | 14 +- packages/presentation/src/index.ts | 1 + packages/presentation/src/types.ts | 11 +- .../src/components/FileBrowserFilters.svelte | 3 +- .../src/components/KanbanCard.svelte | 9 +- .../src/components/UserBoxList.svelte | 4 +- .../components/editor/CardChecklist.svelte | 7 +- .../src/components/CreateEvent.svelte | 4 +- .../src/components/CreateReminder.svelte | 4 +- .../src/components/AddMembersPopup.svelte | 3 + .../src/components/CreateDirectMessage.svelte | 6 +- plugins/contact-assets/lang/en.json | 4 +- plugins/contact-assets/lang/ru.json | 4 +- plugins/contact-resources/package.json | 3 +- .../src/components/EmployeeArrayEditor.svelte | 20 +-- .../src/components/EmployeeEditor.svelte | 49 +++++++ plugins/contact-resources/src/index.ts | 36 +++++- plugins/contact-resources/src/plugin.ts | 4 +- plugins/contact/src/index.ts | 1 + .../src/components/CreateDepartment.svelte | 9 +- .../src/components/DepartmentCard.svelte | 5 +- .../src/components/DepartmentEditor.svelte | 1 + .../src/components/DepartmentStaff.svelte | 3 + plugins/login-resources/src/utils.ts | 31 +++++ .../src/components/CreateApplication.svelte | 7 +- .../src/components/review/CreateReview.svelte | 2 +- plugins/setting-assets/lang/en.json | 4 +- plugins/setting-assets/lang/ru.json | 4 +- .../src/components/Profile.svelte | 122 +++++++++++------- .../components/typeEditors/EnumPopup.svelte | 11 +- .../components/typeEditors/EnumSelect.svelte | 9 +- plugins/setting-resources/src/plugin.ts | 4 +- .../src/components/AssigneePresenter.svelte | 3 + .../components/issues/AssigneeEditor.svelte | 6 +- .../issues/AssigneePresenter.svelte | 3 + .../components/projects/LeadPresenter.svelte | 3 + .../src/components/projects/NewProject.svelte | 12 +- .../projects/ProjectMembersPresenter.svelte | 3 + plugins/workbench-assets/lang/en.json | 4 +- plugins/workbench-assets/lang/ru.json | 4 +- .../src/components/Workbench.svelte | 12 +- plugins/workbench-resources/src/plugin.ts | 4 +- server-plugins/hr-resources/src/index.ts | 39 +++++- server/account/src/index.ts | 97 ++++++++++++-- 57 files changed, 595 insertions(+), 269 deletions(-) create mode 100644 packages/presentation/src/components/EmployeeBox.svelte create mode 100644 plugins/contact-resources/src/components/EmployeeEditor.svelte diff --git a/changelog.md b/changelog.md index 63e8c9a7a2..3ea9582a2c 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,11 @@ ## 0.6.30 (upcoming) +Core: + +- Allow to leave workspace +- Allow to kick employee + HR: - Allow to change assignee in Kanban diff --git a/models/contact/package.json b/models/contact/package.json index 1d31ab3767..bbbe600da4 100644 --- a/models/contact/package.json +++ b/models/contact/package.json @@ -37,6 +37,7 @@ "@anticrm/ui": "~0.6.0", "@anticrm/platform": "~0.6.6", "@anticrm/contact": "~0.6.5", - "@anticrm/contact-resources": "~0.6.0" + "@anticrm/contact-resources": "~0.6.0", + "@anticrm/view": "~0.6.0" } } diff --git a/models/contact/src/index.ts b/models/contact/src/index.ts index 7983acd031..2fb0d8427b 100644 --- a/models/contact/src/index.ts +++ b/models/contact/src/index.ts @@ -121,6 +121,8 @@ export class TStatus extends TAttachedDoc implements Status { @Model(contact.class.Employee, contact.class.Person) @UX(contact.string.Employee, contact.icon.Person, undefined, 'name') export class TEmployee extends TPerson implements Employee { + active!: boolean + @Prop(Collection(contact.class.Status), contact.string.Status) statuses?: number } @@ -243,7 +245,7 @@ export function createModel (builder: Builder): void { }) builder.mixin(contact.class.Employee, core.class.Class, view.mixin.AttributeEditor, { - inlineEditor: contact.component.PersonEditor + inlineEditor: contact.component.EmployeeEditor }) builder.mixin(contact.class.Channel, core.class.Class, view.mixin.AttributePresenter, { @@ -393,6 +395,22 @@ export function createModel (builder: Builder): void { group: 'create' } }) + + createAction( + builder, + { + action: contact.actionImpl.KickEmployee, + label: contact.string.KickEmployee, + category: contact.category.Contact, + target: contact.class.Employee, + input: 'focus', + context: { + mode: ['context'], + group: 'other' + } + }, + contact.action.KickEmployee + ) } export { contactOperation } from './migration' diff --git a/models/contact/src/migration.ts b/models/contact/src/migration.ts index 007e1d6a5b..708f5e682d 100644 --- a/models/contact/src/migration.ts +++ b/models/contact/src/migration.ts @@ -17,7 +17,7 @@ import { TxOperations } from '@anticrm/core' import { MigrateOperation, MigrationClient, MigrationUpgradeClient } from '@anticrm/model' import core from '@anticrm/model-core' -import contact from './index' +import contact, { DOMAIN_CONTACT } from './index' async function createSpace (tx: TxOperations): Promise { const current = await tx.findOne(core.class.Space, { @@ -56,8 +56,22 @@ async function createSpace (tx: TxOperations): Promise { } } +async function setActiveEmployee (client: MigrationClient): Promise { + await client.update( + DOMAIN_CONTACT, + { + _class: contact.class.Employee + }, + { + active: true + } + ) +} + export const contactOperation: MigrateOperation = { - async migrate (client: MigrationClient): Promise {}, + async migrate (client: MigrationClient): Promise { + await setActiveEmployee(client) + }, async upgrade (client: MigrationUpgradeClient): Promise { const tx = new TxOperations(client, core.account.System) await createSpace(tx) diff --git a/models/contact/src/plugin.ts b/models/contact/src/plugin.ts index 70b8ddb35b..be91e35882 100644 --- a/models/contact/src/plugin.ts +++ b/models/contact/src/plugin.ts @@ -20,6 +20,7 @@ import {} from '@anticrm/core' import { ObjectSearchCategory, ObjectSearchFactory } from '@anticrm/model-presentation' import { IntlString, mergeIds, Resource } from '@anticrm/platform' import type { AnyComponent } from '@anticrm/ui' +import { Action, ActionCategory, ViewAction } from '@anticrm/view' export default mergeIds(contactId, contact, { component: { @@ -38,7 +39,8 @@ export default mergeIds(contactId, contact, { Members: '' as AnyComponent, MemberPresenter: '' as AnyComponent, EditMember: '' as AnyComponent, - EmployeeArrayEditor: '' as AnyComponent + EmployeeArrayEditor: '' as AnyComponent, + EmployeeEditor: '' as AnyComponent }, string: { Persons: '' as IntlString, @@ -71,5 +73,14 @@ export default mergeIds(contactId, contact, { EmployeeCategory: '' as Ref, PersonCategory: '' as Ref, OrganizationCategory: '' as Ref + }, + category: { + Contact: '' as Ref + }, + action: { + KickEmployee: '' as Ref + }, + actionImpl: { + KickEmployee: '' as ViewAction } }) diff --git a/models/demo/src/migration.ts b/models/demo/src/migration.ts index b646e13509..83acec306e 100644 --- a/models/demo/src/migration.ts +++ b/models/demo/src/migration.ts @@ -54,7 +54,8 @@ export const demoOperation: MigrateOperation = { if (current === undefined) { const employee = await tx.createDoc(contact.class.Employee, contact.space.Employee, { name: 'Chen,Rosamund', - city: 'Mountain View' + city: 'Mountain View', + active: true }) await tx.createDoc(contact.class.EmployeeAccount, core.space.Model, { diff --git a/packages/presentation/src/components/EmployeeBox.svelte b/packages/presentation/src/components/EmployeeBox.svelte new file mode 100644 index 0000000000..cf7f836f5e --- /dev/null +++ b/packages/presentation/src/components/EmployeeBox.svelte @@ -0,0 +1,60 @@ + + + + diff --git a/packages/presentation/src/components/ObjectPopup.svelte b/packages/presentation/src/components/ObjectPopup.svelte index 18f1938ac9..e995674ac0 100644 --- a/packages/presentation/src/components/ObjectPopup.svelte +++ b/packages/presentation/src/components/ObjectPopup.svelte @@ -16,7 +16,6 @@ import type { Class, Doc, DocumentQuery, FindOptions, Ref } from '@anticrm/core' import type { IntlString } from '@anticrm/platform' import { - AnyComponent, Button, CheckBox, createFocusManager, @@ -32,6 +31,7 @@ import { createEventDispatcher, afterUpdate } from 'svelte' import presentation from '..' import { createQuery, getClient } from '../utils' + import { ObjectCreate } from '../types' export let _class: Ref> export let options: FindOptions | undefined = undefined @@ -53,13 +53,7 @@ export let groupBy = '_class' - export let create: - | { - component: AnyComponent - label: IntlString - update: (doc: Doc) => string - } - | undefined = undefined + export let create: ObjectCreate | undefined = undefined let search: string = '' let objects: Doc[] = [] @@ -151,7 +145,7 @@ // We expect reference to new object. const newPerson = await client.findOne(_class, { _id: res }) if (newPerson !== undefined) { - search = c.update(newPerson) + search = c.update?.(newPerson) ?? '' } } }) diff --git a/packages/presentation/src/components/SpaceSelect.svelte b/packages/presentation/src/components/SpaceSelect.svelte index ce1ac85709..c07590f96f 100644 --- a/packages/presentation/src/components/SpaceSelect.svelte +++ b/packages/presentation/src/components/SpaceSelect.svelte @@ -23,7 +23,6 @@ Button, eventToHTMLElement, getFocusManager, - AnyComponent, Tooltip, TooltipAlignment, ButtonKind, @@ -33,6 +32,7 @@ import type { Ref, Class, Space, DocumentQuery } from '@anticrm/core' import { createEventDispatcher } from 'svelte' + import { ObjectCreate } from '../types' export let _class: Ref> export let spaceQuery: DocumentQuery | undefined = { archived: false } @@ -40,17 +40,13 @@ export let value: Ref | undefined export let focusIndex = -1 export let focus = false - export let create: - | { - component: AnyComponent - label: IntlString - } - | undefined = undefined + export let create: ObjectCreate | undefined = undefined export let labelDirection: TooltipAlignment | undefined = undefined export let kind: ButtonKind = 'no-border' export let size: ButtonSize = 'small' export let justify: 'left' | 'center' = 'center' export let width: string | undefined = undefined + export let allowDeselect = false let selected: Space | undefined @@ -70,6 +66,7 @@ { _class, label, + allowDeselect, options: { sort: { modifiedOn: -1 } }, selected, spaceQuery, diff --git a/packages/presentation/src/components/SpaceSelector.svelte b/packages/presentation/src/components/SpaceSelector.svelte index 0586d0f6f1..8785ed7c67 100644 --- a/packages/presentation/src/components/SpaceSelector.svelte +++ b/packages/presentation/src/components/SpaceSelector.svelte @@ -15,7 +15,8 @@
- {#if kind !== 'link'} - - {:else} - - {/if} + {:else} +
diff --git a/packages/presentation/src/components/UserBoxList.svelte b/packages/presentation/src/components/UserBoxList.svelte index c7e7a67aab..ab79c59558 100644 --- a/packages/presentation/src/components/UserBoxList.svelte +++ b/packages/presentation/src/components/UserBoxList.svelte @@ -13,20 +13,22 @@ // limitations under the License. --> - + diff --git a/plugins/board-resources/src/components/editor/CardChecklist.svelte b/plugins/board-resources/src/components/editor/CardChecklist.svelte index c61292d39e..62f91e4780 100644 --- a/plugins/board-resources/src/components/editor/CardChecklist.svelte +++ b/plugins/board-resources/src/components/editor/CardChecklist.svelte @@ -14,7 +14,7 @@ --> - + diff --git a/plugins/contact-resources/src/components/EmployeeEditor.svelte b/plugins/contact-resources/src/components/EmployeeEditor.svelte new file mode 100644 index 0000000000..597fc40dd5 --- /dev/null +++ b/plugins/contact-resources/src/components/EmployeeEditor.svelte @@ -0,0 +1,49 @@ + + + + onChange(e.detail)} +/> diff --git a/plugins/contact-resources/src/index.ts b/plugins/contact-resources/src/index.ts index 3e1ed64dea..fb1ff7f73f 100644 --- a/plugins/contact-resources/src/index.ts +++ b/plugins/contact-resources/src/index.ts @@ -14,10 +14,11 @@ // limitations under the License. // -import { Contact, formatName } from '@anticrm/contact' +import { Contact, Employee, formatName } from '@anticrm/contact' import { Class, Client, Ref } from '@anticrm/core' import { Resources } from '@anticrm/platform' -import { Avatar, ObjectSearchResult, UserInfo } from '@anticrm/presentation' +import { Avatar, getClient, MessageBox, ObjectSearchResult, UserInfo } from '@anticrm/presentation' +import { showPopup } from '@anticrm/ui' import Channels from './components/Channels.svelte' import ChannelsEditor from './components/ChannelsEditor.svelte' import ChannelsPresenter from './components/ChannelsPresenter.svelte' @@ -45,6 +46,8 @@ import Members from './components/Members.svelte' import MemberPresenter from './components/MemberPresenter.svelte' import EditMember from './components/EditMember.svelte' import EmployeeArrayEditor from './components/EmployeeArrayEditor.svelte' +import EmployeeEditor from './components/EmployeeEditor.svelte' +import { leaveWorkspace } from '@anticrm/login-resources' export { Channels, @@ -55,7 +58,8 @@ export { ChannelsDropdown, EmployeePresenter, EmployeeBrowser, - MemberPresenter + MemberPresenter, + EmployeeEditor } async function queryContact ( @@ -73,7 +77,30 @@ async function queryContact ( })) } +async function kickEmployee (doc: Employee): Promise { + const client = getClient() + const email = await client.findOne(contact.class.EmployeeAccount, { employee: doc._id }) + if (email === undefined) return + showPopup( + MessageBox, + { + label: contact.string.KickEmployee, + message: contact.string.KickEmployeeDescr + }, + undefined, + (res?: boolean) => { + if (res === true) { + // eslint-disable-next-line @typescript-eslint/no-floating-promises + leaveWorkspace(email.email) + } + } + ) +} + export default async (): Promise => ({ + actionImpl: { + KickEmployee: kickEmployee + }, component: { PersonEditor, OrganizationEditor, @@ -94,7 +121,8 @@ export default async (): Promise => ({ Members, MemberPresenter, EditMember, - EmployeeArrayEditor + EmployeeArrayEditor, + EmployeeEditor }, completion: { EmployeeQuery: async (client: Client, query: string) => await queryContact(contact.class.Employee, client, query), diff --git a/plugins/contact-resources/src/plugin.ts b/plugins/contact-resources/src/plugin.ts index 3ea448cfd3..bac95ff278 100644 --- a/plugins/contact-resources/src/plugin.ts +++ b/plugins/contact-resources/src/plugin.ts @@ -56,6 +56,8 @@ export default mergeIds(contactId, contact, { Member: '' as IntlString, Members: '' as IntlString, NoMembers: '' as IntlString, - AddMember: '' as IntlString + AddMember: '' as IntlString, + KickEmployee: '' as IntlString, + KickEmployeeDescr: '' as IntlString } }) diff --git a/plugins/contact/src/index.ts b/plugins/contact/src/index.ts index 8ef65f5215..5187d056fb 100644 --- a/plugins/contact/src/index.ts +++ b/plugins/contact/src/index.ts @@ -105,6 +105,7 @@ export interface Status extends AttachedDoc { * @public */ export interface Employee extends Person { + active: boolean statuses?: number } diff --git a/plugins/hr-resources/src/components/CreateDepartment.svelte b/plugins/hr-resources/src/components/CreateDepartment.svelte index 501b953790..2000a19e25 100644 --- a/plugins/hr-resources/src/components/CreateDepartment.svelte +++ b/plugins/hr-resources/src/components/CreateDepartment.svelte @@ -13,9 +13,9 @@ // limitations under the License. --> @@ -80,51 +97,62 @@
- {#if employee} -
-
- -
-
-
-
- { - changeName(firstName, lastName) - }} - /> -
-
- { - changeName(firstName, lastName) - }} - /> -
-
- -
+
+ {#if employee} +
+
+ +
+
+
+
+ { + changeName(firstName, lastName) + }} + /> +
+
+ { + changeName(firstName, lastName) + }} + /> +
+
+ +
+
+
+
-
-
+ {/if} + - {/if} +
diff --git a/plugins/setting-resources/src/components/typeEditors/EnumPopup.svelte b/plugins/setting-resources/src/components/typeEditors/EnumPopup.svelte index bf125d0dd0..bd5e6b817e 100644 --- a/plugins/setting-resources/src/components/typeEditors/EnumPopup.svelte +++ b/plugins/setting-resources/src/components/typeEditors/EnumPopup.svelte @@ -14,19 +14,12 @@ --> {#if value} - -{#if client} +{#if employee?.active === true} @@ -426,9 +427,7 @@ showPopup(AccountPopup, {}, 'account') }} > - {#if employee} - - {/if} +
@@ -507,7 +506,10 @@ {:else} - No client +
+

+
{/if}