Skip to content

Commit 1ca2481

Browse files
v1.1
Bug fixes
1 parent 8af1c63 commit 1ca2481

File tree

7 files changed

+58
-27
lines changed

7 files changed

+58
-27
lines changed

src/Livewire/DataTable.php

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,26 @@ public function mount(
142142

143143
};
144144

145+
$this->addSearchable();
146+
147+
}
148+
149+
public function addSearchable()
150+
{
151+
foreach($this->selectedCols as $col => $value) {
152+
if($value['searchable']) {
153+
if(!in_array($col, $this->cols['searchable'])) {
154+
array_push($this->cols['searchable'], $col);
155+
}
156+
} else {
157+
if(in_array($col, $this->cols['searchable'])) {
158+
$key = array_search($col, $this->cols['searchable']);
159+
unset($this->cols['searchable'][$key]);
160+
}
161+
}
162+
}
163+
164+
//dd($this->cols['searchable']);
145165
}
146166

147167

@@ -150,11 +170,15 @@ public function reload()
150170
$this->colbox = true;
151171
//dd($this->ckeys);
152172

153-
$cscols = $this->getCache($this->ckeys['selectedCols']);
154-
$ccols = $this->getCache($this->ckeys['columns']);
173+
//$cscols = $this->getCache($this->ckeys['selectedCols']);
174+
//$ccols = $this->getCache($this->ckeys['columns']);
175+
176+
//$this->selectedCols = (empty($cscols)) ? $this->selectedCols : $cscols;
177+
//$this->columns = (empty($ccols)) ? $this->columns : $ccols;
155178

156-
$this->selectedCols = (empty($cscols)) ? $this->selectedCols : $cscols;
157-
$this->columns = (empty($ccols)) ? $this->columns : $ccols;
179+
$c = $this->initCache($this->table_name, true);
180+
if($c) $this->addSearchable();
181+
//$this->addSearchable();
158182
}
159183

160184
public function dbModal()

src/Traits/InitColumns.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ public function columnData(
176176
'editable' => $editable,
177177
'editable-options' => $ed_opt,
178178
'filterable' => $filterable,
179-
'filterable_options' => (is_null($filterableOpts)) ? '' : $filterableOpts
179+
'filterable_options' => (is_null($filterableOpts))
180+
? [] : explode(',', $filterableOpts)
180181
];
181182

182183
}

src/views/components/accordion.blade.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
<div>
2-
<div x-data="manageAccordion()" x-cloak>
1+
2+
<div id="acOutline" onclick="setBorder('acOutline')">
3+
<div x-data="{
4+
content: '<?php echo $isOpen ?>',
5+
}" x-cloak>
36
<div class="overflow-hidden bg-white rounded-md shadow-sm">
47
{{-- top --}}
58
<div class="flex items-center justify-between border-b">
@@ -33,14 +36,9 @@
3336
</div>
3437
</div>
3538
{{-- content ----------------- --}}
36-
<div x-show.transition='content' class="p-2">
39+
<div x-show.transition.opacity='content' class="p-2">
3740
{{ $slot }}
3841
</div>
3942
</div>
4043
</div>
4144
</div>
42-
<script>
43-
Alpine.data('manageAccordion', () => ({
44-
content: "<?php echo $isOpen ?>",
45-
}));
46-
</script>

