-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: similar named organisms are displayed on the edit page of organ…
…isms with an option to edit them
- Loading branch information
1 parent
edde586
commit 36622d4
Showing
3 changed files
with
44 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace App\Forms\Components; | ||
|
||
use App\Models\Organism; | ||
use Filament\Forms\Components\Field; | ||
|
||
class OrganismsTable extends Field | ||
{ | ||
protected string $view = 'forms.components.organisms-table'; | ||
|
||
public static function make(string $name): static | ||
{ | ||
return parent::make($name); | ||
} | ||
|
||
public function getTableData($record_name) | ||
{ | ||
return Organism::select('id', 'name', urldecode('iri'), 'molecule_count')->where('name', 'ILIKE', '%'.$record_name.'%') | ||
->orWhereRaw('? ILIKE CONCAT(\'%\', name, \'%\')', [$record_name]) | ||
->get(); | ||
} | ||
} |
41 changes: 19 additions & 22 deletions
41
resources/views/forms/components/organisms-table.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,19 @@ | ||
|
||
|
||
<div> | ||
<table class="table-auto w-full"> | ||
<thead> | ||
<tr> | ||
@foreach(array_keys($getTableData($getRecord()->name)[0] ?? []) as $header) | ||
<th class="px-4 py-2">{{ $header }}</th> | ||
@endforeach | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@foreach($getTableData($getRecord()->name) as $row) | ||
<tr> | ||
@foreach($row as $value) | ||
<td class="border px-4 py-2">{{ $value }}</td> | ||
@endforeach | ||
</tr> | ||
@endforeach | ||
</tbody> | ||
</table> | ||
</div> | ||
<div class="overflow-x-auto"> | ||
@foreach($getTableData($getRecord()->name) as $row) | ||
<div class="border p-2 px-4 rounded-md mb-2 flex items-center justify-between"> | ||
<div class="mr-4"> | ||
<p class="text-md font-bold"> | ||
{{ $row['name'] }} (Molecule count: {{ $row['molecule_count'] }}) | ||
</p> | ||
<p> | ||
<a href="{{$row['iri']}}" target="_blank" class="text-blue-600 hover:underline"> | ||
IRI - {{ $row['iri'] }} | ||
</a> | ||
</p> | ||
</div> | ||
<x-button href="{{env('APP_URL').'/dashboard/organisms/'.$row['id'].'/edit'}}" target="_blank" wire:navigate.hover> | ||
Edit | ||
</x-button> | ||
</div> | ||
@endforeach | ||
</div> |