Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Sebastian
erp5
Commits
0a3ae365
Commit
0a3ae365
authored
Sep 12, 2012
by
Yusei Tahara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support new sorting feature which user can specify order of sort explicitly.
parent
f9ad726b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
16 deletions
+40
-16
product/ERP5Form/Tool/SelectionTool.py
product/ERP5Form/Tool/SelectionTool.py
+40
-16
No files found.
product/ERP5Form/Tool/SelectionTool.py
View file @
0a3ae365
...
@@ -515,6 +515,19 @@ class SelectionTool( BaseTool, SimpleItem ):
...
@@ -515,6 +515,19 @@ class SelectionTool( BaseTool, SimpleItem ):
if
sort_on
is
None
:
if
sort_on
is
None
:
listbox_id
,
sort_on
=
form
[
"setSelectionQuickSortOrder"
].
split
(
"."
,
1
)
listbox_id
,
sort_on
=
form
[
"setSelectionQuickSortOrder"
].
split
(
"."
,
1
)
# Sort order can be specified in sort_on.
forced_sort_order
=
None
if
sort_on
is
not
None
:
if
sort_on
.
endswith
(
':asc'
):
forced_sort_order
=
'ascending'
sort_on
=
sort_on
[:
-
4
]
elif
sort_on
.
endswith
(
':desc'
):
forced_sort_order
=
'descending'
sort_on
=
sort_on
[:
-
5
]
elif
sort_on
.
endswith
(
':none'
):
forced_sort_order
=
'none'
sort_on
=
sort_on
[:
-
5
]
if
REQUEST
is
not
None
:
if
REQUEST
is
not
None
:
if
listbox_id
is
not
None
:
if
listbox_id
is
not
None
:
selection_name_key
=
"%s_list_selection_name"
%
listbox_id
selection_name_key
=
"%s_list_selection_name"
%
listbox_id
...
@@ -524,22 +537,33 @@ class SelectionTool( BaseTool, SimpleItem ):
...
@@ -524,22 +537,33 @@ class SelectionTool( BaseTool, SimpleItem ):
selection
=
self
.
getSelectionFor
(
selection_name
,
REQUEST
=
REQUEST
)
selection
=
self
.
getSelectionFor
(
selection_name
,
REQUEST
=
REQUEST
)
if
selection
is
not
None
:
if
selection
is
not
None
:
current_sort_on
=
self
.
getSelectionSortOrder
(
selection_name
)
if
forced_sort_order
is
not
None
:
# We must first switch from asc to desc and vice-versa if sort_order exists
if
forced_sort_order
==
'none'
:
# in selection
temporary_new_sort_on
=
[]
n
=
0
else
:
for
current
in
current_sort_on
:
temporary_new_sort_on
=
[(
sort_on
,
forced_sort_order
)]
if
current
[
0
]
==
sort_on
:
# Allow user to sort by multiple columns
n
=
1
new_sort_on
=
[
s
if
current
[
1
]
==
'ascending'
:
for
s
in
self
.
getSelectionSortOrder
(
selection_name
)
new_sort_on
=
[(
sort_on
,
'descending'
)]
if
s
[
0
]
!=
sort_on
]
break
new_sort_on
.
extend
(
temporary_new_sort_on
)
else
:
else
:
new_sort_on
=
[(
sort_on
,
'ascending'
)]
current_sort_on
=
self
.
getSelectionSortOrder
(
selection_name
)
break
# We must first switch from asc to desc and vice-versa if sort_order exists
# And if no one exists, we just set ascending sort
# in selection
if
n
==
0
:
n
=
0
new_sort_on
=
[(
sort_on
,
'ascending'
)]
for
current
in
current_sort_on
:
if
current
[
0
]
==
sort_on
:
n
=
1
if
current
[
1
]
==
'ascending'
:
new_sort_on
=
[(
sort_on
,
'descending'
)]
break
else
:
new_sort_on
=
[(
sort_on
,
'ascending'
)]
break
# And if no one exists, we just set sort
if
n
==
0
:
new_sort_on
=
[(
sort_on
,
'ascending'
)]
selection
.
edit
(
sort_on
=
new_sort_on
)
selection
.
edit
(
sort_on
=
new_sort_on
)
if
REQUEST
is
not
None
:
if
REQUEST
is
not
None
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment