Skip to content

Commit 3133d28

Browse files
committed
Initial commit
0 parents  commit 3133d28

File tree

13 files changed

+318
-0
lines changed

13 files changed

+318
-0
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/.idea
2+
/vendor
3+
/node_modules
4+
package-lock.json
5+
composer.phar
6+
composer.lock
7+
phpunit.xml
8+
.phpunit.result.cache
9+
.DS_Store
10+
Thumbs.db

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Digital Creative
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Nova Slider Filter
2+
3+
[![Latest Version on Packagist](https://img.shields.io/packagist/v/digital-creative/nova-range-input-filter)](https://packagist.org/packages/digital-creative/nova-range-input-filter)
4+
[![Total Downloads](https://img.shields.io/packagist/dt/digital-creative/nova-range-input-filter)](https://packagist.org/packages/digital-creative/nova-range-input-filter)
5+
[![License](https://img.shields.io/packagist/l/digital-creative/nova-range-input-filter)](https://github.com/dcasia/nova-range-input-filter/blob/master/LICENSE)
6+
7+
A Laravel Nova range input filter.
8+
9+
![RangeInputFilter in Action](https://raw.githubusercontent.com/dcasia/nova-range-input-filter/master/screenshot.png)
10+
11+
# Installation
12+
13+
You can install the package via composer:
14+
15+
```
16+
composer require digital-creative/nova-range-input-filter
17+
```
18+
19+
## Basic Usage
20+
21+
Create a filter as usual and extend the `DigitalCreative\RangeInputFilter\RangeInputFilter` class
22+
23+
```php
24+
use DigitalCreative\RangeInputFilter\RangeInputFilter;
25+
26+
class MyFilter extends RangeInputFilter {
27+
28+
public function apply(Request $request, $query, $value)
29+
{
30+
// $value will always be an array
31+
}
32+
33+
public function options(Request $request)
34+
{
35+
return [
36+
'fromPlaceholder' => 0,
37+
'toPlaceholder' => 20,
38+
'dividerLabel' => 'to',
39+
];
40+
}
41+
42+
}
43+
```
44+
45+
and use it as usual on the filters methods within your resource class:
46+
47+
```php
48+
class ExampleNovaResource extends Resource {
49+
50+
public function filters(Request $request)
51+
{
52+
return [
53+
new MyFilter()
54+
];
55+
}
56+
57+
}
58+
```
59+
60+
## License
61+
62+
The MIT License (MIT). Please see [License File](https://raw.githubusercontent.com/dcasia/nova-range-input-filter/master/LICENSE) for more information.

composer.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"name": "digital-creative/nova-range-input-filter",
3+
"description": "A Laravel Nova range input filter.",
4+
"keywords": [
5+
"laravel",
6+
"nova",
7+
"range",
8+
"input",
9+
"filter"
10+
],
11+
"authors": [
12+
{
13+
"name": "Rafael Milewski"
14+
},
15+
{
16+
"name": "littlemiaor"
17+
}
18+
],
19+
"license": "MIT",
20+
"require": {
21+
"php": ">=7.1.0"
22+
},
23+
"autoload": {
24+
"psr-4": {
25+
"DigitalCreative\\RangeInputFilter\\": "src/"
26+
}
27+
},
28+
"extra": {
29+
"laravel": {
30+
"providers": [
31+
"DigitalCreative\\RangeInputFilter\\RangeInputFilterServiceProvider"
32+
]
33+
}
34+
},
35+
"config": {
36+
"sort-packages": true
37+
},
38+
"minimum-stability": "dev",
39+
"prefer-stable": true
40+
}

dist/js/filter.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/mix-manifest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"/js/filter.js": "/js/filter.js"
3+
}

package.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"private": true,
3+
"scripts": {
4+
"dev": "npm run development",
5+
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
6+
"watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
7+
"watch-poll": "npm run watch -- --watch-poll",
8+
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
9+
"prod": "npm run production",
10+
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
11+
},
12+
"devDependencies": {
13+
"cross-env": "^5.0.0",
14+
"laravel-mix": "^1.0"
15+
},
16+
"dependencies": {
17+
"vue": "^2.5.0"
18+
}
19+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<template>
2+
3+
<div>
4+
5+
<h3 class="text-sm uppercase tracking-wide text-80 bg-30 p-3">
6+
{{ filter.name }}
7+
</h3>
8+
9+
<div class="flex p-2 flex-wrap items-center">
10+
11+
<input class="flex items-center form-control form-input text-sm min-w-0 border-60"
12+
:class="{ 'flex-1': filter.options.fullWidth }"
13+
name="from"
14+
:type="filter.options.inputType"
15+
:placeholder="filter.options.fromPlaceholder"
16+
:value="value.from"
17+
@change="handleChange"/>
18+
19+
<div class="text-sm mx-2">{{ filter.options.dividerLabel }}</div>
20+
21+
<input class="flex items-center form-control form-input text-sm min-w-0 border-60"
22+
:class="{ 'flex-1': filter.options.fullWidth }"
23+
name="to"
24+
:type="filter.options.inputType"
25+
:placeholder="filter.options.toPlaceholder"
26+
:value="value.to"
27+
@change="handleChange"/>
28+
29+
</div>
30+
31+
</div>
32+
33+
</template>
34+
35+
<script>
36+
37+
export default {
38+
name: 'RangeInputFilter',
39+
props: {
40+
resourceName: {
41+
type: String,
42+
required: true
43+
},
44+
filterKey: {
45+
type: String,
46+
required: true
47+
}
48+
},
49+
methods: {
50+
handleChange(event) {
51+
52+
this.value[ event.target.name ] = event.target.value
53+
54+
this.$store.commit(`${ this.resourceName }/updateFilterState`, {
55+
filterClass: this.filterKey,
56+
value: this.value
57+
})
58+
59+
this.$emit('change')
60+
61+
}
62+
},
63+
computed: {
64+
filter() {
65+
return this.$store.getters[ `${ this.resourceName }/getFilter` ](this.filterKey)
66+
},
67+
value() {
68+
return this.filter.currentValue || {
69+
from: null,
70+
to: null
71+
}
72+
}
73+
}
74+
}
75+
76+
</script>

resources/js/filter.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Nova.booting((Vue, router, store) => {
2+
Vue.component('range-input-filter', require('./components/RangeInputFilter'))
3+
})

screenshot.png

12.2 KB
Loading

0 commit comments

Comments
 (0)