Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(MWPW-162835): ability to have multiple event sort options #197

Merged
merged 23 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion commitlint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = {
rules: {
'jira-ticket-in-scope': ({scope}) => {
const pattern = /^MWPW-\d+$/;
const hasValidTicket = pattern.test(scope || '');
const hasValidTicket = pattern.test(scope.toUpperCase() || '');
return [
hasValidTicket,
'Scope must contain JIRA ticket (e.g., feat(MWPW-123): message)',
Expand Down
2 changes: 1 addition & 1 deletion dist/app.css

Large diffs are not rendered by default.

98 changes: 59 additions & 39 deletions dist/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Chimera UI Libraries - Build 0.23.28 (1/6/2025, 16:49:34)
* Chimera UI Libraries - Build 0.23.29 (1/10/2025, 13:20:31)
*
*/
/******/ (function(modules) { // webpackBootstrap
Expand Down Expand Up @@ -192,7 +192,7 @@ $exports.store = store;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getSearchParam = exports.getGlobalNavHeight = exports.getLinkTarget = exports.getEventBanner = exports.getCurrentDate = exports.isDateAfterInterval = exports.isDateBeforeInterval = exports.isDateWithinInterval = exports.qs = exports.mergeDeep = exports.setByPath = exports.debounce = exports.getSelectedItemsCount = exports.getByPath = exports.template = exports.getEndNumber = exports.getStartNumber = exports.getPageStartEnd = exports.generateRange = exports.stopPropagation = exports.isAtleastOneFilterSelected = exports.isNullish = exports.parseToPrimitive = exports.isObject = exports.mapObject = exports.sanitizeText = exports.sortByKey = exports.intersection = exports.isSuperset = exports.chainFromIterable = exports.chain = exports.removeDuplicatesByKey = exports.truncateList = exports.truncateString = exports.readInclusionsFromLocalStorage = exports.readBookmarksFromLocalStorage = exports.saveBookmarksToLocalStorage = undefined;
exports.sanitizeEventFilter = exports.getSearchParam = exports.getGlobalNavHeight = exports.getLinkTarget = exports.getEventBanner = exports.getCurrentDate = exports.isDateAfterInterval = exports.isDateBeforeInterval = exports.isDateWithinInterval = exports.qs = exports.mergeDeep = exports.setByPath = exports.debounce = exports.getSelectedItemsCount = exports.getByPath = exports.template = exports.getEndNumber = exports.getStartNumber = exports.getPageStartEnd = exports.generateRange = exports.stopPropagation = exports.isAtleastOneFilterSelected = exports.isNullish = exports.parseToPrimitive = exports.isObject = exports.mapObject = exports.sanitizeText = exports.sortByKey = exports.intersection = exports.isSuperset = exports.chainFromIterable = exports.chain = exports.removeDuplicatesByKey = exports.truncateList = exports.truncateString = exports.readInclusionsFromLocalStorage = exports.readBookmarksFromLocalStorage = exports.saveBookmarksToLocalStorage = undefined;

var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();

Expand Down Expand Up @@ -867,6 +867,12 @@ var getSearchParam = exports.getSearchParam = function getSearchParam(url, param
return urlObj.searchParams.get(param);
};

var sanitizeEventFilter = exports.sanitizeEventFilter = function sanitizeEventFilter(rawEventFilter) {
if (!rawEventFilter || rawEventFilter.indexOf('all') > -1) return [];
if (Array.isArray(rawEventFilter)) return rawEventFilter;
return [rawEventFilter];
};

/***/ }),
/* 6 */
/***/ (function(module, exports, __webpack_require__) {
Expand Down Expand Up @@ -2432,32 +2438,31 @@ var getEventSort = exports.getEventSort = function getEventSort() {
var transformedCards = cards.map(function (card) {
return {
id: card.id,
startDate: card.contentArea.dateDetailText.startTime,
endDate: card.contentArea.dateDetailText.endTime,
tags: card.tags || []
startDate: card.contentArea.dateDetailText.startTime || card.footer[0].left[1].startTime,
endDate: card.contentArea.dateDetailText.endTime || card.footer[0].left[1].endTime,
tags: card.tags || [],
cardDate: card.cardDate || '',
contentArea: card.contentArea || {},
createdDate: card.createdDate || '',
ctaLink: card.ctaLink || '',
description: card.description || '',
footer: card.footer || [],
initial: card.initial || {},
isBookmarked: card.isBookmarked || '',
modifiedDate: card.modifiedDate || '',
overlayLink: card.overlayLink || '',
overlays: card.overlays || {},
showCard: card.showCard || {},
search: card.search || {},
styles: card.styles || {}
};
});

var result = (0, _eventSort.eventTiming)(transformedCards, eventFilter);

var visibleSessions = result.visibleSessions.filter(function (session) {
return session.tags.includes(eventFilter);
}).map(function (session) {
return {
id: session.id,
contentArea: {
dateDetailText: {
startTime: session.startDate,
endTime: session.endDate
}
},
tags: session.tags
};
});

return {
nextTransitionMs: result.nextTransitionMs,
visibleSessions: visibleSessions
visibleSessions: result.visibleSessions,
nextTransitionMs: result.nextTransitionMs
};
};
/**
Expand Down Expand Up @@ -6337,6 +6342,7 @@ var Container = function Container(props) {
var categories = getConfig('filterPanel', 'categories');
// eslint-disable-next-line no-use-before-define, max-len
var authoredCategories = isCategoriesContainer ? getAuthoredCategories(authoredFilters, categories) : [];
var sanitizedEventFilter = eventFilter ? (0, _general.sanitizeEventFilter)(eventFilter) : [];

/**
**** Hooks ****
Expand Down Expand Up @@ -7536,7 +7542,7 @@ var Container = function Container(props) {
* @returns {Object}
* */
var getFilteredCollection = function getFilteredCollection() {
return cardFilterer.sortCards(sortOption, eventFilter, featuredCards, hideCtaIds, isFirstLoad).keepBookmarkedCardsOnly(onlyShowBookmarks, bookmarkedCardIds, showBookmarks).keepCardsWithinDateRange().filterCards(activeFilterIds, activePanels, filterLogic, _constants.FILTER_TYPES, currCategories).truncateList(totalCardLimit).searchCards(searchQuery, searchFields, cardStyle).removeCards(inclusionIds);
return cardFilterer.sortCards(sortOption, sanitizedEventFilter, featuredCards, hideCtaIds, isFirstLoad).keepBookmarkedCardsOnly(onlyShowBookmarks, bookmarkedCardIds, showBookmarks).keepCardsWithinDateRange().filterCards(activeFilterIds, activePanels, filterLogic, _constants.FILTER_TYPES, currCategories).truncateList(totalCardLimit).searchCards(searchQuery, searchFields, cardStyle).removeCards(inclusionIds);
};

/**
Expand Down Expand Up @@ -48988,7 +48994,7 @@ var defineIsUpcoming = function defineIsUpcoming(currentTime, startTimeMls) {
*/
function eventTiming() {
var sessions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
var eventFilter = arguments[1];
var eventFilter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];

if (!sessions.length) return [];

Expand Down Expand Up @@ -49060,7 +49066,7 @@ function eventTiming() {
var isTimed = !!(endMs && startMs);
var isUpComing = isTimed ? defineIsUpcoming(curMs, startMs) : false;
var isOnDemand = isTimed && !isUpComing ? defineIsOnDemand(curMs, endMs) : false;
var isLive = !!(isTimed && !isUpComing && !isOnDemand && startMs) || eventFilter === 'live';
var isLive = !!(isTimed && !isUpComing && !isOnDemand && startMs);
// Tagged Exceptions
var isOnDemandScheduled = defineIsOnDemandScheduled(tags);
var isLiveExpired = defineIsLiveExpired(tags);
Expand Down Expand Up @@ -49112,25 +49118,30 @@ function eventTiming() {
// updateTimeOverride(curMs, nextTransitionMs);
}

var cards = [].concat(live, upComing, onDemand, notTimed);
if (eventFilter === 'live') {
cards = live;
} else if (eventFilter === 'upcoming') {
cards = upComing;
} else if (eventFilter === 'on-demand') {
cards = onDemand;
} else if (eventFilter === 'not-timed') {
cards = notTimed;
var cards = [];
if (eventFilter.length === 0) {
cards = [].concat(live, upComing, onDemand, notTimed);
return _extends({
visibleSessions: cards
}, nextTransitionMs && { nextTransitionMs: nextTransitionMs });
}if (eventFilter.indexOf('live') > -1) {
cards = cards.concat(live);
}if (eventFilter.indexOf('upcoming') > -1) {
cards = cards.concat(upComing);
}if (eventFilter.indexOf('on-demand') > -1) {
cards = cards.concat(onDemand);
}if (eventFilter.indexOf('not-timed') > -1) {
cards = cards.concat(notTimed);
}

/*
returns object
- conditionally adds next sort transition time to returns
- returns an Array of cards sorted by Category and then Date ASC
*/
return _extends({}, nextTransitionMs && { nextTransitionMs: nextTransitionMs }, {
return _extends({
visibleSessions: cards
});
}, nextTransitionMs && { nextTransitionMs: nextTransitionMs });
}

exports.eventTiming = eventTiming;
Expand Down Expand Up @@ -53267,10 +53278,18 @@ var CardFilterer = function () {

}, {
key: 'sortCards',
value: function sortCards(sortOption, eventFilter, featuredCardIds, hideCtaIds, isFirstLoad) {
value: function sortCards(sortOption) {
var eventFilter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
var featuredCardIds = arguments[2];
var hideCtaIds = arguments[3];
var isFirstLoad = arguments[4];

if (!this.filteredCards.length) return this;

var sortType = sortOption ? sortOption.sort.toLowerCase() : null;
if (eventFilter.length > 0) {
sortType = _constants.SORT_TYPES.EVENTSORT;
}

switch (sortType) {
case _constants.SORT_TYPES.DATEASC:
Expand All @@ -53288,9 +53307,10 @@ var CardFilterer = function () {
case _constants.SORT_TYPES.EVENTSORT:
{
var _getEventSort = (0, _Helpers.getEventSort)(this.filteredCards, eventFilter),
nextTransitionMs = _getEventSort.nextTransitionMs,
_getEventSort$visible = _getEventSort.visibleSessions,
visibleSessions = _getEventSort$visible === undefined ? [] : _getEventSort$visible;
visibleSessions = _getEventSort$visible === undefined ? [] : _getEventSort$visible,
_getEventSort$nextTra = _getEventSort.nextTransitionMs,
nextTransitionMs = _getEventSort$nextTra === undefined ? 0 : _getEventSort$nextTra;

this.filteredCards = visibleSessions;

Expand Down
Loading
Loading