Commit 20be7887d44847c75f678dabcf37182a0ac12afc

Authored by Gabriel Silva
1 parent eecf7d16

refactors views

plugins/environment_notification/controllers/environment_notification_plugin_myprofile_controller.rb
1 -class EnvironmentNotificationPluginMyProfileController < MyProfileController 1 +class EnvironmentNotificationPluginMyprofileController < MyProfileController
2 2
3 helper EnvironmentNotificationHelper 3 helper EnvironmentNotificationHelper
4 include EnvironmentNotificationHelper 4 include EnvironmentNotificationHelper
@@ -98,7 +98,7 @@ class EnvironmentNotificationPluginMyProfileController &lt; MyProfileController @@ -98,7 +98,7 @@ class EnvironmentNotificationPluginMyProfileController &lt; MyProfileController
98 98
99 protected 99 protected
100 def admin_required 100 def admin_required
101 - redirect_to :root unless profile.is_admin?(current_user.person) 101 + redirect_to :root unless (current_person.is_admin? || profile.is_admin?(current_person))
102 end 102 end
103 103
104 end 104 end
plugins/environment_notification/lib/environment_notification_plugin.rb
@@ -21,7 +21,7 @@ class EnvironmentNotificationPlugin &lt; Noosfero::Plugin @@ -21,7 +21,7 @@ class EnvironmentNotificationPlugin &lt; Noosfero::Plugin
21 def body_beginning 21 def body_beginning
22 lambda do 22 lambda do
23 extend EnvironmentNotificationHelper 23 extend EnvironmentNotificationHelper
24 - render template: 'environment_notification_plugin_admin/show_notification' 24 + render template: 'shared/show_notification'
25 end 25 end
26 end 26 end
27 27
plugins/environment_notification/views/environment_notification_plugin_admin/_form.html.erb
@@ -1,39 +0,0 @@ @@ -1,39 +0,0 @@
1 -<div class="environment-notification-plugin-form">  
2 -  
3 - <% abstract_options = {:value => @notification.message, :style => 'width: 100%; height: 200px;', :class => 'mceEditor'} %>  
4 -  
5 - <%= button :back, _('Back'), :controller => 'environment_notification_plugin_admin' %>  
6 -  
7 - <%= form_for :notifications do |f| %>  
8 -  
9 - <%= render :file => 'shared/tiny_mce', :locals => {:mode => 'restricted'} %>  
10 -  
11 - <%= labelled_form_field(_("Optional Title:"), f.text_field(:title, value: @notification.title)) %>  
12 -  
13 - <%= labelled_form_field(_("Enter your message here:"), f.text_area(:message, abstract_options)) %>  
14 - <small class="notification-variables-options">  
15 - <%= _("Obs: You can use %{name} and %{email} variables to put the user's name and email in the message.") %>  
16 - </small>  
17 -  
18 - <%= labelled_form_field(_('Notifications Status'), select(:notifications, :active, options_for_select_with_title({"Active" => true, "Inactive" => false}, @notification.active))) %>  
19 -  
20 - <%= labelled_form_field(_('Notifications Color/Type'), select(:notifications, :type, options_for_select_with_title({_("Blue - Information") => "EnvironmentNotificationPlugin::InformationNotification", _("Yellow - Warning") => "EnvironmentNotificationPlugin::WarningNotification", _("Green - Success") => "EnvironmentNotificationPlugin::SuccessNotification", _("Red - Danger") => "EnvironmentNotificationPlugin::DangerNotification"}, @notification.type))) %>  
21 -  
22 - <div>  
23 - <%= labelled_check_box(_("Display only in the homepage"), 'notifications[display_only_in_homepage]', '1', @notification.display_only_in_homepage?) %>  
24 - </div>  
25 -  
26 - <div>  
27 - <%= labelled_check_box(_("Display to not logged users too"), 'notifications[display_to_all_users]', '1', @notification.display_to_all_users?) %>  
28 - </div>  
29 -  
30 - <div>  
31 - <%= labelled_check_box(_("Display popup until user close the notification"), 'notifications[display_popup]', '1', @notification.display_popup?) %>  
32 - </div>  
33 -  
34 - <% button_bar do %>  
35 - <%= submit_button 'save', _('Save'), :cancel => { :action => 'index' } %>  
36 - <% end %>  
37 -  
38 - <% end %>  
39 -</div>  
plugins/environment_notification/views/environment_notification_plugin_admin/edit.html.erb
1 -<%= render :partial => "form" %> 1 +<%= render :partial => "shared/form" %>
plugins/environment_notification/views/environment_notification_plugin_admin/index.html.erb
1 -<div id="environment-notification-plugin-notification-manager">  
2 - <div class="notification-manager-title">  
3 - <h1><%= _("Environment Notifications") %></h1>  
4 - </div>  
5 - <div class="buttons-bar">  
6 - <div class="new-notification">  
7 - <%= button :new, _('New Notification'), {:action => :new}, :method => :get %>  
8 - </div>  
9 - <div class="back-button">  
10 - <%= button :back, _('Back to control panel'), {:controller => 'admin_panel', :action => :index}, :method => :get %>  
11 - </div>  
12 - </div>  
13 -  
14 - <div class="notification-title-bar">  
15 - <div class="notification-title">  
16 - <%= _('Notifications') %>  
17 - </div>  
18 - <div class="action-title">  
19 - <%= _('Actions') %>  
20 - </div>  
21 - </div>  
22 -  
23 - <% @notifications.each do |notification| %>  
24 - <div class="notification-line">  
25 - <div class="notification-message">  
26 - <%= truncate(notification.message, length: 50) %>  
27 - </div>  
28 - <div class="notification-action">  
29 - <% if notification.active? %>  
30 - <%= button_without_text :deactivate, _('Deactivate'), {:action => :change_status, :id => notification}, :method => :post, :confirm => _("Do you want to change the status of this notification?") %>  
31 - <% else %>  
32 - <%= button_without_text :activate, _('Activate'), {:action => :change_status, :id => notification}, :method => :post, :confirm => _("Do you want to change the status of this notification?") %>  
33 - <% end %>  
34 - <%= button_without_text :edit, _('Edit'), {:action => 'edit', :id => notification.id} if !remove_content_button(:edit, notification) %>  
35 - <%= button_without_text :delete, _('Delete'), {:action => :destroy, :id => notification}, :method => :delete, :confirm => _("Do you want to delete this notification?") %>  
36 - </div>  
37 - </div>  
38 - <% end %>  
39 -</div>  
40 - 1 +<%= render :partial => "shared/notifications_list" %>
plugins/environment_notification/views/environment_notification_plugin_admin/new.html.erb
1 -<%= render :partial => "form" %> 1 +<%= render :partial => "shared/form" %>
plugins/environment_notification/views/environment_notification_plugin_admin/show_notification.html.erb
@@ -1,31 +0,0 @@ @@ -1,31 +0,0 @@
1 -<% if current_user && current_user.person.is_admin? %>  
2 - <% active_notifications = EnvironmentNotificationPlugin::EnvironmentNotification.active(environment) %>  
3 - <% unless active_notifications.blank? %>  
4 - <div class="environment-notification-plugin-notification-bar">  
5 - <div class="adminnotification notification">  
6 - <div class="notification-message">  
7 - <p>  
8 - <%= _("There are active notifications in this environment!") %>  
9 - <%= link_to _("Manage all notifications here."), EnvironmentNotificationPlugin.admin_url %>  
10 - </p>  
11 - </div>  
12 - </div>  
13 - </div>  
14 - <% end %>  
15 -<% end %>  
16 -  
17 -<% @notifications = EnvironmentNotificationPlugin::EnvironmentNotification.visibles(environment, current_user, controller_path).where("id NOT IN (?)", hide_notifications) %>  
18 -  
19 -<div class="environment-notification-plugin-notification-bar">  
20 - <% @notifications.each do |notification| %>  
21 - <div class="<%= notification.type.gsub("EnvironmentNotificationPlugin::", "").downcase %> notification" data-notification="<%=notification.id%>" notification-display-popup="<%=notification.display_popup?%>">  
22 - <div class="notification-message">  
23 - <%= EnvironmentNotificationHelper.substitute_variables(notification.message, current_user) %>  
24 - </div>  
25 - <% if logged_in? %>  
26 - <div class="notification-close" title="<%= _('Do not show anymore') %>"></div>  
27 - <div class="notification-hide" title="<%= _('Hide for now') %>"></div>  
28 - <% end %>  
29 - </div>  
30 - <% end %>  
31 -</div>  
plugins/environment_notification/views/environment_notification_plugin_myprofile/edit.html.erb 0 → 100644
@@ -0,0 +1 @@ @@ -0,0 +1 @@
  1 +<%= render :partial => "shared/form" %>
