Move getter methods into roadmap_item_utils.js
What does this MR do?
This MR transform the following Vuex getters (in roadmap/store/getters.js) into vanilla functions in roadmap/utils/roadmap_item_utils.js:
- lastTimeframeIndex
- timeframeStartDate
- timeframeEndDate
The MR also adds a small helper function in datetime_utility.js to easily generate a date object from a string.
Why?
When we fetch raw epic or milestone data from the backend, we need to transform the raw data using formatRoadmapItemDetails function from roadmap_item_utils.js. We also need to provide the start and end dates of the timeframe we're currently in to formatRoadmapItemDetails.
Here's an example:
const formattedMilestone = roadmapItemUtils.formatRoadmapItemDetails(
milestone,
getters.timeframeStartDate,
getters.timeframeEndDate,
);
Having timeframeStartDate and timeframeEndDate (lastTimeframeIndex are used by the previous two) as getters make it difficult to generate mock data for use in specs. Because these getters are almost always used in the context of post-processing fetched data from the backend, it's more ideal to have them as standalone functions in roadmap_item_utils.js.
Screenshots (strongly suggested)
N/A