Files
wekan/models/lib/sortableOptions.js
Lauri Ojansivu a0f2550e5d Large board: set jQuery UI sortable options only when they changed.
The card, list and swimlane sortables re-applied handle, items and disabled
from autoruns. jQuery UI does not skip an unchanged value: setting handle
re-tags every card of the list, about k^2 work for k cards, in every list.
setSortableOptions (models/lib/sortableOptions.js) sets only what differs. The
swimlanes autorun also asked canModifyCard() with no card, which reads the
open card, so it re-ran on every open and close; it asks canModifyBoard().

Thanks to markusst1982 and xet7 !

Fixes #6745.
2026-10-07 03:08:48 +03:00

24 lines
1.0 KiB
JavaScript

'use strict';
// #6745: the jQuery UI sortable options that actually need setting. Pure, so
// tests/largeBoardCardOpen.test.cjs runs it without a browser.
//
// The board re-applies `handle`, `items` and `disabled` from autoruns that
// re-run whenever a user preference or the board changes. jQuery UI does not
// skip an unchanged value: setting `handle` re-tags every item
// (_setHandleClassName -> _addClass per card, each with a $.uniqueSort over
// everything it already tagged), so one list of k cards cost about k^2 work -
// on every card open, in every list. Only a value that differs is set now.
//
// readCurrent key -> the option's current value
// wanted { key: value, ... }
// Returns the subset of `wanted` whose value differs from the current one.
function changedSortableOptions(readCurrent, wanted) {
const changes = {};
Object.keys(wanted || {}).forEach(key => {
if (readCurrent(key) !== wanted[key]) changes[key] = wanted[key];
});
return changes;
}
module.exports = { changedSortableOptions };