c80_order_form 0.1.0.1 → 0.1.0.3

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
  SHA1:
3
- metadata.gz: 8d170f1173fd71f93027b511d02ba41553874152
4
- data.tar.gz: fa27995fb62a5338762c27a91a84903bbc71b999
3
+ metadata.gz: 69d9b2b451b40fb1bc3071bb174b7f466fd546aa
4
+ data.tar.gz: da2134f1e0b56829a3e002777498e08532dfb894
5
5
  SHA512:
6
- metadata.gz: c98e9e303cacb777586300c5d4296923f03393ae39e3e2bb58e7d443477feef5ddc89c18b195f331761ea0cdd2f93328900d2a873cc7ed80a07bb0451de547eb
7
- data.tar.gz: 649ffe5fde65d019f380c363cc0ecf12758f6de1c76493937f1ca10a5f4557f193ac474e3341d1ef4c570c4b57245e6f6208e1e8ae43acbabd248cfc6f62495f
6
+ metadata.gz: 33d93f4b41fba194797118995d3c7df68c07f78e804a9c3366b69389dbd07ae8883a2acab1efcc581fba2efadaef6176004ed9ed36bebaa1bb026b1cb10f72c7
7
+ data.tar.gz: 1dc7d34ad612d875f7aae1fcf7308a235e859b835b59c6eabd1dc2c5c10a8852e05b24b617893e1cf495ba1eeb04c4bd0013dc3af81c6b9296a4ea4bc6b13fd9
data/.gitignore CHANGED
@@ -8,3 +8,4 @@
8
8
  /pkg/
9
9
  /spec/reports/
10
10
  /tmp/
11
+ *.gem
data/README.md CHANGED
@@ -59,8 +59,6 @@ Add this line into `routes.rb`:
59
59
 
60
60
  mount C80OrderForm::Engine => '/'
61
61
 
62
- Form invoked by link with class `c80_order_invoking_btn`.
63
-
64
62
  ## Development
65
63
 
66
64
  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.
@@ -69,7 +67,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
69
67
 
70
68
  ## Contributing
71
69
 
