Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0d03377

Browse files
authored
Merge branch 'master' into display_products_on_frontend
2 parents faf238f + 8f46169 commit 0d03377

Some content is hidden

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

47 files changed

+596
-175
lines changed

‎app/controllers/employees_controller.rb

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

‎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: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ const serializers = {
5757
},
5858
}),
5959
},
60-
6160
products: {
6261
serializer: new Serializer('products', {
6362
keyForAttribute: 'camelCase',
@@ -70,7 +69,17 @@ const serializers = {
7069
keyForAttribute: 'camelCase',
7170
}),
7271
},
73-
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+
},
7483
roles: {
7584
serializer: new Serializer('roles', {
7685
keyForAttribute: 'camelCase',

‎client/src/components/App.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import React, { Component } from 'react';
2-
import { Link } from 'react-router';
32
import { connect } from 'react-redux';
4-
import { isEmpty } from 'lodash';
5-
import { Collapse, Container, Navbar, NavbarToggler, Nav, NavItem, NavLink, NavDropdown, DropdownToggle, DropdownMenu, DropdownItem } from 'reactstrap';
3+
import { Container, Navbar, Nav, NavItem, NavLink, NavDropdown, DropdownToggle, DropdownMenu, DropdownItem } from 'reactstrap';
64

75
import { getUser, logout } from '../store/auth';
86

@@ -17,12 +15,12 @@ export class App extends Component {
1715
};
1816

1917
toggle = () => this.setState({
20-
isOpen: !this.state.isOpen
18+
isOpen: !this.state.isOpen,
2119
});
2220

2321
render() {
2422
const { user } = this.props;
25-
const userIsAdmin = user.roles.includes('admin')
23+
const userIsAdmin = user.roles.includes('admin');
2624

2725
return (
2826
<div>
@@ -38,6 +36,9 @@ export class App extends Component {
3836
<NavItem>
3937
<NavLink href="/#/categories">Categories</NavLink>
4038
</NavItem>
39+
<NavItem>
40+
<NavLink href="/#/customers">Customers</NavLink>
41+
</NavItem>
4142
<NavItem>
4243
{
4344
userIsAdmin && <NavLink href="/#/users">Users</NavLink>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /