callback_request_bootstrap 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +100 -0
- data/Rakefile +37 -0
- data/app/assets/javascripts/callback_request_bootstrap/application.js +3 -0
- data/app/assets/stylesheets/callback_request_bootstrap/application.css.scss +3 -0
- data/app/assets/stylesheets/callback_request_bootstrap/requests.scss +4 -0
- data/app/controllers/callback_request_bootstrap/application_controller.rb +4 -0
- data/app/controllers/callback_request_bootstrap/requests_controller.rb +96 -0
- data/app/helpers/callback_request_bootstrap/application_helper.rb +4 -0
- data/app/helpers/callback_request_bootstrap/requests_helper.rb +19 -0
- data/app/models/callback_request_bootstrap/request.rb +5 -0
- data/app/views/callback_request_bootstrap/requests/_create_result.html.erb +8 -0
- data/app/views/callback_request_bootstrap/requests/_form.basic.html.erb +43 -0
- data/app/views/callback_request_bootstrap/requests/_form.html.erb +0 -0
- data/app/views/callback_request_bootstrap/requests/_form.simple_form.html.erb +49 -0
- data/app/views/callback_request_bootstrap/requests/_js_modal.html.erb +26 -0
- data/app/views/callback_request_bootstrap/requests/_modal.html.erb +20 -0
- data/app/views/callback_request_bootstrap/requests/create.js.erb +7 -0
- data/app/views/callback_request_bootstrap/requests/edit.html.erb +6 -0
- data/app/views/callback_request_bootstrap/requests/new.html.erb +1 -0
- data/app/views/layouts/callback_request_bootstrap/application.html.erb +14 -0
- data/config/initializers/simple_form.rb +166 -0
- data/config/initializers/simple_form_bootstrap.rb +136 -0
- data/config/locales/callback_request.en.yml +16 -0
- data/config/locales/callback_request.ru.yml +16 -0
- data/config/locales/simple_form.en.yml +31 -0
- data/config/routes.rb +5 -0
- data/lib/callback_request_bootstrap/engine.rb +12 -0
- data/lib/callback_request_bootstrap/version.rb +3 -0
- data/lib/callback_request_bootstrap.rb +4 -0
- data/lib/generators/callback_request_bootstrap/install_generator.rb +25 -0
- data/lib/generators/callback_request_bootstrap/templates/migrations/create_requests.rb +16 -0
- data/lib/tasks/callback_request_bootstrap_tasks.rake +4 -0
- data/test/callback_request_bootstrap_test.rb +7 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +3 -0
- data/test/dummy/app/assets/javascripts/jquery-1.11.2.min.js +4 -0
- data/test/dummy/app/assets/javascripts/jquery-2.1.3.min.js +4 -0
- data/test/dummy/app/assets/stylesheets/application.css.scss +1 -0
- data/test/dummy/app/controllers/application_controller.rb +8 -0
- data/test/dummy/app/controllers/debug_controller.rb +6 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/debug/index.html.erb +16 -0
- data/test/dummy/app/views/layouts/application.html.erb +15 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +29 -0
- data/test/dummy/config/application.rb +26 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +54 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +41 -0
- data/test/dummy/config/environments/production.rb +79 -0
- data/test/dummy/config/environments/test.rb +42 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/simple_form.rb +166 -0
- data/test/dummy/config/initializers/simple_form_bootstrap.rb +136 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/locales/simple_form.en.yml +31 -0
- data/test/dummy/config/routes.rb +7 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/migrate/20150403222226_create_requests.rb +16 -0
- data/test/dummy/db/schema.rb +27 -0
- data/test/dummy/log/development.log +1570 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/6aced6a4ee939748ecf9b1329793d18e21f3e7f3/application.css.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/718ee869a0f2dfa88cd3e1aac130baf9697d6696/_alerts.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/718ee869a0f2dfa88cd3e1aac130baf9697d6696/_badges.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/718ee869a0f2dfa88cd3e1aac130baf9697d6696/_breadcrumbs.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/718ee869a0f2dfa88cd3e1aac130baf9697d6696/_button-groups.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/718ee869a0f2dfa88cd3e1aac130baf9697d6696/_buttons.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/718ee869a0f2dfa88cd3e1aac130baf9697d6696/_carousel.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/718ee869a0f2dfa88cd3e1aac130baf9697d6696/_close.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/718ee869a0f2dfa88cd3e1aac130baf9697d6696/_code.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/718ee869a0f2dfa88cd3e1aac130baf9697d6696/_component-animations.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/718ee869a0f2dfa88cd3e1aac130baf9697d6696/_dropdowns.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/718ee869a0f2dfa88cd3e1aac130baf9697d6696/_forms.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/718ee869a0f2dfa88cd3e1aac130baf9697d6696/_glyphicons.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/718ee869a0f2dfa88cd3e1aac130baf9697d6696/_grid.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/718ee869a0f2dfa88cd3e1aac130baf9697d6696/_input-groups.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/718ee869a0f2dfa88cd3e1aac130baf9697d6696/_jumbotron.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/718ee869a0f2dfa88cd3e1aac130baf9697d6696/_labels.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/718ee869a0f2dfa88cd3e1aac130baf9697d6696/_list-group.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/718ee869a0f2dfa88cd3e1aac130baf9697d6696/_media.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/718ee869a0f2dfa88cd3e1aac130baf9697d6696/_mixins.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/718ee869a0f2dfa88cd3e1aac130baf9697d6696/_modals.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/718ee869a0f2dfa88cd3e1aac130baf9697d6696/_navbar.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/718ee869a0f2dfa88cd3e1aac130baf9697d6696/_navs.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/718ee869a0f2dfa88cd3e1aac130baf9697d6696/_normalize.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/718ee869a0f2dfa88cd3e1aac130baf9697d6696/_pager.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/718ee869a0f2dfa88cd3e1aac130baf9697d6696/_pagination.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/718ee869a0f2dfa88cd3e1aac130baf9697d6696/_panels.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/718ee869a0f2dfa88cd3e1aac130baf9697d6696/_popovers.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/718ee869a0f2dfa88cd3e1aac130baf9697d6696/_print.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/718ee869a0f2dfa88cd3e1aac130baf9697d6696/_progress-bars.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/718ee869a0f2dfa88cd3e1aac130baf9697d6696/_responsive-embed.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/718ee869a0f2dfa88cd3e1aac130baf9697d6696/_responsive-utilities.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/718ee869a0f2dfa88cd3e1aac130baf9697d6696/_scaffolding.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/718ee869a0f2dfa88cd3e1aac130baf9697d6696/_tables.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/718ee869a0f2dfa88cd3e1aac130baf9697d6696/_thumbnails.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/718ee869a0f2dfa88cd3e1aac130baf9697d6696/_tooltip.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/718ee869a0f2dfa88cd3e1aac130baf9697d6696/_type.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/718ee869a0f2dfa88cd3e1aac130baf9697d6696/_utilities.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/718ee869a0f2dfa88cd3e1aac130baf9697d6696/_variables.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/718ee869a0f2dfa88cd3e1aac130baf9697d6696/_wells.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7d96349ccfefec93f54a58b723a0db98810ff74d/_alerts.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7d96349ccfefec93f54a58b723a0db98810ff74d/_background-variant.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7d96349ccfefec93f54a58b723a0db98810ff74d/_border-radius.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7d96349ccfefec93f54a58b723a0db98810ff74d/_buttons.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7d96349ccfefec93f54a58b723a0db98810ff74d/_center-block.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7d96349ccfefec93f54a58b723a0db98810ff74d/_clearfix.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7d96349ccfefec93f54a58b723a0db98810ff74d/_forms.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7d96349ccfefec93f54a58b723a0db98810ff74d/_gradients.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7d96349ccfefec93f54a58b723a0db98810ff74d/_grid-framework.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7d96349ccfefec93f54a58b723a0db98810ff74d/_grid.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7d96349ccfefec93f54a58b723a0db98810ff74d/_hide-text.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7d96349ccfefec93f54a58b723a0db98810ff74d/_image.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7d96349ccfefec93f54a58b723a0db98810ff74d/_labels.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7d96349ccfefec93f54a58b723a0db98810ff74d/_list-group.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7d96349ccfefec93f54a58b723a0db98810ff74d/_nav-divider.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7d96349ccfefec93f54a58b723a0db98810ff74d/_nav-vertical-align.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7d96349ccfefec93f54a58b723a0db98810ff74d/_opacity.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7d96349ccfefec93f54a58b723a0db98810ff74d/_pagination.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7d96349ccfefec93f54a58b723a0db98810ff74d/_panels.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7d96349ccfefec93f54a58b723a0db98810ff74d/_progress-bar.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7d96349ccfefec93f54a58b723a0db98810ff74d/_reset-filter.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7d96349ccfefec93f54a58b723a0db98810ff74d/_resize.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7d96349ccfefec93f54a58b723a0db98810ff74d/_responsive-visibility.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7d96349ccfefec93f54a58b723a0db98810ff74d/_size.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7d96349ccfefec93f54a58b723a0db98810ff74d/_tab-focus.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7d96349ccfefec93f54a58b723a0db98810ff74d/_table-row.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7d96349ccfefec93f54a58b723a0db98810ff74d/_text-emphasis.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7d96349ccfefec93f54a58b723a0db98810ff74d/_text-overflow.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7d96349ccfefec93f54a58b723a0db98810ff74d/_vendor-prefixes.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/824891e7a161e94d30c60631d5ad49ffcc066f58/_bootstrap.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/0ae8a82e6f3efa698815c72449c15720 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2e95403dcbb917ca6437eeab5a90767d +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/3bcbaeef523408af8f5632a3f0d822ea +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6ba936e2555107029a6818a003401730 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/8ab512c9b33ac90e699b73469d71f061 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/9224343996967db929488ae8237b8253 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/b00d18a2eb4a905fd47dd3e8fc26134a +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/b4e755bffedb46ef020e7196a0cc36dd +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/bcca522c6302f184f12fe0e8a7d7e71a +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/c13fc73ceafa45876a901b3e775b83ae +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/c7d3f57d1eaa1109e44c8e3944e5c59b +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/e58ed93e38d0c962a358bd32577c8cfe +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/dummy/tmp/pids/server.pid +1 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/test_helper.rb +20 -0
- metadata +386 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: da7f2b5124df67e157802bef6a5cb5ed98027daa
|
4
|
+
data.tar.gz: e956428c089d0af1c3f8fde96b143ab9b0007e40
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7847e0ee6fbf6367560b9c4d6448827e4f1884833e817f6ce324bb8c39439b5b9b4b8946eee547f79353016cdf6a3296a8c21c2a63a66d25d9a0c13617d9041c
|
7
|
+
data.tar.gz: d0d9eea6bfb864bc0a7d22530bc9e489adb1edc23d7cd9c182b4d2f3c634a3b7999013738695ee262d83d7fe1c5a809d6b4e819d287442fc57a39980e2244a32
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2015 Max Ivak
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
= Callback Request with Bootstrap =
|
2
|
+
|
3
|
+
Rails gem to show a form for callback request in modal.
|
4
|
+
To be used with Bootstrap 3 and simple_form.
|
5
|
+
|
6
|
+
|
7
|
+
Requests for phone callbacks are stored in database.
|
8
|
+
|
9
|
+
|
10
|
+
== Installation ==
|
11
|
+
|
12
|
+
Gemfile:
|
13
|
+
```ruby
|
14
|
+
gem 'callback_request_bootstrap'
|
15
|
+
```
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
bundle install
|
19
|
+
```
|
20
|
+
|
21
|
+
install using generator:
|
22
|
+
```ruby
|
23
|
+
rails g request_callback_bootstrap:install
|
24
|
+
```
|
25
|
+
This will add the migrations.
|
26
|
+
|
27
|
+
Migrate the database:
|
28
|
+
```ruby
|
29
|
+
rake db:migrate
|
30
|
+
```
|
31
|
+
It will add table 'requests' to the database.
|
32
|
+
|
33
|
+
|
34
|
+
Your application should have jquery, jquery_ujs and bootstrap.js installed.
|
35
|
+
Your application.js might be:
|
36
|
+
```ruby
|
37
|
+
//= require jquery
|
38
|
+
//= require jquery_ujs
|
39
|
+
|
40
|
+
//= require bootstrap
|
41
|
+
or if you want to include only javascript for modal
|
42
|
+
//= require bootstrap/modal
|
43
|
+
|
44
|
+
```
|
45
|
+
|
46
|
+
mount engine in config/routes.rb:
|
47
|
+
```ruby
|
48
|
+
Rails.application.routes.draw do
|
49
|
+
|
50
|
+
mount CallbackRequestBootstrap::Engine => "/callback"
|
51
|
+
|
52
|
+
..
|
53
|
+
end
|
54
|
+
|
55
|
+
```
|
56
|
+
|
57
|
+
Link to show form in modal:
|
58
|
+
```ruby
|
59
|
+
<%=link_to_callback_modal "Request callback", '#', :class=>'btn' %>
|
60
|
+
|
61
|
+
```
|
62
|
+
This helper generates a link with css class 'callback_link'.
|
63
|
+
|
64
|
+
or add class 'callback_link' to your link:
|
65
|
+
```ruby
|
66
|
+
=link_to 'Request callback', '#', :class=>'btn btn-primary callback_link'
|
67
|
+
```
|
68
|
+
|
69
|
+
include on page (usually at the end of the page where you place the link):
|
70
|
+
```ruby
|
71
|
+
<%= render 'callback_request_bootstrap/requests/js_modal'%>
|
72
|
+
```
|
73
|
+
This will add necessary scripts for modal.
|
74
|
+
|
75
|
+
|
76
|
+
= Options =
|
77
|
+
|
78
|
+
== Autoclose ==
|
79
|
+
To close modal after a request is setn, use option 'autoclose' for a link:
|
80
|
+
```ruby
|
81
|
+
<%=link_to "Show modal with autoclose", '#', :class=>'btn btn-default callback_link', :data=>{'autoclose'=>5} %>
|
82
|
+
```
|
83
|
+
This will close modal in 5 seconds.
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
== Customization ==
|
88
|
+
|
89
|
+
=== Form ===
|
90
|
+
|
91
|
+
Use generator to copy views to your application.
|
92
|
+
Edit views in /app/views/callback_request_bootstrap/.
|
93
|
+
|
94
|
+
If you want to edit fields in the form, then edit view '_form.simple_form.html.erb'.
|
95
|
+
|
96
|
+
|
97
|
+
=== Localization ===
|
98
|
+
|
99
|
+
Copy file config/locales/callback_request.en.yml to your application in config/locales/callback_request.LANG.yml.
|
100
|
+
Edit the file.
|
data/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'CallbackRequestBootstrap'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
load 'rails/tasks/statistics.rake'
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
Bundler::GemHelper.install_tasks
|
26
|
+
|
27
|
+
require 'rake/testtask'
|
28
|
+
|
29
|
+
Rake::TestTask.new(:test) do |t|
|
30
|
+
t.libs << 'lib'
|
31
|
+
t.libs << 'test'
|
32
|
+
t.pattern = 'test/**/*_test.rb'
|
33
|
+
t.verbose = false
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
task default: :test
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require_dependency "callback_request_bootstrap/application_controller"
|
2
|
+
|
3
|
+
module CallbackRequestBootstrap
|
4
|
+
class RequestsController < ApplicationController
|
5
|
+
before_action :set_request, only: [:edit, :update, :destroy]
|
6
|
+
before_action :set_modal, only: [:new, :create, :create_result]
|
7
|
+
|
8
|
+
# GET /requests/new
|
9
|
+
def new
|
10
|
+
@autoclose = (params[:autoclose] || 0).to_i
|
11
|
+
|
12
|
+
#
|
13
|
+
@request = Request.new
|
14
|
+
|
15
|
+
if @modal==1
|
16
|
+
render :layout => false and return
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
# GET /requests/1/edit
|
22
|
+
def edit
|
23
|
+
end
|
24
|
+
|
25
|
+
# POST /requests
|
26
|
+
def create
|
27
|
+
@autoclose = (params[:autoclose] || 0).to_i
|
28
|
+
|
29
|
+
@request = Request.new(request_params)
|
30
|
+
@res = @request.save
|
31
|
+
|
32
|
+
|
33
|
+
#@res = false # debug
|
34
|
+
|
35
|
+
flash.now[:notice] = @res ? t('callback_request.messages.success') : t('callback_request.messages.error')
|
36
|
+
|
37
|
+
respond_to do |format|
|
38
|
+
if @res
|
39
|
+
format.html {
|
40
|
+
redirect_to create_result_request_path(modal: @modal), notice: t('callback_request.messages.success')
|
41
|
+
}
|
42
|
+
format.js{
|
43
|
+
|
44
|
+
}
|
45
|
+
#format.json { render json: @request, status: :created, location: @request }
|
46
|
+
else
|
47
|
+
format.html {
|
48
|
+
if @modal==1
|
49
|
+
render :new, :layout => false
|
50
|
+
return
|
51
|
+
end
|
52
|
+
|
53
|
+
render :new
|
54
|
+
}
|
55
|
+
|
56
|
+
format.js{ }
|
57
|
+
#format.json { render json: @request.errors, status: :unprocessable_entity }
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def create_result
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
# PATCH/PUT /requests/1
|
68
|
+
def update
|
69
|
+
if @request.update(request_params)
|
70
|
+
redirect_to @request, notice: 'Request was successfully updated.'
|
71
|
+
else
|
72
|
+
render :edit
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# DELETE /requests/1
|
77
|
+
def destroy
|
78
|
+
@request.destroy
|
79
|
+
redirect_to requests_url, notice: 'Request was successfully destroyed.'
|
80
|
+
end
|
81
|
+
|
82
|
+
private
|
83
|
+
|
84
|
+
def set_request
|
85
|
+
@request = Request.find(params[:id])
|
86
|
+
end
|
87
|
+
|
88
|
+
def request_params
|
89
|
+
params.require(:request).permit(:name, :email, :phone, :notes)
|
90
|
+
end
|
91
|
+
|
92
|
+
def set_modal
|
93
|
+
@modal = (params[:modal] || 0).to_i rescue 0
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module CallbackRequestBootstrap
|
2
|
+
module RequestsHelper
|
3
|
+
|
4
|
+
def link_to_callback_modal(title, options = nil, html_options = nil)
|
5
|
+
html_options ||= {}
|
6
|
+
html_options[:class] ||= []
|
7
|
+
|
8
|
+
if html_options[:class].is_a? Array
|
9
|
+
html_options[:class] << 'callback_link' # append as element to array
|
10
|
+
else
|
11
|
+
html_options[:class] << ' callback_link' # append with leading space to string
|
12
|
+
end
|
13
|
+
|
14
|
+
#link_to title, '#', opts.merge(html_options)
|
15
|
+
link_to title, options, html_options
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
|
2
|
+
<% if flash[:notice] %>
|
3
|
+
<div class="alert alert-<%= @res ? 'success' : 'danger'%>" role="alert"><%= flash[:notice] %></div>
|
4
|
+
<% end %>
|
5
|
+
|
6
|
+
<% if @modal==1 %>
|
7
|
+
<button type="button" class="btn btn-default" data-dismiss="modal"><%=t('callback_request.close')%></button>
|
8
|
+
<% end %>
|
@@ -0,0 +1,43 @@
|
|
1
|
+
<span><%=t('callback_request.description')%></span>
|
2
|
+
|
3
|
+
<%= form_for @request, :remote=> true, :html=>{class: "form-horizontal", role: "form"} do |f| %>
|
4
|
+
<%= hidden_field_tag :modal, @modal %>
|
5
|
+
|
6
|
+
<% if @request.errors.any? %>
|
7
|
+
<div id="error_explanation">
|
8
|
+
<h2><%=t 'callback_request.errors', n: pluralize(@request.errors.count, "error") %></h2>
|
9
|
+
<ul>
|
10
|
+
<% @request.errors.full_messages.each do |message| %>
|
11
|
+
<li><%= message %></li>
|
12
|
+
<% end %>
|
13
|
+
</ul>
|
14
|
+
</div>
|
15
|
+
<% end %>
|
16
|
+
|
17
|
+
<div class="form-group">
|
18
|
+
<%= f.label :name, t('callback_request.fields.name'), class: "col-sm-2 control-label" %>
|
19
|
+
<div class="col-sm-6">
|
20
|
+
<%= f.text_field :name, :class=>'form-control' %>
|
21
|
+
</div>
|
22
|
+
</div>
|
23
|
+
<div class="form-group">
|
24
|
+
<%= f.label :phone, t('callback_request.fields.phone'), class: "col-sm-2 control-label" %>
|
25
|
+
<div class="col-sm-6">
|
26
|
+
<%= f.text_field :phone, :class=>'form-control' %>
|
27
|
+
</div>
|
28
|
+
</div>
|
29
|
+
<div class="form-group">
|
30
|
+
<%= f.label :notes, t('callback_request.fields.notes'), class: "col-sm-2 control-label" %>
|
31
|
+
<div class="col-sm-6">
|
32
|
+
<%= f.text_area :notes, :class=>'form-control' %>
|
33
|
+
</div>
|
34
|
+
</div>
|
35
|
+
|
36
|
+
<div class="form-group">
|
37
|
+
<div class="col-sm-offset-2 col-sm-10">
|
38
|
+
<%-# = f.submit t('callback_request.submit'), :class=>'btn btn-primary' -%>
|
39
|
+
<button type="button" class="btn btn-primary" name="submit"><%=t('callback_request.submit')%></button>
|
40
|
+
</div>
|
41
|
+
</div>
|
42
|
+
|
43
|
+
<% end %>
|
File without changes
|
@@ -0,0 +1,49 @@
|
|
1
|
+
|
2
|
+
<div id="div_callback_request">
|
3
|
+
|
4
|
+
<span><%=t('callback_request.description')%></span>
|
5
|
+
|
6
|
+
<%= simple_form_for @request, remote: true, html: {class: "form-horizontal", role: "form"} do |f| %>
|
7
|
+
<%= hidden_field_tag :modal, @modal %>
|
8
|
+
<%= hidden_field_tag :autoclose, @autoclose %>
|
9
|
+
|
10
|
+
|
11
|
+
<% if @request.errors.any? %>
|
12
|
+
<div id="error_explanation">
|
13
|
+
<h2><%=t 'callback_request.errors', n: pluralize(@request.errors.count, "error") %></h2>
|
14
|
+
<ul>
|
15
|
+
<% @request.errors.full_messages.each do |message| %>
|
16
|
+
<li><%= message %></li>
|
17
|
+
<% end %>
|
18
|
+
</ul>
|
19
|
+
</div>
|
20
|
+
<% end %>
|
21
|
+
|
22
|
+
<div class="form-group">
|
23
|
+
<%= f.label :name, t('callback_request.fields.name'), class: "col-sm-2 control-label" %>
|
24
|
+
<div class="col-sm-6">
|
25
|
+
<%= f.text_field :name, :class=>'form-control', required: true %>
|
26
|
+
</div>
|
27
|
+
</div>
|
28
|
+
<div class="form-group">
|
29
|
+
<%= f.label :phone, t('callback_request.fields.phone'), class: "col-sm-2 control-label" %>
|
30
|
+
<div class="col-sm-6">
|
31
|
+
<%= f.text_field :phone, :class=>'form-control', required: true %>
|
32
|
+
</div>
|
33
|
+
</div>
|
34
|
+
<div class="form-group">
|
35
|
+
<%= f.label :notes, t('callback_request.fields.notes'), class: "col-sm-2 control-label" %>
|
36
|
+
<div class="col-sm-6">
|
37
|
+
<%= f.text_area :notes, :class=>'form-control' %>
|
38
|
+
</div>
|
39
|
+
</div>
|
40
|
+
|
41
|
+
<div class="form-group">
|
42
|
+
<div class="col-sm-offset-2 col-sm-10">
|
43
|
+
<%= f.submit t('callback_request.submit'), :class=>'btn btn-primary' %>
|
44
|
+
</div>
|
45
|
+
</div>
|
46
|
+
|
47
|
+
<% end %>
|
48
|
+
|
49
|
+
</div>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<%= render 'callback_request_bootstrap/requests/modal' %>
|
2
|
+
|
3
|
+
<script>
|
4
|
+
|
5
|
+
$( document ).ready(function() {
|
6
|
+
$('.callback_link').click(function(event) {
|
7
|
+
$('#modCallback .divContFormCallback').html('');
|
8
|
+
$('#modCallback').modal('show');
|
9
|
+
|
10
|
+
var v = $(this).attr('data-autoclose');
|
11
|
+
var autoclose = v ? v : 0;
|
12
|
+
|
13
|
+
$.get("<%=callback_request_bootstrap.new_request_path()%>", {modal: "1", autoclose: autoclose},
|
14
|
+
function(data) {
|
15
|
+
$('#modCallback .divContFormCallback').html(data);
|
16
|
+
|
17
|
+
//callbackform_after_load();
|
18
|
+
}
|
19
|
+
);
|
20
|
+
|
21
|
+
event.preventDefault();
|
22
|
+
});
|
23
|
+
|
24
|
+
});
|
25
|
+
|
26
|
+
</script>
|