Skip to content

Commit 38fd41e

Browse files
committed
Append sample ids in the addAllCheckedSample function in SampleController.groovy
1 parent 904800a commit 38fd41e

2 files changed

Lines changed: 20 additions & 20 deletions

File tree

pegr/grails-app/controllers/pegr/SampleController.groovy

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -349,20 +349,18 @@ class SampleController {
349349

350350
def clearCheckedSampleAjax(){
351351
if (session.checkedSample) {
352-
session.checkedSample = []
353-
// session.checkedSample = null
352+
session.checkedSample = null
354353
}
355-
render session.checkedSample.size()
354+
render true
356355
}
357356

358357
// add all checked sample ids to the current session
359-
def addAllCheckedSampleAjax(Long[] ids) {
360-
def sampleIdsList= JSON.parse(params.sampleIdsList)
361-
if (session.checkedSample) {
362-
session.checkedSample = []
363-
}
364-
sampleIdsList.each{
365-
session.checkedSample << it.toLong()
358+
def addAllCheckedSampleAjax() {
359+
def sampleList = JSON.parse(params.sampleIdsList)
360+
session.checkedSample = []
361+
362+
sampleList.each{
363+
session.checkedSample.push(it.toLong())
366364
}
367365
render session.checkedSample.size()
368366
}

pegr/grails-app/views/sample/search.gsp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<title>Samples</title>
44
<g:set var="defaultGalaxy" value="${defaultGalaxy}" scope="request"/>
55
<meta name="layout" content="analysis"/>
6-
<!-- <asset:javascript src="cookie.js"/> -->
6+
<asset:javascript src="cookie.js"/>
77
<link rel="stylesheet" type="text/css" href="http://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css"></style>
88
<script type="text/javascript" src="http://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
99
</head>
@@ -23,11 +23,12 @@
2323
});
2424
2525
$(document).ready(function(){
26-
// hedgiejo: reset all the checkboxes and checkedCount (View Checked Samples number)
26+
// BugFix || git:hedgiejo || Reset all the checkboxes and checkedCount when reloading
27+
$('#selectAll').prop('checked', false);
28+
$('.checkbox').prop('checked', false);
2729
$.ajax({url:"/pegr/sample/clearCheckedSampleAjax", success: function(checkedCount) {
28-
$('.checkbox').prop('checked', false);
29-
$('#selectAll').prop('checked', false);
30-
$("#checked-count").text(checkedCount);
30+
checkedCount = 0;
31+
$("#checked-count").text(checkedCount);
3132
}});
3233
3334
$('#table_id').DataTable()({
@@ -38,26 +39,27 @@
3839
});
3940
});
4041
41-
//BugFix || git:hedgiejo || Add checkbox feature that can select and deselect all checkboxes.
42+
// BugFix || git:hedgiejo || Add checkbox feature that can select and deselect all checkboxes.
4243
$('#selectAll').click(function(checkedCount) {
4344
if (this.checked) {
4445
var sampleIds = [];
4546
$('.checkbox').prop('checked', true);
4647
$('.checkbox').each(function(){
4748
sampleIds.push(this.value);
4849
})
50+
console.log(JSON.stringify(sampleIds))
4951
$.ajax({
50-
url:"${createLink(controller: 'sample', action: 'addAllCheckedSampleAjax')}",
51-
type:"GET",
52-
data: {"sampleIdsList": JSON.stringify(sampleIds)},
52+
url:"/pegr/sample/addAllCheckedSampleAjax",
53+
data: {"sampleIdsList":JSON.stringify(sampleIds)},
5354
success : function(checkedCount){
5455
$("#checked-count").text(checkedCount);
5556
}
5657
});
5758
}
5859
else {
59-
$.ajax({url:"/pegr/sample/clearCheckedSampleAjax", success: function(checkedCount) {
6060
$('.checkbox').prop('checked', false);
61+
$.ajax({url:"/pegr/sample/clearCheckedSampleAjax", success: function(checkedCount) {
62+
checkedCount = 0;
6163
$("#checked-count").text(checkedCount);
6264
}});
6365
}

0 commit comments

Comments
 (0)