diff --git a/plugins/notification/controllers/notification_plugin_profile_controller.rb b/plugins/notification/controllers/notification_plugin_profile_controller.rb index d43ab0e..95cb5d8 100644 --- a/plugins/notification/controllers/notification_plugin_profile_controller.rb +++ b/plugins/notification/controllers/notification_plugin_profile_controller.rb @@ -6,8 +6,6 @@ class NotificationPluginProfileController < ProfileController protect 'see_loby_notes', :profile - layout 'embed' - def lobby_notes @date = params[:date].nil? ? Date.today : Date.parse(params[:date]) @events = profile.lobby_notes.by_day(@date).paginate(:per_page => per_page, :page => params[:page]) @@ -15,6 +13,23 @@ class NotificationPluginProfileController < ProfileController if request.xhr? render :partial => 'event', :collection => @events end + render :file => 'notification_plugin_profile/lobby_notes', :layout => 'embed' + end + + def index + @events = current_person.lobby_notes + @event = NotificationPlugin::LobbyNoteContent.new + end + + def create + @event = NotificationPlugin::LobbyNoteContent.new(params[:event]) + @event.profile = profile + @event.created_by = current_person + @events = current_person.lobby_notes + unless @event.save + flash[:error] = _('Note not saved') + end + render :partial => 'event', :collection => @events end end diff --git a/plugins/notification/lib/ext/profile.rb b/plugins/notification/lib/ext/profile.rb index 59dcb98..5bf007a 100644 --- a/plugins/notification/lib/ext/profile.rb +++ b/plugins/notification/lib/ext/profile.rb @@ -4,3 +4,10 @@ Profile.class_eval do has_many :notifications, :source => 'articles', :class_name => 'NotificationPlugin::NotificationContent', :order => 'start_date' has_many :lobby_notes, :source => 'articles', :class_name => 'NotificationPlugin::LobbyNoteContent', :order => 'start_date' end + +Person.class_eval do +# has_many :notifications, :source => 'articles', :class_name => 'NotificationPlugin::NotificationContent', :order => 'start_date' + has_many :lobby_notes, :foreign_key => 'created_by_id', :class_name => 'NotificationPlugin::LobbyNoteContent', :order => 'start_date,created_at' +# named_scope :lobby_notes_by_profile +end + diff --git a/plugins/notification/views/notification_plugin_profile/index.html.erb b/plugins/notification/views/notification_plugin_profile/index.html.erb new file mode 100644 index 0000000..e8f7431 --- /dev/null +++ b/plugins/notification/views/notification_plugin_profile/index.html.erb @@ -0,0 +1,17 @@ +

<%= _('Lobby Notes')%>

+ + +
+ <%= flash[:error] %> + <%= 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 %> + <%= limited_text_area :event, :body, 420, 'leave_note_content', :cols => 50, :rows => 2, :class => 'autogrow' %> + <%= submit_button :new, _('New note') %> + <% end %> +
+ + + -- libgit2 0.21.2