Commit 3a2ff4c45d8d1dfeb25be7409bd6efab7715c4bc

Authored by Leandro Santos
1 parent 5be306c8

Adding admin notifications management

plugins/notification/controllers/notification_plugin_profile_controller.rb
... ... @@ -33,5 +33,21 @@ class NotificationPluginProfileController < ProfileController
33 33 render :partial => 'event', :collection => @events
34 34 end
35 35  
  36 + def notifications
  37 + @date = params[:date].nil? ? Date.today : Date.parse(params[:date])
  38 +
  39 + if request.xhr?
  40 + @event = NotificationPlugin::NotificationContent.new(params[:event])
  41 + @event.profile = profile
  42 + @event.created_by = current_person
  43 + @event.save!
  44 +
  45 + @events = profile.notifications.paginate(:per_page => per_page, :page => params[:page])
  46 + render :partial => 'event', :collection => @events
  47 + else
  48 + @events = profile.notifications.paginate(:per_page => per_page, :page => params[:page])
  49 + render :file => 'notification_plugin_profile/notifications'
  50 + end
  51 + end
36 52 end
37 53  
... ...
plugins/notification/views/notification_plugin_profile/index.html.erb
... ... @@ -5,7 +5,7 @@
5 5 <%= flash[:error] %>
6 6 <%= form_remote_tag :url => {:action => 'create'}, :update => 'lobby_notes', :success => "$('leave_note_content').value=''", :complete => "jQuery('#leave_note_form').removeClass('loading').find('*').attr('disabled', false)", :loading => "jQuery('#leave_note_form').addClass('loading').find('*').attr('disabled', true)", :html => {:id => 'leave_note_form' } do %>
7 7 <%= limited_text_area :event, :body, 420, 'leave_note_content', :cols => 50, :rows => 2, :class => 'autogrow' %>
8   - <%= submit_button :new, _('New note') %>
  8 + <%= submit_button :new, _('New') %>
9 9 <% end %>
10 10 </div>
11 11  
... ...
plugins/notification/views/notification_plugin_profile/notifications.html.erb 0 → 100644
... ... @@ -0,0 +1,19 @@
  1 +<h1><%= _('Notifications')%></h1>
  2 +
  3 +
  4 +<div id='leave_note'>
  5 + <%= flash[:error] %>
  6 + <%= form_remote_tag :url => {:action => 'notifications'}, :update => 'notifications', :success => "$('leave_notification_content').value='';$('leave_notification_title').value=''", :complete => "jQuery('#leave_notification_form').removeClass('loading').find('*').attr('disabled', false)", :loading => "jQuery('#leave_notification_form').addClass('loading').find('*').attr('disabled', true)", :html => {:id => 'leave_notification_form' } do %>
  7 + <%= _('Title:') %>
  8 + <%= text_field :event, :name, :id => 'leave_notification_title' %>
  9 + <%= limited_text_area :event, :body, 420, 'leave_notification_content', :cols => 50, :rows => 3, :class => 'autogrow' %>
  10 + <%= submit_button :new, _('New') %>
  11 + <% end %>
  12 +</div>
  13 +
  14 +
  15 +<ul id='notifications'>
  16 +<% @events.map do |event| %>
  17 + <%= render :partial => 'event', :locals => {:event => event}%>
  18 +<% end %>
  19 +</ul>
... ...