Closed curtisdelicata closed 1 month ago
Here are the code search results. I'm now analyzing these search results to write the PR.
app/Http/Livewire/FanChart.php
Update the `FanChart` Livewire component to use Filament 3 conventions.
--- +++ @@ -1,16 +1,23 @@ <?php -namespace App\Http\Livewire; +namespace App\Filament\Widgets; use App\Models\Person; -use Livewire\Component; // Assuming there's a Person model to fetch genealogical data +use Filament\Widgets\Widget; -class FanChart extends Component +class FanChartWidget extends Widget { - public function render() + protected static string $view = 'filament.widgets.fan-chart-widget'; + + public function getData(): array { - $people = Person::all(); // Fetch all people/person data. Adjust query as needed for performance or specific requirements. + return [ + 'people' => Person::all(), // Fetch all people/person data. Adjust query as needed for performance or specific requirements. + ]; + } - return view('livewire.fan-chart', ['people' => $people]); + public function render(): \Illuminate\Contracts\View\View + { + return view(static::$view, $this->getData()); } }
app/Http/Livewire/PedigreeChart.php
Update the `PedigreeChart` Livewire component to use Filament 3 conventions.
--- +++ @@ -1,28 +1,29 @@ <?php -namespace App\Http\Livewire; +namespace App\Filament\Widgets; use App\Models\Person; -use Illuminate\Support\Collection; -use Livewire\Component; +use Filament\Widgets\Widget; -class PedigreeChart extends Component +class PedigreeChartWidget extends Widget { - public Collection $people; + protected static string $view = 'filament.widgets.pedigree-chart-widget'; - public function mount() + public function getData(): array { - $this->people = Person::with('parents')->get(); - } + return [ + 'people' => Person::with('parents')->get(), + ]; + } - public function render() + public function render(): \Illuminate\Contracts\View\View { - return view('livewire.pedigree-chart'); + return view(static::$view, $this->getData()); } public function initializeChart() { - $this->dispatchBrowserEvent('initializeChart', ['people' => $this->people->toJson()]); + $this->dispatchBrowserEvent('initializeChart', ['people' => $this->getData()['people']->toJson()]); } public function zoomIn()
app/Filament/Widgets/DescendantChartWidget.php
Update the `DescendantChartWidget` to use Filament 3 conventions.
--- +++ @@ -1,22 +1,22 @@ <?php namespace App\Filament\Widgets; -// namespace App\Http\Livewire; use App\Models\Person; use Filament\Widgets\Widget; -// use Livewire\Livewire; class DescendantChartWidget extends Widget { - protected static string $view = 'livewire.descendant-chart-component'; + protected static string $view = 'filament.widgets.descendant-chart-widget'; - public $descendantsData = []; - - public function mount() + public function getData(): array { $rawData = Person::all()->toArray(); - $this->descendantsData = $this->processDescendantData($rawData); + $descendantsData = $this->processDescendantData($rawData); + + return [ + 'descendantsData' => $descendantsData, + ]; } private function processDescendantData($data) @@ -31,6 +31,6 @@ public function render(): \Illuminate\Contracts\View\View { - return view(static::$view, ['descendantsData' => $this->descendantsData]); + return view(static::$view, $this->getData()); } }
resources/views/livewire/fan-chart-component.blade.php
Update the `fan-chart-component` Blade view to use the updated Livewire component.
--- +++ @@ -1,16 +1,16 @@ -@livewire('fan-chart-component') -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8"> - <meta name="viewport" content="width=device-width, initial-scale=1.0"> - <title>Fan Chart</title> - <script src="https://d3js.org/d3.v6.min.js"></script> - @livewireStyles -</head> -<body> - <div id="fanChartContainer"></div> - <script src="{{ asset('js/fan-chart.js') }}"></script> - @livewireScripts -</body> -</html> +<x-filament::widget class="filament-fan-chart-widget"> + <x-filament::card> + <div id="fanChartContainer"></div> + </x-filament::card> + + @push('scripts') + <script src="https://d3js.org/d3.v6.min.js"></script> + <script src="{{ asset('js/fan-chart.js') }}"></script> + <script> + document.addEventListener('DOMContentLoaded', function () { + const people = @json($people); + initializeFanChart(people); + }); + </script> + @endpush +</x-filament::widget>
resources/views/livewire/pedigree-chart.blade.php
Update the `pedigree-chart` Blade view to use the updated Livewire component.
--- +++ @@ -1,50 +1,49 @@ -@livewire('pedigree-chart') -<div id="pedigree-chart-container"> - <!-- Chart will be rendered inside this div --> -</div> +<x-filament::widget class="filament-pedigree-chart-widget"> + <x-filament::card> + <div id="pedigree-chart-container"> + <!-- Chart will be rendered inside this div --> + </div> + </x-filament::card> -@push('scripts') -<script src="{{ asset('js/d3.min.js') }}"></script> -<script> - document.addEventListener('DOMContentLoaded', function () { - window.addEventListener('initializeChart', event => { - const peopleData = JSON.parse(event.detail.people); - initializePedigreeChart(peopleData); - }); - - function initializePedigreeChart(peopleData) { - const container = d3.select('#pedigree-chart-container'); - const width = 800; - const height = 600; - - const svg = container.append('svg') - .attr('width', width) - .attr('height', height); - - // Render pedigree chart using peopleData - // ... - } - - @this.on('zoomIn', () => { - // Implement zoom in logic - // ... - }); - - @this.on('zoomOut', () => { - // Implement zoom out logic - // ... - }); - - @this.on('pan', direction => { - // Implement panning logic based on direction - // ... - }); - }); -</script> -@endpush + @push('scripts') + <script src="{{ asset('js/d3.min.js') }}"></script> + <script> + document.addEventListener('DOMContentLoaded', function () { + const peopleData = @json($people); + initializePedigreeChart(peopleData); -@once -@push('styles') -<link rel="stylesheet" href="{{ asset('css/pedigree-chart.css') }}"> -@endpush -@endonce + function initializePedigreeChart(peopleData) { + const container = d3.select('#pedigree-chart-container'); + const width = 800; + const height = 600; + + const svg = container.append('svg') + .attr('width', width) + .attr('height', height); + + // Render pedigree chart using peopleData + // ... + } + + @this.on('zoomIn', () => { + // Implement zoom in logic + // ... + }); + + @this.on('zoomOut', () => { + // Implement zoom out logic + // ... + }); + + @this.on('pan', direction => { + // Implement panning logic based on direction + // ... + }); + }); + </script> + @endpush + + @push('styles') + <link rel="stylesheet" href="{{ asset('css/pedigree-chart.css') }}"> + @endpush +</x-filament::widget>
resources/views/livewire/descendant-chart-component.blade.php
Update the `descendant-chart-component` Blade view to use the updated Livewire component.
--- +++ @@ -1,39 +1,46 @@ - @livewire('descendant-chart-component') +<x-filament::widget class="filament-descendant-chart-widget"> + <x-filament::card> + <div id="descendant-chart-container"></div> + </x-filament::card> - <script> - document.addEventListener('livewire:load', function () { - const data = @json($descendantsData); + @push('scripts') + <script src="https://d3js.org/d3.v6.min.js"></script> + <script> + document.addEventListener('DOMContentLoaded', function () { + const data = @json($descendantsData); - /** - * Renders the descendant chart using the provided data. - * - * @param {Array} data - The data used to render the chart. - */ -function renderDescendantChart(data) { - const container = d3.select('#descendant-chart-container'); - const width = 960; - const height = 500; + /** + * Renders the descendant chart using the provided data. + * + * @param {Array} data - The data used to render the chart. + */ + function renderDescendantChart(data) { + const container = d3.select('#descendant-chart-container'); + const width = 960; + const height = 500; - const svg = container.append('svg') - .attr('width', width) - .attr('height', height) - .attr('class', 'shadow-lg'); + const svg = container.append('svg') + .attr('width', width) + .attr('height', height) + .attr('class', 'shadow-lg'); - const nodes = svg.selectAll('circle') - .data(data) - .enter() - .append('g') - .attr('transform', (d, i) => `translate(${i * 100 + 50}, ${height / 2})`); + const nodes = svg.selectAll('circle') + .data(data) + .enter() + .append('g') + .attr('transform', (d, i) => `translate(${i * 100 + 50}, ${height / 2})`); - nodes.append('circle') - .attr('r', 40) - .attr('class', 'fill-current text-blue-500'); - - nodes.append('text') - .attr('dy', 5) - .text(d => d.name); - } + nodes.append('circle') + .attr('r', 40) + .attr('class', 'fill-current text-blue-500'); - renderDescendantChart(data); - }); - </script> + nodes.append('text') + .attr('dy', 5) + .text(d => d.name); + } + + renderDescendantChart(data); + }); + </script> + @endpush +</x-filament::widget>
app/Filament/Pages/FanChartPage.php
Update the `FanChartPage` to use the correct Filament 3 conventions.
--- +++ @@ -2,28 +2,28 @@ namespace App\Filament\Pages; +use App\Filament\Widgets\FanChartWidget; use Filament\Pages\Page; -use Livewire\Livewire; class FanChartPage extends Page { - protected static string $view = 'filament.pages.fan-chart'; - protected static ?string $navigationIcon = 'heroicon-o-chart-pie'; protected static ?string $navigationGroup = 'Reports'; protected static ?int $navigationSort = 0; - protected static string $title = 'Fan Chart'; - - public function mount(): void - { - Livewire::mount(\App\Http\Livewire\FanChart::class); - } + protected static string $view = 'filament.pages.fan-chart'; protected function getHeading(): string { - return static::$title; + return 'Fan Chart'; + } + + protected function getWidgets(): array + { + return [ + FanChartWidget::class, + ]; } }
resources/views/filament/pages/descendant-chart.blade.php
Update the `descendant-chart` page to include the updated chart widgets.
--- +++ @@ -1,8 +1,8 @@ -<x-filament-panels::page> - {{-- <livewire:pedigree-chart /> - <livewire:fan-chart-component /> - <livewire:descendant-chart-component /> --}} - {{-- <livewire:daboville-report /> --}} - - <livewire:descendant-chart-component /> -</x-filament-panels::page> +<x-filament::page> + <x-filament::widgets :widgets="[ + \App\Filament\Widgets\PedigreeChartWidget::class, + \App\Filament\Widgets\FanChartWidget::class, + \App\Filament\Widgets\DescendantChartWidget::class, + ]"> + </x-filament::widgets> +</x-filament::page>
Your changes have been successfully made to the branch sweep/make_sure_charts_such_as_fan_chart_desce. I have validated these changes using a syntax checker and a linter.
sweep/make_sure_charts_such_as_fan_chart_desce
[!TIP] To recreate the pull request, edit the issue title or description.
This is an automated message generated by Sweep AI.
🚀 Here's the PR! #655
Actions
Step 1: 🔎 Searching
Here are the code search results. I'm now analyzing these search results to write the PR.
Relevant files (click to expand). Mentioned files will always appear here.
https://github.com/liberu-genealogy/genealogy-laravel/blob/76ac447fb74dd29c47d6ebe0eec506026a4d097a/app/Http/Livewire/FanChart.php#L1-L15 https://github.com/liberu-genealogy/genealogy-laravel/blob/76ac447fb74dd29c47d6ebe0eec506026a4d097a/app/Http/Livewire/PedigreeChart.php#L1-L50 https://github.com/liberu-genealogy/genealogy-laravel/blob/76ac447fb74dd29c47d6ebe0eec506026a4d097a/app/Filament/Widgets/DescendantChartWidget.php#L1-L35 https://github.com/liberu-genealogy/genealogy-laravel/blob/76ac447fb74dd29c47d6ebe0eec506026a4d097a/resources/views/livewire/fan-chart-component.blade.php#L1-L15 https://github.com/liberu-genealogy/genealogy-laravel/blob/76ac447fb74dd29c47d6ebe0eec506026a4d097a/resources/views/livewire/pedigree-chart.blade.php#L1-L49 https://github.com/liberu-genealogy/genealogy-laravel/blob/76ac447fb74dd29c47d6ebe0eec506026a4d097a/resources/views/livewire/descendant-chart-component.blade.php#L1-L74 https://github.com/liberu-genealogy/genealogy-laravel/blob/76ac447fb74dd29c47d6ebe0eec506026a4d097a/app/Filament/Widgets/FanChartWidget.php#L1-L24 https://github.com/liberu-genealogy/genealogy-laravel/blob/76ac447fb74dd29c47d6ebe0eec506026a4d097a/app/Filament/Widgets/PedigreeChartWidget.php#L1-L24 https://github.com/liberu-genealogy/genealogy-laravel/blob/76ac447fb74dd29c47d6ebe0eec506026a4d097a/app/Filament/Pages/FanChartPage.php#L1-L28 https://github.com/liberu-genealogy/genealogy-laravel/blob/76ac447fb74dd29c47d6ebe0eec506026a4d097a/resources/views/filament/pages/descendant-chart.blade.php#L1-L7 https://github.com/liberu-genealogy/genealogy-laravel/blob/76ac447fb74dd29c47d6ebe0eec506026a4d097a/app/Providers/FilamentServiceProvider.php#L1-L28 https://github.com/liberu-genealogy/genealogy-laravel/blob/76ac447fb74dd29c47d6ebe0eec506026a4d097a/resources/views/henry-report-page.blade.php#L1-L11 https://github.com/liberu-genealogy/genealogy-laravel/blob/76ac447fb74dd29c47d6ebe0eec506026a4d097a/resources/views/filament/resources/gedcom-resource/pages/gedcom.blade.php#L1-L5 https://github.com/liberu-genealogy/genealogy-laravel/blob/76ac447fb74dd29c47d6ebe0eec506026a4d097a/resources/views/custom-filament-base-page.blade.php#L1-L9Step 2: ⌨️ Coding
app/Http/Livewire/FanChart.php
app/Http/Livewire/PedigreeChart.php
app/Filament/Widgets/DescendantChartWidget.php
resources/views/livewire/fan-chart-component.blade.php
resources/views/livewire/pedigree-chart.blade.php
resources/views/livewire/descendant-chart-component.blade.php
app/Filament/Pages/FanChartPage.php
resources/views/filament/pages/descendant-chart.blade.php
Step 3: 🔄️ Validating
Your changes have been successfully made to the branch
sweep/make_sure_charts_such_as_fan_chart_desce
. I have validated these changes using a syntax checker and a linter.This is an automated message generated by Sweep AI.