From dc1d4ddf161e2801346eb476618066def0433a7f Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Wed, 29 Aug 2018 07:09:57 +0800 Subject: [PATCH 01/11] Remove FormField on full CRUD create form Move FormFieldversion of create form to new stub file --- .../resources/views/full/create-formfield.stub | 23 +++++++++++++++++ src/stubs/resources/views/full/create.stub | 29 ++++++++++++++-------- tests/Generators/ViewsGeneratorTest.php | 29 ++++++++++++++-------- 3 files changed, 61 insertions(+), 20 deletions(-) create mode 100644 src/stubs/resources/views/full/create-formfield.stub diff --git a/src/stubs/resources/views/full/create-formfield.stub b/src/stubs/resources/views/full/create-formfield.stub new file mode 100644 index 0000000..b4f2704 --- /dev/null +++ b/src/stubs/resources/views/full/create-formfield.stub @@ -0,0 +1,23 @@ +@extends('layouts.app') + +@section('title', __('master.create')) + +@section('content') +
+
+
+

{{ __('master.create') }}

+ {!! Form::open(['route' => 'masters.store']) !!} +
+ {!! FormField::text('name', ['required' => true, 'label' => __('master.name')]) !!} + {!! FormField::textarea('description', ['label' => __('master.description')]) !!} +
+ + {!! Form::close() !!} +
+
+
+@endsection diff --git a/src/stubs/resources/views/full/create.stub b/src/stubs/resources/views/full/create.stub index b4f2704..27e585d 100644 --- a/src/stubs/resources/views/full/create.stub +++ b/src/stubs/resources/views/full/create.stub @@ -7,16 +7,25 @@

{{ __('master.create') }}

- {!! Form::open(['route' => 'masters.store']) !!} -
- {!! FormField::text('name', ['required' => true, 'label' => __('master.name')]) !!} - {!! FormField::textarea('description', ['label' => __('master.description')]) !!} -
- - {!! Form::close() !!} +
+ {{ csrf_field() }} +
+
+ + + {!! $errors->first('name', ':message') !!} +
+
+ + + {!! $errors->first('description', ':message') !!} +
+
+ +
diff --git a/tests/Generators/ViewsGeneratorTest.php b/tests/Generators/ViewsGeneratorTest.php index 926119b..91c6ec2 100644 --- a/tests/Generators/ViewsGeneratorTest.php +++ b/tests/Generators/ViewsGeneratorTest.php @@ -128,16 +128,25 @@ class ViewsGeneratorTest extends TestCase

{{ __('{$this->lang_name}.create') }}

- {!! Form::open(['route' => '{$this->table_name}.store']) !!} -
- {!! FormField::text('name', ['required' => true, 'label' => __('{$this->lang_name}.name')]) !!} - {!! FormField::textarea('description', ['label' => __('{$this->lang_name}.description')]) !!} -
-
- {!! Form::submit(__('{$this->lang_name}.create'), ['class' => 'btn btn-success']) !!} - {{ link_to_route('{$this->table_name}.index', __('app.cancel'), [], ['class' => 'btn btn-default']) }} -
- {!! Form::close() !!} +
table_name}.store') }}\" accept-charset=\"UTF-8\"> + {{ csrf_field() }} +
+
has('name') ? ' has-error' : '' }}\"> + + + {!! \$errors->first('name', ':message') !!} +
+
has('description') ? ' has-error' : '' }}\"> + + + {!! \$errors->first('description', ':message') !!} +
+
+
+ lang_name}.create') }}\" class=\"btn btn-success\"> + table_name}.index') }}\" class=\"btn btn-default\">{{ __('app.cancel') }} +
+
From 7b2970ba6bd81d043256cdff1c60c2f6d9a7780d Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Wed, 29 Aug 2018 07:16:05 +0800 Subject: [PATCH 02/11] Remove FormField on full CRUD edit form Move FormField version of edit form to new stub file --- src/stubs/resources/views/full/edit-formfield.stub | 56 ++++++++++++++++++++++ src/stubs/resources/views/full/edit.stub | 35 +++++++++----- tests/Generators/ViewsGeneratorTest.php | 35 +++++++++----- 3 files changed, 100 insertions(+), 26 deletions(-) create mode 100644 src/stubs/resources/views/full/edit-formfield.stub diff --git a/src/stubs/resources/views/full/edit-formfield.stub b/src/stubs/resources/views/full/edit-formfield.stub new file mode 100644 index 0000000..d23de5b --- /dev/null +++ b/src/stubs/resources/views/full/edit-formfield.stub @@ -0,0 +1,56 @@ +@extends('layouts.app') + +@section('title', __('master.edit')) + +@section('content') +
+
+ @if (request('action') == 'delete' && $singleMstr) + @can('delete', $singleMstr) +
+

{{ __('master.delete') }}

+
+ +

{{ $singleMstr->name }}

+ +

{{ $singleMstr->description }}

+ {!! $errors->first('master_id', ':message') !!} +
+
+
{{ __('master.delete_confirm') }}
+ +
+ @endcan + @else +
+

{{ __('master.edit') }}

+ {!! Form::model($singleMstr, ['route' => ['masters.update', $singleMstr],'method' => 'patch']) !!} +
+ {!! FormField::text('name', ['required' => true, 'label' => __('master.name')]) !!} + {!! FormField::textarea('description', ['label' => __('master.description')]) !!} +
+ + {!! Form::close() !!} +
+
+
+@endif +@endsection diff --git a/src/stubs/resources/views/full/edit.stub b/src/stubs/resources/views/full/edit.stub index d23de5b..b73855b 100644 --- a/src/stubs/resources/views/full/edit.stub +++ b/src/stubs/resources/views/full/edit.stub @@ -36,19 +36,28 @@ @else

