diff --git a/models/card/src/index.ts b/models/card/src/index.ts index 486d6a972a..ac2883ded3 100644 --- a/models/card/src/index.ts +++ b/models/card/src/index.ts @@ -24,13 +24,15 @@ import { import chunter from '@hcengineering/chunter' import core, { AccountRole, + type Blobs, DOMAIN_MODEL, IndexKind, SortingOrder, type CollectionSize, - type MarkupBlobRef, type Rank, - type Ref + type Ref, + ClassifierKind, + type MarkupBlobRef } from '@hcengineering/core' import { Collection, @@ -75,6 +77,8 @@ export class TCard extends TDoc implements Card { @Prop(TypeCollaborativeDoc(), card.string.Content) content!: MarkupBlobRef + blobs!: Blobs + @Prop(TypeRef(card.class.Card), card.string.Parent) parent?: Ref | null @@ -103,6 +107,62 @@ export * from './migration' export function createModel (builder: Builder): void { builder.createModel(TMasterTag, TTag, TCard, MasterTagEditorSection) + builder.createDoc( + card.class.MasterTag, + core.space.Model, + { + label: attachment.string.File, + extends: card.class.Card, + icon: card.icon.File, + kind: ClassifierKind.CLASS + }, + card.types.File + ) + + builder.mixin(card.types.File, card.class.MasterTag, setting.mixin.Editable, { + value: true + }) + + builder.createDoc(view.class.Viewlet, core.space.Model, { + attachTo: card.types.File, + descriptor: view.viewlet.Table, + configOptions: { + hiddenKeys: ['content', 'title'] + }, + config: [ + '', + '_class', + { key: '', presenter: view.component.RolePresenter, label: card.string.Tags, props: { fullSize: true } }, + 'modifiedOn' + ] + }) + + builder.createDoc(view.class.Viewlet, core.space.Model, { + attachTo: card.types.File, + descriptor: view.viewlet.List, + viewOptions: { + groupBy: ['_class', 'createdBy', 'modifiedBy'], + orderBy: [ + ['modifiedOn', SortingOrder.Descending], + ['rank', SortingOrder.Ascending] + ], + other: [] + }, + configOptions: { + hiddenKeys: ['content', 'title'] + }, + config: [ + { key: '', props: { showParent: true } }, + '_class', + { key: '', presenter: view.component.RolePresenter, label: card.string.Tags, props: { fullSize: true } }, + { key: '', displayProps: { grow: true } }, + { + key: 'modifiedOn', + displayProps: { fixed: 'right', dividerBefore: true } + } + ] + }) + builder.createDoc( workbench.class.Application, core.space.Model, diff --git a/models/presentation/src/index.ts b/models/presentation/src/index.ts index 02bb3b0ff2..3ee5488f95 100644 --- a/models/presentation/src/index.ts +++ b/models/presentation/src/index.ts @@ -13,7 +13,15 @@ // limitations under the License. // -import { DOMAIN_MODEL, type Tx, type Blob, type Class, type Doc, type Ref } from '@hcengineering/core' +import { + DOMAIN_MODEL, + type Tx, + type Blob, + type Class, + type Doc, + type Ref, + type BlobMetadata +} from '@hcengineering/core' import { Mixin, Model, Prop, TypeRef, TypeString, type Builder } from '@hcengineering/model' import core, { TClass, TDoc } from '@hcengineering/model-core' import { type Asset, type IntlString, type Resource } from '@hcengineering/platform' @@ -23,7 +31,6 @@ import { type PresentationMiddlewareFactory } from '@hcengineering/presentation/src/pipeline' import { - type BlobMetadata, type ComponentPointExtension, type CreateExtensionKind, type DocAttributeRule, diff --git a/models/view/src/plugin.ts b/models/view/src/plugin.ts index bb74266cec..5e941f242f 100644 --- a/models/view/src/plugin.ts +++ b/models/view/src/plugin.ts @@ -13,7 +13,7 @@ // limitations under the License. // -import { type Blob, type Doc, type Ref } from '@hcengineering/core' +import { type Blob, type BlobMetadata, type Doc, type Ref } from '@hcengineering/core' import { type IntlString, mergeIds, type Resource } from '@hcengineering/platform' import { type AnyComponent } from '@hcengineering/ui/src/types' import { @@ -23,7 +23,7 @@ import { viewId, type ViewOptionsAction } from '@hcengineering/view' -import { type BlobMetadata, type FileOrBlob, type FilePreviewExtension } from '@hcengineering/presentation/src/types' +import { type FileOrBlob, type FilePreviewExtension } from '@hcengineering/presentation/src/types' import { type PresentationMiddlewareFactory } from '@hcengineering/presentation/src/pipeline' import view from '@hcengineering/view-resources/src/plugin' diff --git a/packages/core/src/classes.ts b/packages/core/src/classes.ts index cc52f7a442..289da90a2d 100644 --- a/packages/core/src/classes.ts +++ b/packages/core/src/classes.ts @@ -601,6 +601,11 @@ export interface Sequence extends Doc { sequence: number } +/** + * @public + */ +export type BlobMetadata = Record + /** * @public * @@ -622,6 +627,18 @@ export interface Blob extends Doc { size: number } +export interface BlobType { + file: Ref + + type: string + + name: string + + metadata?: BlobMetadata +} + +export type Blobs = Record + /** * For every blob will automatically add a lookup. * diff --git a/packages/presentation/src/components/FilePreview.svelte b/packages/presentation/src/components/FilePreview.svelte index 5c988b3c99..393e2298c8 100644 --- a/packages/presentation/src/components/FilePreview.svelte +++ b/packages/presentation/src/components/FilePreview.svelte @@ -13,7 +13,7 @@ // limitations under the License. --> diff --git a/plugins/card-resources/src/components/EditCard.svelte b/plugins/card-resources/src/components/EditCard.svelte index 9881fbc7f8..60fda234c3 100644 --- a/plugins/card-resources/src/components/EditCard.svelte +++ b/plugins/card-resources/src/components/EditCard.svelte @@ -16,31 +16,22 @@ --> + + + +
{ + dragover = true + e.preventDefault() + }} + on:dragleave={() => { + dragover = false + }} + on:drop={fileDrop} +> +
+
+ +
+ + +
{ + inputFile.click() + }} + > +
+
+
diff --git a/plugins/card-resources/src/components/MasterTagAttributes.svelte b/plugins/card-resources/src/components/MasterTagAttributes.svelte index 34910fe02e..361716efbf 100644 --- a/plugins/card-resources/src/components/MasterTagAttributes.svelte +++ b/plugins/card-resources/src/components/MasterTagAttributes.svelte @@ -36,7 +36,7 @@ const client = getClient() const hierarchy = client.getHierarchy() - const label = hierarchy.getClass(value._class).label + $: label = hierarchy.getClass(value._class).label let isCollapsed = false diff --git a/plugins/card-resources/src/components/Navigator.svelte b/plugins/card-resources/src/components/Navigator.svelte index 474faa58e1..4c390871f6 100644 --- a/plugins/card-resources/src/components/Navigator.svelte +++ b/plugins/card-resources/src/components/Navigator.svelte @@ -57,7 +57,8 @@ title, rank: makeRank(lastOne?.rank, undefined), content: '' as MarkupBlobRef, - parentInfo: [] + parentInfo: [], + blobs: {} } const filledData = fillDefaults(hierarchy, data, _class) diff --git a/plugins/card-resources/src/components/icons/UploadDuo.svelte b/plugins/card-resources/src/components/icons/UploadDuo.svelte new file mode 100644 index 0000000000..65e5c54a28 --- /dev/null +++ b/plugins/card-resources/src/components/icons/UploadDuo.svelte @@ -0,0 +1,31 @@ + + + + + + + + + + diff --git a/plugins/card/src/index.ts b/plugins/card/src/index.ts index 6b0cba9b6b..dc704aa774 100644 --- a/plugins/card/src/index.ts +++ b/plugins/card/src/index.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Class, Mixin, Doc, Ref, MarkupBlobRef, Rank, Domain } from '@hcengineering/core' +import { Blobs, Class, Doc, Domain, MarkupBlobRef, Mixin, Rank, Ref } from '@hcengineering/core' import { Asset, IntlString, plugin, Plugin } from '@hcengineering/platform' import type { AnyComponent } from '@hcengineering/ui' @@ -22,10 +22,10 @@ export interface MasterTag extends Class {} export interface Tag extends MasterTag, Mixin {} export interface Card extends Doc { - attachments?: number _class: Ref title: string content: MarkupBlobRef + blobs: Blobs children?: number parentInfo: ParentInfo[] parent?: Ref | null @@ -62,12 +62,16 @@ const cardPlugin = plugin(cardId, { Tag: '' as Ref>, MasterTagEditorSection: '' as Ref> }, + types: { + File: '' as Ref + }, icon: { MasterTags: '' as Asset, MasterTag: '' as Asset, Tag: '' as Asset, Tags: '' as Asset, - Card: '' as Asset + Card: '' as Asset, + File: '' as Asset }, string: { MasterTag: '' as IntlString, diff --git a/plugins/print-resources/src/components/DOCXViewer.svelte b/plugins/print-resources/src/components/DOCXViewer.svelte index fc33340ad4..2640e87575 100644 --- a/plugins/print-resources/src/components/DOCXViewer.svelte +++ b/plugins/print-resources/src/components/DOCXViewer.svelte @@ -4,9 +4,9 @@ -->