From a4fa8d6ecfeaedc0a70c63bd4cdce99bf4842f37 Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Wed, 4 Oct 2023 02:29:48 +0100 Subject: [PATCH] V3 develop (#1384) * 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 * Update Docs - Advanced Example, Add Including Assets (#1383) --------- Co-authored-by: lrljoe Co-authored-by: Anthony Rappa --- docs/examples/advanced-example.md | 12 ++---- docs/start/commands.md | 2 +- docs/start/configuration.md | 15 +------- docs/start/including-assets.md | 64 +++++++++++++++++++++++++++++++ docs/start/optional-packages.md | 40 ------------------- docs/start/rendering.md | 2 +- 6 files changed, 71 insertions(+), 64 deletions(-) create mode 100644 docs/start/including-assets.md delete mode 100644 docs/start/optional-packages.md diff --git a/docs/examples/advanced-example.md b/docs/examples/advanced-example.md index 86fc514b7..b9c498801 100644 --- a/docs/examples/advanced-example.md +++ b/docs/examples/advanced-example.md @@ -8,16 +8,12 @@ weight: 2 namespace App\Http\Livewire; -use App\Models\Tag; -use App\Models\User; +use App\Models\{Tag,User}; use Illuminate\Database\Eloquent\Builder; use Rappasoft\LaravelLivewireTables\DataTableComponent; -use Rappasoft\LaravelLivewireTables\Views\Columns\BooleanColumn; use Rappasoft\LaravelLivewireTables\Views\Column; -use Rappasoft\LaravelLivewireTables\Views\Columns\ImageColumn; -use Rappasoft\LaravelLivewireTables\Views\Filters\SelectFilter; -use Rappasoft\LaravelLivewireTables\Views\Filters\MultiSelectFilter; -use Rappasoft\LaravelLivewireTables\Views\Filters\DateFilter; +use Rappasoft\LaravelLivewireTables\Views\Columns\{BooleanColumn, ImageColumn}; +use Rappasoft\LaravelLivewireTables\Views\Filters\{DateFilter, MultiSelectFilter, SelectFilter}; class UsersTable extends DataTableComponent { @@ -231,7 +227,7 @@ class UsersTable extends DataTableComponent public function reorder($items): void { 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()]]); } } } diff --git a/docs/start/commands.md b/docs/start/commands.md index a9d36a78d..26e62788d 100644 --- a/docs/start/commands.md +++ b/docs/start/commands.md @@ -1,6 +1,6 @@ --- title: Commands -weight: 5 +weight: 6 --- ## Generating Datatable Components diff --git a/docs/start/configuration.md b/docs/start/configuration.md index c6dcf315c..75aef5083 100644 --- a/docs/start/configuration.md +++ b/docs/start/configuration.md @@ -1,6 +1,6 @@ --- title: Configuration -weight: 3 +weight: 4 --- ## Publishing Assets @@ -81,16 +81,3 @@ You must also make sure you have this Alpine style available globally. Note that [x-cloak] { display: none !important; } ``` - -## Package Specific Code - -This package now makes use of two external files, one for AlpineJS methods, and one for Custom Styling. There are two options available to you: - -### Injection (Default) -The package will automatically inject the relevant two files into your layout as part of the render process. This is the default behaviour, and mimics that of Livewire 3.0 - -### Build Include (Not Recommended) -If you wish to disable the injection, you may include the following file in your app.js, which will provide the relevant functionality and styling for the package to function. -``` -import '../../vendor/rappasoft/laravel-livewire-tables-v3/resources/laravel-livewire-tables' -``` diff --git a/docs/start/including-assets.md b/docs/start/including-assets.md new file mode 100644 index 000000000..7682c223d --- /dev/null +++ b/docs/start/including-assets.md @@ -0,0 +1,64 @@ +--- +title: Including Assets +weight: 3 +--- + +## Package Specific Code + +This package now makes use of several external files, one for AlpineJS methods, and one for Custom Styling. In addition, Flatpickr is separately bundled with the package, and used for the DateRange Filter. These can be independently enabled/disabled. + +### Injection (Default) +The package will automatically inject the relevant two files into your layout as part of the render process. This is the default behaviour, and mimics that of Livewire 3.0 + +#### Configuration +This is enabled by default, but to re-enable, enable the following options in the livewire-tables configuration file, to enable automatic injection: + +```php + + /** + * Enable or Disable automatic injection of core assets + */ + 'inject_core_assets_enabled' => true, + + /** + * Enable or Disable automatic injection of third-party assets + */ + 'inject_third_party_assets_enabled' => true, +``` + +### Bundler Including +If you'd prefer to bundle the included JS and CSS files with your choice of bundler, this is provided by two files that can be included in your bundler (e.g. app.js) + +#### Include Code (For Bundler) + +To include only Core functions (Includes JS & CSS): +```js +import '../../vendor/rappasoft/laravel-livewire-tables/resources/imports/laravel-livewire-tables.js'; +``` + +To include both Core and Third Party (Flatpickr) Libraries (Includes JS & CSS): +```js +import '../../vendor/rappasoft/laravel-livewire-tables/resources/imports/laravel-livewire-tables-all.js'; +``` + +#### Configuration +Update the following options in the livewire-tables configuration file, to disable automatic injection: + +```php + + /** + * Enable or Disable automatic injection of core assets + */ + 'inject_core_assets_enabled' => false, + + /** + * Enable or Disable automatic injection of third-party assets + */ + 'inject_third_party_assets_enabled' => false, + + /** + * Enable Blade Directives (Not required if automatically injecting or using bundler approaches) + */ + 'enable_blade_directives ' => false, + +``` \ No newline at end of file diff --git a/docs/start/optional-packages.md b/docs/start/optional-packages.md deleted file mode 100644 index f4e952313..000000000 --- a/docs/start/optional-packages.md +++ /dev/null @@ -1,40 +0,0 @@ ---- -title: Optional Packages -weight: 6 ---- - -## Flatpickr -The DateRange filter makes use of Flatpickr, an open-source third party package. You may enable this via one of the following three options: - -### Option 1 - local installation (recommended) -Using your bundler of choice, install and include the Flatpickr library in your build. - -*For example* -``` -npm i flatpickr - -``` -Then in your app.js -``` -import flatpickr from "flatpickr"; -``` -You should then disable both of the other options to avoid multiple (clashing) instances: -- Set the "published_third_party_assets" option to false in the configuration file -- Set the "remote_third_party_assets" option to false in the configuration file - -### Option 2 - Using the included public directory -This sets the package to use a version of Flatpickr that has been tested and confirmed as working. - -Publish the included "public" directory -``` -php artisan vendor:publish --provider="Rappasoft\LaravelLivewireTables\LaravelLivewireTablesServiceProvider" --tag=livewire-tables-public -``` -- Set the "published_third_party_assets" option to true in the configuration file -- Set the "remote_third_party_assets" option to false in the configuration file - -### Option 3 - Use the CDN options -This sets the package to use the published version from cdn.jsdelivr.net, note that you may experience breaking changes if Flatpickr makes major updates! - -- Set the "published_third_party_assets" option to false in the configuration file -- Set the "remote_third_party_assets" option to true in the configuration file - diff --git a/docs/start/rendering.md b/docs/start/rendering.md index b82ef5a78..5694923fd 100644 --- a/docs/start/rendering.md +++ b/docs/start/rendering.md @@ -1,6 +1,6 @@ --- title: Rendering -weight: 4 +weight: 5 --- ## Rendering Components