|
|
@@ -17,7 +17,7 @@
|
|
|
<i class="bi bi-gear-fill"></i>
|
|
|
</button>
|
|
|
</div>
|
|
|
- <table class="table" id="tbl" data-table-name="{{ $id }}" style="display: none; min-height: 380px;">
|
|
|
+ <table class="table table-interactive" id="tbl" data-table-name="{{ $id }}" style="display: none; min-height: 380px;">
|
|
|
<thead>
|
|
|
<tr>
|
|
|
@foreach($header as $headerName => $headerTitle)
|
|
|
@@ -77,15 +77,22 @@
|
|
|
</thead>
|
|
|
<tbody>
|
|
|
@foreach($strings as $string)
|
|
|
- <tr>
|
|
|
+ @php
|
|
|
+ $rowId = $string->id ?? null;
|
|
|
+ $rowAnchor = $rowId ? 'row-' . $rowId : null;
|
|
|
+ $rowHref = null;
|
|
|
+ if (isset($routeName) && $rowId) {
|
|
|
+ $rowHref = route($routeName, [$string->id, 'previous_url' => request()->fullUrl() . '#' . $rowAnchor]);
|
|
|
+ }
|
|
|
+ @endphp
|
|
|
+ <tr
|
|
|
+ @if($rowAnchor) id="{{ $rowAnchor }}" data-row-id="{{ $rowId }}" @endif
|
|
|
+ @if($rowHref) data-row-href="{{ $rowHref }}" @endif
|
|
|
+ @if($id === 'reclamations') data-open-target="_blank" @endif
|
|
|
+ >
|
|
|
@foreach($header as $headerName => $headerTitle)
|
|
|
<td class="column_{{$headerName}}"
|
|
|
- @if(isset($routeName)
|
|
|
- && !str_contains($headerName, 'image')
|
|
|
- && !str_contains($headerName, 'order_status_name')
|
|
|
- && !($id === 'reclamations' && $headerName === 'status_name'))
|
|
|
- onclick="@if($id === 'reclamations')window.open('{{ route($routeName, $string->id) }}','_blank');@else location.href='{{ route($routeName, $string->id) }}';@endif"
|
|
|
- @endif>
|
|
|
+ >
|
|
|
@if(str_contains($headerName, '-'))
|
|
|
@php
|
|
|
list($rel, $field) = explode('-', $headerName);
|
|
|
@@ -369,6 +376,54 @@
|
|
|
|
|
|
$('.table').fadeIn();
|
|
|
|
|
|
+ function isRowActionTarget(target) {
|
|
|
+ return $(target).closest('a, button, input, select, textarea, label, .dropdown, [data-bs-toggle], [data-no-row-select]').length > 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ function selectRow($row, updateHash = true) {
|
|
|
+ if (!$row || !$row.length) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ $row.closest('tbody').find('tr.is-selected').removeClass('is-selected');
|
|
|
+ $row.addClass('is-selected');
|
|
|
+ if (updateHash) {
|
|
|
+ const rowId = $row.data('row-id');
|
|
|
+ if (rowId) {
|
|
|
+ const hash = '#row-' + rowId;
|
|
|
+ const newUrl = window.location.pathname + window.location.search + hash;
|
|
|
+ history.replaceState(null, '', newUrl);
|
|
|
+ if (tableName) {
|
|
|
+ localStorage.setItem('table_last_row_' + tableName, String(rowId));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $(document).on('click', '.table-interactive tbody tr', function (e) {
|
|
|
+ if (isRowActionTarget(e.target)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ selectRow($(this));
|
|
|
+ });
|
|
|
+
|
|
|
+ $(document).on('dblclick', '.table-interactive tbody tr', function (e) {
|
|
|
+ if (isRowActionTarget(e.target)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const $row = $(this);
|
|
|
+ const href = $row.data('row-href');
|
|
|
+ if (!href) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ selectRow($row, false);
|
|
|
+ const target = $row.data('open-target');
|
|
|
+ if (target === '_blank') {
|
|
|
+ window.open(href, '_blank');
|
|
|
+ } else {
|
|
|
+ window.location.href = href;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
$('.toggle-column').on('change', function () {
|
|
|
let columnName = $(this).attr('data-name');
|
|
|
let columnStatus = $(this).is(':checked');
|
|
|
@@ -497,6 +552,31 @@
|
|
|
// Инициализация tooltips для полей tsn_number и pricing_code
|
|
|
const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]');
|
|
|
const tooltipList = [...tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl));
|
|
|
+
|
|
|
+ const hash = window.location.hash;
|
|
|
+ if (hash && hash.startsWith('#row-')) {
|
|
|
+ const $row = $(hash);
|
|
|
+ if ($row.length) {
|
|
|
+ selectRow($row, false);
|
|
|
+ $row[0].scrollIntoView({block: 'center'});
|
|
|
+ const rowId = $row.data('row-id');
|
|
|
+ if (rowId && tableName) {
|
|
|
+ localStorage.setItem('table_last_row_' + tableName, String(rowId));
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (tableName) {
|
|
|
+ const storedRowId = localStorage.getItem('table_last_row_' + tableName);
|
|
|
+ if (storedRowId) {
|
|
|
+ const $storedRow = $('#row-' + storedRowId);
|
|
|
+ if ($storedRow.length) {
|
|
|
+ selectRow($storedRow, false);
|
|
|
+ $storedRow[0].scrollIntoView({block: 'center'});
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
});
|
|
|
}); // end waitForJQuery
|
|
|
</script>
|