Skip to content

Commit 27f41df

Browse files
Merge pull request #75 from ACT-Training/71-add-save-button-to-report-editor
71 add save button to report editor
2 parents 3f670f7 + 343dd7a commit 27f41df

2 files changed

Lines changed: 81 additions & 4 deletions

File tree

resources/views/report-editor.blade.php

Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class="m-4 block p-6 bg-white border border-gray-200 rounded-lg shadow dark:bg-g
33

44
@if(!$selectedColumns)
55
<div class="p-4 mb-4 text-sm text-blue-800 rounded-lg bg-blue-50 dark:bg-gray-800 dark:text-blue-400" role="alert">
6-
Please select one or more columns.
6+
<span class="font-bold">Report Builder</span> Please select one or more columns.
77
</div>
88
@endif
99

@@ -24,9 +24,19 @@ class="ms-2 text-sm font-medium text-gray-900 dark:text-gray-300">{{$column['lab
2424
@endforeach
2525
</div>
2626

27-
<div class="flex items-center gap-2 p-1 px-2 bg-gray-50 -mx-6 -mb-6 rounded-b-lg">
28-
<span class="text-sm text-gray-600">Columns</span>
29-
<button @click="open = !open">
27+
<div wire:ignore class="flex items-center gap-2 justify-between p-1 px-2 bg-gray-50 -mx-6 -mb-6 rounded-b-lg border-t border-gray-200">
28+
<button @click="open = !open" class="p-2 flex items-center gap-2 text-gray-600 hover:bg-gray-100 rounded">
29+
<svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6" viewBox="0 0 24 24" stroke-width="1.5" stroke="#2c3e50" fill="none" stroke-linecap="round" stroke-linejoin="round">
30+
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
31+
<path d="M4 6l5.5 0" />
32+
<path d="M4 10l5.5 0" />
33+
<path d="M4 14l5.5 0" />
34+
<path d="M4 18l5.5 0" />
35+
<path d="M14.5 6l5.5 0" />
36+
<path d="M14.5 10l5.5 0" />
37+
<path d="M14.5 14l5.5 0" />
38+
<path d="M14.5 18l5.5 0" />
39+
</svg>
3040
<span x-show="!open">
3141
<svg xmlns="http://www.w3.org/2000/svg"
3242
class="w-6 h-6"
@@ -45,6 +55,56 @@ class="w-6 h-6"
4555
</svg>
4656
</span>
4757
</button>
58+
<div class="flex items-center">
59+
<button
60+
x-data
61+
x-tooltip.raw="Reset"
62+
wire:key="reset-button"
63+
wire:click="resetReportBuilder" class="p-2 text-gray-600 hover:bg-gray-100 rounded">
64+
<svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6" viewBox="0 0 24 24" stroke-width="1.5" stroke="#2c3e50" fill="none" stroke-linecap="round" stroke-linejoin="round">
65+
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
66+
<path d="M15 4.55a8 8 0 0 0 -6 14.9m0 -4.45v5h-5" />
67+
<path d="M18.37 7.16l0 .01" />
68+
<path d="M13 19.94l0 .01" />
69+
<path d="M16.84 18.37l0 .01" />
70+
<path d="M19.37 15.1l0 .01" />
71+
<path d="M19.94 11l0 .01" />
72+
</svg>
73+
</button>
74+
<button
75+
x-data
76+
x-tooltip.raw="Save"
77+
wire:key="save-button"
78+
wire:click="saveReportBuilder" class="p-2 text-gray-600 hover:bg-gray-100 rounded">
79+
<svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6" viewBox="0 0 24 24" stroke-width="1.5" stroke="#2c3e50" fill="none" stroke-linecap="round" stroke-linejoin="round">
80+
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
81+
<path d="M6 4h10l4 4v10a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2" />
82+
<path d="M12 14m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0" />
83+
<path d="M14 4l0 4l-6 0l0 -4" />
84+
</svg>
85+
</button>
86+
87+
<x-popover wire:key="load-button">
88+
<x-slot name="trigger">
89+
<div
90+
x-data
91+
x-tooltip.raw="Reports"
92+
class="mt-2 p-2 text-gray-600 hover:bg-gray-100 rounded"
93+
>
94+
<x-tabler-file-download/>
95+
</div>
96+
</x-slot>
97+
98+
<x-slot name="panel">
99+
@foreach($this->reports as $report)
100+
<x-popover.menu-item wire:click="loadReportBuilder('{{ $report->uuid }}')">
101+
{{ $report->name }}
102+
</x-popover.menu-item>
103+
@endforeach
104+
</x-slot>
105+
</x-popover>
106+
107+
</div>
48108
</div>
49109
</div>
50110

src/Support/Concerns/WithReportBuilder.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
use ACTTraining\QueryBuilder\Support\Conditions\DateCondition;
1010
use ACTTraining\QueryBuilder\Support\Conditions\NumberCondition;
1111
use ACTTraining\QueryBuilder\Support\Conditions\TextCondition;
12+
use Livewire\Attributes\Validate;
1213

1314
trait WithReportBuilder
1415
{
16+
#[Validate('required|array')]
1517
public array $selectedColumns = [];
1618

1719
private function findElementByKey(array $array, $targetValue): ?array
@@ -106,4 +108,19 @@ public function buildConditions(): array
106108
return $conditions;
107109
}
108110

111+
public function resetReportBuilder(): void
112+
{
113+
$this->criteria = [];
114+
$this->selectedColumns = [];
115+
}
116+
117+
public function saveReportBuilder(): void
118+
{
119+
//
120+
}
121+
122+
public function loadReportBuilder($id): void
123+
{
124+
//
125+
}
109126
}

0 commit comments

Comments
 (0)