From 8ca41d6388195aa3ed6ace4400acc910043832d3 Mon Sep 17 00:00:00 2001 From: Matt Young Date: Thu, 30 May 2024 02:42:16 -0500 Subject: [PATCH] Complete refactoring of components. Some work on students page --- .../views/components/card/card.blade.php | 19 ++++--- .../views/components/card/heading.blade.php | 8 +++ .../views/components/form/body-grid.blade.php | 24 +++++++++ .../views/components/form/field.blade.php | 42 +++++++++++----- .../views/components/form/footer.blade.php | 13 +++++ .../views/components/form/form.blade.php | 13 +++++ .../views/components/layout/app.blade.php | 1 + .../layout/page-section-container.blade.php | 3 ++ .../components/layout/page-section.blade.php | 16 +++--- resources/views/dashboard/profile.blade.php | 25 +++++++++- .../views/dashboard/select_school.blade.php | 13 +++-- resources/views/schools/edit.blade.php | 21 +++++++- resources/views/schools/show.blade.php | 2 +- resources/views/students/index.blade.php | 50 ++++++++++++++++--- routes/web.php | 11 ++-- 15 files changed, 212 insertions(+), 49 deletions(-) create mode 100644 resources/views/components/card/heading.blade.php create mode 100644 resources/views/components/form/body-grid.blade.php create mode 100644 resources/views/components/form/footer.blade.php create mode 100644 resources/views/components/form/form.blade.php create mode 100644 resources/views/components/layout/page-section-container.blade.php diff --git a/resources/views/components/card/card.blade.php b/resources/views/components/card/card.blade.php index e9ba13a..f1251bc 100644 --- a/resources/views/components/card/card.blade.php +++ b/resources/views/components/card/card.blade.php @@ -1,13 +1,12 @@ -@props(['heading' => false, 'subheading' => false]) -
merge(['class' => 'overflow-hidden bg-white shadow sm:rounded-lg']) }}> - @if($heading) -
-

{{ $heading }}

- @if($subheading) -

{{ $subheading }}

- @endif -
- @endif +@props(['mw' => false]) +@php + $wrapper_classes = 'overflow-hidden bg-white shadow sm:rounded-lg'; + if ($mw) { + $wrapper_classes .= ' mx-auto max-w-' . $mw; + } +@endphp +
merge(['class' => $wrapper_classes]) }}> + {{ $slot }} diff --git a/resources/views/components/card/heading.blade.php b/resources/views/components/card/heading.blade.php new file mode 100644 index 0000000..4471909 --- /dev/null +++ b/resources/views/components/card/heading.blade.php @@ -0,0 +1,8 @@ +@props(['subheading' => false]) + +
+

merge(['class' => 'text-base font-semibold leading-7 text-gray-900']) }}>{{ $slot }}

+ @if($subheading) +

attributes->merge(['class' => 'mt-.5 max-w-2xl text-sm leading-6 text-gray-500']) }}>{{ $subheading }}