{{ __('master.edit') }}

- {!! Form::model($singleMstr, ['route' => ['masters.update', $singleMstr],'method' => 'patch']) !!} -
- {!! FormField::text('name', ['required' => true, 'label' => __('master.name')]) !!} - {!! FormField::textarea('description', ['label' => __('master.description')]) !!} -
- - {!! Form::close() !!} +
+ {{ csrf_field() }} {{ method_field('patch') }} +
+
+ + + {!! $errors->first('name', ':message') !!} +
+
+ + + {!! $errors->first('description', ':message') !!} +
+
+ +
diff --git a/tests/Generators/ViewsGeneratorTest.php b/tests/Generators/ViewsGeneratorTest.php index 91c6ec2..b0df8fb 100644 --- a/tests/Generators/ViewsGeneratorTest.php +++ b/tests/Generators/ViewsGeneratorTest.php @@ -200,19 +200,28 @@ class ViewsGeneratorTest extends TestCase @else

{{ __('{$this->lang_name}.edit') }}

- {!! Form::model(\${$this->single_model_var_name}, ['route' => ['{$this->table_name}.update', \${$this->single_model_var_name}],'method' => 'patch']) !!} -
- {!! FormField::text('name', ['required' => true, 'label' => __('{$this->lang_name}.name')]) !!} - {!! FormField::textarea('description', ['label' => __('{$this->lang_name}.description')]) !!} -
-
- {!! Form::submit(__('{$this->lang_name}.update'), ['class' => 'btn btn-success']) !!} - {{ link_to_route('{$this->table_name}.show', __('app.cancel'), [\${$this->single_model_var_name}], ['class' => 'btn btn-default']) }} - @can('delete', \${$this->single_model_var_name}) - {{ link_to_route('{$this->table_name}.edit', __('app.delete'), [\${$this->single_model_var_name}, 'action' => 'delete'], ['class' => 'btn btn-danger pull-right', 'id' => 'del-{$this->lang_name}-'.\${$this->single_model_var_name}->id]) }} - @endcan -
- {!! Form::close() !!} +
table_name}.update', \${$this->single_model_var_name}) }}\" accept-charset=\"UTF-8\"> + {{ csrf_field() }} {{ method_field('patch') }} +
+
has('name') ? ' has-error' : '' }}\"> + + single_model_var_name}->name) }}\" required> + {!! \$errors->first('name', ':message') !!} +
+
has('description') ? ' has-error' : '' }}\"> + + + {!! \$errors->first('description', ':message') !!} +
+
+ +
From 9b496bf30658b75ca194c757440983d948d77a0f Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Wed, 29 Aug 2018 07:38:13 +0800 Subject: [PATCH 03/11] Remove FormField on full CRUD delete form --- src/stubs/resources/views/full/edit.stub | 19 ++++++++----------- tests/Generators/ViewsGeneratorTest.php | 19 ++++++++----------- 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/src/stubs/resources/views/full/edit.stub b/src/stubs/resources/views/full/edit.stub index b73855b..4b96353 100644 --- a/src/stubs/resources/views/full/edit.stub +++ b/src/stubs/resources/views/full/edit.stub @@ -19,17 +19,14 @@
{{ __('master.delete_confirm') }}
@endcan diff --git a/tests/Generators/ViewsGeneratorTest.php b/tests/Generators/ViewsGeneratorTest.php index b0df8fb..744d9d1 100644 --- a/tests/Generators/ViewsGeneratorTest.php +++ b/tests/Generators/ViewsGeneratorTest.php @@ -183,17 +183,14 @@ class ViewsGeneratorTest extends TestCase
{{ __('{$this->lang_name}.delete_confirm') }}
- {!! FormField::delete( - ['route' => ['{$this->table_name}.destroy', \${$this->single_model_var_name}]], - __('app.delete_confirm_button'), - ['class'=>'btn btn-danger'], - [ - '{$this->lang_name}_id' => \${$this->single_model_var_name}->id, - 'page' => request('page'), - 'q' => request('q'), - ] - ) !!} - {{ link_to_route('{$this->table_name}.edit', __('app.cancel'), [\${$this->single_model_var_name}], ['class' => 'btn btn-default']) }} +
table_name}.destroy', \${$this->single_model_var_name}) }}\" accept-charset=\"UTF-8\" onsubmit=\"return confirm("Are you sure to delete this?")\" class=\"del-form pull-right\" style=\"display: inline;\"> + {{ csrf_field() }} {{ method_field('delete') }} + lang_name}_id\" type=\"hidden\" value=\"{{ \${$this->single_model_var_name}->id }}\"> + + + +
+ table_name}.edit', \${$this->single_model_var_name}) }}\" class=\"btn btn-default\">{{ __('app.cancel') }}
@endcan From 7ca724ec3523fd6607accc29d177419341c1bc1f Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Wed, 29 Aug 2018 07:48:18 +0800 Subject: [PATCH 04/11] Remove link_to_route from full CRUD show view Move FormField version of show view to new stub file --- src/stubs/resources/views/full/show-formfield.stub | 25 ++++++++++++++++++++++ src/stubs/resources/views/full/show.stub | 4 ++-- tests/Generators/ViewsGeneratorTest.php | 4 ++-- 3 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 src/stubs/resources/views/full/show-formfield.stub diff --git a/src/stubs/resources/views/full/show-formfield.stub b/src/stubs/resources/views/full/show-formfield.stub new file mode 100644 index 0000000..d115485 --- /dev/null +++ b/src/stubs/resources/views/full/show-formfield.stub @@ -0,0 +1,25 @@ +@extends('layouts.app') + +@section('title', __('master.detail')) + +@section('content') +
+
+
+

