Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}),
]),
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Services/GridSnapperService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
47 changes: 29 additions & 18 deletions Modules/Core/Tests/Unit/ReportTemplateServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down Expand Up @@ -200,22 +203,28 @@ 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')
->setPosition($position)
->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]
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion resources/css/filament/company/invoiceplane.css
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

.fi-sidebar-item.fi-active {
@apply text-white;
@apply !bg-primary-700;
@apply bg-primary-700!;
@apply rounded-lg;
}

Expand Down