Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
89bfd2b
composer update
djaiss Mar 4, 2018
2692ec5
wip
djaiss Mar 4, 2018
5aa5143
wip
djaiss Mar 4, 2018
c0a3215
wip
djaiss Mar 5, 2018
f2d6ac8
wip
djaiss Mar 14, 2018
e28d17b
wip
djaiss Mar 15, 2018
1d05bb2
wip
djaiss Mar 16, 2018
ea24eff
wip
djaiss Mar 16, 2018
8feb259
merge master
djaiss Mar 16, 2018
63b2c78
wip
djaiss Mar 17, 2018
a616fea
wip
djaiss Mar 18, 2018
e9658ef
wip
djaiss Mar 18, 2018
4a772a9
wip
djaiss Mar 19, 2018
3480bb3
wip
djaiss Mar 20, 2018
3cb1e73
wip
djaiss Mar 20, 2018
cc9b3fa
wip
djaiss Mar 21, 2018
a167d84
Merge branch 'replace-relationships' of github.com:monicahq/monica in…
djaiss Mar 22, 2018
e6d6a85
wip
djaiss Mar 22, 2018
1f03697
far from being over... depressing
djaiss Mar 22, 2018
7fb1f20
fix stupid mistake I made while freaking tired
djaiss Mar 22, 2018
4ade29d
wip
djaiss Mar 23, 2018
dd7622b
wip
djaiss Mar 23, 2018
99f8f3a
Add better design for displaying a relationship
djaiss Mar 24, 2018
4cf1c10
wip
djaiss Mar 25, 2018
15bc1dd
tests
djaiss Mar 25, 2018
91a6501
final test
djaiss Mar 25, 2018
941f5ee
api
djaiss Mar 26, 2018
1671a86
wip
djaiss Mar 26, 2018
f9d4595
merge master
djaiss Mar 26, 2018
55aae4b
styleci
djaiss Mar 26, 2018
a2edbeb
styleci
djaiss Mar 26, 2018
0b128cc
bump files
djaiss Mar 26, 2018
beb7ecc
tests
djaiss Mar 27, 2018
f855158
merge master
djaiss Mar 27, 2018
a405ea3
fix styleci
djaiss Mar 27, 2018
7f5b09b
wip api
djaiss Mar 28, 2018
eae3fb1
wip api
djaiss Mar 28, 2018
82da42a
wip
djaiss Mar 30, 2018
c558111
wip
djaiss Mar 30, 2018
5f8a665
wip
djaiss Mar 30, 2018
f5e899a
wip
djaiss Mar 30, 2018
2727011
wip
djaiss Mar 30, 2018
bf0dd02
fix tests
djaiss Mar 30, 2018
91ec824
styleci
djaiss Mar 30, 2018
1c63734
merge master
djaiss Mar 31, 2018
1ad5764
fix bug
djaiss Mar 31, 2018
d7ffd47
fix test
djaiss Mar 31, 2018
b9ee161
remove useless test
djaiss Apr 1, 2018
df2e51a
Merge branch 'master' into replace-relationships
djaiss Apr 1, 2018
d0d5441
optimization
djaiss Apr 1, 2018
66b1965
Merge branch 'master' into replace-relationships
djaiss Apr 1, 2018
e7a7087
fix stuff
djaiss Apr 1, 2018
35020f1
Merge branch 'replace-relationships' of github.com:monicahq/monica in…
djaiss Apr 1, 2018
afaae90
fix dashboard
djaiss Apr 2, 2018
4e49981
merge mastr
djaiss Apr 2, 2018
916107c
styleci
djaiss Apr 2, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
wip
  • Loading branch information
djaiss committed Mar 23, 2018
commit dd7622bda56b9a66c60461cb3c553fad5241dcdf
10 changes: 8 additions & 2 deletions app/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -1103,10 +1103,13 @@ public function setRelationship(self $otherContact, $relationshipTypeId)
$relationship->contact_id_secondary = $otherContact->id;
$relationship->save();

// Get the reverse relationship
$reverseRelationshipType = $this->account->getRelationshipTypeByType($relationshipType->name_reverse_relationship);

// Contact B is linked to Contact A
$relationship = new Relationship;
$relationship->account_id = $this->account_id;
$relationship->relationship_type_id = $relationshipType->id;
$relationship->relationship_type_id = $reverseRelationshipType->id;
$relationship->contact_id_main = $otherContact->id;
$relationship->relationship_type_name = $relationshipType->name_reverse_relationship;
$relationship->contact_id_secondary = $this->id;
Expand Down Expand Up @@ -1143,9 +1146,12 @@ public function deleteRelationship(self $otherContact, $relationshipTypeId)

$relationship->delete();

$relationshipType = RelationshipType::find($relationshipTypeId);
$reverseRelationshipType = $this->account->getRelationshipTypeByType($relationshipType->name_reverse_relationship);

$relationship = Relationship::where('contact_id_main', $otherContact->id)
->where('contact_id_secondary', $this->id)
->where('relationship_type_id', $relationshipTypeId)
->where('relationship_type_id', $reverseRelationshipType->id)
->first();

$relationship->delete();
Expand Down
18 changes: 18 additions & 0 deletions app/Http/Controllers/ContactsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,26 @@ public function show(Contact $contact)
return $item->relationshipType->relationshipTypeGroup->name == 'love';
});

// get family relationship type
$familyRelationships = $relationships->filter(function ($item) {
return $item->relationshipType->relationshipTypeGroup->name == 'family';
});

// get friend relationship type
$friendRelationships = $relationships->filter(function ($item) {
return $item->relationshipType->relationshipTypeGroup->name == 'friend';
});

// get work relationship type
$workRelationships = $relationships->filter(function ($item) {
return $item->relationshipType->relationshipTypeGroup->name == 'work';
});

return view('people.profile')
->withLoveRelationships($loveRelationships)
->withFamilyRelationships($familyRelationships)
->withFriendRelationships($friendRelationships)
->withWorkRelationships($workRelationships)
->withContact($contact);
}

