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 !
195 lines
11 KiB
JavaScript
195 lines
11 KiB
JavaScript
'use strict';
|
|
|
|
// #6796 "Declutter Cards": an opened card gave most of its height to controls
|
|
// with nothing in them, and Board Settings / Card could not be read without
|
|
// scrolling.
|
|
//
|
|
// - A field's add button sits on its title's line (Labels, Stickers, Location,
|
|
// the dates, Members, Assignee, Creator, Requested/Assigned By, Dependencies).
|
|
// - Requested By / Assigned By: the two buttons on one row, not stacked.
|
|
// - Checklists: the controls under the list share one line, and the bottom
|
|
// "+" is drawn only once there is a checklist (before that it is the same as
|
|
// the title line's).
|
|
// - Attachments: the upload rules are in the upload popup, not body text above
|
|
// every list; "+" is a small button; a file with nothing to preview gets a
|
|
// small file button instead of a 144x96 box with "txt" in it; and two new
|
|
// Board Settings / Card / Show on Card rows, Attachments: Preview and
|
|
// Attachments: Details (uploader and date), turn the rest off.
|
|
// - Board Settings / Card is a centred panel as tall as the window. It is now
|
|
// the opened card's Card Settings template (cardSettingsInline), 600px wide.
|
|
// Run: node tests/declutterCard6796.test.cjs
|
|
|
|
const assert = require('assert');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const vm = require('vm');
|
|
|
|
const ROOT = path.join(__dirname, '..');
|
|
const read = rel => fs.readFileSync(path.join(ROOT, rel), 'utf8');
|
|
const { attachmentTileCompact, attachmentHasVisualPreview } = require('../models/lib/attachmentTile.cjs');
|
|
const { CARD_SETTINGS_ROWS } = require('../models/lib/cardSettingsRows');
|
|
const en = JSON.parse(read('imports/i18n/data/en.i18n.json'));
|
|
|
|
let passed = 0;
|
|
function test(name, fn) { fn(); passed += 1; console.log(' ok -', name); }
|
|
|
|
const cardJade = read('client/components/cards/cardDetails.jade');
|
|
const cardCss = read('client/components/cards/cardDetails.css');
|
|
const attJade = read('client/components/cards/attachments.jade');
|
|
const attJs = read('client/components/cards/attachments.js');
|
|
const attCss = read('client/components/cards/attachments.css');
|
|
const chkJade = read('client/components/cards/checklists.jade');
|
|
const chkJs = read('client/components/cards/checklists.js');
|
|
const sidebarCss = read('client/components/sidebar/sidebar.css');
|
|
const popupCss = read('client/components/main/popup.css');
|
|
|
|
function template(src, name) {
|
|
const at = src.indexOf(`template(name="${name}")`);
|
|
assert.ok(at !== -1, `template ${name}`);
|
|
const next = src.indexOf('\ntemplate(name=', at + 1);
|
|
return src.slice(at, next === -1 ? undefined : next);
|
|
}
|
|
|
|
// ── attachments ────────────────────────────────────────────────────────────
|
|
|
|
test('a tile is full size only when it shows something', () => {
|
|
for (const file of [
|
|
{ isImage: true, extension: 'png', hasLink: true },
|
|
{ isImage: false, extension: 'SVG', hasLink: true },
|
|
{ isImage: false, extension: 'mp4', hasLink: true },
|
|
{ isImage: false, extension: 'mp3', hasLink: true },
|
|
]) {
|
|
assert.strictEqual(attachmentHasVisualPreview(file), true, JSON.stringify(file));
|
|
assert.strictEqual(attachmentTileCompact(file, undefined), false, 'unset means previews on');
|
|
assert.strictEqual(attachmentTileCompact(file, true), false);
|
|
}
|
|
});
|
|
|
|
test('negative: a file with nothing to preview, a missing link, or previews off, is the small button', () => {
|
|
for (const file of [
|
|
{ isImage: false, extension: 'txt', hasLink: true },
|
|
{ isImage: false, extension: 'pdf', hasLink: true },
|
|
{ isImage: false, extension: 'docx', hasLink: true },
|
|
{ isImage: true, extension: 'png', hasLink: false },
|
|
{},
|
|
]) assert.strictEqual(attachmentTileCompact(file, true), true, JSON.stringify(file));
|
|
assert.strictEqual(attachmentTileCompact({ isImage: true, extension: 'png', hasLink: true }, false), true);
|
|
});
|
|
|
|
test('Attachments: Preview and Attachments: Details are Show on Card rows, on by default', () => {
|
|
for (const [key, field, label] of [
|
|
['attachmentPreviews', 'allowsAttachmentPreviewsOnCard', 'preview'],
|
|
['attachmentDetails', 'allowsAttachmentDetailsOnCard', 'details'],
|
|
]) {
|
|
const row = CARD_SETTINGS_ROWS.find(r => r.key === key);
|
|
assert.ok(row && row.card, key);
|
|
assert.deepStrictEqual(row.label, ['attachments', label]);
|
|
assert.ok(row.label.every(k => en[k]), 'the label uses existing translations');
|
|
assert.strictEqual(row.card.toggle, 'js-board-card-flag');
|
|
assert.strictEqual(row.card.field, field);
|
|
assert.strictEqual(row.card.default, true, 'nothing an existing board shows disappears');
|
|
assert.strictEqual(row.card.after, 'attachments');
|
|
assert.ok(!row.minicard, 'the minicard has no attachment tiles');
|
|
assert.match(read('models/boards.js'), new RegExp(`${field}: \\{ type: Boolean, optional: true \\}`));
|
|
assert.match(read('server/models/boards.js'), new RegExp(`'${field}',`), 'an API card-setting key');
|
|
}
|
|
});
|
|
|
|
test('the gallery reads both rows (negative: no dead toggle)', () => {
|
|
const gallery = template(attJade, 'attachmentGallery');
|
|
assert.match(gallery, /unless \$eq currentBoard\.allowsAttachmentDetailsOnCard false\n\s+if uploaderName/);
|
|
assert.match(gallery, /if attachmentTileCompact this\n\s+i\.fa\.fa-file-o/);
|
|
assert.match(attJs, /attachmentTileCompact\(\{[\s\S]*?\}, board\?\.allowsAttachmentPreviewsOnCard\)/);
|
|
assert.match(gallery, /a\.card-label\.add-label\.add-attachment\.js-add-attachment/, 'a small "+"');
|
|
// The name is first and on a line of its own, so a long one is not hidden.
|
|
assert.match(attCss, /\.attachment-details > div:first-child \{\s*flex: 1 1 100%;/);
|
|
});
|
|
|
|
test('negative: the upload rules are in the upload popup, not above the opened card\'s list', () => {
|
|
const section = cardJade.slice(cardJade.indexOf('if currentBoard.allowsAttachments'), cardJade.indexOf('+attachmentGallery'));
|
|
for (const key of ['invalid-file', 'max-upload-filesize', 'allowed-upload-filetypes']) {
|
|
assert.ok(!section.includes(key), `${key} is not body text of the opened card`);
|
|
assert.ok(template(attJade, 'cardAttachmentsPopup').includes(`{{_ '${key}'}}`), `${key} is in the upload popup`);
|
|
}
|
|
});
|
|
|
|
// ── the add buttons ────────────────────────────────────────────────────────
|
|
|
|
const ITEMS = ['labels', 'stickers', 'location', 'received', 'start', 'due', 'end', 'members',
|
|
'assignees', 'creator', 'name', 'dependencies'];
|
|
|
|
test('each field\'s add button sits on its title\'s line', () => {
|
|
const rule = cardCss.match(/\.card-details \.card-details-group-body > \.card-details-item:is\(([\s\S]*?)\) \{\s*display: flex;\s*flex-wrap: wrap;/);
|
|
assert.ok(rule, 'the items are wrapping flex rows');
|
|
for (const item of ITEMS) assert.ok(rule[1].includes(`.card-details-item-${item}`), item);
|
|
// ...and the title is only as wide as its words: two rules make it 100%.
|
|
const title = cardCss.match(/\.card-details \.card-details-group-body > \.card-details-item:is\(([\s\S]*?)\)\s*> \.card-details-item-title \{\s*width: auto;/);
|
|
assert.ok(title, 'the title gives up its 100% width');
|
|
for (const item of ITEMS) assert.ok(title[1].includes(`.card-details-item-${item}`), item);
|
|
});
|
|
|
|
test('Requested By and Assigned By: pick a user and type a name side by side, on one line', () => {
|
|
// Both buttons stay what they were (a "+" picks a user; the other adds or,
|
|
// with a name there, edits it - tests/cardDetailsAddIcons.test.cjs), but
|
|
// they sit in a row instead of a column under the title.
|
|
for (const cls of ['js-select-requester', 'js-select-assigner']) {
|
|
const at = cardJade.indexOf(cls);
|
|
assert.ok(at > 0 && cardJade.lastIndexOf('.card-details-person-controls', at) > at - 200, cls);
|
|
}
|
|
assert.match(cardCss, /\.card-details \.card-details-person-controls \{\s*align-items: center;\s*display: flex;\s*flex-direction: row;/);
|
|
});
|
|
|
|
test('Checklists: the bottom controls share a line, and the bottom "+" waits for a checklist', () => {
|
|
const list = template(chkJade, 'checklists');
|
|
assert.match(list, /\.checklists-bottom-actions\n\s+if hasChecklists\n\s+\+inlinedForm/);
|
|
assert.match(chkJs, /hasChecklists\(\) \{/);
|
|
assert.match(read('client/components/cards/checklists.css'), /\.checklists-bottom-actions \{\s*display: flex;/);
|
|
});
|
|
|
|
// ── Board Settings / Card ──────────────────────────────────────────────────
|
|
|
|
const offsetSrc = read('client/lib/popupOffset.js');
|
|
const offset = vm.runInNewContext(`(() => { ${offsetSrc.replace(/^export \{[^}]*\};?\s*$/m, '')}\n return { computePopupOffset, CARD_SETTINGS_MAX_WIDTH }; })()`);
|
|
|
|
test('the popup is a centred panel as wide (up to 1100px) and tall as the window', () => {
|
|
// Deliberate change: Board Settings / Card is Card Settings (sidebar.jade
|
|
// boardCardSettingsPopup is only `+cardSettingsInline`) - one column of
|
|
// checklists, not the
|
|
// Admin Panel's menu and a pane of four checkbox columns - so it is about
|
|
// as wide as an opened card, 600px rather than 1200px. Still centred and
|
|
// as tall as the window (#6796), so it is read with little scrolling.
|
|
// Deliberate change (2026-10-28): 1100px - two such columns side by side,
|
|
// the Minicard pane and the Card pane, instead of a Show switch.
|
|
const base = { popupName: 'boardCardSettingsPopup', viewportHeight: 1080, openerTopVp: 40, openerBottomVp: 60,
|
|
openerLeftVp: 1700, scrollTop: 0, scrollLeft: 0 };
|
|
const wide = offset.computePopupOffset({ ...base, viewportWidth: 1920 });
|
|
assert.strictEqual(offset.CARD_SETTINGS_MAX_WIDTH, 1100);
|
|
assert.strictEqual(wide.left, (1920 - 1100) / 2, 'centred, whatever the opener');
|
|
assert.strictEqual(wide.top, 12);
|
|
assert.strictEqual(wide.maxHeight, 1056);
|
|
const narrow = offset.computePopupOffset({ ...base, viewportWidth: 900, viewportHeight: 768 });
|
|
const narrowWidth = Math.min(1100, 900 * 0.96);
|
|
assert.ok(Math.abs(narrow.left - (900 - narrowWidth) / 2) < 0.01);
|
|
assert.strictEqual(narrow.maxHeight, 768 - 24);
|
|
// A phone is still the full-screen sheet.
|
|
assert.deepStrictEqual({ ...offset.computePopupOffset({ ...base, viewportWidth: 600 }) }, { left: 0, top: 0 });
|
|
// The CSS says the same width.
|
|
assert.match(popupCss, /\.pop-over\[data-popup='boardCardSettingsPopup'\] \{[^}]*width: min\(96vw, 1100px\) !important;[^}]*max-height: calc\(100dvh - 24px\) !important;/);
|
|
assert.ok(!/width: min\(96vw, 1200px\)/.test(popupCss), 'negative: the old 1200px pane width is gone');
|
|
});
|
|
|
|
test('each row is one line: its checkbox, its name and its hamburger', () => {
|
|
// Deliberate change: the pane's column heads (.card-settings-pane-head) are
|
|
// gone with the pane; a row is the checklist item of cardSettingsInline,
|
|
// the same on the opened card and in Board Settings / Card.
|
|
assert.match(sidebarCss, /\n\.card-settings-line \{\n\s+display: grid;/);
|
|
assert.match(read('client/components/cards/cardAddFields.css'),
|
|
/\.card-settings-inline \.card-settings-line \{\s*grid-template-columns: auto minmax\(0, 1fr\) auto;/);
|
|
assert.ok(!sidebarCss.includes('.card-field-order-column-minicard'), 'the column layout is gone (negative)');
|
|
// (The old pane's rules were in sidebar.css; since 2026-10-28 a "pane" is
|
|
// one side of Card Settings, styled in cardAddFields.css.)
|
|
assert.ok(!sidebarCss.includes('.card-settings-pane'), 'the pane layout is gone (negative)');
|
|
});
|
|
|
|
console.log(`\n${passed} passed`);
|