ecm_contact2 1.2.2 → 2.0.0

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: c23440fc43b67bc00dd39c3e0a60f67f5acb0fc3
4
- data.tar.gz: 4e47b62549a121316d6517d10ce38af3aaa90b5e
3
+ metadata.gz: dbf4d3c03f8d9a8a628f7d1012859df59db32fd2
4
+ data.tar.gz: 4fb86a3cf6cac2af75b278f1001ba1b3921ebd92
5
5
  SHA512:
6
- metadata.gz: 23fc92a4af8b89d07a854844271be2c3d070d277c7879a9bddd9c93ce8ef03e43e571d5c17d648b9bc442dfbf9dcce82905d29afc79528aabab734924c368b7a
7
- data.tar.gz: 073f60bbe95f05de9c2cb686accceb9246d75ba7f16ab94602861e8cedb3a1c6fbfc36023dade968c486638fe317c5dbea4e2c159ed4d8314deec50ea509f876
6
+ metadata.gz: 80334f65c183a690bb4be09be1ee00fd608508bdf57e717ac07c374386eab92fc93a5118de1ee4b07d163eaea3365ece66fa3f504986acc8e12dc2ed275d0888
7
+ data.tar.gz: be9688352831f45a3628b7c5999fac53ba775be0904a602c816e2f4729f031ae0555dbefb466580f85f08d0ddd9d9ca34ef1ae1811a97d6969e079ff6f8e35e8
@@ -9,9 +9,15 @@ class Ecm::Contact::RequestsController < Ecm::Contact::Configuration.base_contro
9
9
  @contact_request = Ecm::Contact::Request.new(params[:ecm_contact_request])
10
10
 
11
11
  if @contact_request.deliver
12
- redirect_to({ action: 'index' }, notice: -> { I18n.t('ecm.contact.form.messages.delivered') }.call)
12
+ redirect_to(after_create_url, notice: -> { I18n.t('ecm.contact.form.messages.delivered') }.call)
13
13
  else
14
14
  render :index
15
15
  end
16
16
  end
17
+
18
+ private
19
+
20
+ def after_create_url
21
+ Ecm::Contact::Configuration.after_create_url.call(self)
22
+ end
17
23
  end
@@ -0,0 +1,19 @@
1
+ module Ecm
2
+ module ContactHelper
3
+ def contact_form(options = {})
4
+ options.reverse_merge(form_target_url: nil)
5
+ form_target_url = options[:form_target_url]
6
+
7
+ form_tag_options = {}
8
+ form_tag_options[:url] = form_target_url if form_target_url.present?
9
+
10
+ @contact_request = Ecm::Contact::Request.new(params[:ecm_contact_request])
11
+
12
+ if params[:ecm_contact_request].present? && @contact_request.deliver
13
+ render 'ecm/contact/requests/form', form_tag_options: form_tag_options, notice: I18n.t('ecm.contact.form.messages.delivered')
14
+ else
15
+ render 'ecm/contact/requests/form', form_tag_options: form_tag_options
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,4 +1,12 @@
1
- <%= simple_form_for(@contact_request) do |f| %>
1
+ <% if notice %>
2
+ <div class="alert alert-success alert-dismissible">
3
+ <button type="button" class="close" data-dismiss="alert" aria-label="Close">
4
+ <span aria-hidden="true">&times;</span>
5
+ </button>
6
+ <%= notice %>
7
+ </div>
8
+ <% end %>
9
+ <%= simple_form_for(@contact_request, form_tag_options) do |f| %>
2
10
  <%= f.input :nickname, :input_html => { :style => 'display:none' }, :label_html => { :style => 'display:none' } %>
3
11
  <%= f.input :name, :input_html => { :class => Ecm::Contact::Configuration.input_name_css_classes } %>
4
12
  <%= f.input :email, :input_html => { :class => Ecm::Contact::Configuration.input_email_css_classes } %>
@@ -6,10 +14,10 @@
6
14
  <%= f.input :message, :as => :text, :input_html => { :class => Ecm::Contact::Configuration.input_message_css_classes } %>
7
15
  <%= f.input :terms_of_service, :as => :boolean, :required => true, :input_html => { :class => Ecm::Contact::Configuration.input_terms_of_service_css_classes } %>
8
16
 
9
- <div class="controls form-actions well">
17
+ <div class="<%= Ecm::Contact::Configuration.form_actions_wrapper_css_classes %>">
10
18
  <%= button_tag(:type => 'submit', :class => 'input btn btn-primary', :id => 'ecm_contact_request_submit') do %>
11
19
  <span class="glyphicon glyphicon-ok" aria-hidden="true"></span>
