adminpanel 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -1
- data/Gemfile +3 -3
- data/adminpanel.gemspec +1 -2
- data/app/assets/javascripts/adminpanel/bootstrap-wysihtml5-3.min.js +261 -0
- data/app/assets/javascripts/adminpanel/bootstrap-wysihtml5-advanced.js +553 -0
- data/app/assets/javascripts/adminpanel/bootstrap-wysihtml5.js +511 -0
- data/app/assets/javascripts/adminpanel/wysiwyg.js +5 -0
- data/app/assets/stylesheets/adminpanel/bootstrap-wysihtml5.css +102 -0
- data/app/assets/stylesheets/application-admin.css +0 -1
- data/app/controllers/adminpanel/analytics_controller.rb +2 -1
- data/app/controllers/adminpanel/application_controller.rb +2 -1
- data/app/controllers/adminpanel/sections_controller.rb +1 -1
- data/app/controllers/adminpanel/sessions_controller.rb +2 -2
- data/app/controllers/concerns/adminpanel/rest_actions.rb +4 -5
- data/app/helpers/adminpanel/{custom_form_builder.rb → adminpanel_form_builder.rb} +14 -38
- data/app/helpers/adminpanel/application_helper.rb +2 -2
- data/app/helpers/adminpanel/router_helper.rb +10 -1
- data/app/models/adminpanel/analytic.rb +1 -1
- data/app/models/adminpanel/gallery.rb +1 -1
- data/app/models/adminpanel/section.rb +27 -6
- data/app/models/adminpanel/user.rb +1 -0
- data/app/models/concerns/adminpanel/base.rb +4 -1
- data/app/views/adminpanel/categories/_category_form.html.erb +1 -1
- data/app/views/adminpanel/sections/edit.html.erb +1 -1
- data/app/views/shared/_form_fields.html.erb +88 -85
- data/app/views/shared/_remote_form_fields.html.erb +1 -1
- data/app/views/shared/edit.html.erb +1 -1
- data/app/views/shared/new.html.erb +6 -5
- data/app/views/shared/show.html.erb +7 -7
- data/config/locales/en.yml +12 -8
- data/config/locales/es.yml +13 -9
- data/config/routes.rb +18 -14
- data/lib/adminpanel.rb +1 -1
- data/lib/adminpanel/version.rb +1 -1
- data/lib/generators/adminpanel/initialize/templates/category_template.rb +2 -1
- data/lib/tasks/adminpanel/adminpanel.rake +1 -1
- data/spec/features/shared_pages_spec.rb +1 -1
- metadata +77 -72
@@ -0,0 +1,102 @@
|
|
1
|
+
ul.wysihtml5-toolbar {
|
2
|
+
margin: 0;
|
3
|
+
padding: 0;
|
4
|
+
display: block;
|
5
|
+
}
|
6
|
+
|
7
|
+
ul.wysihtml5-toolbar::after {
|
8
|
+
clear: both;
|
9
|
+
display: table;
|
10
|
+
content: "";
|
11
|
+
}
|
12
|
+
|
13
|
+
ul.wysihtml5-toolbar > li {
|
14
|
+
float: left;
|
15
|
+
display: list-item;
|
16
|
+
list-style: none;
|
17
|
+
margin: 0 5px 10px 0;
|
18
|
+
}
|
19
|
+
|
20
|
+
ul.wysihtml5-toolbar a[data-wysihtml5-command=bold] {
|
21
|
+
font-weight: bold;
|
22
|
+
}
|
23
|
+
|
24
|
+
ul.wysihtml5-toolbar a[data-wysihtml5-command=italic] {
|
25
|
+
font-style: italic;
|
26
|
+
}
|
27
|
+
|
28
|
+
ul.wysihtml5-toolbar a[data-wysihtml5-command=underline] {
|
29
|
+
text-decoration: underline;
|
30
|
+
}
|
31
|
+
|
32
|
+
ul.wysihtml5-toolbar a.btn.wysihtml5-command-active {
|
33
|
+
background-image: none;
|
34
|
+
-webkit-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15),0 1px 2px rgba(0, 0, 0, 0.05);
|
35
|
+
-moz-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15),0 1px 2px rgba(0, 0, 0, 0.05);
|
36
|
+
box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15),0 1px 2px rgba(0, 0, 0, 0.05);
|
37
|
+
background-color: #E6E6E6;
|
38
|
+
background-color: #D9D9D9;
|
39
|
+
outline: 0;
|
40
|
+
}
|
41
|
+
|
42
|
+
ul.wysihtml5-commands-disabled .dropdown-menu {
|
43
|
+
display: none !important;
|
44
|
+
}
|
45
|
+
|
46
|
+
ul.wysihtml5-toolbar div.wysihtml5-colors {
|
47
|
+
display:block;
|
48
|
+
width: 50px;
|
49
|
+
height: 20px;
|
50
|
+
margin-top: 2px;
|
51
|
+
margin-left: 5px;
|
52
|
+
position: absolute;
|
53
|
+
pointer-events: none;
|
54
|
+
}
|
55
|
+
|
56
|
+
ul.wysihtml5-toolbar a.wysihtml5-colors-title {
|
57
|
+
padding-left: 70px;
|
58
|
+
}
|
59
|
+
|
60
|
+
ul.wysihtml5-toolbar div[data-wysihtml5-command-value="black"] {
|
61
|
+
background: black !important;
|
62
|
+
}
|
63
|
+
|
64
|
+
ul.wysihtml5-toolbar div[data-wysihtml5-command-value="silver"] {
|
65
|
+
background: silver !important;
|
66
|
+
}
|
67
|
+
|
68
|
+
ul.wysihtml5-toolbar div[data-wysihtml5-command-value="gray"] {
|
69
|
+
background: gray !important;
|
70
|
+
}
|
71
|
+
|
72
|
+
ul.wysihtml5-toolbar div[data-wysihtml5-command-value="maroon"] {
|
73
|
+
background: maroon !important;
|
74
|
+
}
|
75
|
+
|
76
|
+
ul.wysihtml5-toolbar div[data-wysihtml5-command-value="red"] {
|
77
|
+
background: red !important;
|
78
|
+
}
|
79
|
+
|
80
|
+
ul.wysihtml5-toolbar div[data-wysihtml5-command-value="purple"] {
|
81
|
+
background: purple !important;
|
82
|
+
}
|
83
|
+
|
84
|
+
ul.wysihtml5-toolbar div[data-wysihtml5-command-value="green"] {
|
85
|
+
background: green !important;
|
86
|
+
}
|
87
|
+
|
88
|
+
ul.wysihtml5-toolbar div[data-wysihtml5-command-value="olive"] {
|
89
|
+
background: olive !important;
|
90
|
+
}
|
91
|
+
|
92
|
+
ul.wysihtml5-toolbar div[data-wysihtml5-command-value="navy"] {
|
93
|
+
background: navy !important;
|
94
|
+
}
|
95
|
+
|
96
|
+
ul.wysihtml5-toolbar div[data-wysihtml5-command-value="blue"] {
|
97
|
+
background: blue !important;
|
98
|
+
}
|
99
|
+
|
100
|
+
ul.wysihtml5-toolbar div[data-wysihtml5-command-value="orange"] {
|
101
|
+
background: orange !important;
|
102
|
+
}
|
@@ -12,6 +12,7 @@ module Adminpanel
|
|
12
12
|
|
13
13
|
before_filter :signed_in_user, :set_model, :strong_params_for_cancan
|
14
14
|
|
15
|
+
private
|
15
16
|
def strong_params_for_cancan
|
16
17
|
resource = controller_name.singularize.to_sym
|
17
18
|
method = "#{resource}_params"
|
@@ -24,7 +25,7 @@ module Adminpanel
|
|
24
25
|
end
|
25
26
|
|
26
27
|
def signed_in_user
|
27
|
-
redirect_to signin_url, :notice => I18n.t(
|
28
|
+
redirect_to signin_url, :notice => I18n.t('authentication.welcome') unless signed_in?
|
28
29
|
end
|
29
30
|
|
30
31
|
def set_model
|
@@ -28,7 +28,7 @@ module Adminpanel
|
|
28
28
|
@section = Section.find(params[:id])
|
29
29
|
|
30
30
|
if @section.update_attributes(params[:section])
|
31
|
-
redirect_to section_path(@section), :notice =>
|
31
|
+
redirect_to section_path(@section), :notice => 'La seccion se ha actualizado'
|
32
32
|
else
|
33
33
|
render 'edit'
|
34
34
|
end
|
@@ -27,7 +27,7 @@ module Adminpanel
|
|
27
27
|
params.merge({:belongs_request => params[:belongs_request]}) if params[:belongs_request].present?
|
28
28
|
create! do |success, failure|
|
29
29
|
success.html do
|
30
|
-
flash[:success] = I18n.t(
|
30
|
+
flash[:success] = I18n.t('action.save_success')
|
31
31
|
redirect_to resource
|
32
32
|
end
|
33
33
|
failure.html do
|
@@ -35,11 +35,10 @@ module Adminpanel
|
|
35
35
|
render 'shared/new'
|
36
36
|
end
|
37
37
|
success.js do
|
38
|
-
flash.now[:success] = I18n.t("action.save_success")
|
39
38
|
if params[:belongs_request]
|
40
|
-
render 'shared/create_belongs_to', :locals => {:resource => resource }
|
39
|
+
render 'shared/create_belongs_to', :locals => { :resource => resource }
|
41
40
|
else
|
42
|
-
render 'shared/create_has_many', :locals => {:resource => resource }
|
41
|
+
render 'shared/create_has_many', :locals => { :resource => resource }
|
43
42
|
end
|
44
43
|
end
|
45
44
|
failure.js do
|
@@ -62,7 +61,7 @@ module Adminpanel
|
|
62
61
|
def update
|
63
62
|
update! do |success, failure|
|
64
63
|
success.html do
|
65
|
-
flash[:success] = I18n.t(
|
64
|
+
flash.now[:success] = I18n.t('action.save_success')
|
66
65
|
render 'shared/index'
|
67
66
|
end
|
68
67
|
failure.html do
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Adminpanel
|
2
|
-
class
|
2
|
+
class AdminpanelFormBuilder < ActionView::Helpers::FormBuilder
|
3
3
|
|
4
4
|
alias_method :text_field_original, :text_field
|
5
5
|
alias_method :radio_button_original, :radio_button
|
@@ -70,27 +70,18 @@ module Adminpanel
|
|
70
70
|
|
71
71
|
def wysiwyg_field(name, *args)
|
72
72
|
options = args.extract_options!
|
73
|
-
label = options[
|
74
|
-
options.delete(
|
73
|
+
label = options['label']
|
74
|
+
options.delete('label')
|
75
75
|
|
76
|
-
@template.content_tag(:div, :class =>
|
77
|
-
@template.content_tag(:label, label, :class =>
|
78
|
-
@template.content_tag(:div, :class =>
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
)
|
86
|
-
else
|
87
|
-
@template.content_tag(
|
88
|
-
:div,
|
89
|
-
self.object.send(name).html_safe,
|
90
|
-
:id => name,
|
91
|
-
"data-placeholder" => I18n.t("Write description here")
|
92
|
-
)
|
93
|
-
end
|
76
|
+
@template.content_tag(:div, :class => 'control-group') do
|
77
|
+
@template.content_tag(:label, label, :class => 'control-label') +
|
78
|
+
@template.content_tag(:div, :class => 'controls') do
|
79
|
+
self.text_area(
|
80
|
+
name,
|
81
|
+
class: 'wysihtml5 span10',
|
82
|
+
placeholder: I18n.t('wysiwyg.description'),
|
83
|
+
rows: '6'
|
84
|
+
)
|
94
85
|
end
|
95
86
|
end
|
96
87
|
end
|
@@ -149,12 +140,12 @@ module Adminpanel
|
|
149
140
|
|
150
141
|
def select(name, select_options, *args)
|
151
142
|
options = args.extract_options!
|
143
|
+
label = options['label']
|
144
|
+
options.delete('label')
|
152
145
|
|
153
146
|
options.reverse_merge! :class => "span7"
|
154
147
|
|
155
148
|
options.reverse_merge! :include_blank => "(Seleccione por favor)";
|
156
|
-
label = options['label']
|
157
|
-
options.delete('label')
|
158
149
|
|
159
150
|
@template.content_tag :div, :class => "control-group" do
|
160
151
|
@template.content_tag(:label, label, :class => "control-label") +
|
@@ -189,21 +180,6 @@ module Adminpanel
|
|
189
180
|
end
|
190
181
|
end
|
191
182
|
|
192
|
-
def text_area(name, *args)
|
193
|
-
options = args.extract_options!
|
194
|
-
|
195
|
-
options.reverse_merge! :class => "span7"
|
196
|
-
options.reverse_merge! :rows => "10"
|
197
|
-
options.reverse_merge! :label => name
|
198
|
-
label = options['label']
|
199
|
-
options.delete('label')
|
200
|
-
|
201
|
-
@template.content_tag :div, :class => "control-group" do
|
202
|
-
@template.content_tag(:label, label, :class => "control-label") +
|
203
|
-
@template.content_tag(:div, super(name, *args << options), :class => "controls")
|
204
|
-
end
|
205
|
-
end
|
206
|
-
|
207
183
|
def submit(name, *args)
|
208
184
|
options = args.extract_options!
|
209
185
|
|
@@ -4,9 +4,9 @@ module Adminpanel
|
|
4
4
|
include BreadcrumbsHelper
|
5
5
|
include SharedPagesHelper
|
6
6
|
|
7
|
-
def
|
7
|
+
def adminpanel_form_for(name, *args, &block)
|
8
8
|
options = args.extract_options!
|
9
|
-
options.reverse_merge! :builder => Adminpanel::
|
9
|
+
options.reverse_merge! :builder => Adminpanel::AdminpanelFormBuilder, :html => { :class => "form-horizontal" }
|
10
10
|
|
11
11
|
form_for(name, *(args << options), &block)
|
12
12
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Adminpanel
|
2
2
|
module RouterHelper
|
3
|
-
def
|
3
|
+
def get_gallery_children(resource)
|
4
4
|
resource_class(resource).gallery_children
|
5
5
|
end
|
6
6
|
|
@@ -8,6 +8,15 @@ module Adminpanel
|
|
8
8
|
resource_class(resource).routes_options
|
9
9
|
end
|
10
10
|
|
11
|
+
def rest_path_names
|
12
|
+
{
|
13
|
+
path_names: {
|
14
|
+
new: I18n.t('routes.new'),
|
15
|
+
edit: I18n.t('routes.edit'),
|
16
|
+
show: I18n.t('routes.show')
|
17
|
+
}
|
18
|
+
}
|
19
|
+
end
|
11
20
|
private
|
12
21
|
def resource_class(resource)
|
13
22
|
"adminpanel/#{resource.to_s.singularize}".classify.constantize
|
@@ -6,18 +6,34 @@ module Adminpanel
|
|
6
6
|
|
7
7
|
mount_images :images
|
8
8
|
|
9
|
-
validates_length_of :description,
|
10
|
-
|
11
|
-
|
9
|
+
validates_length_of :description,
|
10
|
+
minimum: 10,
|
11
|
+
maximum: 10,
|
12
|
+
on: :update,
|
13
|
+
if: :is_invalid_phone?,
|
14
|
+
message: I18n.t('activerecord.errors.messages.not_phone')
|
15
|
+
validates_presence_of :description,
|
16
|
+
minimum: 9,
|
17
|
+
on: :update,
|
18
|
+
if: lambda{|section| section.has_description == true }
|
19
|
+
validates :description,
|
20
|
+
numericality: { only_integer: true },
|
21
|
+
on: :update,
|
22
|
+
if: :is_invalid_phone?
|
12
23
|
validates_presence_of :key
|
13
24
|
validates_presence_of :name
|
14
25
|
validates_presence_of :page
|
26
|
+
|
15
27
|
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
|
16
|
-
validates_format_of :description, :
|
28
|
+
validates_format_of :description, with: VALID_EMAIL_REGEX, if: lambda{|section| section.key == 'email'}
|
29
|
+
|
30
|
+
default_scope { order("page ASC") }
|
17
31
|
|
18
|
-
|
32
|
+
scope :of_page, lambda{ |page|
|
33
|
+
where(page: page)
|
34
|
+
}
|
19
35
|
|
20
|
-
scope :
|
36
|
+
scope :with_description, -> { where.not( description: '') }
|
21
37
|
|
22
38
|
def self.form_attributes
|
23
39
|
[
|
@@ -45,5 +61,10 @@ module Adminpanel
|
|
45
61
|
return self.attributes['description']
|
46
62
|
end
|
47
63
|
end
|
64
|
+
|
65
|
+
private
|
66
|
+
def is_invalid_phone?
|
67
|
+
key == 'phone' && description != ''
|
68
|
+
end
|
48
69
|
end
|
49
70
|
end
|
@@ -115,7 +115,10 @@ module Adminpanel
|
|
115
115
|
end
|
116
116
|
|
117
117
|
def routes_options
|
118
|
-
{ path:
|
118
|
+
{ path: ActiveSupport::Inflector.transliterate(
|
119
|
+
display_name.pluralize(I18n.default_locale).downcase
|
120
|
+
).tr(' ', '-')
|
121
|
+
}
|
119
122
|
end
|
120
123
|
|
121
124
|
def has_route?(route)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%=
|
1
|
+
<%= adminpanel_form_for(resource, :url => {:action => :create, :model => params[:model], :model_name => params[:model_name], :currentcontroller => params[:currentcontroller], :belongs_request => params[:belongs_request]}, :remote => true, :html => {:class => "form-horizontal", :id => "new-category-form"}) do |f| -%>
|
2
2
|
<div class="row-fluid">
|
3
3
|
<div class="modal-body">
|
4
4
|
<%= render 'shared/error_messages', :object => resource %>
|
@@ -6,7 +6,7 @@
|
|
6
6
|
<div class = "widget-header"><i class = "fa fa-tasks"></i><h5><%= @section.name %></h5></div>
|
7
7
|
<div class = "widget-body">
|
8
8
|
<div class = "widget-forms clearfix">
|
9
|
-
<%=
|
9
|
+
<%= adminpanel_form_for(@section, :url => section_path(@section)) do |f| %>
|
10
10
|
<%= render 'shared/error_messages', :object => @section %>
|
11
11
|
|
12
12
|
<% if @section.has_description %>
|
@@ -1,102 +1,105 @@
|
|
1
1
|
<% @model.form_attributes.each do |entries| %>
|
2
2
|
<% entries.each do |attribute, properties| %>
|
3
3
|
|
4
|
-
<%
|
5
|
-
|
6
|
-
<% args = properties.except('type') %>
|
7
|
-
<div style="display:none;">
|
8
|
-
<%= f.hidden_field attribute, :id => "#{attribute}-field", :value => resource.send(attribute) %>
|
9
|
-
</div>
|
10
|
-
<%= f.send(type, attribute, args) %>
|
11
|
-
<%= content_for :scripts do %>
|
12
|
-
<script type="text/javascript">
|
13
|
-
<%= render 'shared/init_editor', :field_var => attribute, :label => properties[:label] %>
|
14
|
-
</script>
|
15
|
-
<% end %>
|
4
|
+
<% field_type = properties['type'] %>
|
5
|
+
<% properties = properties.except('type') %>
|
16
6
|
|
17
|
-
<%
|
18
|
-
|
19
|
-
<%= content_tag :div, :class => 'file-collection-container', :data => {:max => properties['max-files'].nil? ? 0 : properties['max-files'] } do %>
|
20
|
-
<%= f.fields_for(attribute) do |builder| %>
|
21
|
-
<%= render 'shared/image_fields', :f => builder %>
|
22
|
-
<% end -%>
|
23
|
-
<%= link_to_add_fields t("Add Image"), f, attribute %>
|
24
|
-
<% end %>
|
7
|
+
<% if field_type == 'wysiwyg_field' %>
|
8
|
+
<%= f.send(field_type, attribute) %>
|
25
9
|
|
26
|
-
<%
|
27
|
-
<% elsif properties['type'] == 'belongs_to' %>
|
28
|
-
<% if !defined? remote_request %>
|
29
|
-
<% args = properties.except('type', 'model') %>
|
30
|
-
<% args.symbolize_keys! %>
|
31
|
-
<%= f.select(attribute, (@collections["#{properties["model"]}"].collect{|resource| [resource.name, resource.id]}), args) %>
|
10
|
+
<% elsif field_type == 'adminpanel_file_field' %>
|
32
11
|
|
12
|
+
<% if !defined? remote_request %>
|
13
|
+
<!-- if not making resource from other form -->
|
14
|
+
<%= content_tag :div, :class => 'file-collection-container', :data => {:max => properties['max-files'].nil? ? 0 : properties['max-files'] } do %>
|
15
|
+
<%= f.fields_for(attribute) do |builder| %>
|
16
|
+
<%= render 'shared/image_fields', :f => builder %>
|
17
|
+
<% end -%>
|
18
|
+
<%= link_to_add_fields t('Add Image'), f, attribute %>
|
19
|
+
<% end %>
|
33
20
|
|
34
|
-
<% if(properties['remote_resource'].nil? || properties['remote_resource']) %>
|
35
|
-
<!-- Button to create a new of this belongs_to resource -->
|
36
|
-
<% model_name = properties['model'].classify.constantize.model_name.to_s.demodulize.downcase %>
|
37
|
-
<%=
|
38
|
-
link_to(
|
39
|
-
I18n.t('other.add',
|
40
|
-
:model => properties['model'].classify.constantize.display_name
|
41
|
-
),
|
42
|
-
polymorphic_path(
|
43
|
-
[:new, :"#{model_name}"],
|
44
|
-
:model => @model.display_name,
|
45
|
-
:model_name => @model.name.demodulize.downcase,
|
46
|
-
:belongs_request => true
|
47
|
-
),
|
48
|
-
:class => 'btn btn-info',
|
49
|
-
:id => "#{model_name}-modal-link",
|
50
|
-
:'data-target' => "#new-modal",
|
51
|
-
:'data-toggle' => 'modal',
|
52
|
-
:remote => true
|
53
|
-
)
|
54
|
-
%>
|
55
21
|
<% end %>
|
22
|
+
<% elsif field_type == 'belongs_to' %>
|
23
|
+
<% if !defined? remote_request %>
|
24
|
+
<!-- if not making resource from other form
|
25
|
+
so we don't have to manage infinite nested forms
|
26
|
+
-->
|
27
|
+
<% args = properties.except('model') %>
|
28
|
+
<%= f.select(attribute, (@collections["#{properties["model"]}"].collect{|resource| [resource.name, resource.id]}), args) %>
|
56
29
|
|
57
30
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
31
|
+
<% if(properties['remote_resource'].nil? || properties['remote_resource']) %>
|
32
|
+
<!--
|
33
|
+
Button to create a new of this belongs_to resource
|
34
|
+
if it's supposed to be created remotely
|
35
|
+
-->
|
36
|
+
<% model_name = properties['model'].classify.constantize.model_name.to_s.demodulize.downcase %>
|
37
|
+
<%=
|
38
|
+
link_to(
|
39
|
+
I18n.t('other.add',
|
40
|
+
:model => properties['model'].classify.constantize.display_name
|
41
|
+
),
|
42
|
+
polymorphic_path(
|
43
|
+
[:new, :"#{model_name}"],
|
44
|
+
:model => @model.display_name,
|
45
|
+
:model_name => @model.name.demodulize.downcase,
|
46
|
+
:belongs_request => true
|
47
|
+
),
|
48
|
+
:class => 'btn btn-info',
|
49
|
+
:id => "#{model_name}-modal-link",
|
50
|
+
:'data-target' => "#new-modal",
|
51
|
+
:'data-toggle' => 'modal',
|
52
|
+
:remote => true
|
53
|
+
)
|
54
|
+
%>
|
55
|
+
<% end %>
|
56
|
+
<% end %>
|
57
|
+
<% elsif field_type == 'has_many' %>
|
58
|
+
<% if !defined? remote_request %>
|
59
|
+
<div class="control-group">
|
60
|
+
<div class="control-label">
|
61
|
+
<%= properties['label'] %>
|
62
|
+
</div>
|
63
|
+
<%= hidden_field_tag("#{class_name_downcase(f.object)}[#{relationship_ids(properties["model"])}][]", nil) %>
|
64
|
+
<div class="controls" id="<%= properties['model'].demodulize.downcase %>-relation">
|
65
|
+
<% @collections["#{properties['model']}"].each do |resource| %>
|
66
|
+
<%= f.checkbox(resource, class_name_downcase(f.object) ,relationship_ids(properties["model"])) %>
|
67
|
+
<% end %>
|
68
|
+
</div>
|
70
69
|
</div>
|
71
|
-
</div>
|
72
70
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
71
|
+
<% if properties['remote_resource'].nil? || propeties['remote_resource'] %>
|
72
|
+
<!-- Button to create a new of this has_many resource
|
73
|
+
if it can be created remotely -->
|
74
|
+
<% model_name = properties['model'].classify.constantize.model_name.to_s.demodulize.downcase %>
|
75
|
+
<%=
|
76
|
+
link_to(
|
77
|
+
I18n.t('other.add',
|
78
|
+
:model => properties['model'].classify.constantize.display_name
|
79
|
+
),
|
80
|
+
polymorphic_path(
|
81
|
+
[:new, :"#{model_name}"],
|
82
|
+
:model => @model.display_name,
|
83
|
+
:model_name => @model.name.demodulize.downcase
|
84
|
+
),
|
85
|
+
:class => 'btn btn-info',
|
86
|
+
:id => "#{model_name}-modal-link",
|
87
|
+
:'data-target' => "#new-modal",
|
88
|
+
:'data-toggle' => 'modal',
|
89
|
+
:remote => true
|
90
|
+
)
|
91
|
+
%>
|
92
|
+
<% end %>
|
93
93
|
<% end %>
|
94
|
-
<% end %>
|
95
94
|
|
96
|
-
<%
|
97
|
-
<%
|
98
|
-
|
99
|
-
|
95
|
+
<% elsif field_type == 'file_field' %>
|
96
|
+
<% if !defined? remote_request %>
|
97
|
+
<% args = properties.except('name') %>
|
98
|
+
<%= f.send(field_type, attribute, args) %>
|
99
|
+
<% end %>
|
100
|
+
<% else %>
|
101
|
+
<% args = properties.except('name') %>
|
102
|
+
<%= f.send(field_type, attribute, args) %>
|
100
103
|
<% end %>
|
101
104
|
|
102
105
|
<% end %>
|