diff --git a/resources/views/users/partials/parent-spouse.blade.php b/resources/views/users/partials/parent-spouse.blade.php
index 14230cc..f66d32b 100644
--- a/resources/views/users/partials/parent-spouse.blade.php
+++ b/resources/views/users/partials/parent-spouse.blade.php
@@ -6,41 +6,61 @@
| Ayah |
- @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']) !!}
{{ Form::text('set_father', null, ['class' => 'form-control input-sm', 'placeholder' => 'Input Nama Baru...']) }}
{{ 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']) }}
- @endcan
{{ Form::close() }}
- @endif
+ @else
+ @if ($user->father_id)
+ {{ $user->father->profileLink() }}
+ @endif
+
+ {{ link_to_route('users.show', 'Set Ayah', [$user->id, 'action' => 'set_father'], ['class' => 'btn btn-link btn-xs']) }}
+
+ @endif
+ @else
+ @if ($user->father_id)
+ {{ $user->father->profileLink() }}
+ @endif
+ @endcan
|
| Ibu |
- @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']) !!}
{{ Form::text('set_mother', null, ['class' => 'form-control input-sm', 'placeholder' => 'Input Nama Baru...']) }}
{{ 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']) }}
{{ Form::close() }}
- @endcan
- @endif
+ @else
+ @if ($user->mother_id)
+ {{ $user->mother->profileLink() }}
+ @endif
+
+ {{ link_to_route('users.show', 'Set Ibu', [$user->id, 'action' => 'set_mother'], ['class' => 'btn btn-link btn-xs']) }}
+
+ @endif
+ @else
+ @if ($user->mother_id)
+ {{ $user->mother->profileLink() }}
+ @endif
+ @endcan
|
@@ -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
@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
@endcan
diff --git a/tests/Feature/ManageUserFamiliesTest.php b/tests/Feature/ManageUserFamiliesTest.php
index 5c58d60..a68af5f 100644
--- a/tests/Feature/ManageUserFamiliesTest.php
+++ b/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']);