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

Change task planner sort order when LHS filter changes #2160

Merged
merged 4 commits into from
Feb 21, 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
71 changes: 49 additions & 22 deletions packages/experiments-realm/crm-app.gts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,29 @@ const sortByPriority: (direction: TaskSortOrder) => Sort = (
},
];

const TASK_SORT_OPTIONS: SortOption[] = [
{
id: 'dueDateDesc',
displayName: 'Due Date',
sort: sortByDueDate('desc'),
},
{
id: 'dueDateAsc',
displayName: 'Due Date',
sort: sortByDueDate('asc'),
},
{
id: 'priorityDesc',
displayName: 'Priority',
sort: sortByPriority('desc'),
},
{
id: 'priorityAsc',
displayName: 'Priority',
sort: sortByPriority('asc'),
},
];

const CONTACT_FILTERS: LayoutFilter[] = [
{
displayName: 'All Contacts',
Expand Down Expand Up @@ -151,34 +174,14 @@ const TASK_FILTERS: LayoutFilter[] = [
icon: ListDetails,
cardTypeName: 'CRM Task',
createNewButtonText: 'Create Task',
sortOptions: [
{
id: 'dueDateDesc',
displayName: 'Due Date',
sort: sortByDueDate('desc'),
},
{
id: 'dueDateAsc',
displayName: 'Due Date',
sort: sortByDueDate('asc'),
},
{
id: 'priorityDesc',
displayName: 'Priority',
sort: sortByPriority('desc'),
},
{
id: 'priorityAsc',
displayName: 'Priority',
sort: sortByPriority('asc'),
},
],
sortOptions: TASK_SORT_OPTIONS,
},
...taskStatusValues.map((status) => ({
displayName: status.label,
icon: status.icon,
cardTypeName: 'CRM Task',
createNewButtonText: 'Create Task',
sortOptions: TASK_SORT_OPTIONS,
})),
];

Expand Down Expand Up @@ -213,6 +216,30 @@ class CrmAppTemplate extends Component<typeof CrmApp> {
@tracked private activeFilter: LayoutFilter = CONTACT_FILTERS[0];
@action private onFilterChange(filter: LayoutFilter) {
this.activeFilter = filter;
if (this.activeTabId === 'Task') {
switch (this.activeFilter.displayName) {
case 'All Tasks':
case 'Overdue':
case 'Due this week':
case 'Unassigned':
this.activeFilter.selectedSort = {
id: 'dueDateAsc',
displayName: 'Due Date',
sort: sortByDueDate('asc'),
};
break;
case 'Due Today':
case 'High Priority':
this.activeFilter.selectedSort = {
id: 'priorityDesc',
displayName: 'Priority',
sort: sortByPriority('desc'),
};
break;
default:
break;
}
}
}
//tabs
@tracked activeTabId: string | undefined = TABS[0].tabId;
Expand Down
5 changes: 4 additions & 1 deletion packages/host/tests/unit/qs-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module('Unit | qs | parse', function () {
{
eq: {
'author.firstName': 'Cardy',
series: null,
},
},
{
Expand All @@ -47,7 +48,9 @@ module('Unit | qs | parse', function () {
},
],
};
let queryString = qs.stringify(query);
let queryString = qs.stringify(query, {
strictNullHandling: true,
});
let parsedQuery: any = parseQuery(queryString);
assert.deepEqual(parsedQuery, query);
});
Expand Down