src/views/components/inline-edit.blade.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
<div>
2-
<div x-data="manageInlineEdit" x-on:inlineedit.window='editbox = false'>
2+
<div x-data="manageInlineEdit()" x-on:inlineedit.window='editbox = false'>
33
<div class="relative flex items-center justify-between">
44
<div>
55
{{ $slot }}
66
</div>
77
<div x-on:click="open($refs)">
88
{{ $trigger ?? '' }}
99
</div>
10-
<div x-ref="editbox" x-show.transition.in.origin.left='editbox'
11-
class="absolute z-50 flex items-center justify-between gap-1 p-2 min-w-min {{ $formStyle == '' ? 'bg-white rounded-md shadow-lg' : $formStyle }}">
12-
<div class="{{ $formWidth }}">{{ $form ?? '' }}</div>
10+
<div style="width: 100%;"
11+
x-ref="editbox" x-show.transition.opacity='editbox'
12+
class="absolute z-50 flex items-center justify-between gap-1 p-2 min-w-min {{ $formStyle == '' ? 'bg-white rounded-md shadow-lg' : $formStyle }}">
13+
<div style="width:90%;min-width:200px" class="min-w-min">{{ $form ?? '' }}</div>
1314
<div x-on:click="editbox = false"
1415
class="px-2 text-xl bg-gray-100 rounded-lg hover:bg-gray-200">
1516
&times;
@@ -25,10 +26,11 @@ function manageInlineEdit() {
2526
open($refs) {
2627
this.editbox = true;
2728
var scr = screen.width;
28-
var offs = $refs.editbox.parentNode.offsetLeft;
29-
29+
var offs = $refs.editbox.parentNode.offsetLeft;
30+
3031
if ((scr / 2) > (scr - offs)) {
3132
$refs.editbox.style.right= 0;
33+
$refs.editbox.style.width = "100%";
3234
}
3335
},
3436
}

src/views/livewire/columns-details.blade.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<div>
2-
2+
<div class="" wire:loading>
3+
<x-btui-loader loading="true" />
4+
</div>
35
@php
46
$checkbox = 'border rounded border-gray-400';
57
@endphp

src/views/livewire/customize-columns.blade.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
<div class="p-4">
2-
<div class="flex justify-between pb-2">
3-
<div>
2+
3+
<div class="flex justify-between items-center pb-2 h-10">
4+
<div class="flex justify-start items-center gap-3">
45
<h3>Customize Columns</h3>
6+
<div class="" wire:loading >
7+
<x-btui-sloader/>
8+
</div>
59
</div>
610

711
<div class="">

src/views/livewire/data-table.blade.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
<div class="flex items-center px-4 py-2">
66
<div class="w-4/12">
7-
<h1 class="uppercase">Data Table - {{ $table }}</h1>
7+
<h1 class="uppercase">Data Table - {{ $table_name }}</h1>
88
</div>
99
<div class="w-full">
10-
<input wire:model='search' type="text" class="w-full px-4 py-1 bg-white border border-gray-300 rounded-full" placeholder="Search in {{ implode(',', $columns) }} ...">
10+
<input wire:model='search' type="text" class="w-full px-4 py-1 bg-white border border-gray-300 rounded-full" placeholder="Search in {{ implode(',', $cols['searchable']) }} ...">
1111
</div>
1212
</div>
1313

@@ -151,7 +151,7 @@
151151
@slot('form')
152152
<div class="flex items-center justify-start gap-2 ">
153153

154-
<div class="w-48">
154+
<div style="width:80%;min-width:200px;">
155155

156156
@if($selectedCols[$col]['editable'])
157157

@@ -187,7 +187,7 @@
187187
{{-- delete - options ----------------------------- --}}
188188
<td class="pr-1 bg-gray-100">
189189

190-
<x-inline-edit form-width="w-64">
190+
<x-dt-inline-edit form-width="w-64">
191191
@slot('trigger')
192192
<div class="text-red-700 hover:text-red-500">
193193
<svg xmlns="http://www.w3.org/2000/svg" class="w-4 h-4" viewBox="0 0 20 20" fill="currentColor">
@@ -201,7 +201,7 @@
201201
<x-btui-button wire:click='deleteData({{ $d->id }})' size="sm" color="light-red">Delete</x-btui-button>
202202
</div>
203203
@endslot
204-
</x-inline-edit>
204+
</x-dt-inline-edit>
205205

206206
</td>
207207
</tr>

0 commit comments

Comments
 (0)