c80_order_form 0.1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.travis.yml +3 -0
  4. data/CODE_OF_CONDUCT.md +13 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +76 -0
  8. data/Rakefile +1 -0
  9. data/app/admin/c80_order_form/message_orders.rb +20 -0
  10. data/app/assets/images/lo.gif +0 -0
  11. data/app/assets/javascripts/c80_order_form.js.coffee +1 -0
  12. data/app/assets/javascripts/frontend/ajax_form.js +154 -0
  13. data/app/assets/stylesheets/backend/active_admin_custom.scss +8 -0
  14. data/app/assets/stylesheets/c80_order_form.scss +4 -0
  15. data/app/assets/stylesheets/c80_order_form_active_admin.scss +5 -0
  16. data/app/assets/stylesheets/frontend/form.scss +3 -0
  17. data/app/assets/stylesheets/frontend/loading.scss +14 -0
  18. data/app/controllers/c80_order_form/application_controller.rb +5 -0
  19. data/app/controllers/c80_order_form/mess_controller.rb +24 -0
  20. data/app/controllers/c80_order_form/site_controller.rb +7 -0
  21. data/app/helpers/c80_order_form/site_helper.rb +23 -0
  22. data/app/mailers/c80_order_form/message_order_mailer.rb +28 -0
  23. data/app/models/c80_order_form/message_order.rb +5 -0
  24. data/app/models/c80_order_form/message_order_validator.rb +50 -0
  25. data/app/views/c80_order_form/mess/handle_message_order.js.erb +4 -0
  26. data/app/views/c80_order_form/message_order_mailer/mail_mess.html.erb +1 -0
  27. data/app/views/c80_order_form/site/give_me_form.js.erb +3 -0
  28. data/app/views/c80_order_form/site/shared/_ok_message.html.erb +16 -0
  29. data/app/views/c80_order_form/site/shared/_order_form.html.erb +67 -0
  30. data/bin/console +14 -0
  31. data/bin/setup +7 -0
  32. data/c80_order_form.gemspec +24 -0
  33. data/config/routes.rb +4 -0
  34. data/db/migrate/20151221164444_create_c80_order_form_message_orders.rb +12 -0
  35. data/lib/c80_order_form/engine.rb +23 -0
  36. data/lib/c80_order_form/version.rb +3 -0
  37. data/lib/c80_order_form.rb +8 -0
  38. metadata +108 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8d170f1173fd71f93027b511d02ba41553874152
