Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

settings_playground: Fix sorting issues in playgrounds table.

Lalit888d6d80378c
diff --git a/web/src/settings_playgrounds.js b/web/src/settings_playgrounds.js
index b11d3a1737f..50cf2b3a7cb 100644
--- a/web/src/settings_playgrounds.js
+++ b/web/src/settings_playgrounds.js
@@ -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"),
});
}
diff --git a/web/templates/settings/playground_settings_admin.hbs b/web/templates/settings/playground_settings_admin.hbs
index e64914fe437..ccdb658c9ba 100644
--- a/web/templates/settings/playground_settings_admin.hbs
+++ b/web/templates/settings/playground_settings_admin.hbs
@@ -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}}