Files
wekan/tests/linkedCardShownFields.test.cjs
T
Lauri Ojansivu 3e5bc58105 Card Settings: a checkbox per section, always every field, only in Board Settings.
Card Settings is now only Board Settings / Card. The opened card has no
Card Settings button any more: it simply shows every field its board
shows on cards, empty or not.

- On this card, Show empty and Show empty fields are removed, with the
  hamburgers' Select all / Select none rows, their handlers, helpers,
  board methods (setCardFieldAlwaysShown, setShowEmptyCardFields), CSS
  and the three translation keys. The card no longer reads its own
  shownFields / hiddenFields, nor the board's cardFieldsAlwaysShown /
  showEmptyCardFields; the schema keeps them so old documents validate.
- Every section has a checkbox before its title: whether the whole
  section is shown on the chosen side, whatever its rows are ticked.
  Stored per side in cardSettingsHiddenOnCard / cardSettingsHiddenOnMinicard
  (setCardSettingsSectionShown, board admins). The opened card's view
  of the board and a new minicard view read false for every row of a
  hidden section, Scrum fields included; Card Settings itself reads the
  raw board, so the rows keep their ticks.
- A section with one row on the chosen side is one line: one checkbox,
  the name, one hamburger.
- A hamburger is drawn only when it holds something.
- Custom Fields: its items are the board's custom fields, in their sort
  order, reordered by drag and drop within the section, with a + under
  them that creates one. Show on Minicard sets a field's showOnCard,
  Show on Card its alwaysOnCard; its hamburger edits the field. The
  section's checkbox is the board's Custom Fields flag of that side.
- Card actions (Filter: Subtasks, Edit voting, Card kind, ...) live in
  the card's own section hamburgers; Card Settings keeps only board
  actions.

Docs: docs/Features/Cards/Card-Settings.md replaces
Card-Settings-On-Card.md; Card-Fields.md and Board Settings / Card.md
rewritten. New tests cardSettingsSectionShown and
cardSettingsCustomFields; the guards of the removed behaviour say why
they changed; card-add-fields.e2e.js covers section hiding per side, an
empty card showing every field, empty hamburgers, the one-row line, the
Custom Fields items and +, and that the opened card has no Card
Settings.

Thanks to xet7 !
2026-10-28 22:43:29 +02:00

45 lines
2.1 KiB
JavaScript

'use strict';
// Found by the #1946/#6613 browser test: an opened card showed the fields it
// had data in, but a LINKED card keeps its data on its source card - members,
// labels, dates, custom fields, checklists - and the decision read the linked
// card's own, empty document, so a linked card hid every field its source has.
//
// Deliberate change (2026-10-28): an opened card no longer decides by its data
// at all - every card shows every field its board shows on cards, empty or not
// (docs/Features/Cards/Card-Fields.md). So the whole class of fault is gone: a
// linked card and its source see the very same board view, whatever either
// document holds. This suite pins that, and that the data-reading helpers
// (shownFieldsOf, cardFieldCounts) that could get it wrong are gone.
// Run: node tests/linkedCardShownFields.test.cjs
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const f = require('../models/lib/cardShownFields.js');
const root = path.join(__dirname, '..');
const read = p => fs.readFileSync(path.join(root, p), 'utf8');
let passed = 0;
function test(name, fn) { fn(); passed += 1; console.log(' ok -', name); }
console.log('linkedCardShownFields:');
const board = { _id: 'b1', allowsMembers: true, allowsLabels: true, allowsChecklists: true };
test('a linked card shows what its board shows, like any card', () => {
const view = f.boardForCard(board);
for (const key of ['members', 'labels', 'checklists']) assert.ok(f.boardAllows(view, key), key);
});
test('negative: no decision reads a card\'s data any more', () => {
const src = read('client/components/cards/cardAddFields.js');
for (const gone of ['shownFieldsOf', 'cardFieldCounts', 'getRealCard', 'cardShowsField']) {
assert.ok(!src.includes(gone), `cardAddFields.js: ${gone}`);
}
assert.match(src, /export function cardBoardView\(data\) \{[^\n]*\n\s+return f\.boardForCard\(Utils\.getCurrentBoard\(\)\);/);
const sidebar = read('client/components/sidebar/sidebar.js');
assert.ok(!/shownFieldsOf|cardFieldCounts/.test(sidebar), 'sidebar.js');
});
console.log(`linkedCardShownFields: ${passed} passed`);