From b2d3256df0e8eff217dae2b09be4a6a0fc3f9717 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pete=20An=C3=B8ther?= Date: Tue, 19 Mar 2024 23:39:30 -0300 Subject: [PATCH] EZQMS-602: Moved `Rank` type to core (utilities stay in its own package) (#5019) --- models/core/src/core.ts | 4 + models/core/src/index.ts | 2 + packages/core/lang/en.json | 3 +- packages/core/lang/es.json | 3 +- packages/core/lang/pt.json | 3 +- packages/core/lang/ru.json | 3 +- packages/core/src/classes.ts | 7 + packages/core/src/component.ts | 6 +- packages/kanban/src/components/Kanban.svelte | 3 +- packages/kanban/src/types.ts | 3 +- packages/model/src/dsl.ts | 8 + .../src/components/DraggableList.svelte | 145 ------------------ packages/presentation/src/index.ts | 1 - packages/rank/package.json | 1 + packages/rank/src/types.ts | 7 +- .../src/components/KanbanView.svelte | 6 +- plugins/task/src/index.ts | 5 +- plugins/task/src/utils.ts | 5 +- .../SetParentIssueActionPopup.svelte | 4 +- 19 files changed, 49 insertions(+), 170 deletions(-) delete mode 100644 packages/presentation/src/components/DraggableList.svelte diff --git a/models/core/src/core.ts b/models/core/src/core.ts index f94244d8fe..9048d82221 100644 --- a/models/core/src/core.ts +++ b/models/core/src/core.ts @@ -363,3 +363,7 @@ export class TTypeCollaborativeDoc extends TType {} @UX(core.string.CollaborativeDocVersion) @Model(core.class.TypeCollaborativeDocVersion, core.class.Type) export class TTypeCollaborativeDocVersion extends TType {} + +@UX(core.string.Rank) +@Model(core.class.TypeRank, core.class.Type) +export class TTypeRank extends TType {} diff --git a/models/core/src/index.ts b/models/core/src/index.ts index bed9a3585c..ccdee072f3 100644 --- a/models/core/src/index.ts +++ b/models/core/src/index.ts @@ -60,6 +60,7 @@ import { TTypeIntlString, TTypeMarkup, TTypeNumber, + TTypeRank, TTypeRecord, TTypeRelatedDocument, TTypeString, @@ -122,6 +123,7 @@ export function createModel (builder: Builder): void { TTypeNumber, TTypeBoolean, TTypeString, + TTypeRank, TTypeRecord, TTypeAttachment, TTypeHyperlink, diff --git a/packages/core/lang/en.json b/packages/core/lang/en.json index e74635eda0..ca27201eec 100644 --- a/packages/core/lang/en.json +++ b/packages/core/lang/en.json @@ -34,6 +34,7 @@ "CreatedDate": "Created date", "Status": "Status", "StatusCategory": "Status category", - "Account": "Account" + "Account": "Account", + "Rank": "Rank" } } diff --git a/packages/core/lang/es.json b/packages/core/lang/es.json index 062f8ea515..dbc1f0091a 100644 --- a/packages/core/lang/es.json +++ b/packages/core/lang/es.json @@ -34,6 +34,7 @@ "CreatedDate": "Fecha de creación", "Status": "Estado", "StatusCategory": "Categoría de estado", - "Account": "Cuenta" + "Account": "Cuenta", + "Rank": "Rango" } } diff --git a/packages/core/lang/pt.json b/packages/core/lang/pt.json index 1486aa9879..f8305f3df9 100644 --- a/packages/core/lang/pt.json +++ b/packages/core/lang/pt.json @@ -34,6 +34,7 @@ "CreatedDate": "Data de criação", "Status": "Estado", "StatusCategory": "Categoria de estado", - "Account": "Conta" + "Account": "Conta", + "Rank": "Ranking" } } diff --git a/packages/core/lang/ru.json b/packages/core/lang/ru.json index 2f1ed81976..a67627519d 100644 --- a/packages/core/lang/ru.json +++ b/packages/core/lang/ru.json @@ -34,6 +34,7 @@ "CreatedDate": "Дата создания", "Status": "Статус", "StatusCategory": "Категория статуса", - "Account": "Аккаунт" + "Account": "Аккаунт", + "Rank": "Ранг" } } diff --git a/packages/core/src/classes.ts b/packages/core/src/classes.ts index d442fc3448..f510eec88b 100644 --- a/packages/core/src/classes.ts +++ b/packages/core/src/classes.ts @@ -46,6 +46,13 @@ export type Hyperlink = string */ export type CollectionSize = T[]['length'] +/** + * @public + * + * String representation of {@link https://www.npmjs.com/package/lexorank LexoRank} type + */ +export type Rank = string + /** * @public */ diff --git a/packages/core/src/component.ts b/packages/core/src/component.ts index a72ab3e47b..139abbcabc 100644 --- a/packages/core/src/component.ts +++ b/packages/core/src/component.ts @@ -14,7 +14,7 @@ // import type { IntlString, Plugin, StatusCode } from '@hcengineering/platform' import { plugin } from '@hcengineering/platform' -import { Mixin, Version } from '.' +import { Mixin, type Rank, Version } from '.' import type { Account, AnyAttribute, @@ -101,6 +101,7 @@ export default plugin(coreId, { TypeHyperlink: '' as Ref>>, TypeNumber: '' as Ref>>, TypeMarkup: '' as Ref>>, + TypeRank: '' as Ref>>, TypeRecord: '' as Ref>>>, TypeBoolean: '' as Ref>>, TypeTimestamp: '' as Ref>>, @@ -187,6 +188,7 @@ export default plugin(coreId, { CreatedDate: '' as IntlString, Status: '' as IntlString, Account: '' as IntlString, - StatusCategory: '' as IntlString + StatusCategory: '' as IntlString, + Rank: '' as IntlString } }) diff --git a/packages/kanban/src/components/Kanban.svelte b/packages/kanban/src/components/Kanban.svelte index cf8e31a3ad..8abcce48e6 100644 --- a/packages/kanban/src/components/Kanban.svelte +++ b/packages/kanban/src/components/Kanban.svelte @@ -20,6 +20,7 @@ DocumentQuery, DocumentUpdate, FindOptions, + type Rank, RateLimiter, Ref, Space @@ -99,7 +100,7 @@ const client = getClient() let dragCard: Item | undefined - let dragCardInitialRank: string | undefined + let dragCardInitialRank: Rank | undefined let dragCardInitialState: CategoryType let dragCardInitialPosition: number | undefined let dragCardState: CategoryType | undefined diff --git a/packages/kanban/src/types.ts b/packages/kanban/src/types.ts index 0b53334923..d706f0fca2 100644 --- a/packages/kanban/src/types.ts +++ b/packages/kanban/src/types.ts @@ -1,6 +1,5 @@ -import { type Doc } from '@hcengineering/core' +import { type Doc, type Rank } from '@hcengineering/core' import { type Asset } from '@hcengineering/platform' -import type { Rank } from '@hcengineering/rank' /** * @public diff --git a/packages/model/src/dsl.ts b/packages/model/src/dsl.ts index be7bc7d137..1aaeb7170b 100644 --- a/packages/model/src/dsl.ts +++ b/packages/model/src/dsl.ts @@ -35,6 +35,7 @@ import core, { MixinUpdate, Obj, PropertyType, + Rank, Ref, RefTo, Space, @@ -501,3 +502,10 @@ export function TypeCollaborativeDoc (): Type { export function TypeCollaborativeDocVersion (): Type { return { _class: core.class.TypeCollaborativeDocVersion, label: core.string.CollaborativeDocVersion } } + +/** + * @public + */ +export function TypeRank (): Type { + return { _class: core.class.TypeRank, label: core.string.Rank } +} diff --git a/packages/presentation/src/components/DraggableList.svelte b/packages/presentation/src/components/DraggableList.svelte deleted file mode 100644 index b59d69a193..0000000000 --- a/packages/presentation/src/components/DraggableList.svelte +++ /dev/null @@ -1,145 +0,0 @@ - - - -
- {#each objects as object, index (object._id)} -
- -
draggingIndex && index === hoveringIndex} - class:drag-over-highlight={index === dragOverIndex} - draggable={editable} - on:contextmenu={(ev) => checkIsNotDraft(object) && showContextMenu?.(ev, object)} - on:dragstart={(ev) => { - handleDragStart(ev, index) - }} - on:dragover|preventDefault={() => { - dragOverIndex = index - return false - }} - on:dragenter={() => (hoveringIndex = index)} - on:drop|preventDefault={(ev) => handleDrop(ev, index)} - on:dragend={resetDrag} - > -
-
-
- -
-
- {`${index + 1}.`} -
- -
- -
-
-
- {/each} -
- - diff --git a/packages/presentation/src/index.ts b/packages/presentation/src/index.ts index 3e940ecaa2..4592aba5e7 100644 --- a/packages/presentation/src/index.ts +++ b/packages/presentation/src/index.ts @@ -36,7 +36,6 @@ export { default as SpacesMultiPopup } from './components/SpacesMultiPopup.svelt export { default as ObjectSearchPopup } from './components/ObjectSearchPopup.svelte' export { default as IndexedDocumentPreview } from './components/IndexedDocumentPreview.svelte' export { default as IndexedDocumentCompare } from './components/IndexedDocumentCompare.svelte' -export { default as DraggableList } from './components/DraggableList.svelte' export { default as NavLink } from './components/NavLink.svelte' export { default as IconForward } from './components/icons/Forward.svelte' export { default as Breadcrumbs } from './components/breadcrumbs/Breadcrumbs.svelte' diff --git a/packages/rank/package.json b/packages/rank/package.json index 0d73094e4c..89a60fb92c 100644 --- a/packages/rank/package.json +++ b/packages/rank/package.json @@ -32,6 +32,7 @@ "typescript": "^5.3.3" }, "dependencies": { + "@hcengineering/core": "^0.6.28", "lexorank": "~1.0.4" } } diff --git a/packages/rank/src/types.ts b/packages/rank/src/types.ts index b08e4c17ce..6a7bb43685 100644 --- a/packages/rank/src/types.ts +++ b/packages/rank/src/types.ts @@ -13,9 +13,4 @@ // limitations under the License. // -/** - * @public - * - * String representation of {@link https://www.npmjs.com/package/lexorank LexoRank} type - */ -export type Rank = string +export { type Rank } from '@hcengineering/core' diff --git a/plugins/board-resources/src/components/KanbanView.svelte b/plugins/board-resources/src/components/KanbanView.svelte index 753a744450..0b1c5820de 100644 --- a/plugins/board-resources/src/components/KanbanView.svelte +++ b/plugins/board-resources/src/components/KanbanView.svelte @@ -76,14 +76,14 @@ const selection = listProvider.selection - let resultQuery: DocumentQuery + let resultQuery: DocumentQuery $: resultQuery = { ...query, isArchived: { $nin: [true] }, space } const cardQuery = createQuery() - let cards: DocWithRank[] = [] + let cards: Card[] = [] - $: cardQuery.query( + $: cardQuery.query( _class, getCategoryQueryNoLookup(resultQuery), (result) => { diff --git a/plugins/task/src/index.ts b/plugins/task/src/index.ts index 6a07e18ac1..5f53249a6e 100644 --- a/plugins/task/src/index.ts +++ b/plugins/task/src/index.ts @@ -20,6 +20,7 @@ import { Class, Doc, Mixin, + type Rank, Ref, Space, Status, @@ -29,7 +30,6 @@ import { import { NotificationType } from '@hcengineering/notification' import type { Asset, IntlString, Plugin, Resource } from '@hcengineering/platform' import { plugin } from '@hcengineering/platform' -import type { Rank } from '@hcengineering/rank' import type { AnyComponent, ComponentExtensionId } from '@hcengineering/ui' import { Action, IconProps, ViewletDescriptor } from '@hcengineering/view' @@ -48,7 +48,7 @@ export interface Project extends Space { /** * @public */ -export interface Task extends AttachedDoc, DocWithRank { +export interface Task extends AttachedDoc { kind: Ref status: Ref isDone?: boolean @@ -59,6 +59,7 @@ export interface Task extends AttachedDoc, DocWithRank { attachments?: number labels?: number identifier: string + rank: Rank } /** diff --git a/plugins/task/src/utils.ts b/plugins/task/src/utils.ts index 3d5860714f..55e1ed5b5c 100644 --- a/plugins/task/src/utils.ts +++ b/plugins/task/src/utils.ts @@ -26,16 +26,17 @@ import core, { TxOperations, generateId, type AnyAttribute, + type Rank, type RefTo } from '@hcengineering/core' import { PlatformError, getEmbeddedLabel, unknownStatus } from '@hcengineering/platform' import task, { Project, ProjectStatus, ProjectType, Task, TaskType } from '.' -import { makeRank, type Rank } from '@hcengineering/rank' +import { makeRank } from '@hcengineering/rank' export { genRanks, makeRank } from '@hcengineering/rank' /** - * @public + * @deprecated Prefer {@link makeRank} * * TODO: Drop after everything migrates to {@link makeRank} */ diff --git a/plugins/tracker-resources/src/components/SetParentIssueActionPopup.svelte b/plugins/tracker-resources/src/components/SetParentIssueActionPopup.svelte index 525deabcb7..a0e55b7c45 100644 --- a/plugins/tracker-resources/src/components/SetParentIssueActionPopup.svelte +++ b/plugins/tracker-resources/src/components/SetParentIssueActionPopup.svelte @@ -13,7 +13,7 @@ // limitations under the License. -->