diff --git a/app/Http/Controllers/OwnedController.php b/app/Http/Controllers/OwnedController.php index 0f96309..e2b601a 100644 --- a/app/Http/Controllers/OwnedController.php +++ b/app/Http/Controllers/OwnedController.php @@ -25,6 +25,7 @@ public function index() */ public function create() { + return view('admin.owned.create'); } /** diff --git a/app/helpers.php b/app/helpers.php index 4920426..8012853 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -2,6 +2,10 @@ define('PER_PAGE', 7); +define('DATE_FMT', 'j F Y'); +define('FORM_DATE_FMT', 'Y-m-d'); +define('DATE_FMT_SHORT', 'j M y'); + /* ------------------------------------------------------------------------- auth_collective ---- */ // returns the currently authenticated collective diff --git a/public/css/admin/style.css b/public/css/admin/style.css index e1820ea..cf2707e 100644 --- a/public/css/admin/style.css +++ b/public/css/admin/style.css @@ -118,6 +118,7 @@ .form__label:first-child, .form__btns:first-child, .form__checkbox:first-child, .form__input, .form__input--search, .form__select { border: 1px solid #7874ff; background-color: #e4e3ff; + width: 50%; border-color: #7874ff; background-color: #e4e3ff; color: #7874ff; @@ -142,6 +143,7 @@ .form__input--file { color: #7874ff; transition: background-color 0.4s, border-color 0.4s, color 0.4s; padding: 5px; + width: 50%; } .form__input--file:hover { border-color: #de7cff; diff --git a/resources/sass/admin/_base.scss b/resources/sass/admin/_base.scss index 0ca9b46..6a5dd60 100644 --- a/resources/sass/admin/_base.scss +++ b/resources/sass/admin/_base.scss @@ -57,6 +57,7 @@ h1 { .form__input { border: 1px solid $c-main; background-color: $c-main-lightest; + width: 50%; @include hover; } @@ -69,6 +70,7 @@ h1 { border: 1px solid $c-main; @include hover($bg: false); padding: 5px; + width: 50%; &::file-selector-button { @extend %btn; diff --git a/resources/views/admin/owned/create.blade.php b/resources/views/admin/owned/create.blade.php new file mode 100644 index 0000000..b3e95bd --- /dev/null +++ b/resources/views/admin/owned/create.blade.php @@ -0,0 +1,29 @@ +@extends('admin.layout') + +@section('pg-nav') + +@endsection + +@section('pg-title', 'Add Owned') + +@section('content') + +
+ @csrf + +
+ + + + + + + + + + + +
+
+ +@endsection \ No newline at end of file diff --git a/resources/views/components/admin/form/categories.blade.php b/resources/views/components/admin/form/categories.blade.php index 339d3d5..607a608 100644 --- a/resources/views/components/admin/form/categories.blade.php +++ b/resources/views/components/admin/form/categories.blade.php @@ -1,4 +1,4 @@ -{{-- expected attributes: name, id --}} +{{-- expected attributes: name --}} @props([ 'prevCats' => false, 'labelClass' => '', @@ -10,7 +10,7 @@ use App\Models\Category; $categories = Category::all(); - $id = rtrim($attributes['name'], '[]'); + $id = $attributes['id'] ?? rtrim($attributes['name'], '[]'); $selected = null; $name = rtrim($attributes['name'], '[]'); diff --git a/resources/views/components/form/date.blade.php b/resources/views/components/form/date.blade.php new file mode 100644 index 0000000..d7e1f2b --- /dev/null +++ b/resources/views/components/form/date.blade.php @@ -0,0 +1,16 @@ +{{-- expected attributes: name --}} +@props([ + 'labelClass' => '', + 'label', + 'current' => null, + 'inputClass' => '', + 'errorClass' => '', +]) + + + +@error($attributes['name'])

{{ $message }}

@enderror \ No newline at end of file diff --git a/resources/views/components/form/select.blade.php b/resources/views/components/form/select.blade.php new file mode 100644 index 0000000..233a84f --- /dev/null +++ b/resources/views/components/form/select.blade.php @@ -0,0 +1,48 @@ +{{-- expected attributes: name --}} +@props([ + 'prevVals' => false, + 'vals' => false, + 'labelClass' => '', + 'selectClass' => '', + 'errorClass' => '', + 'size' => 6, + 'label', + ]) + +@php + $id = $attributes['id'] ?? rtrim($attributes['name'], '[]'); + + $selected = null; + $name = rtrim($attributes['name'], '[]'); + if (old($name) != null) { + $selected = collect(old($name)); + } else if ($prevVals) { + $selected = collect($prevVals); + } + + if (!$vals) { + switch ($name) { + case 'status': + $vals = ['upcoming', 'current']; + break; + + default: + break; + } + } +@endphp + + + +@error($attributes['name'])

{{ $message }}

@enderror \ No newline at end of file diff --git a/tests/Feature/Owned/CreateTest.php b/tests/Feature/Owned/CreateTest.php index d9e97ed..287aad5 100644 --- a/tests/Feature/Owned/CreateTest.php +++ b/tests/Feature/Owned/CreateTest.php @@ -1,7 +1,28 @@ get('/owned/create'); +use App\Models\Collective; +use function Pest\Faker\faker; - $response->assertStatus(200); +uses()->group('owned', 'admin'); + +beforeEach(function () { + $this->user = Collective::first(); + $this->request = [ + 'categories' => [rand(1, 57), rand(1, 57), rand(1, 57)], + 'url' => faker()->url, + 'subject' => faker()->word, + 'approved' => faker()->boolean, + ]; +}); + +it('has owned create page', function () { + $response = $this->actingAs($this->user)->get('/fanatic/owned/create'); + + $response->assertViewIs('admin.owned.create'); +}); + +it('hides owned create page from guests', function () { + $response = $this->get('/fanatic/owned/create'); + + $response->assertRedirect('/fanatic/login'); });