Skip to content
Permalink
Browse files

Merge pull request #4595 from martenson/datalib-various-fixes

Datalibs various fixes
  • Loading branch information...
erasche committed Sep 14, 2017
2 parents a6acf11 + ba3ffd8 commit a9bfb04caa41129ffb524b1caf880f1ce90544b5
@@ -248,10 +248,6 @@ var LibraryDatasetView = Backbone.View.extend({
});
},

goBack: function(){
Galaxy.libraries.library_router.back();
},

showPermissions: function(options){
this.options = _.extend(this.options, options);
$(".tooltip").remove();
@@ -270,11 +266,13 @@ var LibraryDatasetView = Backbone.View.extend({
var template = this.templateDatasetPermissions();
this.$el.html(template({item: this.model, is_admin: is_admin}));
var self = this;
$.get( Galaxy.root + "api/libraries/datasets/" + self.id + "/permissions?scope=current").done(function(fetched_permissions) {
self.prepareSelectBoxes({fetched_permissions: fetched_permissions, is_admin: is_admin});
}).fail(function(){
mod_toastr.error('An error occurred while attempting to fetch dataset permissions.');
});
$.get(Galaxy.root + "api/libraries/datasets/" + self.id + "/permissions?scope=current")
.done(function(fetched_permissions) {
self.prepareSelectBoxes({fetched_permissions: fetched_permissions, is_admin: is_admin});
})
.fail(function(){
mod_toastr.error('An error occurred while attempting to fetch dataset permissions.');
});
$("#center [data-toggle]").tooltip();
$("#center").css('overflow','auto');
},
@@ -49,10 +49,6 @@ var FolderView = Backbone.View.extend({
});
},

goBack: function(){
Galaxy.libraries.library_router.back();
},

showPermissions: function(options){
this.options = _.extend(this.options, options);
$(".tooltip").remove();
@@ -942,8 +942,8 @@ var FolderToolbarView = Backbone.View.extend({
chainCallDeletingItems: function( items_to_delete ){
var self = this;
this.deleted_items = new mod_library_model.Folder();
var popped_item = items_to_delete.pop();
if ( typeof popped_item === "undefined" ) {
var item_to_delete = items_to_delete.pop();
if ( typeof item_to_delete === "undefined" ) {
if ( this.options.chain_call_control.failed_number === 0 ){
mod_toastr.success( 'Selected items were deleted.' );
} else if ( this.options.chain_call_control.failed_number === this.options.chain_call_control.total_number ){
@@ -954,10 +954,9 @@ var FolderToolbarView = Backbone.View.extend({
Galaxy.modal.hide();
return this.deleted_items;
}
var promise = $.when( popped_item.destroy() );

promise.done( function( item ){
Galaxy.libraries.folderListView.collection.remove( popped_item.id );
item_to_delete.destroy()
.done( function( item ){
Galaxy.libraries.folderListView.collection.remove( item_to_delete.id );
self.updateProgress();
// add the deleted item to collection, triggers rendering
if ( Galaxy.libraries.folderListView.options.include_deleted ){
@@ -974,11 +973,11 @@ var FolderToolbarView = Backbone.View.extend({
}
self.chainCallDeletingItems( items_to_delete );
})
.fail( function(){
self.options.chain_call_control.failed_number += 1;
self.updateProgress();
self.chainCallDeletingItems( items_to_delete );
});
.fail( function(){
self.options.chain_call_control.failed_number += 1;
self.updateProgress();
self.chainCallDeletingItems( items_to_delete );
});
},

/**
@@ -996,8 +995,10 @@ var FolderToolbarView = Backbone.View.extend({
* Delete the selected items. Atomic. One by one.
*/
deleteSelectedItems: function(){
var checkedValues = $('#folder_table').find(':checked');
if(checkedValues.length === 0){
var dataset_ids = [];
var folder_ids = [];
var $checkedValues = $('#folder_table').find(':checked');
if($checkedValues.length === 0){
mod_toastr.info('You must select at least one item for deletion.');
} else {
var template = this.templateDeletingItemsProgressBar();
@@ -1013,10 +1014,7 @@ var FolderToolbarView = Backbone.View.extend({
// init the control counters
this.options.chain_call_control.total_number = 0;
this.options.chain_call_control.failed_number = 0;

var dataset_ids = [];
var folder_ids = [];
checkedValues.each(function(){
$checkedValues.each(function(){
var row_id = $(this).closest('tr').data('id');
if (row_id !== undefined) {
if (row_id.substring(0,1) == 'F'){
@@ -1042,7 +1040,7 @@ var FolderToolbarView = Backbone.View.extend({
items_to_delete.push(folder);
}

this.options.chain_call_control.total_number = items_total.length;
this.options.chain_call_control.total_number = items_total;
// call the recursive function to call ajax one after each other (request FIFO queue)
this.chainCallDeletingItems(items_to_delete);
}
@@ -49,10 +49,6 @@ var LibraryView = Backbone.View.extend({
});
},

goBack: function(){
Galaxy.libraries.library_router.back();
},

showPermissions: function(options){
this.options = _.extend(this.options, options);
$(".tooltip").remove();

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more.

Large diffs are not rendered by default.

0 comments on commit a9bfb04

Please sign in to comment.
You can’t perform that action at this time.