mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-27 18:52:07 +08:00
Fix global sort to work with experiments
This commit is contained in:
parent
0c51f7bc8b
commit
da2a06c999
1 changed files with 9 additions and 9 deletions
|
@ -631,17 +631,17 @@ function updateElementControls(el) {
|
||||||
function sortWholeReport(asc) {
|
function sortWholeReport(asc) {
|
||||||
animateLoading();
|
animateLoading();
|
||||||
var reportContent = $(REPORT_CONTENT);
|
var reportContent = $(REPORT_CONTENT);
|
||||||
var moduleElements = reportContent.children(".report-module-element");
|
var experimentElements = reportContent.children(".report-experiment-element");
|
||||||
var newEls = reportContent.children(".new-element");
|
var newEls = reportContent.children(".new-element");
|
||||||
|
|
||||||
if (
|
if (
|
||||||
moduleElements.length === 0 || // Nothing to sort
|
experimentElements.length === 0 || // Nothing to sort
|
||||||
moduleElements.length != newEls.length - 1 // This should never happen
|
experimentElements.length != newEls.length - 1 // This should never happen
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
moduleElements = _.sortBy(moduleElements, function(el) {
|
experimentElements = _.sortBy(experimentElements, function(el) {
|
||||||
if (!asc)
|
if (!asc)
|
||||||
{
|
{
|
||||||
return -$(el).data("ts");
|
return -$(el).data("ts");
|
||||||
|
@ -650,18 +650,18 @@ function sortWholeReport(asc) {
|
||||||
});
|
});
|
||||||
|
|
||||||
newEls.detach();
|
newEls.detach();
|
||||||
moduleElements = $(moduleElements);
|
experimentElements = $(experimentElements);
|
||||||
moduleElements.detach();
|
experimentElements.detach();
|
||||||
|
|
||||||
// Re-insert the children into DOM
|
// Re-insert the children into DOM
|
||||||
reportContent.append(newEls[0]);
|
reportContent.append(newEls[0]);
|
||||||
for (var i = 0; i < moduleElements.length; i++) {
|
for (var i = 0; i < experimentElements.length; i++) {
|
||||||
reportContent.append(moduleElements[i]);
|
reportContent.append(experimentElements[i]);
|
||||||
reportContent.append(newEls[i + 1]);
|
reportContent.append(newEls[i + 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally, fix their controls
|
// Finally, fix their controls
|
||||||
_.each(moduleElements, function(el) {
|
_.each(experimentElements, function(el) {
|
||||||
updateElementControls($(el));
|
updateElementControls($(el));
|
||||||
sortElementChildren($(el), asc, true);
|
sortElementChildren($(el), asc, true);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue