Skip to content

Commit f9703cb

Browse files
Make column size facultative + other improvments
1 parent 4cc7826 commit f9703cb

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

src/Console/ConfigureCmsCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,12 @@ private function updateCmsConfigurationFor($model, int $order = 1, bool $isSubCo
137137
'belongsToFilter' => $list->belongsToFilter()?->toArray(),
138138
'columns' => $list
139139
->columns()
140-
->map(fn (OzuColumn $column) => [
140+
->mapWithKeys(fn (OzuColumn $column) => [$column->key() => [
141141
'type' => $column->type(),
142142
'key' => $column->key(),
143143
'label' => $column->label(),
144144
'size' => $column->size(),
145-
]),
145+
]]),
146146
],
147147
'form' => [
148148
'title' => $form->titleField()?->toArray(),

src/OzuCms/Form/OzuEditorField.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function setCropRatio(string $cropRatio): self
8383
public function setAllowedExtensions(array $extensions): self
8484
{
8585
if (!in_array(OzuEditorToolbarButton::File, $this->toolbar)) {
86-
throw new OzuClientException('You should allow uploads by adding OzuEditorToolbarButton::File in toolbar configuration before setting the allowed extensions for uploads');
86+
throw new OzuClientException('You should allow uploads by adding OzuEditorToolbarButton::File or OzuEditorToolbarButton::Image in toolbar configuration before setting the allowed extensions for uploads');
8787
}
8888

8989
// formatting extensions to be compatible with the editor
@@ -101,6 +101,10 @@ public function type(): string
101101

102102
public function toArray(): array
103103
{
104+
if (in_array(OzuEditorToolbarButton::File, $this->toolbar) && empty($this->allowedExtensions)) {
105+
throw new OzuClientException('You have to set allowed extensions (via ->setAllowedExtensions()’s method) when using the OzuEditorToolbarButton::File in your toolbar');
106+
}
107+
104108
return array_merge(parent::toArray(), [
105109
'withoutParagraphs' => $this->withoutParagraphs,
106110
'hideToolbar' => $this->hideToolbar,

src/OzuCms/List/OzuColumn.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,29 @@ abstract class OzuColumn
1010

1111
protected string $sortDirection = 'asc';
1212

13-
protected function __construct(protected string $key, protected int $size)
13+
/**
14+
* @param ?int $size Accepts no size (will auto-fit), 12-based column size (1-12) or a percentage (e.g. 25)
15+
*/
16+
protected function __construct(protected string $key, protected ?int $size = null)
1417
{
1518
}
1619

17-
public static function makeText(string $key, int $size): OzuTextColumn
20+
public static function makeText(string $key, ?int $size = null): OzuTextColumn
1821
{
1922
return new OzuTextColumn($key, $size);
2023
}
2124

22-
public static function makeDate(string $key, int $size): OzuDateColumn
25+
public static function makeDate(string $key, ?int $size = null): OzuDateColumn
2326
{
2427
return new OzuDateColumn($key, $size);
2528
}
2629

27-
public static function makeImage(string $key, int $size): OzuThumbnailColumn
30+
public static function makeImage(string $key, ?int $size = null): OzuThumbnailColumn
2831
{
2932
return new OzuThumbnailColumn($key, $size);
3033
}
3134

32-
public static function makeCheck(string $key, int $size): OzuCheckColumn
35+
public static function makeCheck(string $key, ?int $size = null): OzuCheckColumn
3336
{
3437
return new OzuCheckColumn($key, $size);
3538
}
@@ -39,7 +42,7 @@ public function key(): string
3942
return $this->key;
4043
}
4144

42-
public function size(): int
45+
public function size(): ?int
4346
{
4447
return $this->size;
4548
}

0 commit comments

Comments
 (0)