Skip to content

Commit

Permalink
Migrate inline handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
labkey-adam committed Mar 7, 2024
1 parent 44b479e commit 0a5f980
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 19 deletions.
10 changes: 6 additions & 4 deletions viscstudies/resources/views/updateStudyProperties.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
var _studiesByContainer = {};
var _updates = [];

LABKEY.NavTrail.setTrail("Update Study Information");
function getStudyDesigns(config)
{
var params = {includeSubfolders:config.includeSubfolders};
Expand Down Expand Up @@ -85,9 +84,12 @@
}

doNextUpdate();


}

LABKEY.Utils.onReady(function(){
LABKEY.NavTrail.setTrail("Update Study Information");
document.getElementById('updateButton')['onclick'] = doUpdates;
});
</script>
<div id="updateList"></div>
<button id="updateButton" onclick="doUpdates();">Update</button>
<button id="updateButton">Update</button>
40 changes: 25 additions & 15 deletions viscstudies/webapp/viscstudies/study.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,6 @@ function graphicalVaccinationSummary(design)
}

return html + "</table><br><br>";


}

function findVaccination(design, cohort, timepoint)
Expand Down Expand Up @@ -281,7 +279,7 @@ function Facet(id, caption, getOptionsFn) {
this.caption = caption;
this.getOptionsForStudy = getOptionsFn;
this.selected = {};
};
}

Facet.prototype = {
allOptions:[],
Expand Down Expand Up @@ -378,30 +376,42 @@ var immunogenFacet = new Facet("immunogens", "Immunogens", function (info) {
var facets = [immunogenFacet, investigatorFacet, speciesFacet, adjuvantFacet];
function initFacets()
{
for (var f = 0; f < facets.length; f++)
for (let f = 0; f < facets.length; f++)
{
var facet = facets[f];
var header = "<span style='display:inline-block;padding:8px;border-right:1px solid lightgray'><h3 style='margin-bottom:0px;padding-top:0;margin-top:0' id='facet_header_" + facet.id +"' >" + h(facet.caption) + "</h3><span id='facet_summary_" + facet.id +"'>Showing all " + h(facet.caption) + " </span></span>";
var html = "<span id='facet_body_" + facet.id + "'>";
html += "<a href='#' onclick='selectAll(\"" + facet.id + "\");return false;'>Show All</a><br><br>" ;
var html = "<span id='facet_body_" + facet.id + "'>";
html += "<a id='showAll_" + facet.id + "'>Show All</a><br><br>" ;
facet.init(_allStudies);
html += "<table><tr><td valign=top>";
var colLength = Math.round(facet.allOptions.length / 3);
for (var i = 0; i < facet.allOptions.length; i++)
const colLength = Math.round(facet.allOptions.length / 3);
for (let i = 0; i < facet.allOptions.length; i++)
{
var option = facet.allOptions[i];
html += "<input type='checkbox' id='" + checkboxId(facet, i) + "' checked onclick='optionClicked(this, \"" + facet.id + "\", " + i + ")'>";
html += "<a href='#' onclick='selectOnly(\"" + facet.id + "\"," +i + ");return false;'>"+ h(option.name) + "</a><br>";
if (i == colLength || i == colLength * 2)
let option = facet.allOptions[i];
html += "<input type='checkbox' id='" + checkboxId(facet, i) + "' checked>";
html += "<a href='#' id='selectOnly_" + i + "'>"+ h(option.name) + "</a><br>";
if (i === colLength || i === colLength * 2)
html += "</td><td valign=top>";

}
html += "</td></tr></table></span>";
Ext.get("facets").insertHtml("beforeEnd", header);

var tip = new LABKEY.ext.CalloutTip({target:"facet_header_" + facet.id, html:html, closable:true});
const id = facet.id;
const facet2 = facet;
const tip = new LABKEY.ext.CalloutTip({target:"facet_header_" + facet.id, html:html, closable:true});
tip.on("render", function(t) {
t.getEl().alignTo("facet_header_" + facet.id, "tl-bl");
t.getEl().alignTo("facet_header_" + id, "tl-bl");
});
tip.on("afterrender", function(t) {
// Attach event handlers after HTML is rendered
document.getElementById('showAll_' + id)['click'] = function() { selectAll(id); return false;}
for (let i = 0; i < facet2.allOptions.length; i++)
{
const id = facet2.id;
const idx = i;
document.getElementById(checkboxId(facet2, i))['click'] = function() { optionClicked(this, id, idx); };
document.getElementById('selectOnly_' + i)['click'] = function() { selectOnly(id, i); return false; }
}
});
}
}
Expand Down

0 comments on commit 0a5f980

Please sign in to comment.