-
{{ __('Form fields') }}
- @foreach($form['fields'] as $index => $field)
-
-
-
{{ __('Group / section') }}
-
-
-
-
{{ __('Internal name') }}
-
-
-
-
{{ __('Visible label') }}
-
-
-
-
{{ __('Question / check') }}
-
-
-
-
{{ __('Field type') }}
-
-
-
-
-
-
{{ __('Required') }}
-
-
-
-
-
- @if(in_array($field['type'], ['integer', 'decimal', 'percentage']))
-
-
{{ __('Min') }} / {{ __('Max') }} / {{ __('Step') }}
-
-
-
-
+
+
{{ __('Form fields') }}
+ @foreach($form['fields'] as $index => $field)
+
+
+
{{ __('Group / section') }}
+
+
+
+
{{ __('Internal name') }}
+
+
+
+
{{ __('Visible label') }}
+
+
+
+
{{ __('Question / check') }}
+
+
+
+
{{ __('Field type') }}
+
+
+
+
+
+
{{ __('Required') }}
+
+
+
+
+
+ @if(in_array($field['type'], ['integer', 'decimal', 'percentage']))
+
+ @elseif($field['type'] === 'select')
+
+
{{ __('Options (comma separated)') }}
+
+
+ @endif
+
+
+
{{ __('Comments / help') }}
+
- @elseif($field['type'] === 'select')
-
-
{{ __('Options (comma separated)') }}
-
+ @endforeach
+
+
+
+
+
+
+
+
+ @endif
+
+ {{-- Tabla Rappasoft (filtros en cabecera: nombre, descripción, uso) --}}
+
+
+
+ {{-- MODAL: Importar desde CSV/Excel --}}
+ @if($showImportFileModal)
+
+
+
+
+
{{ __('Import from CSV/Excel') }}
+
+
+
+
+ {{ __('Columns: name, label, type, required, options, min, max, step') }}.
+
+
+
+
+
+ @error('importTemplateName'){{ $message }}@enderror
+
+
+
+
+ @error('importFile'){{ $message }}@enderror
+
+ @if($importError)
{{ $importError }}
@endif
+
+
+
+ @if(!empty($importPreviewFields))
+
+
{{ count($importPreviewFields) }} {{ __('fields detected') }}:
+
+
+ | {{ __('Label') }} | {{ __('Name') }} | {{ __('Type') }} | {{ __('Required') }} |
+
+ @foreach($importPreviewFields as $f)
+ | {{ $f['label'] }} | {{ $f['name'] }} | {{ $f['type'] }} | {{ !empty($f['required']) ? '✓' : '' }} |
+ @endforeach
+
+
+
@endif
-
-
-
{{ __('Comments / help') }}
-
-
- @endforeach
-
+
+
+
+
+
-
-
-
-
-
-
- @endif
-
- {{-- Tabla --}}
-
-
-
-
- | {{ __('Name') }} |
- {{ __('Description') }} |
- {{ __('Fields') }} |
- {{ __('Used in projects') }} |
- {{ __('Actions') }} |
-
-
-
- @forelse($templates as $template)
-
- | {{ $template->name }} |
- {{ $template->description ?? '-' }} |
- {{ count($template->fields ?? []) }} |
- {{ $template->projects()->count() }} |
-
-
-
- |
-
- @empty
- | {{ __('No templates yet (table)') }} |
- @endforelse
-
-
+ @endif
-
- {{-- MODAL: Importar desde CSV/Excel --}}
- @if($showImportFileModal)
-
-
-
-
-
{{ __('Import from CSV/Excel') }}
-
-
-
-
- {{ __('Columns: name, label, type, required, options, min, max, step') }}.
-
-
-
-
-
- @error('importTemplateName'){{ $message }}@enderror
-
-
-
-
- @error('importFile'){{ $message }}@enderror
-
- @if($importError)
{{ $importError }}
@endif
-
-
-
- @if(!empty($importPreviewFields))
-
-
{{ count($importPreviewFields) }} {{ __('fields detected') }}:
-
-
- | {{ __('Label') }} | {{ __('Name') }} | {{ __('Type') }} | {{ __('Required') }} |
-
- @foreach($importPreviewFields as $f)
- | {{ $f['label'] }} | {{ $f['name'] }} | {{ $f['type'] }} | {{ !empty($f['required']) ? '✓' : '' }} |
- @endforeach
-
-
-
-
- @endif
-
-
-
-
-
-
-
- @endif
-
+
\ No newline at end of file
diff --git a/routes/web.php b/routes/web.php
index 0e295cf..217f378 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -75,6 +75,7 @@ Route::get('/reports/dashboard', ReportsDashboard::class)->name('reports.dashboa
// Ruta para que el componente Livewire muestre/gestione el progreso de una fase
Route::get('/phases/{phase}/progress', PhaseProgress::class)->name('phases.progress');
Route::get('/projects-list', ProjectList::class)->name('projects.list');
+
// Ruta para templates
// Plantillas globales (catálogo único)
Route::get('/inspection-templates', \App\Livewire\Inspections\GlobalTemplateManager::class)
diff --git a/tests/Feature/GlobalTemplatesTest.php b/tests/Feature/GlobalTemplatesTest.php
index 2625fcf..4a39911 100644
--- a/tests/Feature/GlobalTemplatesTest.php
+++ b/tests/Feature/GlobalTemplatesTest.php
@@ -3,6 +3,7 @@
namespace Tests\Feature;
use App\Livewire\Inspections\GlobalTemplateManager;
+use App\Livewire\Inspections\InspectionTemplatesTable;
use App\Livewire\Projects\ProjectMap;
use App\Livewire\Projects\ProjectTemplatesPicker;
use App\Models\InspectionTemplate;
@@ -79,6 +80,42 @@ class GlobalTemplatesTest extends TestCase
$this->assertFalse($project->fresh()->inspectionTemplates()->where('inspection_templates.id', $tpl->id)->exists());
}
+ public function test_templates_table_lists_and_requires_permission(): void
+ {
+ Permission::findOrCreate('manage templates');
+ InspectionTemplate::create(['name' => 'Recepción acero', 'fields' => []]);
+
+ // Sin permiso → 403
+ $weak = User::factory()->create();
+ Livewire::actingAs($weak)
+ ->test(InspectionTemplatesTable::class)
+ ->assertForbidden();
+
+ // Con permiso → lista
+ $admin = User::factory()->create();
+ $admin->givePermissionTo('manage templates');
+ Livewire::actingAs($admin)
+ ->test(InspectionTemplatesTable::class)
+ ->assertOk()
+ ->assertSee('Recepción acero');
+ }
+
+ public function test_table_emits_edit_event_handled_by_manager(): void
+ {
+ Permission::findOrCreate('manage templates');
+ $admin = User::factory()->create();
+ $admin->givePermissionTo('manage templates');
+ $tpl = InspectionTemplate::create(['name' => 'Editame', 'fields' => []]);
+
+ // El manager escucha #[On('template-edit')] y abre el form
+ Livewire::actingAs($admin)
+ ->test(GlobalTemplateManager::class)
+ ->assertSet('showForm', false)
+ ->call('editTemplate', $tpl->id) // simula el dispatch
+ ->assertSet('showForm', true)
+ ->assertSet('editingTemplate', $tpl->id);
+ }
+
public function test_map_template_selector_only_shows_assigned_templates(): void
{
$user = User::factory()->create();