Skip to content

Commit

Permalink
Merge pull request #1266 from rappasoft/develop
Browse files Browse the repository at this point in the history
v2.15
  • Loading branch information
rappasoft authored Jul 15, 2023
2 parents 77408c7 + 0109454 commit 26c596d
Show file tree
Hide file tree
Showing 22 changed files with 144 additions and 40 deletions.
5 changes: 1 addition & 4 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@ blank_issues_enabled: false
contact_links:
- name: Ask a question
url: https://github.com/rappasoft/laravel-livewire-tables/discussions/new?category=q-a
about: Ask the community for help
- name: Request a feature
url: https://github.com/rappasoft/laravel-livewire-tables/discussions/new?category=ideas
about: Share ideas for new features
about: Ask the community for help
32 changes: 32 additions & 0 deletions .github/ISSUE_TEMPLATE/featurerequest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Feature Request
description: Request a New Feature
title: "[Feature Request]: "
labels: ["feature"]
body:
- type: markdown
attributes:
value: |
We're excited to hear any ideas for new features/improvements, please complete as much of the form below as possible
- type: textarea
id: overview
attributes:
label: Overview
description: What do you want to happen?
placeholder: I would like X type of Column or Filter
validations:
required: true
- type: textarea
id: details
attributes:
label: Detailed explanation
description: Give details of how you want this to work
placeholder: When I do X I want to see Y.
validations:
required: false
- type: textarea
id: notes
attributes:
label: Notes
description: Use this field to provide any other notes, screenshots or examples that you feel might be relevant to the request.
validations:
required: false
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ All notable changes to `laravel-livewire-tables` will be documented in this file

## [Unreleased]

## [2.15.0] - 2023-07-15

- Fixes
- Re-enable capability for configuring whether to Hide/Show Bulk Actions when empty - https://github.com/rappasoft/laravel-livewire-tables/pull/1240

- Enhancements
- Allow Label Columns to be Sortable - https://github.com/rappasoft/laravel-livewire-tables/pull/1256
- Add Select All On Page Translations - https://github.com/rappasoft/laravel-livewire-tables/pull/1244
- Add Contributors Document to track Localisation contributors - https://github.com/rappasoft/laravel-livewire-tables/pull/1223

## [2.14.0] - 2023-05-18

### Changed
Expand Down Expand Up @@ -827,7 +837,8 @@ Ground Up Rebuild

- Initial release

[Unreleased]: https://github.com/rappasoft/laravel-livewire-tables/compare/v2.14.0...development
[Unreleased]: https://github.com/rappasoft/laravel-livewire-tables/compare/v2.15.0...development
[2.15.0]: https://github.com/rappasoft/laravel-livewire-tables/compare/v2.15.0...v2.14.0
[2.14.0]: https://github.com/rappasoft/laravel-livewire-tables/compare/v2.14.0...v2.13.1
[2.13.1]: https://github.com/rappasoft/laravel-livewire-tables/compare/v2.13.0...v2.13.1
[2.13.0]: https://github.com/rappasoft/laravel-livewire-tables/compare/v2.12.0...v2.13.0
Expand Down
15 changes: 15 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Core Maintainers
- [Anthony Rappa](https://github.com/rappasoft)
- [Joe McElwee](https://github.com/lrljoe)

# Localisation Contributors
| Language | Contributor(s) |
| --- | --- |
| Brazilian (BR_PT) | [irineujunior](https://github.com/irineujunior)|
| Danish (DA) | [jeppeolesen](https://github.com/jeppeolesen) |
| Dutch (NL) | [siebsie23](https://github.com/siebsie23) & [spekkie2002](https://github.com/spekkie2002)|
| Finnish (FI) | [devmikromike](https://github.com/devmikromike) |
| French (FR) | [dgillier](https://github.com/dgillier) |
| Malay (MS) | [wanadri](https://github.com/wanadri) |
| Spanish (ES) | [CristhoferMF](https://github.com/CristhoferMF) |
| Ukrainian (UK) | [Oleksandr-Moik](https://github.com/Oleksandr-Moik) |
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) Anthony Rappa <rappa819@gmail.com>
Copyright (c) Anthony Rappa <anthony@rappasoft.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ Please e-mail [email protected] to report any security vulnerabilities inste
## Credits

- [Anthony Rappa](https://github.com/rappasoft)
- [lrljoe](https://github.com/lrljoe)
- [All Contributors](../../contributors)
- [Joe McElwee](https://github.com/lrljoe)
- [All Contributors](./CONTRIBUTORS.md)

## License

Expand Down
4 changes: 2 additions & 2 deletions docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ weight: 1

<section class="article_badges">
<a href="https://packagist.org/packages/rappasoft/laravel-livewire-tables"><img src="https://img.shields.io/packagist/v/rappasoft/laravel-livewire-tables.svg?style=flat-square" alt="Latest Version on Packagist"></a>
<a href="https://github.com/rappasoft/laravel-livewire-tables/actions/workflows/php-cs-fixer.yml"><img src="https://github.com/rappasoft/laravel-livewire-tables/actions/workflows/php-cs-fixer.yml/badge.svg" alt="Styling"></a>
<a href="https://github.com/rappasoft/laravel-livewire-tables/actions/workflows/pint.yml"><img src="https://github.com/rappasoft/laravel-livewire-tables/actions/workflows/pint.yml/badge.svg" alt="Styling"></a>
<a href="https://github.com/rappasoft/laravel-livewire-tables/actions/workflows/run-tests.yml"><img src="https://github.com/rappasoft/laravel-livewire-tables/actions/workflows/run-tests.yml/badge.svg" alt="Tests"></a>
<a href="https://packagist.org/packages/rappasoft/laravel-livewire-tables"><img src="https://img.shields.io/packagist/dt/rappasoft/laravel-livewire-tables.svg?style=flat-square" alt="Total Downloads"></a>
</section>

Welcome to the [Laravel Livewire Tables](https://github.com/rappasoft/laravel-livewire-tables) documentation!

I will do my best to document all features and configurations of this plugin.
We will do our best to document all features and configurations of this plugin.

Laravel Livewire Tables is a plugin built for Laravel Livewire that allows you to create simple or advanced dynamic datatables.

Expand Down
2 changes: 1 addition & 1 deletion docs/questions-and-issues.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ If you have general questions not related to any issues you may post a [discussi

If you have found a reproducable bug please create an [issue](https://github.com/rappasoft/laravel-livewire-tables/issues).

If you would like other help you can join the [slack channel](https://rappasoft.herokuapp.com/).
If you would like other help you can join the [discord channel - details here](https://github.com/rappasoft/laravel-livewire-tables/discussions/1252/).

If you've found a bug regarding security please mail [email protected] instead of using the issue tracker.
10 changes: 10 additions & 0 deletions docs/start/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ module.exports = {
};
```

## Tailwind Dark Mode
If you find that the table is consistently displaying in Dark Mode, then you will need to add the following into your tailwind.config.js configuration, keeping in mind that this **could** impact other components using dark mode!

```js
module.exports = {
darkMode: 'class', // This specifies that Tailwind should look at Class elements to determine dark mode
...
};
```

## Alpine.js Cloak

You must also make sure you have this Alpine style available globally:
Expand Down
2 changes: 1 addition & 1 deletion docs/support-me.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ title: Support Me
weight: 2
---

I invest a **lot** of time into creating [my packages](https://rappasoft.com/packages). You can support me by [sponsoring me on Github](https://github.com/sponsors/rappasoft).
I invest a **lot** of time into creating [my packages](https://rappasoft.com/packages). You can support this work by [sponsoring me on Github](https://github.com/sponsors/rappasoft). There are additional benefits at various levels!
1 change: 1 addition & 0 deletions resources/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"rows, do you want to select all": "rows, do you want to select all",
"Search": "Search",
"Select All": "Select All",
"Select All On Page": "Select All On Page",
"Showing": "Showing",
"to": "to",
"Yes": "Yes",
Expand Down
1 change: 1 addition & 0 deletions resources/lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"rows, do you want to select all": "filas, desea seleccionar todas",
"Search": "Buscar",
"Select All": "Seleccionar todo",
"Select All On Page": "Seleccionar todo en la página",
"Showing": "Mostrando",
"to": "a",
"Yes": "",
Expand Down
5 changes: 3 additions & 2 deletions resources/lang/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@
"Yes": "Ja",
"You are currently selecting all": "U selecteerde alle",
"You are not connected to the internet.": "U bent niet verbonden met het internet.",
"You have selected": "U selecteerde"
}
"You have selected": "U selecteerde",
"Select All On Page": "Alles op pagina selecteren"
}
10 changes: 5 additions & 5 deletions resources/views/components/table/th.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
$theme = $component->getTheme();
$customAttributes = $component->getThAttributes($column);
$customSortButtonAttributes = $component->getThSortButtonAttributes($column);
$direction = $column->hasField() ? $component->getSort($column->getColumnSelectName()) : null;
$direction = $column->hasField() ? $component->getSort($column->getColumnSelectName()) : $component->getSort($column->getSlug()) ?? null ;
@endphp

@if ($theme === 'tailwind')
Expand All @@ -17,11 +17,11 @@
->class(['hidden md:table-cell' => $column->shouldCollapseOnTablet()])
->except('default')
}}>
@unless ($component->sortingIsEnabled() && $column->isSortable())
@unless ($component->sortingIsEnabled() && ($column->isSortable() || $column->getSortCallback()))
{{ $column->getTitle() }}
@else
<button
wire:click="sortBy('{{ $column->getColumnSelectName() }}')"
wire:click="sortBy('{{ ($column->isSortable() ? $column->getColumnSelectName() : $column->getSlug()) }}')"
{{
$attributes->merge($customSortButtonAttributes)
->class(['flex items-center space-x-1 text-left text-xs leading-4 font-medium text-gray-500 uppercase tracking-wider group focus:outline-none dark:text-gray-400' => $customSortButtonAttributes['default'] ?? true])
Expand Down Expand Up @@ -64,12 +64,12 @@
->class(['d-none d-md-table-cell' => $column->shouldCollapseOnTablet()])
->except('default')
}}>
@unless ($component->sortingIsEnabled() && $column->isSortable())
@unless ($component->sortingIsEnabled() && ($column->isSortable() || $column->getSortCallback()))
{{ $column->getTitle() }}
@else
<div
class="d-flex align-items-center"
wire:click="sortBy('{{ $column->getColumnSelectName() }}')"
wire:click="sortBy('{{ ($column->isSortable() ? $column->getColumnSelectName() : $column->getSlug()) }}')"
style="cursor:pointer;"
>
<span>{{ $column->getTitle() }}</span>
Expand Down
6 changes: 3 additions & 3 deletions resources/views/components/tools/sorting-pills.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

@foreach($component->getSorts() as $columnSelectName => $direction)
@php
$column = $component->getColumnBySelectName($columnSelectName);
$column = $component->getColumnBySelectName($columnSelectName) ?? $component->getColumnBySlug($columnSelectName);
@endphp

@continue(is_null($column))
Expand Down Expand Up @@ -57,7 +57,7 @@ class="focus:outline-none active:outline-none"

@foreach($component->getSorts() as $columnSelectName => $direction)
@php
$column = $component->getColumnBySelectName($columnSelectName);
$column = $component->getColumnBySelectName($columnSelectName) ?? $component->getColumnBySlug($columnSelectName);
@endphp

@continue(is_null($column))
Expand Down Expand Up @@ -101,7 +101,7 @@ class="badge badge-pill badge-light"

@foreach($component->getSorts() as $columnSelectName => $direction)
@php
$column = $component->getColumnBySelectName($columnSelectName);
$column = $component->getColumnBySelectName($columnSelectName) ?? $component->getColumnBySlug($columnSelectName);
@endphp

@continue(is_null($column))
Expand Down
6 changes: 3 additions & 3 deletions resources/views/components/tools/toolbar.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class="w-full inline-flex items-center justify-center px-3 py-2 border border-gr
@endif

@if ($component->showBulkActionsDropdownAlpine())
<div x-cloak x-show="selectedItems.length > 0" class="w-full md:w-auto mb-4 md:mb-0">
<div x-cloak x-show="(selectedItems.length > 0 || alwaysShowBulkActions)" class="w-full md:w-auto mb-4 md:mb-0">
<div x-data="{ open: false, childElementOpen: false }" @keydown.window.escape="if (!childElementOpen) { open = false }"
x-on:click.away="if (!childElementOpen) { open = false }"
class="relative inline-block text-left z-10 w-full md:w-auto">
Expand Down Expand Up @@ -409,7 +409,7 @@ class="dropdown-item btn text-center">
@endif

@if ($component->showBulkActionsDropdownAlpine())
<div x-cloak x-show="selectedItems.length > 0" class="mb-3 mb-md-0">
<div x-cloak x-show="(selectedItems.length > 0 || alwaysShowBulkActions)" class="mb-3 mb-md-0">
<div class="dropdown d-block d-md-inline">
<button class="btn dropdown-toggle d-block w-100 d-md-inline" type="button"
id="{{ $component->getTableName() }}-bulkActionsDropdown" data-toggle="dropdown"
Expand Down Expand Up @@ -634,7 +634,7 @@ class="dropdown-item text-center">
@endif

@if ($component->showBulkActionsDropdownAlpine())
<div x-cloak x-show="selectedItems.length > 0" class="mb-3 mb-md-0">
<div x-cloak x-show="(selectedItems.length > 0 || alwaysShowBulkActions)" class="mb-3 mb-md-0">
<div class="dropdown d-block d-md-inline">
<button class="btn dropdown-toggle d-block w-100 d-md-inline" type="button"
id="{{ $component->getTableName() }}-bulkActionsDropdown" data-bs-toggle="dropdown"
Expand Down
21 changes: 17 additions & 4 deletions resources/views/components/wrapper.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@
paginationCurrentCount: $wire.entangle('paginationCurrentCount'),
paginationTotalItemCount: $wire.entangle('paginationTotalItemCount'),
paginationCurrentItems: $wire.entangle('paginationCurrentItems'),
@if ($component->bulkActionsAreEnabled() && $component->hasBulkActions())
alwaysShowBulkActions: {{ $component->getHideBulkActionsWhenEmptyStatus() ? 'false' : 'true' }},
selectedItems: $wire.entangle('selected').defer,
@else
selectedItems: {},
@endif
@if ($component->showBulkActionsDropdownAlpine())
toggleSelectAll() {
if (this.paginationTotalItemCount == this.selectedItems.length) {
this.clearSelected();
Expand All @@ -36,6 +34,21 @@
}
this.selectedItems = [...new Set(tempSelectedItems)];
},
@else
toggleSelectAll() {
return;
},
setAllSelected() {
return;
},
clearSelected() {
return;
},
selectAllOnPage() {
return;
},
@endif
}">
<div {{ $attributes->merge($this->getComponentWrapperAttributes()) }}
@if ($component->hasRefresh()) wire:poll{{ $component->getRefreshOptions() }} @endif
Expand Down
7 changes: 7 additions & 0 deletions src/Traits/Helpers/ColumnHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ public function getColumnBySelectName(string $qualifiedColumn): ?Column
->first();
}

public function getColumnBySlug(string $columnSlug): ?Column
{
return $this->getColumns()
->filter(fn (Column $column) => $column->isColumnBySlug($columnSlug))
->first();
}

/**
* @return array<mixed>
*/
Expand Down
13 changes: 12 additions & 1 deletion src/Traits/WithSorting.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,24 @@ public function applySorting(): Builder

return $this->getBuilder();
}
$allCols = $this->getColumns();

foreach ($this->getSorts() as $column => $direction) {
if (! in_array($direction, ['asc', 'desc'])) {
$direction = 'asc';
}
$tmpCol = $column;
$column = $this->getColumnBySelectName($tmpCol);

if (is_null($column)) {
foreach ($allCols as $cols) {
if ($cols->getSlug() == $tmpCol && $cols->hasSortCallback()) {
$this->setBuilder(call_user_func($cols->getSortCallback(), $this->getBuilder(), $direction));

continue;
}
}

if (is_null($column = $this->getColumnBySelectName($column))) {
continue;
}

Expand Down
5 changes: 5 additions & 0 deletions src/Views/Traits/Helpers/ColumnHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ public function isColumnBySelectName(string $name): bool
return $this->getColumnSelectName() === $name;
}

public function isColumnBySlug(string $slug): bool
{
return $this->getSlug() === $slug;
}

public function hasField(): bool
{
return $this->getField() !== null;
Expand Down
14 changes: 7 additions & 7 deletions src/Views/Traits/Helpers/FilterHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,13 @@ public function getCustomPosition(): string
return $this->filterPosition;
}

/**
* Returns whether the filter has a custom label blade
*/
public function hasCustomFilterLabel(): bool
{
return ! is_null($this->filterCustomLabel);
}
/**
* Returns whether the filter has a custom label blade
*/
public function hasCustomFilterLabel(): bool
{
return ! is_null($this->filterCustomLabel);
}

/**
* Returns the path to the custom filter label blade
Expand Down
6 changes: 3 additions & 3 deletions tests/Traits/Helpers/ComponentHelpersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,10 @@ public function can_get_hide_configurable_areas_when_reordering_status(): void
}

// Exists in DataTableComponentTest
// public function can_get_dataTable_fingerprint(): void
// public function can_get_dataTable_fingerprint(): void
//{
// $this->assertSame($this->defaultFingerPrintingAlgo($this->basicTable::class), $this->basicTable->getDataTableFingerprint());
// }
// $this->assertSame($this->defaultFingerPrintingAlgo($this->basicTable::class), $this->basicTable->getDataTableFingerprint());
// }

/** @test */
public function can_get_query_string_alias_and_it_will_be_the_same_as_table_name_by_default(): void
Expand Down

0 comments on commit 26c596d

Please sign in to comment.