diff --git a/client/app/nonComp/components/NonCompTabs.jsx b/client/app/nonComp/components/NonCompTabs.jsx index 6350f5c69fe..f040bb88b8e 100644 --- a/client/app/nonComp/components/NonCompTabs.jsx +++ b/client/app/nonComp/components/NonCompTabs.jsx @@ -52,8 +52,7 @@ const NonCompTabsUnconnected = (props) => { filterableTaskIssueTypes={props.taskFilterDetails.incomplete_issue_types} description={COPY.VHA_INCOMPLETE_TAB_DESCRIPTION} tabName="incomplete" - predefinedColumns={{ includeDaysWaiting: true, - defaultSortIdx: 3 }} /> + predefinedColumns={{ includeDaysWaiting: true }} /> }, in_progress: { label: 'In progress tasks', @@ -64,8 +63,7 @@ const NonCompTabsUnconnected = (props) => { {...(isVhaBusinessLine ? { onHistoryUpdate } : {})} filterableTaskTypes={props.taskFilterDetails.in_progress} filterableTaskIssueTypes={props.taskFilterDetails.in_progress_issue_types} - predefinedColumns={{ includeDaysWaiting: true, - defaultSortIdx: 3 }} /> + predefinedColumns={{ includeDaysWaiting: true }} /> }, completed: { label: 'Completed tasks', @@ -77,8 +75,7 @@ const NonCompTabsUnconnected = (props) => { filterableTaskTypes={props.taskFilterDetails.completed} filterableTaskIssueTypes={props.taskFilterDetails.completed_issue_types} description={COPY.QUEUE_PAGE_COMPLETE_LAST_SEVEN_DAYS_TASKS_DESCRIPTION} - predefinedColumns={{ includeCompletedDate: true, - defaultSortIdx: 3 }} /> + predefinedColumns={{ includeCompletedDate: true }} /> } }; diff --git a/client/app/queue/AssignedCasesPage.jsx b/client/app/queue/AssignedCasesPage.jsx index 53abcda99bd..0947b9d1e31 100644 --- a/client/app/queue/AssignedCasesPage.jsx +++ b/client/app/queue/AssignedCasesPage.jsx @@ -18,6 +18,7 @@ import { import Alert from '../components/Alert'; import COPY from '../../COPY'; +import { DEFAULT_QUEUE_TABLE_SORT } from './constants'; /** * Component showing the cases assigned to a specific attorney referenced by `attorneyId`. @@ -121,7 +122,8 @@ class AssignedCasesPage extends React.Component { includeReaderLink includeNewDocsIcon tasks={this.props.tasksOfAttorney} - userId={attorneyId} /> + userId={attorneyId} + defaultSort={DEFAULT_QUEUE_TABLE_SORT} /> ; } } diff --git a/client/app/queue/UnassignedCasesPage.jsx b/client/app/queue/UnassignedCasesPage.jsx index a09a7f0861f..2c2230feee6 100644 --- a/client/app/queue/UnassignedCasesPage.jsx +++ b/client/app/queue/UnassignedCasesPage.jsx @@ -29,6 +29,7 @@ import Alert from '../components/Alert'; import LoadingContainer from '../components/LoadingContainer'; import { LOGO_COLORS } from '../constants/AppConstants'; import { css } from 'glamor'; +import { DEFAULT_QUEUE_TABLE_SORT } from './constants'; const assignSectionStyling = css({ marginTop: '30px' }); const loadingContainerStyling = css({ marginTop: '-2em' }); @@ -108,6 +109,7 @@ class UnassignedCasesPage extends React.PureComponent { includeNewDocsIcon tasks={this.props.tasks} userId={userId} + defaultSort={DEFAULT_QUEUE_TABLE_SORT} {...(userIsCamoEmployee ? { preserveQueueFilter: true } : {})} /> } diff --git a/client/app/queue/components/TaskTable.jsx b/client/app/queue/components/TaskTable.jsx index 2da3bb42f86..f5d84a4b422 100644 --- a/client/app/queue/components/TaskTable.jsx +++ b/client/app/queue/components/TaskTable.jsx @@ -113,34 +113,26 @@ export class TaskTableUnconnected extends React.PureComponent { this.caseReaderLinkColumn() ])), ['order'], ['desc']); - getDefaultSortableColumn = () => { - if (this.props.defaultSortIdx) { - return this.props.defaultSortIdx; + getDefaultSortHash = () => { + if (this.props.defaultSort) { + return this.props.defaultSort; } - const index = _.findIndex(this.getQueueColumns(), - (column) => column.header === COPY.CASE_LIST_TABLE_APPEAL_TYPE_COLUMN_TITLE); - - if (index >= 0) { - return index; - } - - return _.findIndex(this.getQueueColumns(), (column) => column.getSortValue); } - render = () => - this.taskHasDASRecord(task) || !this.props.requireDasRecord ? null : 'usa-input-error'} - taskPagesApiEndpoint={this.props.taskPagesApiEndpoint} - useTaskPagesApi={this.props.useTaskPagesApi} - tabPaginationOptions={this.props.tabPaginationOptions} - />; + render = () => + (this.taskHasDASRecord(task) || !this.props.requireDasRecord) ? null : 'usa-input-error'} + taskPagesApiEndpoint={this.props.taskPagesApiEndpoint} + useTaskPagesApi={this.props.useTaskPagesApi} + tabPaginationOptions={this.props.tabPaginationOptions} + />; } TaskTableUnconnected.propTypes = { @@ -163,7 +155,10 @@ TaskTableUnconnected.propTypes = { includeReaderLink: PropTypes.bool, includeNewDocsIcon: PropTypes.bool, customColumns: PropTypes.array, - defaultSortIdx: PropTypes.number, + defaultSort: PropTypes.shape({ + sortColName: PropTypes.string, + sortAscending: PropTypes.bool + }), getKeyForRow: PropTypes.func, taskPagesApiEndpoint: PropTypes.string, useTaskPagesApi: PropTypes.bool, diff --git a/client/app/queue/constants.js b/client/app/queue/constants.js index fdb3192709e..c7afb3183e9 100644 --- a/client/app/queue/constants.js +++ b/client/app/queue/constants.js @@ -11,6 +11,7 @@ import { COLORS as COMMON_COLORS } from '@department-of-veterans-affairs/caseflo import COPY from '../../COPY'; import VACOLS_COLUMN_MAX_LENGTHS from '../../constants/VACOLS_COLUMN_MAX_LENGTHS'; import LEGACY_APPEAL_TYPES_BY_ID from '../../constants/LEGACY_APPEAL_TYPES_BY_ID'; +import { DEFAULT_SORTING_COLUMN_KEY, DEFAULT_SORTING_DIRECTION_KEY, COLUMNS } from '../../constants/QUEUE_CONFIG'; export const COLORS = { QUEUE_LOGO_PRIMARY: '#11598D', @@ -290,3 +291,9 @@ export const DECISION_SPECIAL_ISSUES = [ requiresJustification: false } ]; + +export const DEFAULT_QUEUE_TABLE_SORT = { + [DEFAULT_SORTING_COLUMN_KEY]: COLUMNS.APPEAL_TYPE.name, + [DEFAULT_SORTING_DIRECTION_KEY]: true +}; +