Skip to content

Commit

Permalink
Fix deferred dom removal
Browse files Browse the repository at this point in the history
Remove empty line

Fix comments

Fix log location

Fix comments
  • Loading branch information
guerler committed Oct 27, 2015
1 parent 5f3fbde commit c70c1aa
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 40 deletions.
6 changes: 4 additions & 2 deletions client/galaxy/scripts/mvc/app/app-analysis.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ define(['utils/utils', 'mvc/tools', 'mvc/upload/upload-view', 'mvc/ui/ui-misc',
));
}
},
display: function( $el ) {
display: function( view ) {
this.prev && this.prev.remove();
this.prev = view;
this.$( '#galaxy_main' ).hide();
this.$( '#center-panel' ).empty().scrollTop( 0 ).append( $el ).show();
this.$( '#center-panel' ).scrollTop( 0 ).append( view.$el ).show();
},
_template: function() {
return '<div style="position: absolute; width: 100%; height: 100%">' +
Expand Down
2 changes: 1 addition & 1 deletion client/galaxy/scripts/mvc/dataset/dataset-li-edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ var DatasetListItemEdit = _super.extend(
ev.preventDefault();
var form = new ToolsForm.View({'job_id' : creating_job});
form.deferred.execute(function(){
Galaxy.app.display(form.$el);
Galaxy.app.display(form);
});
}
});
Expand Down
2 changes: 1 addition & 1 deletion client/galaxy/scripts/mvc/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ var ToolLinkView = BaseView.extend({
e.preventDefault();
var form = new ToolsForm.View( { id : self.model.id, version : self.model.get('version') } );
form.deferred.execute(function() {
Galaxy.app.display( form.$el );
Galaxy.app.display( form );
});
});
}
Expand Down
29 changes: 13 additions & 16 deletions client/galaxy/scripts/mvc/tools/tools-form-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ define(['utils/utils', 'utils/deferred', 'mvc/ui/ui-misc', 'mvc/form/form-view',
}
},

/** Wait for deferred build processes before removal */
remove: function() {
var self = this;
this.$el.hide();
this.deferred.execute(function(){
Backbone.View.prototype.remove.call(self);
});
},

/** Build form */
_buildForm: function(options) {
// link this
Expand Down Expand Up @@ -87,32 +96,17 @@ define(['utils/utils', 'utils/deferred', 'mvc/ui/ui-misc', 'mvc/form/form-view',
url : build_url,
data : build_data,
success : function(new_model) {
// rebuild form
self._buildForm(new_model['tool_model'] || new_model);

// show version message
!hide_message && self.form.message.update({
status : 'success',
message : 'Now you are using \'' + self.options.name + '\' version ' + self.options.version + '.',
persistent : false
});

// process completed
self.deferred.done(process_id);

// log success
console.debug('tools-form::initialize() - Initial tool model ready.');
console.debug(new_model);
self.deferred.done(process_id);
},
error : function(response) {
// process completed
self.deferred.done(process_id);

// log error
console.debug('tools-form::initialize() - Initial tool model request failed.');
console.debug(response);

// show error
var error_message = ( response && response.err_msg ) || 'Uncaught error.';
if ( self.$el.is(':empty') ) {
self.$el.prepend((new Ui.Message({
Expand All @@ -132,6 +126,9 @@ define(['utils/utils', 'utils/deferred', 'mvc/ui/ui-misc', 'mvc/form/form-view',
}
});
}
console.debug('tools-form::initialize() - Initial tool model request failed.');
console.debug(response);
self.deferred.done(process_id);
}
});
},
Expand Down
15 changes: 5 additions & 10 deletions client/galaxy/scripts/utils/deferred.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,13 @@ define(['utils/utils'], function(Utils) {
* This class provides an alternative way to handle deferred processes. It makes it easy to handle multiple and overlapping sets of deferred processes.
*/
return Backbone.Model.extend({
// callback queue
queue: [],

// list of currently registered processes
process: {},

// process counter
counter: 0,

/** Initialize
*/
initialize: function(){
this.queue = [];
this.process = {};
this.counter = 0;
this.queue_id = Utils.uid();
this.on('refresh', function() {
if (this.queue.length > 0 && this.ready()) {
var callback = this.queue[0];
Expand All @@ -37,7 +32,7 @@ return Backbone.Model.extend({
/** This is called to register a new process
*/
register: function() {
var id = Utils.uid();
var id = this.queue_id + ':' + Utils.uid();
this.process[id] = true;
this.counter++;
console.debug('Deferred:register() - Register ' + id);
Expand Down
2 changes: 1 addition & 1 deletion static/maps/mvc/app/app-analysis.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c70c1aa

Please sign in to comment.