Skip to content

Commit 090db36

Browse files
authored
Merge branch 'master' into orders
2 parents 4da7a7c + 6859ed3 commit 090db36

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+746
-176
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class EmployeesController < AuthorizedController
2+
3+
end

app/models/customer.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
class Customer < ApplicationRecord
2+
scope :company_name_contains, -> (value) { where('company_name ILIKE ?', "%#{value.join}%") }
23
end

app/models/employee.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class Employee < ApplicationRecord
2+
end

app/resources/customer_resource.rb

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
class CustomerResource < JSONAPI::Resource
2+
extend ModelFilter
23
attributes :company_name,
3-
:contact_name
4-
:contact_title
5-
:address
6-
:city
7-
:region
8-
:postal_code
9-
:country
10-
:phone
11-
:fax
4+
:contact_name,
5+
:contact_title,
6+
:address,
7+
:city,
8+
:region,
9+
:postal_code,
10+
:country,
11+
:phone,
12+
:fax,
13+
:created_at
14+
15+
paginator :paged
16+
model_filters :company_name_contains
1217
end

app/resources/employee_resource.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class EmployeeResource < JSONAPI::Resource
2+
attributes :title, :created_at, :first_name
3+
end

app/resources/product_resource.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
class ProductResource < JSONAPI::Resource
2-
attributes :product_name
2+
attributes :product_name, :created_at
3+
4+
paginator :paged
35
end

client/.eslintrc.yml

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,16 @@
11
---
2-
parser: babel-eslint
2+
extends: react-app
33

44
env:
55
browser: true
66
es6: true
7-
jasmine: true
7+
jest: true
88
node: true
99

10-
ecmaFeatures:
11-
jsx: true
12-
13-
plugins:
14-
- react
15-
16-
extends:
17-
- airbnb-base
18-
1910
globals:
2011
context: false
2112
jest: true
2213

2314
rules:
24-
import/no-named-as-default: 0
25-
import/prefer-default-export: 0
26-
no-console: 0
27-
no-param-reassign: 0
28-
no-shadow: 0 # FIXME extract generic Edit component
29-
no-unused-vars: 0 # FIXME
30-
react/jsx-uses-react: 2
15+
jsx-a11y/href-no-hash: 0
16+
jsx-a11y/alt-text: 0

client/package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@
2121
"jsonapi-serializer": "^3.5.2",
2222
"lodash": "^4.17.4",
2323
"object-path-immutable": "^0.5.1",
24+
"prop-types": "^15.5.10",
2425
"qs": "^6.4.0",
2526
"react": "^15.4.2",
2627
"react-addons-css-transition-group": "^15.5.2",
2728
"react-addons-transition-group": "^15.5.2",
2829
"react-dom": "^15.4.2",
2930
"react-redux": "^5.0.3",
30-
"react-router": "~3.0.2",
31+
"react-router": "^4.1.1",
3132
"react-router-redux": "^4.0.8",
3233
"react-ultimate-pagination": "^1.0.1",
3334
"reactstrap": "^4.5.0",
@@ -48,15 +49,16 @@
4849
"enzyme": "^2.7.1",
4950
"enzyme-to-json": "^1.5.0",
5051
"eslint": "^3.19.0",
51-
"eslint-config-airbnb": "^14.1.0",
52-
"eslint-plugin-import": "^2.2.0",
53-
"eslint-plugin-jsx-a11y": "^4.0.0",
54-
"eslint-plugin-react": "^6.10.3",
52+
"eslint-config-react-app": "^1.0.4",
53+
"eslint-plugin-flowtype": "^2.33.0",
54+
"eslint-plugin-import": "^2.3.0",
55+
"eslint-plugin-jsx-a11y": "^5.0.3",
56+
"eslint-plugin-react": "^7.0.1",
5557
"extract-text-webpack-plugin": "^2.1.0",
5658
"html-webpack-plugin": "^2.28.0",
5759
"jest": "^19.0.2",
5860
"node-sass": "^4.5.0",
59-
"react-addons-test-utils": "^15.4.2",
61+
"react-test-renderer": "^15.5.4",
6062
"sass-loader": "^6.0.3",
6163
"shx": "^0.2.2",
6264
"style-loader": "^0.13.2",

client/src/api/client.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
get,
66
groupBy,
77
keys,
8-
pick,
98
set,
109
values,
1110
zipObject,
@@ -21,6 +20,7 @@ export const client = axios.create({
2120
Accept: 'application/vnd.api+json',
2221
'Content-Type': 'application/vnd.api+json',
2322
},
23+
paramsSerializer: params => qs.stringify(params, { format: 'RFC1738', arrayFormat: 'brackets' }),
2424
});
2525

2626
client.interceptors.response.use(
@@ -47,10 +47,6 @@ client.interceptors.request.use(
4747
error => Promise.reject(error),
4848
);
4949

50-
const stringifyParams = params => qs.stringify(params, { format: 'RFC1738', arrayFormat: 'brackets' });
51-
52-
export const withParams = (url, params) => `${url}?${stringifyParams(params)}`;
53-
5450
export const normalizeResponse = (response) => {
5551
const { data = [], included = [] } = response.data;
5652
const dataByType = groupBy(castArray(data).concat(included), 'type');

client/src/api/normalize.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,29 @@ const serializers = {
5757
},
5858
}),
5959
},
60-
60+
products: {
61+
serializer: new Serializer('products', {
62+
keyForAttribute: 'camelCase',
63+
attributes: [
64+
'productName',
65+
'createdAt'
66+
],
67+
}),
68+
deserializer: new Deserializer({
69+
keyForAttribute: 'camelCase',
70+
}),
71+
},
72+
customers: {
73+
serializer: new Serializer('customers', {
74+
keyForAttribute: 'camelCase',
75+
attributes: [
76+
'companyName'
77+
],
78+
}),
79+
deserializer: new Deserializer({
80+
keyForAttribute: 'camelCase'
81+
}),
82+
},
6183
roles: {
6284
serializer: new Serializer('roles', {
6385
keyForAttribute: 'camelCase',

0 commit comments

Comments
 (0)