colorful
Some checks failed
Tests / PHP 8.3 (push) Has been cancelled
Tests / PHP 8.4 (push) Has been cancelled
Tests / PHP 8.5 (push) Has been cancelled

This commit is contained in:
2026-05-01 12:54:12 +00:00
parent 6ef2e9fe4e
commit 7c5055075b
12 changed files with 128 additions and 26 deletions

View File

@@ -21,12 +21,10 @@ class ContractForm
Select::make('product_id') Select::make('product_id')
->relationship('product', 'name') ->relationship('product', 'name')
->searchable() ->searchable()
->preload()
->required(), ->required(),
Select::make('customer_id') Select::make('customer_id')
->relationship('customer', 'name') ->relationship('customer', 'name')
->searchable() ->searchable()
->preload()
->required(), ->required(),
Select::make('type') Select::make('type')
->options(ContractType::options()) ->options(ContractType::options())

View File

@@ -4,6 +4,7 @@ namespace App\Filament\Resources\Feedback\Schemas;
use App\Models\CustomerProduct; use App\Models\CustomerProduct;
use App\Models\Department; use App\Models\Department;
use Filament\Forms\Components\ColorPicker;
use Filament\Forms\Components\FileUpload; use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\Select; use Filament\Forms\Components\Select;
use Filament\Forms\Components\Textarea; use Filament\Forms\Components\Textarea;
@@ -23,7 +24,6 @@ class FeedbackForm
Select::make('customer_id') Select::make('customer_id')
->relationship('customer', 'name') ->relationship('customer', 'name')
->searchable() ->searchable()
->preload()
->required() ->required()
->live(), ->live(),
@@ -34,20 +34,26 @@ class FeedbackForm
Select::make('customer_product_id') Select::make('customer_product_id')
->label('Product') ->label('Product')
->options(function ($get): array { ->searchable()
->getSearchResultsUsing(function (string $search, $get): array {
$customerId = $get('customer_id'); $customerId = $get('customer_id');
if (! $customerId) { if (! $customerId) {
return []; return [];
} }
$keyword = mb_strtolower($search);
return CustomerProduct::where('customer_id', $customerId) return CustomerProduct::where('customer_id', $customerId)
->whereHas('product', fn ($q) => $q->whereRaw('LOWER(name) LIKE ?', ["%{$keyword}%"]))
->with('product') ->with('product')
->limit(50)
->get() ->get()
->pluck('product.name', 'id') ->pluck('product.name', 'id')
->toArray(); ->toArray();
}) })
->getOptionLabelUsing(fn ($value): ?string =>
CustomerProduct::find($value)?->product?->name
)
->visible(fn ($get): bool => ! $get('is_general')) ->visible(fn ($get): bool => ! $get('is_general'))
->nullable() ->nullable()
->searchable()
->live(), ->live(),
Select::make('contract_id') Select::make('contract_id')
@@ -135,7 +141,7 @@ class FeedbackForm
->createOptionForm([ ->createOptionForm([
TextInput::make('name')->required(), TextInput::make('name')->required(),
TextInput::make('slug')->required(), TextInput::make('slug')->required(),
TextInput::make('color')->type('color'), ColorPicker::make('color')->default('#3b82f6'),
]), ]),
Select::make('status') Select::make('status')
@@ -151,7 +157,6 @@ class FeedbackForm
Select::make('assigned_to') Select::make('assigned_to')
->relationship('assignedTo', 'name') ->relationship('assignedTo', 'name')
->searchable() ->searchable()
->preload()
->nullable(), ->nullable(),
Select::make('current_department_id') Select::make('current_department_id')

View File

@@ -39,7 +39,13 @@ class FeedbackTable
->placeholder('-') ->placeholder('-')
->toggleable(), ->toggleable(),
TextColumn::make('feedbackChannel.name') TextColumn::make('feedbackChannel.name')
->label('Channel'), ->label('Channel')
->formatStateUsing(fn ($state, $record) => sprintf(
'<span style="display:inline-block;background:%s;color:#fff;padding:2px 10px;border-radius:9999px;font-size:0.75rem;">%s</span>',
$record->feedbackChannel?->color ?: '#6b7280',
e($state)
))
->html(),
TextColumn::make('tags.name') TextColumn::make('tags.name')
->badge() ->badge()
->separator(','), ->separator(','),