+ @endif +
diff --git a/resources/views/components/form/body-grid.blade.php b/resources/views/components/form/body-grid.blade.php new file mode 100644 index 0000000..632b7ba --- /dev/null +++ b/resources/views/components/form/body-grid.blade.php @@ -0,0 +1,24 @@ +@props([ + 'columns' => '6' +]) +@php + $columnClasses = [ + '1' => '', + '2' => 'sm:grid-cols-2', + '3' => 'sm:grid-cols-3', + '4' => 'sm:grid-cols-4', + '5' => 'sm:grid-cols-5', + '6' => 'sm:grid-cols-6', + '7' => 'sm:grid-cols-7', + '8' => 'sm:grid-cols-8', + '9' => 'sm:grid-cols-9', + '10' => 'sm:grid-cols-10', + '11' => 'sm:grid-cols-11', + '12' => 'sm:grid-cols-12' + ]; + $classes = "grid max-w-2xl grid-cols-1 gap-x-6 gap-y-3 "; + $classes .= $columnClasses["$columns"] +@endphp +
merge(['class' => $classes]) }}> + {{ $slot }} +
diff --git a/resources/views/components/form/field.blade.php b/resources/views/components/form/field.blade.php index bb3c353..2f69e7b 100644 --- a/resources/views/components/form/field.blade.php +++ b/resources/views/components/form/field.blade.php @@ -1,27 +1,43 @@ @props([ - 'name', - 'type' => 'text', - 'label', - 'div_classes' => '' + 'name', + 'type' => 'text', + 'label' => false, + 'colspan' => '1', + 'label_text' => false ]) @php - $labelClasses = "block text-sm font-medium leading-6 text-gray-900"; + $label_classes = "block text-sm font-medium leading-6 text-gray-900"; $inputClasses = "block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6"; $inputAttributes = [ 'id' => $name, 'name' => $name, 'type' => $type, 'class' => $inputClasses, - 'value' => old($name) + 'value' => old($name), + + ]; + $colspan_classes = [ + '1' => '', + '2' => 'sm:col-span-2', + '3' => 'sm:col-span-3', + '4' => 'sm:col-span-4', + '5' => 'sm:col-span-5', + '6' => 'sm:col-span-6', + '7' => 'sm:col-span-7', + '8' => 'sm:col-span-8', + '9' => 'sm:col-span-9', + '10' => 'sm:col-span-10', + '11' => 'sm:col-span-11', + '12' => 'sm:col-span-12' ]; @endphp -
- +
1) class="{{ $colspan_classes["$colspan"] }}" @endif> + @if($label) + + @elseif($label_text) + + @endif
- - merge($inputAttributes)}}> + merge($inputAttributes) }}>
- @error($name) -

{{ $message }}

- @enderror
diff --git a/resources/views/components/form/footer.blade.php b/resources/views/components/form/footer.blade.php new file mode 100644 index 0000000..0e8a21a --- /dev/null +++ b/resources/views/components/form/footer.blade.php @@ -0,0 +1,13 @@ +@props([ + 'submitButtonText' => '', + 'buttons' => false +]) +
merge(['class' => 'flex items-center justify-end mt-4 gap-x-6 border-t border-gray-900/10 px-0 pt-4']) }}> + @if ($slot->isEmpty()) + + Cancel + {{ $submitButtonText }} + @else + {{ $slot }} + @endif +
diff --git a/resources/views/components/form/form.blade.php b/resources/views/components/form/form.blade.php new file mode 100644 index 0000000..3f9b9e5 --- /dev/null +++ b/resources/views/components/form/form.blade.php @@ -0,0 +1,13 @@ +@props([ + 'method' => 'POST', + 'form_classes' => 'px-4 py-6 sm:p-8' +]) + +
merge(['class' => $form_classes]) }}> + @csrf + @if(! in_array($method, ['POST','GET'])) + @method($method) + @endif + {{ $slot }} +
+ diff --git a/resources/views/components/layout/app.blade.php b/resources/views/components/layout/app.blade.php index 757a4a0..eb58fa3 100644 --- a/resources/views/components/layout/app.blade.php +++ b/resources/views/components/layout/app.blade.php @@ -1,3 +1,4 @@ +@props(['page_title' => false]) diff --git a/resources/views/components/layout/page-section-container.blade.php b/resources/views/components/layout/page-section-container.blade.php new file mode 100644 index 0000000..4dbd19b --- /dev/null +++ b/resources/views/components/layout/page-section-container.blade.php @@ -0,0 +1,3 @@ +
merge(['class' => 'space-y-10 divide-y divide-gray-900/10']) }}> + {{ $slot }} +
diff --git a/resources/views/components/layout/page-section.blade.php b/resources/views/components/layout/page-section.blade.php index 0a3e1dc..7ee55e4 100644 --- a/resources/views/components/layout/page-section.blade.php +++ b/resources/views/components/layout/page-section.blade.php @@ -1,20 +1,24 @@ @props([ - 'section_name', - 'section_description', + 'section_name' => false, + 'section_description' => false, 'first' => false ]) - @php $topPadding = ($first) ? '':'pt-10'; @endphp
-

{{ $section_name }}

-

{{ $section_description }}

+ @if($section_name) +

