mirror of
https://github.com/wekan/wekan.git
synced 2026-11-07 11:02:33 -05:00
The reporter coloured lists by stage and wanted cards to follow: "by merely dragging cards around the colors would change". The only way was a script that rewrote every card's colour through the API, again after every move. A list's colour popup now has "Cards without a colour of their own use this colour". Such cards are shown in the list's colour, and nothing is written to them: a card dragged to another list takes that list's colour, and a card's own colour always wins. models/lib/cardDisplayColor.js decides; the card colour helpers use it from the list the card is shown in. tests/cardDisplayColor.test.cjs covers the rule; the guards that pinned the old colour code now pin it through the new helper. New text is in English, pending Transifex. Thanks to C0rn3j and xet7 ! Fixes #4756.
19 lines
754 B
JavaScript
19 lines
754 B
JavaScript
'use strict';
|
|
|
|
// #4756: the colour a card is shown in. A card's own colour always wins; a
|
|
// card without one takes its list's colour when the list says so
|
|
// (cardsUseListColor, set in the list's colour popup). Nothing is written to
|
|
// the card: dragging it to another list changes the colour it is shown in,
|
|
// which is the point - "by merely dragging cards around the colors would
|
|
// change". 'white' is the palette's "no colour".
|
|
//
|
|
// Pure: tested by tests/cardDisplayColor.test.cjs.
|
|
function effectiveCardColor(card, list) {
|
|
const own = card && card.color;
|
|
if (own) return own;
|
|
if (list && list.cardsUseListColor === true && list.color && list.color !== 'white') return list.color;
|
|
return null;
|
|
}
|
|
|
|
module.exports = { effectiveCardColor };
|