diff --git a/CHANGELOG.md b/CHANGELOG.md index 27037e489..87d92ccc4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,39 +2,29 @@ All notable changes to `laravel-livewire-tables` will be documented in this file -## [Unreleased] - 3.x setTrAttributes +## [Unreleased] - 3.x Amends +- Amending Documentation for Reordering - Adding capabilities & tests for setTrAttributes - -## [Unreleased] - 3.x Fixes for reordering striping - Force calculation of even/odd only once in reorder mode - Call internal method for reordering, and pass to configured method to process - -## [Unreleased] - 3.x - Updates to Injection Methods - Amend AutoInjection/FrontendAsset to ensure it returns the original content correctly - Remove errant disabling of Blade Directives when disabling auto-injection - Amended in-line config documentation - -## [Unreleased] - 3.x - setSearchFieldAttributes - Add setSearchFieldAttributes() and getSearchFieldAttributes() - -## [Unreleased] - 3.x - Missing Tests - -## [Unreleased] - 3.x - Missing pagination tests - Add missing pagination tests - -## [Unreleased] - 3.x - Beta Fixes (beta-1) - Removal of setSearchLazy - Fix for setSearchDebounce +- Fix publishing of views +- Fix for Bulk Actions dropdown not working in Bootstrap +- Fix for Column Select "Select All" not consistently updating +- Fix for lazy loading of table +- Fix for ColumnSelect falling out of sync, displaying unselectable colums, or persisting cols in query that are not selected - Add setSearchBlur() - Add setSearchThrottle() -- Fix publishing of views - Add publish translations - Add prependColumns() and appendColumns() functions - Add documentation for setSearchPlaceholder() -- Fix for Bulk Actions dropdown not working in Bootstrap -- Fix for Column Select "Select All" not consistently updating -- Add fix for lazy loading of table -- Fix for ColumnSelect falling out of sync, displaying unselectable colums, or persisting cols in query that are not selected + - Add setExcludeDeselectedColumnsFromQueryEnabled and setExcludeDeselectedColumnsFromQueryDisabled methods to configure() ## [Unreleased] - 3.x (beta-0) @@ -1000,4 +990,4 @@ Ground Up Rebuild [0.1.4]: https://github.com/rappasoft/laravel-livewire-tables/compare/v0.1.3...v0.1.4 [0.1.3]: https://github.com/rappasoft/laravel-livewire-tables/compare/v0.1.2...v0.1.3 [0.1.2]: https://github.com/rappasoft/laravel-livewire-tables/compare/v0.1.1...v0.1.2 -[0.1.1]: https://github.com/rappasoft/laravel-livewire-tables/compare/v0.1.0...v0.1.1 +[0.1.1]: https://github.com/rappasoft/laravel-livewire-tables/compare/v0.1.0...v0.1.1 \ No newline at end of file diff --git a/docs/reordering/available-methods.md b/docs/reordering/available-methods.md index 1e8fb96c5..101848599 100644 --- a/docs/reordering/available-methods.md +++ b/docs/reordering/available-methods.md @@ -123,7 +123,7 @@ public function configure(): void ## setReorderMethod -Set the method that will be called when a row is moved. (Default is `reorder`.) +Set the method that will be called when the "Save" button is clicked. (Default is `reorder`.) ```php public function configure(): void diff --git a/docs/reordering/introduction.md b/docs/reordering/introduction.md index 0a281d5a9..38550b346 100644 --- a/docs/reordering/introduction.md +++ b/docs/reordering/introduction.md @@ -7,6 +7,8 @@ The previous iteration utilised third-party Sortable plugins, which are not requ ## An update about reordering -Version 2.0 returned all rows for sorting. In version 3.0, you will be able to sort with the items on the currently visible page, which allows for sorting on larger tables. - If you have a large data set to sort, then it is recommended that you create a minimal table instance with only the required columns for performance reasons. + +The field keys used in the reorder() function have been updated, and allow for easier upserting/reuse of reorder code. + +The reorder will not be saved until you click the "Save" button. diff --git a/docs/reordering/saving.md b/docs/reordering/saving.md index 1806e90cc..16131f10b 100644 --- a/docs/reordering/saving.md +++ b/docs/reordering/saving.md @@ -10,10 +10,27 @@ You will receive a multi-dimensional array, containing an array item per record, It is recommended that you perform some validation before bulk updating data, but it is in the correct format to perform upserts. ```php -public function reorder($items): void +public function reorder(array $items): void { + // $item[$this->getPrimaryKey()] ensures that the Primary Key is used to find the User + // 'sort' is the name of your "sort" field in your database + // $item[$this->getDefaultReorderColumn()] retrieves the field, as defined in setDefaultReorderSort('FIELD', 'ORDER') + foreach ($items as $item) { - User::find((int)$item['value'])->update(['sort' => (int)$item['order']]); + User::find($item[$this->getPrimaryKey()])->update(['sort' => (int)$item[$this->getDefaultReorderColumn()]]); } } + ``` + +If you have defined both the Primary Key, and the Order Column, and the fields match your database, then you could use an upsert(). Keep in mind that an upsert does not go through validation, and you should exercise caution with this approach +```php +public function reorder(array $items): void +{ + // First value is the array of items + // Second value should be the unique id (set in setPrimaryKey()) + // Third value should be the field set in setDefaultReorderSort('FIELD', 'ORDER') + User::upsert($items, [$this->getPrimaryKey()], [$this->getDefaultReorderColumn()]); +} + +``` \ No newline at end of file diff --git a/docs/reordering/setup.md b/docs/reordering/setup.md index fcebde426..5d7be6d93 100644 --- a/docs/reordering/setup.md +++ b/docs/reordering/setup.md @@ -18,7 +18,7 @@ public function configure(): void ## Specify your reorder method -By default the method that will be called when a row is moved is `reorder`. +By default the method that will be called when the save button is clicked is `reorder`. If you want to change that: