Skip to content

Commit adfd8c2

Browse files
authoredDec 14, 2021
Merge pull request #103 from jobready/NEP-12470_relative_date_range
[NEP-12470] SPIKE: Add custom relative date range option in date filters
2 parents ef2b258 + 742d2f0 commit adfd8c2

File tree

14 files changed

+40562
-21772
lines changed

14 files changed

+40562
-21772
lines changed
 

‎Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM ruby:2.6-slim-buster
2+
WORKDIR /code
3+
4+
RUN apt-get update && \
5+
apt-get install -y --no-install-recommends \
6+
nodejs \
7+
npm
8+
9+
RUN npm install -g npm@7.24.2
10+
COPY package* ./
11+
RUN npm install
12+

‎README.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,33 @@ the data is updated.
231231

232232
* development within the react-filterbar repo can be performed using the example application included. see /example
233233

234+
*Using Docker*
235+
236+
- Build the image for your environment:
237+
```
238+
docker build -t filterbar .
239+
```
240+
- Access your new environment:
241+
```
242+
docker run --rm -it -v "$PWD:/code" -p "4567:4567" filterbar bash
243+
```
244+
- Move to the example dir and run bundle install:
245+
```
246+
cd example/ && bundle install
247+
```
248+
- Start the Sinatra Rack server on port 4567
249+
```
250+
bundle exec rackup -p 4567 -o 0.0.0.0
251+
```
252+
253+
- Visit the server via: http://localhost:4567
254+
255+
### Making Changes
256+
257+
Run `node_modules/.bin/gulp` to deploy your changes to /example application.
258+
234259
## Deployment
235-
run the following to deploy
236-
gulp dist
260+
When your code is ready for distribuition, run: `node_modules/.bin/gulp dist`
237261

238262
## Common Problems / Bugs
239263

‎dist/react-filterbar.js

Lines changed: 3979 additions & 2215 deletions
Large diffs are not rendered by default.

‎dist/react-filterbar.min.js

Lines changed: 14 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎example/README.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,28 @@ This document describes how to setup Sinatra for the purposes of development and
88
git clone https://github.com/jobready/react-filterbar.git
99
```
1010

11-
* move to the example dir and run bundle install
11+
* Use Docker
12+
13+
Build the image for your environment
1214
```
13-
cd react-filterbar/example/
14-
bundle install
15+
docker build -t filterbar .
1516
```
16-
17-
* optionally reset the example data so date filters make sense
17+
Access your new environment
1818
```
19-
cd react-filterbar/example/
20-
ruby generate_books.rb
19+
docker run --rm -it -v "$PWD:/code" -p "4567:4567" filterbar bash
2120
```
22-
23-
24-
* start the Sinatra Rack server on port 4567
21+
Move to the example dir and run bundle install
2522
```
26-
bundle exec rackup -p 4567
23+
cd example/ && bundle install
2724
```
25+
Start the Sinatra Rack server on port 4567
26+
```
27+
bundle exec rackup -p 4567 -o 0.0.0.0
28+
```
29+
Visit the server via: http://localhost:4567
2830

29-
Visit the server via: http://localhost:4567
31+
* optionally reset the example data so date filters make sense
32+
```
33+
cd example/
34+
ruby generate_books.rb
35+
```

‎example/books.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

‎example/public/js/react-filterbar.js

Lines changed: 3980 additions & 2216 deletions
Large diffs are not rendered by default.

‎example/server.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,12 @@ def search_date_relative(haystack, field, value)
159159
search_blank_values(haystack, field)
160160
else
161161
if(relative_value.present?)
162-
from, to = calculate_relative_dates(relative_value)
162+
if relative_value == "Relative from today"
163+
from = Date.current.advance(days: value["from"].to_i)
164+
to = Date.current.advance(days: value["to"].to_i)
165+
else
166+
from, to = calculate_relative_dates(relative_value)
167+
end
163168
else
164169
from = Date.parse(value["from"])
165170
to = Date.parse(value["to"])

‎example/views/index.haml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
%dt.type{ data: { value: "multi_select" } }
5454
%dt.url{ data: { value: "/authors" } }
5555
%dt.default{ data: { value: "Author 31" } }
56+
%dt.operator{ data: { value: "any" }}
5657
%dl.author
5758
%dt.field{ data: { value: "author" } }
5859
%dt.type{ data: { value: "select" } }

‎gulpfile.js

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,6 @@ var appFile = 'app.js';
2525
var appDistFile = appName + '.js';
2626
var appMinDistFile = appName + '.min.js';
2727

28-
gulp.task('dev', function() {
29-
browserify({
30-
entries: './src/' + appFile,
31-
extensions: ['.js'],
32-
debug: true
33-
})
34-
.transform(babelify.configure({
35-
presets: [
36-
"@babel/preset-env",
37-
"@babel/preset-react",
38-
]
39-
}))
40-
.bundle()
41-
.pipe(source(appDistFile))
42-
.pipe(gulp.dest('example/public/js'));
43-
})
44-
4528
gulp.task('devloop', function() {
4629
gulp.watch([scriptsPath + '/**/*.*'], ['dev']);
4730
})

0 commit comments

Comments
 (0)