98 lines
3.5 KiB
JavaScript
98 lines
3.5 KiB
JavaScript
$(document).ready(function() {
|
|
var oTableTaskLst = $('#tblTaskLst').DataTable({
|
|
"processing": true,
|
|
"serverSide": true,
|
|
'responsive': true,
|
|
'destroy' : true,
|
|
"columns": [
|
|
{ "data": "status", "orderable" : false,
|
|
"render": function ( data, type, row ) {
|
|
var status = "-";
|
|
if(data) {
|
|
status = "<span class='badge badge-pill " + data.legendColor + "'>" + data.statusDesc + "</span>";
|
|
}
|
|
return status;
|
|
}
|
|
},
|
|
{ "data": "taskMasterId" },
|
|
{ "data": "appDate" },
|
|
{ "data": "applicant" },
|
|
{ "data": "type.description" },
|
|
{ "data": null, className: 'td-actions text-right', "orderable" : false,
|
|
"render": function ( data, type, row ) {
|
|
var buttons = '<button type="button" rel="tooltip" class="btn btn-info mr-1 claim" data-original-title="Claim" title="Claim">' +
|
|
'<i class="material-icons">system_update_alt</i>' +
|
|
'</button>' + action.viewButton;
|
|
return buttons;
|
|
}
|
|
},
|
|
],
|
|
"ajax": $.fn.dataTable.pipeline({
|
|
"pages" : 1,
|
|
"type" : "GET",
|
|
"url": contextPath + "/tasks/pool/paginated",
|
|
"action": 'xhttp',
|
|
"cache": false,
|
|
'beforeSend': dtRequestHeader,
|
|
'dataType': 'json',
|
|
"dataSrc": dtDataSrc,
|
|
"data": function ( data ) {
|
|
data.taskMasterId = $("#taskMasterId").val();
|
|
data.statusId = $('#status').find(":selected").val();
|
|
data.pool = true;
|
|
},
|
|
"error": function(){ // error handling
|
|
console.log("error");
|
|
}
|
|
}),
|
|
"initComplete": function(settings, json) {
|
|
$('input#taskMasterId').unbind();
|
|
$('input#status').unbind();
|
|
$('#searchFilter').bind('click', function(e) {
|
|
portalUtil.showMainLoading(true);
|
|
oTableTaskLst
|
|
.column(1).search($('input#taskMasterId').val())
|
|
.column(2).search($('#status').find(":selected").val())
|
|
oTableTaskLst.draw();
|
|
$(".em-toggle").click();
|
|
});
|
|
$('#searchClear').bind('click', function(e) {
|
|
$('input#taskMasterId').val("")
|
|
$("#status").val("").select2();
|
|
oTableTaskLst.columns().search("").draw();
|
|
$(".em-toggle").click();
|
|
});
|
|
|
|
},
|
|
"fnDrawCallback": function ( oSettings ) { hidePagination(this,"#tblTaskLst"); portalUtil.showMainLoading(false);}
|
|
});
|
|
|
|
$('#tblTaskLst').dataTable().fnSetFilteringEnterPress();
|
|
$('#tblTaskLst tbody').on( 'click', 'button.view', function () {
|
|
var d = oTableTaskLst.row( $(this).parents('tr') ).data();
|
|
location.href = contextPath + "/tasks/application?id=" + d.taskMasterId;
|
|
});
|
|
$('#tblTaskLst tbody').on( 'click', 'button.claim', function () {
|
|
var d = oTableTaskLst.row( $(this).parents('tr') ).data();
|
|
var inputUrl = contextPath + "/tasks/claim";
|
|
var dataArr = {};
|
|
dataArr.taskMasterId = d.taskMasterId
|
|
$.ajax({
|
|
async : false,
|
|
global : false,
|
|
headers : {
|
|
'X-CSRF-Token' : csrf_token
|
|
},
|
|
type : "POST",
|
|
action : 'xhttp',
|
|
url : inputUrl,
|
|
data: dataArr,
|
|
success : function(data) {
|
|
if(data == 'success') {
|
|
oTableTaskLst.clearPipeline();
|
|
oTableTaskLst.ajax.reload();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}); |