plugins/environment_notification/views/environment_notification_plugin_myprofile/index.html.erb 0 → 100644
@@ -0,0 +1 @@ @@ -0,0 +1 @@
  1 +<%= render :partial => "shared/notifications_list" %>
plugins/environment_notification/views/environment_notification_plugin_myprofile/new.html.erb 0 → 100644
@@ -0,0 +1 @@ @@ -0,0 +1 @@
  1 +<%= render :partial => "shared/form" %>
plugins/environment_notification/views/shared/_form.html.erb 0 → 100644
@@ -0,0 +1,39 @@ @@ -0,0 +1,39 @@
  1 +<div class="environment-notification-plugin-form">
  2 +
  3 + <% abstract_options = {:value => @notification.message, :style => 'width: 100%; height: 200px;', :class => 'mceEditor'} %>
  4 +
  5 + <%= button :back, _('Back'), :controller => 'environment_notification_plugin_admin' %>
  6 +
  7 + <%= form_for :notifications do |f| %>
  8 +
  9 + <%= render :file => 'shared/tiny_mce', :locals => {:mode => 'restricted'} %>
  10 +
  11 + <%= labelled_form_field(_("Optional Title:"), f.text_field(:title, value: @notification.title)) %>
  12 +
  13 + <%= labelled_form_field(_("Enter your message here:"), f.text_area(:message, abstract_options)) %>
  14 + <small class="notification-variables-options">
  15 + <%= _("Obs: You can use %{name} and %{email} variables to put the user's name and email in the message.") %>
  16 + </small>
  17 +
  18 + <%= labelled_form_field(_('Notifications Status'), select(:notifications, :active, options_for_select_with_title({"Active" => true, "Inactive" => false}, @notification.active))) %>
  19 +
  20 + <%= labelled_form_field(_('Notifications Color/Type'), select(:notifications, :type, options_for_select_with_title({_("Blue - Information") => "EnvironmentNotificationPlugin::InformationNotification", _("Yellow - Warning") => "EnvironmentNotificationPlugin::WarningNotification", _("Green - Success") => "EnvironmentNotificationPlugin::SuccessNotification", _("Red - Danger") => "EnvironmentNotificationPlugin::DangerNotification"}, @notification.type))) %>
  21 +
  22 + <div>
  23 + <%= labelled_check_box(_("Display only in the homepage"), 'notifications[display_only_in_homepage]', '1', @notification.display_only_in_homepage?) %>
  24 + </div>
  25 +
  26 + <div>
  27 + <%= labelled_check_box(_("Display to not logged users too"), 'notifications[display_to_all_users]', '1', @notification.display_to_all_users?) %>
  28 + </div>
  29 +
  30 + <div>
  31 + <%= labelled_check_box(_("Display popup until user close the notification"), 'notifications[display_popup]', '1', @notification.display_popup?) %>
  32 + </div>
  33 +
  34 + <% button_bar do %>
  35 + <%= submit_button 'save', _('Save'), :cancel => { :action => 'index' } %>
  36 + <% end %>
  37 +
  38 + <% end %>
  39 +</div>
plugins/environment_notification/views/shared/_notifications_list.html.erb 0 → 100644
@@ -0,0 +1,39 @@ @@ -0,0 +1,39 @@
  1 +<div id="environment-notification-plugin-notification-manager">
  2 + <div class="notification-manager-title">
  3 + <h1><%= _("Environment Notifications") %></h1>
  4 + </div>
  5 + <div class="buttons-bar">
  6 + <div class="new-notification">
  7 + <%= button :new, _('New Notification'), {:action => :new}, :method => :get %>
  8 + </div>
  9 + <div class="back-button">
  10 + <%= button :back, _('Back to control panel'), {:controller => 'admin_panel', :action => :index}, :method => :get %>
  11 + </div>
  12 + </div>
  13 +
  14 + <div class="notification-title-bar">
  15 + <div class="notification-title">
  16 + <%= _('Notifications') %>
  17 + </div>
  18 + <div class="action-title">
  19 + <%= _('Actions') %>
  20 + </div>
  21 + </div>
  22 +
  23 + <% @notifications.each do |notification| %>
  24 + <div class="notification-line">
  25 + <div class="notification-message">
  26 + <%= truncate(notification.message, length: 50) %>
  27 + </div>
  28 + <div class="notification-action">
  29 + <% if notification.active? %>
  30 + <%= button_without_text :deactivate, _('Deactivate'), {:action => :change_status, :id => notification}, :method => :post, :confirm => _("Do you want to change the status of this notification?") %>
  31 + <% else %>
  32 + <%= button_without_text :activate, _('Activate'), {:action => :change_status, :id => notification}, :method => :post, :confirm => _("Do you want to change the status of this notification?") %>
  33 + <% end %>
  34 + <%= button_without_text :edit, _('Edit'), {:action => 'edit', :id => notification.id} if !remove_content_button(:edit, notification) %>
  35 + <%= button_without_text :delete, _('Delete'), {:action => :destroy, :id => notification}, :method => :delete, :confirm => _("Do you want to delete this notification?") %>
  36 + </div>
  37 + </div>
  38 + <% end %>
  39 +</div>
