Browse Source

Add user spouse by click add button

pull/3/head
Nafies Luthfi 9 years ago
parent
commit
25e67f427a
  1. 28
      resources/views/users/partials/parent-spouse.blade.php
  2. 5
      tests/Feature/ManageUserFamiliesTest.php

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

@ -4,8 +4,8 @@
<table class="table">
<tbody>
<tr>
<th>Ayah</th>
<td>
<th class="col-sm-4">Ayah</th>
<td class="col-sm-8">
@if ($user->father_id)
{{ $user->father->profileLink() }}
@else
@ -43,13 +43,22 @@
<tr>
<th>Isteri</th>
<td>
<div class="pull-right">
@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']) }}
@endif
</div>
@if ($user->wifes->isEmpty() == false)
<ul class="list-unstyled">
@foreach($user->wifes as $wife)
<li>{{ $wife->profileLink() }}</li>
@endforeach
</ul>
@else
@endif
@if (request('action') == 'add_spouse')
<div>
{{ Form::open(['route' => ['family-actions.add-wife', $user->id]]) }}
{!! FormField::select('set_wife_id', $femalePersonList, ['label' => false]) !!}
<div class="input-group">
@ -59,6 +68,7 @@
</span>
</div>
{{ Form::close() }}
</div>
@endif
</td>
</tr>
@ -66,13 +76,22 @@
<tr>
<th>Suami</th>
<td>
<div class="pull-right">
@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 Suami', [$user->id, 'action' => 'add_spouse'], ['class' => 'btn btn-success btn-xs']) }}
@endif
</div>
@if ($user->husbands->isEmpty() == false)
<ul class="list-unstyled">
@foreach($user->husbands as $husband)
<li>{{ $husband->profileLink() }}</li>
@endforeach
</ul>
@else
@endif
@if (request('action') == 'add_spouse')
<div>
{{ Form::open(['route' => ['family-actions.add-husband', $user->id]]) }}
{!! FormField::select('set_husband_id', $malePersonList, ['label' => false]) !!}
<div class="input-group">
@ -82,6 +101,7 @@
</span>
</div>
{{ Form::close() }}
</div>
@endif
</td>
</tr>

5
tests/Feature/ManageUserFamiliesTest.php

@ -111,6 +111,7 @@ class ManageUserFamiliesTest extends TestCase
$user = $this->loginAsUser(['gender_id' => 1]);
$this->visit(route('profile'));
$this->seePageIs(route('profile'));
$this->click('Tambah Isteri');
$this->seeElement('input', ['name' => 'set_wife']);
$this->submitForm('set_wife_button', [
@ -136,9 +137,9 @@ class ManageUserFamiliesTest extends TestCase
$user = $this->loginAsUser(['gender_id' => 2]);
$this->visit(route('profile'));
$this->seePageIs(route('profile'));
$this->click('Tambah Suami');
$this->seeElement('input', ['name' => 'set_husband']);
$this->submitForm('set_husband_button', [
'set_husband' => 'Nama Suami',
]);
@ -202,6 +203,7 @@ class ManageUserFamiliesTest extends TestCase
$this->visit(route('profile'));
$this->seePageIs(route('profile'));
$this->click('Tambah Isteri');
$this->seeElement('input', ['name' => 'set_wife']);
$this->seeElement('select', ['name' => 'set_wife_id']);
@ -224,6 +226,7 @@ class ManageUserFamiliesTest extends TestCase
$this->visit(route('profile'));
$this->seePageIs(route('profile'));
$this->click('Tambah Suami');
$this->seeElement('input', ['name' => 'set_husband']);
$this->seeElement('select', ['name' => 'set_husband_id']);

Loading…
Cancel
Save