mirror of
https://github.com/sp-tarkov/forge.git
synced 2025-02-13 04:30:41 -05:00
60 lines
1.2 KiB
PHP
60 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Mod;
|
|
|
|
use App\Models\ModeratedModel;
|
|
use Livewire\Attributes\On;
|
|
use Livewire\Component;
|
|
|
|
class ModerationActionButton extends Component
|
|
{
|
|
public ModeratedModel $moderatedObject;
|
|
|
|
public string $guid = '';
|
|
|
|
public string $actionType;
|
|
|
|
public bool $allowActions = false;
|
|
|
|
public bool $isRunning = false;
|
|
|
|
protected $listeners = ['refreshComponent' => '$refresh'];
|
|
|
|
public function mount(): void
|
|
{
|
|
$this->guid = uniqid('', true);
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
$this->allowActions = ! $this->isRunning;
|
|
|
|
return view('livewire.mod.moderation-action-button');
|
|
}
|
|
|
|
public function runActionEvent(): void
|
|
{
|
|
$this->isRunning = true;
|
|
$this->dispatch("startAction.{$this->guid}");
|
|
}
|
|
|
|
#[On('startAction.{guid}')]
|
|
public function invokeAction(): void
|
|
{
|
|
switch ($this->actionType) {
|
|
case 'delete':
|
|
|
|
$this->moderatedObject->delete();
|
|
break;
|
|
|
|
case 'enable':
|
|
case 'disable':
|
|
|
|
$this->moderatedObject->toggleDisabled();
|
|
break;
|
|
}
|
|
|
|
$this->js('window.location.reload()');
|
|
}
|
|
}
|