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:
Lalit
2023-05-21 14:11:51 +05:30
committed by Tim Abbott
parent f04ae8acd3
commit 888d6d8037
2 changed files with 4 additions and 25 deletions

View File

@@ -21,23 +21,6 @@ export function reset() {
meta.loaded = false; 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() { export function maybe_disable_widgets() {
if (page_params.is_admin) { if (page_params.is_admin) {
return; return;
@@ -76,11 +59,7 @@ export function populate_playgrounds(playgrounds_data) {
}, },
}, },
$parent_container: $("#playground-settings").expectOne(), $parent_container: $("#playground-settings").expectOne(),
init_sort: [sort_pygments_language], init_sort: ["alphabetic", "pygments_language"],
sort_fields: {
pygments_language: sort_pygments_language,
playground_name: sort_playground_name,
},
$simplebar_container: $("#playground-settings .progressive-table-wrapper"), $simplebar_container: $("#playground-settings .progressive-table-wrapper"),
}); });
} }

View File

@@ -71,9 +71,9 @@
<div class="progressive-table-wrapper" data-simplebar> <div class="progressive-table-wrapper" data-simplebar>
<table class="table table-condensed table-striped wrapped-table admin_playgrounds_table"> <table class="table table-condensed table-striped wrapped-table admin_playgrounds_table">
<thead class="table-sticky-headers"> <thead class="table-sticky-headers">
<th class="active" data-sort="pygments_language">{{t "Language" }}</th> <th class="active" data-sort="alphabetic" data-sort-prop="pygments_language">{{t "Language" }}</th>
<th data-sort="playground_name">{{t "Name" }}</th> <th data-sort="alphabetic" data-sort-prop="name">{{t "Name" }}</th>
<th data-sort="url">{{t "URL prefix" }}</th> <th data-sort="alphabetic" data-sort-prop="url_prefix">{{t "URL prefix" }}</th>
{{#if is_admin}} {{#if is_admin}}
<th class="actions">{{t "Actions" }}</th> <th class="actions">{{t "Actions" }}</th>
{{/if}} {{/if}}