Skip to content

Commit

Permalink
Organisation Members: Visible menus to add users to orgs
Browse files Browse the repository at this point in the history
  • Loading branch information
ilestis committed Mar 25, 2019
1 parent 086c3ee commit 820b55f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
3 changes: 2 additions & 1 deletion app/Models/Character.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ public function detach()
public function menuItems($items = [])
{
$campaign = $this->campaign;
$canEdit = auth()->check() && auth()->user()->can('update', $this);

$count = $this->items()->acl()->count();
if ($campaign->enabled('items') && $count > 0) {
Expand All @@ -275,7 +276,7 @@ public function menuItems($items = [])
}

$count = $this->organisations()->acl()->organisationAcl()->has('organisation')->count();
if ($campaign->enabled('organisations') && $count > 0) {
if ($campaign->enabled('organisations') && ($count > 0 || $canEdit)) {
$items['organisations'] = [
'name' => 'characters.show.tabs.organisations',
'route' => 'characters.organisations',
Expand Down
18 changes: 11 additions & 7 deletions app/Models/Organisation.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,19 @@ public function detach()
public function menuItems($items = [])
{
$campaign = $this->campaign;

$items['organisations'] = [
'name' => 'organisations.show.tabs.organisations',
'route' => 'organisations.organisations',
'count' => $this->descendants()->acl()->count()
];
$canEdit = auth()->check() && auth()->user()->can('update', $this);

$count = $this->descendants()->acl()->count();
if ($count > 0) {
$items['organisations'] = [
'name' => 'organisations.show.tabs.organisations',
'route' => 'organisations.organisations',
'count' => $count,
];
}

$count = $this->members()->acl()->has('character')->count();
if ($campaign->enabled('characters') && $count > 0) {
if ($campaign->enabled('characters')) {
$items['members'] = [
'name' => 'organisations.show.tabs.members',
'route' => 'organisations.members',
Expand Down
1 change: 1 addition & 0 deletions app/Policies/CampaignPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public function leave(User $user, Campaign $campaign)
return $user->campaign->id == $campaign->id &&
// If we are not the owner, or that we are an owner but there are other owners
$campaign->user() && (!$this->isAdmin($user) || count($campaign->admins()) > 1) &&
// We also can't leave a campaign if we are not the real user
!Identity::isImpersonating();
}
}
1 change: 1 addition & 0 deletions resources/views/conversations/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,6 @@
</div>

@section('scripts')
@parent
<script src="{{ mix('js/conversation.js') }}" defer></script>
@endsection

0 comments on commit 820b55f

Please sign in to comment.