Mercurial > packages > magicforger
comparison src/Generator/View/stubs/index.stub @ 34:f65ab84ee47f default
merge with codex
| author | luka |
|---|---|
| date | Wed, 10 Sep 2025 21:00:47 -0400 |
| parents | 45f384a24553 |
| children |
comparison
equal
deleted
inserted
replaced
| 10:a9ff874afdbd | 34:f65ab84ee47f |
|---|---|
| 1 <x-app-layout> | |
| 2 <x-slot name="header"> | |
| 3 <h2 class="fw-semibold fs-4 text-dark"> | |
| 4 All {{ Str::plural(ucfirst('{{ modelVariable }}')) }} | |
| 5 </h2> | |
| 6 </x-slot> | |
| 7 | |
| 8 <div class="py-5"> | |
| 9 <div class="container"> | |
| 10 <div class="bg-white shadow-sm rounded p-4"> | |
| 11 <div class="d-flex align-items-center justify-content-between mb-3"> | |
| 12 <a href="{{ route('{{ tableName }}.create') }}" class="btn btn-primary"> | |
| 13 + New {{ ucfirst('{{ modelVariable }}') }} | |
| 14 </a> | |
| 15 </div> | |
| 16 <div id="my-table"></div> | |
| 17 </div> | |
| 18 </div> | |
| 19 </div> | |
| 20 | |
| 21 @include('includes.ServerTable') | |
| 22 @pushOnce('scripts') | |
| 23 <meta name="csrf-token" content="{{ csrf_token() }}"> | |
| 24 @endpushOnce | |
| 25 <script> | |
| 26 document.addEventListener('DOMContentLoaded', function() { | |
| 27 const el = document.getElementById('my-table'); | |
| 28 if (el) { | |
| 29 new ServerTable(el, { | |
| 30 endpoint: '/{{ tableName }}/get_data', | |
| 31 columns: [ | |
| 32 {{ columnInsertPoint }} | |
| 33 { | |
| 34 name: 'actions', | |
| 35 label: ' ', | |
| 36 render: function(row, col, i) { | |
| 37 let actions = ` | |
| 38 <div class="d-flex gap-2"> | |
| 39 <a href="{{ route('{{ tableName }}.show', 'PLACEHOLDER') }}" class="text-primary">View</a> | |
| 40 <a href="{{ route('{{ tableName }}.edit', 'PLACEHOLDER') }}" class="text-warning">Edit</a> | |
| 41 <form action="{{ route('{{ tableName }}.destroy', 'PLACEHOLDER') }}" method="POST" | |
| 42 class="d-inline"> | |
| 43 @csrf | |
| 44 @method('DELETE') | |
| 45 <button type="submit" class="btn btn-link text-danger p-0" | |
| 46 onclick="return confirm('Delete?')">Delete</button> | |
| 47 </form> | |
| 48 </div> | |
| 49 `; | |
| 50 actions = actions.split('PLACEHOLDER').join(row.id); | |
| 51 return actions; | |
| 52 } | |
| 53 } | |
| 54 ], | |
| 55 pageSize: 10, | |
| 56 initialSort: [{ | |
| 57 col: 'created_at', | |
| 58 dir: 'desc' | |
| 59 }], | |
| 60 headers: { | |
| 61 'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute( | |
| 62 'content') | |
| 63 }, | |
| 64 skeleton: ` | |
| 65 <div class="st-table-container"> | |
| 66 <table class="table table-hover"> | |
| 67 <thead> | |
| 68 </thead> | |
| 69 <tbody> | |
| 70 <!-- Data rows will go here --> | |
| 71 </tbody> | |
| 72 </table> | |
| 73 <div class="st-controls"> | |
| 74 <span class="st-pagination"></span> | |
| 75 <span class="st-status"></span> | |
| 76 </div> | |
| 77 </div> | |
| 78 ` | |
| 79 }); | |
| 80 } | |
| 81 }); | |
| 82 </script> | |
| 83 </x-app-layout> |
