From b0a008c77f2e0f4af5d43a43fed547732c669aa4 Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Fri, 7 Sep 2018 09:33:10 +0800 Subject: [PATCH 1/5] Fix invalid cancel link on edit and delete simpel forms --- src/stubs/resources/views/simple/forms.stub | 4 ++-- tests/Generators/Simple/ViewsGeneratorTest.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/stubs/resources/views/simple/forms.stub b/src/stubs/resources/views/simple/forms.stub index 5a3236d..af0c991 100644 --- a/src/stubs/resources/views/simple/forms.stub +++ b/src/stubs/resources/views/simple/forms.stub @@ -34,7 +34,7 @@ - {{ __('app.cancel') }} + {{ __('app.cancel') }} @can('delete', $editableMaster) {{ __('app.delete') }} @endcan @@ -62,7 +62,7 @@ - {{ __('app.cancel') }} + {{ __('app.cancel') }} @endcan diff --git a/tests/Generators/Simple/ViewsGeneratorTest.php b/tests/Generators/Simple/ViewsGeneratorTest.php index 80b4e93..91322d7 100644 --- a/tests/Generators/Simple/ViewsGeneratorTest.php +++ b/tests/Generators/Simple/ViewsGeneratorTest.php @@ -122,7 +122,7 @@ class ViewsGeneratorTest extends TestCase lang_name}.update') }}\" class=\"btn btn-success\"> - table_name}.show', \$editable{$this->model_name}) }}\" class=\"btn btn-default\">{{ __('app.cancel') }} + table_name}.index', Request::only('q', 'page')) }}\" class=\"btn btn-default\">{{ __('app.cancel') }} @can('delete', \$editable{$this->model_name}) table_name}.index', ['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\">{{ __('app.delete') }} @endcan @@ -150,7 +150,7 @@ class ViewsGeneratorTest extends TestCase - table_name}.index', [\$editable{$this->model_name}] + Request::only('page', 'q')) }}\" class=\"btn btn-default\">{{ __('app.cancel') }} + table_name}.index', Request::only('q', 'page')) }}\" class=\"btn btn-default\">{{ __('app.cancel') }} @endcan From cd97af37c5f30035363c748cd200b43cce3db20c Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Fri, 7 Sep 2018 09:36:39 +0800 Subject: [PATCH 2/5] Update form stubs fixing textareas attribute --- src/stubs/resources/views/full/create.stub | 2 +- src/stubs/resources/views/full/edit.stub | 2 +- src/stubs/resources/views/simple/forms.stub | 4 ++-- tests/Generators/Simple/ViewsGeneratorTest.php | 4 ++-- tests/Generators/ViewsGeneratorTest.php | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/stubs/resources/views/full/create.stub b/src/stubs/resources/views/full/create.stub index 27e585d..0018b7e 100644 --- a/src/stubs/resources/views/full/create.stub +++ b/src/stubs/resources/views/full/create.stub @@ -17,7 +17,7 @@
- + {!! $errors->first('description', ':message') !!}
diff --git a/src/stubs/resources/views/full/edit.stub b/src/stubs/resources/views/full/edit.stub index 4b96353..5e9c344 100644 --- a/src/stubs/resources/views/full/edit.stub +++ b/src/stubs/resources/views/full/edit.stub @@ -43,7 +43,7 @@
- + {!! $errors->first('description', ':message') !!}
diff --git a/src/stubs/resources/views/simple/forms.stub b/src/stubs/resources/views/simple/forms.stub index af0c991..74b622a 100644 --- a/src/stubs/resources/views/simple/forms.stub +++ b/src/stubs/resources/views/simple/forms.stub @@ -9,7 +9,7 @@
- + {!! $errors->first('description', ':message') !!}
@@ -28,7 +28,7 @@
- + {!! $errors->first('description', ':message') !!}
diff --git a/tests/Generators/Simple/ViewsGeneratorTest.php b/tests/Generators/Simple/ViewsGeneratorTest.php index 91322d7..c31f68b 100644 --- a/tests/Generators/Simple/ViewsGeneratorTest.php +++ b/tests/Generators/Simple/ViewsGeneratorTest.php @@ -97,7 +97,7 @@ class ViewsGeneratorTest extends TestCase
has('description') ? ' has-error' : '' }}\"> - + {!! \$errors->first('description', ':message') !!}
lang_name}.create') }}\" class=\"btn btn-success\"> @@ -116,7 +116,7 @@ class ViewsGeneratorTest extends TestCase
has('description') ? ' has-error' : '' }}\"> - + {!! \$errors->first('description', ':message') !!}
diff --git a/tests/Generators/ViewsGeneratorTest.php b/tests/Generators/ViewsGeneratorTest.php index 16ce31a..884b6e2 100644 --- a/tests/Generators/ViewsGeneratorTest.php +++ b/tests/Generators/ViewsGeneratorTest.php @@ -136,7 +136,7 @@ class ViewsGeneratorTest extends TestCase
has('description') ? ' has-error' : '' }}\"> - + {!! \$errors->first('description', ':message') !!}
@@ -205,7 +205,7 @@ class ViewsGeneratorTest extends TestCase
has('description') ? ' has-error' : '' }}\"> - + {!! \$errors->first('description', ':message') !!}
From 33b81dc038bf23b18d8e2ff2cbf235e9fa706085 Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Fri, 7 Sep 2018 10:15:35 +0800 Subject: [PATCH 3/5] Update simple views stub to bootstrap 4 Save bootstrap 3 forms view as forms-bs3 Save bootstrap 3 index view as index-bs3 --- src/stubs/resources/views/simple/forms-bs3.stub | 69 +++++++++++++++++++++++++ src/stubs/resources/views/simple/forms.stub | 46 ++++++++--------- src/stubs/resources/views/simple/index-bs3.stub | 61 ++++++++++++++++++++++ src/stubs/resources/views/simple/index.stub | 18 +++---- tests/Generators/Simple/ViewsGeneratorTest.php | 64 +++++++++++------------ 5 files changed, 194 insertions(+), 64 deletions(-) create mode 100644 src/stubs/resources/views/simple/forms-bs3.stub create mode 100644 src/stubs/resources/views/simple/index-bs3.stub diff --git a/src/stubs/resources/views/simple/forms-bs3.stub b/src/stubs/resources/views/simple/forms-bs3.stub new file mode 100644 index 0000000..74b622a --- /dev/null +++ b/src/stubs/resources/views/simple/forms-bs3.stub @@ -0,0 +1,69 @@ +@if (Request::get('action') == 'create') +@can('create', new fullMstr) +
+ {{ csrf_field() }} +
+ + + {!! $errors->first('name', ':message') !!} +
+
+ + + {!! $errors->first('description', ':message') !!} +
+ + {{ __('app.cancel') }} +
+@endcan +@endif +@if (Request::get('action') == 'edit' && $editableMaster) +@can('update', $editableMaster) +
+ {{ csrf_field() }} {{ method_field('patch') }} +
+ + + {!! $errors->first('name', ':message') !!} +
+
+ + + {!! $errors->first('description', ':message') !!} +
+ + + + {{ __('app.cancel') }} + @can('delete', $editableMaster) + {{ __('app.delete') }} + @endcan +
+@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 74b622a..4104eb7 100644 --- a/src/stubs/resources/views/simple/forms.stub +++ b/src/stubs/resources/views/simple/forms.stub @@ -2,18 +2,18 @@ @can('create', new fullMstr)
{{ csrf_field() }} -
+
- - {!! $errors->first('name', ':message') !!} + + {!! $errors->first('name', ':message') !!}
-
+
- - {!! $errors->first('description', ':message') !!} + + {!! $errors->first('description', ':message') !!}
- {{ __('app.cancel') }} + {{ __('app.cancel') }} @endcan @endif @@ -21,20 +21,20 @@ @can('update', $editableMaster)
{{ csrf_field() }} {{ method_field('patch') }} -
+
- - {!! $errors->first('name', ':message') !!} + + {!! $errors->first('name', ':message') !!}
-
+
- - {!! $errors->first('description', ':message') !!} + + {!! $errors->first('description', ':message') !!}
- {{ __('app.cancel') }} + {{ __('app.cancel') }} @can('delete', $editableMaster) {{ __('app.delete') }} @endcan @@ -43,18 +43,18 @@ @endif @if (Request::get('action') == 'delete' && $editableMaster) @can('delete', $editableMaster) -
-

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

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

