mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-11 04:07:43 +02:00
UBERF-8316 Documents drag and drop (#6769)
Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
//
|
||||
|
||||
import activity from '@hcengineering/activity'
|
||||
import type { Class, CollaborativeDoc, CollectionSize, Domain, Role, RolesAssignment } from '@hcengineering/core'
|
||||
import type { Class, CollaborativeDoc, CollectionSize, Domain, Rank, Role, RolesAssignment } from '@hcengineering/core'
|
||||
import { IndexKind, Account, Ref, AccountRole } from '@hcengineering/core'
|
||||
import {
|
||||
type Document,
|
||||
@@ -130,6 +130,10 @@ export class TDocument extends TAttachedDoc implements Document, Todoable {
|
||||
|
||||
@Prop(Collection(time.class.ToDo), getEmbeddedLabel('Action Items'))
|
||||
todos?: CollectionSize<ToDo>
|
||||
|
||||
@Index(IndexKind.Indexed)
|
||||
@Hidden()
|
||||
rank!: Rank
|
||||
}
|
||||
|
||||
@Model(document.class.DocumentSnapshot, core.class.AttachedDoc, DOMAIN_DOCUMENT)
|
||||
|
||||
@@ -13,16 +13,19 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import { DOMAIN_TX, MeasureMetricsContext } from '@hcengineering/core'
|
||||
import { DOMAIN_TX, MeasureMetricsContext, SortingOrder } from '@hcengineering/core'
|
||||
import { type Document, type Teamspace } from '@hcengineering/document'
|
||||
import {
|
||||
tryMigrate,
|
||||
type MigrateOperation,
|
||||
type MigrationClient,
|
||||
type MigrationUpgradeClient
|
||||
type MigrationUpgradeClient,
|
||||
type MigrateUpdate,
|
||||
type MigrationDocumentQuery,
|
||||
tryMigrate
|
||||
} from '@hcengineering/model'
|
||||
import core, { DOMAIN_SPACE } from '@hcengineering/model-core'
|
||||
import { type Asset } from '@hcengineering/platform'
|
||||
import { makeRank } from '@hcengineering/rank'
|
||||
|
||||
import document, { documentId, DOMAIN_DOCUMENT } from './index'
|
||||
import { loadCollaborativeDoc, saveCollaborativeDoc, yDocCopyXmlField } from '@hcengineering/collaboration'
|
||||
@@ -127,6 +130,30 @@ async function migrateContentField (client: MigrationClient): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
async function migrateRank (client: MigrationClient): Promise<void> {
|
||||
const documents = await client.find<Document>(
|
||||
DOMAIN_DOCUMENT,
|
||||
{
|
||||
_class: document.class.Document,
|
||||
rank: { $exists: false }
|
||||
},
|
||||
{ sort: { name: SortingOrder.Ascending } }
|
||||
)
|
||||
|
||||
let rank = makeRank(undefined, undefined)
|
||||
const operations: { filter: MigrationDocumentQuery<Document>, update: MigrateUpdate<Document> }[] = []
|
||||
|
||||
for (const doc of documents) {
|
||||
operations.push({
|
||||
filter: { _id: doc._id },
|
||||
update: { $set: { rank } }
|
||||
})
|
||||
rank = makeRank(rank, undefined)
|
||||
}
|
||||
|
||||
await client.bulk(DOMAIN_DOCUMENT, operations)
|
||||
}
|
||||
|
||||
export const documentOperation: MigrateOperation = {
|
||||
async migrate (client: MigrationClient): Promise<void> {
|
||||
await tryMigrate(client, documentId, [
|
||||
@@ -145,6 +172,10 @@ export const documentOperation: MigrateOperation = {
|
||||
{
|
||||
state: 'migrateContentField',
|
||||
func: migrateContentField
|
||||
},
|
||||
{
|
||||
state: 'migrateRank',
|
||||
func: migrateRank
|
||||
}
|
||||
])
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user