Skip to content

Commit

Permalink
fixing bugs related to empty data or config
Browse files Browse the repository at this point in the history
  • Loading branch information
anuprulez committed Aug 12, 2016
1 parent ff9f39a commit 85fde4c
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 31 deletions.
70 changes: 47 additions & 23 deletions client/galaxy/scripts/mvc/user/extra-information.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,70 @@ var ExtraInformation = Backbone.View.extend({

/** renders the markup of extra information */
render: function( data_plugin ) {
data = data_plugin["config"],
plugins = JSON.parse(data_plugin["plugins"]) ;
var template = "",
self = this,
item_object = null,
model = null;
model = null,
data = {},
plugins = {},
plugin_name = "",
is_plugin_empty = false;

$( '.user-pref' ).hide();
$( '.donemessage' ).hide();
$( '.errormessage' ).hide();

data = data_plugin["config"];

plugins = ( Object.keys( data_plugin["plugins"]).length === 0 ) ? {} : JSON.parse( data_plugin["plugins"] );

template = template + '<div class="extra-information-section"> <h2>Extra Information</h2>';
template = template + '<ul class="manage-table-actions"> <li>' +
'<a class="action-button back-user-pref" target="galaxy_main">User preferences</a>' +
'</li></ul>';
'</li></ul>';

template = template + '<div class="toolForm">' +
'<form name="extra_information" id="extra_information">' +
if( data === null || data === undefined || data["preferences"] === null || data["preferences"] === undefined ) {
template = template + "<div>No plugins available. Please contact your administrator.</div>";
}
else {
template = template + '<div class="toolForm">' +
'<form name="extra_information" id="extra_information">' +
'<div class="toolFormTitle">Extra Information</div>';
for( var item in data["preferences"] ) {
item_object = data["preferences"][item];
// sets the model for each plugin data and
// values to each input field
for( var item in data["preferences"] ) {

item_object = data["preferences"][item];
// sets the model for each plugin data and
// values to each input field
var input_val = "";
if( Object.keys(plugins).length !== 0 ) {
plugin_name = item_object["name"];
model = plugins[plugin_name];
}
else {
is_plugin_empty = true;
}

model = item_object["name"];
template = template + '<div class="form-row '+ item_object["name"] +' ">';
template = template + "<label>" + item_object["description"] + ":</label>";

template = template + '<div class="form-row '+ item_object["name"] +' ">';
template = template + "<label>" + item_object["description"] + ":</label>";
for( var i = 0; i < item_object["inputs"].length; i++ ) {
var input_object = item_object["inputs"][i];
template = template + '<div class="form-row">';
template = template + "<label>" + input_object.label + ':</label><input type="'+ input_object.type +
'" name="'+ input_object.name +'" value="'+ model[input_object.name] +'" '
+ (input_object.required ? 'required': '') + '/>';
for( var i = 0; i < item_object["inputs"].length; i++ ) {
var input_object = item_object["inputs"][i];
input_val = ( is_plugin_empty ? "" : ( !model ? "" : model[input_object.name] ) );
template = template + '<div class="form-row">';
template = template + "<label>" + input_object.label + ':</label><input type="'+ input_object.type +
'" name="'+ input_object.name +'" value="'+ input_val +'" '
+ (input_object.required ? 'required': '') + '/>';
template = template + '</div>';
}
template = template + '</div>';
}
template = template + '</div>';
}

template = template + '<div class="form-row">' +
template = template + '<div class="form-row">' +
'<input type="button" class="save-extra-info action-button" name="save_extra_information" value="Save"/>';
template = template + '</div></div></form></div></div>';
template = template + '</div></div></form></div>';
}

template = template + '</div>';
$('.user-preferences-all').append( template );
$('.save-extra-info').on( 'click', function( e ) { self.saveExtraInformation( self, e ) } );
$('.back-user-pref').on( 'click', function( e ) {
Expand Down
7 changes: 2 additions & 5 deletions lib/galaxy/webapps/galaxy/api/user_preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,8 +559,9 @@ def get_extra_preferences( self, trans, cntrller='user_preferences', **kwd ):
log.error('Config file (%s) could not be found or is malformed.' % path)

user = trans.user
plugin_data = user.preferences.get("dynamic_user_preferences", '{}')
plugin_data = user.preferences.get("dynamic_user_preferences", "{}")
log.warn(plugin_data)

# deserializes the json and returns to the client
return { "config": config,
"plugins": json.loads(plugin_data)
Expand All @@ -584,8 +585,4 @@ def save_extra_preferences( self, trans, cntrller='user_preferences', **kwd ):
'message': "The data was successfully saved",
'status': "done"
}





4 changes: 2 additions & 2 deletions static/scripts/bundled/libs.bundled.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion static/scripts/bundled/libs.bundled.js.map

Large diffs are not rendered by default.

0 comments on commit 85fde4c

Please sign in to comment.