MappedEnum does not keep the order of corresponding Enumeration #1142

Closed
indrajitr opened this Issue Nov 3, 2011 · 3 comments

Projects

None yet

3 participants

@indrajitr
Lift Web Framework member

There seems to be a regression since May 15, 2011 when MappedEnum's buildDisplayList() was updated from

enum.map(a => (a.id, a.toString)).toList

to

enum.values.map(a => (a.id, a.toString)).toList

with commit description 'Fix deprecation for 2.9 compliance'.

Unfortunately, values.map does not keep the original order of items in enum, and thus rendering MappedEnum via toForm() (which uses buildDisplayList) will result in a select (drop down control) where items are not ordered like they are ordered in original Enumeration.

Simple fixes could be:

enum.values.toSeq.map(a => (a.id, a.toString)).toList

or

enum.values.toList.map(a => (a.id, a.toString))

Original thread referencing the commit, related discussion in scala-user list, and example fixes given above:
https://groups.google.com/d/topic/liftweb/DmEof5Zr1v8/discussion

@jeppenejsum
Lift Web Framework member

(In [[r:4d3ccdc44b0b8d70883ca3fd6781ac9af54813d4]]) Preserve Enumeration ordering when building display list in MappedEnum. Closes #1142

Branch: master

@jeppenejsum
Lift Web Framework member

(In [[r:88f3b29766937d66eeee7c2234234d27a1a6223d]]) Preserve Enumeration ordering when building display list in MappedEnum. Closes #1142

Branch: master

@jeppenejsum jeppenejsum was assigned Mar 1, 2012
@etorreborre etorreborre pushed a commit to etorreborre/framework that referenced this issue Dec 3, 2014
@jeppenejsum jeppenejsum Preserve Enumeration ordering when building display list in MappedEnu…
…m. Closes #1142
4d3ccdc
@etorreborre etorreborre pushed a commit to etorreborre/framework that referenced this issue Dec 3, 2014
@jeppenejsum jeppenejsum Preserve Enumeration ordering when building display list in MappedEnu…
…m. Closes #1142
88f3b29
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment