colorful
This commit is contained in:
@@ -21,12 +21,10 @@ class ContractForm
|
||||
Select::make('product_id')
|
||||
->relationship('product', 'name')
|
||||
->searchable()
|
||||
->preload()
|
||||
->required(),
|
||||
Select::make('customer_id')
|
||||
->relationship('customer', 'name')
|
||||
->searchable()
|
||||
->preload()
|
||||
->required(),
|
||||
Select::make('type')
|
||||
->options(ContractType::options())
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Filament\Resources\Feedback\Schemas;
|
||||
|
||||
use App\Models\CustomerProduct;
|
||||
use App\Models\Department;
|
||||
use Filament\Forms\Components\ColorPicker;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
@@ -23,7 +24,6 @@ class FeedbackForm
|
||||
Select::make('customer_id')
|
||||
->relationship('customer', 'name')
|
||||
->searchable()
|
||||
->preload()
|
||||
->required()
|
||||
->live(),
|
||||
|
||||
@@ -34,20 +34,26 @@ class FeedbackForm
|
||||
|
||||
Select::make('customer_product_id')
|
||||
->label('Product')
|
||||
->options(function ($get): array {
|
||||
->searchable()
|
||||
->getSearchResultsUsing(function (string $search, $get): array {
|
||||
$customerId = $get('customer_id');
|
||||
if (! $customerId) {
|
||||
return [];
|
||||
}
|
||||
$keyword = mb_strtolower($search);
|
||||
return CustomerProduct::where('customer_id', $customerId)
|
||||
->whereHas('product', fn ($q) => $q->whereRaw('LOWER(name) LIKE ?', ["%{$keyword}%"]))
|
||||
->with('product')
|
||||
->limit(50)
|
||||
->get()
|
||||
->pluck('product.name', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->getOptionLabelUsing(fn ($value): ?string =>
|
||||
CustomerProduct::find($value)?->product?->name
|
||||
)
|
||||
->visible(fn ($get): bool => ! $get('is_general'))
|
||||
->nullable()
|
||||
->searchable()
|
||||
->live(),
|
||||
|
||||
Select::make('contract_id')
|
||||
@@ -135,7 +141,7 @@ class FeedbackForm
|
||||
->createOptionForm([
|
||||
TextInput::make('name')->required(),
|
||||
TextInput::make('slug')->required(),
|
||||
TextInput::make('color')->type('color'),
|
||||
ColorPicker::make('color')->default('#3b82f6'),
|
||||
]),
|
||||
|
||||
Select::make('status')
|
||||
@@ -151,7 +157,6 @@ class FeedbackForm
|
||||
Select::make('assigned_to')
|
||||
->relationship('assignedTo', 'name')
|
||||
->searchable()
|
||||
->preload()
|
||||
->nullable(),
|
||||
|
||||
Select::make('current_department_id')
|
||||
|
||||
@@ -39,7 +39,13 @@ class FeedbackTable
|
||||
->placeholder('-')
|
||||
->toggleable(),
|
||||
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')
|
||||
->badge()
|
||||
->separator(','),
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\FeedbackChannels\Schemas;
|
||||
|
||||
use Filament\Forms\Components\ColorPicker;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Schemas\Components\Section;
|
||||
@@ -25,6 +26,8 @@ class FeedbackChannelForm
|
||||
TextInput::make('icon')
|
||||
->maxLength(255)
|
||||
->hint('Heroicon name or emoji'),
|
||||
ColorPicker::make('color')
|
||||
->label('Color'),
|
||||
Toggle::make('is_active')
|
||||
->default(true),
|
||||
])
|
||||
|
||||
@@ -17,9 +17,23 @@ class FeedbackChannelsTable
|
||||
->columns([
|
||||
TextColumn::make('name')
|
||||
->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')
|
||||
->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')
|
||||
->boolean()
|
||||
->label('Active'),
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace App\Filament\Resources\FeedbackTags\Schemas;
|
||||
|
||||
use Filament\Forms\Components\ColorPicker;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class FeedbackTagForm
|
||||
@@ -11,11 +13,19 @@ class FeedbackTagForm
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Section::make()
|
||||
->schema([
|
||||
TextInput::make('name')
|
||||
->required(),
|
||||
->required()
|
||||
->maxLength(255),
|
||||
TextInput::make('slug')
|
||||
->required(),
|
||||
TextInput::make('color'),
|
||||
->required()
|
||||
->maxLength(255),
|
||||
ColorPicker::make('color')
|
||||
->label('Color')
|
||||
->default('#3b82f6'),
|
||||
])
|
||||
->columns(2),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Filament\Resources\FeedbackTags\Tables;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
@@ -15,19 +16,30 @@ class FeedbackTagsTable
|
||||
return $table
|
||||
->columns([
|
||||
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')
|
||||
->searchable(),
|
||||
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')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
|
||||
@@ -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'])]
|
||||
class Contract extends Model
|
||||
{
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'start_date' => 'date',
|
||||
'end_date' => 'date',
|
||||
'printed_at' => 'date',
|
||||
];
|
||||
}
|
||||
|
||||
public function product(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Product::class);
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
#[Fillable(['name', 'slug', 'icon', 'is_active'])]
|
||||
#[Fillable(['name', 'slug', 'icon', 'color', 'is_active'])]
|
||||
class FeedbackChannel extends Model
|
||||
{
|
||||
protected function casts(): array
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -49,11 +49,11 @@ class AfterSalesSeeder extends Seeder
|
||||
$depPhaply = Department::create(['name' => 'Phòng Pháp lý', 'manager_id' => null]);
|
||||
|
||||
$channels = [
|
||||
['name' => 'Email', 'slug' => 'email', 'icon' => 'heroicon-o-envelope'],
|
||||
['name' => 'Zalo', 'slug' => 'zalo', 'icon' => 'heroicon-o-chat-bubble-left'],
|
||||
['name' => 'Phone', 'slug' => 'phone', 'icon' => 'heroicon-o-phone'],
|
||||
['name' => 'Document', 'slug' => 'document', 'icon' => 'heroicon-o-document-text'],
|
||||
['name' => 'In Person', 'slug' => 'in-person', 'icon' => 'heroicon-o-user'],
|
||||
['name' => 'Email', 'slug' => 'email', 'icon' => 'heroicon-o-envelope', 'color' => '#3b82f6'],
|
||||
['name' => 'Zalo', 'slug' => 'zalo', 'icon' => 'heroicon-o-chat-bubble-left', 'color' => '#10b981'],
|
||||
['name' => 'Phone', 'slug' => 'phone', 'icon' => 'heroicon-o-phone', 'color' => '#f59e0b'],
|
||||
['name' => 'Document', 'slug' => 'document', 'icon' => 'heroicon-o-document-text', 'color' => '#8b5cf6'],
|
||||
['name' => 'In Person', 'slug' => 'in-person', 'icon' => 'heroicon-o-user', 'color' => '#ec4899'],
|
||||
];
|
||||
|
||||
foreach ($channels as $channel) {
|
||||
|
||||
@@ -488,6 +488,29 @@ select {
|
||||
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 ---------- */
|
||||
.fi-footer {
|
||||
margin-top: 2rem;
|
||||
|
||||
Reference in New Issue
Block a user