feat: i18n, language switcher fix, DataTable improvements, blade translations
- Translation system: lang/es/ PHP files (auth, validation, pagination, passwords)
- Rappasoft vendor translations published (lang/vendor/livewire-tables/es/)
- JSON files synced to 391 keys (EN + ES, full parity)
- APP_LOCALE changed to 'es', users.locale column default changed to 'es'
- Language switcher fixed: JS event + window.location.reload() avoids /livewire/update redirect
- SetLocale middleware fallback uses config('app.locale') instead of hardcoded 'en'
- setSortingPillsEnabled(false) on ProjectTable, CompanyTable, UserTable
- Translated 17 blade views: project-map, template-manager, layer-manager,
company-management, phase-list, media-manager, reports-dashboard,
client-projects, layer-upload, project-form, project-map-editor-tab,
admin/users, projects/media, projects/templates, layouts/client
- Navigation 'Empresas' link uses __('Companies')
- Fixed typo key 'Fases and layers' -> 'Phases and layers'
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
namespace App\Livewire;
|
||||
use Livewire\Component;
|
||||
use Livewire\Attributes\Layout;
|
||||
use App\Models\Project;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
#[Layout('layouts.app')]
|
||||
class PhaseGantt extends Component
|
||||
{
|
||||
public Project $project;
|
||||
public $ganttData = [];
|
||||
|
||||
public function mount(Project $project)
|
||||
{
|
||||
$user = Auth::user();
|
||||
if (!$user->hasRole('Admin') && !$project->users()->where('user_id', $user->id)->exists()) {
|
||||
abort(403);
|
||||
}
|
||||
$this->project = $project;
|
||||
$this->loadGanttData();
|
||||
}
|
||||
|
||||
public function loadGanttData()
|
||||
{
|
||||
$phases = $this->project->phases()->with(['layers.features'])->orderBy('order')->get();
|
||||
$projectStart = $this->project->start_date ?? now()->startOfMonth();
|
||||
$projectEnd = $this->project->end_date_estimated ?? now()->addMonths(6);
|
||||
|
||||
$this->ganttData = $phases->map(function($phase) use ($projectStart, $projectEnd) {
|
||||
$planned_start = $phase->planned_start ?? $projectStart;
|
||||
$planned_end = $phase->planned_end ?? $projectEnd;
|
||||
$actual_start = $phase->actual_start;
|
||||
$actual_end = $phase->actual_end;
|
||||
|
||||
$totalDays = max(1, $projectStart->diffInDays($projectEnd));
|
||||
|
||||
$pStartOffset = max(0, $projectStart->diffInDays($planned_start));
|
||||
$pDuration = max(1, $planned_start->diffInDays($planned_end));
|
||||
$pStartPct = round(($pStartOffset / $totalDays) * 100, 2);
|
||||
$pWidthPct = round(($pDuration / $totalDays) * 100, 2);
|
||||
|
||||
$aStartPct = null; $aWidthPct = null;
|
||||
if ($actual_start) {
|
||||
$aStart = max(0, $projectStart->diffInDays($actual_start));
|
||||
$aEnd = $actual_end ?? now();
|
||||
$aDuration = max(1, $actual_start->diffInDays($aEnd));
|
||||
$aStartPct = round(($aStart / $totalDays) * 100, 2);
|
||||
$aWidthPct = round(($aDuration / $totalDays) * 100, 2);
|
||||
}
|
||||
|
||||
$isDelayed = $phase->planned_end && $phase->planned_end->isPast() && $phase->progress_percent < 100;
|
||||
|
||||
return [
|
||||
'id' => $phase->id,
|
||||
'name' => $phase->name,
|
||||
'color' => $phase->color ?? '#3b82f6',
|
||||
'progress' => $phase->progress_percent,
|
||||
'planned_start' => $planned_start->format('d/m/Y'),
|
||||
'planned_end' => $planned_end->format('d/m/Y'),
|
||||
'actual_start' => $actual_start?->format('d/m/Y'),
|
||||
'actual_end' => $actual_end?->format('d/m/Y'),
|
||||
'p_start_pct' => $pStartPct,
|
||||
'p_width_pct' => min($pWidthPct, 100 - $pStartPct),
|
||||
'a_start_pct' => $aStartPct,
|
||||
'a_width_pct' => $aWidthPct ? min($aWidthPct, 100 - $aStartPct) : null,
|
||||
'is_delayed' => $isDelayed,
|
||||
'features_count' => $phase->layers->sum(fn($l) => $l->features->count()),
|
||||
];
|
||||
})->toArray();
|
||||
}
|
||||
|
||||
public function updatePhaseDates($phaseId, $plannedStart, $plannedEnd, $actualStart = null, $actualEnd = null)
|
||||
{
|
||||
$phase = $this->project->phases()->findOrFail($phaseId);
|
||||
$phase->update([
|
||||
'planned_start' => $plannedStart ?: null,
|
||||
'planned_end' => $plannedEnd ?: null,
|
||||
'actual_start' => $actualStart ?: null,
|
||||
'actual_end' => $actualEnd ?: null,
|
||||
]);
|
||||
$this->loadGanttData();
|
||||
$this->dispatch('notify', 'Fechas actualizadas');
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.projects.phase-gantt', [
|
||||
'project' => $this->project,
|
||||
'phases' => $this->project->phases()->orderBy('order')->get(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user