Permet de déplacer schémas et dossiers par glisser-déposer
Reprend le mécanisme du module Documents (drag & drop + menu déroulant "Déplacer vers"), scopé aux documents de type diagram pour rester isolé du navigateur Documents. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
c1c6d56d1e
commit
2e614f2929
@@ -159,4 +159,64 @@ class InfrastructureTest extends TestCase
|
||||
Livewire::test('infrastructure.index', ['organization' => $org, 'locationId' => $otherLocation->id])
|
||||
->assertDontSee('Schéma test');
|
||||
}
|
||||
|
||||
public function test_can_move_a_diagram_into_a_folder_and_back_to_the_root(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$org = Organization::create(['name' => 'Test Commune', 'slug' => 'test-commune', 'org_type' => 'client']);
|
||||
|
||||
$folder = $org->documents()->create(['name' => 'Réseau', 'type' => 'diagram', 'is_folder' => true, 'created_by' => $user->id]);
|
||||
$diagram = $org->documents()->create([
|
||||
'name' => 'Schéma test', 'type' => 'diagram', 'content' => '<mxfile></mxfile>',
|
||||
'current_version' => 1, 'created_by' => $user->id,
|
||||
]);
|
||||
|
||||
$this->actingAs($user);
|
||||
|
||||
Livewire::test('infrastructure.index', ['organization' => $org])
|
||||
->call('moveDocument', $diagram->id, $folder->id);
|
||||
|
||||
$this->assertSame($folder->id, $diagram->refresh()->folder_id);
|
||||
|
||||
Livewire::test('infrastructure.index', ['organization' => $org])
|
||||
->call('moveDocument', $diagram->id, null);
|
||||
|
||||
$this->assertNull($diagram->refresh()->folder_id);
|
||||
}
|
||||
|
||||
public function test_cannot_move_a_folder_into_its_own_descendant(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$org = Organization::create(['name' => 'Test Commune', 'slug' => 'test-commune', 'org_type' => 'client']);
|
||||
|
||||
$parent = $org->documents()->create(['name' => 'Parent', 'type' => 'diagram', 'is_folder' => true, 'created_by' => $user->id]);
|
||||
$child = $org->documents()->create(['name' => 'Enfant', 'type' => 'diagram', 'is_folder' => true, 'folder_id' => $parent->id, 'created_by' => $user->id]);
|
||||
|
||||
$this->actingAs($user);
|
||||
|
||||
Livewire::test('infrastructure.index', ['organization' => $org])
|
||||
->call('moveDocument', $parent->id, $child->id);
|
||||
|
||||
$this->assertNull($parent->refresh()->folder_id);
|
||||
}
|
||||
|
||||
public function test_moving_an_item_is_scoped_to_diagram_type_documents(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$org = Organization::create(['name' => 'Test Commune', 'slug' => 'test-commune', 'org_type' => 'client']);
|
||||
|
||||
$regularFolder = $org->documents()->create(['name' => 'Dossier documents', 'is_folder' => true, 'created_by' => $user->id]);
|
||||
$diagram = $org->documents()->create([
|
||||
'name' => 'Schéma test', 'type' => 'diagram', 'content' => '<mxfile></mxfile>',
|
||||
'current_version' => 1, 'created_by' => $user->id,
|
||||
]);
|
||||
|
||||
$this->actingAs($user);
|
||||
|
||||
// A plain (non-diagram) folder must not be a valid drop target from Infrastructure.
|
||||
Livewire::test('infrastructure.index', ['organization' => $org])
|
||||
->call('moveDocument', $diagram->id, $regularFolder->id);
|
||||
|
||||
$this->assertNull($diagram->refresh()->folder_id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user