plugins/environment_notification/views/shared/show_notification.html.erb 0 → 100644
@@ -0,0 +1,31 @@ @@ -0,0 +1,31 @@
  1 +<% if current_user && current_user.person.is_admin? %>
  2 + <% active_notifications = EnvironmentNotificationPlugin::EnvironmentNotification.active(environment) %>
  3 + <% unless active_notifications.blank? %>
  4 + <div class="environment-notification-plugin-notification-bar">
  5 + <div class="adminnotification notification">
  6 + <div class="notification-message">
  7 + <p>
  8 + <%= _("There are active notifications in this environment!") %>
  9 + <%= link_to _("Manage all notifications here."), EnvironmentNotificationPlugin.admin_url %>
  10 + </p>
  11 + </div>
  12 + </div>
  13 + </div>
  14 + <% end %>
  15 +<% end %>
  16 +
  17 +<% @notifications = EnvironmentNotificationPlugin::EnvironmentNotification.visibles(environment, current_user, controller_path).where("id NOT IN (?)", hide_notifications) %>
  18 +
  19 +<div class="environment-notification-plugin-notification-bar">
  20 + <% @notifications.each do |notification| %>
  21 + <div class="<%= notification.type.gsub("EnvironmentNotificationPlugin::", "").downcase %> notification" data-notification="<%=notification.id%>" notification-display-popup="<%=notification.display_popup?%>">
  22 + <div class="notification-message">
  23 + <%= EnvironmentNotificationHelper.substitute_variables(notification.message, current_user) %>
  24 + </div>
  25 + <% if logged_in? %>
  26 + <div class="notification-close" title="<%= _('Do not show anymore') %>"></div>
  27 + <div class="notification-hide" title="<%= _('Hide for now') %>"></div>
  28 + <% end %>
  29 + </div>
  30 + <% end %>
  31 +</div>