Browse Source

User can edit fahter and mother name

pull/3/head
Nafies Luthfi 8 years ago
parent
commit
4833a383ac
  1. 53
      resources/views/users/partials/parent-spouse.blade.php
  2. 12
      tests/Feature/ManageUserFamiliesTest.php

53
resources/views/users/partials/parent-spouse.blade.php

@ -6,41 +6,61 @@
<tr>
<th class="col-sm-4">Ayah</th>
<td class="col-sm-8">
@if ($user->father_id)
{{ $user->father->profileLink() }}
@else
@can ('edit', $currentUser)
@can ('edit', $currentUser)
@if (request('action') == 'set_father')
{{ Form::open(['route' => ['family-actions.set-father', $user->id]]) }}
{!! FormField::select('set_father_id', $malePersonList, ['label' => false, 'placeholder' => 'Pilih dari Laki-laki Terdaftar']) !!}
{!! FormField::select('set_father_id', $malePersonList, ['label' => false, 'value' => $user->father_id, 'placeholder' => 'Pilih dari Laki-laki Terdaftar']) !!}
<div class="input-group">
{{ Form::text('set_father', null, ['class' => 'form-control input-sm', 'placeholder' => 'Input Nama Baru...']) }}
<span class="input-group-btn">
{{ Form::submit('update', ['class' => 'btn btn-info btn-sm', 'id' => 'set_father_button']) }}
{{ link_to_route('users.show', 'Batal', [$user->id], ['class' => 'btn btn-default btn-sm']) }}
</span>
</div>
@endcan
{{ Form::close() }}
@endif
@else
@if ($user->father_id)
{{ $user->father->profileLink() }}
@endif
<div class="pull-right">
{{ link_to_route('users.show', 'Set Ayah', [$user->id, 'action' => 'set_father'], ['class' => 'btn btn-link btn-xs']) }}
</div>
@endif
@else
@if ($user->father_id)
{{ $user->father->profileLink() }}
@endif
@endcan
</td>
</tr>
<tr>
<th>Ibu</th>
<td>
@if ($user->mother_id)
{{ $user->mother->profileLink() }}
@else
@can ('edit', $currentUser)
@can ('edit', $currentUser)
@if (request('action') == 'set_mother')
{{ Form::open(['route' => ['family-actions.set-mother', $user->id]]) }}
{!! FormField::select('set_mother_id', $femalePersonList, ['label' => false, 'placeholder' => 'Pilih dari Wanita Terdaftar']) !!}
{!! FormField::select('set_mother_id', $femalePersonList, ['label' => false, 'value' => $user->mother_id, 'placeholder' => 'Pilih dari Laki-laki Terdaftar']) !!}
<div class="input-group">
{{ Form::text('set_mother', null, ['class' => 'form-control input-sm', 'placeholder' => 'Input Nama Baru...']) }}
<span class="input-group-btn">
{{ Form::submit('update', ['class' => 'btn btn-info btn-sm', 'id' => 'set_mother_button']) }}
{{ link_to_route('users.show', 'Batal', [$user->id], ['class' => 'btn btn-default btn-sm']) }}
</span>
</div>
{{ Form::close() }}
@endcan
@endif
@else
@if ($user->mother_id)
{{ $user->mother->profileLink() }}
@endif
<div class="pull-right">
{{ link_to_route('users.show', 'Set Ibu', [$user->id, 'action' => 'set_mother'], ['class' => 'btn btn-link btn-xs']) }}
</div>
@endif
@else
@if ($user->mother_id)
{{ $user->mother->profileLink() }}
@endif
@endcan
</td>
</tr>
<tr>
@ -52,12 +72,11 @@
@if (request('action') == 'set_parent')
{{ link_to_route('users.show', 'Batal', [$user->id], ['class' => 'btn btn-default btn-xs']) }}
@else
{{ link_to_route('users.show', 'Set Orang Tua', [$user->id, 'action' => 'set_parent'], ['class' => 'btn btn-success btn-xs']) }}
{{ link_to_route('users.show', 'Set Orang Tua', [$user->id, 'action' => 'set_parent'], ['class' => 'btn btn-link btn-xs']) }}
@endif
</div>
@endcan
@if ($user->parent)
{{ $user->parent->husband->name }} & {{ $user->parent->wife->name }}
@endif
@ -81,7 +100,7 @@
@if (request('action') == 'add_spouse')
{{ link_to_route('users.show', 'Batal', [$user->id], ['class' => 'btn btn-default btn-xs']) }}
@else
{{ link_to_route('users.show', 'Tambah Isteri', [$user->id, 'action' => 'add_spouse'], ['class' => 'btn btn-success btn-xs']) }}
{{ link_to_route('users.show', 'Tambah Isteri', [$user->id, 'action' => 'add_spouse'], ['class' => 'btn btn-link btn-xs']) }}
@endif
</div>
@endcan

12
tests/Feature/ManageUserFamiliesTest.php

@ -16,6 +16,9 @@ class ManageUserFamiliesTest extends TestCase
$user = $this->loginAsUser();
$this->visit(route('profile'));
$this->seePageIs(route('profile'));
$this->dontSeeElement('input', ['name' => 'set_father']);
$this->click('Set Ayah');
$this->seePageIs(route('users.show', [$user->id, 'action' => 'set_father']));
$this->seeElement('input', ['name' => 'set_father']);
$this->submitForm('set_father_button', [
@ -35,6 +38,9 @@ class ManageUserFamiliesTest extends TestCase
$user = $this->loginAsUser();
$this->visit(route('profile'));
$this->seePageIs(route('profile'));
$this->dontSeeElement('input', ['name' => 'set_mother']);
$this->click('Set Ibu');
$this->seePageIs(route('users.show', [$user->id, 'action' => 'set_mother']));
$this->seeElement('input', ['name' => 'set_mother']);
$this->submitForm('set_mother_button', [
@ -169,6 +175,9 @@ class ManageUserFamiliesTest extends TestCase
$this->visit(route('profile'));
$this->seePageIs(route('profile'));
$this->dontSeeElement('input', ['name' => 'set_father']);
$this->click('Set Ayah');
$this->seePageIs(route('users.show', [$user->id, 'action' => 'set_father']));
$this->seeElement('input', ['name' => 'set_father']);
$this->seeElement('select', ['name' => 'set_father_id']);
@ -188,6 +197,9 @@ class ManageUserFamiliesTest extends TestCase
$this->visit(route('profile'));
$this->seePageIs(route('profile'));
$this->dontSeeElement('input', ['name' => 'set_mother']);
$this->click('Set Ibu');
$this->seePageIs(route('users.show', [$user->id, 'action' => 'set_mother']));
$this->seeElement('input', ['name' => 'set_mother']);
$this->seeElement('select', ['name' => 'set_mother_id']);

Loading…
Cancel
Save