mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 20:45:00 -05:00
The Calendar view drew a Start/End interval bar and a separate Due marker, but Received never got a marker at all, and a card whose Start fell outside the visible window got no End marker either - so a user could not see all four of WeKan's card dates (Received, Start, Due, End) on the Calendar. cardsReceivedInBetween/cardsEndInBetween (mirroring the existing cardsDueInBetween) give Received and End their own labeled events. Frappe Gantt and DHTMLX Gantt each only ever drew a single bar per card (Start-or-Received to Due-or-End), silently dropping whichever date lost that fallback. Both now track which underlying field each bar edge actually represents and show all four dates - Frappe in its click popup, DHTMLX in its hover tooltip - so Received/End stay visible even when the bar itself only spans Start/Due. Compared against Kanboard's Gantt (kanboard/plugin-gantt, MIT) for feature parity: both WeKan Gantt alternatives now support drag-to-move and drag-to-resize, persisted back to the correct field (card.setStart/setDue/ setReceived/setEnd - the same calls the Calendar's own drag handlers already use), gated on the same board-write capability as the rest of WeKan rather than offered to users the server would refuse. Kanboard has no dependency arrows, view-mode switching or export; nothing to match there. Thanks to xet7 !
85 lines
3.1 KiB
JavaScript
85 lines
3.1 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';
|
|
|
|
// Cards whose due date falls within [start, end].
|
|
function cardsDueInBetweenSelector(boardId, start, end, filterSelector) {
|
|
return combineWithFilter(
|
|
{
|
|
boardId,
|
|
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,
|
|
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,
|
|
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,
|
|
$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,
|
|
};
|