Files
galaxy/static/scripts/mvc/user/extra-information.js
T
2016-12-14 22:46:36 +01:00

2 lines
2.3 KiB
JavaScript

define(["mvc/user/manage-user-information"],function(a){var b=Backbone.View.extend({initialize:function(a){this.render(a)},render:function(a){var b="",c=this,d=null,e=null,f={},g={},h="",i=!1;if($(".user-pref").hide(),$(".donemessage").hide(),$(".errormessage").hide(),f=a.config,g=0===Object.keys(a.plugins).length?{}:JSON.parse(a.plugins),b+='<div class="extra-information-section"> <h2>Extra Information</h2>',b+='<ul class="manage-table-actions"> <li><a class="action-button back-user-pref" target="galaxy_main">User preferences</a></li></ul>',null===f||void 0===f||null===f.preferences||void 0===f.preferences)b+="<div>No plugins available. Please contact your administrator.</div>";else{b+='<div class="toolForm"><form name="extra_information" id="extra_information"><div class="toolFormTitle">Extra Information</div>';for(var j in f.preferences){d=f.preferences[j];var k="";0!==Object.keys(g).length?(h=j,e=g[h]):i=!0,b=b+'<div class="form-row '+h+' ">',b=b+"<label>"+d.description+":</label>";for(var l=0;l<d.inputs.length;l++){var m=d.inputs[l];k=i?"":e?e[m.name]:"",b+='<div class="form-row">',b=b+"<label>"+m.label+':</label><input type="'+m.type+'" name="'+m.name+'" value="'+k+'" />',b+="</div>"}b+="</div>"}b+='<div class="form-row"><input type="button" class="save-extra-info action-button" name="save_extra_information" value="Save"/>',b+="</div></div></form></div>"}b+="</div>",$(".user-preferences-all").append(b),$(".save-extra-info").on("click",function(a){c.saveExtraInformation(c,a)}),$(".back-user-pref").on("click",function(){$(".extra-information-section").remove(),$(".donemessage").hide(),$(".errormessage").hide(),$(".user-pref").show()})},saveExtraInformation:function(){var b=Galaxy.root+"api/user_preferences/save_extra_preferences/",c=($("input[name='username']").val(),$("input[name='password']").val(),$("input[name='url']").val(),{}),d=a.ManageUserInformation.prototype,e=!0;$(".form-row input").each(function(){if("text"===$(this).attr("type")||"password"===$(this).attr("type")){var a=$($(this).parent().parent()[0]).attr("class").split(" ")[1],b={};attrname=$(this).attr("name"),attrvalue=$(this).val(),b[$(this).attr("name")]=attrvalue,c[a]?c[a][attrname]=attrvalue:c[a]=b}}),e&&$.getJSON(b,{plugin_data:JSON.stringify(c)},function(a){d.renderDone(a.message)})}});return{ExtraInformation:b}});
//# sourceMappingURL=../../../maps/mvc/user/extra-information.js.map