scrivito_crm_form_widget 0.7.2 → 0.8.0.beta2
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 +4 -4
- data/Rakefile +0 -10
- data/app/assets/styles/scrivito_crm_form_widget.scss +30 -0
- data/app/models/crm_form_widget.rb +6 -0
- data/app/presenter/crm_form_presenter.rb +18 -4
- data/app/views/crm_form_widget/_crm_enum.html.erb +12 -8
- data/app/views/crm_form_widget/_crm_multienum.html.erb +1 -1
- data/app/views/crm_form_widget/_crm_string.html.erb +1 -1
- data/app/views/crm_form_widget/_crm_text.html.erb +1 -1
- data/app/views/crm_form_widget/_form.html.erb +3 -3
- data/app/views/crm_form_widget/details.html.erb +8 -0
- data/lib/scrivito_crm_form_widget/version.rb +1 -1
- metadata +6 -6
- data/app/assets/styles/scrivito_crm_form_widget.css +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 165d85e828c452d6827e8465161f568447c285d3
|
4
|
+
data.tar.gz: 7902487559b63f09494ebaa79078729fdbec789c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1280f07793e61e4b6773f81f12515d9f5c3812982211d6a97b84b6c12cf72081337a089942e2159395ab20e43b73ee1e9b12b69e05af3afa9d802bf9c01f7a6e
|
7
|
+
data.tar.gz: f95246027994f68484ee8259528d2a726b27f64e3b749368ab8ee9828ac72e6f9e87afdd14d963ffec234fa564a403f8289662c322b64f13c287c3dcb02ef8d1
|
data/Rakefile
CHANGED
@@ -4,16 +4,6 @@ rescue LoadError
|
|
4
4
|
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
5
|
end
|
6
6
|
|
7
|
-
require 'rdoc/task'
|
8
|
-
|
9
|
-
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
-
rdoc.rdoc_dir = 'rdoc'
|
11
|
-
rdoc.title = 'ScrivitoJrFormWidget'
|
12
|
-
rdoc.options << '--line-numbers'
|
13
|
-
rdoc.rdoc_files.include('README.rdoc')
|
14
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
-
end
|
16
|
-
|
17
7
|
|
18
8
|
|
19
9
|
|
@@ -0,0 +1,30 @@
|
|
1
|
+
form .form-group.last {
|
2
|
+
display: none;
|
3
|
+
}
|
4
|
+
|
5
|
+
form.form-horizontal.label-position-top {
|
6
|
+
label {
|
7
|
+
float: none;
|
8
|
+
width: 100%;
|
9
|
+
text-align: left;
|
10
|
+
}
|
11
|
+
.col-sm-9 {
|
12
|
+
width: 100%;
|
13
|
+
float: none;
|
14
|
+
}
|
15
|
+
}
|
16
|
+
|
17
|
+
form.form-horizontal.two-column-layout {
|
18
|
+
margin: 0 -15px;
|
19
|
+
.form-group {
|
20
|
+
width: 50%;
|
21
|
+
float: left;
|
22
|
+
margin: 0;
|
23
|
+
}
|
24
|
+
|
25
|
+
.btn {
|
26
|
+
clear: both;
|
27
|
+
margin-right: 15px;
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
@@ -8,6 +8,8 @@ class CrmFormWidget < Widget
|
|
8
8
|
attribute :redirect_to, :reference
|
9
9
|
attribute :submit_button_text, :string
|
10
10
|
attribute :dynamic_attributes, :widgetlist
|
11
|
+
attribute :label_position, :enum, values: ['left','top'], default: 'left'
|
12
|
+
attribute :columns, :enum, values: ['one','two'], default: 'one'
|
11
13
|
|
12
14
|
def valid_widget_classes_for(field_name)
|
13
15
|
[DynamicAttributeWidget]
|
@@ -52,4 +54,8 @@ class CrmFormWidget < Widget
|
|
52
54
|
def self.activity_ids
|
53
55
|
CrmFormWidget.activities.map {|a| a.id}
|
54
56
|
end
|
57
|
+
|
58
|
+
def field_as_select?(options)
|
59
|
+
columns == 'two' || options['valid_values'].count > 5
|
60
|
+
end
|
55
61
|
end
|
@@ -10,8 +10,12 @@ class CrmFormPresenter
|
|
10
10
|
@activity = widget.activity
|
11
11
|
@page = widget.obj
|
12
12
|
@params = request.params["crm_form_presenter"]
|
13
|
+
@dynamic_params = set_dynamic_params
|
14
|
+
errors = validate_params
|
13
15
|
|
14
|
-
if
|
16
|
+
if errors.present?
|
17
|
+
return {status: "error", message: errors}
|
18
|
+
elsif request.post? && widget.id == @params[:widget_id]
|
15
19
|
redirect_after_submit(controller, widget, self.submit)
|
16
20
|
end
|
17
21
|
end
|
@@ -32,8 +36,7 @@ class CrmFormPresenter
|
|
32
36
|
|
33
37
|
private
|
34
38
|
def prepare_activity_params
|
35
|
-
|
36
|
-
@params[:comment_notes] = dynamic_params if dynamic_params.present?
|
39
|
+
@params[:comment_notes] = @dynamic_params if @dynamic_params.present?
|
37
40
|
|
38
41
|
@params.delete("widget_id")
|
39
42
|
@params["title"] = @params[:title].empty? ? @activity.id : @params[:title]
|
@@ -43,7 +46,7 @@ class CrmFormPresenter
|
|
43
46
|
|
44
47
|
def set_dynamic_params
|
45
48
|
dynamic_params = {};
|
46
|
-
@params.each do |key, value|
|
49
|
+
(@params || []).each do |key, value|
|
47
50
|
if key.starts_with? 'dynamic_'
|
48
51
|
dynamic_params[key] = value
|
49
52
|
@params.delete(key)
|
@@ -118,4 +121,15 @@ class CrmFormPresenter
|
|
118
121
|
controller.redirect_to("/#{@page.id}", alert: submit_message[:message])
|
119
122
|
end
|
120
123
|
end
|
124
|
+
|
125
|
+
def validate_params
|
126
|
+
return false if @params.nil?
|
127
|
+
email = validate_email(@params['custom_email'])
|
128
|
+
hook = Obj.respond_to?('crm_form_validation') ? Obj.crm_form_validation(@params) : false
|
129
|
+
email || hook
|
130
|
+
end
|
131
|
+
|
132
|
+
def validate_email(email)
|
133
|
+
email.present ? /.+@.+\..+/i.match(email).present? : false
|
134
|
+
end
|
121
135
|
end
|
@@ -1,13 +1,17 @@
|
|
1
|
-
<div class="form-group">
|
1
|
+
<div class="form-group form-field-<%= name %>">
|
2
2
|
<%= form.label name.to_sym, label, class: "control-label col-sm-3 #{options[:mandatory] ? 'mandatory' : ''}" %>
|
3
3
|
<div class="col-sm-9">
|
4
|
-
<% options
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
4
|
+
<% if widget.field_as_select?(options) %>
|
5
|
+
<%= form.select(name.to_sym, options_for_select(options['valid_values'].map { |u| [u, u.downcase] })) %>
|
6
|
+
<% else %>
|
7
|
+
<% options['valid_values'].each do |value| %>
|
8
|
+
<div class="radio">
|
9
|
+
<%= form.label "#{name}_#{value.downcase}" do %>
|
10
|
+
<%= form.radio_button name.to_sym, value %>
|
11
|
+
<%= t("helpers.label.crm_form_presenter.#{name}_option.#{value.downcase}") %>
|
12
|
+
<% end %>
|
13
|
+
</div>
|
14
|
+
<% end %>
|
11
15
|
<% end %>
|
12
16
|
</div>
|
13
17
|
</div>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<div class="form-group">
|
1
|
+
<div class="form-group form-field-<%= name %>">
|
2
2
|
<%= form.label name.to_sym, label, class: "control-label col-sm-3 #{options[:mandatory] ? 'mandatory' : ''}" %>
|
3
3
|
<div class="col-sm-9">
|
4
4
|
<%= form.text_field name.to_sym, class: "form-control", maxlength: options[:maxlength] %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<div class="form-group">
|
1
|
+
<div class="form-group form-field-<%= name %>">
|
2
2
|
<%= form.label name.to_sym, label, class: "control-label col-sm-3 #{options[:mandatory] ? 'mandatory' : ''}" %>
|
3
3
|
<div class="col-sm-9">
|
4
4
|
<%= form.text_area name.to_sym, class: "form-control", maxlength: options[:maxlength] %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= form_for CrmFormPresenter.new(widget, request, controller), url: scrivito_path(widget.obj), html: { class: "form-horizontal"} do |form| %>
|
1
|
+
<%= form_for CrmFormPresenter.new(widget, request, controller), url: scrivito_path(widget.obj), html: { class: "form-horizontal clearfix label-position-#{widget.label_position} #{widget.columns}-column-layout"} do |form| %>
|
2
2
|
<% if widget.subject %>
|
3
3
|
<%= form.hidden_field(:title, value: widget.subject) %>
|
4
4
|
<% end %>
|
@@ -7,12 +7,12 @@
|
|
7
7
|
|
8
8
|
<% widget.attributes.each do |name, options| %>
|
9
9
|
<% CrmFormPresenter.send(:attr_accessor, name.to_sym) %>
|
10
|
-
<%= render "crm_form_widget/crm_#{options["attribute_type"]}", form: form, name: name, options: options, label: nil %>
|
10
|
+
<%= render "crm_form_widget/crm_#{options["attribute_type"]}", form: form, name: name, options: options, label: nil, widget: widget %>
|
11
11
|
<% end %>
|
12
12
|
|
13
13
|
<% widget.dynamic_attributes.each do |attribute| %>
|
14
14
|
<% CrmFormPresenter.send(:attr_accessor, attribute.field_name.to_sym) %>
|
15
|
-
<%= render "crm_form_widget/crm_#{attribute.type}", form: form, name: attribute.field_name, options: attribute.options || {}, label: attribute.label %>
|
15
|
+
<%= render "crm_form_widget/crm_#{attribute.type}", form: form, name: attribute.field_name, options: attribute.options || {}, label: attribute.label, widget: widget %>
|
16
16
|
<% end %>
|
17
17
|
|
18
18
|
<div class="form-group last">
|
@@ -19,6 +19,14 @@
|
|
19
19
|
<%= scrivito_details_for t('scrivito_crm_form_widget.details.submit_button_text', default: 'Text on submit button') do %>
|
20
20
|
<%= scrivito_tag :div, widget, :submit_button_text %>
|
21
21
|
<% end %>
|
22
|
+
|
23
|
+
<%= scrivito_details_for t('scrivito_crm_form_widget.details.label_position', default: 'Label Position') do %>
|
24
|
+
<%= scrivito_tag :div, widget, :label_position %>
|
25
|
+
<% end %>
|
26
|
+
|
27
|
+
<%= scrivito_details_for t('scrivito_crm_form_widget.details.columns', default: 'Columns') do %>
|
28
|
+
<%= scrivito_tag :div, widget, :columns %>
|
29
|
+
<% end %>
|
22
30
|
</div>
|
23
31
|
|
24
32
|
<div class="tab-panel" id="edit-tags">
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scrivito_crm_form_widget
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0.beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scrivito
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: scrivito
|
@@ -77,7 +77,7 @@ files:
|
|
77
77
|
- Rakefile
|
78
78
|
- app/assets/images/widgets/scrivito_crm_form_widget.png
|
79
79
|
- app/assets/scripts/scrivito_crm_form_widget.js
|
80
|
-
- app/assets/styles/scrivito_crm_form_widget.
|
80
|
+
- app/assets/styles/scrivito_crm_form_widget.scss
|
81
81
|
- app/controllers/scrivito_crm_form_widget/application_controller.rb
|
82
82
|
- app/models/crm_form_widget.rb
|
83
83
|
- app/models/dynamic_attribute_widget.rb
|
@@ -112,12 +112,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
112
112
|
version: '0'
|
113
113
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - "
|
115
|
+
- - ">"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
117
|
+
version: 1.3.1
|
118
118
|
requirements: []
|
119
119
|
rubyforge_project:
|
120
|
-
rubygems_version: 2.
|
120
|
+
rubygems_version: 2.5.1
|
121
121
|
signing_key:
|
122
122
|
specification_version: 4
|
123
123
|
summary: A widget for Scrivito to show a form using Infopark CRM api v2.0.
|