{{ $editableMaster->name }}

- +

{{ $editableMaster->description }}

- {!! $errors->first('master_id', ':message') !!} + {!! $errors->first('master_id', ':message') !!}

-
{{ __('master.delete_confirm') }}
- @endcan diff --git a/src/stubs/resources/views/simple/index-bs3.stub b/src/stubs/resources/views/simple/index-bs3.stub new file mode 100644 index 0000000..724aa38 --- /dev/null +++ b/src/stubs/resources/views/simple/index-bs3.stub @@ -0,0 +1,61 @@ +@extends('layouts.app') + +@section('title', __('master.list')) + +@section('content') +

+
+ @can('create', new fullMstr) + {{ __('master.create') }} + @endcan +
+ {{ __('master.list') }} + {{ __('app.total') }} : {{ $mstrCollections->total() }} {{ __('master.master') }} +

+
+
+
+
+
+
+ + +
+ + {{ __('app.reset') }} +
+
+ + + + + + + + + + + @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) + {{ __('app.edit') }} + @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 724aa38..3d76bdb 100644 --- a/src/stubs/resources/views/simple/index.stub +++ b/src/stubs/resources/views/simple/index.stub @@ -3,8 +3,8 @@ @section('title', __('master.list')) @section('content') -

-
+

+
@can('create', new fullMstr) {{ __('master.create') }} @endcan @@ -14,18 +14,18 @@

-
-
+
+
- - + +
- {{ __('app.reset') }} + {{ __('app.reset') }}
- +
@@ -49,7 +49,7 @@ @endforeach
{{ __('app.table_no') }}
-
{{ $mstrCollections->appends(Request::except('page'))->render() }}
+
{{ $mstrCollections->appends(Request::except('page'))->render() }}
diff --git a/tests/Generators/Simple/ViewsGeneratorTest.php b/tests/Generators/Simple/ViewsGeneratorTest.php index c31f68b..aeb0b8c 100644 --- a/tests/Generators/Simple/ViewsGeneratorTest.php +++ b/tests/Generators/Simple/ViewsGeneratorTest.php @@ -19,8 +19,8 @@ class ViewsGeneratorTest extends TestCase @section('title', __('{$this->lang_name}.list')) @section('content') -

-
+

+
@can('create', new {$this->full_model_name}) table_name}.index', ['action' => 'create']) }}\" class=\"btn btn-success\">{{ __('{$this->lang_name}.create') }} @endcan @@ -30,18 +30,18 @@ class ViewsGeneratorTest extends TestCase

-
-
+
+
- - lang_name}.search_text') }}\" name=\"q\" type=\"text\" id=\"q\" class=\"form-control input-sm\" value=\"{{ request('q') }}\"> + + lang_name}.search_text') }}\" name=\"q\" type=\"text\" id=\"q\" class=\"form-control form-control-sm mr-sm-2\" value=\"{{ request('q') }}\">
lang_name}.search') }}\" class=\"btn btn-sm\"> - table_name}.index') }}\">{{ __('app.reset') }} + table_name}.index') }}\" class=\"btn btn-link btn-sm\">{{ __('app.reset') }}
- +
@@ -65,7 +65,7 @@ class ViewsGeneratorTest extends TestCase @endforeach
{{ __('app.table_no') }}
-
{{ \${$this->collection_model_var_name}->appends(Request::except('page'))->render() }}
+
{{ \${$this->collection_model_var_name}->appends(Request::except('page'))->render() }}
@@ -90,18 +90,18 @@ class ViewsGeneratorTest extends TestCase @can('create', new {$this->full_model_name})
table_name}.store') }}\" accept-charset=\"UTF-8\"> {{ csrf_field() }} -
has('name') ? ' has-error' : '' }}\"> +
- - {!! \$errors->first('name', ':message') !!} + has('name') ? ' is-invalid' : '' }}\" name=\"name\" value=\"{{ old('name') }}\" required> + {!! \$errors->first('name', ':message') !!}
-
has('description') ? ' has-error' : '' }}\"> +
- - {!! \$errors->first('description', ':message') !!} + + {!! \$errors->first('description', ':message') !!}
lang_name}.create') }}\" class=\"btn btn-success\"> - table_name}.index') }}\" class=\"btn btn-default\">{{ __('app.cancel') }} + table_name}.index') }}\" class=\"btn btn-link\">{{ __('app.cancel') }} @endcan @endif @@ -109,20 +109,20 @@ class ViewsGeneratorTest extends TestCase @can('update', \$editable{$this->model_name})
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('name') ? ' is-invalid' : '' }}\" name=\"name\" value=\"{{ old('name', \$editable{$this->model_name}->name) }}\" required> + {!! \$errors->first('name', ':message') !!}
-
has('description') ? ' has-error' : '' }}\"> +
- - {!! \$errors->first('description', ':message') !!} + + {!! \$errors->first('description', ':message') !!}
lang_name}.update') }}\" class=\"btn btn-success\"> - table_name}.index', Request::only('q', 'page')) }}\" class=\"btn btn-default\">{{ __('app.cancel') }} + table_name}.index', Request::only('q', 'page')) }}\" class=\"btn btn-link\">{{ __('app.cancel') }} @can('delete', \$editable{$this->model_name}) table_name}.index', ['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\">{{ __('app.delete') }} @endcan @@ -131,18 +131,18 @@ class ViewsGeneratorTest extends TestCase @endif @if (Request::get('action') == 'delete' && \$editable{$this->model_name}) @can('delete', \$editable{$this->model_name}) -
-

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

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

{{ \$editable{$this->model_name}->name }}

- +

{{ \$editable{$this->model_name}->description }}

- {!! \$errors->first('{$this->lang_name}_id', ':message') !!} + {!! \$errors->first('{$this->lang_name}_id', ':message') !!}

-
{{ __('{$this->lang_name}.delete_confirm') }}
-
+
{{ __('{$this->lang_name}.delete_confirm') }}
+
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 }}\"> @@ -150,7 +150,7 @@ class ViewsGeneratorTest extends TestCase - table_name}.index', Request::only('q', 'page')) }}\" class=\"btn btn-default\">{{ __('app.cancel') }} + table_name}.index', Request::only('q', 'page')) }}\" class=\"btn btn-link\">{{ __('app.cancel') }}
@endcan From a1bbd9e2f99815bdeb6bd41fa6636f44cbab9488 Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Fri, 7 Sep 2018 10:40:57 +0800 Subject: [PATCH 4/5] Fix some invalid class attributes --- src/stubs/resources/views/simple/forms.stub | 4 ++-- src/stubs/resources/views/simple/index-bs3.stub | 2 +- src/stubs/resources/views/simple/index.stub | 2 +- tests/Generators/Simple/ViewsGeneratorTest.php | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/stubs/resources/views/simple/forms.stub b/src/stubs/resources/views/simple/forms.stub index 4104eb7..fee69ec 100644 --- a/src/stubs/resources/views/simple/forms.stub +++ b/src/stubs/resources/views/simple/forms.stub @@ -36,7 +36,7 @@ {{ __('app.cancel') }} @can('delete', $editableMaster) - {{ __('app.delete') }} + {{ __('app.delete') }} @endcan @endcan @@ -55,7 +55,7 @@
{{ __('master.delete_confirm') }}