From ca5d8ec6b721a3a19b288bb2af98e7d57111c619 Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Wed, 29 Aug 2018 17:26:17 +0800 Subject: [PATCH] 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() }} +
+ + + + + + + + + + + @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
{{ \${$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