resq/templates/notification/list.html.twig

118 lines
3.9 KiB
Twig

{% extends 'base.html.twig' %}
{% block body %}
<!-- BEGIN: Subheader -->
<div class="m-subheader">
<div class="d-flex align-items-center">
<div class="mr-auto">
<h3 class="m-subheader__title">
Notifications
</h3>
</div>
</div>
</div>
<!-- END: Subheader -->
<div class="m-content">
<!--Begin::Section-->
<div class="row">
<div class="col-xl-12">
<div class="m-portlet m-portlet--mobile">
<div class="m-portlet__body">
<div class="m-form m-form--label-align-right m--margin-top-20 m--margin-bottom-30">
<div class="row align-items-center">
<div class="m-separator m-separator--dashed d-xl-none"></div>
</div>
</div>
<!--begin: Datatable -->
<div id="data-rows"></div>
<!--end: Datatable -->
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% block scripts %}
<script>
$(function() {
var options = {
data: {
type: 'remote',
source: {
read: {
url: '{{ url("notification_rows") }}',
method: 'POST',
}
},
saveState: {
cookie: false,
webstorage: false
},
pageSize: 10,
serverPaging: true,
serverFiltering: true,
serverSorting: true
},
rows: {
beforeTemplate: function(row, data, index) {
console.log(data.flag_read);
if (data.flag_read) {
$(row).addClass('m-table__row--primary');
}
else {
$(row).addClass('m-table__row--danger');
}
}
},
columns: [
{
field: 'id',
title: 'ID',
width: 30
},
{
field: 'message',
title: 'Message'
},
{
field: 'notif_type',
title: 'Notification Type'
},
{
field: 'Actions',
width: 110,
title: 'Actions',
sortable: false,
overflow: 'visible',
template: function (row, index, datatable) {
var actions = '';
if (row.meta.view_jo_url != '') {
actions += '<a href="' + row.meta.view_jo_url + '" class="m-portlet__nav-link btn m-btn m-btn--hover-accent m-btn--icon m-btn--icon-only m-btn--pill btn-edit" data-id="' + row.id + '" title="View JO"><i class="la la-edit"></i></a>';
}
return actions;
},
}
]
};
var table = $("#data-rows").mDatatable(options);
$(document).on('click', '.btn-edit', function(e) {
var url = $(this).prop('href');
var id = $(this).data('id');
console.log(id);
$.ajax({
method: 'POST',
url: "{{ url('notification_ajax_read') }}",
data: { id: id }
}).done(function(response) {
console.log(response);
}).error(function(err) {
console.log(err);
});
});
});
</script>
{% endblock %}