create create page
This commit is contained in:
parent
985febc962
commit
94557a817f
9 changed files with 128 additions and 5 deletions
|
@ -25,6 +25,7 @@ public function index()
|
||||||
*/
|
*/
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
|
return view('admin.owned.create');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
|
|
||||||
define('PER_PAGE', 7);
|
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 ---- */
|
/* ------------------------------------------------------------------------- auth_collective ---- */
|
||||||
|
|
||||||
// returns the currently authenticated collective
|
// returns the currently authenticated collective
|
||||||
|
|
|
@ -118,6 +118,7 @@ .form__label:first-child, .form__btns:first-child, .form__checkbox:first-child,
|
||||||
.form__input, .form__input--search, .form__select {
|
.form__input, .form__input--search, .form__select {
|
||||||
border: 1px solid #7874ff;
|
border: 1px solid #7874ff;
|
||||||
background-color: #e4e3ff;
|
background-color: #e4e3ff;
|
||||||
|
width: 50%;
|
||||||
border-color: #7874ff;
|
border-color: #7874ff;
|
||||||
background-color: #e4e3ff;
|
background-color: #e4e3ff;
|
||||||
color: #7874ff;
|
color: #7874ff;
|
||||||
|
@ -142,6 +143,7 @@ .form__input--file {
|
||||||
color: #7874ff;
|
color: #7874ff;
|
||||||
transition: background-color 0.4s, border-color 0.4s, color 0.4s;
|
transition: background-color 0.4s, border-color 0.4s, color 0.4s;
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
|
width: 50%;
|
||||||
}
|
}
|
||||||
.form__input--file:hover {
|
.form__input--file:hover {
|
||||||
border-color: #de7cff;
|
border-color: #de7cff;
|
||||||
|
|
|
@ -57,6 +57,7 @@ h1 {
|
||||||
.form__input {
|
.form__input {
|
||||||
border: 1px solid $c-main;
|
border: 1px solid $c-main;
|
||||||
background-color: $c-main-lightest;
|
background-color: $c-main-lightest;
|
||||||
|
width: 50%;
|
||||||
|
|
||||||
@include hover;
|
@include hover;
|
||||||
}
|
}
|
||||||
|
@ -69,6 +70,7 @@ h1 {
|
||||||
border: 1px solid $c-main;
|
border: 1px solid $c-main;
|
||||||
@include hover($bg: false);
|
@include hover($bg: false);
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
|
width: 50%;
|
||||||
|
|
||||||
&::file-selector-button {
|
&::file-selector-button {
|
||||||
@extend %btn;
|
@extend %btn;
|
||||||
|
|
29
resources/views/admin/owned/create.blade.php
Normal file
29
resources/views/admin/owned/create.blade.php
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
@extends('admin.layout')
|
||||||
|
|
||||||
|
@section('pg-nav')
|
||||||
|
<x-admin.nav :section="'owned'" />
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('pg-title', 'Add Owned')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
|
||||||
|
<form action="{{ route('admin.owned.store') }}" method="POST" autocomplete="off">
|
||||||
|
@csrf
|
||||||
|
|
||||||
|
<fieldset class="form__fieldset">
|
||||||
|
<x-admin.form.categories name="categories[]" required />
|
||||||
|
<x-form.text name="subject" :label="'Subject:'" required />
|
||||||
|
<x-form.select name="status" :label="'Status:'" :size="1" required />
|
||||||
|
<x-form.text name="slug" :label="'Slug:'" required />
|
||||||
|
<x-form.text name="title" :label="'Title:'" />
|
||||||
|
<x-form.file name="image" />
|
||||||
|
<x-form.date name="date_opened" :label="'Date opened:'" />
|
||||||
|
<x-form.checkbox name="hold_member_updates" :label="'Hold member updates?'" />
|
||||||
|
<x-form.checkbox name="notify_pending" :label="'Notify when you have pending members?'" />
|
||||||
|
|
||||||
|
<x-form.buttons />
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
@endsection
|
|
@ -1,4 +1,4 @@
|
||||||
{{-- expected attributes: name, id --}}
|
{{-- expected attributes: name --}}
|
||||||
@props([
|
@props([
|
||||||
'prevCats' => false,
|
'prevCats' => false,
|
||||||
'labelClass' => '',
|
'labelClass' => '',
|
||||||
|
@ -10,7 +10,7 @@
|
||||||
use App\Models\Category;
|
use App\Models\Category;
|
||||||
$categories = Category::all();
|
$categories = Category::all();
|
||||||
|
|
||||||
$id = rtrim($attributes['name'], '[]');
|
$id = $attributes['id'] ?? rtrim($attributes['name'], '[]');
|
||||||
|
|
||||||
$selected = null;
|
$selected = null;
|
||||||
$name = rtrim($attributes['name'], '[]');
|
$name = rtrim($attributes['name'], '[]');
|
||||||
|
|
16
resources/views/components/form/date.blade.php
Normal file
16
resources/views/components/form/date.blade.php
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
{{-- expected attributes: name --}}
|
||||||
|
@props([
|
||||||
|
'labelClass' => '',
|
||||||
|
'label',
|
||||||
|
'current' => null,
|
||||||
|
'inputClass' => '',
|
||||||
|
'errorClass' => '',
|
||||||
|
])
|
||||||
|
|
||||||
|
<label for="{{ $attributes['id'] ?? $attributes['name'] }}" class="form__label {{ $labelClass }}">
|
||||||
|
{{ $label }}
|
||||||
|
</label>
|
||||||
|
<input type="date" id="{{ $attributes['id'] ?? $attributes['name'] }}" {{ $attributes }}
|
||||||
|
value="{{ old($attributes['name'], $current?->format(FORM_DATE_FMT)) }}"
|
||||||
|
class="form__input {{ $inputClass }}">
|
||||||
|
@error($attributes['name']) <p class="form__error {{ $errorClass }}">{{ $message }}</p> @enderror
|
48
resources/views/components/form/select.blade.php
Normal file
48
resources/views/components/form/select.blade.php
Normal file
|
@ -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
|
||||||
|
|
||||||
|
<label for="{{ $id }}" class="form__label {{ $labelClass }}">{{ $label }}</label>
|
||||||
|
<select id="{{ $id }}" {{ $attributes }} class="form__select {{ $selectClass }}" size="{{ $size }}">
|
||||||
|
@if (!isset($attributes['multiple']))
|
||||||
|
<option value=""></option>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@foreach ($vals as $val)
|
||||||
|
<option value="{{ $val }}"
|
||||||
|
@if(isset($selected)) @selected($selected->search($val) !== false) @endif>
|
||||||
|
{{ $val }}
|
||||||
|
</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
@error($attributes['name']) <p class="form__error {{ $errorClass }}">{{ $message }}</p> @enderror
|
|
@ -1,7 +1,28 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
it('has owned/create page', function () {
|
use App\Models\Collective;
|
||||||
$response = $this->get('/owned/create');
|
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');
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue