Skip to content

Commit 7a0b436

Browse files
committed
fix: max values fix
1 parent 80a8fb3 commit 7a0b436

4 files changed

Lines changed: 14 additions & 32 deletions

File tree

resources/lang/en/property.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
'code' => 'Optional alphanumeric code with underscores, automatically converted to lowercase',
3535
'internal_name' => 'Internal name for distinction, not translatable',
3636
'is_global' => 'Auto-assigned to all product types',
37-
'max_values' => 'Controls form field type: single = radio/select, multiple = checkbox/multiselect',
37+
'max_values' => 'Maximum number of values allowed for this property (1 = single value, 2+ = multiple values)',
3838
'enable_sorting' => 'Allow drag-and-drop sorting of property values',
3939
'is_filter' => 'Display property as filter in product table',
4040
'product_types' => 'Select product types for this property (ignored if Global is enabled)',
@@ -66,19 +66,7 @@
6666
],
6767
],
6868

69-
'options' => [
70-
'max_values' => [
71-
1 => 'Single value (1)',
72-
2 => 'Multiple values (2+)',
73-
],
74-
],
7569

76-
'format' => [
77-
'max_values' => [
78-
'single' => 'Single',
79-
'multiple' => 'Multiple',
80-
],
81-
],
8270

8371
'messages' => [
8472
'created' => 'Property created successfully.',

resources/lang/sl/property.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
'code' => 'Neobvezna alfanumerična koda s podčrtaji, avtomatsko pretvorjena v male črke',
3535
'internal_name' => 'Interno ime za razlikovanje, ni prevedeno',
3636
'is_global' => 'Avtomatsko dodeljeno vsem tipom proizvodov',
37-
'max_values' => 'Nadzoruje tip polja obrazca: ena = radio/select, več = checkbox/multiselect',
37+
'max_values' => 'Največje število vrednosti, ki so dovoljene za to lastnost (1 = ena vrednost, 2+ = več vrednosti)',
3838
'enable_sorting' => 'Dovoli razvrščanje vrednosti lastnosti z vlečenjem',
3939
'is_filter' => 'Prikaži lastnost kot filter v tabeli proizvodov',
4040
'product_types' => 'Izberi tipe proizvodov za to lastnost (ignorirano, če je Global omogočeno)',
@@ -66,19 +66,7 @@
6666
],
6767
],
6868

69-
'options' => [
70-
'max_values' => [
71-
1 => 'Ena vrednost (1)',
72-
2 => 'Več vrednosti (2+)',
73-
],
74-
],
7569

76-
'format' => [
77-
'max_values' => [
78-
'single' => 'Ena',
79-
'multiple' => 'Več',
80-
],
81-
],
8270

8371
'messages' => [
8472
'created' => 'Lastnost je bila uspešno ustvarjena.',

src/Filament/Resources/PropertyResource.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,11 @@ public static function form(Form $form): Form
6262
->helperText(__('eclipse-catalogue::property.help_text.is_global'))
6363
->reactive(),
6464

65-
Forms\Components\Select::make('max_values')
65+
Forms\Components\TextInput::make('max_values')
6666
->label(__('eclipse-catalogue::property.fields.max_values'))
67-
->options([
68-
1 => __('eclipse-catalogue::property.options.max_values.1'),
69-
2 => __('eclipse-catalogue::property.options.max_values.2'),
70-
])
67+
->numeric()
68+
->minValue(1)
69+
->maxValue(10)
7170
->helperText(__('eclipse-catalogue::property.help_text.max_values')),
7271

7372
Forms\Components\Toggle::make('enable_sorting')
@@ -117,7 +116,7 @@ public static function table(Table $table): Table
117116

118117
Tables\Columns\TextColumn::make('max_values')
119118
->label(__('eclipse-catalogue::property.table.columns.max_values'))
120-
->formatStateUsing(fn ($state) => $state === 1 ? __('eclipse-catalogue::property.format.max_values.single') : __('eclipse-catalogue::property.format.max_values.multiple')),
119+
->numeric(),
121120

122121
Tables\Columns\IconColumn::make('enable_sorting')
123122
->label(__('eclipse-catalogue::property.table.columns.enable_sorting'))

src/Models/PropertyValue.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ protected static function newFactory(): PropertyValueFactory
5959
return PropertyValueFactory::new();
6060
}
6161

62+
protected static function booted(): void
63+
{
64+
static::addGlobalScope('orderBySort', function ($query) {
65+
$query->orderBy('sort');
66+
});
67+
}
68+
6269
/**
6370
* Ensure Filament receives scalar values for form hydration.
6471
*

0 commit comments

Comments
 (0)