js.dataexplorer-directory.min.js Maven / Gradle / Ivy
var i18nDeferred=$.Deferred();window.top.molgenis.I18nStrings(function(a){i18nDeferred.resolve(a)});$.when($,window.top.molgenis,i18nDeferred.promise()).then(function(e,b,d){b.dataexplorer=b.dataexplorer||{};function c(){var m=b.dataexplorer.getSelectedEntityMeta().name;var l=b.dataexplorer.getSearchQuery();var j=b.dataexplorer.getRSQL();var k=[];var h=[];if(l){k.push("*=q="+b.rsql.toRsqlValue(l));h.push("Free text search contains "+l)}if(j){k.push(j);h.push(b.rsql.getHumanReadable(j))}var n=b.rsql.encodeRsqlValue(k.join(";"));var g=h.join(" and ");var i=window.location.href.replace(/&nToken=\w{32}/,"");return{URL:i,entityId:m,rsql:n,humanReadable:g,nToken:b.dataexplorer.getnToken()}}function a(g){e.ajax({method:"POST",dataType:"json",url:"/plugin/directory/export",data:JSON.stringify(g),contentType:"application/json",success:function(h){window.location.href=h}})}function f(){var g=c();e.ajax({method:"POST",dataType:"json",url:"/plugin/directory/validate",data:JSON.stringify(g),contentType:"application/json",success:function(h){if(h.isValid){if(!h.message){bootbox.confirm({title:d.dataexplorer_directory_export_dialog_title,message:d.dataexplorer_directory_export_dialog_message,buttons:{confirm:{label:d.dataexplorer_directory_export_dialog_yes},cancel:{label:d.dataexplorer_directory_export_dialog_no}},callback:function(j){if(j){a(g)}}})}else{var i=e("#negotiator-modal");i.on("show.bs.modal",function(m){var l=e(this);l.find("#negotiator-message").text(h.message);var k=l.find("#enabled-collections-list");var j=l.find("#disabled-collections-list");e.each(h.enabledCollections,function(o,n){k.append(e("").text(n))});e.each(h.disabledCollections,function(o,n){j.append(e(" ").text(n))});l.find("#negotiator-apply-btn").click(function(){a(g)})});i.on("hidden.bs.modal",function(k){var j=e(this);j.find("#enabled-collections-list").empty();j.find("#disabled-collections-list").empty();j.find("#negotiator-apply-btn").off("click");i.off("show.bs.modal");i.off("hidden.bs.modal")});i.modal("show")}}else{bootbox.alert({title:d.dataexplorer_directory_export_dialog_warning_title,message:h.message})}}})}e(function(){e("#directory-export-button").on("click",function(){if(!b.dataexplorer.getRSQL()&&!b.dataexplorer.getSearchQuery()){bootbox.alert(d.dataexplorer_directory_export_no_filters);return}f()})})});