Commit e5609faaa64a73271bfdeb7fbd256a348ffb8e52
1 parent
164e064c
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
comment_paragraph: minor fixes
Showing
4 changed files
with
56 additions
and
9 deletions
Show diff stats
plugins/comment_paragraph/controllers/comment_paragraph_plugin_admin_controller.rb
@@ -13,6 +13,7 @@ class CommentParagraphPluginAdminController < AdminController | @@ -13,6 +13,7 @@ class CommentParagraphPluginAdminController < AdminController | ||
13 | end | 13 | end |
14 | 14 | ||
15 | if request.post? | 15 | if request.post? |
16 | + @settings.settings[:auto_marking_article_types].reject! { |type| type.blank? } | ||
16 | @settings.save! | 17 | @settings.save! |
17 | redirect_to :controller => 'plugins', :action => 'index' | 18 | redirect_to :controller => 'plugins', :action => 'index' |
18 | end | 19 | end |
plugins/comment_paragraph/lib/comment_paragraph_plugin/comment_paragraph_helper.rb
1 | module CommentParagraphPlugin::CommentParagraphHelper | 1 | module CommentParagraphPlugin::CommentParagraphHelper |
2 | 2 | ||
3 | - def self.auto_marking_enabled?(plugin_settings, article_type) | ||
4 | - auto_marking_setting = plugin_settings.get_setting('article_types_with_auto_marking') | ||
5 | - auto_marking_setting.include?(article_type) ? true : false | 3 | + def auto_marking_enabled?(plugin_settings, article_type) |
4 | + auto_marking_setting = plugin_settings.get_setting('auto_marking_article_types') | ||
5 | + auto_marking_setting && auto_marking_setting.include?(article_type) ? true : false | ||
6 | end | 6 | end |
7 | 7 | ||
8 | end | 8 | end |
plugins/comment_paragraph/public/comment_paragraph_admin.js
0 → 100644
@@ -0,0 +1,39 @@ | @@ -0,0 +1,39 @@ | ||
1 | +function check_fields(check, table_id, start) { | ||
2 | + var checkboxes = jQuery("#" + table_id + " tbody tr td input[type='checkbox']"); | ||
3 | + for (var i = start; i < checkboxes.length; i++) { | ||
4 | + checkboxes[i].checked = check; | ||
5 | + } | ||
6 | +} | ||
7 | + | ||
8 | +function verify_checked() { | ||
9 | + var checkboxes = jQuery("#auto_marking_article_types_conf tbody tr td input[type='checkbox']"); | ||
10 | + var allchecked = true | ||
11 | + for (var j = 1; j < checkboxes.length; j++) { | ||
12 | + if(!checkboxes[j].checked) { | ||
13 | + allchecked = false | ||
14 | + break | ||
15 | + } | ||
16 | + } | ||
17 | + | ||
18 | + var checkbox = checkboxes.first(); | ||
19 | + checkboxes.first().attr('checked', allchecked); | ||
20 | +} | ||
21 | + | ||
22 | +function check_all() { | ||
23 | + jQuery("input[type='checkbox']").first().click(function () { | ||
24 | + check_fields(this.checked, "auto_marking_article_types_conf", 0) | ||
25 | + }); | ||
26 | + verify_checked(); | ||
27 | +} | ||
28 | + | ||
29 | +jQuery(document).ready(function() { | ||
30 | + check_all(); | ||
31 | + jQuery("input[type='checkbox']").click(function () { | ||
32 | + var checkbox = jQuery(this).attr("id").split("_"); | ||
33 | + verify_checked(); | ||
34 | + | ||
35 | + if(this.checked == false) { | ||
36 | + jQuery("#" + checkbox.first() + "_" + checkbox.last()).attr("checked", false) | ||
37 | + } | ||
38 | + }); | ||
39 | +}); |
plugins/comment_paragraph/views/comment_paragraph_plugin_admin/index.html.erb
1 | +<% extend CommentParagraphPlugin::CommentParagraphHelper %> | ||
2 | + | ||
1 | <h1><%= _("Comment paragraph plugin settings") %></h1> | 3 | <h1><%= _("Comment paragraph plugin settings") %></h1> |
2 | 4 | ||
3 | <%= form_for(:settings) do |f| %> | 5 | <%= form_for(:settings) do |f| %> |
4 | 6 | ||
5 | -<table> | 7 | +<%= hidden_field_tag 'settings[auto_marking_article_types][]' %> |
8 | + | ||
9 | +<table id="auto_marking_article_types_conf" border="0"> | ||
6 | <tr> | 10 | <tr> |
7 | - <th> </th> | ||
8 | <th align="left"><%= _('Article type') %></th> | 11 | <th align="left"><%= _('Article type') %></th> |
9 | - <th align="left"><%= _('Article type description') %></th> | 12 | + <th><%= _('Automatic marking active') %></th> |
13 | + </tr> | ||
14 | + <tr style="background-color: #EEE; border-bottom: 2px solid #000;"> | ||
15 | + <td><span style="font-style: italic;"><%= _('Check/Uncheck All') %></span></td> | ||
16 | + <td align="center"><%= check_box_tag 'article_active', '' %></td> | ||
10 | </tr> | 17 | </tr> |
11 | <% @article_types.each do |type| %> | 18 | <% @article_types.each do |type| %> |
12 | <tr> | 19 | <tr> |
13 | - <td><%= check_box_tag 'settings[article_types_with_auto_marking][]', type[:class_name], CommentParagraphPlugin::CommentParagraphHelper.auto_marking_enabled?(@settings, type[:class_name]) %></td> | ||
14 | - <td><%= _(type[:class_name]) %></td> | ||
15 | <td><%= _(type[:short_description]) %></td> | 20 | <td><%= _(type[:short_description]) %></td> |
21 | + <td align="center"><%= check_box_tag 'settings[auto_marking_article_types][]', type[:class_name], auto_marking_enabled?(@settings, type[:class_name]) %></td> | ||
16 | </tr> | 22 | </tr> |
17 | <% end %> | 23 | <% end %> |
18 | </table> | 24 | </table> |
19 | 25 | ||
20 | - | ||
21 | <% button_bar do %> | 26 | <% button_bar do %> |
22 | <%= submit_button(:save, _('Save'), :cancel => {:controller => 'plugins', :action => 'index'}) %> | 27 | <%= submit_button(:save, _('Save'), :cancel => {:controller => 'plugins', :action => 'index'}) %> |
23 | <% end %> | 28 | <% end %> |
24 | 29 | ||
25 | <% end %> | 30 | <% end %> |
31 | + | ||
32 | +<%= javascript_include_tag 'plugins/comment_paragraph/comment_paragraph_admin' %> |