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

5
tests/Feature/ManageUserFamiliesTest.php

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

Loading…
Cancel
Save