mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
Above the Features Save there is now one tick per field type of Board Settings / Card - the same icons and names, all ticked by default. An unticked field, for example Pomodoro, is not offered in any board's Board Settings / Card and is not shown on any opened card or minicard, whatever the board chose. Visibility only: no card data and no board setting is written, so ticking it again shows every board as it was set. There is no ordering here; the order stays each board's own. The catalog and the decisions are models/lib/cardFieldVisibility.js. It is stored as cardFieldStates on the settings document (missing means shown, so existing installs are unchanged), published with the other Features settings and saved by the site-admin-only saveInstanceFeatures method, which refuses unknown field keys. The hiding happens at the client's one board read (ReactiveCache.getBoard), which returns the board with the hidden fields' flags reading false - the same object when nothing is hidden - so every card and minicard template that reads a board flag agrees without being edited; the per-card List title and the user's Labels text override check the same mark. The server's reads, publications and the REST API are unchanged. A whole-column tick in Board Settings / Card leaves the hidden fields' board values alone. Thanks to xet7 !
47 lines
2.5 KiB
JavaScript
47 lines
2.5 KiB
JavaScript
'use strict';
|
|
const { DRAG_SETTINGS } = require('./boardDragging');
|
|
const { CARD_SETTINGS_ROWS } = require('./cardSettingsRows');
|
|
const { fieldKeyOfRow } = require('./cardFieldVisibility');
|
|
|
|
// Explicit columns rather than client-supplied field names. Reuse the row tables
|
|
// so new board-level rows automatically participate in their column action.
|
|
// `hiddenKeys` are the card fields unticked in Admin Panel / Settings /
|
|
// Visibility / Features (models/lib/cardFieldVisibility.js): their rows are not
|
|
// offered, so a whole-column tick leaves the board's own value of them as it
|
|
// was, for when the administrator ticks them again.
|
|
function columnFields(section, column, hiddenKeys = []) {
|
|
if (column === 'draggable' && ['swimlane', 'list', 'card'].includes(section)) {
|
|
return DRAG_SETTINGS.filter(row => row.section === section).map(row => row.field);
|
|
}
|
|
if (section === 'card' && ['card', 'minicard'].includes(column)) {
|
|
// A Scrum row's flag lives in the board's Scrum settings, named by its path.
|
|
const hidden = Array.isArray(hiddenKeys) ? hiddenKeys : [];
|
|
return CARD_SETTINGS_ROWS.filter(row => !hidden.includes(fieldKeyOfRow(row.key)))
|
|
.map(row => row[column])
|
|
.filter(row => row && !row.personal && !row.needsCard)
|
|
.map(row => (row.scrum ? `${SCRUM_PATH}${row.scrum}`
|
|
: row.field === 'allowsLabelText' ? 'showLabelText' : row.field));
|
|
}
|
|
if (column === 'settings') {
|
|
if (section === 'swimlane') return ['swimlaneHeightResizeLocked'];
|
|
if (section === 'list') return ['listWidthResizeLocked', 'sameWidthForAllLists'];
|
|
}
|
|
return [];
|
|
}
|
|
const SCRUM_PATH = 'scrum.visibility.';
|
|
// The board's own flags. The Scrum ones are not here: they are saved through
|
|
// scrum.configure (columnScrumVisibility), which keeps its lock, its revision
|
|
// and its Scrum history.
|
|
function columnModifier(section, column, enabled, hiddenKeys = []) {
|
|
const fields = columnFields(section, column, hiddenKeys).filter(field => !field.startsWith(SCRUM_PATH));
|
|
if (!fields.length || typeof enabled !== 'boolean') return null;
|
|
return { $set: Object.fromEntries(fields.map(field => [field, enabled])) };
|
|
}
|
|
// The Scrum visibility flags of a column, as scrum.configure takes them.
|
|
function columnScrumVisibility(section, column, enabled, hiddenKeys = []) {
|
|
if (typeof enabled !== 'boolean') return {};
|
|
return Object.fromEntries(columnFields(section, column, hiddenKeys).filter(field => field.startsWith(SCRUM_PATH))
|
|
.map(field => [field.slice(SCRUM_PATH.length), enabled]));
|
|
}
|
|
module.exports = { columnFields, columnModifier, columnScrumVisibility };
|