Skip to content

Commit

Permalink
Merge branch 'feature/locale' of https://github.com/mooxphp/moox into…
Browse files Browse the repository at this point in the history
… feature/locale
  • Loading branch information
Kim-the-Diamond committed Dec 20, 2024
2 parents 296b461 + 7937e7a commit 79d3431
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 71 deletions.
11 changes: 3 additions & 8 deletions app/Locale/Presets/CountryPreset.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,12 @@

namespace App\Locale\Presets;

use Moox\Builder\Blocks\Features\SimpleType;
use Moox\Builder\Blocks\Fields\KeyValue;
use Moox\Builder\Blocks\Fields\Number;
use Moox\Builder\Blocks\Fields\Text;
use Moox\Builder\Blocks\Features\Tabs;
use Moox\Builder\Blocks\Singles\Simple;
use Moox\Builder\Blocks\Fields\DateTime;
use Moox\Builder\Blocks\Fields\KeyValue;
use Moox\Builder\Blocks\Fields\TextArea;
use Moox\Builder\Presets\AbstractPreset;
use Moox\Builder\Blocks\Features\SimpleType;
use Moox\Builder\Blocks\Features\SimpleStatus;
use Moox\Builder\Blocks\Fields\Boolean;
use Moox\Builder\Blocks\Fields\Number;

