From 04aa7bd5b7fe694ca5fc592aa6c79240cba43335 Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Tue, 3 Oct 2023 23:06:12 +0100 Subject: [PATCH] V3 Develop to V3 Master (#1382) * Beta Fixes - Publishing Views/Localizations. Beta Improvements - Search Options (#1324) * Update setSearchDebounce, add setSearchThrottle/setSearchBlur * Remove Lazy Test * Remove Lazy Tests - Update Docs * Update Views Publish Path * Add Translations Publish Option * Update ChangeLog * Add Reusable Columns * Add Tests for Prepend/Append Cols --------- Co-authored-by: lrljoe * Bulk Actions Fix - v3 (#1326) * Update setSearchDebounce, add setSearchThrottle/setSearchBlur * Remove Lazy Test * Remove Lazy Tests - Update Docs * Update Views Publish Path * Add Translations Publish Option * Update ChangeLog * Add Reusable Columns * Add Tests for Prepend/Append Cols * Column Select Fixes * Fix test * Add docs for setSearchPlaceholder * Move Filter Specific Docs ino Filter-Types * Fix styling * Remove extraneous space * Adjusting Selectable Test * Fix For BulkActions Dropdown * Fixes for ColumnSelect * Update ChangeLog * Test Fix for Selectable Columns * Remove Faulty Test --------- Co-authored-by: lrljoe * Fix Column Select - Select All state (#1333) * Fix Column Select - All * Update ChangeLog * Add NonArray setAdditionalSelects Test (#1337) * Test Additions (#1339) * Add NonArray setAdditionalSelects Test * Update for FrontendAssets Test * Fix styling --------- Co-authored-by: lrljoe * Add Third Party Tests (#1340) * Add NonArray setAdditionalSelects Test * Update for FrontendAssets Test * Add ThirdPartyScripts/Styles to Test * Fix styling --------- Co-authored-by: lrljoe * Third Party Asset Tests (#1341) * Add NonArray setAdditionalSelects Test * Update for FrontendAssets Test * Add ThirdPartyScripts/Styles to Test * Add ThirdParty Tests * Fix AutoInjection Issue * Fix 3rd party test * Set default back to remote 3rd party assets * Add CodeCov YML * Update CodeCov - 80% minimum * Add Filter Custom Pills Blade Test * Fix styling * Add formatted column test * Column - Get Formatted Contents Test * Fix styling --------- Co-authored-by: lrljoe * Lazy Loading Fix (#1355) * Add fix for lazy loading * Fix styling --------- Co-authored-by: lrljoe * Spacing fixes * v3 - Missing Tests - Pagination Related Tests (#1363) * Add missing pagination helper tests --------- Co-authored-by: lrljoe * v3 - Missing Tests - Broken Tables (Missing Primary Key/Builder) (#1362) * Add missing component visuals tests & failed tables * Update Exception Expectation * Temporary test swapping to check Exception throwing --------- Co-authored-by: lrljoe * v3 - Add setSearchFieldAttribute Options (#1361) * Add setSearchFieldAttribute Options --------- Co-authored-by: lrljoe * v3 - Column Select Fixes & Tweaks (#1360) * ColumnSelect Fixes - Phase 1 * Update "Select All" to use counts * Missing closing bracket * All Are Selected -> Move to method in Helpers * ColSelectFixes * Ensure event fires * Update ColumnsSelectedTest * Fix superfluous empty array return * Remove superfluous default return * Adjust Tests - Include Coverage For ExcludeDeselectedCols * Add Tests For AllColsSelected * Fix styling * Fixes for Deselected Cols * Fix styling * Updates to Changelog * Removing ColumnSelected Event Test - Temporary * Add default true to replace removed test * Add improved test --------- Co-authored-by: lrljoe * Fix ServiceProvider Fault (#1366) * V3 Frontend Asset Tweaks (#1371) * Check for "original" property * Adjusting order of request validations * Updates to Asset Injection Methods * Fix assertViewIs is not working (#67) Contribs By: Jackson Tong * Bundler Import Options (#1377) * Add All Option * Update Import Paths * Add minified CSS Versions * V3 Restore setTrAttributes (#1378) * Add setTrAttributes back into use * Fix styling --------- Co-authored-by: lrljoe * Update Reorder Documentation (#1381) * Update Reorder Documentation * Update ChangeLog - Merge Unreleased --------- Co-authored-by: lrljoe Co-authored-by: Anthony Rappa --- CHANGELOG.md | 28 +++++++++------------------- docs/reordering/available-methods.md | 2 +- docs/reordering/introduction.md | 6 ++++-- docs/reordering/saving.md | 21 +++++++++++++++++++-- docs/reordering/setup.md | 2 +- 5 files changed, 34 insertions(+), 25 deletions(-) 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: