mirror of
https://github.com/hcengineering/platform.git
synced 2025-06-03 14:19:56 +00:00
kanban fix
Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
parent
a87194dee7
commit
4cac9797ce
@ -63,7 +63,7 @@
|
|||||||
$: if (_space) statesQuery.query(core.class.State, { _id: { $in: _space.states } }, result => { states = sort(result); console.log('states', sort(result)) })
|
$: if (_space) statesQuery.query(core.class.State, { _id: { $in: _space.states } }, result => { states = sort(result); console.log('states', sort(result)) })
|
||||||
|
|
||||||
const query = createQuery()
|
const query = createQuery()
|
||||||
$: query.query(_class, { space }, result => { objects = sortObjects(result) }, options)
|
$: if (_space) query.query(_class, { space }, result => { objects = sortObjects(result) }, options)
|
||||||
|
|
||||||
function dragover(ev: MouseEvent, object: Doc) {
|
function dragover(ev: MouseEvent, object: Doc) {
|
||||||
// if (dragswap(ev, i)) {
|
// if (dragswap(ev, i)) {
|
||||||
@ -75,20 +75,29 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function move(to: number) {
|
async function move(to: number, state: Ref<State>) {
|
||||||
client.updateDoc(core.class.SpaceWithStates, core.space.Model, space, {
|
console.log('move version 10')
|
||||||
$pull: {
|
const id = dragCard._id
|
||||||
order: dragCard._id
|
|
||||||
}
|
if (dragCardInitialState !== state)
|
||||||
})
|
await client.updateDoc(_class, space, id, { state })
|
||||||
client.updateDoc(core.class.SpaceWithStates, core.space.Model, space, {
|
|
||||||
$push: {
|
if (dragCardInitialPosition !== to) {
|
||||||
order: {
|
await client.updateDoc(core.class.SpaceWithStates, core.space.Model, space, {
|
||||||
$each: [dragCard._id],
|
$pull: {
|
||||||
$position: to < dragCardInitialPosition ? to : to
|
order: id
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
})
|
|
||||||
|
client.updateDoc(core.class.SpaceWithStates, core.space.Model, space, {
|
||||||
|
$push: {
|
||||||
|
order: {
|
||||||
|
$each: [id],
|
||||||
|
$position: to
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getValue(doc: Doc, key: string): any {
|
function getValue(doc: Doc, key: string): any {
|
||||||
@ -111,6 +120,7 @@
|
|||||||
|
|
||||||
let dragCard: Doc
|
let dragCard: Doc
|
||||||
let dragCardInitialPosition: number
|
let dragCardInitialPosition: number
|
||||||
|
let dragCardInitialState: Ref<State>
|
||||||
|
|
||||||
async function cardPresenter(_class: Ref<Class<Doc>>): Promise<AnySvelteComponent> {
|
async function cardPresenter(_class: Ref<Class<Doc>>): Promise<AnySvelteComponent> {
|
||||||
const clazz = client.getHierarchy().getClass(_class)
|
const clazz = client.getHierarchy().getClass(_class)
|
||||||
@ -131,17 +141,9 @@
|
|||||||
on:dragover={(event) => {
|
on:dragover={(event) => {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
if (dragCard.state !== state._id) {
|
if (dragCard.state !== state._id) {
|
||||||
client.updateDoc(_class, space, dragCard._id, { state: state._id })
|
dragCard.state = state._id
|
||||||
}
|
}
|
||||||
}}
|
}}>
|
||||||
on:drop={(event) => {
|
|
||||||
event.preventDefault()
|
|
||||||
// if (selected !== -1) {
|
|
||||||
// client.updateDoc(_class, space, objects[selected]._id, { state: state._id })
|
|
||||||
// selected = -1
|
|
||||||
// }
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<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}
|
||||||
@ -150,16 +152,14 @@
|
|||||||
dragover(ev, object)
|
dragover(ev, object)
|
||||||
}}
|
}}
|
||||||
on:drop|preventDefault={() => {
|
on:drop|preventDefault={() => {
|
||||||
move(j)
|
move(j, state._id)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<svelte:component this={presenter} {object} draggable={true}
|
<svelte:component this={presenter} {object} draggable={true}
|
||||||
on:dragstart={() => {
|
on:dragstart={() => {
|
||||||
|
dragCardInitialState = state._id
|
||||||
dragCardInitialPosition = j
|
dragCardInitialPosition = j
|
||||||
dragCard = objects[j]
|
dragCard = objects[j]
|
||||||
}}
|
|
||||||
on:dragend={() => {
|
|
||||||
dragCard = undefined
|
|
||||||
}}/>
|
}}/>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
Loading…
Reference in New Issue
Block a user