View File

@@ -2,6 +2,7 @@
namespace App\Filament\Resources\FeedbackChannels\Schemas; namespace App\Filament\Resources\FeedbackChannels\Schemas;
use Filament\Forms\Components\ColorPicker;
use Filament\Forms\Components\TextInput; use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle; use Filament\Forms\Components\Toggle;
use Filament\Schemas\Components\Section; use Filament\Schemas\Components\Section;
@@ -25,6 +26,8 @@ class FeedbackChannelForm
TextInput::make('icon') TextInput::make('icon')
->maxLength(255) ->maxLength(255)
->hint('Heroicon name or emoji'), ->hint('Heroicon name or emoji'),
ColorPicker::make('color')
->label('Color'),
Toggle::make('is_active') Toggle::make('is_active')
->default(true), ->default(true),
]) ])

View File

@@ -17,9 +17,23 @@ class FeedbackChannelsTable
->columns([ ->columns([
TextColumn::make('name') TextColumn::make('name')
->searchable() ->searchable()
->sortable(), ->sortable()
->formatStateUsing(fn ($state, $record) => sprintf(
'<span style="display:inline-block;background:%s;color:#fff;padding:2px 10px;border-radius:9999px;font-size:0.75rem;">%s</span>',
$record->color ?: '#6b7280',
e($state)
))
->html(),
TextColumn::make('slug') TextColumn::make('slug')
->searchable(), ->searchable(),
TextColumn::make('color')
->label('Color')
->formatStateUsing(fn ($state) => sprintf(
'<span style="display:inline-block;width:24px;height:24px;background:%s;border-radius:6px;border:1px solid #d1d5db;" title="%s"></span>',
$state ?: '#6b7280',
$state
))
->html(),
IconColumn::make('is_active') IconColumn::make('is_active')
->boolean() ->boolean()
->label('Active'), ->label('Active'),

View File

@@ -2,7 +2,9 @@
namespace App\Filament\Resources\FeedbackTags\Schemas; namespace App\Filament\Resources\FeedbackTags\Schemas;
use Filament\Forms\Components\ColorPicker;
use Filament\Forms\Components\TextInput; use Filament\Forms\Components\TextInput;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Schema; use Filament\Schemas\Schema;
class FeedbackTagForm class FeedbackTagForm
@@ -11,11 +13,19 @@ class FeedbackTagForm
{ {
return $schema return $schema
->components([ ->components([
TextInput::make('name') Section::make()
->required(), ->schema([
TextInput::make('slug') TextInput::make('name')
->required(), ->required()
TextInput::make('color'), ->maxLength(255),
TextInput::make('slug')
->required()
->maxLength(255),
ColorPicker::make('color')
->label('Color')
->default('#3b82f6'),
])
->columns(2),
]); ]);
} }
} }

View File

@@ -5,6 +5,7 @@ namespace App\Filament\Resources\FeedbackTags\Tables;
use Filament\Actions\BulkActionGroup; use Filament\Actions\BulkActionGroup;
use Filament\Actions\DeleteBulkAction; use Filament\Actions\DeleteBulkAction;
use Filament\Actions\EditAction; use Filament\Actions\EditAction;
use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Columns\TextColumn; use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table; use Filament\Tables\Table;
@@ -15,19 +16,30 @@ class FeedbackTagsTable
return $table return $table
->columns([ ->columns([
TextColumn::make('name') TextColumn::make('name')
->searchable(), ->searchable()
->formatStateUsing(fn ($state, $record) => sprintf(
'<span style="display:inline-block;background:%s;color:#fff;padding:2px 10px;border-radius:9999px;font-size:0.75rem;">%s</span>',
$record->color ?: '#6b7280',
e($state)
))
->html(),
TextColumn::make('slug') TextColumn::make('slug')
->searchable(), ->searchable(),
TextColumn::make('color') TextColumn::make('color')
->searchable(), ->label('Color')
->formatStateUsing(fn ($state) => sprintf(
'<span style="display:inline-block;width:24px;height:24px;background:%s;border-radius:6px;border:1px solid #d1d5db;" title="%s"></span>',
$state ?: '#6b7280',
$state
))
->html(),
TextColumn::make('feedbacks_count')
->counts('feedbacks')
->label('Used'),
TextColumn::make('created_at') TextColumn::make('created_at')
->dateTime() ->dateTime()
->sortable() ->sortable()
->toggleable(isToggledHiddenByDefault: true), ->toggleable(isToggledHiddenByDefault: true),
TextColumn::make('updated_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
]) ])
->filters([ ->filters([
// //

View File

@@ -10,6 +10,15 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
#[Fillable(['product_id', 'customer_id', 'type', 'start_date', 'end_date', 'status', 'printed_at', 'signed_status'])] #[Fillable(['product_id', 'customer_id', 'type', 'start_date', 'end_date', 'status', 'printed_at', 'signed_status'])]
class Contract extends Model class Contract extends Model
{ {
protected function casts(): array
{
return [
'start_date' => 'date',
'end_date' => 'date',
'printed_at' => 'date',
];
}
public function product(): BelongsTo public function product(): BelongsTo
{ {
return $this->belongsTo(Product::class); return $this->belongsTo(Product::class);

View File

@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasMany;
#[Fillable(['name', 'slug', 'icon', 'is_active'])] #[Fillable(['name', 'slug', 'icon', 'color', 'is_active'])]
class FeedbackChannel extends Model class FeedbackChannel extends Model
{ {
protected function casts(): array protected function casts(): array

View File

@@ -0,0 +1,22 @@
<?php
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('feedback_channels', function (Blueprint $table) {
$table->string('color')->nullable()->after('icon');
});
}
public function down(): void
{
Schema::table('feedback_channels', function (Blueprint $table) {
$table->dropColumn('color');
});
}
};

View File

@@ -49,11 +49,11 @@ class AfterSalesSeeder extends Seeder
$depPhaply = Department::create(['name' => 'Phòng Pháp lý', 'manager_id' => null]); $depPhaply = Department::create(['name' => 'Phòng Pháp lý', 'manager_id' => null]);
$channels = [ $channels = [
['name' => 'Email', 'slug' => 'email', 'icon' => 'heroicon-o-envelope'], ['name' => 'Email', 'slug' => 'email', 'icon' => 'heroicon-o-envelope', 'color' => '#3b82f6'],
['name' => 'Zalo', 'slug' => 'zalo', 'icon' => 'heroicon-o-chat-bubble-left'], ['name' => 'Zalo', 'slug' => 'zalo', 'icon' => 'heroicon-o-chat-bubble-left', 'color' => '#10b981'],
['name' => 'Phone', 'slug' => 'phone', 'icon' => 'heroicon-o-phone'], ['name' => 'Phone', 'slug' => 'phone', 'icon' => 'heroicon-o-phone', 'color' => '#f59e0b'],
['name' => 'Document', 'slug' => 'document', 'icon' => 'heroicon-o-document-text'], ['name' => 'Document', 'slug' => 'document', 'icon' => 'heroicon-o-document-text', 'color' => '#8b5cf6'],
['name' => 'In Person', 'slug' => 'in-person', 'icon' => 'heroicon-o-user'], ['name' => 'In Person', 'slug' => 'in-person', 'icon' => 'heroicon-o-user', 'color' => '#ec4899'],
]; ];
foreach ($channels as $channel) { foreach ($channels as $channel) {

View File

@@ -488,6 +488,29 @@ select {
background-color: var(--crm-surface-container-lowest) !important; background-color: var(--crm-surface-container-lowest) !important;
} }
/* ---------- FIX: Icon sizing ---------- */
svg.fi-icon,
.fi-icon svg,
.fi-btn svg.fi-icon,
.fi-icon-btn svg,
.fi-input-wrp svg,
.fi-select svg,
.fi-fo-field-wrp svg,
svg[class*="fi-icon"] {
width: 1.25rem !important;
height: 1.25rem !important;
max-width: 1.25rem !important;
max-height: 1.25rem !important;
flex-shrink: 0 !important;
}
/* Smaller icons in table cells and badges */
.fi-ta-cell svg.fi-icon,
.fi-badge svg {
width: 1rem !important;
height: 1rem !important;
}
/* ---------- Similar Cases footer panel ---------- */ /* ---------- Similar Cases footer panel ---------- */
.fi-footer { .fi-footer {
margin-top: 2rem; margin-top: 2rem;