mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
- Calendar, Calendar Mode and Multi Board Calendar showed archived cards once the Archive sidebar had loaded them; every calendar selector leaves them out now. - Timeline offered "Restore to this state" to every viewer, and a refused restore vanished, since nothing awaited it. The button is shown to those who may change the card, and a refusal is reported. - Table: a swimlane header row spanned a fixed 11 columns, one short with all four date columns and too wide on a phone; it spans the columns the table has. Its add-card error was an English sentence. - Map showed the raw "upload-failed" for a failed upload; it is translated. - client/lib/errorMessage.js turns a failed call into a message in the reader's language: the translation when the error code is a translation key, otherwise the translated "Something went wrong" with the server's reason after it. 25 alert() calls with their own English fallback use it. tests/errorMessageI18n.test.cjs runs the helper and fails on an alert() that falls back to English again; calendarFilter tests the archived cards for all four selectors. Thanks to xet7 !
93 lines
3.4 KiB
JavaScript
93 lines
3.4 KiB
JavaScript
'use strict';
|
|
|
|
// Pure, Meteor-free helpers for building the card selectors the Calendar view
|
|
// (client/components/boards/boardBody.js) queries. Extracted so the selectors
|
|
// are unit-testable in plain Node (mirrors models/lib/swimlaneFilter.js).
|
|
//
|
|
// #5656 ("Filter not working for Calendar"): the board Filter sidebar (member /
|
|
// assignee / due-date / label / custom-field) scopes the Board / Lists /
|
|
// Swimlanes views, but the Calendar view used to query cards with only a
|
|
// board+date selector and ignore the active Filter entirely, so it showed every
|
|
// card in the interval regardless of the filter. These builders combine the
|
|
// date-interval base selector with the Filter's selector via combineWithFilter,
|
|
// so the Filter is ALWAYS ANDed in (never overwritten by — nor colliding with —
|
|
// the top-level `$or` that cardsInIntervalSelector uses) and the Calendar honors
|
|
// the same filter as the other views. `filterSelector` is the object produced by
|
|
// Filter._getMongoSelector() on the client; pass a falsy/empty value when no
|
|
// filter is active (or on the server) and the base selector is returned
|
|
// unchanged.
|
|
|
|
import { combineWithFilter } from './swimlaneFilter.js';
|
|
|
|
// Every selector leaves out archived cards: the board publication does not send
|
|
// them, but the Archive sidebar does, and once it had they showed on the
|
|
// calendars as if they were live.
|
|
|
|
// Cards whose due date falls within [start, end].
|
|
function cardsDueInBetweenSelector(boardId, start, end, filterSelector) {
|
|
return combineWithFilter(
|
|
{
|
|
boardId,
|
|
archived: { $ne: true },
|
|
dueAt: { $gte: start, $lte: end },
|
|
},
|
|
filterSelector,
|
|
);
|
|
}
|
|
|
|
// Cards whose received date falls within [start, end] - the Calendar view's
|
|
// counterpart to cardsDueInBetweenSelector, so Received gets its own marker
|
|
// the same way Due already does (#6712-adjacent: all four card dates -
|
|
// Received, Start, Due, End - are meant to be visible on the Calendar).
|
|
function cardsReceivedInBetweenSelector(boardId, start, end, filterSelector) {
|
|
return combineWithFilter(
|
|
{
|
|
boardId,
|
|
archived: { $ne: true },
|
|
receivedAt: { $gte: start, $lte: end },
|
|
},
|
|
filterSelector,
|
|
);
|
|
}
|
|
|
|
// Cards whose end date falls within [start, end]. cardsInIntervalSelector
|
|
// already covers a card whose [startAt, endAt] span overlaps the visible
|
|
// range, but that draws ONE bar for the whole span - a card whose End lands
|
|
// in the visible range while its Start does not (e.g. Start is months in the
|
|
// past) would otherwise never get its own End marker on the Calendar.
|
|
function cardsEndInBetweenSelector(boardId, start, end, filterSelector) {
|
|
return combineWithFilter(
|
|
{
|
|
boardId,
|
|
archived: { $ne: true },
|
|
endAt: { $gte: start, $lte: end },
|
|
},
|
|
filterSelector,
|
|
);
|
|
}
|
|
|
|
// Cards whose [startAt, endAt] interval overlaps [start, end] in any way:
|
|
// starts before and still runs at `start`, starts before and still runs at
|
|
// `end`, or is fully contained within [start, end].
|
|
function cardsInIntervalSelector(boardId, start, end, filterSelector) {
|
|
return combineWithFilter(
|
|
{
|
|
boardId,
|
|
archived: { $ne: true },
|
|
$or: [
|
|
{ startAt: { $lte: start }, endAt: { $gte: start } },
|
|
{ startAt: { $lte: end }, endAt: { $gte: end } },
|
|
{ startAt: { $gte: start }, endAt: { $lte: end } },
|
|
],
|
|
},
|
|
filterSelector,
|
|
);
|
|
}
|
|
|
|
export {
|
|
cardsDueInBetweenSelector,
|
|
cardsInIntervalSelector,
|
|
cardsReceivedInBetweenSelector,
|
|
cardsEndInBetweenSelector,
|
|
};
|