From 33492bf82435d16f5dca7106a85d6f3341a32ddd Mon Sep 17 00:00:00 2001 From: Birwa balar Date: Wed, 17 Jun 2026 07:40:43 -0600 Subject: [PATCH] Milestone map modal bug fix --- .../WFM_NMT_map_widget/milestoneMapModal.js | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/public/Samples/WFM_NMT_map_widget/milestoneMapModal.js b/public/Samples/WFM_NMT_map_widget/milestoneMapModal.js index c379c1f..72c4bb3 100644 --- a/public/Samples/WFM_NMT_map_widget/milestoneMapModal.js +++ b/public/Samples/WFM_NMT_map_widget/milestoneMapModal.js @@ -80,6 +80,24 @@ export const MilestoneMapModal = ({ open }) => { } if (milestoneTickets.length > 0) { + // If the milestone itself had no date fields populated, fall back to + // deriving the date range from the tickets' created datetimes. + if (!beginTime || !endTime) { + const dates = milestoneTickets + .map(t => t.properties?.mywwfm_created_datetime) + .filter(Boolean) + .map(d => dayjs(d).valueOf()) + .filter(v => !isNaN(v)); + + if (dates.length > 0) { + const minDate = dayjs(Math.min(...dates)); + const maxDate = dayjs(Math.max(...dates)); + setBeginTime(minDate.toISOString()); + setEndTime(maxDate.toISOString()); + setSliderMinTime(minDate.subtract(3, 'days').valueOf()); + setSliderMaxTime(maxDate.add(3, 'days').valueOf()); + } + } mapTickets(milestoneTickets); } }, [milestoneTickets]); @@ -340,6 +358,17 @@ export const MilestoneMapModal = ({ open }) => { const milestoneStart = dayjs(ticket.properties.milestone_start); const milestoneEnd = dayjs(ticket.properties.milestone_end); + // When the milestone has no planned/expected/actual dates, fall back to + // filtering by the ticket's own created datetime. + if (!milestoneStart.isValid() || !milestoneEnd.isValid()) { + const createdAt = dayjs(ticket.properties.mywwfm_created_datetime); + if (!createdAt.isValid()) return true; // no date at all — always show + return ( + (createdAt.isAfter(sliderBegin) || createdAt.isSame(sliderBegin)) && + (createdAt.isBefore(sliderEnd) || createdAt.isSame(sliderEnd)) + ); + } + // test whether the date range of the milestone overlaps with the // date range of the slider return ( @@ -807,4 +836,4 @@ export const MilestoneMapModal = ({ open }) => { )} ); -}; +}; \ No newline at end of file