mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
settings_playground: Fix sorting issues in playgrounds table.
Removed the sorting functions which were sorting under the assumption that our comparison items were a list instead I used the generic sort functions functionality of our `list_widget` module.
This commit is contained in:
@@ -21,23 +21,6 @@ export function reset() {
|
||||
meta.loaded = false;
|
||||
}
|
||||
|
||||
function compare_by_index(a, b, i) {
|
||||
if (a[i] > b[i]) {
|
||||
return 1;
|
||||
} else if (a[i] === b[i]) {
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
function sort_pygments_language(a, b) {
|
||||
return compare_by_index(a, b, 0);
|
||||
}
|
||||
|
||||
function sort_playground_name(a, b) {
|
||||
return compare_by_index(a, b, 1);
|
||||
}
|
||||
|
||||
export function maybe_disable_widgets() {
|
||||
if (page_params.is_admin) {
|
||||
return;
|
||||
@@ -76,11 +59,7 @@ export function populate_playgrounds(playgrounds_data) {
|
||||
},
|
||||
},
|
||||
$parent_container: $("#playground-settings").expectOne(),
|
||||
init_sort: [sort_pygments_language],
|
||||
sort_fields: {
|
||||
pygments_language: sort_pygments_language,
|
||||
playground_name: sort_playground_name,
|
||||
},
|
||||
init_sort: ["alphabetic", "pygments_language"],
|
||||
$simplebar_container: $("#playground-settings .progressive-table-wrapper"),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -71,9 +71,9 @@
|
||||
<div class="progressive-table-wrapper" data-simplebar>
|
||||
<table class="table table-condensed table-striped wrapped-table admin_playgrounds_table">
|
||||
<thead class="table-sticky-headers">
|
||||
<th class="active" data-sort="pygments_language">{{t "Language" }}</th>
|
||||
<th data-sort="playground_name">{{t "Name" }}</th>
|
||||
<th data-sort="url">{{t "URL prefix" }}</th>
|
||||
<th class="active" data-sort="alphabetic" data-sort-prop="pygments_language">{{t "Language" }}</th>
|
||||
<th data-sort="alphabetic" data-sort-prop="name">{{t "Name" }}</th>
|
||||
<th data-sort="alphabetic" data-sort-prop="url_prefix">{{t "URL prefix" }}</th>
|
||||
{{#if is_admin}}
|
||||
<th class="actions">{{t "Actions" }}</th>
|
||||
{{/if}}
|
||||
|
||||
Reference in New Issue
Block a user