Skip to content

Commit

Permalink
Reorder nomenclature items
Browse files Browse the repository at this point in the history
  • Loading branch information
alexPopaCode4 committed Jan 10, 2025
1 parent 7a60c0f commit 156f90e
Show file tree
Hide file tree
Showing 17 changed files with 1,454 additions and 16 deletions.
20 changes: 20 additions & 0 deletions app/Concerns/HasSortOrder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

namespace App\Concerns;

use App\Models\Scopes\SortOrder;

trait HasSortOrder
{
public function initializeHasSortOrder(): void
{
$this->fillable[] = 'sort';
}

protected static function bootHasSortOrder(): void
{
static::addGlobalScope(new SortOrder);
}
}
10 changes: 10 additions & 0 deletions app/Filament/Admin/Resources/BenefitResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Filament\Forms\Components\Toggle;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables\Actions\Action as TableAction;
use Filament\Tables\Actions\CreateAction;
use Filament\Tables\Actions\ViewAction;
use Filament\Tables\Columns\TextColumn;
Expand Down Expand Up @@ -87,6 +88,15 @@ public static function table(Table $table): Table
->url(self::getUrl('create')),
])
->heading(__('nomenclature.headings.benefit_table'))
->reorderable('sort')
->defaultSort('sort')
->reorderRecordsTriggerAction(
fn (TableAction $action) => $action
->icon(null)
->button()
->outlined()
->color('primary')
)
->columns([
TextColumn::make('name')
->label(__('nomenclature.labels.benefit')),
Expand Down
10 changes: 10 additions & 0 deletions app/Filament/Admin/Resources/ResultResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables\Actions\Action as TableAction;
use Filament\Tables\Actions\CreateAction;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
Expand Down Expand Up @@ -48,6 +49,15 @@ public static function table(Table $table): Table
CreateAction::make()
->label(__('nomenclature.actions.add_result')),
])
->reorderable('sort')
->defaultSort('sort')
->reorderRecordsTriggerAction(
fn (TableAction $action) => $action
->icon(null)
->button()
->outlined()
->color('primary')
)
->columns([
TextColumn::make('name')
->label(__('nomenclature.labels.result_name')),
Expand Down
10 changes: 10 additions & 0 deletions app/Filament/Admin/Resources/RoleResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Filament\Forms\Components\Toggle;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables\Actions\Action as TableAction;
use Filament\Tables\Actions\CreateAction;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\SelectFilter;
Expand Down Expand Up @@ -81,6 +82,15 @@ public static function table(Table $table): Table
->label(__('nomenclature.actions.add_role')),

])
->reorderable('sort')
->defaultSort('sort')
->reorderRecordsTriggerAction(
fn (TableAction $action) => $action
->icon(null)
->button()
->outlined()
->color('primary')
)
->columns([
TextColumn::make('name')
->label(__('nomenclature.labels.role_name')),
Expand Down
10 changes: 10 additions & 0 deletions app/Filament/Admin/Resources/ServiceResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Filament\Forms\Form;
use Filament\Forms\Get;
use Filament\Resources\Resource;
use Filament\Tables\Actions\Action as TableAction;
use Filament\Tables\Actions\CreateAction;
use Filament\Tables\Actions\ViewAction;
use Filament\Tables\Columns\TextColumn;
Expand Down Expand Up @@ -141,6 +142,15 @@ public static function table(Table $table): Table
{
return $table
->modifyQueryUsing(fn (Builder $query) => $query->withCount(['organizationServices']))
->reorderable('sort')
->defaultSort('sort')
->reorderRecordsTriggerAction(
fn (TableAction $action) => $action
->icon(null)
->button()
->outlined()
->color('primary')
)
->columns([
TextColumn::make('name')
->label(__('nomenclature.labels.name'))
Expand Down
2 changes: 2 additions & 0 deletions app/Models/Benefit.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace App\Models;

use App\Concerns\HasGeneralStatus;
use App\Concerns\HasSortOrder;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
Expand All @@ -14,6 +15,7 @@ class Benefit extends Model
{
use HasFactory;
use HasGeneralStatus;
use HasSortOrder;

protected $fillable = [
'name',
Expand Down
10 changes: 2 additions & 8 deletions app/Models/BenefitType.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace App\Models;

use App\Concerns\HasGeneralStatus;
use App\Models\Scopes\SortOrder;
use App\Concerns\HasSortOrder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
Expand All @@ -14,19 +14,13 @@ class BenefitType extends Model
{
use HasFactory;
use HasGeneralStatus;
use HasSortOrder;

protected $fillable = [
'benefit_id',
'name',
'sort',
];

protected static function booted()
{
parent::booted();
static::addGlobalScope(new SortOrder);
}

public function benefit(): BelongsTo
{
return $this->belongsTo(Benefit::class);
Expand Down
2 changes: 2 additions & 0 deletions app/Models/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace App\Models;

use App\Concerns\HasGeneralStatus;
use App\Concerns\HasSortOrder;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
Expand All @@ -14,6 +15,7 @@ class Result extends Model
{
use HasFactory;
use HasGeneralStatus;
use HasSortOrder;

protected $fillable = [
'name',
Expand Down
2 changes: 2 additions & 0 deletions app/Models/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace App\Models;

use App\Concerns\HasGeneralStatus;
use App\Concerns\HasSortOrder;
use App\Enums\AdminPermission;
use App\Enums\CasePermission;
use Illuminate\Database\Eloquent\Casts\AsEnumCollection;
Expand All @@ -16,6 +17,7 @@ class Role extends Model
{
use HasFactory;
use HasGeneralStatus;
use HasSortOrder;

protected $fillable = [
'name',
Expand Down
2 changes: 2 additions & 0 deletions app/Models/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace App\Models;

use App\Concerns\HasGeneralStatus;
use App\Concerns\HasSortOrder;
use App\Enums\CounselingSheet;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
Expand All @@ -15,6 +16,7 @@ class Service extends Model
{
use HasFactory;
use HasGeneralStatus;
use HasSortOrder;

protected $fillable = [
'name',
Expand Down
10 changes: 2 additions & 8 deletions app/Models/ServiceIntervention.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace App\Models;

use App\Concerns\HasGeneralStatus;
use App\Models\Scopes\SortOrder;
use App\Concerns\HasSortOrder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
Expand All @@ -16,19 +16,13 @@ class ServiceIntervention extends Model
{
use HasFactory;
use HasGeneralStatus;
use HasSortOrder;

protected $fillable = [
'service_id',
'name',
'sort',
];

protected static function booted()
{
parent::booted();
static::addGlobalScope(new SortOrder);
}

public function service(): BelongsTo
{
return $this->belongsTo(Service::class);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
public function up(): void
{
Schema::table('services', function (Blueprint $table) {
$table->integer('sort')->default(0);
});
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
public function up(): void
{
Schema::table('benefits', function (Blueprint $table) {
$table->integer('sort')->default(0);
});
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
public function up(): void
{
Schema::table('results', function (Blueprint $table) {
$table->integer('sort')->default(0);
});
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
public function up(): void
{
Schema::table('roles', function (Blueprint $table) {
$table->integer('sort')->default(0);
});
}
};
16 changes: 16 additions & 0 deletions lang/vendor/filament-tables/ro/table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

return [
'actions' => [

'disable_reordering' => [
'label' => 'Salvează modificările',
],

'enable_reordering' => [
'label' => 'Ordonează lista',
],
],
];
Loading

0 comments on commit 156f90e

Please sign in to comment.