From 54f167805eacd32346dac4ec0fd5c27cd33a21ac Mon Sep 17 00:00:00 2001 From: Vyacheslav Tumanov Date: Tue, 30 Jan 2024 08:59:30 +0500 Subject: [PATCH] UBER-1005: Array> support as custom attribute (#4471) Signed-off-by: Vyacheslav Tumanov --- .github/pull_request_template.md | 2 +- models/contact/src/index.ts | 4 ++ models/hr/src/index.ts | 4 ++ models/recruit/src/index.ts | 4 ++ models/tracker/src/presenters.ts | 4 ++ .../src/components/ContactArrayEditor.svelte | 6 ++- .../src/components/ClassAttributeRow.svelte | 13 ++++- .../components/typeEditors/ArrayEditor.svelte | 7 +-- .../src/components/ArrayEditor.svelte | 52 +++++++++++++++++++ .../src/components/ArrayEditorPopup.svelte | 39 ++++++++++++++ plugins/view-resources/src/index.ts | 2 + plugins/view-resources/src/plugin.ts | 3 +- 12 files changed, 132 insertions(+), 8 deletions(-) create mode 100644 plugins/view-resources/src/components/ArrayEditor.svelte create mode 100644 plugins/view-resources/src/components/ArrayEditorPopup.svelte diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 0793385b4c..a4f7807795 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -7,7 +7,7 @@ * [ ] - UI test added to added/changed functionality? * [ ] - Screenshot is added to PR if applicable ? * [ ] - Does a local formatting is applied (rush format) -* [ ] - Does a local svele-check is applied (rush svelte-check) +* [ ] - Does a local svelte-check is applied (rush svelte-check) * [ ] - Does a local UI tests are executed [UI Testing](../tests/readme.md) * [ ] - Does the code work? Check whether function and logic are correct. * [ ] - Does Changelog.md is updated with changes? diff --git a/models/contact/src/index.ts b/models/contact/src/index.ts index e875c27748..6800ba6aa2 100644 --- a/models/contact/src/index.ts +++ b/models/contact/src/index.ts @@ -715,6 +715,10 @@ export function createModel (builder: Builder): void { presenter: contact.component.OrganizationPresenter }) + builder.mixin(contact.class.Organization, core.class.Class, view.mixin.ArrayEditor, { + inlineEditor: contact.component.ContactArrayEditor + }) + builder.mixin(contact.class.Contact, core.class.Class, view.mixin.ObjectPresenter, { presenter: contact.component.ContactPresenter }) diff --git a/models/hr/src/index.ts b/models/hr/src/index.ts index a3d934975f..ddd4ce7a4f 100644 --- a/models/hr/src/index.ts +++ b/models/hr/src/index.ts @@ -207,6 +207,10 @@ export function createModel (builder: Builder): void { editor: hr.component.EditDepartment }) + builder.mixin(hr.class.Department, core.class.Class, view.mixin.ArrayEditor, { + inlineEditor: view.component.ArrayEditor + }) + builder.mixin(hr.class.Request, core.class.Class, view.mixin.ObjectEditor, { editor: hr.component.EditRequest }) diff --git a/models/recruit/src/index.ts b/models/recruit/src/index.ts index 671943046f..7cf635ab1c 100644 --- a/models/recruit/src/index.ts +++ b/models/recruit/src/index.ts @@ -263,6 +263,10 @@ export function createModel (builder: Builder): void { inlineEditor: recruit.component.VacancyEditor }) + builder.mixin(recruit.class.Vacancy, core.class.Class, view.mixin.ArrayEditor, { + inlineEditor: view.component.ArrayEditor + }) + builder.mixin(recruit.class.Applicant, core.class.Class, notification.mixin.ClassCollaborators, { fields: ['createdBy'] }) diff --git a/models/tracker/src/presenters.ts b/models/tracker/src/presenters.ts index 072e7f4e85..dd60944675 100644 --- a/models/tracker/src/presenters.ts +++ b/models/tracker/src/presenters.ts @@ -122,6 +122,10 @@ export function definePresenters (builder: Builder): void { inlineEditor: tracker.component.ComponentSelector }) + builder.mixin(tracker.class.Component, core.class.Class, view.mixin.ArrayEditor, { + inlineEditor: view.component.ArrayEditor + }) + builder.mixin(tracker.class.Component, core.class.Class, view.mixin.AttributePresenter, { presenter: tracker.component.ComponentRefPresenter }) diff --git a/plugins/contact-resources/src/components/ContactArrayEditor.svelte b/plugins/contact-resources/src/components/ContactArrayEditor.svelte index 9e02ef8846..d69781df4d 100644 --- a/plugins/contact-resources/src/components/ContactArrayEditor.svelte +++ b/plugins/contact-resources/src/components/ContactArrayEditor.svelte @@ -1,14 +1,15 @@ diff --git a/plugins/view-resources/src/components/ArrayEditorPopup.svelte b/plugins/view-resources/src/components/ArrayEditorPopup.svelte new file mode 100644 index 0000000000..49126c7582 --- /dev/null +++ b/plugins/view-resources/src/components/ArrayEditorPopup.svelte @@ -0,0 +1,39 @@ + + + + +
+ + {item.name ?? item.label} + +
+
+
diff --git a/plugins/view-resources/src/index.ts b/plugins/view-resources/src/index.ts index 4543fd9df8..f766ae6240 100644 --- a/plugins/view-resources/src/index.ts +++ b/plugins/view-resources/src/index.ts @@ -18,6 +18,7 @@ import { type Resources } from '@hcengineering/platform' import { getEventPopupPositionElement, type PopupAlignment } from '@hcengineering/ui' import { actionImpl } from './actionImpl' import ActionsPopup from './components/ActionsPopup.svelte' +import ArrayEditor from './components/ArrayEditor.svelte' import BooleanEditor from './components/BooleanEditor.svelte' import BooleanPresenter from './components/BooleanPresenter.svelte' import BooleanTruePresenter from './components/BooleanTruePresenter.svelte' @@ -203,6 +204,7 @@ export default async (): Promise => ({ actionImpl, component: { ArrayFilter, + ArrayEditor, ClassPresenter, ClassRefPresenter, ObjectFilter, diff --git a/plugins/view-resources/src/plugin.ts b/plugins/view-resources/src/plugin.ts index 54c6041a6d..1f2609316d 100644 --- a/plugins/view-resources/src/plugin.ts +++ b/plugins/view-resources/src/plugin.ts @@ -28,7 +28,8 @@ export default mergeIds(viewId, view, { StringFilter: '' as AnyComponent, TimestampFilter: '' as AnyComponent, FilterTypePopup: '' as AnyComponent, - ProxyPresenter: '' as AnyComponent + ProxyPresenter: '' as AnyComponent, + ArrayEditor: '' as AnyComponent }, string: { Contains: '' as IntlString,