Skip to content

Commit 22a105e

Browse files
committed
revert
1 parent 3830bd8 commit 22a105e

File tree

1 file changed

+8
-19
lines changed

1 file changed

+8
-19
lines changed

app/Filament/Pages/LabelsGenerator.php

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -76,24 +76,12 @@ public function form(Form $form): Form
7676
->label('Label Height (inches)')
7777
->numeric()
7878
->required()
79-
->default($this->cardHeight)
80-
->rules(['required', 'numeric', 'min:0.1', function($attribute, $value, $fail) {
81-
$availableHeight = $this->pageHeight - $this->pageTopPadding - $this->pageBottomPadding;
82-
if ($value > $availableHeight) {
83-
$fail("The card height must not exceed the available page height.");
84-
}
85-
}]),
79+
->default($this->cardHeight),
8680
TextInput::make('cardWidth')
8781
->label('Label Width (inches)')
8882
->numeric()
8983
->required()
90-
->rules(['required', 'numeric', 'min:0.1', function($attribute, $value, $fail) {
91-
$availableWidth = $this->pageWidth - $this->pageLeftPadding - $this->pageRightPadding;
92-
if ($value > $availableWidth) {
93-
$fail("The card width must not exceed the available page width.");
94-
}
95-
}])
96-
->default($this->cardWidth),
84+
->default($this->cardWidth),
9785
TextInput::make('pageWidth')
9886
->label('Page Width (inches)')
9987
->numeric()
@@ -136,7 +124,7 @@ public function form(Form $form): Form
136124
])->columns(2);
137125
}
138126

139-
public function generatePages($showNotification = true): void
127+
public function generatePages($showNotification = true)
140128
{
141129
$this->validate();
142130
$this->init();
@@ -193,10 +181,11 @@ private function calculateGridData()
193181
];
194182
}
195183

196-
$cols = max(1, floor($availablePageWidth / $this->cardWidth));
197-
$rows = max(1, floor($availablePageHeight / $this->cardHeight));
198-
$gapX = $cols > 1 ? ($availablePageWidth - $cols * $this->cardWidth) / ($cols - 1) : 0;
199-
$gapY = $rows > 1 ? ($availablePageHeight - $rows * $this->cardHeight) / ($rows - 1) : 0;
184+
$cols = floor($availablePageWidth / $this->cardWidth);
185+
$rows = floor($availablePageHeight / $this->cardHeight);
186+
$gapX = ($availablePageWidth - $cols * $this->cardWidth) / ($cols - 1);
187+
$gapY = ($this->pageHeight - $rows * $this->cardHeight) / ($rows - 1);
188+
200189
return [
201190
'cols' => $cols,
202191
'rows' => $rows,

0 commit comments

Comments
 (0)