Skip to content

Commit

Permalink
Merge branch 'feature/workbench-integration'
Browse files Browse the repository at this point in the history
  • Loading branch information
KasparRosin committed Jan 16, 2024
2 parents 740ee0c + 5d9aa83 commit 3d651a4
Show file tree
Hide file tree
Showing 23 changed files with 649 additions and 106 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.1.0] - 24-01-16

### Added

- Workbench usable by `composer run serve` command.

### Changed

- Updated mixins and resources to latest nova release (4.32.11)

## [2.0.4] - 24-01-09

### Changed
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,16 @@ public function cards(Request $request)
}
```

### Demo

You can preview the application via workbench by running the following commands on your local machine.
This will assume you have installed the required software on your pc.

```
composer install
composer serve
```

## Credits

- [Kaspar Rosin](https://github.com/kasparrosin)
Expand Down
154 changes: 87 additions & 67 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,71 +1,91 @@
{
"name": "outl1ne/nova-detached-filters",
"description": "This Laravel Nova package allows you to detach filters from the filter dropdown",
"keywords": [
"laravel",
"nova",
"card",
"filter",
"persist"
],
"license": "MIT",
"authors": [
{
"name": "Kaspar Rosin",
"email": "[email protected]",
"role": "Developer"
"name": "outl1ne/nova-detached-filters",
"description": "This Laravel Nova package allows you to detach filters from the filter dropdown",
"keywords": [
"laravel",
"nova",
"card",
"filter",
"persist"
],
"license": "MIT",
"authors": [
{
"name": "Kaspar Rosin",
"email": "[email protected]",
"role": "Developer"
},
{
"name": "Tarvo Reinpalu",
"email": "[email protected]",
"role": "Developer"
},
{
"name": "Outl1ne",
"email": "[email protected]",
"role": "Maintainer"
}
],
"require": {
"php": ">=8.0.0",
"laravel/nova": "~4.0",
"nova-kit/nova-packages-tool": "^1.14"
},
{
"name": "Tarvo Reinpalu",
"email": "[email protected]",
"role": "Developer"
"require-dev": {
"laravel/pint": "^0.2.1",
"nova-kit/nova-devtool": "^1.5",
"orchestra/testbench": "^7.0.0",
"phpunit/phpunit": "^9.5"
},
{
"name": "Outl1ne",
"email": "[email protected]",
"role": "Maintainer"
}
],
"require": {
"php": ">=8.0.0",
"laravel/nova": "~4.0"
},
"require-dev": {
"laravel/pint": "^0.2.1",
"orchestra/testbench": "^7.0.0",
"phpunit/phpunit": "^9.5"
},
"autoload": {
"psr-4": {
"Outl1ne\\NovaDetachedFilters\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Outl1ne\\NovaDetachedFilters\\Tests\\": "tests/"
}
},
"extra": {
"laravel": {
"providers": [
"Outl1ne\\NovaDetachedFilters\\CardServiceProvider"
]
}
},
"config": {
"sort-packages": true
},
"repositories": [
{
"type": "composer",
"url": "https://nova.laravel.com"
"autoload": {
"psr-4": {
"Outl1ne\\NovaDetachedFilters\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Outl1ne\\NovaDetachedFilters\\Tests\\": "tests/",
"Workbench\\App\\": "workbench/app/",
"Workbench\\Database\\Factories\\": "workbench/database/factories/",
"Workbench\\Database\\Seeders\\": "workbench/database/seeders/"
}
},
"extra": {
"laravel": {
"providers": [
"Outl1ne\\NovaDetachedFilters\\CardServiceProvider"
]
}
},
"config": {
"sort-packages": true
},
"repositories": [
{
"type": "composer",
"url": "https://nova.laravel.com"
}
],
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"test": [
"phpunit tests"
],
"post-autoload-dump": [
"@clear",
"@prepare"
],
"clear": "@php vendor/bin/testbench package:purge-skeleton --ansi",
"prepare": "@php vendor/bin/testbench package:discover --ansi",
"build": "@php vendor/bin/testbench workbench:build --ansi",
"serve": [
"Composer\\Config::disableProcessTimeout",
"@build",
"@php vendor/bin/testbench serve"
],
"lint": [
"@php vendor/bin/pint"
]
}
],
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"test": [
"phpunit tests"
]
}
}
}
2 changes: 1 addition & 1 deletion dist/js/entry.js

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions dist/js/entry.js.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
/*!
* vuex v4.1.0
* (c) 2022 Evan You
* @license MIT
*/

/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
1 change: 0 additions & 1 deletion nova.mix.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class NovaExtension {

webpackPlugins() {
return new webpack.ProvidePlugin({
_: 'lodash',
Errors: 'form-backend-validation',
});
}
Expand Down
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-vue": "^9.3.0",
"laravel-mix": "^6.0.49",
"postcss": "^8.4.16",
"postcss-import": "^14.1.0",
"prettier": "^2.7.1",
"resolve-url-loader": "^5.0.0",
"sass": "^1.54.3",
"sass-loader": "^13.0.2",
"vue-loader": "^17.0.0",
"postcss": "^8.4.16",
"postcss-import": "^14.1.0"
"vue-loader": "^17.0.0"
},
"dependencies": {
"tailwindcss": "^3.1.8",
"vue": "^3.2.37"
"vue": "^3.2.37",
"vuex": "^4.1.0"
}
}
8 changes: 4 additions & 4 deletions resources/js/components/DetachedFilterCard.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<card class="flex flex-col h-auto relative o1-min-h-0 o1-overflow-visible">
<card id="o1-detached-card" class="flex flex-col h-auto relative o1-min-h-0 o1-overflow-visible">
<div
v-if="hasAnyActions"
class="o1-flex o1-justify-end overflow-hidden"
Expand Down Expand Up @@ -141,10 +141,12 @@ export default {
});
});
this.filterChanged();
this.syncFilters();
},
handleFilterChanged(filter) {
this.filterChanged();
if (this.isPersisting) {
// Get updated filter from $store;
const updatedFilter = this.getFilter(filter.class);
Expand All @@ -164,8 +166,6 @@ export default {
localStorage.setItem('PERSISTED_DETACHED_FILTERS', JSON.stringify(this.persistedFilters));
}
this.filterChanged();
},
getFilter(filterKey) {
Expand Down
7 changes: 6 additions & 1 deletion resources/js/mixins/Filterable.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ export default {
Nova.$emit('filter-changed', ['']);
},

syncFilters() {
const encodedFilters = this.$store.getters[`${this.resourceName}/currentEncodedFilters`];
this.updateQueryString({ [this.filterParameter]: encodedFilters });
Nova.$emit('filter-changed');
},
/**
* Handle a filter state change.
*/
Expand All @@ -41,7 +46,7 @@ export default {
});
}

Nova.$emit('filter-changed', [encodedFilters]);
Nova.$emit('filter-changed');
},
},

Expand Down
31 changes: 3 additions & 28 deletions resources/js/mixins/InteractsWithQueryString.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,6 @@
import forEach from 'lodash/forEach';
import clone from 'lodash/cloneDeep';

let compiledSearchParams = null;
import { mapActions, mapGetters } from 'vuex';

export default {
methods: {
/**
* Update the given query string values.
*/
updateQueryString(value) {
let searchParams = new URLSearchParams(window.location.search);
let page = clone(this.$page);

forEach(value, (v, i) => {
searchParams.set(i, v || '');
});

if (compiledSearchParams !== searchParams.toString()) {
if (page.url !== `${window.location.pathname}?${searchParams}`) {
page.url = `${window.location.pathname}?${searchParams}`;
window.history.pushState(page, '', `${window.location.pathname}?${searchParams}`);
}

compiledSearchParams = searchParams.toString();
}

Nova.$emit('query-string-changed', searchParams);
},
},
methods: mapActions(['syncQueryString', 'updateQueryString']),
computed: mapGetters(['queryStringParams']),
};
24 changes: 24 additions & 0 deletions testbench.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
providers:
- Laravel\Nova\NovaCoreServiceProvider
- Workbench\App\Providers\NovaServiceProvider

migrations: true

seeders:
- Workbench\Database\Seeders\DatabaseSeeder

workbench:
start: /nova
build:
- asset-publish
- create-sqlite-db
- db:wipe
- migrate:refresh
assets:
- nova-assets
sync: []

purge:
directories:
- lang/*
- public/vendor/*
Loading

0 comments on commit 3d651a4

Please sign in to comment.