diff --git a/models/attachment/src/index.ts b/models/attachment/src/index.ts index 274cc3dffa..6ef7653714 100644 --- a/models/attachment/src/index.ts +++ b/models/attachment/src/index.ts @@ -64,6 +64,10 @@ export function createModel (builder: Builder): void { presenter: attachment.component.AttachmentPresenter }) + builder.mixin(attachment.class.Attachment, core.class.Class, view.mixin.CollectionPresenter, { + presenter: attachment.component.AttachmentsPresenter + }) + builder.mixin(attachment.class.Attachment, core.class.Class, view.mixin.CollectionEditor, { editor: attachment.component.Attachments }) diff --git a/models/board/src/index.ts b/models/board/src/index.ts index 520175fe52..4fdb018e3f 100644 --- a/models/board/src/index.ts +++ b/models/board/src/index.ts @@ -105,7 +105,7 @@ export class TCard extends TTask implements Card { @Prop(Collection(chunter.class.Comment), chunter.string.Comments) comments?: number - @Prop(Collection(attachment.class.Attachment), attachment.string.Attachments) + @Prop(Collection(attachment.class.Attachment), attachment.string.Attachments, undefined, attachment.string.Files) attachments?: number @Prop(TypeRef(contact.class.Employee), board.string.Assignee) diff --git a/models/calendar/src/index.ts b/models/calendar/src/index.ts index 2df8a5e354..685f3ec771 100644 --- a/models/calendar/src/index.ts +++ b/models/calendar/src/index.ts @@ -72,7 +72,7 @@ export class TEvent extends TAttachedDoc implements Event { @Prop(TypeDate(true), calendar.string.DueTo) dueDate!: Timestamp - @Prop(Collection(attachment.class.Attachment), attachment.string.Attachments) + @Prop(Collection(attachment.class.Attachment), attachment.string.Attachments, undefined, attachment.string.Files) attachments?: number @Prop(Collection(chunter.class.Comment), chunter.string.Comments) diff --git a/models/chunter/src/index.ts b/models/chunter/src/index.ts index a5e224feb5..605de85b48 100644 --- a/models/chunter/src/index.ts +++ b/models/chunter/src/index.ts @@ -79,7 +79,7 @@ export class TChunterMessage extends TAttachedDoc implements ChunterMessage { @Index(IndexKind.FullText) content!: string - @Prop(Collection(attachment.class.Attachment), attachment.string.Attachments) + @Prop(Collection(attachment.class.Attachment), attachment.string.Attachments, undefined, attachment.string.Files) attachments?: number @Prop(TypeRef(core.class.Account), chunter.string.CreateBy) @@ -119,7 +119,7 @@ export class TComment extends TAttachedDoc implements Comment { @Index(IndexKind.FullText) message!: string - @Prop(Collection(attachment.class.Attachment), attachment.string.Attachments) + @Prop(Collection(attachment.class.Attachment), attachment.string.Attachments, undefined, attachment.string.Files) attachments?: number } @@ -373,6 +373,10 @@ export function createModel (builder: Builder): void { presenter: chunter.component.CommentPresenter }) + builder.mixin(chunter.class.Comment, core.class.Class, view.mixin.CollectionPresenter, { + presenter: chunter.component.CommentsPresenter + }) + builder.createDoc( activity.class.TxViewlet, core.space.Model, diff --git a/models/contact/src/index.ts b/models/contact/src/index.ts index 5403c6b94b..575a80ad03 100644 --- a/models/contact/src/index.ts +++ b/models/contact/src/index.ts @@ -59,7 +59,7 @@ export class TContact extends TDoc implements Contact { @Prop(Collection(contact.class.Channel), contact.string.ContactInfo) channels?: number - @Prop(Collection(attachment.class.Attachment), attachment.string.Attachments) + @Prop(Collection(attachment.class.Attachment), attachment.string.Attachments, undefined, attachment.string.Files) attachments?: number @Prop(Collection(chunter.class.Comment), chunter.string.Comments) @@ -164,12 +164,7 @@ export function createModel (builder: Builder): void { '', { key: '$lookup._class.label', label: contact.string.TypeLabel }, 'city', - { - key: '', - presenter: attachment.component.AttachmentsPresenter, - label: attachment.string.Files, - sortingKey: 'attachments' - }, + 'attachments', 'modifiedOn', { key: '', presenter: view.component.RolePresenter, label: view.string.Role }, '$lookup.channels' diff --git a/models/gmail/src/index.ts b/models/gmail/src/index.ts index c1af64e64a..306d73c313 100644 --- a/models/gmail/src/index.ts +++ b/models/gmail/src/index.ts @@ -68,7 +68,7 @@ export class TMessage extends TAttachedDoc implements Message { @Prop(TypeBoolean(), gmail.string.Incoming) incoming!: boolean - @Prop(Collection(attachment.class.Attachment), attachment.string.Attachments) + @Prop(Collection(attachment.class.Attachment), attachment.string.Attachments, undefined, attachment.string.Files) attachments?: number @Prop(TypeTimestamp(), core.string.Modified) @@ -99,7 +99,7 @@ export class TNewMessage extends TDoc implements NewMessage { @Prop(ArrOf(TypeString()), gmail.string.Copy) copy?: string[] - @Prop(Collection(attachment.class.Attachment), attachment.string.Attachments) + @Prop(Collection(attachment.class.Attachment), attachment.string.Attachments, undefined, attachment.string.Files) attachments?: number } diff --git a/models/inventory/src/index.ts b/models/inventory/src/index.ts index 9b5dc86f59..05a149407f 100644 --- a/models/inventory/src/index.ts +++ b/models/inventory/src/index.ts @@ -50,7 +50,7 @@ export class TProduct extends TAttachedDoc implements Product { @Prop(Collection(inventory.class.Variant), inventory.string.Variants) variants?: number - @Prop(Collection(attachment.class.Attachment), attachment.string.Attachments) + @Prop(Collection(attachment.class.Attachment), attachment.string.Attachments, undefined, attachment.string.Files) attachments?: number } diff --git a/models/lead/src/index.ts b/models/lead/src/index.ts index 5f45fdf90e..2003b6f936 100644 --- a/models/lead/src/index.ts +++ b/models/lead/src/index.ts @@ -44,7 +44,7 @@ export class TLead extends TTask implements Lead { @Prop(Collection(chunter.class.Comment), chunter.string.Comments) comments?: number - @Prop(Collection(attachment.class.Attachment), attachment.string.Attachments) + @Prop(Collection(attachment.class.Attachment), attachment.string.Attachments, undefined, attachment.string.Files) attachments?: number @Prop(TypeRef(contact.class.Employee), lead.string.Assignee) @@ -139,18 +139,8 @@ export function createModel (builder: Builder): void { '$lookup.attachedTo', '$lookup.state', '$lookup.doneState', - { - key: '', - presenter: attachment.component.AttachmentsPresenter, - label: attachment.string.Files, - sortingKey: 'attachments' - }, - { - key: '', - presenter: chunter.component.CommentsPresenter, - label: chunter.string.Comments, - sortingKey: 'comments' - }, + 'attachments', + 'comments', 'modifiedOn', '$lookup.attachedTo.$lookup.channels' ] diff --git a/models/recruit/src/index.ts b/models/recruit/src/index.ts index 8327641694..5c08932b67 100644 --- a/models/recruit/src/index.ts +++ b/models/recruit/src/index.ts @@ -53,7 +53,7 @@ export class TVacancy extends TSpaceWithStates implements Vacancy { @Index(IndexKind.FullText) fullDescription?: string - @Prop(Collection(attachment.class.Attachment), attachment.string.Attachments) + @Prop(Collection(attachment.class.Attachment), attachment.string.Attachments, undefined, attachment.string.Files) attachments?: number @Prop(TypeDate(), recruit.string.Due, recruit.icon.Calendar) @@ -81,7 +81,7 @@ export class TCandidate extends TPerson implements Candidate { @Index(IndexKind.FullText) title?: string - @Prop(Collection(recruit.class.Applicant), recruit.string.Applications) + @Prop(Collection(recruit.class.Applicant), recruit.string.Applications, undefined, recruit.string.ApplicationsShort) applications?: number @Prop(TypeBoolean(), recruit.string.Onsite) @@ -112,7 +112,7 @@ export class TApplicant extends TTask implements Applicant { @Prop(TypeRef(recruit.class.Vacancy), recruit.string.Vacancy) declare space: Ref - @Prop(Collection(attachment.class.Attachment), attachment.string.Attachments) + @Prop(Collection(attachment.class.Attachment), attachment.string.Attachments, undefined, attachment.string.Files) attachments?: number @Prop(Collection(chunter.class.Comment), chunter.string.Comments) @@ -240,24 +240,9 @@ export function createModel (builder: Builder): void { '', 'title', 'city', - { - key: '', - presenter: recruit.component.ApplicationsPresenter, - label: recruit.string.ApplicationsShort, - sortingKey: 'applications' - }, - { - key: '', - presenter: attachment.component.AttachmentsPresenter, - label: attachment.string.Files, - sortingKey: 'attachments' - }, - { - key: '', - presenter: chunter.component.CommentsPresenter, - label: chunter.string.Comments, - sortingKey: 'comments' - }, + 'applications', + 'attachments', + 'comments', { // key: '$lookup.skills', // Required, since presenter require list of tag references or '' and TagsPopupPresenter key: '', @@ -284,18 +269,8 @@ export function createModel (builder: Builder): void { '$lookup.assignee', '$lookup.state', '$lookup.doneState', - { - key: '', - presenter: attachment.component.AttachmentsPresenter, - label: attachment.string.Files, - sortingKey: 'attachments' - }, - { - key: '', - presenter: chunter.component.CommentsPresenter, - label: chunter.string.Comments, - sortingKey: 'comments' - }, + 'attachments', + 'comments', 'modifiedOn', '$lookup.attachedTo.$lookup.channels' ] @@ -339,6 +314,10 @@ export function createModel (builder: Builder): void { presenter: recruit.component.ApplicationPresenter }) + builder.mixin(recruit.class.Applicant, core.class.Class, view.mixin.CollectionPresenter, { + presenter: recruit.component.ApplicationsPresenter + }) + builder.mixin(recruit.class.Vacancy, core.class.Class, view.mixin.AttributePresenter, { presenter: recruit.component.VacancyPresenter }) diff --git a/models/recruit/src/review-model.ts b/models/recruit/src/review-model.ts index 0fe1650db9..671b559aed 100644 --- a/models/recruit/src/review-model.ts +++ b/models/recruit/src/review-model.ts @@ -41,7 +41,7 @@ export class TOpinion extends TAttachedDoc implements Opinion { @Prop(TypeRef(recruit.class.Review), recruit.string.Review) declare attachedTo: Ref - @Prop(Collection(attachment.class.Attachment), attachment.string.Attachments) + @Prop(Collection(attachment.class.Attachment), attachment.string.Attachments, undefined, attachment.string.Files) attachments?: number @Prop(Collection(chunter.class.Comment), chunter.string.Comments) diff --git a/models/task/src/index.ts b/models/task/src/index.ts index fad5c80615..e47db5668b 100644 --- a/models/task/src/index.ts +++ b/models/task/src/index.ts @@ -164,7 +164,7 @@ export class TIssue extends TTask implements Issue { @Prop(Collection(chunter.class.Comment), task.string.TaskComments) comments!: number - @Prop(Collection(attachment.class.Attachment), attachment.string.Attachments) + @Prop(Collection(attachment.class.Attachment), attachment.string.Attachments, undefined, attachment.string.Files) attachments!: number @Prop(TypeString(), task.string.TaskLabels) @@ -341,18 +341,8 @@ export function createModel (builder: Builder): void { '$lookup.assignee', '$lookup.state', '$lookup.doneState', - { - key: '', - presenter: attachment.component.AttachmentsPresenter, - label: attachment.string.Files, - sortingKey: 'attachments' - }, - { - key: '', - presenter: chunter.component.CommentsPresenter, - label: chunter.string.Comments, - sortingKey: 'comments' - }, + 'attachments', + 'comments', 'modifiedOn' ] }) diff --git a/models/telegram/src/index.ts b/models/telegram/src/index.ts index 90e07c75f2..0dcbcbb809 100644 --- a/models/telegram/src/index.ts +++ b/models/telegram/src/index.ts @@ -48,7 +48,7 @@ export class TTelegramMessage extends TAttachedDoc implements TelegramMessage { @Prop(TypeBoolean(), telegram.string.Incoming) incoming!: boolean - @Prop(Collection(attachment.class.Attachment), attachment.string.Attachments) + @Prop(Collection(attachment.class.Attachment), attachment.string.Attachments, undefined, attachment.string.Files) attachments?: number @Prop(TypeTimestamp(), core.string.Modified) @@ -64,7 +64,7 @@ export class TNewTelegramMessage extends TAttachedDoc implements NewTelegramMess @Prop(TypeString(), telegram.string.Status) status!: 'new' | 'sent' - @Prop(Collection(attachment.class.Attachment), attachment.string.Attachments) + @Prop(Collection(attachment.class.Attachment), attachment.string.Attachments, undefined, attachment.string.Files) attachments?: number } diff --git a/models/tracker/src/index.ts b/models/tracker/src/index.ts index feb3e13e2b..ed1be2582c 100644 --- a/models/tracker/src/index.ts +++ b/models/tracker/src/index.ts @@ -233,7 +233,7 @@ export class TProject extends TDoc implements Project { @Prop(Collection(tracker.class.Document), tracker.string.Document) documents!: number - @Prop(Collection(attachment.class.Attachment), attachment.string.Attachments) + @Prop(Collection(attachment.class.Attachment), attachment.string.Attachments, undefined, attachment.string.Files) attachments?: number @Prop(TypeDate(true), tracker.string.Project) diff --git a/models/view/src/index.ts b/models/view/src/index.ts index 92672491d6..11f8731137 100644 --- a/models/view/src/index.ts +++ b/models/view/src/index.ts @@ -28,6 +28,7 @@ import type { BuildModelKey, ClassFilters, CollectionEditor, + CollectionPresenter, HTMLPresenter, IgnoreActions, KeyBinding, @@ -94,6 +95,11 @@ export class TAttributeEditor extends TClass implements AttributeEditor { editor!: AnyComponent } +@Mixin(view.mixin.CollectionPresenter, core.class.Class) +export class TCollectionPresenter extends TClass implements CollectionPresenter { + presenter!: AnyComponent +} + @Mixin(view.mixin.CollectionEditor, core.class.Class) export class TCollectionEditor extends TClass implements CollectionEditor { editor!: AnyComponent @@ -242,6 +248,7 @@ export function createModel (builder: Builder): void { TAttributeEditor, TAttributePresenter, TCollectionEditor, + TCollectionPresenter, TObjectEditor, TViewletPreference, TViewletDescriptor, diff --git a/packages/core/src/classes.ts b/packages/core/src/classes.ts index dd8244a520..37c53e8300 100644 --- a/packages/core/src/classes.ts +++ b/packages/core/src/classes.ts @@ -98,6 +98,7 @@ export interface Attribute extends Doc, UXObject { name: string type: Type index?: IndexKind + shortLabel?: IntlString isCustom?: boolean } diff --git a/packages/model/src/dsl.ts b/packages/model/src/dsl.ts index 6fd05bf265..cd4827c7fe 100644 --- a/packages/model/src/dsl.ts +++ b/packages/model/src/dsl.ts @@ -119,7 +119,7 @@ function getAttrs (target: any, prop: string): Record { * @param icon - * @returns */ -export function Prop (type: Type, label: IntlString, icon?: Asset) { +export function Prop (type: Type, label: IntlString, icon?: Asset, shortLabel?: IntlString) { return function (target: any, propertyKey: string): void { const txes = getTxes(target) const tx: NoIDs>> = { @@ -135,6 +135,7 @@ export function Prop (type: Type, label: IntlString, icon?: Asset) type, label, icon, + shortLabel, attributeOf: txes._id, // undefined, need to fix later ...getAttrs(target, propertyKey) } diff --git a/plugins/attachment-resources/src/components/AttachmentsPresenter.svelte b/plugins/attachment-resources/src/components/AttachmentsPresenter.svelte index 1a1c027fa8..9bf95c85ff 100644 --- a/plugins/attachment-resources/src/components/AttachmentsPresenter.svelte +++ b/plugins/attachment-resources/src/components/AttachmentsPresenter.svelte @@ -19,21 +19,22 @@ import AttachmentPopup from './AttachmentPopup.svelte' import attachment from '../plugin' - export let value: Doc & { attachments?: number } + export let value: number | undefined + export let object: Doc export let size: 'small' | 'medium' | 'large' = 'small' export let showCounter = true -{#if value && value.attachments && value.attachments > 0} +{#if value && value > 0}
{#if showCounter} -  {value.attachments} +  {value} {/if}
diff --git a/plugins/board-resources/src/components/KanbanCard.svelte b/plugins/board-resources/src/components/KanbanCard.svelte index 2649272e35..3af9048907 100644 --- a/plugins/board-resources/src/components/KanbanCard.svelte +++ b/plugins/board-resources/src/components/KanbanCard.svelte @@ -179,12 +179,12 @@ {/if} {#if (object.attachments ?? 0) > 0}
- +
{/if} {#if (object.comments ?? 0) > 0}
- +
{/if} {#if (object.todoItems ?? 0) > 0} diff --git a/plugins/chunter-resources/src/components/CommentsPresenter.svelte b/plugins/chunter-resources/src/components/CommentsPresenter.svelte index 9a90b3f4c7..789e01b549 100644 --- a/plugins/chunter-resources/src/components/CommentsPresenter.svelte +++ b/plugins/chunter-resources/src/components/CommentsPresenter.svelte @@ -19,17 +19,18 @@ import CommentPopup from './CommentPopup.svelte' import chunter from '@anticrm/chunter' - export let value: Doc & { comments?: number } + export let value: number | undefined + export let object: Doc export let size: 'small' | 'medium' | 'large' = 'small' export let showCounter = true -{#if value && value.comments && value.comments > 0} - +{#if value && value > 0} +
{#if showCounter} -  {value.comments} +  {value} {/if}
diff --git a/plugins/gmail-resources/src/components/Message.svelte b/plugins/gmail-resources/src/components/Message.svelte index 077b42cbe4..fd45377abd 100644 --- a/plugins/gmail-resources/src/components/Message.svelte +++ b/plugins/gmail-resources/src/components/Message.svelte @@ -41,7 +41,7 @@ {message.sender}
- + {getTime(message.sendOn)}
diff --git a/plugins/lead-resources/src/components/KanbanCard.svelte b/plugins/lead-resources/src/components/KanbanCard.svelte index 7bfcae38bd..b297edc693 100644 --- a/plugins/lead-resources/src/components/KanbanCard.svelte +++ b/plugins/lead-resources/src/components/KanbanCard.svelte @@ -62,12 +62,12 @@
{#if (object.attachments ?? 0) > 0}
- +
{/if} {#if (object.comments ?? 0) > 0}
- +
{/if}
diff --git a/plugins/recruit-resources/src/components/Applications.svelte b/plugins/recruit-resources/src/components/Applications.svelte index d6083c184b..799a80d757 100644 --- a/plugins/recruit-resources/src/components/Applications.svelte +++ b/plugins/recruit-resources/src/components/Applications.svelte @@ -13,8 +13,6 @@ // limitations under the License. --> -{#if value.applications && value.applications > 0} - +{#if value && value > 0} +
-  {value.applications} +  {value}
{/if} diff --git a/plugins/recruit-resources/src/components/CandidateCard.svelte b/plugins/recruit-resources/src/components/CandidateCard.svelte index c5285d366d..a008e8f300 100644 --- a/plugins/recruit-resources/src/components/CandidateCard.svelte +++ b/plugins/recruit-resources/src/components/CandidateCard.svelte @@ -58,11 +58,11 @@
{#if channels[0]} diff --git a/plugins/recruit-resources/src/components/KanbanCard.svelte b/plugins/recruit-resources/src/components/KanbanCard.svelte index 20fa1c4d81..55aadd8f90 100644 --- a/plugins/recruit-resources/src/components/KanbanCard.svelte +++ b/plugins/recruit-resources/src/components/KanbanCard.svelte @@ -67,12 +67,12 @@ {#if (object.attachments ?? 0) > 0}
- +
{/if} {#if (object.comments ?? 0) > 0}
- +
{/if} diff --git a/plugins/task-resources/src/components/AssignedTasks.svelte b/plugins/task-resources/src/components/AssignedTasks.svelte index 0e331ce19d..1712804687 100644 --- a/plugins/task-resources/src/components/AssignedTasks.svelte +++ b/plugins/task-resources/src/components/AssignedTasks.svelte @@ -13,8 +13,6 @@ // limitations under the License. -->