mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-11-22 16:24:11 +01:00
Drag a whole column's ghost, and keep default places until reordered
The ghost of a dragged column is now its header and the cells of the rows in view, copied once when the drag starts and moved sideways by a transform, kept within the list; the column dims in place, its cells by one style rule so no row renders. A built-in column turned on before any reordering takes its default place again; once the person has an order, a newly shown column goes at the end. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9ee37e4015
commit
185a4e30df
4 files changed
+198
-50
No files matched your search
@@ -269,17 +269,30 @@ describe("column order", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
test("a column turned on goes at the end, unless it had a place", () => {
|
||||
test("never reordered, a built-in column turned on takes its default place", () => {
|
||||
// Request Size's default place is before Size
|
||||
let prefs = toggleColumn(defaultColumnPrefs, "requestSize");
|
||||
const prefs = toggleColumn(defaultColumnPrefs, "requestSize");
|
||||
expect(prefs.order).toEqual([]);
|
||||
expect(ids(prefs).slice(-4)).toEqual(["type", "requestSize", "size", "time"]);
|
||||
// Among the built-in ones, so a custom column stays at the end
|
||||
const custom = addCustomColumn(defaultColumnPrefs, "header.x-cache");
|
||||
expect(ids(custom).at(-1)).toBe("field:header.x-cache");
|
||||
const both = toggleColumn(custom, "requestSize");
|
||||
expect(both.order).toEqual([]);
|
||||
expect(ids(both).slice(-4)).toEqual(["requestSize", "size", "time", "field:header.x-cache"]);
|
||||
});
|
||||
|
||||
test("once reordered, a column turned on goes at the end, unless it had a place", () => {
|
||||
let prefs = moveColumn(defaultColumnPrefs, "time", 0);
|
||||
prefs = toggleColumn(prefs, "requestSize");
|
||||
expect(ids(prefs).at(-1)).toBe("requestSize");
|
||||
expect(ids(prefs).slice(0, -1)).toEqual(defaults);
|
||||
// Moved, hidden and shown again, it goes back where it was moved to
|
||||
prefs = moveColumn(prefs, "requestSize", defaults.indexOf("size"));
|
||||
const before = ids(prefs).indexOf("size");
|
||||
prefs = moveColumn(prefs, "requestSize", before);
|
||||
prefs = toggleColumn(toggleColumn(prefs, "requestSize"), "requestSize");
|
||||
expect(ids(prefs).slice(-3)).toEqual(["requestSize", "size", "time"]);
|
||||
// Already last of those shown, nothing needs placing
|
||||
expect(toggleColumn(defaultColumnPrefs, "remote").order).toEqual([]);
|
||||
expect(ids(prefs).slice(-3)).toEqual(["type", "requestSize", "size"]);
|
||||
// A custom column added goes at the end too
|
||||
expect(ids(addCustomColumn(prefs, "query.page")).at(-1)).toBe("field:query.page");
|
||||
});
|
||||
|
||||
test("a custom column is added at the end and leaves the order when removed", () => {
|
||||
|
||||
@@ -243,10 +243,11 @@ export function toggleColumn(
|
||||
/**
|
||||
* Puts a column just shown after the others shown, unless the person placed it before, so it
|
||||
* goes back to that place. The columns shown before it are placed too, where they are, so the
|
||||
* ones not listed don't jump ahead of it.
|
||||
* ones not listed don't jump ahead of it. Until the person has ordered the columns, each keeps
|
||||
* its default place: a built-in one among the others, an added one at the end.
|
||||
*/
|
||||
function placeAtEnd(prefs: ColumnPrefs, id: ColumnId): ColumnPrefs {
|
||||
if (prefs.order.includes(id)) return prefs;
|
||||
if (prefs.order.length === 0 || prefs.order.includes(id)) return prefs;
|
||||
const all = allColumns(prefs);
|
||||
if (all.filter((c) => isVisible(prefs, c)).at(-1)?.id === id) return prefs;
|
||||
const placed = all.filter(
|
||||
|
||||
Reference in new issue
Block a user