Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fixes #531

Open
wants to merge 51 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
e84be27
wip
marksalmon Jan 6, 2022
73e677b
wip
marksalmon Jan 6, 2022
653abb6
wip
marksalmon Jan 6, 2022
073688a
wip
marksalmon Jan 6, 2022
3f9566b
Apply fixes from StyleCI (#374)
marksalmon Jan 6, 2022
5a60a95
bugfix
marksalmon Jan 7, 2022
2696ff2
Apply fixes from StyleCI
StyleCIBot Jan 7, 2022
165cf61
Merge pull request #376 from MedicOneSystems/analysis-QMRVyw
thyseus Mar 22, 2022
8ed023d
Update composer.json
marksalmon Mar 23, 2022
f22720c
Update composer.json
marksalmon Mar 23, 2022
d3559c0
fix boolean complex query
marksalmon May 18, 2022
4bfc91b
Merge branch 'relation-refactor' of https://github.com/MedicOneSystem…
marksalmon May 18, 2022
e8de7c8
try again
marksalmon May 18, 2022
966b719
Apply fixes from StyleCI
StyleCIBot Jan 7, 2022
1d4a02a
Update composer.json
marksalmon Mar 23, 2022
1cc392d
Update composer.json
marksalmon Mar 23, 2022
3558658
try again
marksalmon May 18, 2022
3fda3f4
Merge branch 'relation-refactor' of https://github.com/MedicOneSystem…
marksalmon Dec 2, 2022
7957648
Apply fixes from StyleCI (#528)
marksalmon Dec 2, 2022
b09bb9f
rebase master
marksalmon Jan 6, 2022
1749ded
wip
marksalmon Jan 6, 2022
91fc90b
wip
marksalmon Jan 6, 2022
fad8d27
wip
marksalmon Jan 6, 2022
7a0757b
Apply fixes from StyleCI (#374)
marksalmon Jan 6, 2022
7d1e3cf
bugfix
marksalmon Jan 7, 2022
73f9a77
fix boolean complex query
marksalmon May 18, 2022
0490d74
Apply fixes from StyleCI
StyleCIBot Jan 7, 2022
63233cf
try again
marksalmon May 18, 2022
101861c
Apply fixes from StyleCI
StyleCIBot Jan 7, 2022
1e5a8dc
try again
marksalmon May 18, 2022
f424715
wip
marksalmon Dec 2, 2022
b1bb0c3
Merge branch 'relation-refactor' of https://github.com/MedicOneSystem…
marksalmon Dec 2, 2022
51388ad
Apply fixes from StyleCI (#529)
marksalmon Dec 2, 2022
628c06a
wip
marksalmon Dec 2, 2022
784e245
fix pagination with complex query
marksalmon Dec 5, 2022
370d229
replace excel exporter
marksalmon Dec 20, 2022
ed3b73a
fix error as no json filter type
marksalmon Jan 15, 2023
725d419
Apply fixes from StyleCI (#560)
marksalmon Mar 21, 2023
94c5b62
remove weird checkbox stuff
marksalmon Mar 21, 2023
ff5b2e2
Merge branch 'mark-branch' of https://github.com/MedicOneSystems/live…
marksalmon Mar 21, 2023
a941d7d
update laravel-relation-joins
marksalmon Apr 9, 2023
1504918
unupdate laravel-relation-joins
marksalmon Apr 9, 2023
847143f
fix boolean query column name
marksalmon May 2, 2023
1addfdc
fix hidden column persistence
marksalmon May 15, 2023
21f56ae
fix perpage persistence
marksalmon May 15, 2023
7b62e53
dynamic hide column
marksalmon May 15, 2023
49e4232
boolean non-zero
marksalmon May 30, 2023
c04b8b8
boolean non zero column
marksalmon May 30, 2023
864cfda
wip
marksalmon May 30, 2023
5c949bd
resetSessionStoredHidden
marksalmon Dec 3, 2023
f16b8d9
Update ComplexQuery.php
marksalmon Jan 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .phpunit.result.cache

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ composer require mediconesystems/livewire-datatables
```
If you use laravel 9 first execute
```bash
composer require psr/simple-cache:^1.0 maatwebsite/excel
composer require psr/simple-cache:^1.0
```

### Optional
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
"php": "^8.0",
"illuminate/support": "^7.0|^8.0|^9.0",
"livewire/livewire": "^2.4.4",
"maatwebsite/excel": "^3.1",
"reedware/laravel-relation-joins": "^2.4|^3.0"
"reedware/laravel-relation-joins": "^2.4|^3.0",
"spatie/simple-excel": "^3.0"
},
"require-dev": {
"laravel/legacy-factories": "^1.0.4",
Expand Down
13 changes: 13 additions & 0 deletions resources/views/livewire/datatables/boolean-non-zero.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<div>
@if(filled($value))
<div class="relative group">
<x-icons.check-circle class="mx-auto text-green-600" />

<div class="z-10 mt-2 px-2 py-1 rounded-lg bg-base-100 dark:bg-base-900 dark:text-primary-200 border border-{{ $colour ?? 'gray' }}-300 shadow-xl text-{{ $colour ?? 'gray' }}-700 text-left whitespace-normal absolute hidden group-hover:block shadow-xl">
{{ $value }}
</div>
</div>
@else
<x-icons.x-circle class="mx-auto text-red-300" />
@endif
</div>
96 changes: 51 additions & 45 deletions resources/views/livewire/datatables/complex-query.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,58 +16,64 @@
@endif</span>
</div>

@if(count($this->rules[0]['content']))
<div class="my-4 px-4 py-2 bg-gray-500 whitespace-pre-wrap @if($errors->any())text-red-200 @else text-green-100 @endif rounded">{{ $this->rulesString }}@if($errors->any()) Invalid rules @endif</div>
@endif
<div>
@if(count($this->rules[0]['content']))
<div class="my-4 px-4 py-2 bg-gray-500 whitespace-pre-wrap @if($errors->any())text-red-200 @else text-green-100 @endif rounded">{{ $this->rulesString }}@if($errors->any()) Invalid rules @endif</div>
@endif
</div>

<div>@include('datatables::complex-query-group', ['rules' => $rules, 'parentIndex' => null])</div>

@if(count($this->rules[0]['content']))
@unless($errors->any())
<div class="pt-2 sm:flex w-full justify-between">
<div>
{{-- <button class="bg-blue-500 px-3 py-2 rounded text-white" wire:click="runQuery">Apply Query</button> --}}
<div>
@if(count($this->rules[0]['content']))
@unless($errors->any())
<div class="pt-2 sm:flex w-full justify-between">
<div>
{{-- <button class="bg-blue-500 px-3 py-2 rounded text-white" wire:click="runQuery">Apply Query</button> --}}
</div>
<div class="mt-2 sm:mt-0 sm:flex sm:space-x-2">
@isset($savedQueries)
<div class="flex items-center space-x-2" x-data="{
name: null,
saveQuery() {
$wire.call('saveQuery', this.name)
this.name = null
}
}">
<input x-model="name" wire:loading.attr="disabled" x-on:keydown.enter="saveQuery" placeholder="save as..." class="flex-grow px-3 py-3 border text-sm text-gray-900 leading-4 block rounded-md border-gray-300 shadow-sm focus:outline-none focus:border-blue-300 focus:ring focus:ring-blue-200 focus:ring-opacity-50" />
<button x-bind:disabled="! name" x-show="rules" x-on:click="saveQuery" class="flex items-center space-x-2 px-3 py-0.5 border border-green-400 disabled:border-gray-300 rounded-md bg-white text-green-500 disabled:text-gray-300 text-xs leading-4 font-medium uppercase tracking-wider hover:bg-green-200 disabled:hover:bg-white focus:outline-none disabled:pointer-events-none">
<span>{{ __('Save') }}</span>
<span wire:loading.remove><x-icons.check-circle class="m-2" /></span>
<span wire:loading><x-icons.cog class="animate-spin m-2" /></span>
</button>
</div>
@endisset
<button x-show="rules" wire:click="resetQuery" class="flex items-center space-x-2 px-3 border border-red-400 rounded-md bg-white text-red-500 text-xs leading-4 font-medium uppercase tracking-wider hover:bg-red-200 focus:outline-none">
<span>{{ __('Reset') }}</span>
<x-icons.x-circle class="m-2" />
</button>
</div>
</div>
<div class="mt-2 sm:mt-0 sm:flex sm:space-x-2">
@isset($savedQueries)
<div class="flex items-center space-x-2" x-data="{
name: null,
saveQuery() {
$wire.call('saveQuery', this.name)
this.name = null
}
}">
<input x-model="name" wire:loading.attr="disabled" x-on:keydown.enter="saveQuery" placeholder="save as..." class="flex-grow px-3 py-3 border text-sm text-gray-900 leading-4 block rounded-md border-gray-300 shadow-sm focus:outline-none focus:border-blue-300 focus:ring focus:ring-blue-200 focus:ring-opacity-50" />
<button x-bind:disabled="! name" x-show="rules" x-on:click="saveQuery" class="flex items-center space-x-2 px-3 py-0.5 border border-green-400 disabled:border-gray-300 rounded-md bg-white text-green-500 disabled:text-gray-300 text-xs leading-4 font-medium uppercase tracking-wider hover:bg-green-200 disabled:hover:bg-white focus:outline-none disabled:pointer-events-none">
<span>{{ __('Save') }}</span>
<span wire:loading.remove><x-icons.check-circle class="m-2" /></span>
<span wire:loading><x-icons.cog class="animate-spin m-2" /></span>
@endif
@endif
</div>

<div>
@if(count($savedQueries ?? []))
<div>
<div class="mt-8 my-4 text-xl uppercase tracking-wide font-medium leading-none">Saved Queries</div>
<div class="grid md:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4 gap-2">
@foreach($savedQueries as $saved)
<div class="flex" wire:key="{{ $saved['id'] }}">
<button wire:click="loadRules({{ json_encode($saved['rules']) }})" wire:loading.attr="disabled" class="p-2 flex-grow flex items-center space-x-2 px-3 border border-r-0 border-blue-400 rounded-md rounded-r-none bg-white text-blue-500 text-xs leading-4 font-medium uppercase tracking-wider hover:bg-blue-200 focus:outline-none">{{ $saved['name'] }}</button>
<button wire:click="deleteRules({{ $saved['id'] }})" wire:loading.attr="disabled" class="p-2 flex items-center space-x-2 px-3 border border-red-400 rounded-md rounded-l-none bg-white text-red-500 text-xs leading-4 font-medium uppercase tracking-wider hover:bg-red-200 focus:outline-none">
<x-icons.x-circle wire:loading.remove />
<x-icons.cog wire:loading class="h-6 w-6 animate-spin" />
</button>
</div>
@endisset
<button x-show="rules" wire:click="resetQuery" class="flex items-center space-x-2 px-3 border border-red-400 rounded-md bg-white text-red-500 text-xs leading-4 font-medium uppercase tracking-wider hover:bg-red-200 focus:outline-none">
<span>{{ __('Reset') }}</span>
<x-icons.x-circle class="m-2" />
</button>
@endforeach
</div>
</div>
@endif

@endif
@if(count($savedQueries ?? []))
<div>
<div class="mt-8 my-4 text-xl uppercase tracking-wide font-medium leading-none">Saved Queries</div>
<div class="grid md:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4 gap-2">
@foreach($savedQueries as $saved)
<div class="flex" wire:key="{{ $saved['id'] }}">
<button wire:click="loadRules({{ json_encode($saved['rules']) }})" wire:loading.attr="disabled" class="p-2 flex-grow flex items-center space-x-2 px-3 border border-r-0 border-blue-400 rounded-md rounded-r-none bg-white text-blue-500 text-xs leading-4 font-medium uppercase tracking-wider hover:bg-blue-200 focus:outline-none">{{ $saved['name'] }}</button>
<button wire:click="deleteRules({{ $saved['id'] }})" wire:loading.attr="disabled" class="p-2 flex items-center space-x-2 px-3 border border-red-400 rounded-md rounded-l-none bg-white text-red-500 text-xs leading-4 font-medium uppercase tracking-wider hover:bg-red-200 focus:outline-none">
<x-icons.x-circle wire:loading.remove />
<x-icons.cog wire:loading class="h-6 w-6 animate-spin" />
</button>
</div>
@endforeach
</div>
</div>
@endif
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@include('boolean')
20 changes: 20 additions & 0 deletions src/BooleanNonZeroColumn.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Mediconesystems\LivewireDatatables;

class BooleanNonZeroColumn extends Column
{
public $type = 'boolean-non-zero';
public $callback;

public function __construct()
{
$this->callback = function ($value) {
return view('datatables::boolean-non-zero', ['value' => $value]);
};

$this->exportCallback = function ($value) {
return filled($value) ? 1 : 0;
};
}
}
14 changes: 14 additions & 0 deletions src/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,20 @@ public function hide()
return $this;
}

public function hideIf($boolean)
{
$this->hidden = $boolean;

return $this;
}

public function hideUnless($boolean)
{
$this->hidden = ! $boolean;

return $this;
}

public function alignRight()
{
$this->headerAlign = 'right';
Expand Down
88 changes: 0 additions & 88 deletions src/Exports/DatatableExport.php

This file was deleted.

28 changes: 14 additions & 14 deletions src/Http/Controllers/FileExportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
use Illuminate\Support\Facades\Response;
use Illuminate\Support\Facades\Storage;

class FileExportController
{
public function handle($filename)
{
$response = Response::make(Storage::disk(config('livewire-datatables.file_export.disk') ?: config('filesystems.default'))
->get('datatables/' . $filename), 200, [
'Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'Content-Disposition' => 'inline; filename="' . $filename . '"',
'X-Vapor-Base64-Encode' => 'True',
]);
class FileExportController
{
public function handle($filename)
{
$response = Response::make(Storage::disk(config('livewire-datatables.file_export.disk') ?: config('filesystems.default'))
->get('datatables/' . $filename), 200, [
'Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'Content-Disposition' => 'inline; filename="' . $filename . '"',
'X-Vapor-Base64-Encode' => 'True',
]);

Storage::disk(config('livewire-datatables.file_export.disk') ?: config('filesystems.default'))
Storage::disk(config('livewire-datatables.file_export.disk') ?: config('filesystems.default'))
->delete('datatables/' . $filename);

return $response;
}
}
return $response;
}
}
1 change: 1 addition & 0 deletions src/Http/Livewire/ComplexQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ public function getOperands($key)
'date' => ['=', '<>', '<', '<=', '>', '>='],
'time' => ['=', '<>', '<', '<=', '>', '>='],
'boolean' => [],
'boolean-non-zero' => [],
'scope' => ['includes'],
];

Expand Down
Loading