mirror of
https://github.com/zulip/zulip.git
synced 2025-11-20 22:48:16 +00:00
list_render: Add sorting reversal.
This allows a user to reverse the sort order by clicking again on an active tab, which changes from ascending to descending order. Fixes: #7254.
This commit is contained in:
@@ -183,9 +183,14 @@ var list_render = (function () {
|
|||||||
|
|
||||||
// `do_not_display` will signal to not update the DOM, likely because in
|
// `do_not_display` will signal to not update the DOM, likely because in
|
||||||
// the next function it will be updated in the DOM.
|
// the next function it will be updated in the DOM.
|
||||||
sort: function (sorting_function, prop, map, do_not_display) {
|
sort: function (sorting_function, prop, map, do_not_display, reverse) {
|
||||||
meta.prop = prop;
|
meta.prop = prop;
|
||||||
|
|
||||||
|
if (reverse === true) {
|
||||||
|
// simple mutable array reversal.
|
||||||
|
meta.filtered_list.reverse();
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof sorting_function === "function") {
|
if (typeof sorting_function === "function") {
|
||||||
meta.sorting_function = sorting_function;
|
meta.sorting_function = sorting_function;
|
||||||
} else if (typeof sorting_function === "string") {
|
} else if (typeof sorting_function === "string") {
|
||||||
@@ -197,17 +202,18 @@ var list_render = (function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (meta.sorting_function) {
|
// we do not want to sort if we are just looking to reverse.
|
||||||
|
if (meta.sorting_function && !reverse) {
|
||||||
meta.filtered_list = meta.filtered_list.sort(meta.sorting_function);
|
meta.filtered_list = meta.filtered_list.sort(meta.sorting_function);
|
||||||
|
}
|
||||||
|
|
||||||
if (!do_not_display) {
|
if (!do_not_display) {
|
||||||
// clear and re-initialize the list with the newly filtered subset
|
// clear and re-initialize the list with the newly filtered subset
|
||||||
// of items.
|
// of items.
|
||||||
prototype.init();
|
prototype.init();
|
||||||
|
|
||||||
if (opts.filter.onupdate) {
|
if (opts.filter.onupdate) {
|
||||||
opts.filter.onupdate();
|
opts.filter.onupdate();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -372,6 +378,13 @@ $(function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($this.hasClass("active")) {
|
if ($this.hasClass("active")) {
|
||||||
|
if (!$this.hasClass("descend")) {
|
||||||
|
$this.addClass("descend");
|
||||||
|
} else {
|
||||||
|
$this.removeClass("descend");
|
||||||
|
}
|
||||||
|
|
||||||
|
list.sort(undefined, undefined, undefined, undefined, true);
|
||||||
// Table has already been sorted by this property; do not re-sort.
|
// Table has already been sorted by this property; do not re-sort.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -970,6 +970,10 @@ input[type=checkbox].inline-block {
|
|||||||
-moz-osx-font-smoothing: grayscale;
|
-moz-osx-font-smoothing: grayscale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#settings_page .table-striped thead th.active.descend:after {
|
||||||
|
content: " \f0d7";
|
||||||
|
}
|
||||||
|
|
||||||
#settings_page input.search {
|
#settings_page input.search {
|
||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
margin: 0px 0px 20px 0px;
|
margin: 0px 0px 20px 0px;
|
||||||
|
|||||||
Reference in New Issue
Block a user