4
+ data.tar.gz: fa27995fb62a5338762c27a91a84903bbc71b999
5
+ SHA512:
6
+ metadata.gz: c98e9e303cacb777586300c5d4296923f03393ae39e3e2bb58e7d443477feef5ddc89c18b195f331761ea0cdd2f93328900d2a873cc7ed80a07bb0451de547eb
7
+ data.tar.gz: 649ffe5fde65d019f380c363cc0ecf12758f6de1c76493937f1ca10a5f4557f193ac474e3341d1ef4c570c4b57245e6f6208e1e8ae43acbabd248cfc6f62495f
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.idea/
2
+ /.bundle/
3
+ /.yardoc
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.4
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in c80_order_form.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 C80609A
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,76 @@
1
+ [![Gem Version](https://badge.fury.io/rb/c80_order_form.svg)](http://badge.fury.io/rb/c80_order_form)
2
+ [![Build Status](https://travis-ci.org/c080609a/c80_order_form.svg?branch=master)](https://travis-ci.org/c080609a/c80_order_form)
3
+
4
+ # C80OrderForm
5
+
6
+ This gem allows to users to send order messages from site.
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'c80_order_form'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install c80_order_form
23
+
24
+ ## Usage
25
+
26
+ NOTE: This gem uses `activeadmin` gem, `jQuery` gem, `bootstrap-sass` gem and `c80_modal_forms` gem.
27
+
28
+ Ensure, that your application's `Gemfile` contains these lines:
29
+ ```ruby
30
+ # active admin
31
+ gem 'activeadmin'
32
+ gem 'devise'
33
+ gem 'cancan' # or cancancan
34
+ gem 'draper'
35
+ gem 'pundit'
36
+
37
+ gem 'jquery-rails'
38
+ gem 'bootstrap-sass'
39
+ gem 'c80_modal_forms'
40
+ ```
41
+
42
+ You will need to add these lines into your `application.js`:
43
+
44
+ //= require bootstrap/modal
45
+ //= require c80_modals_form
46
+ //= require c80_order_form
47
+
48
+ And add this line into `application.scss`:
49
+
50
+ @import "bootstrap-sprockets";
51
+ @import "bootstrap";
52
+ @import "c80_order_form";
53
+
54
+ Add this line into `active_admin.scss`:
55
+
56
+ @import "c80_order_form_active_admin";
57
+
58
+ Add this line into `routes.rb`:
59
+
60
+ mount C80OrderForm::Engine => '/'
61
+
62
+ Form invoked by link with class `c80_order_invoking_btn`.
63
+
64
+ ## Development
65
+
66
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
67
+
68
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
69
+
70
+ ## Contributing
71
+
72
+ 1. Fork it ( https://github.com/c080609a/c80_order_form/fork )
73
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
74
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
75
+ 4. Push to the branch (`git push origin my-new-feature`)
76
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,20 @@
1
+ ActiveAdmin.register C80OrderForm::MessageOrder, :as => 'MessageOrder' do
2
+
3
+ before_filter :skip_sidebar!, :only => :index
4
+
5
+ menu :parent => 'Сообщения', :label => 'Заявки' # TODO_MY:: слово "заявки" перенести в базу, в настройки гема
6
+
7
+ index do
8
+ selectable_column
9
+ id_column
10
+ column :created_at
11
+ column :name
12
+ column :email_or_phone
13
+ column :comment do |msg|
14
+ msg.comment.html_safe if msg.comment.present?
15
+ end
16
+
17
+ actions
18
+ end
19
+
20
+ end
Binary file
@@ -0,0 +1 @@
1
+ #= require frontend/ajax_form
@@ -0,0 +1,154 @@
1
+ // Содержит функцию, которая запрашивает
2
+ // html форму с сервера, предварительно
3
+ // показывая прелоадер.
4
+ //
5
+ // Код иницализируется и начинает своё исполнение,
6
+ // если на странице есть хотя бы одна кнопка класса
7
+ // c80_order_invoking_btn
8
+
9
+ var orderForm;
10
+ var $c80OrderInvokingBtns;
11
+ var okMessage;
12
+
13
+ $(function () {
14
+
15
+ $c80OrderInvokingBtns = $('.c80_order_invoking_btn');
16
+
17
+ if ($c80OrderInvokingBtns.length > 0) {
18
+
19
+ var loading = (function () {
20
+
21
+ var _$lo;
22
+
23
+ var _fInit = function () {
24
+ _$lo = $('<div id="lo"></div>');
25
+ };
26
+
27
+ var fShow = function ($clickedButton) {
28
+
29
+ _$lo.appendTo($('body'));
30
+
31
+ var top = $clickedButton.offset().top;
32
+ var left = $clickedButton.offset().left;
33
+ left -= _$lo.width() + 10;
34
+ top = top + $clickedButton.height()/2 - _$lo.height()/2;
35
+
36
+ _$lo.css("top",top+"px");
37
+ _$lo.css("left",left+"px");
38
+ };
39
+
40
+ var fHide = function () {
41
+ _$lo.addClass('invis');
42
+ setTimeout(function () {
43
+ _$lo.remove();
44
+ _$lo.removeClass('invis');
45
+ }, 1000);
46
+ };
47
+
48
+ _fInit();
49
+
50
+ return {
51
+ show:fShow,
52
+ hide:fHide
53
+ }
54
+
55
+ })();
56
+
57
+ orderForm = (function () {
58
+
59
+ var _markInvalidateInProgress = false;
60
+ var _markWasPasted = false;
61
+ var __$f;
62
+
63
+ var init = function () {
64
+ $c80OrderInvokingBtns.click(function (e) {
65
+ var $t = $(this);
66
+ e.preventDefault();
67
+ _fGetOrderForm($t);
68
+ loading.show($t);
69
+ });
70
+ };
71
+
72
+ var _fGetOrderForm = function ($clickedButton) {
73
+ if (!_markInvalidateInProgress) {
74
+ _markInvalidateInProgress = true;
75
+
76
+ if (!_markWasPasted) {
77
+
78
+ var predefined_comment = '';
79
+ if ($clickedButton.data('comment-text') != undefined) {
80
+ predefined_comment = $clickedButton.data('comment-text');
81
+ }
82
+
83
+ $.ajax({
84
+ url: '/give_me_order_form',
85
+ data:{predefined_comment:predefined_comment},
86
+ type: 'POST',
87
+ dataType: 'script'
88
+ }).done(function (data, result) {
89
+ if (result == "success") {
90
+ _markWasPasted = true;
91
+ _markInvalidateInProgress = false;
92
+ }
93
+ });
94
+ }
95
+ }
96
+ };
97
+
98
+ var fShowForm = function (html_str) {
99
+
100
+ var $cc = $('body');
101
+ $cc.append($(html_str));
102
+
103
+ __$f = $('#order_form');
104
+ __$f.on('hidden.bs.modal', __fRemoveForm);
105
+
106
+ var $form = $("form#form_order");
107
+ $form.bind("ajax:error", function (event, data, status, xhr) {
108
+ $form.render_form_errors($.parseJSON(data.responseText));
109
+ });
110
+
111
+ setTimeout(function () {
112
+ __$f.modal();
113
+ loading.hide();
114
+ },1000);
115
+
116
+ };
117
+
118
+ var fHideForm = function () {
119
+ __$f.modal('hide');
120
+ };
121
+
122
+ var __fRemoveForm = function () {
123
+ __$f.remove();
124
+ _markWasPasted = false;
125
+ };
126
+
127
+ return {
128
+ init: init,
129
+ show: fShowForm,
130
+ hide: fHideForm
131
+ }
132
+
133
+ })();
134
+
135
+ okMessage = (function () {
136
+
137
+ var fShow = function () {
138
+ var $form = $("#modal_ok");
139
+ $form.modal();
140
+ $form.on('hidden.bs.modal', function () {
141
+ $form.remove();
142
+ });
143
+ };
144
+
145
+ return {
146
+ show:fShow
147
+ }
148
+
149
+ })();
150
+
151
+ orderForm.init();
152
+ }
153
+
154
+ });
@@ -0,0 +1,8 @@
1
+ body.admin_message_orders {
2
+ // прячем кнопку batch actions
3
+ //.table_tools { display: none; }
4
+ // прячем кнопку "создать новую запись"
5
+ div.action_items { display: none; }
6
+ //прячем ссылку "редактировать"
7
+ a.edit_link { display: none; }
8
+ }
@@ -0,0 +1,4 @@
1
+ /*
2
+ *= require_self
3
+ */
4
+ @import "frontend/*";
@@ -0,0 +1,5 @@
1
+ /*
2
+ *= require_self
3
+ */
4
+
5
+ @import "backend/active_admin_custom";
@@ -0,0 +1,3 @@
1
+ .kapcha {
2
+ display: none;
3
+ }
@@ -0,0 +1,14 @@
1
+ #lo {
2
+ position: absolute;
3
+ width: 50px;
4
+ height: 17px;
5
+ background: transparent url(image_path('lo.gif')) no-repeat 50% 50%;
6
+ z-index: 120;
7
+ transition: visibility 1s, opacity 0.5s linear;
8
+
9
+ &.invis {
10
+ visibility: hidden;
11
+ opacity: 0;
12
+ }
13
+
14
+ }
@@ -0,0 +1,5 @@
1
+ module C80OrderForm
2
+ class ApplicationController < ActionController::Base
3
+ protect_from_forgery with: :exception
4
+ end
5
+ end
@@ -0,0 +1,24 @@
1
+ module C80OrderForm
2
+ class MessController < ApplicationController
3
+
4
+ def handle_message_order
5
+ puts "<MessController.handle_message_order>"
6
+ m = MessageOrder.new(mess_params)
7
+ respond_to do |format|
8
+ if m.save
9
+
10
+ format.js
11
+ MessageOrderMailer.send_mess(m, "Заявка").deliver # TODO_MY:: слово "заявка" поместить в базу, в модель настроек гема
12
+ else
13
+ puts "<MessController.handle_message_order> errors: #{m.errors}"
14
+ format.js { render json: m.errors, status: :unprocessable_entity }
15
+ end
16
+ end
17
+ end
18
+
19
+ def mess_params
20
+ params.require(:mess).permit(:name, :email_or_phone, :comment, :kapcha)
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,7 @@
1
+ module C80OrderForm
2
+ class SiteController < ApplicationController
3
+ def give_me_form
4
+ @predefined_comment = params[:predefined_comment]
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,23 @@
1
+ module C80OrderForm
2
+ module SiteHelper
3
+
4
+ def render_order_form(predefined_comment="")
5
+
6
+ render :partial => "c80_order_form/site/shared/order_form",
7
+ :locals => {
8
+ :mess => "MessageOrder.new",
9
+ :predefined_comment => predefined_comment
10
+ }
11
+
12
+ end
13
+
14
+ def render_ok_message
15
+ render :partial => "c80_order_form/site/shared/ok_message",
16
+ :locals => {
17
+ ok_text: "Мы свяжемся с Вами в ближайшее время.", # TODO_MY:: текст "мы свяжемся с вами ..." перенести в базу, в модель настроек гема
18
+ wtitle: "Ваша заявка отправлена" # TODO_MY:: текст "ваше сообщение отправлено" перенести в базу, в модель настроек гема
19
+ }
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,28 @@
1
+ module C80OrderForm
2
+ class MessageOrderMailer < ActionMailer::Base
3
+
4
+ default from: Proc.new { SiteProp.first.mail_from },
5
+ to: Proc.new { SiteProp.first.mail_to }
6
+
7
+ def send_mess(message, subject)
8
+ @message = format_message(message)
9
+
10
+ puts "<MessageOrderMailer.send_mess> Отправляем сообщение."
11
+ mail(subject: subject) do |format|
12
+ format.html { render "mail_mess" }
13
+ end
14
+
15
+ #puts "#{SiteProps.first.mail_to}"
16
+ end
17
+
18
+ private
19
+
20
+ def format_message(message)
21
+ result = "<br> • Имя: #{message.name}"
22
+ result += "<br> • Email или телефон: #{message.email_or_phone}"
23
+ result += "<br> • Сообщение: #{message.comment}"
24
+ result
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,5 @@
1
+ module C80OrderForm
2
+ class MessageOrder < ActiveRecord::Base
3
+ validates_with MessageOrderValidator
4
+ end
5
+ end
@@ -0,0 +1,50 @@
1
+ module C80OrderForm
2
+ class MessageOrderValidator < ActiveModel::Validator
3
+ def validate(record)
4
+ unless record.errors.present?
5
+ puts "<MessageOrderValidator.validate> record = #{record}"
6
+ mark_please_used = false
7
+
8
+ unless record.name.present?
9
+ record.errors[:name] = 'Укажите, пожалуйста, Ваше имя'
10
+ mark_please_used = true
11
+ end
12
+
13
+ if record.email_or_phone.present?
14
+ # указан email
15
+ if record.email_or_phone[/([a-z0-9_.-]+)@([a-z0-9-]+)\.[a-z.]+/].present?
16
+ else
17
+ # указан мобильный
18
+ if record.email_or_phone[/^((8|\+7)[\- ]?)?(\(?\d{3}\)?[\- ]?)?[\d\- ]{7,10}$/].present?
19
+ else
20
+ if mark_please_used
21
+ t2 = 'Номер телефона или email введены неверно'
22
+ else
23
+ t2 = 'Пожалуйста, укажите корректный номер телефона или email'
24
+ mark_please_used = true
25
+ end
26
+ record.errors[:email_or_phone] = t2
27
+ end
28
+ end
29
+ else
30
+ if mark_please_used
31
+ t1 = 'Укажите или номер телефона или email'
32
+ else
33
+ t1 = 'Укажите, пожалуйста, или номер телефона или email'
34
+ mark_please_used = true
35
+ end
36
+ record.errors[:email_or_phone] = t1
37
+ end
38
+
39
+ unless record.comment.present?
40
+ record.errors[:comment] = 'Сообщение не может быть пустым'
41
+ end
42
+
43
+ unless record.kapcha.blank?
44
+ record.errors[:kapcha] = 'fail'
45
+ end
46
+ end
47
+
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,4 @@
1
+ orderForm.hide();
2
+ setTimeout(function(){
3
+ okMessage.show();
4
+ },400);
@@ -0,0 +1 @@
1
+ <%= @message.html_safe %>
@@ -0,0 +1,3 @@
1
+ var html_str = "<%= j render_order_form(@predefined_comment) %>";
2
+ orderForm.show(html_str);
3
+
@@ -0,0 +1,16 @@
1
+ <div class="modal fade" id="modal_ok">
2
+ <div class="modal-dialog">
3
+ <div class="modal-content">
4
+ <div class="modal-header">
5
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
6
+ <h4 class="modal-title" id="myModalLabel"><%= wtitle %></h4>
7
+ </div>
8
+ <div class="modal-body">
9
+ <p><%= ok_text %></p>
10
+ </div>
11
+ <div class="modal-footer">
12
+ <button type="button" class="btn btn-default" data-dismiss="modal">Закрыть</button>
13
+ </div>
14
+ </div>
15
+ </div>
16
+ </div>
@@ -0,0 +1,67 @@
1
+ <%= render_ok_message %>
2
+ <div id="order_form" class="modal fade">
3
+ <div class="modal-dialog">
4
+ <div class="modal-content">
5
+ <div class="modal-header">
6
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
7
+ <h4 class="modal-title medium" id="myModalLabel">Обратная связь</h4> <!-- TODO_MY:: слово "обратная связь" перенести в настроки гема, в базу, в модель -->
8
+ </div>
9
+ <div class="modal-body regular">
10
+
11
+ <%= form_for :mess,
12
+ :url => '/message_order',
13
+ :remote => true,
14
+ html: {
15
+ multipart: true,
16
+ :role => :form,
17
+ :id => "form_order",
18
+ :data => {
19
+ :model => "mess"
20
+ }
21
+ } do |f| %>
22
+
23
+ <div class="form-group clearfix">
24
+ <%= f.label :name, "Имя", class: 'control-label must' %>
25
+ <%= f.text_field :name, class: 'form-control' %>
26
+ <span class="help-block col-md-12"></span>
27
+ </div>
28
+
29
+ <div class="form-group clearfix">
30
+ <%= f.label :email_or_phone, "Email или телефон", class: 'control-label must' %>
31
+ <%= f.text_field :email_or_phone, class: 'form-control' %>
32
+ <span class="help-block col-md-12"></span>
33
+ </div>
34
+
35
+ <div class="form-group kapcha clearfix">
36
+ <%= f.label :kapcha, "Капча: сколько будет 2+2?", class: 'control-label' %>
37
+ <%= f.text_field :kapcha, class: 'form-control' %>
38
+ <span class="help-block col-md-12"></span>
39
+ </div>
40
+
41
+ <div class="form-group clearfix" style="margin-bottom: 0;">
42
+ <%= f.label :comment, "Сообщение", class: 'control-label' %>
43
+ <%= f.text_area :comment, class: 'form-control', :rows => "4", :value => predefined_comment %>
44
+ <span class="help-block col-md-12"></span>
45
+ </div>
46
+
47
+ <div class="actions clearfix">
48
+ <%= f.label " ", class: 'control-label' %>
49
+ <%= f.submit "Отправить", # TODO_MY:: надпись "Отправить" перенести в модель, в настройки гема
50
+ class: 'btn btn-primary',
51
+ data: {
52
+ disable_with: 'Отправляется...' # TODO_MY:: надпись 'Отправляется...' перенести в модель, в настройки гема
53
+ }
54
+ %>
55
+ </div>
56
+
57
+ <% end %>
58
+
59
+ </div>
60
+
61
+ <div class="modal-footer">
62
+ <button type="button" class="btn btn_close btn-default" data-dismiss="modal">Закрыть</button>
63
+ </div>
64
+
65
+ </div>
66
+ </div>
67
+ </div>
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "c80_order_form"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'c80_order_form/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "c80_order_form"
8
+ spec.version = C80OrderForm::VERSION
9
+ spec.authors = ["C80609A"]
10
+ spec.email = ["c080609a@gmail.com"]
11
+
12
+ spec.summary = 'Order form'
13
+ spec.description = 'Order form'
14
+ spec.homepage = "https://github.com/c080609a/c80_order_form"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.9"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,4 @@
1
+ C80OrderForm::Engine.routes.draw do
2
+ match '/message_order', :to => 'mess#handle_message_order', :via => :post
3
+ match '/give_me_order_form', :to => 'site#give_me_form', :via => :post
4
+ end
@@ -0,0 +1,12 @@
1
+ class CreateC80OrderFormMessageOrders < ActiveRecord::Migration
2
+ def change
3
+ create_table :c80_order_form_message_orders, :options => 'COLLATE=utf8_unicode_ci' do |t|
4
+ t.string :name
5
+ t.string :email_or_phone
6
+ t.string :comment
7
+ t.string :kapcha
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,23 @@
1
+ module C80OrderForm
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace C80OrderForm
4
+
5
+ initializer :c80_order_form_engine do
6
+ if defined?(ActiveAdmin)
7
+ ActiveAdmin.application.load_paths += Dir["#{config.root}/app/models/**/"]
8
+ #ActiveAdmin.application.load_paths += Dir["#{config.root}/app/models/concerns/**/"]
9
+ ActiveAdmin.application.load_paths += Dir["#{config.root}/app/admin/c80_order_form/**/"]
10
+ # ActiveAdmin.application.load_paths += Dir["#{config.root}/app/jobs/**/"]
11
+ end
12
+ end
13
+
14
+ initializer :append_migrations do |app|
15
+ unless app.root.to_s.match root.to_s
16
+ config.paths["db/migrate"].expanded.each do |expanded_path|
17
+ app.config.paths["db/migrate"] << expanded_path
18
+ end
19
+ end
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,3 @@
1
+ module C80OrderForm
2
+ VERSION = "0.1.0.1"
3
+ end
@@ -0,0 +1,8 @@
1
+ require "c80_order_form/version"
2
+ require "c80_order_form/engine"
3
+
4
+ module C80OrderForm
5
+ def self.table_name_prefix
6
+ 'c80_order_form_'
7
+ end
8
+ end
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: c80_order_form
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - C80609A
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-12-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.9'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: Order form
42
+ email:
43
+ - c080609a@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - ".travis.yml"
50
+ - CODE_OF_CONDUCT.md
51
+ - Gemfile
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Rakefile
55
+ - app/admin/c80_order_form/message_orders.rb
56
+ - app/assets/images/lo.gif
57
+ - app/assets/javascripts/c80_order_form.js.coffee
58
+ - app/assets/javascripts/frontend/ajax_form.js
59
+ - app/assets/stylesheets/backend/active_admin_custom.scss
60
+ - app/assets/stylesheets/c80_order_form.scss
61
+ - app/assets/stylesheets/c80_order_form_active_admin.scss
62
+ - app/assets/stylesheets/frontend/form.scss
63
+ - app/assets/stylesheets/frontend/loading.scss
64
+ - app/controllers/c80_order_form/application_controller.rb
65
+ - app/controllers/c80_order_form/mess_controller.rb
66
+ - app/controllers/c80_order_form/site_controller.rb
67
+ - app/helpers/c80_order_form/site_helper.rb
68
+ - app/mailers/c80_order_form/message_order_mailer.rb
69
+ - app/models/c80_order_form/message_order.rb
70
+ - app/models/c80_order_form/message_order_validator.rb
71
+ - app/views/c80_order_form/mess/handle_message_order.js.erb
72
+ - app/views/c80_order_form/message_order_mailer/mail_mess.html.erb
73
+ - app/views/c80_order_form/site/give_me_form.js.erb
74
+ - app/views/c80_order_form/site/shared/_ok_message.html.erb
75
+ - app/views/c80_order_form/site/shared/_order_form.html.erb
76
+ - bin/console
77
+ - bin/setup
78
+ - c80_order_form.gemspec
79
+ - config/routes.rb
80
+ - db/migrate/20151221164444_create_c80_order_form_message_orders.rb
81
+ - lib/c80_order_form.rb
82
+ - lib/c80_order_form/engine.rb
83
+ - lib/c80_order_form/version.rb
84
+ homepage: https://github.com/c080609a/c80_order_form
85
+ licenses:
86
+ - MIT
87
+ metadata: {}
88
+ post_install_message:
89
+ rdoc_options: []
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ requirements: []
103
+ rubyforge_project:
104
+ rubygems_version: 2.5.1
105
+ signing_key:
106
+ specification_version: 4
107
+ summary: Order form
108
+ test_files: []