diff --git a/app/controllers/app_notifications_controller.rb b/app/controllers/app_notifications_controller.rb index a782975..0585eb7 100644 --- a/app/controllers/app_notifications_controller.rb +++ b/app/controllers/app_notifications_controller.rb @@ -47,6 +47,11 @@ def view end end + def view_by_issue_id + AppNotification.where(:recipient_id => User.current.id, :viewed => false,:issue_id => params[:issue_id] ).update_all( :viewed => true ) + redirect_to :action => 'index' + end + def view_all AppNotification.where(:recipient_id => User.current.id, :viewed => false).update_all( :viewed => true ) redirect_to :action => 'index' diff --git a/app/views/app_notifications/_mark_notify_by_issue.erb b/app/views/app_notifications/_mark_notify_by_issue.erb new file mode 100644 index 0000000..0aedd8f --- /dev/null +++ b/app/views/app_notifications/_mark_notify_by_issue.erb @@ -0,0 +1,8 @@ +<% + mnum=AppNotification.where(:recipient_id => User.current.id, :viewed => false,:issue_id => issue.id ).count.to_i + if mnum>0 +%> +<%= button_to l(:mark_this_issue_all_notify_as_seen)+":"+mnum.to_s,:controller=>"app_notifications", action: "view_by_issue_id", :issue_id => issue.id %> +<% + end +%> \ No newline at end of file diff --git a/app/views/app_notifications/index.html.erb b/app/views/app_notifications/index.html.erb index 509e664..885928e 100644 --- a/app/views/app_notifications/index.html.erb +++ b/app/views/app_notifications/index.html.erb @@ -11,6 +11,7 @@ <% @app_notifications.each do |notification| %>
"> + <%= notification.issue.subject %> <% if notification.is_edited? %> <%= render :partial => 'issues/issue_edit', :formats => [:html], :locals => { :notification => notification, :journal => notification.journal, :journal_details => details_to_strings(notification.journal.visible_details(notification.author), false, :only_path => false) }%> <% else %> diff --git a/app/views/issues/_issue_ajax_add.html.erb b/app/views/issues/_issue_ajax_add.html.erb index 7a56289..1f53386 100644 --- a/app/views/issues/_issue_ajax_add.html.erb +++ b/app/views/issues/_issue_ajax_add.html.erb @@ -3,6 +3,7 @@
<%= avatar(notification.issue.author, :size => "24") %> + <%= notification.issue.subject %>
<%= l(:text_issue_added, :id => "##{notification.issue.id}", :author => h(notification.issue.author)) %>
<%= format_time(notification.created_on) %>
diff --git a/app/views/issues/_issue_ajax_edit.html.erb b/app/views/issues/_issue_ajax_edit.html.erb index a4a1a06..955c567 100644 --- a/app/views/issues/_issue_ajax_edit.html.erb +++ b/app/views/issues/_issue_ajax_edit.html.erb @@ -3,6 +3,7 @@
<%= avatar(notification.journal.user, :size => "24") %> + <%= notification.issue.subject %>
<%= l(:text_issue_updated, :id => "##{notification.issue.id}", :author => h(notification.journal.user)) %>
diff --git a/config/locales/en.yml b/config/locales/en.yml index c82c264..1d8589c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -19,3 +19,4 @@ en: filter_button: "Filter" view_app_notifications: "View notifications" unreachable_faye_server: "Your Faye server is unreachable" + mark_this_issue_all_notify_as_seen: "Mark all notify of this issue as seen" diff --git a/config/locales/zh.yml b/config/locales/zh.yml new file mode 100644 index 0000000..c79c88a --- /dev/null +++ b/config/locales/zh.yml @@ -0,0 +1,22 @@ +# English strings go here for Rails i18n +zh: + field_app_notification: "redmine内部通知" + field_app_notification_desktop: "如果浏览器支持则使用桌面通知" + notifications: "通知" + see_all: "查看所有" + notifications_events_settings: "通知事件设置" + issue_added: "问题添加" + issue_updated: "问题更新" + issue_note_added: "问题note添加" + issue_status_updated: "问题状态更新" + issue_assigned_to_updated: "问题指派者更新" + issue_priority_updated: "问题优先级更新" + faye_server_adress: "faye的server地址,如果为空则关闭" + mark_as_seen: "标记为已读" + mark_all_as_seen: "标记所有为已读" + viewed_notification: "已读通知" + new_notification: "新通知" + filter_button: "过滤器" + view_app_notifications: "查看通知" + unreachable_faye_server: "你的 Faye服务器不可用" + mark_this_issue_all_notify_as_seen: "标记此问题的所有通知为已读" diff --git a/config/routes.rb b/config/routes.rb index 18f5d52..4c1fa79 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,3 +1,4 @@ get 'app-notifications', :to => 'app_notifications#index' get 'app-notifications/:id', :to => 'app_notifications#view' post 'app-notifications/view-all', :to => 'app_notifications#view_all' +post 'app-notifications/view_by_issue_id', :to => 'app_notifications#view_by_issue_id' diff --git a/lib/app_notifications_hook_listener.rb b/lib/app_notifications_hook_listener.rb index 63bdd9f..c2fdf19 100644 --- a/lib/app_notifications_hook_listener.rb +++ b/lib/app_notifications_hook_listener.rb @@ -1,4 +1,5 @@ class AppNotificationsHookListener < Redmine::Hook::ViewListener render_on :view_my_account_preferences, :partial => "app_notifications/my_account_preferences" render_on :view_layouts_base_html_head, :partial => "app_notifications/layouts_base_html_head" -end \ No newline at end of file + render_on(:view_issues_show_details_bottom, :partial => "app_notifications/mark_notify_by_issue" ) +end