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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3b54ccc8a8f4bb97f78ed3370247b9f72da24685
4
- data.tar.gz: b486a30659731e319926a27404dfcc785b65e6f1
3
+ metadata.gz: fb43f13ec70155872dfc74693dad99bde8a0e6fe
4
+ data.tar.gz: e1f14e0f6b31786f5308e932391b6bbed5f2db0b
5
5
  SHA512:
6
- metadata.gz: 8a5dcf4a8f25f4004bc1dad76d7f67de6eae71055a3d0537313a981dd5d522e8c3894e646c54187ab8e359187c2d00adb83759d50cf2672f6c9ef77718cfd810
7
- data.tar.gz: 262e322c1f2727160222de954d53544d179bea4a181435b144f7974b9b8cd7eb3e1cdca86f6ff3cb991384dd8f6a7aed09b5709b332de7d1bf402be1d138f1d1
6
+ metadata.gz: debe7eace5d5fac99323d56e3c8667dca975d62d5c9402c21f5a7f6943e645fc3a147c890e10f94c09ea686fe3f81419418c70ed8a7f1e486237f732b240dd9b
7
+ data.tar.gz: 46bdd75bbb49d8975c8a4f2bece8208b696138142d4dce4991b581051e25e41382f30adeb8e110ac928bb8b7c2091d829be49e2f0a6e0ea3d3d1da89b2f57c93
@@ -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
- view_parts = _prefixes.reverse.push(action_name)[1..-1]
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
@@ -21,6 +21,8 @@ module Breezy
21
21
  self.status = 200
22
22
  response.headers["X-BREEZY-LOCATION"] = url
23
23
  end
24
+
25
+ url
24
26
  end
25
27
 
26
28
  private
@@ -1,68 +1,12 @@
1
1
  import React from 'react'
2
- import {SubmissionError} from 'redux-form'
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
- this.handleSubmit = this.handleSubmit.bind(this)
8
- this.handleClick = this.handleClick.bind(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
- return super.handleSubmit('/<%= plural_table_name %>/' + this.props.id, body, 'PATCH')
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.handleClick(this.props.meta.show_path)}>Show</a>
23
- <a onClick={ e => this.handleClick(this.props.meta.index_path)}>Back</a>
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.handleClick(<%=singular_table_name%>.meta.show_path)}>Show</a></td>
19
- <td><a onClick={ e => this.handleClick(<%=singular_table_name%>.meta.edit_path)}>Edit</a></td>
20
- <td><a onClick={ e => this.handleClick(<%=singular_table_name%>.meta.delete_path, 'DELETE')}>Delete</a></td>
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.handleClick(this.props.meta.new_path)}>New <%= singular_table_name.capitalize %></a>
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
- return super.handleSubmit('/<%= plural_table_name %>', body, 'POST')
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.handleClick(this.props.meta.index_path)}>Back</a>
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.handleClick(this.props.meta.edit_path)}>Edit</a>
18
- <a onClick={ e => this.handleClick(this.props.meta.index_path)}>Back</a>
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.3
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-05-01 00:00:00.000000000 Z
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.3
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.3
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.4.5.1
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/breezy_test.rb
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
- has_rdoc:
235
+ - test/breezy_test.rb