rao-service_controller 0.0.23.pre → 0.0.24.pre

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df3cd50c485d169f7a4acb888e00b38d76e515495feab9d964686a3b2a5066ff
4
- data.tar.gz: cba83c7da930482ab442914a89240c4591bca52d6bc22ee37e1cf9de602be1e7
3
+ metadata.gz: f6a408511ba775bffd8b2b70f924e65df12044df25a1038e95bd51b16537a271
4
+ data.tar.gz: 39ee4104f95634437525585d129ee5b3e66e00cea76cadb9e09f5921a7932a33
5
5
  SHA512:
6
- metadata.gz: 9951d370e7cd13850ec3343c7b281b750ed4764cb7d95e2f1bbda4e0006382aba7d7ab89fc9aec4df003c778373e9c81b0c61fe84486f1561caa589e037e92d7
7
- data.tar.gz: 27eec077af569a8fa6b1c8cef3e5f168e0ba1858e5c3138ba589459ee1d9efab09ae4ca4205922ffd67c28d9b7b16281e8787924bd2d694ec33b38b35203877f
6
+ metadata.gz: 3d7414b40c28a85d834056f2d0415e3332c5788a6132c46701587db28d0b8b0fa56a88a7a30aa7f0bffb2ce0f7afc0e0c8f105dbc0842171c383b1073c5e6ae8
7
+ data.tar.gz: ccdda2bfe6687430525425ab60ab9c1bb0baec894f501da7a25866f846a433b29c1b912f6fd9fc710855272e8d5866c15de40aec553252d0df304933d898cf2c
@@ -0,0 +1,6 @@
1
+ $(document).ready(function () {
2
+ $('[data-auto-submit="true"]').each(function () {
3
+ $(this).closest("form").append('<div class="loading">Loading&#8230;</div>');
4
+ $(this).closest("form").submit();
5
+ });
6
+ });
@@ -1,3 +1,4 @@
1
1
  Rails.application.config.assets.precompile += %w(
2
2
  rao-service_controller.css
3
+ rao/service_controller/application/auto_submit.js
3
4
  )
@@ -0,0 +1,53 @@
1
+ module Rao
2
+ module ServiceController
3
+ # Handles automatic form submits.
4
+ #
5
+ # Prerequisites:
6
+ #
7
+ # * jQuery
8
+ # * Rao::ViewHelper
9
+ #
10
+ # Include the javascript:
11
+ #
12
+ # # app/assets/javascripts/application.js
13
+ # //= require rao/service_controller/application/auto_submit
14
+ #
15
+ # Example:
16
+ #
17
+ # # app/controllers/posts_controller.rb
18
+ # require 'rao/service_controller/auto_submit_concern'
19
+ # require 'rao/service_controller/auto_submit_view_helper'
20
+ #
21
+ # class PostsController < ApplicationController
22
+ # include Rao::ServiceController::AutoSubmitConcern
23
+ # view_helper Rao::ServiceController::AutoSubmitViewHelper, as: :auto_submit_helper
24
+ #
25
+ # # ...
26
+ #
27
+ # private
28
+ #
29
+ # def auto_submit?
30
+ # true
31
+ # end
32
+ # end
33
+ #
34
+ # # app/views/posts/new.html.haml
35
+ # = form_for(...) do |f|
36
+ # = auto_submit_helper(self).form_field
37
+ #
38
+ module AutoSubmitConcern
39
+ extend ActiveSupport::Concern
40
+
41
+ private
42
+
43
+ # Overwrite this method to control the auto submission of the form.
44
+ def auto_submit?
45
+ false
46
+ end
47
+
48
+ def auto_submit_now?
49
+ auto_submit? && action_name == 'new'
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,36 @@
1
+ require 'rao/view_helper/base'
2
+
3
+ module Rao
4
+ module ServiceController
5
+ # Example:
6
+ #
7
+ # # app/controllers/application_controller.rb
8
+ # require 'rao/service_controller/auto_submit_view_helper'
9
+ #
10
+ # class ApplicationController < ActionController::Base
11
+ # view_helper Rao::ServiceController::AutoSubmitViewHelper, as: :auto_submit_helper
12
+ # end
13
+ #
14
+ class AutoSubmitViewHelper < Rao::ViewHelper::Base
15
+ # Example:
16
+ #
17
+ # # app/views/posts/new.html.haml
18
+ # = form_for(...) do |f|
19
+ # = auto_submit_helper(self).form_field
20
+ #
21
+ def form_field
22
+ if auto_submit_now?
23
+ c.content_tag(:div, nil, data: { 'auto-submit': true } ).html_safe
24
+ end
25
+ end
26
+
27
+ def auto_submit?
28
+ c.controller.send(:auto_submit?)
29
+ end
30
+
31
+ def auto_submit_now?
32
+ c.controller.send(:auto_submit_now?)
33
+ end
34
+ end
35
+ end
36
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rao-service_controller
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.23.pre
4
+ version: 0.0.24.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roberto Vasquez Angel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-02 00:00:00.000000000 Z
11
+ date: 2019-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -146,10 +146,10 @@ files:
146
146
  - MIT-LICENSE
147
147
  - README.md
148
148
  - Rakefile
149
+ - app/assets/javascripts/rao/service_controller/application/auto_submit.js
149
150
  - app/assets/stylesheets/rao-service_controller.css
150
151
  - app/assets/stylesheets/rao/service_controller/application.css
151
152
  - app/assets/stylesheets/rao/service_controller/application/table_monospaced.css
152
- - app/concerns/rao/controller/autosubmit_concern.rb
153
153
  - app/concerns/rao/service_controller/location_history_concern.rb
154
154
  - app/concerns/rao/service_controller/rest_actions_concern.rb
155
155
  - app/concerns/rao/service_controller/rest_service_urls_concern.rb
@@ -169,6 +169,8 @@ files:
169
169
  - lib/generators/rao/service_controller/templates/initializer.rb
170
170
  - lib/rao-service_controller.rb
171
171
  - lib/rao/service_controller.rb
172
+ - lib/rao/service_controller/auto_submit_concern.rb
173
+ - lib/rao/service_controller/auto_submit_view_helper.rb
172
174
  - lib/rao/service_controller/configuration.rb
173
175
  - lib/rao/service_controller/engine.rb
174
176
  - lib/rao/service_controller/version.rb
@@ -1,50 +0,0 @@
1
- module Raos
2
- module Controller
3
- # Handles automatic form submits.
4
- #
5
- # Prerequisites:
6
- #
7
- # Include the javascript:
8
- #
9
- # # app/assets/javascripts/application.js
10
- # //= require rails/add_ons/application/autosubmit
11
- #
12
- # Example:
13
- #
14
- # # app/controllers/posts_controller.rb
15
- # class PostsController < ApplicationController
16
- # include AutosubmitConcern
17
- #
18
- # # ...
19
- #
20
- # private
21
- #
22
- # def autosubmit?
23
- # true
24
- # end
25
- # end
26
- #
27
- # # app/views/posts/new.html.haml
28
- # = form_for(...) do |f|
29
- # = autosubmit
30
- #
31
- module AutosubmitConcern
32
- extend ActiveSupport::Concern
33
-
34
- included do
35
- helper Rao::AutosubmitHelper
36
- helper_method :autosubmit?, :autosubmit_now?
37
- end
38
-
39
- private
40
-
41
- def autosubmit?
42
- false
43
- end
44
-
45
- def autosubmit_now?
46
- autosubmit? && action_name == 'new'
47
- end
48
- end
49
- end
50
- end