12
- <%= t('helpers.submit.create', :model => f.object.class.model_name.human) %>
20
+ <%= t('.submit', :model => f.object.class.model_name.human) %>
13
21
  <% end %>
14
22
  </div>
15
23
  <% end %>
@@ -10,6 +10,9 @@ de:
10
10
  meta_description: Kontaktieren Sie uns über unser Kontaktformular
11
11
  title: Kontaktanfrage
12
12
  subject: "[%{application_name}] Neue Kontaktanfrage"
13
+ requests:
14
+ form:
15
+ submit: Abschicken
13
16
  views:
14
17
  actions:
15
18
  back: 'Zurück'
@@ -21,3 +24,9 @@ de:
21
24
  required:
22
25
  text: 'Pflichtfeld'
23
26
  mark: '*'
27
+ placeholders:
28
+ ecm_contact_request:
29
+ name: "Max Mustermann"
30
+ email: "max.mustermann@example.com"
31
+ message: "Hi Dave..."
32
+ phone: "+49 69 12345678"
@@ -10,6 +10,9 @@ en:
10
10
  meta_description: Contact us
11
11
  title: Contact request
12
12
  subject: "[%{application_name}] New contact request"
13
+ requests:
14
+ form:
15
+ submit: Submit
13
16
  views:
14
17
  actions:
15
18
  back: 'Back'
@@ -21,4 +24,9 @@ en:
21
24
  required:
22
25
  text: 'required'
23
26
  mark: '*'
24
-
27
+ placeholders:
28
+ ecm_contact_request:
29
+ name: "John Doe"
30
+ email: "john.doe@example.com"
31
+ message: "Hi Dave..."
32
+ phone: "+1-541-754-3010"
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ Ecm::Contact::Engine.routes.draw do
2
+ resources :contact_requests, only: [:create, :new]
3
+ end
@@ -28,6 +28,10 @@ module Ecm
28
28
  ''
29
29
  end
30
30
 
31
+ mattr_accessor :form_actions_wrapper_css_classes do
32
+ 'controls form-actions well'
33
+ end
34
+
31
35
  mattr_accessor :recipients do
32
36
  {}
33
37
  end
@@ -40,6 +44,10 @@ module Ecm
40
44
  nil
41
45
  end
42
46
 
47
+ mattr_accessor :after_create_url do
48
+ ->(controller) { controller.url_for(action: index) }
49
+ end
50
+
43
51
  def recipients=(recipients)
44
52
  @@recipients = HashWithIndifferentAccess.new(recipients)
45
53
  end
@@ -1,5 +1,5 @@
1
1
  module Ecm
2
2
  module Contact
3
- VERSION = '1.2.2'.freeze
3
+ VERSION = '2.0.0'.freeze
4
4
  end
5
5
  end
@@ -47,6 +47,12 @@ Ecm::Contact.configure do |config|
47
47
  #
48
48
  config.input_terms_of_service_css_classes = ''
49
49
 
50
+ # Configure your form action wrapper div css classes here.
51
+ #
52
+ # Default: config.form_actions_wrapper_css_classes = 'controls form-actions well'
53
+ #
54
+ config.form_actions_wrapper_css_classes = 'controls form-actions well'
55
+
50
56
  # set the base controller for the contact form
51
57
  #
52
58
  # Default: config.base_controller = 'ApplicationController'
@@ -62,4 +68,10 @@ Ecm::Contact.configure do |config|
62
68
  # Default: config.additional_contact_information = nil
63
69
  #
64
70
  config.additional_contact_information = nil
71
+
72
+ # url to redirect to after successful contact request.
73
+ #
74
+ # default: config.after_create_url = ->(controller) { controller.url_for(action: index) }
75
+ #
76
+ config.after_create_url = ->(controller) { controller.url_for(action: index) }
65
77
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecm_contact2
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roberto Vasquez Angel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-21 00:00:00.000000000 Z
11
+ date: 2016-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -266,6 +266,7 @@ files:
266
266
  - Rakefile
267
267
  - app/assets/stylesheets/ecm_contact.css
268
268
  - app/controllers/ecm/contact/requests_controller.rb
269
+ - app/helpers/ecm/contact_helper.rb
269
270
  - app/mail_forms/ecm/contact/request.rb
270
271
  - app/views/ecm/contact/requests/_form.erb
271
272
  - app/views/ecm/contact/requests/_request.erb
@@ -275,6 +276,7 @@ files:
275
276
  - config/locales/ecm.contact.en.yml
276
277
  - config/locales/ecm.contact.request.de.yml
277
278
  - config/locales/ecm.contact.request.en.yml
279
+ - config/routes.rb
278
280
  - lib/ecm/contact/configuration.rb
279
281
  - lib/ecm/contact/engine.rb
280
282
  - lib/ecm/contact/routing.rb