mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
Repair relative ordering and destination dialog lifecycles, retain failed operations, and make checklist, rule and attachment controls keyboard accessible. Improve scaled layouts and reuse canonical translated labels. Add source-execution and Chromium/Firefox regression coverage, including awaiting background persistence before reload. Record implementation decisions and validation limits. Thanks to xet7 !
18 lines
864 B
JavaScript
18 lines
864 B
JavaScript
import { TAPi18n } from '/imports/i18n';
|
|
import Cards from '/models/cards';
|
|
import { relativePosition } from '/models/lib/relativePosition';
|
|
|
|
export async function relativeCardSort(targetCard, position, movingId) {
|
|
if (targetCard._id === movingId) return targetCard.sort;
|
|
const scope = { boardId: targetCard.boardId, listId: targetCard.listId,
|
|
swimlaneId: targetCard.swimlaneId, archived: false, deletedAt: null };
|
|
const siblings = Cards.find(scope, { sort: { sort: 1, _id: 1 } }).fetch();
|
|
const plan = relativePosition(siblings, targetCard._id, position, movingId);
|
|
for (const update of plan.updates) {
|
|
const sibling = Cards.findOne({ ...scope, _id: update.id });
|
|
if (!sibling) throw new Error(TAPi18n.__('no-cards-found'));
|
|
await sibling.move(sibling.boardId, sibling.swimlaneId, sibling.listId, update.sort);
|
|
}
|
|
return plan.sort;
|
|
}
|