Skip to content
Snippets Groups Projects
Commit 2ce654d0 authored by Todd Dembrey's avatar Todd Dembrey
Browse files

GH-991: make sure we order items if the order changes after the submissions

parent b186c5d0
No related branches found
No related tags found
No related merge requests found
...@@ -19,7 +19,9 @@ export default class GroupedListing extends React.Component { ...@@ -19,7 +19,9 @@ export default class GroupedListing extends React.Component {
order: PropTypes.arrayOf(PropTypes.shape({ order: PropTypes.arrayOf(PropTypes.shape({
key: PropTypes.string.isRequired, key: PropTypes.string.isRequired,
display: PropTypes.string.isRequired, display: PropTypes.string.isRequired,
values: PropTypes.arrayOf(PropTypes.number), values: PropTypes.arrayOf(
PropTypes.oneOf(PropTypes.number, PropTypes.string),
)
})), })),
onItemSelection: PropTypes.func, onItemSelection: PropTypes.func,
shouldSelectFirst: PropTypes.bool, shouldSelectFirst: PropTypes.bool,
...@@ -47,7 +49,7 @@ export default class GroupedListing extends React.Component { ...@@ -47,7 +49,7 @@ export default class GroupedListing extends React.Component {
componentDidUpdate(prevProps, prevState) { componentDidUpdate(prevProps, prevState) {
// Order items // Order items
if (this.props.items !== prevProps.items) { if (this.props.items !== prevProps.items || this.props.order !== prevProps.order) {
this.orderItems(); this.orderItems();
} }
......
...@@ -57,11 +57,11 @@ class ByStatusListing extends React.Component { ...@@ -57,11 +57,11 @@ class ByStatusListing extends React.Component {
const slugify = value => value.toLowerCase().replace(/\s/g, '-') const slugify = value => value.toLowerCase().replace(/\s/g, '-')
const workflow = round.workflow const workflow = round.workflow
const order = workflow.reduce((accumulator, {display, value}, idx) => { const order = workflow.reduce((accumulator, {display, value}, idx) => {
const key = slugify(display); const key = slugify(value);
const existing = accumulator[key] || {} const existing = accumulator[key] || {}
const existingValues = existing.values || [] const existingValues = existing.values || []
const position = existing.position || idx const position = existing.position || idx
accumulator[key] = {key, display, position, values: [...existingValues, parseInt(value)]} accumulator[key] = {key, display, position, values: [...existingValues, value]}
return accumulator return accumulator
}, {}) }, {})
const arrayOrder = Object.values(order).sort((a,b) => a.position - b.position) const arrayOrder = Object.values(order).sort((a,b) => a.position - b.position)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment