mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 18:10:06 -05:00
The opened card and the minicard now draw Card Settings' sections, in
Card Settings' order, each section's fields in the order of its rows:
- Section order is per side: cardSettingsSectionOrder for the card,
the new minicardSettingsSectionOrder for the minicard. A board that
stores none: the card starts with Labels, Date, Members, Card, ...
(the card's historical order as far as the grouping allows), the
minicard with what it drew first before.
- CARD_LAYOUT's and MINICARD_LAYOUT's reorderable sections are Card
Settings' sections, so dragging a section or a row in Card Settings
moves it on the card or the minicard. Stored field orders map: a
field keeps its place relative to the others of its new section.
- On the card every section has the shared heading (its icon, title,
caret and hamburger) - Voting and Planning Poker too, which had a
heading of their own. The minicard stays compact: no headings.
Card Settings shows both sides at once: the minicard's pane first (on
the left), the card's second, each with a caret that folds it, each
scrolling on its own, stacked when the popup is too narrow for two.
The Show radio is gone. A splitter between the panes changes their
widths by dragging, like spreadsheet columns (clamped, kept per user
as a fraction, reset by a double-click, moved by the arrow keys). The
popup is wider again for two panes and its corner grip resizes it,
the panes following.
A hamburger's content opens under its line inside the pane, not in a
popup: the hamburger shows it is open (aria-expanded, highlighted, the
panel attached to it); its button, the panel's X or Escape closes it.
A custom field's edit form and the + create form open inline the same
way and close only their panel when saved. The popup layer added in
9c9742e09d is removed, as nothing uses it now.
Docs: Card-Settings.md, Card-Fields.md and Board Settings / Card.md.
New tests cardSectionsOnCard, minicardSections, cardSettingsSplit,
cardSettingsInlinePanels and card-settings-sections-order.e2e.js; the
guards of the old layouts and orders say why they changed.
Thanks to xet7 !
75 lines
3.4 KiB
JavaScript
75 lines
3.4 KiB
JavaScript
'use strict';
|
|
|
|
// Card Settings' two panes side by side - the Minicard pane first, the Card
|
|
// pane after it - with a splitter between them that is dragged like the edge
|
|
// between two spreadsheet columns, or the Admin Panel left menu's inner edge
|
|
// (client/components/settings/leftMenu.js), and the same way a swimlane's
|
|
// height is dragged. What is kept is the Minicard pane's share of the width,
|
|
// a FRACTION and not pixels, so the split survives a different popup width;
|
|
// the Card pane takes the rest. docs/Features/Cards/Card-Settings.md
|
|
//
|
|
// Pure: no Meteor, no DOM. tests/cardSettingsSplit.test.cjs.
|
|
|
|
// The panes start half and half; a double-click on the splitter goes back.
|
|
const DEFAULT_SPLIT = 0.5;
|
|
// Neither pane narrower than this many em (at the popup's font size).
|
|
const MIN_PANE_EM = 16;
|
|
// One press of an arrow key moves the splitter this share of the width.
|
|
const KEY_STEP = 0.05;
|
|
|
|
const finite = n => typeof n === 'number' && Number.isFinite(n);
|
|
|
|
// `fraction` kept so that each pane is at least `minPx` of `totalPx`. When
|
|
// the two minimums do not fit, half and half. Anything that is not a number
|
|
// is the default.
|
|
function clampSplit(fraction, totalPx, minPx) {
|
|
const f = finite(fraction) ? fraction : DEFAULT_SPLIT;
|
|
if (!finite(totalPx) || totalPx <= 0) return Math.min(1, Math.max(0, f));
|
|
const min = finite(minPx) && minPx > 0 ? minPx : 0;
|
|
if (2 * min >= totalPx) return DEFAULT_SPLIT;
|
|
const lo = min / totalPx;
|
|
return Math.min(1 - lo, Math.max(lo, f));
|
|
}
|
|
|
|
// The split after the pointer moved `deltaPx` (its x now minus its x when the
|
|
// drag started) from `startFraction`. In a right-to-left page the Minicard
|
|
// pane is on the right, so moving toward it - to the right - narrows it.
|
|
function splitAfterDrag(startFraction, deltaPx, totalPx, minPx, rtl) {
|
|
if (!finite(totalPx) || totalPx <= 0) return clampSplit(startFraction, totalPx, minPx);
|
|
const delta = (finite(deltaPx) ? deltaPx : 0) * (rtl ? -1 : 1);
|
|
return clampSplit(clampSplit(startFraction, totalPx, minPx) + delta / totalPx, totalPx, minPx);
|
|
}
|
|
|
|
// The split after a key on the focused splitter: ArrowLeft / ArrowRight move
|
|
// it one step the way the arrow points (so in a right-to-left page ArrowRight
|
|
// narrows the Minicard pane, which is on the right), Home makes the Minicard
|
|
// pane as narrow and End as wide as allowed. Any other key: null.
|
|
function splitAfterKey(fraction, key, totalPx, minPx, rtl) {
|
|
const now = clampSplit(fraction, totalPx, minPx);
|
|
const towardRight = rtl ? -1 : 1;
|
|
switch (key) {
|
|
case 'ArrowLeft': return clampSplit(now - KEY_STEP * towardRight, totalPx, minPx);
|
|
case 'ArrowRight': return clampSplit(now + KEY_STEP * towardRight, totalPx, minPx);
|
|
case 'Home': return clampSplit(0, totalPx, minPx);
|
|
case 'End': return clampSplit(1, totalPx, minPx);
|
|
default: return null;
|
|
}
|
|
}
|
|
|
|
// What is stored: a share between 0 and 1, rounded so a drag does not store
|
|
// fifteen digits. Not a number: nothing (the default).
|
|
function normaliseSplit(fraction) {
|
|
if (!finite(fraction)) return undefined;
|
|
return Math.round(Math.min(1, Math.max(0, fraction)) * 1000) / 1000;
|
|
}
|
|
|
|
// The splitter's aria-valuenow: the Minicard pane's share in percent.
|
|
function splitPercent(fraction) {
|
|
return Math.round((finite(fraction) ? Math.min(1, Math.max(0, fraction)) : DEFAULT_SPLIT) * 100);
|
|
}
|
|
|
|
module.exports = {
|
|
DEFAULT_SPLIT, MIN_PANE_EM, KEY_STEP,
|
|
clampSplit, splitAfterDrag, splitAfterKey, normaliseSplit, splitPercent,
|
|
};
|