class CountryPreset extends AbstractPreset
{
Expand Down
7 changes: 2 additions & 5 deletions app/Locale/Presets/LocalePreset.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@

namespace App\Locale\Presets;

use Moox\Builder\Blocks\Fields\Text;
use Moox\Builder\Blocks\Features\Tabs;
use Moox\Builder\Blocks\Fields\Relationship;
use Moox\Builder\Blocks\Fields\Text;
use Moox\Builder\Blocks\Singles\Simple;
use Moox\Builder\Blocks\Fields\TextArea;
use Moox\Builder\Presets\AbstractPreset;
use Moox\Builder\Blocks\Features\SimpleType;
use Moox\Builder\Blocks\Features\SimpleStatus;
use Moox\Builder\Blocks\Fields\Relationship;

class LocalePreset extends AbstractPreset
{
Expand Down
4 changes: 2 additions & 2 deletions app/Locale/Presets/StaticLanguagePreset.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

namespace App\Locale\Presets;

use Moox\Builder\Blocks\Features\SimpleType;
use Moox\Builder\Blocks\Fields\KeyValue;
use Moox\Builder\Blocks\Fields\Text;
use Moox\Builder\Blocks\Singles\Simple;
use Moox\Builder\Blocks\Fields\KeyValue;
use Moox\Builder\Presets\AbstractPreset;
use Moox\Builder\Blocks\Features\SimpleType;

class StaticLanguagePreset extends AbstractPreset
{
Expand Down
67 changes: 33 additions & 34 deletions app/Locale/Resources/StaticCountryResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Filament\Resources\Resource;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\Filter;
use Filament\Tables\Filters\NumberFilter;
use Filament\Tables\Filters\SelectFilter;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
Expand Down Expand Up @@ -189,15 +188,15 @@ public static function table(Table $table): Table
->query(function (Builder $query, array $data): Builder {
return $query->when(
$data['alpha2'],
fn(Builder $query, $value): Builder => $query->where('alpha2', 'like', "%{$value}%"),
fn (Builder $query, $value): Builder => $query->where('alpha2', 'like', "%{$value}%"),
);
})
->indicateUsing(function (array $data): ?string {
if (! $data['alpha2']) {
return null;
}

return 'Alpha-2 Code: ' . $data['alpha2'];
return 'Alpha-2 Code: '.$data['alpha2'];
}),
Filter::make('alpha3_b')
->form([
Expand All @@ -208,15 +207,15 @@ public static function table(Table $table): Table
->query(function (Builder $query, array $data): Builder {
return $query->when(
$data['alpha3_b'],
fn(Builder $query, $value): Builder => $query->where('alpha3_b', 'like', "%{$value}%"),
fn (Builder $query, $value): Builder => $query->where('alpha3_b', 'like', "%{$value}%"),
);
})
->indicateUsing(function (array $data): ?string {
if (! $data['alpha3_b']) {
return null;
}

return 'Alpha-3 Code (B): ' . $data['alpha3_b'];
return 'Alpha-3 Code (B): '.$data['alpha3_b'];
}),
Filter::make('alpha3_t')
->form([
Expand All @@ -227,15 +226,15 @@ public static function table(Table $table): Table
->query(function (Builder $query, array $data): Builder {
return $query->when(
$data['alpha3_t'],
fn(Builder $query, $value): Builder => $query->where('alpha3_t', 'like', "%{$value}%"),
fn (Builder $query, $value): Builder => $query->where('alpha3_t', 'like', "%{$value}%"),
);
})
->indicateUsing(function (array $data): ?string {
if (! $data['alpha3_t']) {
return null;
}

return 'Alpha-3 Code (T): ' . $data['alpha3_t'];
return 'Alpha-3 Code (T): '.$data['alpha3_t'];
}),
Filter::make('common_name')
->form([
Expand All @@ -246,15 +245,15 @@ public static function table(Table $table): Table
->query(function (Builder $query, array $data): Builder {
return $query->when(
$data['common_name'],
fn(Builder $query, $value): Builder => $query->where('common_name', 'like', "%{$value}%"),
fn (Builder $query, $value): Builder => $query->where('common_name', 'like', "%{$value}%"),
);
})
->indicateUsing(function (array $data): ?string {
if (! $data['common_name']) {
return null;
}

return 'Common Name: ' . $data['common_name'];
return 'Common Name: '.$data['common_name'];
}),
Filter::make('native_name')
->form([
Expand All @@ -265,25 +264,25 @@ public static function table(Table $table): Table
->query(function (Builder $query, array $data): Builder {
return $query->when(
$data['native_name'],
fn(Builder $query, $value): Builder => $query->where('native_name', 'like', "%{$value}%"),
fn (Builder $query, $value): Builder => $query->where('native_name', 'like', "%{$value}%"),
);
})
->indicateUsing(function (array $data): ?string {
if (! $data['native_name']) {
return null;
}

return 'Native Name: ' . $data['native_name'];
return 'Native Name: '.$data['native_name'];
}),
Filter::make('has_exonyms')
->query(fn($query) => $query->whereNotNull('exonyms')),
->query(fn ($query) => $query->whereNotNull('exonyms')),
SelectFilter::make('region')
->label('Region')
->placeholder(__('core::core.filter') . ' Region')
->placeholder(__('core::core.filter').' Region')
->options(['Africa' => 'Africa', 'Americas' => 'Americas', 'Asia' => 'Asia', 'Europe' => 'Europe', 'Oceania' => 'Oceania', 'Antarctica' => 'Antarctica']),
SelectFilter::make('subregion')
->label('Subregion')
->placeholder(__('core::core.filter') . ' Subregion')
->placeholder(__('core::core.filter').' Subregion')
->options(['Northern Africa' => 'Northern Africa', 'Sub-Saharan Africa' => 'Sub-Saharan Africa', 'Eastern Africa' => 'Eastern Africa', 'Middle Africa' => 'Middle Africa', 'Southern Africa' => 'Southern Africa', 'Western Africa' => 'Western Africa', 'Latin America and the Caribbean' => 'Latin America and the Caribbean', 'Northern America' => 'Northern America', 'Caribbean' => 'Caribbean', 'Central America' => 'Central America', 'South America' => 'South America', 'Central Asia' => 'Central Asia', 'Eastern Asia' => 'Eastern Asia', 'South-Eastern Asia' => 'South-Eastern Asia', 'Southern Asia' => 'Southern Asia', 'Western Asia' => 'Western Asia', 'Eastern Europe' => 'Eastern Europe', 'Northern Europe' => 'Northern Europe', 'Southern Europe' => 'Southern Europe', 'Western Europe' => 'Western Europe', 'Australia and New Zealand' => 'Australia and New Zealand', 'Melanesia' => 'Melanesia', 'Micronesia' => 'Micronesia', 'Polynesia' => 'Polynesia']),
Filter::make('capital')
->form([
Expand All @@ -294,15 +293,15 @@ public static function table(Table $table): Table
->query(function (Builder $query, array $data): Builder {
return $query->when(
$data['capital'],
fn(Builder $query, $value): Builder => $query->where('capital', 'like', "%{$value}%"),
fn (Builder $query, $value): Builder => $query->where('capital', 'like', "%{$value}%"),
);
})
->indicateUsing(function (array $data): ?string {
if (! $data['capital']) {
return null;
}

return 'Capital: ' . $data['capital'];
return 'Capital: '.$data['capital'];
}),
Filter::make('population')
->form([
Expand All @@ -313,15 +312,15 @@ public static function table(Table $table): Table
->query(function (Builder $query, array $data): Builder {
return $query->when(
$data['population'],
fn(Builder $query, $value): Builder => $query->where('population', 'like', "%{$value}%"),
fn (Builder $query, $value): Builder => $query->where('population', 'like', "%{$value}%"),
);
})
->indicateUsing(function (array $data): ?string {
if (! $data['population']) {
return null;
}

return 'Population: ' . $data['population'];
return 'Population: '.$data['population'];
}),
Filter::make('area')
->form([
Expand All @@ -332,30 +331,30 @@ public static function table(Table $table): Table
->query(function (Builder $query, array $data): Builder {
return $query->when(
$data['area'],
fn(Builder $query, $value): Builder => $query->where('area', 'like', "%{$value}%"),
fn (Builder $query, $value): Builder => $query->where('area', 'like', "%{$value}%"),
);
})
->indicateUsing(function (array $data): ?string {
if (! $data['area']) {
return null;
}

return 'Area: ' . $data['area'];
return 'Area: '.$data['area'];
}),
Filter::make('has_links')
->query(fn($query) => $query->whereNotNull('links')),
->query(fn ($query) => $query->whereNotNull('links')),
Filter::make('has_tlds')
->query(fn($query) => $query->whereNotNull('tlds')),
->query(fn ($query) => $query->whereNotNull('tlds')),
Filter::make('has_membership')
->query(fn($query) => $query->whereNotNull('membership')),
->query(fn ($query) => $query->whereNotNull('membership')),
SelectFilter::make('embargo')
->label('Embargo')
->placeholder(__('core::core.filter') . ' Embargo')
->placeholder(__('core::core.filter').' Embargo')
->options(['New' => 'New', 'Open' => 'Open', 'Pending' => 'Pending', 'Closed' => 'Closed']),
Filter::make('has_embargo_data')
->query(fn($query) => $query->whereNotNull('embargo_data')),
->query(fn ($query) => $query->whereNotNull('embargo_data')),
Filter::make('has_address_format')
->query(fn($query) => $query->whereNotNull('address_format')),
->query(fn ($query) => $query->whereNotNull('address_format')),
Filter::make('postal_code_regex')
->form([
TextInput::make('postal_code_regex')
Expand All @@ -365,15 +364,15 @@ public static function table(Table $table): Table
->query(function (Builder $query, array $data): Builder {
return $query->when(
$data['postal_code_regex'],
fn(Builder $query, $value): Builder => $query->where('postal_code_regex', 'like', "%{$value}%"),
fn (Builder $query, $value): Builder => $query->where('postal_code_regex', 'like', "%{$value}%"),
);
})
->indicateUsing(function (array $data): ?string {
if (! $data['postal_code_regex']) {
return null;
}

return 'Postal Code Regex: ' . $data['postal_code_regex'];
return 'Postal Code Regex: '.$data['postal_code_regex'];
}),
Filter::make('dialing_prefix')
->form([
Expand All @@ -384,18 +383,18 @@ public static function table(Table $table): Table
->query(function (Builder $query, array $data): Builder {
return $query->when(
$data['dialing_prefix'],
fn(Builder $query, $value): Builder => $query->where('dialing_prefix', 'like', "%{$value}%"),
fn (Builder $query, $value): Builder => $query->where('dialing_prefix', 'like', "%{$value}%"),
);
})
->indicateUsing(function (array $data): ?string {
if (! $data['dialing_prefix']) {
return null;
}

return 'Dialing Prefix: ' . $data['dialing_prefix'];
return 'Dialing Prefix: '.$data['dialing_prefix'];
}),
Filter::make('has_phone_number_formatting')
->query(fn($query) => $query->whereNotNull('phone_number_formatting')),
->query(fn ($query) => $query->whereNotNull('phone_number_formatting')),
Filter::make('date_format')
->form([
TextInput::make('date_format')
Expand All @@ -405,18 +404,18 @@ public static function table(Table $table): Table
->query(function (Builder $query, array $data): Builder {
return $query->when(
$data['date_format'],
fn(Builder $query, $value): Builder => $query->where('date_format', 'like', "%{$value}%"),
fn (Builder $query, $value): Builder => $query->where('date_format', 'like', "%{$value}%"),
);
})
->indicateUsing(function (array $data): ?string {
if (! $data['date_format']) {
return null;
}

return 'Date Format: ' . $data['date_format'];
return 'Date Format: '.$data['date_format'];
}),
Filter::make('has_currency_format')
->query(fn($query) => $query->whereNotNull('currency_format')),
->query(fn ($query) => $query->whereNotNull('currency_format')),
]);
}

Expand Down
Loading

0 comments on commit 79d3431

Please sign in to comment.