{{ __('master.detail') }}

+ + + + + +
{{ __('master.name') }}{{ $singleMstr->name }}
{{ __('master.description') }}{{ $singleMstr->description }}
+ +
+
+
+@endsection diff --git a/src/stubs/resources/views/full/show.stub b/src/stubs/resources/views/full/show.stub index d115485..c391b93 100644 --- a/src/stubs/resources/views/full/show.stub +++ b/src/stubs/resources/views/full/show.stub @@ -15,9 +15,9 @@ diff --git a/tests/Generators/ViewsGeneratorTest.php b/tests/Generators/ViewsGeneratorTest.php index 744d9d1..0dc7eec 100644 --- a/tests/Generators/ViewsGeneratorTest.php +++ b/tests/Generators/ViewsGeneratorTest.php @@ -100,9 +100,9 @@ class ViewsGeneratorTest extends TestCase
@can('update', \${$this->single_model_var_name}) - {{ link_to_route('{$this->table_name}.edit', __('{$this->lang_name}.edit'), [\${$this->single_model_var_name}], ['class' => 'btn btn-warning', 'id' => 'edit-{$this->lang_name}-'.\${$this->single_model_var_name}->id]) }} + table_name}.edit', \${$this->single_model_var_name}) }}\" id=\"edit-{$this->lang_name}-{{ \${$this->single_model_var_name}->id }}\" class=\"btn btn-warning\">{{ __('{$this->lang_name}.edit') }} @endcan - {{ link_to_route('{$this->table_name}.index', __('{$this->lang_name}.back_to_index'), [], ['class' => 'btn btn-default']) }} + table_name}.index') }}\" class=\"btn btn-default\">{{ __('{$this->lang_name}.back_to_index') }}
From 47826099dde89ee93adaa7d59c9dcd851a0fd0e9 Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Wed, 29 Aug 2018 08:06:46 +0800 Subject: [PATCH 05/11] Remove FormField from full CRUD index view Move FormField version of index view to new stub file --- .../resources/views/full/index-formfield.stub | 58 ++++++++++++++++++++++ src/stubs/resources/views/full/index.stub | 22 ++++---- tests/Generators/ViewsGeneratorTest.php | 22 ++++---- 3 files changed, 78 insertions(+), 24 deletions(-) create mode 100644 src/stubs/resources/views/full/index-formfield.stub diff --git a/src/stubs/resources/views/full/index-formfield.stub b/src/stubs/resources/views/full/index-formfield.stub new file mode 100644 index 0000000..a10b0a0 --- /dev/null +++ b/src/stubs/resources/views/full/index-formfield.stub @@ -0,0 +1,58 @@ +@extends('layouts.app') + +@section('title', __('master.list')) + +@section('content') +

+
+ @can('create', new fullMstr) + {{ link_to_route('masters.create', __('master.create'), [], ['class' => 'btn btn-success']) }} + @endcan +
+ {{ __('master.list') }} + {{ __('app.total') }} : {{ $mstrCollections->total() }} {{ __('master.master') }} +

+
+
+
+
+ {{ Form::open(['method' => 'get','class' => 'form-inline']) }} + {!! FormField::text('q', ['label' => __('master.search'), 'placeholder' => __('master.search_text'), 'class' => 'input-sm']) !!} + {{ Form::submit(__('master.search'), ['class' => 'btn btn-sm']) }} + {{ link_to_route('masters.index', __('app.reset')) }} + {{ Form::close() }} +
+ + + + + + + + + + + @foreach($mstrCollections as $key => $singleMstr) + + + + + + + @endforeach + +
{{ __('app.table_no') }}{{ __('master.name') }}{{ __('master.description') }}{{ __('app.action') }}
{{ $mstrCollections->firstItem() + $key }}{{ $singleMstr->name_link }}{{ $singleMstr->description }} + @can('view', $singleMstr) + {!! link_to_route( + 'masters.show', + __('app.show'), + [$singleMstr], + ['class' => 'btn btn-default btn-xs', 'id' => 'show-master-' . $singleMstr->id] + ) !!} + @endcan +
+
{{ $mstrCollections->appends(Request::except('page'))->render() }}
+
+
+
+@endsection diff --git a/src/stubs/resources/views/full/index.stub b/src/stubs/resources/views/full/index.stub index a10b0a0..2cf3845 100644 --- a/src/stubs/resources/views/full/index.stub +++ b/src/stubs/resources/views/full/index.stub @@ -6,7 +6,7 @@

