diff --git a/Modules/Core/Filament/Admin/Resources/ReportBlocks/Tables/ReportBlocksTable.php b/Modules/Core/Filament/Admin/Resources/ReportBlocks/Tables/ReportBlocksTable.php index 8d4fb1ec..2ef400cc 100644 --- a/Modules/Core/Filament/Admin/Resources/ReportBlocks/Tables/ReportBlocksTable.php +++ b/Modules/Core/Filament/Admin/Resources/ReportBlocks/Tables/ReportBlocksTable.php @@ -2,9 +2,9 @@ namespace Modules\Core\Filament\Admin\Resources\ReportBlocks\Tables; -use Filament\Actions\ActionGroup; -use Filament\Actions\DeleteAction; -use Filament\Actions\EditAction; +use Filament\Tables\Actions\ActionGroup; +use Filament\Tables\Actions\DeleteAction; +use Filament\Tables\Actions\EditAction; use Filament\Tables\Columns\IconColumn; use Filament\Tables\Columns\TextColumn; use Filament\Tables\Table; @@ -40,7 +40,7 @@ public static function configure(Table $table): Table ActionGroup::make([ EditAction::make(), DeleteAction::make('delete') - ->action(function (ReportBlock $record, array $data) { + ->action(function (ReportBlock $record) { app(ReportBlockService::class)->deleteReportBlock($record); }), ]), diff --git a/Modules/Core/Services/GridSnapperService.php b/Modules/Core/Services/GridSnapperService.php index 694715be..8012fb12 100644 --- a/Modules/Core/Services/GridSnapperService.php +++ b/Modules/Core/Services/GridSnapperService.php @@ -26,7 +26,7 @@ public function snap(GridPositionDTO $position): GridPositionDTO { $x = max(0, min($position->getX(), $this->gridSize - 1)); $y = max(0, $position->getY()); - $width = max(1, min($position->getWidth(), $this->gridSize - $position->getX())); + $width = max(1, min($position->getWidth(), $this->gridSize - $x)); $height = max(1, $position->getHeight()); return GridPositionDTO::create($x, $y, $width, $height); diff --git a/Modules/Core/Tests/Unit/ReportTemplateServiceTest.php b/Modules/Core/Tests/Unit/ReportTemplateServiceTest.php index b7a44acf..f07a0cc1 100644 --- a/Modules/Core/Tests/Unit/ReportTemplateServiceTest.php +++ b/Modules/Core/Tests/Unit/ReportTemplateServiceTest.php @@ -2,6 +2,7 @@ namespace Modules\Core\Tests\Unit; +use Illuminate\Support\Facades\Storage; use InvalidArgumentException; use Modules\Core\DTOs\BlockDTO; use Modules\Core\DTOs\GridPositionDTO; @@ -26,7 +27,9 @@ protected function setUp(): void { parent::setUp(); - $this->fileRepository = $this->createMock(ReportTemplateFileRepository::class); + Storage::fake('report_templates'); + + $this->fileRepository = new ReportTemplateFileRepository(); $this->gridSnapper = new GridSnapperService(12); $this->service = new ReportTemplateService($this->fileRepository, $this->gridSnapper); } @@ -200,11 +203,8 @@ public function it_persists_blocks(): void $template->slug = 'test-template'; $position = new GridPositionDTO(); - - /* act */ $position->setX(0)->setY(0)->setWidth(6)->setHeight(4); - /* assert */ $block = new BlockDTO(); $block->setId('block_1') ->setType('company_header') @@ -212,10 +212,19 @@ public function it_persists_blocks(): void ->setConfig([]) ->setIsCloneable(true) ->setIsCloned(false); - $this->fileRepository->expects($this->once()) - ->method('save') - ->with(1, 'test-template', $this->isType('array')); + + /* act */ $this->service->persistBlocks($template, [$block]); + + /* assert */ + Storage::disk('report_templates')->assertExists('1/test-template.json'); + $content = Storage::disk('report_templates')->get('1/test-template.json'); + $data = json_decode($content, true); + + $this->assertIsArray($data); + $this->assertCount(1, $data); + $this->assertEquals('block_1', $data[0]['id']); + $this->assertEquals('company_header', $data[0]['type']); } #[Test] @@ -227,17 +236,19 @@ public function it_loads_blocks(): void $template->company_id = 1; $template->slug = 'test-template'; - $this->fileRepository->expects($this->once()) - ->method('load') - ->with(1, 'test-template') - ->willReturn([ - [ - 'id' => 'block_1', - 'type' => 'company_header', - 'position' => ['x' => 0, 'y' => 0, 'width' => 6, 'height' => 4], - 'config' => [], - ], - ]); + $fileData = [ + [ + 'id' => 'block_1', + 'type' => 'company_header', + 'position' => ['x' => 0, 'y' => 0, 'width' => 6, 'height' => 4], + 'config' => [], + ], + ]; + + Storage::disk('report_templates')->put( + '1/test-template.json', + json_encode($fileData, JSON_PRETTY_PRINT) + ); /* act */ $blocks = $this->service->loadBlocks($template); diff --git a/resources/css/filament/company/invoiceplane.css b/resources/css/filament/company/invoiceplane.css index 96b82d17..cd97219e 100644 --- a/resources/css/filament/company/invoiceplane.css +++ b/resources/css/filament/company/invoiceplane.css @@ -58,7 +58,7 @@ .fi-sidebar-item.fi-active { @apply text-white; - @apply !bg-primary-700; + @apply bg-primary-700!; @apply rounded-lg; }