Expand Down
10 changes: 9 additions & 1 deletion app/RelationshipType.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function relationshipTypeGroup()
*
* @return string
*/
public function getLocalizedName(Contact $contact = null, bool $includeReverse = false)
public function getLocalizedName(Contact $contact = null, bool $includeReverse = false, string $gender = 'man')
{
// include the reverse of the relation in the string (masculine/feminine)
if (! is_null($contact) && $includeReverse) {
Expand All @@ -72,10 +72,18 @@ public function getLocalizedName(Contact $contact = null, bool $includeReverse =

// `Regis Freyd's uncle`
if (! is_null($contact)) {
if (strtolower($gender) == 'woman') {
return trans('app.relationship_type_'.$this->name.'_female_with_name', ["name" => $contact->getCompleteName()]);
}

return trans('app.relationship_type_'.$this->name.'_with_name', ["name" => $contact->getCompleteName()]);
}

// `uncle`
if (strtolower($gender) == 'woman') {
return trans('app.relationship_type_'.$this->name.'_female');
}

return trans('app.relationship_type_'.$this->name);
}

Expand Down
6 changes: 6 additions & 0 deletions resources/lang/en/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@
// and then, the feminine version of the string. Finally, in some sentences
// in the UI, we need to include the name of the person we add the relationship
// to.
'relationship_type_group_love' => 'Love relationships',
'relationship_type_group_family' => 'Family relationships',
'relationship_type_group_friend' => 'Friend relationships',
'relationship_type_group_work' => 'Work relationships',
'relationship_type_group_other' => 'Other kind of relationships',

'relationship_type_partner' => 'significant other',
'relationship_type_partner_female' => 'significant other',
'relationship_type_partner_reverse' => 'significant other',
Expand Down
2 changes: 1 addition & 1 deletion resources/views/people/profile.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<div class="col-xs-12 col-sm-3 profile-sidebar">

{{-- Significant Other --}}
@include('people.relationship.love')
@include('people.relationship.index')

@include('people.dashboard.index')

Expand Down
38 changes: 38 additions & 0 deletions resources/views/people/relationship/_relationship.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
@foreach ($relationships as $relationship)
<div>
<span class="silver fw3">[{{ $relationship->relationshipType->getLocalizedName(null, false, $relationship->withContact->gender->name) }}]</span>

{{-- NAME --}}
@if ($relationship->withContact->is_partial)
<span>{{ $relationship->withContact->getCompleteName(auth()->user()->name_order) }}</span>
@else
<a href="{{ route('people.show', $relationship->withContact) }}">{{ $relationship->withContact->getCompleteName(auth()->user()->name_order) }}</a>
@endif

{{-- AGE --}}
@if ($relationship->withContact->birthday_special_date_id)
@if ($relationship->withContact->birthdate->getAge())
({{ $relationship->withContact->birthdate->getAge() }})
@endif
@endif

{{-- ACTIONS: EDIT/DELETE --}}
@if ($relationship->withContact->is_partial)
<a href="{{ route('people.relationships.edit', [$contact, $relationship->withContact]) }}" class="action-link {{ $contact->id }}-edit-relationship">
{{ trans('app.edit') }}
</a>
<a href="#" onclick="if (confirm('{{ trans('people.relationship_delete_confirmation') }}')) { $(this).closest('.sidebar-box-paragraph').find('.entry-delete-form').submit(); } return false;" class="action-link">
{{ trans('app.delete') }}
</a>
@else
<a href="#" onclick="if (confirm('{{ trans('people.relationship_unlink_confirmation') }}')) { $(this).closest('.sidebar-box-paragraph').find('.entry-delete-form').submit(); } return false;" class="action-link">
{{ trans('app.delete') }}
</a>
@endif

<form method="POST" action="/people/{{ $contact->id }}/relationships/{{ $relationship->withContact->id }}" class="entry-delete-form hidden">
{{ method_field('DELETE') }}
{{ csrf_field() }}
</form>
</div>
@endforeach
43 changes: 43 additions & 0 deletions resources/views/people/relationship/index.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<div class="ba b--near-white br2 bg-gray-monica pa3 mb3 f6">
<div class="w-100 dt">
<div class="dtc">
<h3 class="f6 ttu normal">{{ trans('app.relationship_type_group_'.auth()->user()->account->getRelationshipTypeGroupByType('love')->name) }}</h3>
</div>
</div>

@include('people.relationship._relationship', ['relationships' => $loveRelationships])

<p class="mb0">
<a href="/people/{{ $contact->id }}/relationships/new?type={{ $contact->account->getRelationshipTypeByType('partner')->id }}">Add</a>
</p>
</div>

<div class="ba b--near-white br2 bg-gray-monica pa3 mb3 f6">
<div class="w-100 dt">
<div class="dtc">
<h3 class="f6 ttu normal">{{ trans('app.relationship_type_group_'.auth()->user()->account->getRelationshipTypeGroupByType('family')->name) }}</h3>
</div>
</div>

@include('people.relationship._relationship', ['relationships' => $familyRelationships])

<p class="mb0">
<a href="/people/{{ $contact->id }}/relationships/new?type={{ $contact->account->getRelationshipTypeByType('child')->id }}">Add</a>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Add" should be localized

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done

</p>
</div>

<div class="ba b--near-white br2 bg-gray-monica pa3 mb3 f6">
<div class="w-100 dt">
<div class="dtc">
<h3 class="f6 ttu normal">{{ trans('app.relationship_type_group_other') }}</h3>
</div>
</div>

@include('people.relationship._relationship', ['relationships' => $friendRelationships])

@include('people.relationship._relationship', ['relationships' => $workRelationships])

<p class="mb0">
<a href="/people/{{ $contact->id }}/relationships/new?type={{ $contact->account->getRelationshipTypeByType('friend')->id }}">Add</a>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Add" should be localized

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done

</p>
</div>
58 changes: 0 additions & 58 deletions resources/views/people/relationship/love.blade.php

This file was deleted.