Browse Source

Update simple crud, move delete button to edit form

tags/1.1.2
Nafies Luthfi 8 years ago
parent
commit
ee61a11c4f
  1. 2
      src/stubs/test-feature-simple.stub
  2. 8
      src/stubs/view-forms.stub
  3. 24
      src/stubs/view-index-simple.stub
  4. 4
      tests/Generators/Simple/FeatureTestGeneratorTest.php
  5. 34
      tests/Generators/Simple/ViewsGeneratorTest.php

2
src/stubs/test-feature-simple.stub

@ -71,7 +71,7 @@ class ManageMastersTest extends TestCase
$this->loginAsUser();
$singleMstr = factory(Master::class)->create();
$this->visit(route('masters.index', [$singleMstr->id]));
$this->visit(route('masters.index', ['action' => 'edit', 'id' => $singleMstr->id]));
$this->click('del-master-'.$singleMstr->id);
$this->seePageIs(route('masters.index', ['action' => 'delete', 'id' => $singleMstr->id]));

8
src/stubs/view-forms.stub

@ -21,6 +21,14 @@
@endif
{!! Form::submit(trans('master.update'), ['class' => 'btn btn-success']) !!}
{{ link_to_route('masters.index', trans('app.cancel'), [], ['class' => 'btn btn-default']) }}
@can('delete', $singleMstr)
{!! link_to_route(
'masters.index',
trans('app.delete'),
['action' => 'delete', 'id' => $singleMstr->id] + Request::only('page', 'q'),
['id' => 'del-master-'.$singleMstr->id, 'class' => 'btn btn-danger pull-right']
) !!}
@endcan
{!! Form::close() !!}
@endcan
@endif

24
src/stubs/view-index-simple.stub

@ -38,22 +38,14 @@
<td>{{ $singleMstr->name }}</td>
<td>{{ $singleMstr->description }}</td>
<td class="text-center">
@can('update', $singleMstr)
{!! link_to_route(
'masters.index',
trans('app.edit'),
['action' => 'edit', 'id' => $singleMstr->id] + Request::only('page', 'q'),
['id' => 'edit-master-'.$singleMstr->id]
) !!} |
@endcan
@can('delete', $singleMstr)
{!! link_to_route(
'masters.index',
trans('app.delete'),
['action' => 'delete', 'id' => $singleMstr->id] + Request::only('page', 'q'),
['id' => 'del-master-'.$singleMstr->id]
) !!}
@endcan
@can('update', $singleMstr)
{!! link_to_route(
'masters.index',
trans('app.edit'),
['action' => 'edit', 'id' => $singleMstr->id] + Request::only('page', 'q'),
['id' => 'edit-master-'.$singleMstr->id]
) !!}
@endcan
</td>
</tr>
@endforeach

4
tests/Generators/Simple/FeatureTestGeneratorTest.php

@ -127,7 +127,7 @@ class Manage{$this->plural_model_name}Test extends TestCase
\$this->loginAsUser();
\${$this->single_model_var_name} = factory({$this->model_name}::class)->create();
\$this->visit(route('{$this->table_name}.index', [\${$this->single_model_var_name}->id]));
\$this->visit(route('{$this->table_name}.index', ['action' => 'edit', 'id' => \${$this->single_model_var_name}->id]));
\$this->click('del-{$this->lang_name}-'.\${$this->single_model_var_name}->id);
\$this->seePageIs(route('{$this->table_name}.index', ['action' => 'delete', 'id' => \${$this->single_model_var_name}->id]));
@ -276,7 +276,7 @@ class Manage{$this->plural_model_name}Test extends TestCase
\$this->loginAsUser();
\${$this->single_model_var_name} = factory({$this->model_name}::class)->create();
\$this->visit(route('{$this->table_name}.index', [\${$this->single_model_var_name}->id]));
\$this->visit(route('{$this->table_name}.index', ['action' => 'edit', 'id' => \${$this->single_model_var_name}->id]));
\$this->click('del-{$this->lang_name}-'.\${$this->single_model_var_name}->id);
\$this->seePageIs(route('{$this->table_name}.index', ['action' => 'delete', 'id' => \${$this->single_model_var_name}->id]));

34
tests/Generators/Simple/ViewsGeneratorTest.php

@ -2,8 +2,8 @@
namespace Tests\Generators\Simple;
use Illuminate\Contracts\Console\Kernel;
use Tests\TestCase;
use Illuminate\Contracts\Console\Kernel;
class ViewsGeneratorTest extends TestCase
{
@ -54,22 +54,14 @@ class ViewsGeneratorTest extends TestCase
<td>{{ \${$this->single_model_var_name}->name }}</td>
<td>{{ \${$this->single_model_var_name}->description }}</td>
<td class=\"text-center\">
@can('update', \${$this->single_model_var_name})
{!! link_to_route(
'{$this->table_name}.index',
trans('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]
) !!} |
@endcan
@can('delete', \${$this->single_model_var_name})
{!! link_to_route(
'{$this->table_name}.index',
trans('app.delete'),
['action' => 'delete', 'id' => \${$this->single_model_var_name}->id] + Request::only('page', 'q'),
['id' => 'del-{$this->lang_name}-'.\${$this->single_model_var_name}->id]
) !!}
@endcan
@can('update', \${$this->single_model_var_name})
{!! link_to_route(
'{$this->table_name}.index',
trans('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]
) !!}
@endcan
</td>
</tr>
@endforeach
@ -119,6 +111,14 @@ class ViewsGeneratorTest extends TestCase
@endif
{!! Form::submit(trans('{$this->lang_name}.update'), ['class' => 'btn btn-success']) !!}
{{ link_to_route('{$this->table_name}.index', trans('app.cancel'), [], ['class' => 'btn btn-default']) }}
@can('delete', \${$this->single_model_var_name})
{!! link_to_route(
'{$this->table_name}.index',
trans('app.delete'),
['action' => 'delete', 'id' => \${$this->single_model_var_name}->id] + Request::only('page', 'q'),
['id' => 'del-{$this->lang_name}-'.\${$this->single_model_var_name}->id, 'class' => 'btn btn-danger pull-right']
) !!}
@endcan
{!! Form::close() !!}
@endcan
@endif

Loading…
Cancel
Save