attributes->merge(['class' => 'text-base font-semibold leading-7 text-gray-900']) }}>{{ $section_name }}

+ @endif + + @if($section_description) +

attributes->merge(['class' => 'mt-1 text-sm leading-6 text-gray-600']) }}>{{ $section_description }}

+ @endif
-
+
merge(['class' => 'bg-white shadow-sm ring-1 ring-gray-900/5 sm:rounded-xl md:col-span-3']) }}> {{ $slot }}
diff --git a/resources/views/dashboard/profile.blade.php b/resources/views/dashboard/profile.blade.php index 563b9a9..7a0de19 100644 --- a/resources/views/dashboard/profile.blade.php +++ b/resources/views/dashboard/profile.blade.php @@ -1,4 +1,27 @@ @php use Illuminate\Support\Facades\Auth; @endphp + + + + + User Information + Use a permanent address where you receive mail + + + + + + + + + + + + + + + + +{{--@php use Illuminate\Support\Facades\Auth; @endphp User Profile
@@ -50,4 +73,4 @@
-
+--}} diff --git a/resources/views/dashboard/select_school.blade.php b/resources/views/dashboard/select_school.blade.php index a05398d..f9092dd 100644 --- a/resources/views/dashboard/select_school.blade.php +++ b/resources/views/dashboard/select_school.blade.php @@ -3,10 +3,15 @@ Choose School - +{{-- --}} + + + Choose your school + + Based on your email address, one of these schools may be yours + + + @foreach($possibilities as $possibility) @php $school = $possibility->school; @endphp diff --git a/resources/views/schools/edit.blade.php b/resources/views/schools/edit.blade.php index abad79d..3af4da2 100644 --- a/resources/views/schools/edit.blade.php +++ b/resources/views/schools/edit.blade.php @@ -1,4 +1,23 @@ + + + Edit School + + + + + + + + + + + + + + + +{{-- Edit School - {{ $school->name }}
-
+
--}} diff --git a/resources/views/schools/show.blade.php b/resources/views/schools/show.blade.php index 0a40fa2..c3d83aa 100644 --- a/resources/views/schools/show.blade.php +++ b/resources/views/schools/show.blade.php @@ -1,7 +1,7 @@ School Info - {{ $school->name }} - +
diff --git a/resources/views/students/index.blade.php b/resources/views/students/index.blade.php index 7c81437..45a9425 100644 --- a/resources/views/students/index.blade.php +++ b/resources/views/students/index.blade.php @@ -6,12 +6,46 @@ Students - - Create Student - Student full names must be unique. Add a middle initial to the first name if necessary. - - - - - + + + Add Student + + + + + +{{-- TODO make grade a dropdown--}} + Save + + + + + + Student Listing + + + Name + Grade + + Edit + + + + + + + + +{{----}} +{{-- Students--}} + +{{-- --}} +{{-- Create Student--}} +{{-- Student full names must be unique. Add a middle initial to the first name if necessary.--}} +{{-- --}} +{{-- --}} +{{-- --}} +{{-- --}} +{{-- --}} +{{----}} diff --git a/routes/web.php b/routes/web.php index 47fb3fe..78dfdca 100644 --- a/routes/web.php +++ b/routes/web.php @@ -16,7 +16,12 @@ Route::middleware(['auth','verified'])->group(function () { Route::get('/dashboard', [DashboardController::class, 'dashboard']); Route::get('/profile', [DashboardController::class, 'profile']); Route::get('/my_school', [DashboardController::class, 'my_school']); - Route::patch('/users/{user}/set_school', [UserController::class, 'set_school']); +}); + +// User Related Routes +Route::middleware(['auth','verified'])->controller(UserController::class)->group(function() { + Route::patch('/users/{user}/set_school', 'set_school'); + Route::patch('/users/{$user}', 'update'); }); // Student Related Routes @@ -26,10 +31,6 @@ Route::middleware(['auth','verified'])->controller(StudentController::class)->gr }); - - - - // School Related Routes Route::middleware(['auth','verified'])->controller(SchoolController::class)->group(function() { Route::get('/schools/create', 'create');