breezy 0.5.3 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/breezy/render.rb +8 -1
- data/lib/breezy/xhr_headers.rb +2 -0
- data/lib/generators/rails/templates/web/base.jsx +4 -60
- data/lib/generators/rails/templates/web/edit.jsx +18 -4
- data/lib/generators/rails/templates/web/index.jsx +4 -4
- data/lib/generators/rails/templates/web/new.jsx +17 -3
- data/lib/generators/rails/templates/web/show.jsx +2 -2
- metadata +23 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb43f13ec70155872dfc74693dad99bde8a0e6fe
|
4
|
+
data.tar.gz: e1f14e0f6b31786f5308e932391b6bbed5f2db0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: debe7eace5d5fac99323d56e3c8667dca975d62d5c9402c21f5a7f6943e645fc3a147c890e10f94c09ea686fe3f81419418c70ed8a7f1e486237f732b240dd9b
|
7
|
+
data.tar.gz: 46bdd75bbb49d8975c8a4f2bece8208b696138142d4dce4991b581051e25e41382f30adeb8e110ac928bb8b7c2091d829be49e2f0a6e0ea3d3d1da89b2f57c93
|
data/lib/breezy/render.rb
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
module Breezy
|
2
2
|
module Render
|
3
|
+
DEFAULT_ACTIONS_FOR_VERBS = {
|
4
|
+
:post => 'new',
|
5
|
+
:patch => 'edit',
|
6
|
+
:put => 'edit'
|
7
|
+
}
|
8
|
+
|
3
9
|
def default_render(*args)
|
4
10
|
if @_use_breezy_html
|
5
11
|
render(*args)
|
@@ -21,7 +27,8 @@ module Breezy
|
|
21
27
|
end
|
22
28
|
|
23
29
|
if breezy
|
24
|
-
|
30
|
+
action = render_options[action] || DEFAULT_ACTIONS_FOR_VERBS[request.request_method_symbol] || action_name
|
31
|
+
view_parts = _prefixes.reverse.push(action)[1..-1]
|
25
32
|
view_name = view_parts.map(&:camelize).join.gsub('::', '')
|
26
33
|
|
27
34
|
breezy[:screen] ||= view_name
|
data/lib/breezy/xhr_headers.rb
CHANGED
@@ -1,68 +1,12 @@
|
|
1
1
|
import React from 'react'
|
2
|
-
import {
|
2
|
+
import {withBrowserBehavior} from '@jho406/breezy'
|
3
3
|
|
4
4
|
export default class extends React.Component {
|
5
5
|
constructor (props) {
|
6
6
|
super(props)
|
7
|
-
|
8
|
-
this.
|
9
|
-
|
10
|
-
|
11
|
-
handleClick(path, method='GET') {
|
12
|
-
this.props.visit(path, {method}).then((rsp)=>{
|
13
|
-
// the window needs a full reload when asset fingerprint changes
|
14
|
-
if (rsp.needsRefresh) {
|
15
|
-
return window.location = rsp.url
|
16
|
-
}
|
17
|
-
|
18
|
-
if (rsp.canNavigate) {
|
19
|
-
return this.props.navigateTo(rsp.screen, rsp.pageKey)
|
20
|
-
} else {
|
21
|
-
// There can only be one visit at a time, if `canNavigate`
|
22
|
-
// is false, then this request is being ignored for a more
|
23
|
-
// recent visit. Do Nothing.
|
24
|
-
return
|
25
|
-
}
|
26
|
-
})
|
27
|
-
}
|
28
|
-
|
29
|
-
handleSubmit (url, body, method='POST') {
|
30
|
-
const options = {
|
31
|
-
method,
|
32
|
-
body: JSON.stringify(body),
|
33
|
-
contentType: 'application/json'
|
34
|
-
}
|
35
|
-
|
36
|
-
return this.props.visit(url, options).then((rsp) => {
|
37
|
-
// the window needs a full reload when asset fingerprint changes
|
38
|
-
if (rsp.needsRefresh) {
|
39
|
-
return window.location = rsp.url
|
40
|
-
}
|
41
|
-
|
42
|
-
if (this.props.errors) {
|
43
|
-
throw new SubmissionError({
|
44
|
-
...this.props.errors
|
45
|
-
})
|
46
|
-
}
|
47
|
-
|
48
|
-
if (rsp.canNavigate) {
|
49
|
-
//Uncomment this if you want full-page reloads
|
50
|
-
// window.location = rsp.url
|
51
|
-
|
52
|
-
return this.props.navigateTo(rsp.screen, rsp.pageKey)
|
53
|
-
} else {
|
54
|
-
// There can only ve one visit at a time, if `canNavigate`
|
55
|
-
// is false, then this request is being ignored for a more
|
56
|
-
// recent visit. Do Nothing.
|
57
|
-
return
|
58
|
-
}
|
59
|
-
}).catch((err) => {
|
60
|
-
if (err.name === 'SubmissionError') {
|
61
|
-
throw err
|
62
|
-
} else {
|
63
|
-
window.location = err.url
|
64
|
-
}
|
65
|
-
})
|
7
|
+
const {visit, remote} = withBrowserBehavior(props.visit, props.remote)
|
8
|
+
this.visit = visit.bind(this)
|
9
|
+
this.remote = remote.bind(this)
|
66
10
|
}
|
67
11
|
}
|
68
12
|
|
@@ -3,12 +3,26 @@ import {mapStateToProps, mapDispatchToProps} from '@jho406/breezy'
|
|
3
3
|
import {delInPage} from '@jho406/breezy/dist/action_creators'
|
4
4
|
import {connect} from 'react-redux'
|
5
5
|
import BaseScreen from 'components/BaseScreen'
|
6
|
+
import {SubmissionError} from 'redux-form'
|
6
7
|
import <%= plural_table_name.camelize %>Form from 'components/<%= plural_table_name.camelize %>Form'
|
7
8
|
|
8
9
|
class <%= plural_table_name.camelize %>Edit extends BaseScreen {
|
9
|
-
handleSubmit (body) {
|
10
|
+
handleSubmit = (body) => {
|
10
11
|
this.props.delInPage({pageKey: this.props.pageKey, keypath: 'errors'})
|
11
|
-
|
12
|
+
|
13
|
+
const options = {
|
14
|
+
method:'PUT',
|
15
|
+
body: JSON.stringify(body),
|
16
|
+
}
|
17
|
+
const path = '/<%= plural_table_name %>/' + this.props.id
|
18
|
+
|
19
|
+
this.visit(path, options).then( rsp => {
|
20
|
+
if (this.props.errors) {
|
21
|
+
throw new SubmissionError({
|
22
|
+
...this.props.errors
|
23
|
+
})
|
24
|
+
}
|
25
|
+
})
|
12
26
|
}
|
13
27
|
|
14
28
|
render () {
|
@@ -19,8 +33,8 @@ class <%= plural_table_name.camelize %>Edit extends BaseScreen {
|
|
19
33
|
onSubmit={this.handleSubmit}
|
20
34
|
initialValues={this.props.attributes_for_form}
|
21
35
|
/>
|
22
|
-
<a onClick={ e => this.
|
23
|
-
<a onClick={ e => this.
|
36
|
+
<a onClick={ e => this.visit(this.props.meta.show_path)}>Show</a>
|
37
|
+
<a onClick={ e => this.visit(this.props.meta.index_path)}>Back</a>
|
24
38
|
</div>
|
25
39
|
)
|
26
40
|
}
|
@@ -15,9 +15,9 @@ class <%= plural_table_name.camelize %>Index extends BaseScreen {
|
|
15
15
|
<%- attributes_list.select{|attr| attr != :id }.each do |attr| -%>
|
16
16
|
<td>{<%=singular_table_name%>.<%=attr%>}</td>
|
17
17
|
<%- end -%>
|
18
|
-
<td><a onClick={ e => this.
|
19
|
-
<td><a onClick={ e => this.
|
20
|
-
<td><a onClick={ e => this.
|
18
|
+
<td><a onClick={ e => this.visit(<%=singular_table_name%>.meta.show_path)}>Show</a></td>
|
19
|
+
<td><a onClick={ e => this.visit(<%=singular_table_name%>.meta.edit_path)}>Edit</a></td>
|
20
|
+
<td><a onClick={ e => this.visit(<%=singular_table_name%>.meta.delete_path, {method: 'DELETE'})}>Delete</a></td>
|
21
21
|
</tr>
|
22
22
|
)
|
23
23
|
})
|
@@ -43,7 +43,7 @@ class <%= plural_table_name.camelize %>Index extends BaseScreen {
|
|
43
43
|
</tbody>
|
44
44
|
</table>
|
45
45
|
<br />
|
46
|
-
<a onClick={ e => this.
|
46
|
+
<a onClick={ e => this.visit(this.props.meta.new_path)}>New <%= singular_table_name.capitalize %></a>
|
47
47
|
</div>
|
48
48
|
)
|
49
49
|
}
|
@@ -3,12 +3,26 @@ import {mapStateToProps, mapDispatchToProps} from '@jho406/breezy'
|
|
3
3
|
import {delInPage} from '@jho406/breezy/dist/action_creators'
|
4
4
|
import {connect} from 'react-redux'
|
5
5
|
import BaseScreen from 'components/BaseScreen'
|
6
|
+
import {SubmissionError} from 'redux-form'
|
6
7
|
import <%= plural_table_name.camelize %>Form from 'components/<%= plural_table_name.camelize %>Form'
|
7
8
|
|
8
9
|
class <%= plural_table_name.camelize %>New extends BaseScreen {
|
9
|
-
handleSubmit(body) {
|
10
|
+
handleSubmit = (body) => {
|
10
11
|
this.props.delInPage({pageKey: this.props.pageKey, keypath: 'errors'})
|
11
|
-
|
12
|
+
|
13
|
+
const options = {
|
14
|
+
method:'POST',
|
15
|
+
body: JSON.stringify(body),
|
16
|
+
}
|
17
|
+
|
18
|
+
this.visit('/<%= plural_table_name %>', options).then( rsp => {
|
19
|
+
if (this.props.errors) {
|
20
|
+
throw new SubmissionError({
|
21
|
+
...this.props.errors
|
22
|
+
})
|
23
|
+
}
|
24
|
+
})
|
25
|
+
|
12
26
|
}
|
13
27
|
|
14
28
|
render () {
|
@@ -18,7 +32,7 @@ class <%= plural_table_name.camelize %>New extends BaseScreen {
|
|
18
32
|
error={this.props.error}
|
19
33
|
onSubmit={this.handleSubmit}
|
20
34
|
/>
|
21
|
-
<a onClick={ e => this.
|
35
|
+
<a onClick={ e => this.visit(this.props.meta.index_path)}>Back</a>
|
22
36
|
</div>
|
23
37
|
)
|
24
38
|
}
|
@@ -14,8 +14,8 @@ class <%= plural_table_name.camelize %>Show extends BaseScreen {
|
|
14
14
|
{this.props.<%=attr%>}
|
15
15
|
</p>
|
16
16
|
<%- end -%>
|
17
|
-
<a onClick={ e => this.
|
18
|
-
<a onClick={ e => this.
|
17
|
+
<a onClick={ e => this.visit(this.props.meta.edit_path)}>Edit</a>
|
18
|
+
<a onClick={ e => this.visit(this.props.meta.index_path)}>Back</a>
|
19
19
|
</div>
|
20
20
|
)
|
21
21
|
}
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: breezy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Johny Ho
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '5.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '5.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.5.
|
33
|
+
version: 0.5.4
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.5.
|
40
|
+
version: 0.5.4
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: webpacker
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: activerecord
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '5.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '5.0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rake
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -209,14 +223,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
209
223
|
version: '0'
|
210
224
|
requirements: []
|
211
225
|
rubyforge_project:
|
212
|
-
rubygems_version: 2.
|
226
|
+
rubygems_version: 2.5.2
|
213
227
|
signing_key:
|
214
228
|
specification_version: 4
|
215
229
|
summary: Rails integration for BreezyJS
|
216
230
|
test_files:
|
217
|
-
- test/
|
231
|
+
- test/render_test.rb
|
218
232
|
- test/configuration_test.rb
|
219
233
|
- test/engine_test.rb
|
220
|
-
- test/render_test.rb
|
221
234
|
- test/test_helper.rb
|
222
|
-
|
235
|
+
- test/breezy_test.rb
|