72
- 1. Fork it ( https://github.com/c080609a/c80_order_form/fork )
70
+ 1. Fork it ( https://github.com/[my-github-username]/c80_order_form/fork )
73
71
  2. Create your feature branch (`git checkout -b my-new-feature`)
74
72
  3. Commit your changes (`git commit -am 'Add some feature'`)
75
73
  4. Push to the branch (`git push origin my-new-feature`)
@@ -2,7 +2,7 @@ ActiveAdmin.register C80OrderForm::MessageOrder, :as => 'MessageOrder' do
2
2
 
3
3
  before_filter :skip_sidebar!, :only => :index
4
4
 
5
- menu :parent => 'Сообщения', :label => 'Заявки' # TODO_MY:: слово "заявки" перенести в базу, в настройки гема
5
+ menu :parent => 'Сообщения', :label => C80OrderForm::Settings.first.admin_label_menu
6
6
 
7
7
  index do
8
8
  selectable_column
@@ -80,9 +80,17 @@ $(function () {
80
80
  predefined_comment = $clickedButton.data('comment-text');
81
81
  }
82
82
 
83
+ var subj_id = -1;
84
+ if ($clickedButton.data('subj-id') != undefined) {
85
+ subj_id = $clickedButton.data('subj-id');
86
+ }
87
+
83
88
  $.ajax({
84
89
  url: '/give_me_order_form',
85
- data:{predefined_comment:predefined_comment},
90
+ data:{
91
+ predefined_comment:predefined_comment,
92
+ subj_id:subj_id
93
+ },
86
94
  type: 'POST',
87
95
  dataType: 'script'
88
96
  }).done(function (data, result) {
@@ -1,6 +1,6 @@
1
1
  body.admin_message_orders {
2
2
  // прячем кнопку batch actions
3
- //.table_tools { display: none; }
3
+ .table_tools { display: none; }
4
4
  // прячем кнопку "создать новую запись"
5
5
  div.action_items { display: none; }
6
6
  //прячем ссылку "редактировать"
@@ -2,13 +2,14 @@ module C80OrderForm
2
2
  class MessController < ApplicationController
3
3
 
4
4
  def handle_message_order
5
- puts "<MessController.handle_message_order>"
5
+ # puts "<MessController.handle_message_order>"
6
6
  m = MessageOrder.new(mess_params)
7
7
  respond_to do |format|
8
8
  if m.save
9
9
 
10
10
  format.js
11
- MessageOrderMailer.send_mess(m, "Заявка").deliver # TODO_MY:: слово "заявка" поместить в базу, в модель настроек гема
11
+ settings = Settings.first
12
+ MessageOrderMailer.send_mess(m, settings.message_letter_subj).deliver
12
13
  else
13
14
  puts "<MessController.handle_message_order> errors: #{m.errors}"
14
15
  format.js { render json: m.errors, status: :unprocessable_entity }
@@ -17,7 +18,7 @@ module C80OrderForm
17
18
  end
18
19
 
19
20
  def mess_params
20
- params.require(:mess).permit(:name, :email_or_phone, :comment, :kapcha)
21
+ params.require(:mess).permit(:name, :email_or_phone, :comment, :kapcha, :subj_id)
21
22
  end
22
23
 
23
24
  end
@@ -2,6 +2,7 @@ module C80OrderForm
2
2
  class SiteController < ApplicationController
3
3
  def give_me_form
4
4
  @predefined_comment = params[:predefined_comment]
5
+ @subj_id = params[:subj_id]
5
6
  end
6
7
  end
7
8
  end
@@ -1,21 +1,25 @@
1
1
  module C80OrderForm
2
2
  module SiteHelper
3
3
 
4
- def render_order_form(predefined_comment="")
4
+ def render_order_form(predefined_comment="",subj_id=-1)
5
+
6
+ @settings = Settings.first
5
7
 
6
8
  render :partial => "c80_order_form/site/shared/order_form",
7
9
  :locals => {
8
10
  :mess => "MessageOrder.new",
9
- :predefined_comment => predefined_comment
11
+ :predefined_comment => predefined_comment,
12
+ :subj_id => subj_id
10
13
  }
11
14
 
12
15
  end
13
16
 
14
17
  def render_ok_message
18
+ settings = Settings.first
15
19
  render :partial => "c80_order_form/site/shared/ok_message",
16
20
  :locals => {
17
- ok_text: "Мы свяжемся с Вами в ближайшее время.", # TODO_MY:: текст "мы свяжемся с вами ..." перенести в базу, в модель настроек гема
18
- wtitle: "Ваша заявка отправлена" # TODO_MY:: текст "ваше сообщение отправлено" перенести в базу, в модель настроек гема
21
+ ok_text: settings.ok_text,
22
+ wtitle: settings.ok_text_title
19
23
  }
20
24
  end
21
25
 
@@ -15,13 +15,17 @@ module C80OrderForm
15
15
  #puts "#{SiteProps.first.mail_to}"
16
16
  end
17
17
 
18
- private
18
+ # private
19
19
 
20
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
21
+ m = Settings.first.message_text
22
+ m = m.gsub!('{name}',message.name)
23
+ m = m.gsub!('{email_or_phone}',message.email_or_phone)
24
+ m = m.gsub!('{comment}',message.comment)
25
+ m = m.gsub!('{subj_id}',message.subj_id)
26
+ # puts "<format_message> m: #{m}"
27
+ message.update(:comment => m)
28
+ m
25
29
  end
26
30
 
27
31
  end
@@ -0,0 +1,4 @@
1
+ module C80OrderForm
2
+ class Settings < ActiveRecord::Base
3
+ end
4
+ end
@@ -1,3 +1,3 @@
1
- var html_str = "<%= j render_order_form(@predefined_comment) %>";
1
+ var html_str = "<%= j render_order_form(@predefined_comment,@subj_id) %>";
2
2
  orderForm.show(html_str);
3
3
 
@@ -4,7 +4,7 @@
4
4
  <div class="modal-content">
5
5
  <div class="modal-header">
6
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:: слово "обратная связь" перенести в настроки гема, в базу, в модель -->
7
+ <h4 class="modal-title medium" id="myModalLabel"><%= @settings.order_form_title %></h4>
8
8
  </div>
9
9
  <div class="modal-body regular">
10
10
 
@@ -21,13 +21,13 @@
21
21
  } do |f| %>
22
22
 
23
23
  <div class="form-group clearfix">
24
- <%= f.label :name, "Имя", class: 'control-label must' %>
24
+ <%= f.label :name, @settings.order_form_label_name, class: 'control-label must' %>
25
25
  <%= f.text_field :name, class: 'form-control' %>
26
26
  <span class="help-block col-md-12"></span>
27
27
  </div>
28
28
 
29
29
  <div class="form-group clearfix">
30
- <%= f.label :email_or_phone, "Email или телефон", class: 'control-label must' %>
30
+ <%= f.label :email_or_phone, @settings.order_form_label_email_or_phone, class: 'control-label must' %>
31
31
  <%= f.text_field :email_or_phone, class: 'form-control' %>
32
32
  <span class="help-block col-md-12"></span>
33
33
  </div>
@@ -38,18 +38,24 @@
38
38
  <span class="help-block col-md-12"></span>
39
39
  </div>
40
40
 
41
+ <div class="form-group kapcha clearfix">
42
+ <%= f.label :subj_id, "subj_id", class: 'control-label' %>
43
+ <%= f.text_field :subj_id, class: 'form-control', :value => subj_id %>
44
+ <span class="help-block col-md-12"></span>
45
+ </div>
46
+
41
47
  <div class="form-group clearfix" style="margin-bottom: 0;">
42
- <%= f.label :comment, "Сообщение", class: 'control-label' %>
48
+ <%= f.label :comment, @settings.order_form_label_comment, class: 'control-label' %>
43
49
  <%= f.text_area :comment, class: 'form-control', :rows => "4", :value => predefined_comment %>
44
50
  <span class="help-block col-md-12"></span>
45
51
  </div>
46
52
 
47
53
  <div class="actions clearfix">
48
54
  <%= f.label " ", class: 'control-label' %>
49
- <%= f.submit "Отправить", # TODO_MY:: надпись "Отправить" перенести в модель, в настройки гема
55
+ <%= f.submit @settings.order_form_label_button_send,
50
56
  class: 'btn btn-primary',
51
57
  data: {
52
- disable_with: 'Отправляется...' # TODO_MY:: надпись 'Отправляется...' перенести в модель, в настройки гема
58
+ disable_with: @settings.order_form_label_button_sending
53
59
  }
54
60
  %>
55
61
  </div>
@@ -21,4 +21,6 @@ Gem::Specification.new do |spec|
21
21
 
22
22
  spec.add_development_dependency "bundler", "~> 1.9"
23
23
  spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_dependency 'activesupport', ['>= 3.0.0']
25
+
24
26
  end
@@ -0,0 +1,5 @@
1
+ class AddSubjIdToC80OrderFormMessageOrders < ActiveRecord::Migration
2
+ def change
3
+ add_column :c80_order_form_message_orders, :subj_id, :integer
4
+ end
5
+ end
@@ -0,0 +1,18 @@
1
+ class CreateC80OrderFormSettings < ActiveRecord::Migration
2
+ def change
3
+ create_table :c80_order_form_settings, :options => 'COLLATE=utf8_unicode_ci' do |t|
4
+ t.string :order_form_title
5
+ t.string :order_form_label_name
6
+ t.string :order_form_label_email_or_phone
7
+ t.string :order_form_label_comment
8
+ t.string :order_form_label_button_send
9
+ t.string :order_form_label_button_sending
10
+ t.string :ok_text
11
+ t.string :ok_text_title
12
+ t.string :admin_label_menu
13
+ t.text :message_text
14
+ t.string :message_letter_subj
15
+ t.timestamps
16
+ end
17
+ end
18
+ end
@@ -1,3 +1,3 @@
1
1
  module C80OrderForm
2
- VERSION = "0.1.0.1"
2
+ VERSION = "0.1.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: c80_order_form
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.1
4
+ version: 0.1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - C80609A
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-12-28 00:00:00.000000000 Z
11
+ date: 2015-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
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
41
55
  description: Order form
42
56
  email:
43
57
  - c080609a@gmail.com
@@ -68,6 +82,7 @@ files:
68
82
  - app/mailers/c80_order_form/message_order_mailer.rb
69
83
  - app/models/c80_order_form/message_order.rb
70
84
  - app/models/c80_order_form/message_order_validator.rb
85
+ - app/models/c80_order_form/settings.rb
71
86
  - app/views/c80_order_form/mess/handle_message_order.js.erb
72
87
  - app/views/c80_order_form/message_order_mailer/mail_mess.html.erb
73
88
  - app/views/c80_order_form/site/give_me_form.js.erb
@@ -78,6 +93,8 @@ files:
78
93
  - c80_order_form.gemspec
79
94
  - config/routes.rb
80
95
  - db/migrate/20151221164444_create_c80_order_form_message_orders.rb
96
+ - db/migrate/20151229144545_add_subj_id_to_c80_order_form_message_orders.rb
97
+ - db/migrate/20151229234343_create_c80_order_form_settings.rb
81
98
  - lib/c80_order_form.rb
82
99
  - lib/c80_order_form/engine.rb
83
100
  - lib/c80_order_form/version.rb