@can('create', new fullMstr) - {{ link_to_route('masters.create', __('master.create'), [], ['class' => 'btn btn-success']) }} + {{ __('master.create') }} @endcan
{{ __('master.list') }} @@ -16,11 +16,14 @@
- {{ Form::open(['method' => 'get','class' => 'form-inline']) }} - {!! FormField::text('q', ['label' => __('master.search'), 'placeholder' => __('master.search_text'), 'class' => 'input-sm']) !!} - {{ Form::submit(__('master.search'), ['class' => 'btn btn-sm']) }} - {{ link_to_route('masters.index', __('app.reset')) }} - {{ Form::close() }} +
+
+ + +
+ + Reset +
@@ -39,12 +42,7 @@ diff --git a/tests/Generators/ViewsGeneratorTest.php b/tests/Generators/ViewsGeneratorTest.php index 0dc7eec..6f9ba6b 100644 --- a/tests/Generators/ViewsGeneratorTest.php +++ b/tests/Generators/ViewsGeneratorTest.php @@ -22,7 +22,7 @@ class ViewsGeneratorTest extends TestCase

@can('create', new {$this->full_model_name}) - {{ link_to_route('{$this->table_name}.create', __('{$this->lang_name}.create'), [], ['class' => 'btn btn-success']) }} + table_name}.create') }}\" class=\"btn btn-success\">{{ __('{$this->lang_name}.create') }} @endcan
{{ __('{$this->lang_name}.list') }} @@ -32,11 +32,14 @@ class ViewsGeneratorTest extends TestCase
- {{ Form::open(['method' => 'get','class' => 'form-inline']) }} - {!! FormField::text('q', ['label' => __('{$this->lang_name}.search'), 'placeholder' => __('{$this->lang_name}.search_text'), 'class' => 'input-sm']) !!} - {{ Form::submit(__('{$this->lang_name}.search'), ['class' => 'btn btn-sm']) }} - {{ link_to_route('{$this->table_name}.index', __('app.reset')) }} - {{ Form::close() }} +
+
+ + lang_name}.search_text') }}\" name=\"q\" type=\"text\" id=\"q\" class=\"form-control input-sm\"> +
+ lang_name}.search') }}\" class=\"btn btn-sm\"> + table_name}.index') }}\">Reset +

{{ $singleMstr->description }} @can('view', $singleMstr) - {!! link_to_route( - 'masters.show', - __('app.show'), - [$singleMstr], - ['class' => 'btn btn-default btn-xs', 'id' => 'show-master-' . $singleMstr->id] - ) !!} + {{ __('app.show') }} @endcan
@@ -55,12 +58,7 @@ class ViewsGeneratorTest extends TestCase From 0578d4ff20e1e5f1b1fb0301a68aeecdbabfde7d Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Wed, 29 Aug 2018 17:26:13 +0800 Subject: [PATCH 06/11] Set search field value to request value --- src/stubs/resources/views/full/index.stub | 2 +- tests/Generators/ViewsGeneratorTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/stubs/resources/views/full/index.stub b/src/stubs/resources/views/full/index.stub index 2cf3845..4449dc1 100644 --- a/src/stubs/resources/views/full/index.stub +++ b/src/stubs/resources/views/full/index.stub @@ -19,7 +19,7 @@
- +
Reset diff --git a/tests/Generators/ViewsGeneratorTest.php b/tests/Generators/ViewsGeneratorTest.php index 6f9ba6b..378e0b5 100644 --- a/tests/Generators/ViewsGeneratorTest.php +++ b/tests/Generators/ViewsGeneratorTest.php @@ -35,7 +35,7 @@ class ViewsGeneratorTest extends TestCase
- lang_name}.search_text') }}\" name=\"q\" type=\"text\" id=\"q\" class=\"form-control input-sm\"> + lang_name}.search_text') }}\" name=\"q\" type=\"text\" id=\"q\" class=\"form-control input-sm\" value=\"{{ request('q') }}\">
lang_name}.search') }}\" class=\"btn btn-sm\"> table_name}.index') }}\">Reset From ca5d8ec6b721a3a19b288bb2af98e7d57111c619 Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Wed, 29 Aug 2018 17:26:17 +0800 Subject: [PATCH 07/11] Remove FormField from simple crud index view Move FormField version of simple index view to new stub file --- .../resources/views/simple/index-formfield.stub | 63 ++++++++++++++++++++++ src/stubs/resources/views/simple/index.stub | 22 ++++---- tests/Generators/Simple/ViewsGeneratorTest.php | 22 ++++---- 3 files changed, 83 insertions(+), 24 deletions(-) create mode 100644 src/stubs/resources/views/simple/index-formfield.stub diff --git a/src/stubs/resources/views/simple/index-formfield.stub b/src/stubs/resources/views/simple/index-formfield.stub new file mode 100644 index 0000000..b602cbe --- /dev/null +++ b/src/stubs/resources/views/simple/index-formfield.stub @@ -0,0 +1,63 @@ +@extends('layouts.app') + +@section('title', __('master.list')) + +@section('content') +

+
+ @can('create', new fullMstr) + {{ link_to_route('masters.index', __('master.create'), ['action' => 'create'], ['class' => 'btn btn-success']) }} + @endcan +
+ {{ __('master.list') }} + {{ __('app.total') }} : {{ $mstrCollections->total() }} {{ __('master.master') }} +

