Skip to content

Commit

Permalink
feat: Allow editing middle name (#3218)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivankruchkoff authored Mar 1, 2020
1 parent 2c9def6 commit 7d50381
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### New features:

* Add middle name field to new contact and edit contact
* Add backend and api for contact field labels
* Add audit log when setting a contact's description
* Add support for audit logs on a contact page
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ Bryan Kam @lydgate
Tom Granot-Scalosub @tomgs
Chris Forrence @chrisforrence
Mohammed Al-Sahaf @Mohammed90
Ivan Kruchkoff @ivankruchkoff <ivan@kruchkoff.com>
2 changes: 2 additions & 0 deletions app/Http/Controllers/ContactsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ public function store(Request $request)
'account_id' => auth()->user()->account->id,
'author_id' => auth()->user()->id,
'first_name' => $request->input('first_name'),
'middle_name' => $request->input('middle_name', null),
'last_name' => $request->input('last_name', null),
'nickname' => $request->input('nickname', null),
'gender_id' => $request->input('gender'),
Expand Down Expand Up @@ -394,6 +395,7 @@ public function update(Request $request, Contact $contact)
'account_id' => auth()->user()->account->id,
'contact_id' => $contact->id,
'first_name' => $request->input('firstname'),
'middle_name' => $request->input('middlename', null),
'last_name' => $request->input('lastname', null),
'nickname' => $request->input('nickname', null),
'gender_id' => $request->input('gender'),
Expand Down
18 changes: 18 additions & 0 deletions resources/views/people/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@
</form-input>
</div>

<div class="mb3">
<form-input
:id="'middle_name'"
:input-type="'text'"
:required="false"
:title="'{{ trans('people.people_add_middlename') }}'">
</form-input>
</div>

<div class="mb3">
<form-input
:id="'last_name'"
Expand Down Expand Up @@ -79,6 +88,15 @@
</form-input>
</div>

<div class="mb3">
<form-input
:id="'middle_name'"
:input-type="'text'"
:required="false"
:title="'{{ trans('people.people_add_middlename') }}'">
</form-input>
</div>

<div class="mb3 mb0-ns">
<form-input
:id="'nickname'"
Expand Down
9 changes: 9 additions & 0 deletions resources/views/people/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@
:title="'{{ trans('people.people_add_firstname') }}'">
</form-input>
</div>
<div class="dtc-ns pr2-ns pb0-ns w-100 pb3">
<form-input
value="{{ $contact->middle_name }}"
:input-type="'text'"
:id="'middlename'"
:required="false"
:title="'{{ trans('people.people_add_middlename') }}'">
</form-input>
</div>
<div class="dtc-ns pr2-ns pb0-ns w-100 pb3">
<form-input
value="{{ $contact->last_name }}"
Expand Down
28 changes: 28 additions & 0 deletions tests/Feature/ContactTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Models\Contact\Tag;
use App\Models\Contact\Gift;
use App\Helpers\StringHelper;
use App\Models\Contact\Gender;
use App\Models\Contact\Contact;
use App\Models\Account\Activity;
use App\Models\Contact\Reminder;
Expand Down Expand Up @@ -633,6 +634,33 @@ public function test_edit_contact_put_deceased_with_reminder()
]);
}

public function test_it_create_a_contact()
{
$user = $this->signIn();

$gender = factory(Gender::class)->create([
'account_id' => $user->account_id,
]);

$data = [
'first_name' => 'John',
'last_name' => 'Doe',
'middle_name' => 'Mike',
'gender' => $gender->id,
];

$response = $this->post('/people', $data);

$response->assertStatus(302);

$this->assertDatabaseHas('contacts', [
'first_name' => 'John',
'last_name' => 'Doe',
'middle_name' => 'Mike',
'gender_id' => $gender->id,
]);
}

/** @test */
public function it_gets_the_value()
{
Expand Down

0 comments on commit 7d50381

Please sign in to comment.