mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Merge pull request #4877 from martenson/lib-comparators
add sorting options for data library folders
This commit is contained in:
@@ -24,13 +24,18 @@ define(
|
||||
|
||||
folderContainer: null,
|
||||
|
||||
sort: "asc",
|
||||
current_sort_order: "asc",
|
||||
|
||||
current_sort_key: "name",
|
||||
|
||||
events: {
|
||||
"click #select-all-checkboxes": "selectAll",
|
||||
"click .dataset_row": "selectClickedRow",
|
||||
"click .folder_row": "selectClickedRow",
|
||||
"click .sort-folder-link": "sortColumnClicked"
|
||||
"click .sort-folder-name": "sortColumnClicked",
|
||||
"click .sort-folder-file_ext": "sortColumnClicked",
|
||||
"click .sort-folder-description": "sortColumnClicked",
|
||||
"click .sort-folder-state": "sortColumnClicked"
|
||||
},
|
||||
|
||||
collection: null,
|
||||
@@ -139,7 +144,7 @@ define(
|
||||
.metadata.parent_library_id,
|
||||
id: this.options.id,
|
||||
upper_folder_id: upper_folder_id,
|
||||
order: this.sort
|
||||
order: this.current_sort_order
|
||||
})
|
||||
);
|
||||
|
||||
@@ -226,7 +231,7 @@ define(
|
||||
addAll: function(models) {
|
||||
_.each(models, function(model) {
|
||||
Galaxy.libraries.folderListView.collection.add(model, {
|
||||
sort: false
|
||||
current_sort_order: false
|
||||
});
|
||||
});
|
||||
$("#center [data-toggle]").tooltip();
|
||||
@@ -318,37 +323,21 @@ define(
|
||||
}
|
||||
},
|
||||
|
||||
/** User clicked the table heading = he wants to sort stuff */
|
||||
sortColumnClicked: function(event) {
|
||||
event.preventDefault();
|
||||
if (this.sort === "asc") {
|
||||
this.sortFolder("name", "desc");
|
||||
this.sort = "desc";
|
||||
} else {
|
||||
this.sortFolder("name", "asc");
|
||||
this.sort = "asc";
|
||||
}
|
||||
this.current_sort_order =
|
||||
this.current_sort_order === "asc" ? "desc" : "asc";
|
||||
this.current_sort_key = event.currentTarget.className.replace(
|
||||
"sort-folder-",
|
||||
""
|
||||
);
|
||||
this.collection.sortFolder(
|
||||
this.current_sort_key,
|
||||
this.current_sort_order
|
||||
);
|
||||
this.renderSortIcon();
|
||||
},
|
||||
|
||||
/**
|
||||
* Sorts the underlying collection according to the parameters received.
|
||||
* Currently supports only sorting by name.
|
||||
*/
|
||||
sortFolder: function(sort_by, order) {
|
||||
// default to asc sort by name
|
||||
if (sort_by === "undefined" && order === "undefined") {
|
||||
return this.collection.sortByNameAsc();
|
||||
}
|
||||
if (sort_by === "name") {
|
||||
if (order === "asc") {
|
||||
return this.collection.sortByNameAsc();
|
||||
} else if (order === "desc") {
|
||||
return this.collection.sortByNameDesc();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* User clicked the checkbox in the table heading
|
||||
* @param {context} event
|
||||
@@ -435,14 +424,17 @@ define(
|
||||
},
|
||||
|
||||
renderSortIcon: function() {
|
||||
if (this.sort === "asc") {
|
||||
$(".sort-icon")
|
||||
if (this.current_sort_order === "asc") {
|
||||
$('[class*="sort-icon"]')
|
||||
.removeClass("fa-sort-alpha-desc")
|
||||
.addClass("fa-sort-alpha-asc");
|
||||
.removeClass("fa-sort-alpha-asc");
|
||||
$(".sort-icon" + "-" + this.current_sort_key).addClass(
|
||||
"fa-sort-alpha-asc"
|
||||
);
|
||||
} else {
|
||||
$(".sort-icon")
|
||||
.removeClass("fa-sort-alpha-asc")
|
||||
.addClass("fa-sort-alpha-desc");
|
||||
$(".sort-icon" + "-" + this.current_sort_key).addClass(
|
||||
"fa-sort-alpha-desc"
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -466,12 +458,12 @@ define(
|
||||
"<thead>",
|
||||
'<th class="button_heading"></th>',
|
||||
'<th style="text-align: center; width: 20px; " title="Check to select all datasets"><input id="select-all-checkboxes" style="margin: 0;" type="checkbox"></th>',
|
||||
'<th><a class="sort-folder-link" title="Click to reverse order" href="#">name</a> <span title="Sorted alphabetically" class="sort-icon fa fa-sort-alpha-<%- order %>"></span></th>',
|
||||
'<th style="width:20%;">description</th>',
|
||||
'<th style="width:5%;">data type</th>',
|
||||
'<th><a class="sort-folder-name" title="Click to reverse order" href="#">name</a> <span title="Sorted alphabetically" class="sort-icon-name fa fa-sort-alpha-<%- order %>"></span></th>',
|
||||
'<th style="width:20%;"><a class="sort-folder-description" title="Click to reverse order" href="#">description</a> <span title="Sorted alphabetically" class="sort-icon-description fa"></span></th>',
|
||||
'<th style="width:5%;"><a class="sort-folder-file_ext" title="Click to reverse order" href="#">data type</a> <span title="Sorted alphabetically" class="sort-icon-file_ext fa"></span></th>',
|
||||
'<th style="width:10%;">size</th>',
|
||||
'<th style="width:160px;">time updated (UTC)</th>',
|
||||
'<th style="width:5%;">state</th> ',
|
||||
'<th style="width:5%;"><a class="sort-folder-state" title="Click to reverse order" href="#">state</a> <span title="Sorted alphabetically" class="sort-icon-state fa"></span></th>',
|
||||
'<th style="width:150px;"></th> ',
|
||||
"</thead>",
|
||||
'<tbody id="folder_list_body">',
|
||||
|
||||
@@ -136,7 +136,10 @@ define(
|
||||
Galaxy.libraries.folderListView.collection.add(
|
||||
updated_dataset
|
||||
);
|
||||
Galaxy.libraries.folderListView.collection.sortByNameAsc();
|
||||
Galaxy.libraries.folderListView.collection.sortFolder(
|
||||
"name",
|
||||
"asc"
|
||||
);
|
||||
mod_toastr.success(
|
||||
"Dataset undeleted. Click this to see it.",
|
||||
"",
|
||||
@@ -190,7 +193,10 @@ define(
|
||||
Galaxy.libraries.folderListView.collection.add(
|
||||
updated_folder
|
||||
);
|
||||
Galaxy.libraries.folderListView.collection.sortByNameAsc();
|
||||
Galaxy.libraries.folderListView.collection.sortFolder(
|
||||
"name",
|
||||
"asc"
|
||||
);
|
||||
mod_toastr.success("Folder undeleted.");
|
||||
},
|
||||
error: function(model, response) {
|
||||
@@ -306,12 +312,12 @@ define(
|
||||
"<td>",
|
||||
'<%- content_item.get("description") %>',
|
||||
"</td>",
|
||||
"<td></td>",
|
||||
"<% } else if(edit_mode){ %>",
|
||||
'<td><textarea rows="4" class="form-control input_folder_name" placeholder="name" ><%- content_item.get("name") %></textarea></td>',
|
||||
'<td><textarea rows="4" class="form-control input_folder_description" placeholder="description" ><%- content_item.get("description") %></textarea></td>',
|
||||
"<% } %>",
|
||||
"<td>folder</td>",
|
||||
"<td></td>",
|
||||
"<td>",
|
||||
'<%= _.escape(content_item.get("update_time")) %>',
|
||||
"</td>",
|
||||
|
||||
@@ -251,12 +251,12 @@ define(
|
||||
if (
|
||||
Galaxy.libraries.preferences.get("sort_order") === "asc"
|
||||
) {
|
||||
this.collection.sortByNameAsc();
|
||||
this.collection.sortLibraries("name", "asc");
|
||||
} else if (
|
||||
Galaxy.libraries.preferences.get("sort_order") ===
|
||||
"desc"
|
||||
) {
|
||||
this.collection.sortByNameDesc();
|
||||
this.collection.sortLibraries("name", "desc");
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
define([], function() {
|
||||
define(["mvc/library/library-util"], function(mod_util) {
|
||||
// ============================================================================
|
||||
// LIBRARY RELATED MODELS
|
||||
|
||||
@@ -22,10 +22,6 @@ define([], function() {
|
||||
|
||||
model: Library,
|
||||
|
||||
sort_key: "name", // default
|
||||
|
||||
sort_order: null, // default
|
||||
|
||||
initialize: function(options) {
|
||||
options = options || {};
|
||||
},
|
||||
@@ -60,50 +56,12 @@ define([], function() {
|
||||
return filteredLibraries;
|
||||
},
|
||||
|
||||
/** Sort collection by library name (ascending) and return the sorted
|
||||
* collection
|
||||
*/
|
||||
sortByNameAsc: function() {
|
||||
this.comparator = function(libraryA, libraryB) {
|
||||
if (
|
||||
libraryA.get("name").toLowerCase() >
|
||||
libraryB.get("name").toLowerCase()
|
||||
) {
|
||||
return 1; // after
|
||||
}
|
||||
if (
|
||||
libraryB.get("name").toLowerCase() >
|
||||
libraryA.get("name").toLowerCase()
|
||||
) {
|
||||
return -1; // before
|
||||
}
|
||||
return 0; // equal
|
||||
};
|
||||
sortLibraries: function(sort_key, sort_order) {
|
||||
this.comparator = mod_util.generateLibraryComparator(
|
||||
sort_key,
|
||||
sort_order
|
||||
);
|
||||
this.sort();
|
||||
return this;
|
||||
},
|
||||
|
||||
/** Sort collection by library name (descending) and return the sorted
|
||||
* collection
|
||||
*/
|
||||
sortByNameDesc: function() {
|
||||
this.comparator = function(libraryA, libraryB) {
|
||||
if (
|
||||
libraryA.get("name").toLowerCase() >
|
||||
libraryB.get("name").toLowerCase()
|
||||
) {
|
||||
return -1; // before
|
||||
}
|
||||
if (
|
||||
libraryB.get("name").toLowerCase() >
|
||||
libraryA.get("name").toLowerCase()
|
||||
) {
|
||||
return 1; // after
|
||||
}
|
||||
return 0; // equal
|
||||
};
|
||||
this.sort();
|
||||
return this;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -123,66 +81,12 @@ define([], function() {
|
||||
var Folder = Backbone.Collection.extend({
|
||||
model: LibraryItem,
|
||||
|
||||
/** Sort collection by item name (ascending) and return the sorted
|
||||
* collection. Folders go before datasets.
|
||||
*/
|
||||
sortByNameAsc: function() {
|
||||
this.comparator = function(itemA, itemB) {
|
||||
if (itemA.get("type") === itemB.get("type")) {
|
||||
if (
|
||||
itemA.get("name").toLowerCase() >
|
||||
itemB.get("name").toLowerCase()
|
||||
) {
|
||||
return 1; // after
|
||||
}
|
||||
if (
|
||||
itemB.get("name").toLowerCase() >
|
||||
itemA.get("name").toLowerCase()
|
||||
) {
|
||||
return -1; // before
|
||||
}
|
||||
return 0; // equal
|
||||
} else {
|
||||
if (itemA.get("type") === "folder") {
|
||||
return -1; // folder is always before dataset
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
};
|
||||
sortFolder: function(sort_key, sort_order) {
|
||||
this.comparator = mod_util.generateFolderComparator(
|
||||
sort_key,
|
||||
sort_order
|
||||
);
|
||||
this.sort();
|
||||
return this;
|
||||
},
|
||||
|
||||
/** Sort collection by item name (descending) and return the sorted
|
||||
* collection. Folders go before datasets.
|
||||
*/
|
||||
sortByNameDesc: function() {
|
||||
this.comparator = function(itemA, itemB) {
|
||||
if (itemA.get("type") === itemB.get("type")) {
|
||||
if (
|
||||
itemA.get("name").toLowerCase() >
|
||||
itemB.get("name").toLowerCase()
|
||||
) {
|
||||
return -1; // after
|
||||
}
|
||||
if (
|
||||
itemB.get("name").toLowerCase() >
|
||||
itemA.get("name").toLowerCase()
|
||||
) {
|
||||
return 1; // before
|
||||
}
|
||||
return 0; // equal
|
||||
} else {
|
||||
if (itemA.get("type") === "folder") {
|
||||
return -1; // folder is always before dataset
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
};
|
||||
this.sort();
|
||||
return this;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
define([], function() {
|
||||
/**
|
||||
* Create alphabetical based two-argument comparator
|
||||
* that takes into account that Folder comes before Dataset.
|
||||
* If sort_key is not present it is set to ''.
|
||||
* @param {str} sort_key key to sort by
|
||||
* @param {str} sort_order order to sort by (asc, desc)
|
||||
* @return {function} two-argument comparator function
|
||||
*/
|
||||
var generateFolderComparator = function(sort_key, sort_order) {
|
||||
return function(itemA, itemB) {
|
||||
if (itemA.get("type") === itemB.get("type")) {
|
||||
if (!itemA.has(sort_key) && !itemB.has(sort_key)) {
|
||||
return 0;
|
||||
} else if (!itemA.has(sort_key)) {
|
||||
return 1;
|
||||
} else if (!itemB.has(sort_key)) {
|
||||
return -1;
|
||||
}
|
||||
if (
|
||||
itemA.get(sort_key).toLowerCase() >
|
||||
itemB.get(sort_key).toLowerCase()
|
||||
) {
|
||||
return sort_order === "asc" ? 1 : -1;
|
||||
}
|
||||
if (
|
||||
itemB.get(sort_key).toLowerCase() >
|
||||
itemA.get(sort_key).toLowerCase()
|
||||
) {
|
||||
return sort_order === "asc" ? -1 : 1;
|
||||
}
|
||||
return 0; // equal
|
||||
} else {
|
||||
if (itemA.get("type") === "folder") {
|
||||
return -1; // folder is always before dataset
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
};
|
||||
/**
|
||||
* Create alphabetical based two-argument comparator
|
||||
* @param {str} sort_key key to sort by
|
||||
* @param {str} sort_order order to sort by (asc, desc)
|
||||
* @return {function} two-argument comparator function
|
||||
*/
|
||||
var generateLibraryComparator = function(sort_key, sort_order) {
|
||||
return function(libraryA, libraryB) {
|
||||
if (
|
||||
libraryA.get(sort_key).toLowerCase() >
|
||||
libraryB.get(sort_key).toLowerCase()
|
||||
) {
|
||||
return sort_order === "asc" ? 1 : -1;
|
||||
}
|
||||
if (
|
||||
libraryB.get(sort_key).toLowerCase() >
|
||||
libraryA.get(sort_key).toLowerCase()
|
||||
) {
|
||||
return sort_order === "asc" ? -1 : 1;
|
||||
}
|
||||
return 0; // equal
|
||||
};
|
||||
};
|
||||
return {
|
||||
generateFolderComparator: generateFolderComparator,
|
||||
generateLibraryComparator: generateLibraryComparator
|
||||
};
|
||||
});
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["mvc/library/library-util.js"],"names":["define","generateFolderComparator","sort_key","sort_order","itemA","itemB","has","get","toLowerCase","generateLibraryComparator","libraryB","libraryA"],"mappings":"aAAAA,UAAW,WA+DP,OACIC,yBAvD2B,SAASC,EAAUC,GAC9C,OAAO,SAASC,EAAOC,GADvBJ,OAAAA,EAAAA,IAAAA,UAA2BI,EAA3BJ,IAAAA,QACOG,EAASA,IAATF,IAAuBG,EAAAC,IAAAJ,GAEXI,EAAIJ,IAAAA,GAEHE,EAAME,IAAIJ,GAIrBE,EAAAG,IAAAL,GAAAM,cAEGJ,EAAMG,IAAIL,GAAUM,cAIvB,QAAAL,EAAA,GAAA,EAMAE,EAAAE,IAAAL,GAAAM,cACDJ,EAAUG,IAAAL,GAAAM,cAEgB,QAAhBD,GAAV,EAAoC,EAEnC,GApBG,EAFO,EAFD,EA0Bb,WAAAH,EAAAG,IAAA,SA3BL,EA8BJ,IAyBIE,0BAZK,SAAAP,EAAAC,GACD,OAAA,SACIO,EAAaR,GAGb,OACHS,EAAAJ,IAAAL,GAAAM,cACDE,EAAUH,IAAAL,GAAAM,cAdlB,QAAAL,EAAA,GAAA,EAmBIM,EAAAA,IAAAA,GAA2BA,cAF/BE,EAAAJ,IAAAL,GAAAM,cALkC,QAAfL,GAAwB,EAAI,EAEhC","file":"../../../scripts/mvc/library/library-util.js","sourcesContent":["define([], function() {\n /**\n * Create alphabetical based two-argument comparator\n * that takes into account that Folder comes before Dataset.\n * If sort_key is not present it is set to ''.\n * @param {str} sort_key key to sort by\n * @param {str} sort_order order to sort by (asc, desc)\n * @return {function} two-argument comparator function\n */\n var generateFolderComparator = function(sort_key, sort_order) {\n return function(itemA, itemB) {\n if (itemA.get(\"type\") === itemB.get(\"type\")) {\n if (!itemA.has(sort_key) && !itemB.has(sort_key)) {\n return 0;\n } else if (!itemA.has(sort_key)) {\n return 1;\n } else if (!itemB.has(sort_key)) {\n return -1;\n }\n if (\n itemA.get(sort_key).toLowerCase() >\n itemB.get(sort_key).toLowerCase()\n ) {\n return sort_order === \"asc\" ? 1 : -1;\n }\n if (\n itemB.get(sort_key).toLowerCase() >\n itemA.get(sort_key).toLowerCase()\n ) {\n return sort_order === \"asc\" ? -1 : 1;\n }\n return 0; // equal\n } else {\n if (itemA.get(\"type\") === \"folder\") {\n return -1; // folder is always before dataset\n }\n return 1;\n }\n };\n };\n /**\n * Create alphabetical based two-argument comparator\n * @param {str} sort_key key to sort by\n * @param {str} sort_order order to sort by (asc, desc)\n * @return {function} two-argument comparator function\n */\n var generateLibraryComparator = function(sort_key, sort_order) {\n return function(libraryA, libraryB) {\n if (\n libraryA.get(sort_key).toLowerCase() >\n libraryB.get(sort_key).toLowerCase()\n ) {\n return sort_order === \"asc\" ? 1 : -1;\n }\n if (\n libraryB.get(sort_key).toLowerCase() >\n libraryA.get(sort_key).toLowerCase()\n ) {\n return sort_order === \"asc\" ? -1 : 1;\n }\n return 0; // equal\n };\n };\n return {\n generateFolderComparator: generateFolderComparator,\n generateLibraryComparator: generateLibraryComparator\n };\n});\n"]}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,2 +1,2 @@
|
||||
"use strict";define(["libs/toastr","mvc/library/library-model","mvc/library/library-libraryrow-view","libs/underscore"],function(e,r,i,t){return{LibraryListView:Backbone.View.extend({el:"#libraries_element",events:{"click .sort-libraries-link":"sort_clicked"},defaults:{page_count:null,show_page:null,all_fetched:!1},initialize:function(i){this.options=t.defaults(this.options||{},i,this.defaults);var s=this;this.modal=null,this.collection=new r.Libraries,this.collection.url=this.collection.urlRoot+"?deleted=false",this.collection.fetch({success:function(){s.render()},error:function(r,i){void 0!==i.responseJSON?e.error(i.responseJSON.err_msg):e.error("An error occurred.")}})},render:function(e){this.options=t.extend(this.options,e),this.setElement("#libraries_element");var r=this.templateLibraryList(),i=null,s=null,l=function(e){return!0===e.get("public")};if($(".tooltip").hide(),void 0!==e&&(s=void 0!==e.models?e.models:null),null!==this.collection&&null===s)this.sortLibraries(),i=Galaxy.libraries.preferences.get("with_deleted")?this.collection.models:this.collection.where({deleted:!1}),Galaxy.libraries.preferences.get("without_restricted")&&(i=t.filter(i,l));else if(null!==s){if(Galaxy.libraries.preferences.get("with_deleted"))i=s;else{i=t.filter(s,function(e){return!1===e.get("deleted")})}Galaxy.libraries.preferences.get("without_restricted")&&(i=t.filter(i,l))}else i=[];(null===this.options.show_page||this.options.show_page<1)&&(this.options.show_page=1),this.options.total_libraries_count=i.length;var o=Galaxy.libraries.preferences.get("library_page_size")*(this.options.show_page-1);this.options.page_count=Math.ceil(this.options.total_libraries_count/Galaxy.libraries.preferences.get("library_page_size")),this.options.total_libraries_count>0&&o<this.options.total_libraries_count?(i=i.slice(o,o+Galaxy.libraries.preferences.get("library_page_size")),this.options.libraries_shown=i.length,Galaxy.libraries.preferences.get("library_page_size")*this.options.show_page>this.options.total_libraries_count+Galaxy.libraries.preferences.get("library_page_size")&&(i=[]),this.$el.html(r({length:1,order:Galaxy.libraries.preferences.get("sort_order"),search_term:Galaxy.libraries.libraryToolbarView.options.search_term})),Galaxy.libraries.libraryToolbarView.renderPaginator(this.options),this.renderRows(i)):(this.$el.html(r({length:0,order:Galaxy.libraries.preferences.get("sort_order"),search_term:Galaxy.libraries.libraryToolbarView.options.search_term})),Galaxy.libraries.libraryToolbarView.renderPaginator(this.options)),$("#center [data-toggle]").tooltip(),$("#center").css("overflow","auto")},fetchDeleted:function(){if(this.options.all_fetched)this.render();else{var r=this;this.collection.url=this.collection.urlRoot+"?deleted=true",this.collection.fetch({remove:!1,success:function(){r.options.all_fetched=!0,r.render()},error:function(r,i){void 0!==i.responseJSON?e.error(i.responseJSON.err_msg):e.error("An error occurred.")}})}},renderRows:function(e){for(var r=0;r<e.length;r++){var i=e[r];this.renderOne({library:i})}},renderOne:function(e){var r=e.library,t=new i.LibraryRowView(r);this.$el.find("#library_list_body").append(t.el)},sort_clicked:function(){"asc"===Galaxy.libraries.preferences.get("sort_order")?Galaxy.libraries.preferences.set({sort_order:"desc"}):Galaxy.libraries.preferences.set({sort_order:"asc"}),this.render()},sortLibraries:function(){"name"===Galaxy.libraries.preferences.get("sort_by")&&("asc"===Galaxy.libraries.preferences.get("sort_order")?this.collection.sortByNameAsc():"desc"===Galaxy.libraries.preferences.get("sort_order")&&this.collection.sortByNameDesc())},searchLibraries:function(e){if(""!==$.trim(e)){var r=null;r=this.collection.search(e),this.options.searching=!0,this.render({models:r,show_page:1})}else this.options.searching=!1,this.render()},templateLibraryList:function(){return t.template(['<div class="library_container table-responsive">',"<% if(length === 0) { %>","<% if(search_term.length > 0) { %>","<div>","There are no libraries matching your search. Try different keyword.","</div>","<% } else{ %>","<div>","There are no libraries visible to you here. If you expected some to show up please consult the",' <a href="https://galaxyproject.org/data-libraries/#permissions" target="_blank">library security wikipage</a>',' or visit the <a href="https://biostar.usegalaxy.org/" target="_blank">Galaxy support site</a>.',"</div>","<% }%>","<% } else{ %>",'<table class="grid table table-condensed">',"<thead>",'<th style="width:30%;">','<a class="sort-libraries-link" title="Click to reverse order" href="#">',"name","</a>",'<span title="Sorted alphabetically" class="fa fa-sort-alpha-<%- order %>"/>',"</th>",'<th style="width:22%;">description</th>','<th style="width:22%;">synopsis</th> ','<th style="width:26%;"></th>',"</thead>",'<tbody id="library_list_body">',"</tbody>","</table>","<% }%>","</div>"].join(""))}})}});
|
||||
"use strict";define(["libs/toastr","mvc/library/library-model","mvc/library/library-libraryrow-view","libs/underscore"],function(e,r,i,t){return{LibraryListView:Backbone.View.extend({el:"#libraries_element",events:{"click .sort-libraries-link":"sort_clicked"},defaults:{page_count:null,show_page:null,all_fetched:!1},initialize:function(i){this.options=t.defaults(this.options||{},i,this.defaults);var s=this;this.modal=null,this.collection=new r.Libraries,this.collection.url=this.collection.urlRoot+"?deleted=false",this.collection.fetch({success:function(){s.render()},error:function(r,i){void 0!==i.responseJSON?e.error(i.responseJSON.err_msg):e.error("An error occurred.")}})},render:function(e){this.options=t.extend(this.options,e),this.setElement("#libraries_element");var r=this.templateLibraryList(),i=null,s=null,l=function(e){return!0===e.get("public")};if($(".tooltip").hide(),void 0!==e&&(s=void 0!==e.models?e.models:null),null!==this.collection&&null===s)this.sortLibraries(),i=Galaxy.libraries.preferences.get("with_deleted")?this.collection.models:this.collection.where({deleted:!1}),Galaxy.libraries.preferences.get("without_restricted")&&(i=t.filter(i,l));else if(null!==s){if(Galaxy.libraries.preferences.get("with_deleted"))i=s;else{i=t.filter(s,function(e){return!1===e.get("deleted")})}Galaxy.libraries.preferences.get("without_restricted")&&(i=t.filter(i,l))}else i=[];(null===this.options.show_page||this.options.show_page<1)&&(this.options.show_page=1),this.options.total_libraries_count=i.length;var o=Galaxy.libraries.preferences.get("library_page_size")*(this.options.show_page-1);this.options.page_count=Math.ceil(this.options.total_libraries_count/Galaxy.libraries.preferences.get("library_page_size")),this.options.total_libraries_count>0&&o<this.options.total_libraries_count?(i=i.slice(o,o+Galaxy.libraries.preferences.get("library_page_size")),this.options.libraries_shown=i.length,Galaxy.libraries.preferences.get("library_page_size")*this.options.show_page>this.options.total_libraries_count+Galaxy.libraries.preferences.get("library_page_size")&&(i=[]),this.$el.html(r({length:1,order:Galaxy.libraries.preferences.get("sort_order"),search_term:Galaxy.libraries.libraryToolbarView.options.search_term})),Galaxy.libraries.libraryToolbarView.renderPaginator(this.options),this.renderRows(i)):(this.$el.html(r({length:0,order:Galaxy.libraries.preferences.get("sort_order"),search_term:Galaxy.libraries.libraryToolbarView.options.search_term})),Galaxy.libraries.libraryToolbarView.renderPaginator(this.options)),$("#center [data-toggle]").tooltip(),$("#center").css("overflow","auto")},fetchDeleted:function(){if(this.options.all_fetched)this.render();else{var r=this;this.collection.url=this.collection.urlRoot+"?deleted=true",this.collection.fetch({remove:!1,success:function(){r.options.all_fetched=!0,r.render()},error:function(r,i){void 0!==i.responseJSON?e.error(i.responseJSON.err_msg):e.error("An error occurred.")}})}},renderRows:function(e){for(var r=0;r<e.length;r++){var i=e[r];this.renderOne({library:i})}},renderOne:function(e){var r=e.library,t=new i.LibraryRowView(r);this.$el.find("#library_list_body").append(t.el)},sort_clicked:function(){"asc"===Galaxy.libraries.preferences.get("sort_order")?Galaxy.libraries.preferences.set({sort_order:"desc"}):Galaxy.libraries.preferences.set({sort_order:"asc"}),this.render()},sortLibraries:function(){"name"===Galaxy.libraries.preferences.get("sort_by")&&("asc"===Galaxy.libraries.preferences.get("sort_order")?this.collection.sortLibraries("name","asc"):"desc"===Galaxy.libraries.preferences.get("sort_order")&&this.collection.sortLibraries("name","desc"))},searchLibraries:function(e){if(""!==$.trim(e)){var r=null;r=this.collection.search(e),this.options.searching=!0,this.render({models:r,show_page:1})}else this.options.searching=!1,this.render()},templateLibraryList:function(){return t.template(['<div class="library_container table-responsive">',"<% if(length === 0) { %>","<% if(search_term.length > 0) { %>","<div>","There are no libraries matching your search. Try different keyword.","</div>","<% } else{ %>","<div>","There are no libraries visible to you here. If you expected some to show up please consult the",' <a href="https://galaxyproject.org/data-libraries/#permissions" target="_blank">library security wikipage</a>',' or visit the <a href="https://biostar.usegalaxy.org/" target="_blank">Galaxy support site</a>.',"</div>","<% }%>","<% } else{ %>",'<table class="grid table table-condensed">',"<thead>",'<th style="width:30%;">','<a class="sort-libraries-link" title="Click to reverse order" href="#">',"name","</a>",'<span title="Sorted alphabetically" class="fa fa-sort-alpha-<%- order %>"/>',"</th>",'<th style="width:22%;">description</th>','<th style="width:22%;">synopsis</th> ','<th style="width:26%;"></th>',"</thead>",'<tbody id="library_list_body">',"</tbody>","</table>","<% }%>","</div>"].join(""))}})}});
|
||||
//# sourceMappingURL=../../../maps/mvc/library/library-librarylist-view.js.map
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
"use strict";define([],function(){var e=Backbone.Model.extend({urlRoot:Galaxy.root+"api/libraries/",isVisible:function(e){var t=!0;return!e&&this.get("deleted")&&(t=!1),t}}),t=Backbone.Collection.extend({urlRoot:Galaxy.root+"api/libraries",model:e,sort_key:"name",sort_order:null,initialize:function(e){e=e||{}},search:function(e){if(""==e)return this;var t=e.toLowerCase();return this.filter(function(e){return-1!==e.get("name").toLowerCase().indexOf(t)})},getVisible:function(e,o){return o=o||[],new t(this.filter(function(t){return t.isVisible(e)}))},sortByNameAsc:function(){return this.comparator=function(e,t){return e.get("name").toLowerCase()>t.get("name").toLowerCase()?1:t.get("name").toLowerCase()>e.get("name").toLowerCase()?-1:0},this.sort(),this},sortByNameDesc:function(){return this.comparator=function(e,t){return e.get("name").toLowerCase()>t.get("name").toLowerCase()?-1:t.get("name").toLowerCase()>e.get("name").toLowerCase()?1:0},this.sort(),this}}),o=Backbone.Model.extend({}),r=o.extend({urlRoot:Galaxy.root+"api/libraries/datasets/"}),n=o.extend({urlRoot:Galaxy.root+"api/folders/"}),a=Backbone.Collection.extend({model:o,sortByNameAsc:function(){return this.comparator=function(e,t){return e.get("type")===t.get("type")?e.get("name").toLowerCase()>t.get("name").toLowerCase()?1:t.get("name").toLowerCase()>e.get("name").toLowerCase()?-1:0:"folder"===e.get("type")?-1:1},this.sort(),this},sortByNameDesc:function(){return this.comparator=function(e,t){return e.get("type")===t.get("type")?e.get("name").toLowerCase()>t.get("name").toLowerCase()?-1:t.get("name").toLowerCase()>e.get("name").toLowerCase()?1:0:"folder"===e.get("type")?-1:1},this.sort(),this}}),i=Backbone.Model.extend({defaults:{folder:new a,urlRoot:Galaxy.root+"api/folders/",id:"unknown"},parse:function(e){this.get("folder").reset();for(var t=0;t<e.folder_contents.length;t++)if("folder"===e.folder_contents[t].type){var o=new n(e.folder_contents[t]);this.get("folder").add(o)}else if("file"===e.folder_contents[t].type){var a=new r(e.folder_contents[t]);this.get("folder").add(a)}else Galaxy.emit.error("Unknown folder item type encountered while parsing response.");return e}}),s=Backbone.Model.extend({urlRoot:Galaxy.root+"api/histories/"}),l=Backbone.Collection.extend({urlRoot:Galaxy.root+"api/histories/",initialize:function(e){this.id=e.id},url:function(){return this.urlRoot+this.id+"/contents"},model:s}),d=Backbone.Model.extend({urlRoot:Galaxy.root+"api/histories/"}),u=Backbone.Collection.extend({url:Galaxy.root+"api/histories",model:d}),c=Backbone.Model.extend({urlRoot:Galaxy.root+"api/remote_files"});return{Library:e,Libraries:t,Item:r,Ldda:r,FolderAsModel:n,Folder:a,FolderContainer:i,HistoryItem:s,HistoryContents:l,GalaxyHistory:d,GalaxyHistories:u,Jstree:c}});
|
||||
"use strict";define(["mvc/library/library-util"],function(e){var o=Backbone.Model.extend({urlRoot:Galaxy.root+"api/libraries/",isVisible:function(e){var o=!0;return!e&&this.get("deleted")&&(o=!1),o}}),t=Backbone.Collection.extend({urlRoot:Galaxy.root+"api/libraries",model:o,initialize:function(e){e=e||{}},search:function(e){if(""==e)return this;var o=e.toLowerCase();return this.filter(function(e){return-1!==e.get("name").toLowerCase().indexOf(o)})},getVisible:function(e,o){return o=o||[],new t(this.filter(function(o){return o.isVisible(e)}))},sortLibraries:function(o,t){this.comparator=e.generateLibraryComparator(o,t),this.sort()}}),r=Backbone.Model.extend({}),i=r.extend({urlRoot:Galaxy.root+"api/libraries/datasets/"}),n=r.extend({urlRoot:Galaxy.root+"api/folders/"}),a=Backbone.Collection.extend({model:r,sortFolder:function(o,t){this.comparator=e.generateFolderComparator(o,t),this.sort()}}),l=Backbone.Model.extend({defaults:{folder:new a,urlRoot:Galaxy.root+"api/folders/",id:"unknown"},parse:function(e){this.get("folder").reset();for(var o=0;o<e.folder_contents.length;o++)if("folder"===e.folder_contents[o].type){var t=new n(e.folder_contents[o]);this.get("folder").add(t)}else if("file"===e.folder_contents[o].type){var r=new i(e.folder_contents[o]);this.get("folder").add(r)}else Galaxy.emit.error("Unknown folder item type encountered while parsing response.");return e}}),s=Backbone.Model.extend({urlRoot:Galaxy.root+"api/histories/"}),d=Backbone.Collection.extend({urlRoot:Galaxy.root+"api/histories/",initialize:function(e){this.id=e.id},url:function(){return this.urlRoot+this.id+"/contents"},model:s}),c=Backbone.Model.extend({urlRoot:Galaxy.root+"api/histories/"}),u=Backbone.Collection.extend({url:Galaxy.root+"api/histories",model:c}),f=Backbone.Model.extend({urlRoot:Galaxy.root+"api/remote_files"});return{Library:o,Libraries:t,Item:i,Ldda:i,FolderAsModel:n,Folder:a,FolderContainer:l,HistoryItem:s,HistoryContents:d,GalaxyHistory:c,GalaxyHistories:u,Jstree:f}});
|
||||
//# sourceMappingURL=../../../maps/mvc/library/library-model.js.map
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
"use strict";define([],function(){return{generateFolderComparator:function(e,t){return function(r,o){return r.get("type")===o.get("type")?r.has(e)||o.has(e)?r.has(e)?o.has(e)?r.get(e).toLowerCase()>o.get(e).toLowerCase()?"asc"===t?1:-1:o.get(e).toLowerCase()>r.get(e).toLowerCase()?"asc"===t?-1:1:0:-1:1:0:"folder"===r.get("type")?-1:1}},generateLibraryComparator:function(e,t){return function(r,o){return r.get(e).toLowerCase()>o.get(e).toLowerCase()?"asc"===t?1:-1:o.get(e).toLowerCase()>r.get(e).toLowerCase()?"asc"===t?-1:1:0}}}});
|
||||
//# sourceMappingURL=../../../maps/mvc/library/library-util.js.map
|
||||
Reference in New Issue
Block a user