Fixed setting of colors for special JO rows. #674
This commit is contained in:
parent
fe0243a4cc
commit
a67ec1ec11
2 changed files with 104 additions and 99 deletions
|
|
@ -157,13 +157,13 @@ span.has-danger,
|
||||||
|
|
||||||
.m-table__row--is_vip td {
|
.m-table__row--is_vip td {
|
||||||
background-color: #ffff00 !important;
|
background-color: #ffff00 !important;
|
||||||
color: #fff !important;
|
color: #414a4c !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.m-table__row--is_vip td > span,
|
.m-table__row--is_vip td > span,
|
||||||
.m-table__row--is_vip td > span a,
|
.m-table__row--is_vip td > span a,
|
||||||
.m-table__row--is_vip td > span a i {
|
.m-table__row--is_vip td > span a i {
|
||||||
color: #fff !important;
|
color: #414a4c !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.m-table__row--is_emergency td {
|
.m-table__row--is_emergency td {
|
||||||
|
|
|
||||||
|
|
@ -45,106 +45,111 @@
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
<script>
|
<script>
|
||||||
$(function() {
|
$(function() {
|
||||||
var options = {
|
var options = {
|
||||||
data: {
|
data: {
|
||||||
type: 'remote',
|
type: 'remote',
|
||||||
source: {
|
source: {
|
||||||
read: {
|
read: {
|
||||||
url: '{{ url('jo_proc_rows') }}',
|
url: '{{ url('jo_proc_rows') }}',
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
saveState: {
|
saveState: {
|
||||||
cookie: false,
|
cookie: false,
|
||||||
webstorage: false
|
webstorage: false
|
||||||
},
|
},
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
serverPaging: true,
|
serverPaging: true,
|
||||||
serverFiltering: true,
|
serverFiltering: true,
|
||||||
serverSorting: true
|
serverSorting: true
|
||||||
},
|
},
|
||||||
rows: {
|
rows: {
|
||||||
beforeTemplate: function (row, data, index) {
|
beforeTemplate: function (row, data, index) {
|
||||||
// TODO: create function getRowColor that will return
|
var attribute = getRowAttribute(data);
|
||||||
// what class to display
|
// check if we have to apply a background color for the row
|
||||||
if (data.is_vip) {
|
if (attribute) {
|
||||||
console.log('is vip');
|
var row_class = "m-table__row--" + attribute;
|
||||||
$(row).addClass('m-table__row--is_vip');
|
$(row).addClass(row_class);
|
||||||
}
|
}
|
||||||
if ($(row).hasClass('m-table__row--is_vip') == false) {
|
}
|
||||||
if (data.flag_advance) {
|
},
|
||||||
$(row).addClass('m-table__row--danger');
|
columns: [
|
||||||
}
|
{
|
||||||
|
field: 'id',
|
||||||
|
title: 'JO Number'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'delivery_address',
|
||||||
|
title: 'Customer Area'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'type',
|
||||||
|
title: 'Schedule'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'date_schedule',
|
||||||
|
title: 'Scheduled Date'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'status',
|
||||||
|
title: 'Status'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'processor',
|
||||||
|
title: 'Dispatcher'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'Actions',
|
||||||
|
width: 110,
|
||||||
|
title: 'Actions',
|
||||||
|
sortable: false,
|
||||||
|
overflow: 'visible',
|
||||||
|
template: function (row, index, datatable) {
|
||||||
|
var actions = '<a href="' + row.meta.update_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" title="View / Edit"><i class="la la-edit"></i></a>';
|
||||||
|
|
||||||
if (data.is_mobile) {
|
{% if is_granted('jo_proc.unlock') %}
|
||||||
$(row).addClass('m-table__row--is_mobile');
|
if (row.meta.unlock_url != '') {
|
||||||
}
|
actions += '<a href="' + row.meta.unlock_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" title="Unlock"><i class="fa fa-unlock"></i></a>';
|
||||||
if (data.is_emergency) {
|
}
|
||||||
console.log('is emergency');
|
{% endif %}
|
||||||
$(row).addClass('m-table__row--is_emergency');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
columns: [
|
|
||||||
{
|
|
||||||
field: 'id',
|
|
||||||
title: 'JO Number'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'delivery_address',
|
|
||||||
title: 'Customer Area'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'type',
|
|
||||||
title: 'Schedule'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'date_schedule',
|
|
||||||
title: 'Scheduled Date'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'status',
|
|
||||||
title: 'Status'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'processor',
|
|
||||||
title: 'Dispatcher'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'Actions',
|
|
||||||
width: 110,
|
|
||||||
title: 'Actions',
|
|
||||||
sortable: false,
|
|
||||||
overflow: 'visible',
|
|
||||||
template: function (row, index, datatable) {
|
|
||||||
var actions = '<a href="' + row.meta.update_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" title="View / Edit"><i class="la la-edit"></i></a>';
|
|
||||||
|
|
||||||
{% if is_granted('jo_proc.unlock') %}
|
return actions;
|
||||||
if (row.meta.unlock_url != '') {
|
},
|
||||||
actions += '<a href="' + row.meta.unlock_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" title="Unlock"><i class="fa fa-unlock"></i></a>';
|
}
|
||||||
}
|
],
|
||||||
{% endif %}
|
search: {
|
||||||
|
onEnter: false,
|
||||||
|
input: $('#data-rows-search'),
|
||||||
|
delay: 400
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return actions;
|
var table = $("#data-rows").mDatatable(options);
|
||||||
},
|
|
||||||
}
|
|
||||||
],
|
|
||||||
search: {
|
|
||||||
onEnter: false,
|
|
||||||
input: $('#data-rows-search'),
|
|
||||||
delay: 400
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var table = $("#data-rows").mDatatable(options);
|
// auto refresh table
|
||||||
|
setInterval(function() {
|
||||||
|
table.reload();
|
||||||
|
}, {{ table_refresh_rate }});
|
||||||
|
});
|
||||||
|
|
||||||
// auto refresh table
|
function getRowAttribute(data) {
|
||||||
setInterval(function() {
|
if (data.is_vip) {
|
||||||
table.reload();
|
return 'is_vip';
|
||||||
}, {{ table_refresh_rate }});
|
}
|
||||||
});
|
if (data.is_emergency) {
|
||||||
</script>
|
return 'is_emergency';
|
||||||
|
}
|
||||||
|
if (data.flag_advance) {
|
||||||
|
return 'danger';
|
||||||
|
}
|
||||||
|
if (data.is_mobile) {
|
||||||
|
return 'is_mobile';
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue