You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ro...@apache.org on 2019/07/02 07:23:18 UTC
[cloudstack] branch master updated: ui: Fix sorting bug in UI Code
(#3445)
This is an automated email from the ASF dual-hosted git repository.
rohit pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/master by this push:
new 4185452 ui: Fix sorting bug in UI Code (#3445)
4185452 is described below
commit 4185452366d5cb2f7c7ef6915a90b36ea5c14622
Author: Anurag Awasthi <an...@shapeblue.com>
AuthorDate: Tue Jul 2 12:53:11 2019 +0530
ui: Fix sorting bug in UI Code (#3445)
Current master has sorting broken and the order reverses as opposed to
what is set if sortkey.algorithm is set to true. The problem lies in the
way the update APIs were being called by the UI. The code was agnostic
to a global config that backend uses to set the order of the entities
in the corresponding list APIs.
We need to make UI aware of the global config and instead of changing
sign of sort key pass proper numbers so that DB isn't confusing when
some tables have positive sortkey and some have negative.
The fix is in 2 steps-
1) Make use of sortkey name in place where it's relevant. Mere row index
is not sufficient.
2) Reverse the sortkey if we are sorting by descending (when global
config is false)
---
ui/scripts/sharedFunctions.js | 2 +-
ui/scripts/ui/widgets/listView.js | 9 +++++++--
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/ui/scripts/sharedFunctions.js b/ui/scripts/sharedFunctions.js
index 44623dc..a8049ee 100644
--- a/ui/scripts/sharedFunctions.js
+++ b/ui/scripts/sharedFunctions.js
@@ -2419,7 +2419,7 @@ cloudStack.api = {
url: createURL(updateCommand),
data: {
id: args.context[objType].id,
- sortKey: g_sortKeyIsAscending ? (-1 * args.index) : args.index
+ sortKey: args.sortKey
},
success: function(json) {
args.response.success();
diff --git a/ui/scripts/ui/widgets/listView.js b/ui/scripts/ui/widgets/listView.js
index 25bdc06..9157814 100644
--- a/ui/scripts/ui/widgets/listView.js
+++ b/ui/scripts/ui/widgets/listView.js
@@ -1335,13 +1335,18 @@
true, {},
$tr.closest('.list-view').data('view-args').context
);
- var rowIndex = $tr.closest('tbody').find('tr').length - ($tr.index());
+ var sortKey;
+ if (g_sortKeyIsAscending) {
+ sortKey = $tr.index() + 1;
+ } else {
+ sortKey = ($tr.closest('tbody').find('tr').length - ($tr.index()));
+ }
context[viewArgs.activeSection] = $tr.data('json-obj');
action.action({
context: context,
- index: rowIndex,
+ sortKey: sortKey,
response: {
success: function(args) {},
error: function(args) {