+
+
+
+
+ {{ Form::open(['method' => 'get', 'class' => 'form-inline']) }} + {!! FormField::text('q', ['label' => __('master.search'), 'placeholder' => __('master.search_text'), 'class' => 'input-sm']) !!} + {{ Form::submit(__('master.search'), ['class' => 'btn btn-sm']) }} + {{ link_to_route('masters.index', __('app.reset')) }} + {{ Form::close() }} +
+
{{ \${$this->single_model_var_name}->description }} @can('view', \${$this->single_model_var_name}) - {!! link_to_route( - '{$this->table_name}.show', - __('app.show'), - [\${$this->single_model_var_name}], - ['class' => 'btn btn-default btn-xs', 'id' => 'show-{$this->lang_name}-' . \${$this->single_model_var_name}->id] - ) !!} + table_name}.show', \${$this->single_model_var_name}) }}\" id=\"show-{$this->lang_name}-{{ \${$this->single_model_var_name}->id }}\" class=\"btn btn-default btn-xs\">{{ __('app.show') }} @endcan
+ + + + + + + + + + @foreach($mstrCollections as $key => $singleMstr) + + + + + + + @endforeach + +
{{ __('app.table_no') }}{{ __('master.name') }}{{ __('master.description') }}{{ __('app.action') }}
{{ $mstrCollections->firstItem() + $key }}{{ $singleMstr->name }}{{ $singleMstr->description }} + @can('update', $singleMstr) + {!! link_to_route( + 'masters.index', + __('app.edit'), + ['action' => 'edit', 'id' => $singleMstr->id] + Request::only('page', 'q'), + ['id' => 'edit-master-'.$singleMstr->id] + ) !!} + @endcan +
+
{{ $mstrCollections->appends(Request::except('page'))->render() }}
+
+
+
+ @if(Request::has('action')) + @include('masters.forms') + @endif +
+ +@endsection diff --git a/src/stubs/resources/views/simple/index.stub b/src/stubs/resources/views/simple/index.stub index b602cbe..561daca 100644 --- a/src/stubs/resources/views/simple/index.stub +++ b/src/stubs/resources/views/simple/index.stub @@ -6,7 +6,7 @@

@can('create', new fullMstr) - {{ link_to_route('masters.index', __('master.create'), ['action' => 'create'], ['class' => 'btn btn-success']) }} + {{ __('master.create') }} @endcan
{{ __('master.list') }} @@ -16,11 +16,14 @@
- {{ Form::open(['method' => 'get', 'class' => 'form-inline']) }} - {!! FormField::text('q', ['label' => __('master.search'), 'placeholder' => __('master.search_text'), 'class' => 'input-sm']) !!} - {{ Form::submit(__('master.search'), ['class' => 'btn btn-sm']) }} - {{ link_to_route('masters.index', __('app.reset')) }} - {{ Form::close() }} + +
+ + +
+ + Reset +
@@ -39,12 +42,7 @@ diff --git a/tests/Generators/Simple/ViewsGeneratorTest.php b/tests/Generators/Simple/ViewsGeneratorTest.php index 1fed9e6..01de64e 100644 --- a/tests/Generators/Simple/ViewsGeneratorTest.php +++ b/tests/Generators/Simple/ViewsGeneratorTest.php @@ -22,7 +22,7 @@ class ViewsGeneratorTest extends TestCase

@can('create', new {$this->full_model_name}) - {{ link_to_route('{$this->table_name}.index', __('{$this->lang_name}.create'), ['action' => 'create'], ['class' => 'btn btn-success']) }} + table_name}.index', ['action' => 'create']) }}\" class=\"btn btn-success\">{{ __('{$this->lang_name}.create') }} @endcan
{{ __('{$this->lang_name}.list') }} @@ -32,11 +32,14 @@ class ViewsGeneratorTest extends TestCase
- {{ Form::open(['method' => 'get', 'class' => 'form-inline']) }} - {!! FormField::text('q', ['label' => __('{$this->lang_name}.search'), 'placeholder' => __('{$this->lang_name}.search_text'), 'class' => 'input-sm']) !!} - {{ Form::submit(__('{$this->lang_name}.search'), ['class' => 'btn btn-sm']) }} - {{ link_to_route('{$this->table_name}.index', __('app.reset')) }} - {{ Form::close() }} +
+
+ + lang_name}.search_text') }}\" name=\"q\" type=\"text\" id=\"q\" class=\"form-control input-sm\" value=\"{{ request('q') }}\"> +
+ lang_name}.search') }}\" class=\"btn btn-sm\"> + table_name}.index') }}\">Reset +

