mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 18:10:06 -05:00
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 !
43 lines
2.6 KiB
JavaScript
43 lines
2.6 KiB
JavaScript
'use strict';
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const vm = require('node:vm');
|
|
const { CARD_SETTINGS_ROWS, rowsForSide } = require('../models/lib/cardSettingsRows');
|
|
const { DEFAULT_CARD_ORDER, DEFAULT_MINICARD_ORDER } = require('../models/lib/cardFieldOrder');
|
|
const { DATE_FORMATS, resolveDateFormat } = require('../models/lib/dateFormatPolicy');
|
|
const read = name => fs.readFileSync(name, 'utf8');
|
|
const fields = { allowsMinicardCollapse: true, labelsAboveTitleOnMinicard: false,
|
|
allowsChecklistDueDate: true, allowsChecklistTitle: true };
|
|
for (const [field, defaultValue] of Object.entries(fields)) {
|
|
assert.match(read('models/boards.js'), new RegExp(`${field}: \\{\\s*type: Boolean,\\s*defaultValue: ${defaultValue}`));
|
|
assert.ok(read('server/models/boards.js').includes(`'${field}'`), 'board settings API exposes the flag');
|
|
assert.ok(CARD_SETTINGS_ROWS.some(row => Object.values(row).some(spec => spec?.field === field)));
|
|
}
|
|
for (const [side, order] of [['card', DEFAULT_CARD_ORDER], ['minicard', DEFAULT_MINICARD_ORDER]]) {
|
|
const rows = rowsForSide(side, order);
|
|
for (const row of rows.filter(row => row[side].after)) {
|
|
assert.ok(rows.findIndex(other => other.key === row[side].after) < rows.indexOf(row));
|
|
}
|
|
}
|
|
// Exercise the real helper: hiding the caret cannot strand a saved collapsed card.
|
|
const source = read('client/components/cards/minicard.js');
|
|
const body = source.match(/ minicardCollapsed\(\) \{([^]*?)\n \},/)[1];
|
|
let board = {}; let collapsed = true;
|
|
// The helper reads the board as the minicard sees it (minicardBoardOf - a
|
|
// Card Settings section hidden on Show on Minicard reads false there,
|
|
// models/lib/cardShownFields.js boardForMinicard); here it is the board itself.
|
|
const helper = vm.runInNewContext(`(function () {${body}})`, {
|
|
minicardBoardOf: () => board, Utils: { getCardCollapseState: () => collapsed },
|
|
});
|
|
assert.equal(helper.call({ boardId: 'board' }), true);
|
|
board.allowsMinicardCollapse = false;
|
|
assert.equal(helper.call({ boardId: 'board' }), false);
|
|
board.allowsMinicardCollapse = true;
|
|
assert.equal(helper.call({ boardId: 'board' }), true);
|
|
collapsed = false;
|
|
assert.equal(helper.call({ boardId: 'board' }), false);
|
|
for (const fmt of DATE_FORMATS) assert.equal(resolveDateFormat(fmt, {}, null, true), fmt);
|
|
assert.equal(resolveDateFormat('unsupported', {}), 'YYYY-MM-DD');
|
|
assert.equal(resolveDateFormat('YYYY-MM-DD-date-only', { hideDateFormat: true, globalDateFormat: 'DD-MM-YYYY-date-only' }), 'DD-MM-YYYY-date-only');
|
|
console.log('cleanTaskBoards: compatible defaults, modifier rows, collapse recovery and date format validation passed');
|