Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table component #2770

Merged
merged 4 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 57 additions & 7 deletions app/Domain/Tickets/Js/ticketsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -1177,16 +1177,19 @@ export const initTicketsTable = function (groupBy) {
}

},
"dom": '<"top">rt<"bottom"><"clear">',
"searching": false,
"stateSave": true,
"dom": '<"top"f>rt<"bottom"lip><"clear">',
"pagingType": "full_numbers",
"pageLength": 10,
"lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
"searching": true,
"stateSave": false,
"displayLength":100,
"order": defaultOrder,
"columnDefs": [
{ "visible": false, "targets": 10 },
{ "visible": false, "targets": 11 },
{ "visible": false, "targets": 10, "searchable": false },
{ "visible": false, "targets": 11, "searchable": false },
{ "target": "no-sort", "orderable": false},
],
],
"footerCallback": function ( row, data, start, end, display ) {
var api = this.api(), data;

Expand All @@ -1200,7 +1203,6 @@ export const initTicketsTable = function (groupBy) {

// computing column Total of the complete result


var plannedHours = api
.column(10)
.data()
Expand Down Expand Up @@ -1263,6 +1265,29 @@ export const initTicketsTable = function (groupBy) {

});

function format(d) {
return "foo";
// d[6];
}

// Add event listener for opening and closing child row
jQuery('.ticketTable tbody').on('click', 'td.dt-control', function (e) {
let tr = e.target.closest('tr');
// let tr = jQuery(this).closest('tr');
let row = allTickets.row(tr);

console.log("Row data is", row.data());

if (row.child.isShown()) {
row.child.hide();
tr.removeClass('shown');
} else {
row.child(format(row.data())).show();
tr.addClass('shown');
}
});


var buttons = new jQuery.fn.dataTable.Buttons(allTickets.table(0), {
buttons: [
{
Expand Down Expand Up @@ -1310,6 +1335,31 @@ export const initTicketsTable = function (groupBy) {
allTickets.draw();

});

// Testing add row
function addNewRow() {
allTickets.row
.add([
"col 1",
"col 2",
"col 3",
"col 4",
"col 5",
"col 6",
"col 7",
"col 8",
"col 9",
"col 10",
"col 11",
"col 12",
])
.draw(false);

}

// document.querySelector('#addRow').addEventListener('click', addNewRow);
jQuery('#addRow').on('click', addNewRow);

});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@
{{ __('buttons.search') }}
</x-global::forms.button>
</div>


</x-slot:cardContent>
</x-global::actions.dropdown>

Expand Down
762 changes: 398 additions & 364 deletions app/Domain/Tickets/Templates/showAll.blade.php

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<td {{ $attributes->merge(['class' => 'px-6 py-4 text-sm text-gray-500']) }}>
{{ $slot }}
</td>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<tr {{ $attributes->merge(['class' => 'text-left text-xs font-medium text-gray-500 tracking-wider']) }}>
{{ $slot }}
</tr>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<th {{ $attributes->merge(['class' => 'px-6 py-3']) }}>
{{ $slot }}
</th>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<tr {{ $attributes->merge(['class' => 'text-left text-xs font-medium text-gray-500 tracking-wider']) }}>
{{ $slot }}
</tr>
24 changes: 24 additions & 0 deletions app/Views/Templates/components/elements/table/index.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@props([
'header',
'body',
'footer',
'extraClass' => ''
])

<table {{ $attributes->merge(['class' => 'table table-bordered min-w-full bg-white border-separate border-spacing-0 '.$extraClass ]) }}>
@if(isset($header))
<thead class="bg-gray-50">
{{ $header }}
</thead>
@endif

<tbody class="bg-white divide-y divide-gray-200">
{{ $body }}
</tbody>

@if(isset($footer))
<tfoot class="bg-gray-50">
{{ $footer }}
</tfoot>
@endif
</table>
3 changes: 3 additions & 0 deletions app/Views/Templates/components/elements/table/row.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<tr {{ $attributes->merge(['class' => 'hover:bg-gray-50']) }}>
{{ $slot }}
</tr>
Loading