c80_refine_price 0.1.0
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 +7 -0
- data/.gitignore +11 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +2 -0
- data/app/admin/c80_refine_price/rp_props.rb +31 -0
- data/app/admin/c80_refine_price/rpmessages.rb +23 -0
- data/app/assets/images/loader_button.gif +0 -0
- data/app/assets/javascripts/c80_refine_price/refine_price_decorator.js +100 -0
- data/app/assets/javascripts/c80_refine_price.js.coffee +1 -0
- data/app/assets/stylesheets/c80_refine_price/bs_modal.scss +15 -0
- data/app/assets/stylesheets/c80_refine_price/button.scss +34 -0
- data/app/assets/stylesheets/c80_refine_price/c80_refine_price_progress.scss +0 -0
- data/app/assets/stylesheets/c80_refine_price.scss +1 -0
- data/app/controllers/c80_refine_price/application_controller.rb +18 -0
- data/app/controllers/c80_refine_price/messages_controller.rb +31 -0
- data/app/helpers/c80_refine_price/app_helper.rb +25 -0
- data/app/helpers/c80_refine_price/inner/forms_helper.rb +34 -0
- data/app/helpers/c80_refine_price/inner/modal_helper.rb +16 -0
- data/app/mailers/c80_refine_price/refine_price_mailer.rb +28 -0
- data/app/models/c80_refine_price/rp_prop.rb +7 -0
- data/app/models/c80_refine_price/rpmessage.rb +9 -0
- data/app/models/c80_refine_price/rpmessage_validator.rb +52 -0
- data/app/views/c80_refine_price/application/refine_price_popup.js.erb +23 -0
- data/app/views/c80_refine_price/messages/refine_price_message.js.erb +23 -0
- data/app/views/c80_refine_price/refine_price_mailer/mail_letter.html.erb +1 -0
- data/app/views/c80_refine_price/shared/_popup.html.erb +2 -0
- data/app/views/c80_refine_price/shared/inner/forms/_full_contact_form.html.erb +81 -0
- data/app/views/c80_refine_price/shared/inner/modal/_bs_modal.html.erb +18 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/c80_refine_price.gemspec +25 -0
- data/config/locales/ru.yml +14 -0
- data/config/routes.rb +6 -0
- data/db/migrate/20161122085950_create_c80_refine_price_rp_props.rb +10 -0
- data/db/migrate/20161122085959_create_c80_refine_price_rpmessages.rb +12 -0
- data/lib/c80_refine_price/engine.rb +23 -0
- data/lib/c80_refine_price/version.rb +3 -0
- data/lib/c80_refine_price.rb +8 -0
- metadata +126 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b615ab19288844bbab4f012bed415d731e03d78c
|
4
|
+
data.tar.gz: a2bcf430a5d4baad0d34f6d218a0f1c331377d7e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cb4df2765d3106dadb79c3c567e145d89da20815244e1e9b8337ff64323602e04df7e8653d94465e53cc89778cdc414fb893eec915a02f1e7fd65bb128443a17
|
7
|
+
data.tar.gz: 656b7222da90764017ed861dd596d568127f203b612ded3b7fc69000fe36564d3e7f2bc516542395c2cd6ba71ef161eb8110df56626a2eb2322adcfbf8a7e0c6
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at c080609a@gmail.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 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,41 @@
|
|
1
|
+
# C80RefinePrice
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/c80_refine_price`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'c80_refine_price'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install c80_refine_price
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
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`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/c80_refine_price. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
ActiveAdmin.register C80RefinePrice::RpProp, as: 'RpProp' do
|
2
|
+
|
3
|
+
menu :parent => 'Сообщения',
|
4
|
+
:label => 'Уточнить цену (настройки)',
|
5
|
+
:priority => 202
|
6
|
+
|
7
|
+
permit_params :yandex_metrika_counter_id,
|
8
|
+
:yandex_metrika_target_id
|
9
|
+
|
10
|
+
batch_action :destroy, false
|
11
|
+
|
12
|
+
before_filter :skip_sidebar!, :only => :index
|
13
|
+
|
14
|
+
index do
|
15
|
+
selectable_column
|
16
|
+
column :yandex_metrika_counter_id
|
17
|
+
column :yandex_metrika_target_id
|
18
|
+
actions
|
19
|
+
end
|
20
|
+
|
21
|
+
form(:html => {:multipart => true}) do |f|
|
22
|
+
|
23
|
+
f.inputs 'Свойства' do
|
24
|
+
f.input :yandex_metrika_counter_id
|
25
|
+
f.input :yandex_metrika_target_id
|
26
|
+
end
|
27
|
+
|
28
|
+
f.actions
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
ActiveAdmin.register C80RefinePrice::Rpmessage, :as => 'Rpmessage' do
|
2
|
+
|
3
|
+
before_filter :skip_sidebar!, :only => :index
|
4
|
+
|
5
|
+
menu :parent => 'Сообщения',
|
6
|
+
:label => 'Уточнить цену',
|
7
|
+
:priority => 201
|
8
|
+
|
9
|
+
index do
|
10
|
+
selectable_column
|
11
|
+
id_column
|
12
|
+
column :created_at
|
13
|
+
column :name
|
14
|
+
column :email_or_phone
|
15
|
+
column :comment do |msg|
|
16
|
+
msg.comment.html_safe if msg.comment.present?
|
17
|
+
end
|
18
|
+
|
19
|
+
actions
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
end
|
Binary file
|
@@ -0,0 +1,100 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
// найдём на странице все элементы класса `.c80_refine_price_show_popup`
|
4
|
+
// и добавим поведение при клике:
|
5
|
+
// - кнопка должна перейти в состояние "in progress" и стать некликабельной
|
6
|
+
// - на сервер уходит запрос за popup формой
|
7
|
+
// также содержит "метод" removeInProgressState, который переводит все `.c80_refine_price_show_popup` в "нормальное" состояние
|
8
|
+
|
9
|
+
function RefinePriceDecorator() {
|
10
|
+
|
11
|
+
var css_selector = '.c80_refine_price_button'; // слушаем клики по этим элементам [кнопкам]
|
12
|
+
var url = '/refine_price_popup';
|
13
|
+
|
14
|
+
var $links;
|
15
|
+
var _mark_req_in_progress = false;
|
16
|
+
|
17
|
+
//-[ public ]-----------------------------------------------------------------------------------------------------------------------
|
18
|
+
|
19
|
+
|
20
|
+
//-[ private ]-----------------------------------------------------------------------------------------------------------------------
|
21
|
+
|
22
|
+
var _progress_state_add = function ($link) {
|
23
|
+
console.log('<_progress_state_add>');
|
24
|
+
$link.addClass('c80_refine_price_progress');
|
25
|
+
};
|
26
|
+
|
27
|
+
// у кнопок `.c80_refine_price_show_popup` уберём in_progress state
|
28
|
+
var _progress_state_remove = function () {
|
29
|
+
setTimeout(function () {
|
30
|
+
$links.removeClass('c80_refine_price_progress');
|
31
|
+
}, 500);
|
32
|
+
};
|
33
|
+
|
34
|
+
var _req = function ($clicked_button) {
|
35
|
+
|
36
|
+
var item_id;
|
37
|
+
var item_title;
|
38
|
+
var item_url;
|
39
|
+
|
40
|
+
item_id = $clicked_button.data('item-id');
|
41
|
+
item_title = $clicked_button.data('item-title');
|
42
|
+
item_url = $clicked_button.data('item-url');
|
43
|
+
|
44
|
+
$.ajax({
|
45
|
+
url : url,
|
46
|
+
type : 'POST',
|
47
|
+
data : {
|
48
|
+
item_id : item_id,
|
49
|
+
item_title: item_title,
|
50
|
+
item_url : item_url
|
51
|
+
},
|
52
|
+
dataType: 'script'
|
53
|
+
}).done(function (data, result) {
|
54
|
+
|
55
|
+
if (result == "success") { // refine_price_popup.js.erb
|
56
|
+
//markWasPasted = true;
|
57
|
+
}
|
58
|
+
|
59
|
+
_mark_req_in_progress = false;
|
60
|
+
_progress_state_remove();
|
61
|
+
|
62
|
+
})
|
63
|
+
};
|
64
|
+
|
65
|
+
var _on_link_click = function (e) {
|
66
|
+
e.preventDefault();
|
67
|
+
|
68
|
+
if (!_mark_req_in_progress) {
|
69
|
+
console.log('<_on_link_click>');
|
70
|
+
|
71
|
+
var $t = $(this);
|
72
|
+
|
73
|
+
_mark_req_in_progress = true;
|
74
|
+
_progress_state_add($t);
|
75
|
+
_req($t);
|
76
|
+
}
|
77
|
+
|
78
|
+
};
|
79
|
+
|
80
|
+
var _decorateLinks = function () {
|
81
|
+
console.log('<_decorateLinks>');
|
82
|
+
$links.on('click', _on_link_click);
|
83
|
+
|
84
|
+
};
|
85
|
+
|
86
|
+
//-[ fire ]-----------------------------------------------------------------------------------------------------------------------
|
87
|
+
|
88
|
+
var _fInit = function () {
|
89
|
+
console.log('<_fInit>');
|
90
|
+
|
91
|
+
$links = $(css_selector);
|
92
|
+
_decorateLinks();
|
93
|
+
};
|
94
|
+
|
95
|
+
_fInit();
|
96
|
+
}
|
97
|
+
|
98
|
+
$(document).ready(function () {
|
99
|
+
var refinePriceDecorator = new RefinePriceDecorator();
|
100
|
+
});
|
@@ -0,0 +1 @@
|
|
1
|
+
#= require_tree ./c80_refine_price
|
@@ -0,0 +1,34 @@
|
|
1
|
+
.c80_refine_price_button {
|
2
|
+
|
3
|
+
width: 100%;
|
4
|
+
height: 36px;
|
5
|
+
line-height: 23px; // 36 - 5 - 5 - 1 - 1 = 23px // minis border * 2 // minus padding * 2
|
6
|
+
padding: 5px !important;
|
7
|
+
|
8
|
+
border: 1px solid #C6C4C4;
|
9
|
+
border-radius: 3px;
|
10
|
+
cursor: pointer;
|
11
|
+
text-align: center;
|
12
|
+
|
13
|
+
&:hover {
|
14
|
+
background-color: #e6e6e6;
|
15
|
+
border: 1px solid #979696;
|
16
|
+
}
|
17
|
+
|
18
|
+
&.c80_refine_price_progress {
|
19
|
+
background: #ffffff url(image_path('loader_button.gif')) repeat 0 0;
|
20
|
+
|
21
|
+
border: 1px solid #6b6a6a;
|
22
|
+
opacity: 0.4;
|
23
|
+
color: rgb(255, 0, 0);
|
24
|
+
cursor: wait;
|
25
|
+
|
26
|
+
&:hover {
|
27
|
+
opacity: 0.4;
|
28
|
+
color: rgb(255, 0, 100);
|
29
|
+
border: 1px solid #6b6a6a;
|
30
|
+
}
|
31
|
+
|
32
|
+
}
|
33
|
+
|
34
|
+
}
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "c80_refine_price/**/*";
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'c80_lazy_images'
|
2
|
+
|
3
|
+
module C80RefinePrice
|
4
|
+
class ApplicationController < ActionController::Base
|
5
|
+
|
6
|
+
helper C80LazyImages::Engine.helpers
|
7
|
+
|
8
|
+
protect_from_forgery with: :exception
|
9
|
+
|
10
|
+
# обрабатываем запрос от `.c80_refine_price_show_popup` кнопок за popup формой
|
11
|
+
def refine_price_popup
|
12
|
+
respond_to do |format|
|
13
|
+
format.js
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module C80RefinePrice
|
2
|
+
class MessagesController < ActionController::Base
|
3
|
+
|
4
|
+
protect_from_forgery with: :exception
|
5
|
+
|
6
|
+
# на этот скрипт уходят все сообщения с форм обратной связи, затем отправляется почта владельцу сайта
|
7
|
+
def refine_price_message
|
8
|
+
|
9
|
+
m = Rpmessage.new(rpmessage_params)
|
10
|
+
|
11
|
+
respond_to do |format|
|
12
|
+
|
13
|
+
if m.save
|
14
|
+
|
15
|
+
format.js
|
16
|
+
RefinePriceMailer.send_email(m, 'Уточнить цену').deliver
|
17
|
+
else
|
18
|
+
Rails.logger.debug "[TRACE] <MessagesController.refine_price_message> errors: #{m.errors}"
|
19
|
+
format.js { render json: m.errors, status: :unprocessable_entity }
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
def rpmessage_params
|
27
|
+
params.require(:rpmessage).permit(:name, :email_or_phone, :kapcha, :comment)
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module C80RefinePrice
|
2
|
+
module AppHelper
|
3
|
+
|
4
|
+
# отрисовка формы 'Уточнить цену', завёрнутой в bootstrap modal окно
|
5
|
+
def render_popup_refine_price(params)
|
6
|
+
render :partial => 'c80_refine_price/shared/popup',
|
7
|
+
:locals => {
|
8
|
+
title: I18n.t('c80_refine_price.popup_refine_price.title'),
|
9
|
+
content: _render_full_contact_form(params)
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
# отрисовка success-сообщения, завёрнутого в bootstrap modal окно
|
14
|
+
def render_popup_ok
|
15
|
+
|
16
|
+
render :partial => 'c80_refine_price/shared/popup',
|
17
|
+
:locals => {
|
18
|
+
title: I18n.t('c80_refine_price.popup_ok.title'),
|
19
|
+
content: I18n.t('c80_refine_price.popup_ok.content')
|
20
|
+
}
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module C80RefinePrice
|
2
|
+
module Inner
|
3
|
+
module FormsHelper
|
4
|
+
|
5
|
+
def _render_full_contact_form(params={})
|
6
|
+
|
7
|
+
# params: {
|
8
|
+
# "item_id"=>"67",
|
9
|
+
# "item_title"=>"Газобетонный стеновой блок YTONG, D400, 625*250*375мм",
|
10
|
+
# "item_url"=>"/stroitelnye-materialy/gazobetonnye-bloki/67",
|
11
|
+
# "controller"=>"c80_refine_price/application",
|
12
|
+
# "action"=>"refine_price_popup"
|
13
|
+
# }
|
14
|
+
|
15
|
+
settings = {
|
16
|
+
:item_id => '',
|
17
|
+
:item_title => '',
|
18
|
+
:item_url => ''
|
19
|
+
}
|
20
|
+
|
21
|
+
se = settings.merge(params.deep_symbolize_keys)
|
22
|
+
|
23
|
+
se[:comment_value] = "Товар: #{se[:item_title]}. [br] Ссылка: #{se[:item_url]}"
|
24
|
+
|
25
|
+
render :partial => 'c80_refine_price/shared/inner/forms/full_contact_form',
|
26
|
+
:locals => {
|
27
|
+
rpmessage: Rpmessage.new,
|
28
|
+
settings: se
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module C80RefinePrice
|
2
|
+
module Inner
|
3
|
+
module ModalHelper
|
4
|
+
|
5
|
+
def _render_bs_modal(content='', title='')
|
6
|
+
render :partial => 'c80_refine_price/shared/inner/modal/bs_modal',
|
7
|
+
:locals => {
|
8
|
+
title: title,
|
9
|
+
content: content,
|
10
|
+
close_label: 'Закрыть'
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module C80RefinePrice
|
2
|
+
class RefinePriceMailer < ActionMailer::Base
|
3
|
+
|
4
|
+
default from: Proc.new { SiteProp.first.mail_from },
|
5
|
+
to: Proc.new { SiteProp.first.mail_to }
|
6
|
+
|
7
|
+
def send_email(message, subject)
|
8
|
+
@message = format_message(message)
|
9
|
+
|
10
|
+
puts '<RefinePriceMailer.send_mess> Отправляем сообщение.'
|
11
|
+
mail(subject: subject) do |format|
|
12
|
+
format.html { render 'mail_letter' }
|
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
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module C80RefinePrice
|
2
|
+
class RpmessageValidator < ActiveModel::Validator
|
3
|
+
def validate(record)
|
4
|
+
|
5
|
+
unless record.errors.present?
|
6
|
+
puts "<RpmessageValidator.validate> record = #{record}"
|
7
|
+
mark_please_used = false
|
8
|
+
|
9
|
+
unless record.name.present?
|
10
|
+
record.errors[:name] = 'Укажите, пожалуйста, Ваше имя'
|
11
|
+
mark_please_used = true
|
12
|
+
end
|
13
|
+
|
14
|
+
if record.email_or_phone.present?
|
15
|
+
# указан email
|
16
|
+
if record.email_or_phone[/([a-z0-9_.-]+)@([a-z0-9-]+)\.[a-z.]+/].present?
|
17
|
+
else
|
18
|
+
# указан мобильный
|
19
|
+
if record.email_or_phone[/^((8|\+7)[\- ]?)?(\(?\d{3}\)?[\- ]?)?[\d\- ]{7,10}$/].present?
|
20
|
+
else
|
21
|
+
if mark_please_used
|
22
|
+
t2 = 'Номер телефона или email введены неверно'
|
23
|
+
else
|
24
|
+
t2 = 'Пожалуйста, укажите корректный номер телефона или email'
|
25
|
+
mark_please_used = true
|
26
|
+
end
|
27
|
+
record.errors[:email_or_phone] = t2
|
28
|
+
end
|
29
|
+
end
|
30
|
+
else
|
31
|
+
if mark_please_used
|
32
|
+
t1 = 'Укажите или номер телефона или email'
|
33
|
+
else
|
34
|
+
t1 = 'Укажите, пожалуйста, или номер телефона или email'
|
35
|
+
mark_please_used = true
|
36
|
+
end
|
37
|
+
record.errors[:email_or_phone] = t1
|
38
|
+
end
|
39
|
+
|
40
|
+
# unless record.comment.present?
|
41
|
+
# record.errors[:comment] = 'Сообщение не может быть пустым'
|
42
|
+
# end
|
43
|
+
|
44
|
+
unless record.kapcha.blank?
|
45
|
+
record.errors[:kapcha] = 'fail'
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<%# это приходит в ответ на запрос формы, завёрнутой в popup (такие запросы отправляют кнопки, обработанные RefinePriceDecorator) %>
|
2
|
+
|
3
|
+
var $body = $('body');
|
4
|
+
|
5
|
+
// вставим окно
|
6
|
+
var html_str = "<%= j render_popup_refine_price(params) %>";
|
7
|
+
var $m = $(html_str);
|
8
|
+
$body.append($m);
|
9
|
+
|
10
|
+
// покажем окно
|
11
|
+
$('#c80_refine_price_bs_modal')
|
12
|
+
.modal('show')
|
13
|
+
.on('hidden.bs.modal', function () {
|
14
|
+
$(this).remove();
|
15
|
+
//console.log($(this));
|
16
|
+
});
|
17
|
+
|
18
|
+
// настроим форму
|
19
|
+
var $form = $("form#form_refine_price");
|
20
|
+
$form.bind("ajax:error", function (event, data, status, xhr) {
|
21
|
+
$form.render_form_errors($.parseJSON(data.responseText));
|
22
|
+
});
|
23
|
+
$form.modal_success();
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<%# это приходит в ответ на успешную отправку сообщения из формы 'Уточнить стоимость' в модальном окне %>
|
2
|
+
|
3
|
+
$('#form_refine_price').modal_success();
|
4
|
+
$('#c80_refine_price_bs_modal').modal('hide');
|
5
|
+
|
6
|
+
setTimeout(function () {
|
7
|
+
var $body = $('body');
|
8
|
+
|
9
|
+
// вставим окно
|
10
|
+
var html_str = "<%= j render_popup_ok %>";
|
11
|
+
var $m = $(html_str);
|
12
|
+
$body.append($m);
|
13
|
+
|
14
|
+
// покажем окно
|
15
|
+
$('#c80_refine_price_bs_modal')
|
16
|
+
.modal('show')
|
17
|
+
.on('hidden.bs.modal', function () {
|
18
|
+
$(this).remove();
|
19
|
+
//console.log($(this));
|
20
|
+
})
|
21
|
+
|
22
|
+
|
23
|
+
}, 500);
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= @message.html_safe %>
|
@@ -0,0 +1,81 @@
|
|
1
|
+
|
2
|
+
<div class="full_contact_form">
|
3
|
+
|
4
|
+
<%= form_for :rpmessage,
|
5
|
+
:url => '/refine_price_message',
|
6
|
+
:remote => true,
|
7
|
+
html: {
|
8
|
+
:role => :form,
|
9
|
+
:id => 'form_refine_price', #-> refine_price_message.js.erb uses this ID
|
10
|
+
:data => {
|
11
|
+
:model => 'rpmessage'
|
12
|
+
}
|
13
|
+
} do |f| %>
|
14
|
+
|
15
|
+
<div class="form-group clearfix">
|
16
|
+
<%= f.label :name, 'Ваше имя', class: 'control-label' %>
|
17
|
+
<%= f.text_field :name,
|
18
|
+
:class => 'form-control',
|
19
|
+
:maxlength => 30
|
20
|
+
%>
|
21
|
+
<span class="help-block col-md-12"></span>
|
22
|
+
</div>
|
23
|
+
|
24
|
+
<div class="form-group clearfix">
|
25
|
+
<%= f.label :email_or_phone, 'Email или телефон', class: 'control-label' %>
|
26
|
+
<%= f.text_field :email_or_phone,
|
27
|
+
:class => 'form-control',
|
28
|
+
:maxlength => 30
|
29
|
+
%>
|
30
|
+
<span class="help-block col-md-12"></span>
|
31
|
+
</div>
|
32
|
+
|
33
|
+
<div class="form-group kapcha clearfix">
|
34
|
+
<%= f.text_field :kapcha, class: 'form-control', :maxlength => 30 %>
|
35
|
+
</div>
|
36
|
+
|
37
|
+
<div class="form-group clearfix">
|
38
|
+
<%= f.label :comment, 'Сообщение', class: 'control-label' %>
|
39
|
+
<div class="input_wrapper">
|
40
|
+
<%= f.text_area :comment, class: 'form-control', :rows => 5 %>
|
41
|
+
</div>
|
42
|
+
<span class="help-block col-md-12"></span>
|
43
|
+
</div>
|
44
|
+
|
45
|
+
<div class="actions clearfix">
|
46
|
+
<%= f.submit 'Отправить',
|
47
|
+
class: 'btn btn-danger',
|
48
|
+
data: {
|
49
|
+
disable_with: 'Отправляется...'
|
50
|
+
}
|
51
|
+
%>
|
52
|
+
</div>
|
53
|
+
|
54
|
+
<% end %>
|
55
|
+
|
56
|
+
<script>
|
57
|
+
$(document).ready(function(){
|
58
|
+
|
59
|
+
var $form = $("form#form_refine_price");
|
60
|
+
|
61
|
+
$form.bind("ajax:error",function(event, data, status, xhr){
|
62
|
+
$form.render_form_errors( $.parseJSON(data.responseText) );
|
63
|
+
});
|
64
|
+
|
65
|
+
$form.modal_success();
|
66
|
+
|
67
|
+
$form.find("input").each(function() {
|
68
|
+
$(this).blur();
|
69
|
+
});
|
70
|
+
|
71
|
+
setTimeout(function () {
|
72
|
+
var asd = "<%= settings[:comment_value].html_safe %>";
|
73
|
+
asd = asd.split('[br]').join('\n\n');
|
74
|
+
$form.find('#rpmessage_comment').val(asd);
|
75
|
+
}, 500);
|
76
|
+
|
77
|
+
});
|
78
|
+
</script>
|
79
|
+
|
80
|
+
</div>
|
81
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<!-- Modal -->
|
2
|
+
<div class="modal fade" id="c80_refine_price_bs_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
|
3
|
+
<div class="modal-dialog" role="document">
|
4
|
+
<div class="modal-content">
|
5
|
+
<div class="modal-header">
|
6
|
+
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
7
|
+
<h4 class="modal-title" id="myModalLabel"><%= title %></h4>
|
8
|
+
</div>
|
9
|
+
<div class="modal-body">
|
10
|
+
<%= content.html_safe %>
|
11
|
+
</div>
|
12
|
+
<div class="modal-footer">
|
13
|
+
<button type="button" class="btn btn-default" data-dismiss="modal"><%= close_label %></button>
|
14
|
+
<!--<button type="button" class="btn btn-primary">Save changes</button>-->
|
15
|
+
</div>
|
16
|
+
</div>
|
17
|
+
</div>
|
18
|
+
</div>
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "c80_refine_price"
|
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,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'c80_refine_price/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'c80_refine_price'
|
8
|
+
spec.version = C80RefinePrice::VERSION
|
9
|
+
spec.authors = ['C80609A']
|
10
|
+
spec.email = ['c080609a@gmail.com']
|
11
|
+
|
12
|
+
spec.summary = 'Refine price gem'
|
13
|
+
spec.description = 'Gem adds refine price to site'
|
14
|
+
spec.homepage = 'https://github.com/c80609a/c80_refine_price'
|
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.12'
|
23
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
24
|
+
spec.add_dependency 'activesupport', ['>= 3.0.0']
|
25
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
ru:
|
2
|
+
activerecord:
|
3
|
+
errors:
|
4
|
+
models:
|
5
|
+
c80_refine_price/rpmessage:
|
6
|
+
attributes:
|
7
|
+
name:
|
8
|
+
email_or_phone:
|
9
|
+
c80_refine_price:
|
10
|
+
popup_refine_price:
|
11
|
+
title: 'Мы отправим запрашиваемую информацию удобным для Вас способом'
|
12
|
+
popup_ok:
|
13
|
+
title: 'Ваше сообщение доставлено'
|
14
|
+
content: 'Мы отправим запрашиваемую информацию о цене товара удобным для Вас способом'
|
data/config/routes.rb
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
C80RefinePrice::Engine.routes.draw do
|
2
|
+
|
3
|
+
match 'refine_price_popup', :to => 'application#refine_price_popup', :via => :post # сюда обращается js за формой обратной связи, завёрнутой в bootstrap modal
|
4
|
+
match 'refine_price_message', :to => 'messages#refine_price_message', :via => :post # на этот скрипт уходят все сообщения с форм обратной связи, затем отправляется почта владельцу сайта
|
5
|
+
|
6
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
class CreateC80RefinePriceRpProps < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :c80_refine_price_rp_props, :options => 'COLLATE=utf8_unicode_ci' do |t|
|
4
|
+
t.string :yandex_metrika_counter_id
|
5
|
+
t.string :yandex_metrika_target_id
|
6
|
+
|
7
|
+
t.timestamps null: false
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class CreateC80RefinePriceRpmessages < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :c80_refine_price_rpmessages, :options => 'COLLATE=utf8_unicode_ci' do |t|
|
4
|
+
t.string :name
|
5
|
+
t.string :email_or_phone
|
6
|
+
t.string :kapcha
|
7
|
+
t.string :comment
|
8
|
+
|
9
|
+
t.timestamps null: false
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module C80RefinePrice
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
isolate_namespace C80RefinePrice
|
4
|
+
|
5
|
+
initializer :c80_refine_price_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_refine_price/**/"]
|
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
|
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: c80_refine_price
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- C80609A
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-11-22 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.12'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.12'
|
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
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: activesupport
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.0.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.0.0
|
55
|
+
description: Gem adds refine price to site
|
56
|
+
email:
|
57
|
+
- c080609a@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- CODE_OF_CONDUCT.md
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- app/admin/c80_refine_price/rp_props.rb
|
69
|
+
- app/admin/c80_refine_price/rpmessages.rb
|
70
|
+
- app/assets/images/loader_button.gif
|
71
|
+
- app/assets/javascripts/c80_refine_price.js.coffee
|
72
|
+
- app/assets/javascripts/c80_refine_price/refine_price_decorator.js
|
73
|
+
- app/assets/stylesheets/c80_refine_price.scss
|
74
|
+
- app/assets/stylesheets/c80_refine_price/bs_modal.scss
|
75
|
+
- app/assets/stylesheets/c80_refine_price/button.scss
|
76
|
+
- app/assets/stylesheets/c80_refine_price/c80_refine_price_progress.scss
|
77
|
+
- app/controllers/c80_refine_price/application_controller.rb
|
78
|
+
- app/controllers/c80_refine_price/messages_controller.rb
|
79
|
+
- app/helpers/c80_refine_price/app_helper.rb
|
80
|
+
- app/helpers/c80_refine_price/inner/forms_helper.rb
|
81
|
+
- app/helpers/c80_refine_price/inner/modal_helper.rb
|
82
|
+
- app/mailers/c80_refine_price/refine_price_mailer.rb
|
83
|
+
- app/models/c80_refine_price/rp_prop.rb
|
84
|
+
- app/models/c80_refine_price/rpmessage.rb
|
85
|
+
- app/models/c80_refine_price/rpmessage_validator.rb
|
86
|
+
- app/views/c80_refine_price/application/refine_price_popup.js.erb
|
87
|
+
- app/views/c80_refine_price/messages/refine_price_message.js.erb
|
88
|
+
- app/views/c80_refine_price/refine_price_mailer/mail_letter.html.erb
|
89
|
+
- app/views/c80_refine_price/shared/_popup.html.erb
|
90
|
+
- app/views/c80_refine_price/shared/inner/forms/_full_contact_form.html.erb
|
91
|
+
- app/views/c80_refine_price/shared/inner/modal/_bs_modal.html.erb
|
92
|
+
- bin/console
|
93
|
+
- bin/setup
|
94
|
+
- c80_refine_price.gemspec
|
95
|
+
- config/locales/ru.yml
|
96
|
+
- config/routes.rb
|
97
|
+
- db/migrate/20161122085950_create_c80_refine_price_rp_props.rb
|
98
|
+
- db/migrate/20161122085959_create_c80_refine_price_rpmessages.rb
|
99
|
+
- lib/c80_refine_price.rb
|
100
|
+
- lib/c80_refine_price/engine.rb
|
101
|
+
- lib/c80_refine_price/version.rb
|
102
|
+
homepage: https://github.com/c80609a/c80_refine_price
|
103
|
+
licenses:
|
104
|
+
- MIT
|
105
|
+
metadata: {}
|
106
|
+
post_install_message:
|
107
|
+
rdoc_options: []
|
108
|
+
require_paths:
|
109
|
+
- lib
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
requirements: []
|
121
|
+
rubyforge_project:
|
122
|
+
rubygems_version: 2.5.1
|
123
|
+
signing_key:
|
124
|
+
specification_version: 4
|
125
|
+
summary: Refine price gem
|
126
|
+
test_files: []
|