{{ $singleMstr->description }} @can('update', $singleMstr) - {!! link_to_route( - 'masters.index', - __('app.edit'), - ['action' => 'edit', 'id' => $singleMstr->id] + Request::only('page', 'q'), - ['id' => 'edit-master-'.$singleMstr->id] - ) !!} + {{ __('app.edit') }} @endcan
@@ -55,12 +58,7 @@ class ViewsGeneratorTest extends TestCase From ccc855ed8ed946a007d5457de10f72e19ca9c8e0 Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Wed, 29 Aug 2018 17:38:08 +0800 Subject: [PATCH 08/11] Remove FormField from simple crud create form Move FormField version of simple form view to new stub file --- .../resources/views/simple/forms-formfield.stub | 63 ++++++++++++++++++++++ src/stubs/resources/views/simple/forms.stub | 31 +++++++---- tests/Generators/Simple/ViewsGeneratorTest.php | 31 +++++++---- 3 files changed, 103 insertions(+), 22 deletions(-) create mode 100644 src/stubs/resources/views/simple/forms-formfield.stub diff --git a/src/stubs/resources/views/simple/forms-formfield.stub b/src/stubs/resources/views/simple/forms-formfield.stub new file mode 100644 index 0000000..2d3f4fb --- /dev/null +++ b/src/stubs/resources/views/simple/forms-formfield.stub @@ -0,0 +1,63 @@ +@if (Request::get('action') == 'create') +@can('create', new fullMstr) + {{ Form::open(['route' => 'masters.store']) }} + {!! FormField::text('name', ['required' => true, 'label' => __('master.name')]) !!} + {!! FormField::textarea('description', ['label' => __('master.description')]) !!} + {{ Form::submit(__('master.create'), ['class' => 'btn btn-success']) }} + {{ link_to_route('masters.index', __('app.cancel'), [], ['class' => 'btn btn-default']) }} + {{ Form::close() }} +@endcan +@endif +@if (Request::get('action') == 'edit' && $editableMaster) +@can('update', $editableMaster) + {{ Form::model($editableMaster, ['route' => ['masters.update', $editableMaster], 'method' => 'patch']) }} + {!! FormField::text('name', ['required' => true, 'label' => __('master.name')]) !!} + {!! FormField::textarea('description', ['label' => __('master.description')]) !!} + @if (request('q')) + {{ Form::hidden('q', request('q')) }} + @endif + @if (request('page')) + {{ Form::hidden('page', request('page')) }} + @endif + {{ Form::submit(__('master.update'), ['class' => 'btn btn-success']) }} + {{ link_to_route('masters.index', __('app.cancel'), Request::only('page', 'q'), ['class' => 'btn btn-default']) }} + @can('delete', $editableMaster) + {{ link_to_route( + 'masters.index', + __('app.delete'), + ['action' => 'delete', 'id' => $editableMaster->id] + Request::only('page', 'q'), + ['id' => 'del-master-'.$editableMaster->id, 'class' => 'btn btn-danger pull-right'] + ) }} + @endcan + {{ Form::close() }} +@endcan +@endif +@if (Request::get('action') == 'delete' && $editableMaster) +@can('delete', $editableMaster) +
+

{{ __('master.delete') }}

+
+ +

{{ $editableMaster->name }}

+ +

{{ $editableMaster->description }}

