From 2b769e1e5755056ff204c0e8ff22b4a3d2562b9e Mon Sep 17 00:00:00 2001 From: Genevieve Date: Mon, 1 Oct 2018 15:38:16 -0500 Subject: [PATCH 1/4] initial code for sorting --- src/components/QueueCardList.js | 11 +++++++++++ src/pages/course.js | 4 +++- src/pages/index.js | 4 +++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/components/QueueCardList.js b/src/components/QueueCardList.js index 1b96f0d1..0459d7db 100644 --- a/src/components/QueueCardList.js +++ b/src/components/QueueCardList.js @@ -68,6 +68,14 @@ class QueueCardList extends React.Component { })) } + queueSorter(l, r) { + const queueL = this.props.queues[l] + const queueR = this.props.queues[r] + const courseNameL = this.props.courses[queueL.courseId].name + const courseNameR = this.props.courses[queueR.courseId].name + return courseNameL > courseNameR + } + render() { const CardCol = ({ children, ...rest }) => ( { Router.pushRoute('queue', { id }) } + + this.props.queueIds.sort(this.queueSorter.bind(this)) + queues = this.props.queueIds.map(queueId => { const queue = this.props.queues[queueId] const courseName = this.props.courses[queue.courseId].name diff --git a/src/pages/course.js b/src/pages/course.js index 055adf54..f2ed0414 100644 --- a/src/pages/course.js +++ b/src/pages/course.js @@ -190,7 +190,9 @@ const mapStateToProps = (state, ownProps) => { const course = state.courses.courses[ownProps.courseId] return { course, - queues: mapObjectToArray(state.queues.queues), + queues: mapObjectToArray(state.queues.queues).sort((a, b) => { + return a.name > b.name + }), isFetching: state.courses.isFetching || state.queues.isFetching, } } diff --git a/src/pages/index.js b/src/pages/index.js index d6a876d6..2565e863 100644 --- a/src/pages/index.js +++ b/src/pages/index.js @@ -244,7 +244,9 @@ const mapStateToProps = state => ({ showCreateQueueButton: state.user.user && (state.user.user.isAdmin || state.user.user.staffAssignments.length > 0), - courses: mapObjectToArray(state.courses.courses), + courses: mapObjectToArray(state.courses.courses).sort((a, b) => { + return a.name > b.name + }), queues: mapObjectToArray(state.queues.queues), }) From e70307fb246c345f352e9e4f588db3894da44713 Mon Sep 17 00:00:00 2001 From: Genevieve Date: Mon, 1 Oct 2018 15:48:01 -0500 Subject: [PATCH 2/4] changelog and tiebreak --- CHANGELOG.md | 1 + src/components/QueueCardList.js | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e64a5912..815ee575 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ with the current date and the next changes should go under a **[Next]** header. ## [Next] +* Sort queues and courses by name. ([@genevievehelsel](https://github.com/genevievehelsel) in [#144](https://github.com/illinois/queue/pull/144)) * Add open and closed cards to course pages. ([@genevievehelsel](https://github.com/genevievehelsel) in [#142](https://github.com/illinois/queue/pull/142)) * Upgrade to Next 7 and React 16.5.2. ([@nwalters512](https://github.com/nwalters512) in [#143](https://github.com/illinois/queue/pull/143)) diff --git a/src/components/QueueCardList.js b/src/components/QueueCardList.js index 0459d7db..8fcb69b7 100644 --- a/src/components/QueueCardList.js +++ b/src/components/QueueCardList.js @@ -73,6 +73,11 @@ class QueueCardList extends React.Component { const queueR = this.props.queues[r] const courseNameL = this.props.courses[queueL.courseId].name const courseNameR = this.props.courses[queueR.courseId].name + + if (courseNameL === courseNameR) { + return queueL.name > queueR.name + } + return courseNameL > courseNameR } From ae2fe331b866cf71bdaec1d315454aa222abbd3b Mon Sep 17 00:00:00 2001 From: Genevieve Date: Tue, 2 Oct 2018 08:49:39 -0500 Subject: [PATCH 3/4] remove extra filter --- src/pages/course.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/pages/course.js b/src/pages/course.js index f2ed0414..055adf54 100644 --- a/src/pages/course.js +++ b/src/pages/course.js @@ -190,9 +190,7 @@ const mapStateToProps = (state, ownProps) => { const course = state.courses.courses[ownProps.courseId] return { course, - queues: mapObjectToArray(state.queues.queues).sort((a, b) => { - return a.name > b.name - }), + queues: mapObjectToArray(state.queues.queues), isFetching: state.courses.isFetching || state.queues.isFetching, } } From f7fd59f4f7bd85615b54367411af24ae9df13865 Mon Sep 17 00:00:00 2001 From: Nathan Walters Date: Tue, 9 Oct 2018 22:49:00 -0500 Subject: [PATCH 4/4] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 815ee575..3b909524 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,9 +7,9 @@ with the current date and the next changes should go under a **[Next]** header. ## [Next] -* Sort queues and courses by name. ([@genevievehelsel](https://github.com/genevievehelsel) in [#144](https://github.com/illinois/queue/pull/144)) * Add open and closed cards to course pages. ([@genevievehelsel](https://github.com/genevievehelsel) in [#142](https://github.com/illinois/queue/pull/142)) * Upgrade to Next 7 and React 16.5.2. ([@nwalters512](https://github.com/nwalters512) in [#143](https://github.com/illinois/queue/pull/143)) +* Sort queues and courses by name. ([@genevievehelsel](https://github.com/genevievehelsel) in [#144](https://github.com/illinois/queue/pull/144)) ## 5 September 2018