Skip to content

Commit b22a685

Browse files
committed
Remove onclick handlers
1 parent 685f5db commit b22a685

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

SequenceAnalysis/src/org/labkey/sequenceanalysis/query/DownloadSequenceDisplayColumnFactory.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,16 @@
66
import org.labkey.api.data.DisplayColumn;
77
import org.labkey.api.data.DisplayColumnFactory;
88
import org.labkey.api.data.RenderContext;
9-
import org.labkey.api.data.Sort;
10-
import org.labkey.api.data.UrlColumn;
119
import org.labkey.api.query.FieldKey;
1210
import org.labkey.api.util.PageFlowUtil;
13-
import org.labkey.api.util.StringExpression;
14-
import org.labkey.api.util.StringExpressionFactory;
15-
import org.labkey.api.util.URLHelper;
11+
import org.labkey.api.view.HttpView;
1612
import org.labkey.api.view.template.ClientDependency;
1713

1814
import java.io.IOException;
1915
import java.io.Writer;
20-
import java.util.Arrays;
2116
import java.util.Collections;
2217
import java.util.LinkedHashSet;
18+
import java.util.Map;
2319
import java.util.Set;
2420

2521
/**
@@ -39,11 +35,21 @@ public DisplayColumn createRenderer(ColumnInfo colInfo)
3935
{
4036
DataColumn ret = new DataColumn(colInfo)
4137
{
38+
private boolean _handlerRegistered = false;
39+
4240
@Override
4341
public void renderGridCellContents(RenderContext ctx, Writer out) throws IOException
4442
{
4543
Object val = ctx.get(FieldKey.fromString(getBoundColumn().getFieldKey().getParent(), "rowId"));
46-
out.write(PageFlowUtil.link("Download Sequence").onClick("SequenceAnalysis.window.DownloadSequencesWindow.downloadSingle(" + val + ")").toString());
44+
out.write(PageFlowUtil.link("Download Sequence").attributes(Map.of(
45+
"data-rowid", val.toString()
46+
)).addClass("sdc-row").toString());
47+
48+
if (!_handlerRegistered)
49+
{
50+
HttpView.currentPageConfig().addHandlerForQuerySelector("a.sdc-row", "click", "SequenceAnalysis.window.DownloadSequencesWindow.downloadSingle(this.attributes.getNamedItem('data-rowid').value); return false;");
51+
_handlerRegistered = true;
52+
}
4753
}
4854

4955
@Override

SequenceAnalysis/src/org/labkey/sequenceanalysis/query/SequenceAnalysisCustomizer.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.labkey.api.security.User;
2929
import org.labkey.api.util.PageFlowUtil;
3030
import org.labkey.api.view.ActionURL;
31+
import org.labkey.api.view.HttpView;
3132
import org.labkey.api.view.template.ClientDependency;
3233
import org.labkey.sequenceanalysis.SequenceAnalysisSchema;
3334

@@ -232,6 +233,8 @@ public DisplayColumn createRenderer(ColumnInfo colInfo)
232233
{
233234
return new DataColumn(colInfo)
234235
{
236+
private boolean _handlerRegistered = false;
237+
235238
@Override
236239
public @NotNull Set<ClientDependency> getClientDependencies()
237240
{
@@ -275,8 +278,13 @@ public void renderGridCellContents(RenderContext ctx, Writer out) throws IOExcep
275278
}
276279
}
277280

278-
String onclick = "onclick=\"SequenceAnalysis.window.ManageFileSetsWindow.buttonHandlerForOutputFiles(" + PageFlowUtil.jsString(rowId.toString()) + ", " + PageFlowUtil.jsString(ctx.getCurrentRegion().getName()) + ");\"";
279-
out.write("<a class=\"fa fa-pencil lk-dr-action-icon\" data-tt=\"tooltip\" data-original-title=\"add/edit\" " + onclick + "></a>");
281+
out.write("<a class=\"fa fa-pencil lk-dr-action-icon sfs-row\" data-tt=\"tooltip\" data-rowid=\"" + rowId +"\" data-original-title=\"add/edit\"></a>");
282+
283+
if (!_handlerRegistered)
284+
{
285+
HttpView.currentPageConfig().addHandlerForQuerySelector("a.sfs-row", "click", "SequenceAnalysis.window.ManageFileSetsWindow.buttonHandlerForOutputFiles(this.attributes.getNamedItem('data-rowid').value, " + PageFlowUtil.jsString(ctx.getCurrentRegion().getName()) + "); return false;");
286+
_handlerRegistered = true;
287+
}
280288
}
281289
}
282290
};

0 commit comments

Comments
 (0)