From 12f66bc43315b5349d49e9db87b3f0425eb653ba Mon Sep 17 00:00:00 2001 From: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com> Date: Mon, 13 Dec 2021 15:05:46 +0600 Subject: [PATCH] Candidate move (#604) Signed-off-by: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com> --- models/contact/src/index.ts | 4 +- models/contact/src/plugin.ts | 2 + models/recruit/src/index.ts | 37 +++-- models/recruit/src/plugin.ts | 1 + models/view/src/index.ts | 11 ++ models/view/src/plugin.ts | 6 +- packages/core/src/tx.ts | 9 +- packages/presentation/src/index.ts | 1 + packages/ui/src/index.ts | 2 + plugins/recruit-assets/lang/en.json | 3 +- plugins/view-assets/assets/icons.svg | 3 + plugins/view-assets/lang/en.json | 6 + plugins/view-assets/src/index.ts | 7 +- .../view-resources/src/components/Move.svelte | 135 ++++++++++++++++++ plugins/view-resources/src/index.ts | 30 ++-- plugins/view-resources/src/plugin.ts | 26 ++++ plugins/view/src/index.ts | 3 +- 17 files changed, 254 insertions(+), 32 deletions(-) create mode 100644 plugins/view-assets/lang/en.json create mode 100644 plugins/view-resources/src/components/Move.svelte create mode 100644 plugins/view-resources/src/plugin.ts diff --git a/models/contact/src/index.ts b/models/contact/src/index.ts index e8b6edc5c2..94ac4051d2 100644 --- a/models/contact/src/index.ts +++ b/models/contact/src/index.ts @@ -85,11 +85,11 @@ export class TEmployeeAccount extends TAccount implements EmployeeAccount { } @Model(contact.class.Organizations, core.class.Space) -@UX(contact.string.Organizations, contact.icon.Company) +@UX(contact.string.OrganizationsFolder, contact.icon.Company) export class TOrganizations extends TSpace implements Organizations {} @Model(contact.class.Persons, core.class.Space) -@UX(contact.string.Persons, contact.icon.Person) +@UX(contact.string.PersonsFolder, contact.icon.Person) export class TPersons extends TSpace implements Persons {} export function createModel (builder: Builder): void { diff --git a/models/contact/src/plugin.ts b/models/contact/src/plugin.ts index 484297196d..248572b5d2 100644 --- a/models/contact/src/plugin.ts +++ b/models/contact/src/plugin.ts @@ -35,6 +35,8 @@ export const ids = mergeIds(contactId, contact, { }, string: { Organizations: '' as IntlString, + OrganizationsFolder: '' as IntlString, + PersonsFolder: '' as IntlString, Persons: '' as IntlString, Contacts: '' as IntlString, CreatePersons: '' as IntlString, diff --git a/models/recruit/src/index.ts b/models/recruit/src/index.ts index c16f8780e9..d1ba02cf68 100644 --- a/models/recruit/src/index.ts +++ b/models/recruit/src/index.ts @@ -128,7 +128,7 @@ export function createModel (builder: Builder): void { component: recruit.component.EditVacancy }, { - label: recruit.string.CandidatePools, + label: recruit.string.Candidates, spaceClass: recruit.class.Candidates, addSpaceLabel: recruit.string.CreateCandidates, createComponent: recruit.component.CreateCandidates @@ -136,12 +136,17 @@ export function createModel (builder: Builder): void { ] } }) - builder.createDoc(recruit.class.Candidates, core.space.Model, { - name: 'public', - description: 'Public Candidates', - private: false, - members: [] - }, recruit.space.CandidatesPublic) + builder.createDoc( + recruit.class.Candidates, + core.space.Model, + { + name: 'public', + description: 'Public Candidates', + private: false, + members: [] + }, + recruit.space.CandidatesPublic + ) builder.createDoc(view.class.Viewlet, core.space.Model, { attachTo: recruit.class.Candidate, @@ -184,7 +189,8 @@ export function createModel (builder: Builder): void { { presenter: attachment.component.AttachmentsPresenter, label: 'Files' }, { presenter: chunter.component.CommentsPresenter, label: 'Comments' }, 'modifiedOn', - '$lookup.attachedTo.channels'] + '$lookup.attachedTo.channels' + ] }) builder.createDoc(view.class.Viewlet, core.space.Model, { @@ -213,11 +219,16 @@ export function createModel (builder: Builder): void { presenter: recruit.component.ApplicationPresenter }) - builder.createDoc(view.class.Action, core.space.Model, { - label: 'Create application' as IntlString, - icon: recruit.icon.Create, - action: recruit.actionImpl.CreateApplication - }, recruit.action.CreateApplication) + builder.createDoc( + view.class.Action, + core.space.Model, + { + label: 'Create application' as IntlString, + icon: recruit.icon.Create, + action: recruit.actionImpl.CreateApplication + }, + recruit.action.CreateApplication + ) builder.createDoc(view.class.ActionTarget, core.space.Model, { target: recruit.class.Candidate, diff --git a/models/recruit/src/plugin.ts b/models/recruit/src/plugin.ts index 081d61b318..197dd5eec5 100644 --- a/models/recruit/src/plugin.ts +++ b/models/recruit/src/plugin.ts @@ -32,6 +32,7 @@ export default mergeIds(recruitId, recruit, { RecruitApplication: '' as IntlString, Vacancies: '' as IntlString, CandidatePools: '' as IntlString, + Candidates: '' as IntlString, Vacancy: '' as IntlString }, component: { diff --git a/models/view/src/index.ts b/models/view/src/index.ts index 269352b971..fad6c260d7 100644 --- a/models/view/src/index.ts +++ b/models/view/src/index.ts @@ -148,6 +148,17 @@ export function createModel (builder: Builder): void { action: view.action.Delete }) + builder.createDoc(view.class.Action, core.space.Model, { + label: 'Move' as IntlString, + icon: view.icon.Move, + action: view.actionImpl.Move + }, view.action.Move) + + builder.createDoc(view.class.ActionTarget, core.space.Model, { + target: core.class.Doc, + action: view.action.Move + }) + builder.createDoc(core.class.Space, core.space.Model, { name: 'Sequences', description: 'Internal space to store sequence numbers', diff --git a/models/view/src/plugin.ts b/models/view/src/plugin.ts index 58a1d2f0a7..f78cb62d55 100644 --- a/models/view/src/plugin.ts +++ b/models/view/src/plugin.ts @@ -21,10 +21,12 @@ import view, { viewId, Action } from '@anticrm/view' export default mergeIds(viewId, view, { action: { - Delete: '' as Ref + Delete: '' as Ref, + Move: '' as Ref }, actionImpl: { - Delete: '' as Resource<(doc: Doc) => Promise> + Delete: '' as Resource<(doc: Doc) => Promise>, + Move: '' as Resource<(doc: Doc) => Promise> }, component: { StringEditor: '' as AnyComponent, diff --git a/packages/core/src/tx.ts b/packages/core/src/tx.ts index 207151c1ed..76046b6093 100644 --- a/packages/core/src/tx.ts +++ b/packages/core/src/tx.ts @@ -160,7 +160,14 @@ export interface IncOptions { /** * @public */ -export type DocumentUpdate = Partial> & PushOptions & PushMixinOptions & IncOptions +export interface SpaceUpdate { + space?: Ref +} + +/** + * @public + */ +export type DocumentUpdate = Partial> & PushOptions & PushMixinOptions & IncOptions & SpaceUpdate /** * @public diff --git a/packages/presentation/src/index.ts b/packages/presentation/src/index.ts index a9ae507a2a..31f4d11a5a 100644 --- a/packages/presentation/src/index.ts +++ b/packages/presentation/src/index.ts @@ -28,3 +28,4 @@ export { default as Channels } from './components/Channels.svelte' export { default as PDFViewer } from './components/PDFViewer.svelte' export { default as MessageBox } from './components/MessageBox.svelte' export { default as SpaceCreateCard } from './components/SpaceCreateCard.svelte' +export { default as SpaceSelect } from './components/SpaceSelect.svelte' diff --git a/packages/ui/src/index.ts b/packages/ui/src/index.ts index aa1eb2995a..f528393563 100644 --- a/packages/ui/src/index.ts +++ b/packages/ui/src/index.ts @@ -150,3 +150,5 @@ export const ticker = readable(Date.now(), set => { addStringsLoader(uiId, async (lang: string) => { return await import(`../lang/${lang}.json`) }) + +export { default } from './plugin' diff --git a/plugins/recruit-assets/lang/en.json b/plugins/recruit-assets/lang/en.json index f33e5d2da2..933ce554eb 100644 --- a/plugins/recruit-assets/lang/en.json +++ b/plugins/recruit-assets/lang/en.json @@ -2,7 +2,8 @@ "string": { "RecruitApplication": "Recruiting", "Vacancies": "Vacancies", - "CandidatePools": "Candidates", + "CandidatePools": "Candidate’s pool", + "Candidates": "Candidates", "VacancyName": "Vacancy Title *", "VacancyDescription": "Vacancy Description", "CreateVacancy": "Create Vacancy", diff --git a/plugins/view-assets/assets/icons.svg b/plugins/view-assets/assets/icons.svg index c5fc5daf80..c9d6057495 100644 --- a/plugins/view-assets/assets/icons.svg +++ b/plugins/view-assets/assets/icons.svg @@ -25,4 +25,7 @@ + + + diff --git a/plugins/view-assets/lang/en.json b/plugins/view-assets/lang/en.json new file mode 100644 index 0000000000..e7e785221a --- /dev/null +++ b/plugins/view-assets/lang/en.json @@ -0,0 +1,6 @@ +{ + "string": { + "MoveClass": "Move {class}", + "SelectToMove": "Select the {classLabel} you want to move {class} to." + } +} \ No newline at end of file diff --git a/plugins/view-assets/src/index.ts b/plugins/view-assets/src/index.ts index 6174315c0c..33770d4575 100644 --- a/plugins/view-assets/src/index.ts +++ b/plugins/view-assets/src/index.ts @@ -13,12 +13,15 @@ // limitations under the License. // -import { loadMetadata } from '@anticrm/platform' -import view from '@anticrm/view' +import { addStringsLoader, loadMetadata } from '@anticrm/platform' +import view, { viewId } from '@anticrm/view' const icons = require('../assets/icons.svg') loadMetadata(view.icon, { Table: `${icons}#table`, Kanban: `${icons}#kanban`, Delete: `${icons}#delete`, + Move: `${icons}#move` }) + +addStringsLoader(viewId, async (lang: string) => await import(`../lang/${lang}.json`)) diff --git a/plugins/view-resources/src/components/Move.svelte b/plugins/view-resources/src/components/Move.svelte new file mode 100644 index 0000000000..e49c867331 --- /dev/null +++ b/plugins/view-resources/src/components/Move.svelte @@ -0,0 +1,135 @@ + + + +
+
+
+
+
+
+ {#if currentSpace} + + {/if} +
+ +
+ + diff --git a/plugins/view-resources/src/index.ts b/plugins/view-resources/src/index.ts index 6a7c7122f8..3416e8fe1b 100644 --- a/plugins/view-resources/src/index.ts +++ b/plugins/view-resources/src/index.ts @@ -13,8 +13,7 @@ // limitations under the License. // -import type { AttachedDoc, Doc } from '@anticrm/core' -import core from '@anticrm/core' +import type { Doc } from '@anticrm/core' import { Resources } from '@anticrm/platform' import { getClient, MessageBox } from '@anticrm/presentation' import { showPopup } from '@anticrm/ui' @@ -31,25 +30,36 @@ import Table from './components/Table.svelte' import TableView from './components/TableView.svelte' import TimestampPresenter from './components/TimestampPresenter.svelte' import { deleteObject } from './utils' +import MoveView from './components/Move.svelte' export { default as ContextMenu } from './components/Menu.svelte' export { buildModel, getActions, getObjectPresenter } from './utils' export { Table } function Delete (object: Doc): void { - showPopup(MessageBox, { - label: 'Delete object', - message: 'Do you want to delete this object?' - }, undefined, (result) => { - if (result) { - deleteObject(getClient(), object) + showPopup( + MessageBox, + { + label: 'Delete object', + message: 'Do you want to delete this object?' + }, + undefined, + (result) => { + if (result) { + deleteObject(getClient(), object) + } } - }) + ) +} + +async function Move (object: Doc): Promise { + showPopup(MoveView, { object }) } export default async (): Promise => ({ actionImpl: { - Delete + Delete, + Move }, component: { StringEditor, diff --git a/plugins/view-resources/src/plugin.ts b/plugins/view-resources/src/plugin.ts new file mode 100644 index 0000000000..2651392901 --- /dev/null +++ b/plugins/view-resources/src/plugin.ts @@ -0,0 +1,26 @@ +// +// Copyright © 2020, 2021 Anticrm Platform Contributors. +// Copyright © 2021 Hardcore Engineering Inc. +// +// Licensed under the Eclipse Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. You may +// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import { IntlString, mergeIds } from '@anticrm/platform' + +import view, { viewId } from '@anticrm/view' + +export default mergeIds(viewId, view, { + string: { + MoveClass: '' as IntlString, + SelectToMove: '' as IntlString + } +}) diff --git a/plugins/view/src/index.ts b/plugins/view/src/index.ts index be9680548a..81398de648 100644 --- a/plugins/view/src/index.ts +++ b/plugins/view/src/index.ts @@ -159,6 +159,7 @@ export default plugin(viewId, { icon: { Table: '' as Asset, Kanban: '' as Asset, - Delete: '' as Asset + Delete: '' as Asset, + Move: '' as Asset } })