new: add colored status badges for tariffs in list and offer form select
This commit is contained in:
@@ -154,6 +154,27 @@
|
||||
initSelect2();
|
||||
$('#status_id').bootstrapToggle();
|
||||
|
||||
// Tariff status badges in select2
|
||||
var tariffStatuses = {!! json_encode($tariff_statuses ?? (object)[]) !!};
|
||||
var tariffStatusLabels = {!! json_encode($tariff_status_labels ?? []) !!};
|
||||
var tariffStatusColors = {0: '#28a745', 1: '#ffc107', 2: '#6c757d', 3: '#dc3545'};
|
||||
|
||||
function formatTariff(item) {
|
||||
if (!item.id) return item.text;
|
||||
var statusId = tariffStatuses[item.id];
|
||||
var color = tariffStatusColors[statusId] || '#6c757d';
|
||||
var label = tariffStatusLabels[statusId] || '';
|
||||
return $('<span style="display:flex;justify-content:space-between;align-items:center;width:100%;">' + item.text + '<span class="badge" style="background:' + color + ';color:#fff;font-size:0.75em;margin-left:8px;">' + label + '</span></span>');
|
||||
}
|
||||
|
||||
$('#tariff_id').select2('destroy').select2({
|
||||
placeholder: "{{ __('select_a_value') }}",
|
||||
allowClear: false,
|
||||
width: { value: '100%' },
|
||||
templateResult: formatTariff,
|
||||
templateSelection: formatTariff
|
||||
});
|
||||
|
||||
function updateEditLink(selectId, linkId, routeTemplate) {
|
||||
var val = $('#' + selectId).val();
|
||||
var $link = $('#' + linkId);
|
||||
|
||||
Reference in New Issue
Block a user