myMedisys/tomcatfiles/mymedisys-frontend/WEB-INF/classes/scripts/wps/history.js
2023-09-06 05:56:42 +05:30

75 lines
2.8 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 ) {
console.log(data);
var buttons = action.viewButton;
return buttons;
}
},
],
"ajax": $.fn.dataTable.pipeline({
"pages" : 1,
"type" : "GET",
"url": contextPath + "/tasks/history/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.history = 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;
});
});