Skip to content

Commit

Permalink
v3.4.16 (#1897)
Browse files Browse the repository at this point in the history
## [v3.4.16] - 2024-08-27
### New Features
- Add icon column by @lrljoe in #1902
- Enable/Disable Tools/Toolbar by @lrljoe in #1896

### Bug Fixes
- Fix has actions by @lrljoe in #1901
- Use Computed Properties By Default by @lrljoe in #1898

### Tweaks
- PHPStan - Config File Update and Baseline by @lrljoe in #1903
  • Loading branch information
lrljoe authored Aug 27, 2024
1 parent d140f39 commit c576c28
Show file tree
Hide file tree
Showing 32 changed files with 807 additions and 42 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

All notable changes to `laravel-livewire-tables` will be documented in this file

## [v3.4.16] - 2024-08-27
### New Features
- Add icon column by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1902
- Enable/Disable Tools/Toolbar by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1896

### Bug Fixes
- Fix has actions by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1901
- Use Computed Properties By Default by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1898

### Tweaks
- PHPStan - Config File Update and Baseline by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1903

## [v3.4.15] - 2024-08-25
### New Features
- BooleanColumn - Toggleable Callback by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1892
Expand Down
Binary file not shown.
87 changes: 87 additions & 0 deletions docs/column-types/icon_column.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
---
title: Icon Columns (beta)
weight: 10
---

Icon columns provide a way to display icons in your table without having to use `format()` or partial views.

### setIcon
setIcon requires a valid path to an SVG (Directly or via a Library), it receives the $row, and $value (if available) to help you customise which icon to use
```php
IconColumn::make('Icon', 'status')
->setIcon(function ($row, $value) {
if($value == 1) {
return "heroicon-o-check-circle";
}
else
{
return "heroicon-o-x-circle";
}
}),
```

### attributes
Attributes receives the $row, and $value (if available) to help you customise which attributes to apply, you may pass both classes, and other SVG specific attributes.
```php
IconColumn::make('Icon', 'status')
->setIcon(function ($row, $value) { if($value == 1) { return "heroicon-o-check-circle"; } else { return "heroicon-o-x-circle"; } })
->attributes(function ($row, $value) {
if($value == 1) {
return [
'class' => 'w-6 h-6',
'stroke' => '#008000'
];
}
else
{
return [
'class' => 'w-3 h-3',
'stroke' => '#FF0000'
];
}
}),
```

For example:
### Example
```php
IconColumn::make('Icon', 'status')
->setIcon(function ($row, $value) { if($value == 1) { return "heroicon-o-check-circle"; } else { return "heroicon-o-x-circle"; } })
->attributes(function ($row, $value) {
if($value == 3) {
return [
'class' => 'w-3 h-3',
'stroke' => '#008000'
];
}
else if($value == 2) {
return [
'class' => 'w-3 h-3',
'stroke' => '#0000FF'
];
}
else
{
return [
'class' => 'w-3 h-3',
'stroke' => '#FF0000'
];
}
}),
```

Please also see the following for other available methods:
<ul>
<li>
<a href="https://rappasoft.com/docs/laravel-livewire-tables/v3/columns/available-methods">Available Methods</a>
</li>
<li>
<a href="https://rappasoft.com/docs/laravel-livewire-tables/v3/columns/column-selection">Column Selection</a>
</li>
<li>
<a href="https://rappasoft.com/docs/laravel-livewire-tables/v3/columns/secondary-header">Secondary Header</a>
</li>
<li>
<a href="https://rappasoft.com/docs/laravel-livewire-tables/v3/columns/footer">Footer</a>
</li>
</ul>
2 changes: 1 addition & 1 deletion docs/column-types/image_columns.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Image Columns
weight: 10
weight: 11
---

Image columns provide a way to display images in your table without having to use `format()` or partial views:
Expand Down
2 changes: 1 addition & 1 deletion docs/column-types/link_columns.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Link Columns
weight: 11
weight: 12
---

Link columns provide a way to display HTML links in your table without having to use `format()` or partial views:
Expand Down
2 changes: 1 addition & 1 deletion docs/column-types/livewire_component_column.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Livewire Component (beta)
weight: 12
weight: 13
---

Livewire Component Columns allow for the use of a Livewire Component as a Column.
Expand Down
2 changes: 1 addition & 1 deletion docs/column-types/sum_column.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Sum Columns (beta)
weight: 13
weight: 14
---

Sum columns provide an easy way to display the "Sum" of a field on a relation.
Expand Down
2 changes: 1 addition & 1 deletion docs/column-types/view_component_column.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: View Component Columns
weight: 14
weight: 15
---

View Component columns let you specify a component name and attributes and provide attributes to the View Component. This will render the View Component in it's entirety.
Expand Down
2 changes: 1 addition & 1 deletion docs/column-types/wire_link_column.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Wire Link Column (beta)
weight: 15
weight: 16
---

WireLink columns provide a way to display Wired Links in your table without having to use `format()` or partial views, with or without a Confirmation Message
Expand Down
3 changes: 3 additions & 0 deletions docs/columns/other-column-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ weight: 4
<li>
<a href="https://rappasoft.com/docs/laravel-livewire-tables/v3/column-types/date_columns">Date Columns</a>
</li>
<li>
[Icon Columns (Beta)](../column-types/icon_columns)
</li>
<li>
<a href="https://rappasoft.com/docs/laravel-livewire-tables/v3/column-types/image_columns">Image Columns</a>
</li>
Expand Down
59 changes: 59 additions & 0 deletions docs/misc/tools.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
title: Tools
weight: 9
---

The Table offers additional configuration to show/hide the Tools/Toolbar sections:
## Tools
Contains:
- Filter Pills
- Sorting Pills
- The Toolbar

## Toolbar
Contains:
- Actions (if set to Toolbar)
- Column Select dropdown
- Configurable Areas for Toolbar
- Filters Button/Dropdown/Popover
- Pagination dropdown
- Reorder Button
- Search Input

## Component Available Methods

### setToolsEnabled
The Default Behaviour, Tools Are Enabled. But will only be rendered if there are available/enabled elements. If the Toolbar is enabled, this takes into account any Toolbar elements that are present.
```php
public function configure(): void
{
$this->setToolsEnabled();
}
```

### setToolsDisabled
Disables the Tools section, this includes the Toolbar, and Sort/Filter pills
```php
public function configure(): void
{
$this->setToolsDisabled();
}
```

### setToolBarEnabled
The Default Behaviour, ToolBar is Enabled. But will only be rendered if there are available/enabled elements
```php
public function configure(): void
{
$this->setToolBarEnabled();
}
```

### setToolBarDisabled
Disables the Toolbar, which contains the Reorder, Filters, Search, Column Select, Pagination buttons/options. Does not impact the Filter/Sort pills (if enabled)
```php
public function configure(): void
{
$this->setToolBarDisabled();
}
```
76 changes: 76 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
parameters:
ignoreErrors:
-
message: "#^Offset '1' on array\\<string, non\\-empty\\-array\\<int\\<0, max\\>, mixed\\>\\> in empty\\(\\) does not exist\\.$#"
count: 1
path: src/DataTableComponent.php

-
message: "#^Offset '99' on array\\<string, non\\-empty\\-array\\<int\\<0, max\\>, mixed\\>\\> in isset\\(\\) does not exist\\.$#"
count: 1
path: src/DataTableComponent.php

-
message: "#^Offset '99' on non\\-empty\\-array\\<1\\|string, array\\<int\\<0, max\\>, mixed\\>\\> in isset\\(\\) does not exist\\.$#"
count: 1
path: src/DataTableComponent.php

-
message: "#^Property Illuminate\\\\Database\\\\Query\\\\Builder\\:\\:\\$joins \\(array\\) on left side of \\?\\? is not nullable\\.$#"
count: 1
path: src/DataTableComponent.php

-
message: "#^Property Rappasoft\\\\LaravelLivewireTables\\\\DataTableComponent\\:\\:\\$model has no type specified\\.$#"
count: 1
path: src/DataTableComponent.php

-
message: "#^Unsafe usage of new static\\(\\)\\.$#"
count: 1
path: src/Views/Action.php

-
message: "#^Unsafe usage of new static\\(\\)\\.$#"
count: 1
path: src/Views/Column.php

-
message: "#^Unsafe usage of new static\\(\\)\\.$#"
count: 1
path: src/Views/Filter.php

-
message: "#^Parameter \\#1 \\$callback of method Illuminate\\\\Support\\\\Collection\\<int,string\\>\\:\\:filter\\(\\) expects \\(callable\\(string, int\\)\\: bool\\)\\|null, Closure\\(mixed\\)\\: int\\<0, max\\> given\\.$#"
count: 1
path: src/Views/Filters/MultiSelectDropdownFilter.php

-
message: "#^Unable to resolve the template type TMapWithKeysKey in call to method Illuminate\\\\Support\\\\Collection\\<\\(int\\|string\\),mixed\\>\\:\\:mapWithKeys\\(\\)$#"
count: 1
path: src/Views/Filters/MultiSelectDropdownFilter.php

-
message: "#^Unable to resolve the template type TMapWithKeysValue in call to method Illuminate\\\\Support\\\\Collection\\<\\(int\\|string\\),mixed\\>\\:\\:mapWithKeys\\(\\)$#"
count: 1
path: src/Views/Filters/MultiSelectDropdownFilter.php

-
message: "#^Parameter \\#1 \\$callback of method Illuminate\\\\Support\\\\Collection\\<int,string\\>\\:\\:filter\\(\\) expects \\(callable\\(string, int\\)\\: bool\\)\\|null, Closure\\(mixed\\)\\: int\\<0, max\\> given\\.$#"
count: 1
path: src/Views/Filters/MultiSelectFilter.php

-
message: "#^Parameter \\#1 \\$callback of method Illuminate\\\\Support\\\\Collection\\<int,string\\>\\:\\:filter\\(\\) expects \\(callable\\(string, int\\)\\: bool\\)\\|null, Closure\\(mixed\\)\\: int\\<0, max\\> given\\.$#"
count: 1
path: src/Views/Filters/NumberRangeFilter.php

-
message: "#^Unable to resolve the template type TMapWithKeysKey in call to method Illuminate\\\\Support\\\\Collection\\<\\(int\\|string\\),mixed\\>\\:\\:mapWithKeys\\(\\)$#"
count: 1
path: src/Views/Filters/SelectFilter.php

-
message: "#^Unable to resolve the template type TMapWithKeysValue in call to method Illuminate\\\\Support\\\\Collection\\<\\(int\\|string\\),mixed\\>\\:\\:mapWithKeys\\(\\)$#"
count: 1
path: src/Views/Filters/SelectFilter.php
13 changes: 2 additions & 11 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
includes:
- vendor/larastan/larastan/extension.neon
- phpstan-baseline.neon

parameters:
paths:
Expand All @@ -14,14 +15,4 @@ parameters:
reportUnmatchedIgnoredErrors: false
ignoreErrors:
- identifier: missingType.generics
- identifier: missingType.iterableValue
- '#Property Rappasoft\\LaravelLivewireTables\\DataTableComponent\:\:\$model has no type specified#'
- '#Unable to resolve the template type TMapWithKeysKey in call to method Illuminate\\Support\\Collection#'
- '#Unable to resolve the template type TMapWithKeysValue in call to method Illuminate\\Support\\Collection#'
- '#Access to an undefined property Rappasoft\\LaravelLivewireTables\\Views\\Column\:\:\$view#'
- "#Unsafe usage of new static#"
- '#on array\<string, non-empty-array\<int\<0, max\>, mixed\>\> in empty\(\) does not exist.#'
- '#on array<string, non-empty-array<int<0, max>, mixed>> in isset\(\) does not exist#'
- '#on non-empty-array<1\|string, array<int<0, max>, mixed>> in isset\(\) does not exist.#'
- '#\$callback of method Illuminate\\Support\\Collection<int,string>::filter\(\) expects \(callable\(string, int\): bool\)\|null, Closure\(mixed\): int<0, max> given.#'
- '#Property Illuminate\\Database\\Query\\Builder\:\:\$joins \(array\) on left side of \?\? is not nullable.#'
- identifier: missingType.iterableValue
10 changes: 0 additions & 10 deletions resources/views/components/tools/toolbar.blade.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
@aware(['component', 'tableName','isTailwind','isBootstrap'])
@props([])

@if ($this->hasConfigurableAreaFor('before-toolbar'))
@include($this->getConfigurableAreaFor('before-toolbar'), $this->getParametersForConfigurableArea('before-toolbar'))
@endif

<div @class([
'd-md-flex justify-content-between mb-3' => $this->isBootstrap,
'md:flex md:justify-between mb-4 px-4 md:p-0' => $this->isTailwind,
Expand Down Expand Up @@ -90,9 +86,3 @@
<x-livewire-tables::tools.toolbar.items.filter-slidedown />
@endif


@if ($this->hasConfigurableAreaFor('after-toolbar'))
<div x-cloak x-show="!currentlyReorderingStatus" >
@include($this->getConfigurableAreaFor('after-toolbar'), $this->getParametersForConfigurableArea('after-toolbar'))
</div>
@endif
10 changes: 9 additions & 1 deletion resources/views/datatable.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,23 @@
@include($this->getConfigurableAreaFor('before-tools'), $this->getParametersForConfigurableArea('before-tools'))
@endif

@if($this->shouldShowTools)
<x-livewire-tables::tools>
@if ($this->showSortPillsSection)
<x-livewire-tables::tools.sorting-pills />
@endif
@if($this->showFilterPillsSection)
<x-livewire-tables::tools.filter-pills />
@endif
<x-livewire-tables::tools.toolbar />

@includeWhen($this->hasConfigurableAreaFor('before-toolbar'), $this->getConfigurableAreaFor('before-toolbar'), $this->getParametersForConfigurableArea('before-toolbar'))
@if($this->shouldShowToolBar)
<x-livewire-tables::tools.toolbar />
@endif
@includeWhen($this->hasConfigurableAreaFor('after-toolbar'), $this->getConfigurableAreaFor('after-toolbar'), $this->getParametersForConfigurableArea('after-toolbar'))

</x-livewire-tables::tools>
@endif

<x-livewire-tables::table>

Expand Down
7 changes: 7 additions & 0 deletions resources/views/includes/columns/icon.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div class="livewire-tables-columns-icon">
@svg(
$icon,
$classes,
$attributes,
)
</div>
2 changes: 1 addition & 1 deletion src/Traits/ComponentUtilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ trait ComponentUtilities

protected array $extraWithAvgs = [];

protected bool $useComputedProperties = false;
protected bool $useComputedProperties = true;

/**
* Set any configuration options
Expand Down
Loading

0 comments on commit c576c28

Please sign in to comment.