ranjith-dev #1513

Merged
jothi merged 4 commits from ranjith-dev into master 2026-11-25 06:19:30 +00:00
4 changed files with 120 additions and 0 deletions

View File

@@ -0,0 +1,75 @@
<?php
namespace App\Filament\Pages;
use App\Models\SharedClipBoard;
use Filament\Pages\Page;
use Illuminate\Support\Facades\Auth;
class SharedEditor extends Page
{
protected static ?string $navigationIcon = 'heroicon-s-clipboard-document';
protected static string $view = 'filament.pages.shared-editor';
protected static ?string $navigationLabel = 'Shared Clipboard';
protected static ?string $title = 'Shared Clipboard';
public string $content = '';
public string $lastSyncedContent = '';
public function mount(): void
{
$clipboard = SharedClipBoard::firstOrCreate(
['id' => 1],
['content' => '']
);
$this->content = $clipboard->content ?? '';
$this->lastSyncedContent = $this->content;
}
public function updatedContent(): void
{
SharedClipBoard::where('id', 1)->update([
'content' => $this->content,
]);
$this->lastSyncedContent = $this->content;
}
public function refreshSharedContent(): void
{
$sharedContent = SharedClipBoard::find(1)?->content ?? '';
// Do not overwrite text that this user is editing.
if (
$this->content === $this->lastSyncedContent
&& $sharedContent !== $this->lastSyncedContent
) {
$this->content = $sharedContent;
$this->lastSyncedContent = $sharedContent;
}
}
public function clearContent(): void
{
SharedClipBoard::where('id', 1)->update([
'content' => '',
]);
$this->content = '';
$this->lastSyncedContent = '';
}
public static function canAccess(): bool
{
return Auth::check() && Auth::user()->can('view shared clipboard page');
}
}

View File

@@ -0,0 +1,15 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class SharedClipBoard extends Model
{
protected $fillable = [
'content',
'created_at',
'updated_at',
];
}

View File

@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('shared_clip_boards', function (Blueprint $table) {
$table->id();
$table->longText('content')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('shared_clip_boards');
}
};

View File

@@ -292,5 +292,7 @@ class PermissionSeeder extends Seeder
Permission::updateOrCreate(['name' => 'view test certificate page']);
Permission::updateOrCreate(['name' => 'view process order rejection dashboard']);
Permission::updateOrCreate(['name' => 'view shared clipboard page']);
}
}