Skip to content

Commit

Permalink
fix: disable checkboxes within resources
Browse files Browse the repository at this point in the history
  • Loading branch information
daveroverts committed May 18, 2022
1 parent 1afb0c2 commit 6cc3cc8
Show file tree
Hide file tree
Showing 12 changed files with 186 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ protected function canDelete(Model $record): bool
return false;
}

protected function canDeleteAny(): bool
{
return false;
}

public static function form(Form $form): Form
{
return $form
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ protected function canDelete(Model $record): bool
return false;
}

protected function canDeleteAny(): bool
{
return false;
}

public static function form(Form $form): Form
{
return $form
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ class EventsRelationManager extends HasManyRelationManager

protected static ?string $recordTitleAttribute = 'name';

private static function setFirOptions(Collection $firs)
{
return $firs->mapWithKeys(fn (FlightInformationRegion $fir) => [$fir->id => $fir->identifierName]);
}

public static function form(Form $form): Form
{
return $form
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ protected function canDelete(Model $record): bool
return false;
}

protected function canDeleteAny(): bool
{
return false;
}

protected function canEdit(Model $record): bool
{
// TODO: Might add role stuff here
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ protected function canDelete(Model $record): bool
return false;
}

protected function canDeleteAny(): bool
{
return false;
}

public static function form(Form $form): Form
{
return $form
Expand Down
10 changes: 10 additions & 0 deletions app/Policies/AirportGroupPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,14 @@ public function forceDelete(User $user, AirportGroup $airportGroup)
RoleKey::NMT,
]);
}

public function deleteAny()
{
return false;
}

public function detachAny()
{
return false;
}
}
10 changes: 10 additions & 0 deletions app/Policies/AirportPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,14 @@ public function forceDelete(User $user, Airport $airport)
RoleKey::NMT,
]);
}

public function deleteAny()
{
return false;
}

public function detachAny()
{
return false;
}
}
126 changes: 126 additions & 0 deletions app/Policies/DiscordTagPolicy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<?php

namespace App\Policies;

use App\Models\User;
use App\Enums\RoleKey;
use App\Models\DiscordTag;
use Illuminate\Auth\Access\HandlesAuthorization;

class DiscordTagPolicy
{
use HandlesAuthorization;

/**
* Determine whether the user can view any models.
*
* @param \App\Models\User $user
* @return \Illuminate\Auth\Access\Response|bool
*/
public function viewAny(User $user)
{
return in_array($user->role->key, [
RoleKey::SYSTEM,
RoleKey::NMT,
]);
}

/**
* Determine whether the user can view the model.
*
* @param \App\Models\User $user
* @param \App\Models\DiscordTag $discordTag
* @return \Illuminate\Auth\Access\Response|bool
*/
public function view(User $user, DiscordTag $discordTag)
{
return in_array($user->role->key, [
RoleKey::SYSTEM,
RoleKey::NMT,
]);
}

/**
* Determine whether the user can create models.
*
* @param \App\Models\User $user
* @return \Illuminate\Auth\Access\Response|bool
*/
public function create(User $user)
{
return in_array($user->role->key, [
RoleKey::SYSTEM,
RoleKey::NMT,
]);
}

/**
* Determine whether the user can update the model.
*
* @param \App\Models\User $user
* @param \App\Models\DiscordTag $discordTag
* @return \Illuminate\Auth\Access\Response|bool
*/
public function update(User $user, DiscordTag $discordTag)
{
return in_array($user->role->key, [
RoleKey::SYSTEM,
RoleKey::NMT,
]);
}

/**
* Determine whether the user can delete the model.
*
* @param \App\Models\User $user
* @param \App\Models\DiscordTag $discordTag
* @return \Illuminate\Auth\Access\Response|bool
*/
public function delete(User $user, DiscordTag $discordTag)
{
return in_array($user->role->key, [
RoleKey::SYSTEM,
RoleKey::NMT,
]);
}

/**
* Determine whether the user can restore the model.
*
* @param \App\Models\User $user
* @param \App\Models\DiscordTag $discordTag
* @return \Illuminate\Auth\Access\Response|bool
*/
public function restore(User $user, DiscordTag $discordTag)
{
return in_array($user->role->key, [
RoleKey::SYSTEM,
RoleKey::NMT,
]);
}

/**
* Determine whether the user can permanently delete the model.
*
* @param \App\Models\User $user
* @param \App\Models\DiscordTag $discordTag
* @return \Illuminate\Auth\Access\Response|bool
*/
public function forceDelete(User $user, DiscordTag $discordTag)
{
return in_array($user->role->key, [
RoleKey::SYSTEM,
RoleKey::NMT,
]);
}

public function deleteAny()
{
return false;
}

public function detachAny()
{
return false;
}
}
10 changes: 10 additions & 0 deletions app/Policies/EventPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,14 @@ public function forceDelete(User $user, Event $event)
RoleKey::FLOW_MANAGER,
]);
}

public function deleteAny()
{
return false;
}

public function detachAny()
{
return false;
}
}
10 changes: 10 additions & 0 deletions app/Policies/FlightInformationRegionPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,14 @@ public function forceDelete(User $user, FlightInformationRegion $flightInformati
RoleKey::NMT,
]);
}

public function deleteAny()
{
return false;
}

public function detachAny()
{
return false;
}
}
10 changes: 10 additions & 0 deletions app/Policies/FlowMeasurePolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,14 @@ public function forceDelete(User $user, FlowMeasure $flowMeasure)
RoleKey::NMT,
]);
}

public function deleteAny()
{
return false;
}

public function detachAny()
{
return false;
}
}
10 changes: 10 additions & 0 deletions app/Policies/UserPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,14 @@ public function forceDelete(User $user, User $model)
{
return false;
}

public function deleteAny()
{
return false;
}

public function detachAny()
{
return false;
}
}

0 comments on commit 6cc3cc8

Please sign in to comment.