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 @@ -110,6 +110,14 @@ protected static function getHandleFormComponent(): Component
{
return TextInput::make('handle')
->label(__('lunarpanel::attributegroup.form.handle.label'))
->live(onBlur: true)
->afterStateUpdated(function (string $operation, $state, Set $set) {
if ($operation !== 'create') {
return;
}

$set('handle', Str::snake(Str::lower($state)));
})
->required()
->maxLength(255);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ public function getDefaultForm(Schema $schema): Schema
->label(
__('lunarpanel::attribute.form.handle.label')
)->dehydrated()
->live(onBlur: true)
->afterStateUpdated(function (string $operation, $state, Set $set) {
if ($operation !== 'create') {
return;
}

$set('handle', Str::snake(Str::lower($state)));
})
->unique(ignoreRecord: true, modifyRuleUsing: function (Unique $rule, RelationManager $livewire) {
return $rule->where('attribute_group_id', $livewire->ownerRecord->id);
})->disabled(
Expand Down
8 changes: 8 additions & 0 deletions packages/admin/src/Filament/Resources/ChannelResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ protected static function getHandleFormComponent(): Component
->label(__('lunarpanel::channel.form.handle.label'))
->required()
->unique(ignoreRecord: true)
->live(onBlur: true)
->afterStateUpdated(function (string $operation, $state, Set $set) {
if ($operation !== 'create') {
return;
}

$set('handle', Str::snake(Str::lower($state)));
})
->minLength(3)
->maxLength(255);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ protected static function getHandleFormComponent(): Component
->label(__('lunarpanel::collectiongroup.form.handle.label'))
->unique(ignoreRecord: true)
->required()
->live(onBlur: true)
->afterStateUpdated(function (string $operation, $state, Set $set) {
if ($operation !== 'create') {
return;
}

$set('handle', Str::snake(Str::lower($state)));
})
->maxLength(255);
}

Expand Down
10 changes: 10 additions & 0 deletions packages/admin/src/Filament/Resources/CustomerGroupResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Schemas\Components\Component;
use Filament\Schemas\Components\Utilities\Set;
use Filament\Support\Facades\FilamentIcon;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
use Lunar\Admin\Filament\Resources\CustomerGroupResource\Pages\CreateCustomerGroup;
use Lunar\Admin\Filament\Resources\CustomerGroupResource\Pages\EditCustomerGroup;
use Lunar\Admin\Filament\Resources\CustomerGroupResource\Pages\ListCustomerGroups;
Expand Down Expand Up @@ -74,6 +76,14 @@ protected static function getHandleFormComponent(): Component
->label(__('lunarpanel::customergroup.form.handle.label'))
->required()
->unique(ignoreRecord: true)
->live(onBlur: true)
->afterStateUpdated(function (string $operation, $state, Set $set) {
if ($operation !== 'create') {
return;
}

$set('handle', Str::snake(Str::lower($state)));
})
->minLength(3)
->maxLength(255);
}
Expand Down
8 changes: 8 additions & 0 deletions packages/admin/src/Filament/Resources/DiscountResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,14 @@ public static function getHandleFormComponent(): Component
->label(__('lunarpanel::discount.form.handle.label'))
->required()
->unique(ignoreRecord: true)
->live(onBlur: true)
->afterStateUpdated(function (string $operation, $state, Set $set) {
if ($operation !== 'create') {
return;
}

$set('handle', Str::snake(Str::lower($state)));
})
->maxLength(255)
->autofocus();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ protected static function getHandleFormComponent(): Component
->label(__('lunarpanel::productoption.form.handle.label'))
->required()
->maxLength(255)
->live(onBlur: true)
->afterStateUpdated(function (string $operation, $state, Set $set) {
if ($operation !== 'create') {
return;
}

$set('handle', Str::snake(Str::lower($state)));
})
->disabled(fn ($operation, $record) => $operation == 'edit' && (! $record->shared));
}

Expand Down
Loading