From 602ded464d56029e833c935564cb71f1ccb7397a Mon Sep 17 00:00:00 2001 From: Andrey Sobolev Date: Sat, 28 May 2022 11:06:41 +0700 Subject: [PATCH] HR: Issue fixes 1. Fix Application Labels 2. + Attachment Description/Pinned Signed-off-by: Andrey Sobolev --- models/attachment/package.json | 3 +- models/attachment/src/index.ts | 68 ++++++++++++++++++- models/attachment/src/plugin.ts | 13 +++- models/recruit/src/migration.ts | 14 ++++ models/view/src/index.ts | 14 +++- models/view/src/plugin.ts | 1 + packages/core/src/predicate.ts | 2 +- packages/core/src/storage.ts | 2 +- plugins/attachment-assets/lang/en.json | 6 +- plugins/attachment-assets/lang/ru.json | 6 +- .../src/components/Attachments.svelte | 17 +++-- plugins/attachment-resources/src/index.ts | 22 +++--- plugins/attachment-resources/src/plugin.ts | 8 +-- plugins/attachment/src/index.ts | 2 + plugins/recruit-resources/src/plugin.ts | 3 +- .../src/components/ClassAttributes.svelte | 19 ++++-- .../tags-resources/src/components/Tags.svelte | 8 +-- .../src/components/TagsEditor.svelte | 2 +- .../src/components/TagsPopup.svelte | 6 +- plugins/view-resources/src/actionImpl.ts | 65 +++++++++++++++++- .../components/BooleanTruePresenter.svelte | 36 ++++++++++ plugins/view-resources/src/index.ts | 6 +- plugins/view/src/index.ts | 10 ++- 23 files changed, 285 insertions(+), 48 deletions(-) create mode 100644 plugins/view-resources/src/components/BooleanTruePresenter.svelte diff --git a/models/attachment/package.json b/models/attachment/package.json index 968ff47376..d2a62d37c3 100644 --- a/models/attachment/package.json +++ b/models/attachment/package.json @@ -34,6 +34,7 @@ "@anticrm/model-core": "~0.6.0", "@anticrm/model-view": "~0.6.0", "@anticrm/activity": "~0.6.0", - "@anticrm/model-preference": "~0.6.0" + "@anticrm/model-preference": "~0.6.0", + "@anticrm/view": "~0.6.0" } } diff --git a/models/attachment/src/index.ts b/models/attachment/src/index.ts index 6ef7653714..d05cd616eb 100644 --- a/models/attachment/src/index.ts +++ b/models/attachment/src/index.ts @@ -16,10 +16,10 @@ import activity from '@anticrm/activity' import type { Attachment, Photo, SavedAttachments } from '@anticrm/attachment' import { Domain, IndexKind, Ref } from '@anticrm/core' -import { Builder, Index, Model, Prop, TypeRef, TypeString, TypeTimestamp, UX } from '@anticrm/model' +import { Builder, Index, Model, Prop, TypeBoolean, TypeRef, TypeString, TypeTimestamp, UX } from '@anticrm/model' import core, { TAttachedDoc } from '@anticrm/model-core' -import view from '@anticrm/model-view' import preference, { TPreference } from '@anticrm/model-preference' +import view, { createAction } from '@anticrm/model-view' import attachment from './plugin' export { attachmentOperation } from './migration' @@ -45,6 +45,12 @@ export class TAttachment extends TAttachedDoc implements Attachment { @Prop(TypeTimestamp(), attachment.string.Date) lastModified!: number + + @Prop(TypeString(), attachment.string.Description) + description!: string + + @Prop(TypeBoolean(), attachment.string.Pinned) + pinned!: boolean } @Model(attachment.class.Photo, attachment.class.Attachment) @@ -89,6 +95,64 @@ export function createModel (builder: Builder): void { }, attachment.ids.TxAttachmentCreate ) + + builder.createDoc( + view.class.ActionCategory, + core.space.Model, + { label: attachment.string.Attachments, visible: true }, + attachment.category.Attachments + ) + + createAction(builder, { + action: view.actionImpl.ShowEditor, + actionProps: { + attribute: 'description' + }, + label: attachment.string.Description, + icon: view.icon.Open, + input: 'focus', + category: attachment.category.Attachments, + target: attachment.class.Attachment, + context: { + mode: ['context', 'browser'] + } + }) + + createAction(builder, { + action: view.actionImpl.UpdateDocument, + actionProps: { + key: 'pinned', + value: true + }, + query: { + pinned: { $in: [false, undefined, null] } + }, + label: attachment.string.PinAttachment, + input: 'focus', + category: attachment.category.Attachments, + target: attachment.class.Attachment, + context: { + mode: ['context', 'browser'] + } + }) + + createAction(builder, { + action: view.actionImpl.UpdateDocument, + actionProps: { + key: 'pinned', + value: false + }, + query: { + pinned: true + }, + label: attachment.string.UnPinAttachment, + input: 'focus', + category: attachment.category.Attachments, + target: attachment.class.Attachment, + context: { + mode: ['context', 'browser'] + } + }) } export default attachment diff --git a/models/attachment/src/plugin.ts b/models/attachment/src/plugin.ts index 804c972c84..aaba1d847b 100644 --- a/models/attachment/src/plugin.ts +++ b/models/attachment/src/plugin.ts @@ -13,13 +13,14 @@ // limitations under the License. // +import type { TxViewlet } from '@anticrm/activity' import { attachmentId } from '@anticrm/attachment' import attachment from '@anticrm/attachment-resources/src/plugin' +import type { Ref } from '@anticrm/core' import type { IntlString } from '@anticrm/platform' import { mergeIds } from '@anticrm/platform' -import type { Ref } from '@anticrm/core' import type { AnyComponent } from '@anticrm/ui' -import type { TxViewlet } from '@anticrm/activity' +import type { ActionCategory } from '@anticrm/view' export default mergeIds(attachmentId, attachment, { component: { @@ -34,12 +35,18 @@ export default mergeIds(attachmentId, attachment, { Type: '' as IntlString, Photo: '' as IntlString, Date: '' as IntlString, - SavedAttachments: '' as IntlString + SavedAttachments: '' as IntlString, + Description: '' as IntlString, + PinAttachment: '' as IntlString, + UnPinAttachment: '' as IntlString }, ids: { TxAttachmentCreate: '' as Ref }, activity: { TxAttachmentCreate: '' as AnyComponent + }, + category: { + Attachments: '' as Ref } }) diff --git a/models/recruit/src/migration.ts b/models/recruit/src/migration.ts index 6c2f663eaf..22cc82bd09 100644 --- a/models/recruit/src/migration.ts +++ b/models/recruit/src/migration.ts @@ -92,6 +92,20 @@ async function createDefaults (tx: TxOperations): Promise { await createSequence(tx, recruit.class.Opinion) await createSequence(tx, recruit.class.Applicant) await createDefaultKanbanTemplate(tx) + + await createOrUpdate( + tx, + tags.class.TagCategory, + tags.space.Tags, + { + icon: tags.icon.Tags, + label: 'Text Label', + targetClass: recruit.class.Applicant, + tags: [], + default: true + }, + recruit.category.OtherLabel + ) } async function createDefaultKanbanTemplate (tx: TxOperations): Promise> { diff --git a/models/view/src/index.ts b/models/view/src/index.ts index abde695815..c6a85ad2f7 100644 --- a/models/view/src/index.ts +++ b/models/view/src/index.ts @@ -68,14 +68,16 @@ export function classPresenter ( builder: Builder, _class: Ref>, presenter: AnyComponent, - editor?: AnyComponent + editor?: AnyComponent, + popup?: AnyComponent ): void { builder.mixin(_class, core.class.Class, view.mixin.AttributePresenter, { presenter }) if (editor !== undefined) { builder.mixin(_class, core.class.Class, view.mixin.AttributeEditor, { - editor + editor, + popup }) } } @@ -267,7 +269,13 @@ export function createModel (builder: Builder): void { TLinkPresenter ) - classPresenter(builder, core.class.TypeString, view.component.StringPresenter, view.component.StringEditor) + classPresenter( + builder, + core.class.TypeString, + view.component.StringPresenter, + view.component.StringEditor, + view.component.StringEditorPopup + ) classPresenter(builder, core.class.TypeIntlString, view.component.IntlStringPresenter) classPresenter(builder, core.class.TypeNumber, view.component.NumberPresenter, view.component.NumberEditor) classPresenter(builder, core.class.TypeMarkup, view.component.HTMLPresenter) diff --git a/models/view/src/plugin.ts b/models/view/src/plugin.ts index f78b48640e..7c08339e7c 100644 --- a/models/view/src/plugin.ts +++ b/models/view/src/plugin.ts @@ -64,6 +64,7 @@ export default mergeIds(viewId, view, { ValueFilter: '' as AnyComponent, TimestampFilter: '' as AnyComponent, StringEditor: '' as AnyComponent, + StringEditorPopup: '' as AnyComponent, StringPresenter: '' as AnyComponent, IntlStringPresenter: '' as AnyComponent, NumberEditor: '' as AnyComponent, diff --git a/packages/core/src/predicate.ts b/packages/core/src/predicate.ts index b9510cf467..f450b7d548 100644 --- a/packages/core/src/predicate.ts +++ b/packages/core/src/predicate.ts @@ -76,7 +76,7 @@ const predicates: Record = { $lte: (o, propertyKey) => { return (docs) => execPredicate(docs, propertyKey, (value) => value <= o) }, - $exist: (o, propertyKey) => { + $exists: (o, propertyKey) => { return (docs) => execPredicate(docs, propertyKey, (value) => (value !== undefined) === o) } } diff --git a/packages/core/src/storage.ts b/packages/core/src/storage.ts index 8a7df7fecf..f85d2975f9 100644 --- a/packages/core/src/storage.ts +++ b/packages/core/src/storage.ts @@ -28,7 +28,7 @@ export type QuerySelector = { $gte?: T extends number ? number : never $lt?: T extends number ? number : never $lte?: T extends number ? number : never - $exist?: boolean + $exists?: boolean $like?: string $regex?: string $options?: string diff --git a/plugins/attachment-assets/lang/en.json b/plugins/attachment-assets/lang/en.json index 5b09aac325..eb343789e6 100644 --- a/plugins/attachment-assets/lang/en.json +++ b/plugins/attachment-assets/lang/en.json @@ -44,6 +44,10 @@ "FileBrowserTypeFilterPDFs": "PDFs", "AddAttachmentToSaved": "Add attachment to saved", "RemoveAttachmentFromSaved": "Remove attachment from saved", - "DeleteFile": "Delete file" + "DeleteFile": "Delete file", + "Description": "Description", + "Pinned": "Important", + "PinAttachment": "Mark important", + "UnPinAttachment": "Mark less important" } } diff --git a/plugins/attachment-assets/lang/ru.json b/plugins/attachment-assets/lang/ru.json index abba0344f0..31dc5cc9ed 100644 --- a/plugins/attachment-assets/lang/ru.json +++ b/plugins/attachment-assets/lang/ru.json @@ -44,6 +44,10 @@ "FileBrowserTypeFilterPDFs": "PDF-файлы", "AddAttachmentToSaved": "Добавить вложение в сохраненные", "RemoveAttachmentFromSaved": "Удалить вложение из сохраненных", - "DeleteFile": "Удалить файл" + "DeleteFile": "Удалить файл", + "Description": "Описание", + "Pinned": "Важное", + "PinAttachment": "Пометить как важное", + "UnPinAttachment": "Убрать пометку важное" } } diff --git a/plugins/attachment-resources/src/components/Attachments.svelte b/plugins/attachment-resources/src/components/Attachments.svelte index a4c3de6b2f..7e51fa426d 100644 --- a/plugins/attachment-resources/src/components/Attachments.svelte +++ b/plugins/attachment-resources/src/components/Attachments.svelte @@ -15,13 +15,12 @@ -->
@@ -122,6 +127,7 @@ {#each attributes as attr} + {@const attrType = attr.type._class === core.class.RefTo ? getRefClassTo(attr.type) : undefined} showMenu(ev, attr)}>
@@ -135,9 +141,12 @@