add $move descriptor

Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
Andrey Platov 2021-10-09 13:17:00 +02:00
parent 4f4d2f8e48
commit fe2d8176f1
No known key found for this signature in database
GPG Key ID: C8787EFEB4B64AF0
2 changed files with 16 additions and 1 deletions

View File

@ -85,6 +85,14 @@ export interface Position<X extends PropertyType> {
$position: number $position: number
} }
/**
* @public
*/
export interface MoveDescriptor<X extends PropertyType> {
$value: X
$position: number
}
/** /**
* @public * @public
*/ */
@ -92,6 +100,13 @@ export type ArrayAsElementPosition<T extends Doc> = {
[P in keyof T]: T[P] extends Arr<infer X> ? X | Position<X> : never [P in keyof T]: T[P] extends Arr<infer X> ? X | Position<X> : never
} }
/**
* @public
*/
export type ArrayMoveDescriptor<T extends Doc> = {
[P in keyof T]: T[P] extends Arr<infer X> ? MoveDescriptor<X> : never
}
/** /**
* @public * @public
*/ */
@ -110,6 +125,7 @@ export type OmitNever<T extends object> = Omit<T, KeysByType<T, never>>
export interface PushOptions<T extends Doc> { export interface PushOptions<T extends Doc> {
$push?: Partial<OmitNever<ArrayAsElementPosition<T>>> $push?: Partial<OmitNever<ArrayAsElementPosition<T>>>
$pull?: Partial<OmitNever<ArrayAsElement<T>>> $pull?: Partial<OmitNever<ArrayAsElement<T>>>
$move?: Partial<OmitNever<ArrayMoveDescriptor<T>>>
} }
/** /**

View File

@ -181,7 +181,6 @@
<KanbanCardEmpty label={'Create new application'} /> <KanbanCardEmpty label={'Create new application'} />
{#each objects as object, j} {#each objects as object, j}
{#if object.state === state._id} {#if object.state === state._id}
{j}
<div <div
on:dragover|preventDefault={(ev) => { on:dragover|preventDefault={(ev) => {
dragover(ev, object) dragover(ev, object)