+ {!! $errors->first('master_id', ':message') !!} +
+
+
{{ __('master.delete_confirm') }}
+ +
+@endcan +@endif diff --git a/src/stubs/resources/views/simple/forms.stub b/src/stubs/resources/views/simple/forms.stub index a98cdc3..dc1399b 100644 --- a/src/stubs/resources/views/simple/forms.stub +++ b/src/stubs/resources/views/simple/forms.stub @@ -1,16 +1,25 @@ @if (Request::get('action') == 'create') @can('create', new fullMstr) - {!! Form::open(['route' => 'masters.store']) !!} - {!! FormField::text('name', ['required' => true, 'label' => __('master.name')]) !!} - {!! FormField::textarea('description', ['label' => __('master.description')]) !!} - {!! Form::submit(__('master.create'), ['class' => 'btn btn-success']) !!} - {{ link_to_route('masters.index', __('app.cancel'), [], ['class' => 'btn btn-default']) }} - {!! Form::close() !!} +
+ {{ csrf_field() }} +
+ + + {!! $errors->first('name', ':message') !!} +
+
+ + + {!! $errors->first('description', ':message') !!} +
+ + {{ __('app.cancel') }} + @endcan @endif @if (Request::get('action') == 'edit' && $editableMaster) @can('update', $editableMaster) - {!! Form::model($editableMaster, ['route' => ['masters.update', $editableMaster], 'method' => 'patch']) !!} + {{ Form::model($editableMaster, ['route' => ['masters.update', $editableMaster], 'method' => 'patch']) }} {!! FormField::text('name', ['required' => true, 'label' => __('master.name')]) !!} {!! FormField::textarea('description', ['label' => __('master.description')]) !!} @if (request('q')) @@ -19,17 +28,17 @@ @if (request('page')) {{ Form::hidden('page', request('page')) }} @endif - {!! Form::submit(__('master.update'), ['class' => 'btn btn-success']) !!} + {{ Form::submit(__('master.update'), ['class' => 'btn btn-success']) }} {{ link_to_route('masters.index', __('app.cancel'), Request::only('page', 'q'), ['class' => 'btn btn-default']) }} @can('delete', $editableMaster) - {!! link_to_route( + {{ link_to_route( 'masters.index', __('app.delete'), ['action' => 'delete', 'id' => $editableMaster->id] + Request::only('page', 'q'), ['id' => 'del-master-'.$editableMaster->id, 'class' => 'btn btn-danger pull-right'] - ) !!} + ) }} @endcan - {!! Form::close() !!} + {{ Form::close() }} @endcan @endif @if (Request::get('action') == 'delete' && $editableMaster) diff --git a/tests/Generators/Simple/ViewsGeneratorTest.php b/tests/Generators/Simple/ViewsGeneratorTest.php index 01de64e..089be3f 100644 --- a/tests/Generators/Simple/ViewsGeneratorTest.php +++ b/tests/Generators/Simple/ViewsGeneratorTest.php @@ -88,17 +88,26 @@ class ViewsGeneratorTest extends TestCase $this->assertFileExists($formViewPath); $formViewContent = "@if (Request::get('action') == 'create') @can('create', new {$this->full_model_name}) - {!! Form::open(['route' => '{$this->table_name}.store']) !!} - {!! FormField::text('name', ['required' => true, 'label' => __('{$this->lang_name}.name')]) !!} - {!! FormField::textarea('description', ['label' => __('{$this->lang_name}.description')]) !!} - {!! Form::submit(__('{$this->lang_name}.create'), ['class' => 'btn btn-success']) !!} - {{ link_to_route('{$this->table_name}.index', __('app.cancel'), [], ['class' => 'btn btn-default']) }} - {!! Form::close() !!} +
table_name}.store') }}\" accept-charset=\"UTF-8\"> + {{ csrf_field() }} +
has('name') ? ' has-error' : '' }}\"> + + + {!! \$errors->first('name', ':message') !!} +
+
has('description') ? ' has-error' : '' }}\"> + + + {!! \$errors->first('description', ':message') !!} +
+ lang_name}.create') }}\" class=\"btn btn-success\"> + table_name}.index') }}\" class=\"btn btn-default\">{{ __('app.cancel') }} + @endcan @endif @if (Request::get('action') == 'edit' && \$editable{$this->model_name}) @can('update', \$editable{$this->model_name}) - {!! Form::model(\$editable{$this->model_name}, ['route' => ['{$this->table_name}.update', \$editable{$this->model_name}], 'method' => 'patch']) !!} + {{ Form::model(\$editable{$this->model_name}, ['route' => ['{$this->table_name}.update', \$editable{$this->model_name}], 'method' => 'patch']) }} {!! FormField::text('name', ['required' => true, 'label' => __('{$this->lang_name}.name')]) !!} {!! FormField::textarea('description', ['label' => __('{$this->lang_name}.description')]) !!} @if (request('q')) @@ -107,17 +116,17 @@ class ViewsGeneratorTest extends TestCase @if (request('page')) {{ Form::hidden('page', request('page')) }} @endif - {!! Form::submit(__('{$this->lang_name}.update'), ['class' => 'btn btn-success']) !!} + {{ Form::submit(__('{$this->lang_name}.update'), ['class' => 'btn btn-success']) }} {{ link_to_route('{$this->table_name}.index', __('app.cancel'), Request::only('page', 'q'), ['class' => 'btn btn-default']) }} @can('delete', \$editable{$this->model_name}) - {!! link_to_route( + {{ link_to_route( '{$this->table_name}.index', __('app.delete'), ['action' => 'delete', 'id' => \$editable{$this->model_name}->id] + Request::only('page', 'q'), ['id' => 'del-{$this->lang_name}-'.\$editable{$this->model_name}->id, 'class' => 'btn btn-danger pull-right'] - ) !!} + ) }} @endcan - {!! Form::close() !!} + {{ Form::close() }} @endcan @endif @if (Request::get('action') == 'delete' && \$editable{$this->model_name}) From 4d94ae28784c56c6f58a1713af44f3f0442b10a0 Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Wed, 29 Aug 2018 17:42:53 +0800 Subject: [PATCH 09/11] Remove FormField from simple crud edit form --- src/stubs/resources/views/simple/forms.stub | 42 ++++++++++++++------------ tests/Generators/Simple/ViewsGeneratorTest.php | 42 ++++++++++++++------------ 2 files changed, 44 insertions(+), 40 deletions(-) diff --git a/src/stubs/resources/views/simple/forms.stub b/src/stubs/resources/views/simple/forms.stub index dc1399b..d1e830b 100644 --- a/src/stubs/resources/views/simple/forms.stub +++ b/src/stubs/resources/views/simple/forms.stub @@ -19,26 +19,28 @@ @endif @if (Request::get('action') == 'edit' && $editableMaster) @can('update', $editableMaster) - {{ Form::model($editableMaster, ['route' => ['masters.update', $editableMaster], 'method' => 'patch']) }} - {!! FormField::text('name', ['required' => true, 'label' => __('master.name')]) !!} - {!! FormField::textarea('description', ['label' => __('master.description')]) !!} - @if (request('q')) - {{ Form::hidden('q', request('q')) }} - @endif - @if (request('page')) - {{ Form::hidden('page', request('page')) }} - @endif - {{ Form::submit(__('master.update'), ['class' => 'btn btn-success']) }} - {{ link_to_route('masters.index', __('app.cancel'), Request::only('page', 'q'), ['class' => 'btn btn-default']) }} - @can('delete', $editableMaster) - {{ link_to_route( - 'masters.index', - __('app.delete'), - ['action' => 'delete', 'id' => $editableMaster->id] + Request::only('page', 'q'), - ['id' => 'del-master-'.$editableMaster->id, 'class' => 'btn btn-danger pull-right'] - ) }} - @endcan - {{ Form::close() }} +
+ {{ csrf_field() }} {{ method_field('patch') }} +
+
+ + + {!! $errors->first('name', ':message') !!} +
+
+ + + {!! $errors->first('description', ':message') !!} +
+
+ + @endcan @endif @if (Request::get('action') == 'delete' && $editableMaster) diff --git a/tests/Generators/Simple/ViewsGeneratorTest.php b/tests/Generators/Simple/ViewsGeneratorTest.php index 089be3f..cbb7343 100644 --- a/tests/Generators/Simple/ViewsGeneratorTest.php +++ b/tests/Generators/Simple/ViewsGeneratorTest.php @@ -107,26 +107,28 @@ class ViewsGeneratorTest extends TestCase @endif @if (Request::get('action') == 'edit' && \$editable{$this->model_name}) @can('update', \$editable{$this->model_name}) - {{ Form::model(\$editable{$this->model_name}, ['route' => ['{$this->table_name}.update', \$editable{$this->model_name}], 'method' => 'patch']) }} - {!! FormField::text('name', ['required' => true, 'label' => __('{$this->lang_name}.name')]) !!} - {!! FormField::textarea('description', ['label' => __('{$this->lang_name}.description')]) !!} - @if (request('q')) - {{ Form::hidden('q', request('q')) }} - @endif - @if (request('page')) - {{ Form::hidden('page', request('page')) }} - @endif - {{ Form::submit(__('{$this->lang_name}.update'), ['class' => 'btn btn-success']) }} - {{ link_to_route('{$this->table_name}.index', __('app.cancel'), Request::only('page', 'q'), ['class' => 'btn btn-default']) }} - @can('delete', \$editable{$this->model_name}) - {{ link_to_route( - '{$this->table_name}.index', - __('app.delete'), - ['action' => 'delete', 'id' => \$editable{$this->model_name}->id] + Request::only('page', 'q'), - ['id' => 'del-{$this->lang_name}-'.\$editable{$this->model_name}->id, 'class' => 'btn btn-danger pull-right'] - ) }} - @endcan - {{ Form::close() }} +
table_name}.update', \$editable{$this->model_name}) }}\" accept-charset=\"UTF-8\"> + {{ csrf_field() }} {{ method_field('patch') }} +
+
has('name') ? ' has-error' : '' }}\"> + + model_name}->name) }}\" required> + {!! \$errors->first('name', ':message') !!} +
+
has('description') ? ' has-error' : '' }}\"> + + + {!! \$errors->first('description', ':message') !!} +
+
+ + @endcan @endif @if (Request::get('action') == 'delete' && \$editable{$this->model_name}) From 06cb3a5a03406f94db2df76e7b164cd690bfe301 Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Wed, 29 Aug 2018 17:49:03 +0800 Subject: [PATCH 10/11] Remove FormField from simple crud delete form --- src/stubs/resources/views/simple/forms.stub | 19 ++++++++----------- tests/Generators/Simple/ViewsGeneratorTest.php | 19 ++++++++----------- 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/src/stubs/resources/views/simple/forms.stub b/src/stubs/resources/views/simple/forms.stub index d1e830b..8cd214a 100644 --- a/src/stubs/resources/views/simple/forms.stub +++ b/src/stubs/resources/views/simple/forms.stub @@ -57,17 +57,14 @@
{{ __('master.delete_confirm') }}
@endcan diff --git a/tests/Generators/Simple/ViewsGeneratorTest.php b/tests/Generators/Simple/ViewsGeneratorTest.php index cbb7343..8f25729 100644 --- a/tests/Generators/Simple/ViewsGeneratorTest.php +++ b/tests/Generators/Simple/ViewsGeneratorTest.php @@ -145,17 +145,14 @@ class ViewsGeneratorTest extends TestCase
{{ __('{$this->lang_name}.delete_confirm') }}
- {!! FormField::delete( - ['route' => ['{$this->table_name}.destroy', \$editable{$this->model_name}]], - __('app.delete_confirm_button'), - ['class'=>'btn btn-danger'], - [ - '{$this->lang_name}_id' => \$editable{$this->model_name}->id, - 'page' => request('page'), - 'q' => request('q'), - ] - ) !!} - {{ link_to_route('{$this->table_name}.index', __('app.cancel'), Request::only('page', 'q'), ['class' => 'btn btn-default']) }} +
table_name}.destroy', \$editable{$this->model_name}) }}\" accept-charset=\"UTF-8\" onsubmit=\"return confirm("Are you sure to delete this?")\" class=\"del-form pull-right\" style=\"display: inline;\"> + {{ csrf_field() }} {{ method_field('delete') }} + lang_name}_id\" type=\"hidden\" value=\"{{ \$editable{$this->model_name}->id }}\"> + + + + + table_name}.index', [\$editable{$this->model_name}] + Request::only('page', 'q')) }}\" class=\"btn btn-default\">{{ __('app.cancel') }}
@endcan From 0ef54c273c864e734bc287d541e7a70bdb048e0c Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Wed, 29 Aug 2018 18:33:55 +0800 Subject: [PATCH 11/11] Update simple form view to correct delete action --- src/stubs/resources/views/simple/forms.stub | 36 ++++++++++++-------------- tests/Generators/Simple/ViewsGeneratorTest.php | 36 ++++++++++++-------------- 2 files changed, 34 insertions(+), 38 deletions(-) diff --git a/src/stubs/resources/views/simple/forms.stub b/src/stubs/resources/views/simple/forms.stub index 8cd214a..5a3236d 100644 --- a/src/stubs/resources/views/simple/forms.stub +++ b/src/stubs/resources/views/simple/forms.stub @@ -21,25 +21,23 @@ @can('update', $editableMaster)
{{ csrf_field() }} {{ method_field('patch') }} -
-
- - - {!! $errors->first('name', ':message') !!} -
-
- - - {!! $errors->first('description', ':message') !!} -
+
+ + + {!! $errors->first('name', ':message') !!}
-
{{ \${$this->single_model_var_name}->description }} @can('update', \${$this->single_model_var_name}) - {!! link_to_route( - '{$this->table_name}.index', - __('app.edit'), - ['action' => 'edit', 'id' => \${$this->single_model_var_name}->id] + Request::only('page', 'q'), - ['id' => 'edit-{$this->lang_name}-'.\${$this->single_model_var_name}->id] - ) !!} + table_name}.index', ['action' => 'edit', 'id' => \${$this->single_model_var_name}->id] + Request::only('page', 'q')) }}\" id=\"edit-{$this->lang_name}-{{ \${$this->single_model_var_name}->id }}\">{{ __('app.edit') }} @endcan