typus 3.1.0.rc18 → 3.1.0.rc19
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +14 -11
- data/.travis.yml +12 -0
- data/CHANGELOG +253 -0
- data/Gemfile +69 -0
- data/Guardfile +11 -0
- data/README.md +14 -26
- data/Rakefile +24 -100
- data/app/assets/javascripts/typus/application.js +8 -2
- data/app/assets/javascripts/typus/custom.js +2 -0
- data/app/assets/javascripts/typus/jquery.application.js +14 -0
- data/app/assets/stylesheets/typus/application.css +18 -10
- data/app/assets/stylesheets/typus/content.css +0 -1
- data/app/assets/stylesheets/typus/custom.css +11 -0
- data/app/assets/stylesheets/typus/errors.css +1 -1
- data/app/assets/stylesheets/typus/forms.css +17 -5
- data/app/assets/stylesheets/typus/hacks.css +4 -0
- data/app/assets/stylesheets/typus/header.css +8 -2
- data/app/assets/stylesheets/typus/pagination.css +3 -3
- data/app/assets/stylesheets/typus/sidebar.css +4 -0
- data/app/assets/stylesheets/typus/tables.css +0 -1
- data/app/controllers/admin/account_controller.rb +1 -2
- data/app/controllers/admin/base_controller.rb +5 -2
- data/app/controllers/admin/dashboard_controller.rb +5 -0
- data/app/controllers/admin/resource_controller.rb +1 -2
- data/app/controllers/admin/resources_controller.rb +36 -51
- data/app/controllers/admin/session_controller.rb +2 -3
- data/app/helpers/admin/base_helper.rb +2 -5
- data/app/helpers/admin/resources/data_types/belongs_to_helper.rb +35 -27
- data/app/helpers/admin/resources/data_types/dragonfly_helper.rb +16 -3
- data/app/helpers/admin/resources/data_types/has_and_belongs_to_many_helper.rb +45 -13
- data/app/helpers/admin/resources/data_types/has_many_helper.rb +27 -19
- data/app/helpers/admin/resources/data_types/has_one_helper.rb +24 -11
- data/app/helpers/admin/resources/data_types/paperclip_helper.rb +1 -1
- data/app/helpers/admin/resources/data_types/string_helper.rb +1 -1
- data/app/helpers/admin/resources/data_types/text_helper.rb +1 -1
- data/app/helpers/admin/resources/data_types/transversal_helper.rb +1 -1
- data/app/helpers/admin/resources/data_types/tree_helper.rb +1 -1
- data/app/helpers/admin/resources/display_helper.rb +10 -9
- data/app/helpers/admin/resources/filters_helper.rb +3 -10
- data/app/helpers/admin/resources/form_helper.rb +12 -2
- data/app/helpers/admin/resources/list_helper.rb +13 -5
- data/app/helpers/admin/resources/relationships_helper.rb +0 -21
- data/app/helpers/admin/resources_helper.rb +3 -3
- data/app/mailers/admin/mailer.rb +9 -4
- data/app/views/admin/base/user_guide.html.erb +1 -1
- data/app/views/admin/dashboard/{show.html.erb → index.html.erb} +0 -0
- data/app/views/admin/dashboard/widgets/_applications.html.erb +32 -10
- data/app/views/admin/mailer/reset_password_instructions.html.erb +9 -0
- data/app/views/admin/mailer/reset_password_instructions.text.erb +9 -0
- data/app/views/admin/resources/edit.html.erb +3 -13
- data/app/views/admin/resources/index.html.erb +11 -4
- data/app/views/admin/resources/new.html.erb +2 -2
- data/app/views/admin/resources/show.html.erb +1 -1
- data/app/views/admin/shared/_head.html.erb +2 -2
- data/app/views/admin/templates/_belongs_to.html.erb +6 -9
- data/app/views/admin/templates/_dragonfly.html.erb +1 -1
- data/app/views/admin/templates/_dragonfly_form_preview.html.erb +21 -0
- data/app/views/admin/templates/_dragonfly_preview.html.erb +1 -1
- data/app/views/admin/templates/_has_and_belongs_to_many.html.erb +15 -0
- data/app/views/admin/templates/{_has_n.html.erb → _has_many.html.erb} +0 -0
- data/app/views/admin/templates/_password.html.erb +1 -1
- data/app/views/admin/templates/_selector.html.erb +1 -11
- data/app/views/admin/templates/_string.html.erb +2 -20
- data/app/views/admin/templates/_string_with_preview.html.erb +2 -3
- data/app/views/admin/templates/_text.html.erb +1 -8
- data/app/views/admin/templates/_text_with_ckeditor.html.erb +1 -1
- data/app/views/admin/templates/_text_with_ckeditor_and_assets.html.erb +12 -9
- data/app/views/helpers/admin/base/_apps.html.erb +12 -4
- data/app/views/helpers/admin/base/_login_info.html.erb +1 -1
- data/app/views/helpers/admin/resources/_filters.html.erb +2 -1
- data/app/views/helpers/admin/resources/_sidebar.html.erb +25 -41
- data/app/views/layouts/admin/base.html.erb +1 -1
- data/config/locales/typus.ca.yml +1 -1
- data/config/locales/typus.de.yml +40 -35
- data/config/locales/typus.el.yml +1 -1
- data/config/locales/typus.es.yml +1 -1
- data/config/locales/typus.fr.yml +1 -1
- data/config/locales/typus.hu.yml +1 -1
- data/config/locales/typus.it.yml +1 -1
- data/config/locales/typus.locale.models.yml.template +17 -0
- data/config/locales/typus.locale.yml.template +80 -0
- data/config/locales/typus.pt-BR.yml +1 -1
- data/config/locales/typus.pt-PT.yml +2 -2
- data/config/locales/typus.ru.yml +1 -1
- data/config/locales/typus.zh-CN.yml +1 -1
- data/config/routes.rb +5 -1
- data/lib/generators/templates/config/initializers/typus.rb +9 -0
- data/lib/generators/templates/config/typus/README +0 -6
- data/lib/support/active_record.rb +2 -10
- data/lib/support/string.rb +6 -1
- data/lib/typus.rb +49 -10
- data/lib/typus/authentication/base.rb +0 -4
- data/lib/typus/authentication/none_with_role.rb +15 -0
- data/lib/typus/configuration.rb +3 -7
- data/lib/typus/controller/ancestry.rb +1 -1
- data/lib/typus/controller/bulk.rb +6 -2
- data/lib/typus/controller/format.rb +38 -25
- data/lib/typus/orm/active_record/class_methods.rb +0 -1
- data/lib/typus/orm/active_record/search.rb +6 -2
- data/lib/typus/orm/base.rb +4 -3
- data/lib/typus/orm/mongoid.rb +4 -0
- data/lib/typus/orm/{mongo → mongoid}/class_methods.rb +4 -3
- data/lib/typus/resources.rb +9 -0
- data/lib/typus/version.rb +1 -1
- data/typus.gemspec +13 -13
- data/vendor/assets/chosen/chosen-sprite.png +0 -0
- data/vendor/assets/chosen/chosen.css +334 -0
- data/vendor/assets/chosen/chosen.jquery.min.js +10 -0
- data/vendor/assets/fancybox/jquery.fancybox-1.3.4.css +17 -17
- metadata +57 -131
- data/.gitmodules +0 -6
- data/app/assets/javascripts/typus.js +0 -8
- data/app/assets/stylesheets/typus.css +0 -20
- data/app/assets/stylesheets/typus/actions.css +0 -11
- data/app/views/admin/mailer/reset_password_link.text.erb +0 -9
- data/app/views/admin/templates/_belongs_to_with_autocomplete.html.erb +0 -26
- data/lib/typus/controller/associations.rb +0 -146
- data/lib/typus/controller/autocomplete.rb +0 -16
- data/vendor/assets/fancybox/jquery.easing-1.3.pack.js +0 -72
- data/vendor/assets/fancybox/jquery.fancybox-1.3.4.js +0 -1156
- data/vendor/assets/fancybox/jquery.mousewheel-3.0.4.pack.js +0 -14
- data/vendor/assets/formalize/css/_formalize.sass +0 -332
- data/vendor/assets/formalize/css/demo.css +0 -47
- data/vendor/assets/formalize/css/reset.css +0 -202
- data/vendor/assets/formalize/css/text.css +0 -81
- data/vendor/assets/formalize/js/dojo.formalize.js +0 -166
- data/vendor/assets/formalize/js/dojo.formalize.min.js +0 -1
- data/vendor/assets/formalize/js/extjs.formalize.js +0 -163
- data/vendor/assets/formalize/js/extjs.formalize.min.js +0 -1
- data/vendor/assets/formalize/js/jquery.formalize.js +0 -150
- data/vendor/assets/formalize/js/mootools.formalize.js +0 -155
- data/vendor/assets/formalize/js/mootools.formalize.min.js +0 -1
- data/vendor/assets/formalize/js/prototype.formalize.js +0 -163
- data/vendor/assets/formalize/js/prototype.formalize.min.js +0 -1
- data/vendor/assets/formalize/js/yui.formalize.js +0 -152
- data/vendor/assets/formalize/js/yui.formalize.min.js +0 -1
- data/vendor/assets/jquery-tokeninput/jquery.tokeninput.js +0 -736
- data/vendor/assets/jquery-tokeninput/token-input.css +0 -120
@@ -10,11 +10,8 @@ module Admin::BaseHelper
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def admin_title
|
13
|
-
|
14
|
-
|
15
|
-
else
|
16
|
-
Typus.admin_title
|
17
|
-
end
|
13
|
+
setting = defined?(Admin::Setting) && Admin::Setting.admin_title
|
14
|
+
setting || Typus.admin_title
|
18
15
|
end
|
19
16
|
|
20
17
|
def has_root_path?
|
@@ -10,31 +10,21 @@ module Admin::Resources::DataTypes::BelongsToHelper
|
|
10
10
|
end
|
11
11
|
related_fk = association.foreign_key
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
options = { :controller => "/admin/#{related.to_resource}",
|
16
|
-
:action => 'new',
|
17
|
-
:resource => @resource.model_name,
|
18
|
-
:layout => 'admin/headless' }
|
19
|
-
# Pass the resource_id only to edit/update because only there is where
|
20
|
-
# the record actually exists.
|
21
|
-
options.merge!(:resource_id => @item.id) if %w(edit update).include?(params[:action])
|
22
|
-
message = link_to Typus::I18n.t("Add New"), options, { :class => 'iframe' }
|
23
|
-
end
|
24
|
-
|
25
|
-
# By default the used template is ALWAYS `belongs_to` unless we have the
|
26
|
-
# `Typus.autocomplete` feature enabled.
|
27
|
-
template = Typus.autocomplete ? "belongs_to_with_autocomplete" : "belongs_to"
|
13
|
+
html_options = { :disabled => attribute_disabled?(attribute) }
|
14
|
+
label_text = @resource.human_attribute_name(attribute)
|
28
15
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
values = expand_tree_into_select_field(related.roots, related_fk)
|
33
|
-
elsif !Typus.autocomplete
|
34
|
-
values = related.order(related.typus_order_by).map { |p| [p.to_label, p.id] }
|
16
|
+
label_text = @resource.human_attribute_name(attribute)
|
17
|
+
if (text = build_label_text_for_belongs_to(related, html_options))
|
18
|
+
label_text += "<small>#{text}</small>"
|
35
19
|
end
|
36
20
|
|
37
|
-
|
21
|
+
values = if related.respond_to?(:roots)
|
22
|
+
expand_tree_into_select_field(related.roots, related_fk)
|
23
|
+
else
|
24
|
+
related.order(related.typus_order_by).map { |p| [p.to_label, p.id] }
|
25
|
+
end
|
26
|
+
|
27
|
+
render "admin/templates/belongs_to",
|
38
28
|
:association => association,
|
39
29
|
:resource => @resource,
|
40
30
|
:attribute => attribute,
|
@@ -42,10 +32,9 @@ module Admin::Resources::DataTypes::BelongsToHelper
|
|
42
32
|
:form => form,
|
43
33
|
:related_fk => related_fk,
|
44
34
|
:related => related,
|
45
|
-
:
|
46
|
-
:label_text => @resource.human_attribute_name(attribute),
|
35
|
+
:label_text => label_text.html_safe,
|
47
36
|
:values => values,
|
48
|
-
:html_options =>
|
37
|
+
:html_options => html_options,
|
49
38
|
:options => { :include_blank => true }
|
50
39
|
end
|
51
40
|
|
@@ -58,13 +47,13 @@ module Admin::Resources::DataTypes::BelongsToHelper
|
|
58
47
|
end
|
59
48
|
end
|
60
49
|
|
61
|
-
message ||
|
50
|
+
message || mdash
|
62
51
|
end
|
63
52
|
|
64
53
|
def display_belongs_to(item, attribute)
|
65
54
|
data = item.send(attribute)
|
66
55
|
link_to data.to_label, { :controller => data.class.to_resource,
|
67
|
-
:action =>
|
56
|
+
:action => params[:action],
|
68
57
|
:id => data.id }
|
69
58
|
end
|
70
59
|
|
@@ -77,4 +66,23 @@ module Admin::Resources::DataTypes::BelongsToHelper
|
|
77
66
|
items += resource.order(resource.typus_order_by).map { |v| [v.to_label, v.id] }
|
78
67
|
end
|
79
68
|
|
69
|
+
def build_label_text_for_belongs_to(klass, html_options)
|
70
|
+
if html_options[:disabled] == true
|
71
|
+
Typus::I18n.t("Read only")
|
72
|
+
elsif admin_user.can?('create', klass) && !headless_mode?
|
73
|
+
build_add_new_for_belongs_to(klass)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def build_add_new_for_belongs_to(klass)
|
78
|
+
options = { :controller => "/admin/#{klass.to_resource}",
|
79
|
+
:action => 'new',
|
80
|
+
:resource => @resource.model_name,
|
81
|
+
:layout => 'admin/headless' }
|
82
|
+
# Pass the resource_id only to edit/update because only there is where
|
83
|
+
# the record actually exists.
|
84
|
+
options.merge!(:resource_id => @item.id) if %w(edit update).include?(params[:action])
|
85
|
+
link_to Typus::I18n.t("Add New"), options, { :class => 'iframe' }
|
86
|
+
end
|
87
|
+
|
80
88
|
end
|
@@ -1,8 +1,7 @@
|
|
1
1
|
module Admin::Resources::DataTypes::DragonflyHelper
|
2
2
|
|
3
3
|
def table_dragonfly_field(attribute, item)
|
4
|
-
|
5
|
-
typus_dragonfly_preview(item, attribute, options)
|
4
|
+
typus_dragonfly_preview(item, attribute)
|
6
5
|
end
|
7
6
|
|
8
7
|
def link_to_detach_attribute_for_dragonfly(attribute)
|
@@ -19,12 +18,26 @@ module Admin::Resources::DataTypes::DragonflyHelper
|
|
19
18
|
end
|
20
19
|
end
|
21
20
|
|
22
|
-
def typus_dragonfly_preview(item, attachment
|
21
|
+
def typus_dragonfly_preview(item, attachment)
|
23
22
|
data = item.send(attachment)
|
24
23
|
return unless data
|
25
24
|
|
26
25
|
if data.mime_type =~ /^image\/.+/
|
27
26
|
render "admin/templates/dragonfly_preview",
|
27
|
+
:preview => data.process(:thumb, Typus.image_preview_size).url,
|
28
|
+
:thumb => data.process(:thumb, Typus.image_table_thumb_size).url
|
29
|
+
else
|
30
|
+
link_to data.name, data.url
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def typus_dragonfly_form_preview(item, attachment, options = {})
|
35
|
+
data = item.send(attachment)
|
36
|
+
return unless data
|
37
|
+
|
38
|
+
if data.mime_type =~ /^image\/.+/
|
39
|
+
render "admin/templates/dragonfly_form_preview",
|
40
|
+
:attachment => data,
|
28
41
|
:preview => data.process(:thumb, Typus.image_preview_size).url,
|
29
42
|
:thumb => data.process(:thumb, Typus.image_thumb_size).url,
|
30
43
|
:options => options
|
@@ -6,19 +6,51 @@ module Admin::Resources::DataTypes::HasAndBelongsToManyHelper
|
|
6
6
|
|
7
7
|
alias_method :table_has_many_field, :table_has_and_belongs_to_many_field
|
8
8
|
|
9
|
-
def
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
locals = { :
|
21
|
-
|
9
|
+
def typus_has_and_belongs_to_many_field(attribute, form)
|
10
|
+
klass = attribute.singularize.capitalize.constantize
|
11
|
+
resource_ids = "#{attribute.singularize}_ids"
|
12
|
+
|
13
|
+
html_options = { :disabled => attribute_disabled?(resource_ids.to_sym) }
|
14
|
+
|
15
|
+
label_text = @resource.human_attribute_name(attribute)
|
16
|
+
if (text = build_label_text_for_has_and_belongs_to_many(klass, html_options))
|
17
|
+
label_text += "<small>#{text}</small>"
|
18
|
+
end
|
19
|
+
|
20
|
+
locals = { :attribute => attribute,
|
21
|
+
:attribute_id => "#{@resource.table_name}_#{attribute}",
|
22
|
+
:related_klass => klass,
|
23
|
+
:related_items => klass.all,
|
24
|
+
:related_ids => "#{@resource.name.downcase}[#{resource_ids}][]",
|
25
|
+
:values => @item.send(attribute),
|
26
|
+
:form => form,
|
27
|
+
:label_text => label_text.html_safe,
|
28
|
+
:html_options => html_options }
|
29
|
+
|
30
|
+
render "admin/templates/has_and_belongs_to_many", locals
|
31
|
+
end
|
32
|
+
|
33
|
+
def build_label_text_for_has_and_belongs_to_many(klass, html_options)
|
34
|
+
if html_options[:disabled] == true
|
35
|
+
Typus::I18n.t("Read only")
|
36
|
+
=begin
|
37
|
+
# TODO: Take this back at some point in the future. Adding a new item
|
38
|
+
# using the pop-up should update the items on the selector. I know
|
39
|
+
# this might be the most trivial thing in the world, but I don't
|
40
|
+
# know how to do it.
|
41
|
+
elsif admin_user.can?('create', klass) && !headless_mode?
|
42
|
+
build_add_new_for_has_and_belongs_to_many(klass)
|
43
|
+
=end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def build_add_new_for_has_and_belongs_to_many(klass)
|
48
|
+
options = { :controller => "/admin/#{klass.to_resource}",
|
49
|
+
:action => "new",
|
50
|
+
:layout => "admin/headless",
|
51
|
+
:return_to => request.path }
|
52
|
+
|
53
|
+
link_to Typus::I18n.t("Add New"), options, { :class => "iframe" }
|
22
54
|
end
|
23
55
|
|
24
56
|
end
|
@@ -14,30 +14,38 @@ module Admin::Resources::DataTypes::HasManyHelper
|
|
14
14
|
def typus_form_has_many(field)
|
15
15
|
setup_relationship(field)
|
16
16
|
|
17
|
-
options =
|
17
|
+
options = { @reflection.foreign_key => @item.id }
|
18
|
+
|
19
|
+
if @reflection.options && (as = @reflection.options[:as])
|
20
|
+
klass = @resource.is_sti? ? @resource.superclass : @resource
|
21
|
+
options.merge!("#{as}_type" => klass)
|
22
|
+
end
|
18
23
|
|
19
24
|
count_items_to_relate = @model_to_relate.order(@model_to_relate.typus_order_by).count - @item.send(field).count
|
20
25
|
|
21
26
|
build_pagination
|
27
|
+
set_has_many_resource_actions
|
28
|
+
|
29
|
+
locals = { :association_name => @association_name,
|
30
|
+
:add_new => build_add_new_for_has_many(@model_to_relate, field, options),
|
31
|
+
:table => build_relationship_table }
|
32
|
+
|
33
|
+
render "admin/templates/has_many", locals
|
34
|
+
end
|
35
|
+
|
36
|
+
def build_add_new_for_has_many(klass, field, options = {})
|
37
|
+
if admin_user.can?("create", klass)
|
38
|
+
default_options = { :controller => "/admin/#{klass.to_resource}",
|
39
|
+
:action => "new",
|
40
|
+
:layout => "admin/headless" }
|
41
|
+
|
42
|
+
link_to Typus::I18n.t("Add New"), default_options.merge(options), { :class => "iframe_with_reload" }
|
43
|
+
end
|
44
|
+
end
|
22
45
|
|
23
|
-
|
24
|
-
@resource_actions =
|
25
|
-
|
26
|
-
["Unrelate", { :resource_id => @item.id,
|
27
|
-
:resource => @resource.model_name,
|
28
|
-
:action => "unrelate",
|
29
|
-
:association_name => @association_name},
|
30
|
-
{ :confirm => "Unrelate?" } ]]
|
31
|
-
else
|
32
|
-
[["Edit", { :action => "edit", :layout => 'admin/headless' }, { :class => 'iframe' }],
|
33
|
-
["Trash", { :resource_id => @item.id,
|
34
|
-
:resource => @resource.model_name,
|
35
|
-
:action => "destroy" },
|
36
|
-
{ :confirm => "Trash?" } ]]
|
37
|
-
end
|
38
|
-
|
39
|
-
locals = { :association_name => @association_name, :add_new => build_add_new(options), :table => build_relationship_table }
|
40
|
-
render "admin/templates/has_n", locals
|
46
|
+
def set_has_many_resource_actions
|
47
|
+
@resource_actions = [["Edit", { :action => "edit", :layout => 'admin/headless' }, { :class => 'iframe' }],
|
48
|
+
["Trash", { :action => "destroy" }, { :confirm => "Trash?" } ]]
|
41
49
|
end
|
42
50
|
|
43
51
|
end
|
@@ -3,21 +3,34 @@ module Admin::Resources::DataTypes::HasOneHelper
|
|
3
3
|
def typus_form_has_one(field)
|
4
4
|
setup_relationship(field)
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
related_items = @item.send(field)
|
7
|
+
@items = related_items ? [related_items] : []
|
8
|
+
|
9
|
+
set_has_one_resource_actions
|
10
|
+
|
11
|
+
locals = { :association_name => @association_name, :table => build_relationship_table, :add_new => nil }
|
12
|
+
|
13
|
+
if @items.empty?
|
14
|
+
options = { :resource_id => nil, @reflection.foreign_key => @item.id }
|
15
|
+
locals[:add_new] = build_add_new_for_has_one(@model_to_relate, field, options)
|
9
16
|
end
|
10
17
|
|
11
|
-
|
12
|
-
|
13
|
-
["Trash", { :resource_id => @item.id, :resource => @resource.model_name, :action => "destroy" }, { :confirm => "Trash?" }]]
|
18
|
+
render "admin/templates/has_one", locals
|
19
|
+
end
|
14
20
|
|
15
|
-
|
21
|
+
def build_add_new_for_has_one(klass, field, options = {})
|
22
|
+
if admin_user.can?("create", klass)
|
23
|
+
default_options = { :controller => "/admin/#{klass.to_resource}",
|
24
|
+
:action => "new",
|
25
|
+
:layout => "admin/headless" }
|
26
|
+
|
27
|
+
link_to Typus::I18n.t("Add New"), default_options.merge(options), { :class => "iframe" }
|
28
|
+
end
|
29
|
+
end
|
16
30
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
:table => build_relationship_table
|
31
|
+
def set_has_one_resource_actions
|
32
|
+
@resource_actions = [["Edit", { :action => "edit" }, {}],
|
33
|
+
["Trash", { :action => "destroy" }, { :confirm => "Trash?" }]]
|
21
34
|
end
|
22
35
|
|
23
36
|
end
|
@@ -19,7 +19,7 @@ module Admin::Resources::DataTypes::StringHelper
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def table_string_field(attribute, item)
|
22
|
-
(raw_content = item.send(attribute)).present? ? raw_content :
|
22
|
+
(raw_content = item.send(attribute)).present? ? raw_content : mdash
|
23
23
|
end
|
24
24
|
|
25
25
|
alias_method :table_decimal_field, :table_string_field
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Admin::Resources::DataTypes::TextHelper
|
2
2
|
|
3
3
|
def table_text_field(attribute, item)
|
4
|
-
(raw_content = item.send(attribute)).present? ? truncate(raw_content) :
|
4
|
+
(raw_content = item.send(attribute)).present? ? truncate(raw_content) : mdash
|
5
5
|
end
|
6
6
|
|
7
7
|
end
|
@@ -2,7 +2,7 @@ module Admin::Resources::DataTypes::TransversalHelper
|
|
2
2
|
|
3
3
|
def table_transversal_field(attribute, item)
|
4
4
|
field_1, field_2 = attribute.split(".")
|
5
|
-
(related_item = item.send(field_1)) ? related_item.send(field_2) :
|
5
|
+
(related_item = item.send(field_1)) ? related_item.send(field_2) : mdash
|
6
6
|
end
|
7
7
|
|
8
8
|
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
module Admin::Resources::DisplayHelper
|
2
2
|
|
3
|
+
def mdash
|
4
|
+
"—".html_safe
|
5
|
+
end
|
6
|
+
|
3
7
|
def build_display(item, fields)
|
4
8
|
fields.map do |attribute, type|
|
5
|
-
|
6
|
-
|
7
|
-
else
|
8
|
-
"—".html_safe
|
9
|
-
end
|
10
|
-
|
9
|
+
condition = (type == :boolean) || item.send(attribute).present?
|
10
|
+
value = condition ? send("display_#{type}", item, attribute) : mdash
|
11
11
|
[@resource.human_attribute_name(attribute), value]
|
12
12
|
end
|
13
13
|
end
|
@@ -16,9 +16,10 @@ module Admin::Resources::DisplayHelper
|
|
16
16
|
String.new.tap do |html|
|
17
17
|
@resource.typus_defaults_for(:relationships).each do |relationship|
|
18
18
|
association = @resource.reflect_on_association(relationship.to_sym)
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
macro, klass = association.macro, association.class_name.constantize
|
20
|
+
if [:has_many, :has_one].include?(macro) && admin_user.can?('read', klass)
|
21
|
+
html << send("typus_form_#{macro}", relationship)
|
22
|
+
end
|
22
23
|
end
|
23
24
|
end.html_safe
|
24
25
|
end
|
@@ -5,18 +5,11 @@ module Admin::Resources::FiltersHelper
|
|
5
5
|
locals = {}
|
6
6
|
|
7
7
|
locals[:filters] = typus_filters.map do |key, value|
|
8
|
-
{ :
|
8
|
+
{ :key => set_filter(key, value), :value => send("#{value}_filter", key) }
|
9
9
|
end
|
10
10
|
|
11
|
-
locals[:
|
12
|
-
|
13
|
-
# Remove default params.
|
14
|
-
rejections = %w(controller action locale utf8 sort_order order_by)
|
15
|
-
locals[:hidden_filters].delete_if { |k, v| rejections.include?(k) }
|
16
|
-
|
17
|
-
# Remove also custom params.
|
18
|
-
rejections = locals[:filters].map { |f| f[:filter] }
|
19
|
-
locals[:hidden_filters].delete_if { |k, v| rejections.include?(k) }
|
11
|
+
rejections = %w(controller action locale utf8 sort_order order_by) + locals[:filters].map { |f| f[:key] }
|
12
|
+
locals[:hidden_filters] = params.dup.delete_if { |k, v| rejections.include?(k) }
|
20
13
|
|
21
14
|
render "helpers/admin/resources/filters", locals
|
22
15
|
end
|
@@ -13,6 +13,8 @@ module Admin::Resources::FormHelper
|
|
13
13
|
typus_template_field(key, value, form)
|
14
14
|
when :template
|
15
15
|
typus_template_field(key, template, form)
|
16
|
+
when :has_and_belongs_to_many
|
17
|
+
typus_has_and_belongs_to_many_field(key, form)
|
16
18
|
else
|
17
19
|
typus_template_field(key, :string, form)
|
18
20
|
end
|
@@ -29,13 +31,21 @@ module Admin::Resources::FormHelper
|
|
29
31
|
|
30
32
|
html_options = attribute_disabled?(attribute) ? { :disabled => 'disabled' } : {}
|
31
33
|
|
34
|
+
label_text = @resource.human_attribute_name(attribute)
|
35
|
+
|
36
|
+
=begin
|
37
|
+
if options[:disabled] == true
|
38
|
+
label_text += "<small>#{Typus::I18n.t("Read only")}</small>"
|
39
|
+
end
|
40
|
+
=end
|
41
|
+
|
32
42
|
locals = { :resource => @resource,
|
33
43
|
:attribute => attribute,
|
34
44
|
:attribute_id => "#{@resource.table_name}_#{attribute}",
|
35
45
|
:options => options,
|
36
46
|
:html_options => html_options,
|
37
47
|
:form => form,
|
38
|
-
:label_text =>
|
48
|
+
:label_text => label_text.html_safe }
|
39
49
|
|
40
50
|
render "admin/templates/#{template}", locals
|
41
51
|
end
|
@@ -59,7 +69,7 @@ module Admin::Resources::FormHelper
|
|
59
69
|
|
60
70
|
def save_options_for_headless_mode
|
61
71
|
return unless headless_mode?
|
62
|
-
|
72
|
+
{ "_continue" => "Save and continue editing" }
|
63
73
|
end
|
64
74
|
|
65
75
|
def save_options_for_user_class
|