mirror of
https://github.com/peeringdb/peeringdb.git
synced 2024-05-11 05:55:09 +00:00
* Add pointer from API docs to tutorial #650 * Sorting by clicking table headers should use local-compare #356 * Mark IXP peering LAN as bogon #352 * Add help text to "Add (Facility, Network, Exchange)" tab #669 * Add Looking Glass field to the IX object #672 * Add read-only Superuser #679 * Make spelling of traffic levels consistent #519 (#723) * Offer 2FA (#290) * Show "Last Updated" fields on fac, ix, org records (#526) * Enable sort and reverse sort of IP column in IX display (#72) * IRR validation not handling unexpected characters gracefully (#712) * Support alternative direction of writing, e.g. Arabic (#618) * Undeleting an ixlan with an emtpy IPv4 XOR IPv6 field throws a silly error (#644) * Changing org while adding net results in 500 #654 * missing delete button for organisations (#121) * When changing owner of an ix admin GUI borks because of "Ixlan for exchange already exists" #666 * Selection should only present undeleted objects (#664) * change default encoding of API calls to 'utf-8' #663 * Posting https://www.peeringdb.com onto social media doesn't select a good preview image #537 * Revert "Add Looking Glass field to the IX object #672" This reverts commit 4daf2520043c241fabe9a521757efa86a274e28a. Conflicts: peeringdb_server/migrations/0037_ix_looking_glass.py peeringdb_server/views.py * 500 Internal Error when creating IX where prefix already exists elsewhere #718 * Fix graceful restore of soft-deleted objects with translation active (#580) * Don't return any POC data with status=deleted #569 Hard delete soft-deleted pocs after grace period #566 * django-peeringdb from github@2.0.0.2-beta Co-authored-by: Stefan Pratter <stefan@20c.com>
161 lines
3.2 KiB
JavaScript
161 lines
3.2 KiB
JavaScript
/**
|
|
* Makes a content listing sortable.
|
|
*
|
|
* Requirements:
|
|
*
|
|
* 1. jquery 1.11.3
|
|
* 2. twentyc.core.js
|
|
*/
|
|
|
|
(function($) {
|
|
|
|
tc.u.require_namespace("twentyc.listutil");
|
|
|
|
twentyc.listutil.sortable = {
|
|
init : function(opt) {
|
|
if(this.initialized)
|
|
return;
|
|
$('[data-sort-container]').sortable(opt);
|
|
this.initialized = true;
|
|
},
|
|
|
|
sorter : function(dir) {
|
|
return this["_sort_"+dir];
|
|
},
|
|
|
|
natural_sorter : function(dir) {
|
|
return this["_natural_sort_"+dir];
|
|
},
|
|
|
|
_sort_asc : function(a,b) {
|
|
if(a && a.localeCompare)
|
|
return a.localeCompare(b);
|
|
|
|
if(a > b)
|
|
return 1;
|
|
if(a < b)
|
|
return -1;
|
|
return 0;
|
|
},
|
|
|
|
_sort_desc : function(a,b) {
|
|
if(b && b.localeCompare)
|
|
return b.localeCompare(a);
|
|
|
|
if(a > b)
|
|
return -1;
|
|
if(a < b)
|
|
return 1;
|
|
return 0;
|
|
},
|
|
|
|
_natural_sort_asc : function(a,b) {
|
|
return a.localeCompare(b, undefined, {numeric:true, sensitivity: 'base'})
|
|
},
|
|
|
|
_natural_sort_desc : function(a,b) {
|
|
return b.localeCompare(a, undefined, {numeric:true, sensitivity: 'base'})
|
|
}
|
|
|
|
}
|
|
|
|
twentyc.jq.plugin(
|
|
"sortable",
|
|
{
|
|
init : function(opt) {
|
|
|
|
this.each(function(idx) {
|
|
|
|
var list = $(this);
|
|
|
|
list.find("[data-sort-target]").each(function(idx) {
|
|
|
|
var button = $(this);
|
|
|
|
button.click(function(e) {
|
|
list.sortable("sort", button.data("sort-target"), button);
|
|
});
|
|
|
|
if(button.data("sort-initial")) {
|
|
list.sortable("sort", button.data("sort-target"), button, button.data("sort-initial"));
|
|
}
|
|
|
|
});
|
|
|
|
|
|
});
|
|
return this;
|
|
|
|
},
|
|
|
|
sortInitial : function() {
|
|
this.each(function(idx) {
|
|
var list = $(this);
|
|
list.find("[data-sort-target]").each(function(idx) {
|
|
var button = $(this);
|
|
if(button.data("sort-initial")) {
|
|
list.sortable(
|
|
"sort",
|
|
button.data("sort-target"),
|
|
button,
|
|
button.data("sort-initial"),
|
|
);
|
|
}
|
|
});
|
|
});
|
|
return this;
|
|
},
|
|
|
|
sort : function(target, button, sortdir) {
|
|
|
|
if(sortdir == undefined) {
|
|
sortdir = button.data("sort-dir");
|
|
|
|
if(!sortdir || sortdir == "desc")
|
|
sortdir = "asc";
|
|
else
|
|
sortdir = "desc";
|
|
}
|
|
|
|
var sort_type = button.data("sort-type")
|
|
|
|
if(sort_type == "natural") {
|
|
var sorter = twentyc.listutil.sortable.natural_sorter(sortdir)
|
|
} else {
|
|
var sorter = twentyc.listutil.sortable.sorter(sortdir);
|
|
}
|
|
|
|
button.data("sort-dir", sortdir);
|
|
|
|
this.each(function(idx) {
|
|
var list = $(this);
|
|
var container = list.find(list.data("sort-container")).first()
|
|
|
|
list.find("[data-sort-target]").removeClass("sort-desc").removeClass("sort-asc");
|
|
|
|
var rows = container.find(list.data("sort-row"));
|
|
|
|
rows.sort(function(a,b) {
|
|
var av = $(a).find(target).first().data("sort-value");
|
|
var bv = $(b).find(target).first().data("sort-value");
|
|
return sorter(av, bv);
|
|
});
|
|
|
|
rows.detach().appendTo(container);
|
|
|
|
|
|
});
|
|
|
|
button.addClass("sort-"+sortdir);
|
|
|
|
return this;
|
|
}
|
|
},
|
|
{
|
|
|
|
}
|
|
);
|
|
|
|
|
|
})(jQuery);
|