Browse Source

adding

master
Björn 3 years ago
parent
commit
509c958cda
8 changed files with 76 additions and 7 deletions
  1. +23
    -0
      app/Http/Controllers/Api/BucketController.php
  2. +21
    -0
      app/Http/Controllers/BucketController.php
  3. +1
    -1
      public/css/bootstrap.css
  4. +1
    -1
      public/js/bucket.js
  5. +21
    -3
      resources/js/components/bucket/form.riot
  6. +5
    -0
      resources/scss/bootstrap.scss
  7. +1
    -1
      resources/views/bucket/create.blade.php
  8. +3
    -1
      routes/web.php

+ 23
- 0
app/Http/Controllers/Api/BucketController.php View File

@ -0,0 +1,23 @@
<?php
namespace App\Http\Controllers\Api;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
class BucketController extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
/**
*
* @return [type] [description]
*
*/
public function store()
{
}
}

+ 21
- 0
app/Http/Controllers/BucketController.php View File

@ -11,6 +11,11 @@ class BucketController extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
public function get()
{
}
/**
*
* @return [type] [description]
@ -20,4 +25,20 @@ class BucketController extends BaseController
{
return view('bucket.create');
}
public function store()
{
$validated = request()->validate([
'title' => 'required|max:255',
'is_public' => 'boolean',
]);
if ($validated) {
return redirect()
->route('bucket.get', ['uuid' => 12]);
} else {
return back()
->withInput();
}
}
}

+ 1
- 1
public/css/bootstrap.css
File diff suppressed because it is too large
View File


+ 1
- 1
public/js/bucket.js
File diff suppressed because it is too large
View File


+ 21
- 3
resources/js/components/bucket/form.riot View File

@ -4,6 +4,7 @@
<input type="hidden" name="_token" value={ state.csrfToken } if={ state.csrfToken } />
<!-- title -->
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label" for="title">
@ -20,6 +21,7 @@
</div>
</div>
<!-- is public -->
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label" for="public">
@ -28,11 +30,12 @@
</div>
<div class="field-body">
<div class="field">
<input id="public" type="checkbox">
<input id="public" type="checkbox" name="public" value="1" checked={ props.public }>
</div>
</div>
</div>
<!-- submit -->
<div class="field">
<div class="control">
<button class="button is-primary" type="submit" disabled={ state.validator.errors().length > 0 }>
@ -57,6 +60,13 @@
*/
export default {
/**
*
* @param {[type]} props [description]
* @param {[type]} state [description]
*
*/
onBeforeMount(props, state) {
state.validator = new Validator({
title: {
@ -72,14 +82,22 @@
}
},
/**
*
*
* @param {[type]} key
* @param {[type]} defaultClass
* @return {[type]}
*
*/
getClasses(key, defaultClass) {
const classes = [
defaultClass
]
console.log(this.state.validator)
const errors = this.state.validator.errors(key)
if (this.state.validator.errors(key).length > 0) {
if (errors && errors.length > 0) {
classes.push('is-danger')
}


+ 5
- 0
resources/scss/bootstrap.scss View File

@ -55,5 +55,10 @@ input {
}
}
input[type=checkbox] {
position: relative;
top: 0.7em;
}
@include component__accordion();
@include component__buckets();

+ 1
- 1
resources/views/bucket/create.blade.php View File

@ -15,7 +15,7 @@
@push('scripts')
<script type="text/javascript" src="/js/bucket.js"></script>
<script type="text/javascript" defer>
riot.mount('urban-bucket-form', {!! json_encode(request()->all()) !!});
riot.mount('urban-bucket-form', {!! json_encode(old()) !!});
</script>
@endpush
@endsection

+ 3
- 1
routes/web.php View File

@ -17,7 +17,9 @@ Route::get('/', 'App\Http\Controllers\HomeController@show');
Route::prefix('bucket')->group(function() {
Route::get('create', 'App\Http\Controllers\BucketController@create');
Route::post('create', 'App\Http\Controllers\BucketController@create');
Route::post('create', 'App\Http\Controllers\BucketController@store');
Route::get('{uuid}', 'App\Http\Controllers\BucketController@get')->name('bucket.get');
});
/***


Loading…
Cancel
Save