From ebd1b28b2db4da10f16e72dc59be525f38ac4f07 Mon Sep 17 00:00:00 2001 From: movilla Date: Sat, 13 Oct 2012 15:16:06 +0200 Subject: [PATCH] Fix problem javascript with read-unread notifications on notifications popup --- Changelog.md | 14 +++++++--- .../javascripts/widgets/notifications.js | 2 +- .../notifications/_notify_popup_item.haml | 12 ++++----- .../javascripts/widgets/notifications-spec.js | 26 +++++++++++++++---- 4 files changed, 38 insertions(+), 16 deletions(-) diff --git a/Changelog.md b/Changelog.md index dc5d0b437..e0692e54e 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,9 +1,15 @@ # 0.0.2.0pre -Add password_confirmation field to registration page -Fix error with open/close registrations. -Fix javascripts error in invitations facebox. -Fix css overflow problem in aspect dropdown on welcome page. +## Add Features + +* Add password_confirmation field to registration page. [#3647](https://github.com/diaspora/diaspora/pull/3647) + +## Bug Fixes + +* Fix javascripts problem with read/unread notifications. [#3656](https://github.com/diaspora/diaspora/pull/3656) +* Fix error with open/close registrations. [#3649](https://github.com/diaspora/diaspora/pull/3649) +* Fix javascripts error in invitations facebox. [#3638](https://github.com/diaspora/diaspora/pull/3638) +* Fix css overflow problem in aspect dropdown on welcome page. [#3637](https://github.com/diaspora/diaspora/pull/3637) # 0.0.1.1 diff --git a/app/assets/javascripts/widgets/notifications.js b/app/assets/javascripts/widgets/notifications.js index 55e64d0af..797d94588 100644 --- a/app/assets/javascripts/widgets/notifications.js +++ b/app/assets/javascripts/widgets/notifications.js @@ -54,7 +54,7 @@ } this.unreadClick = function() { $.ajax({ - url: "/notifications/" + $(this).closest(".stream_element").data("guid"), + url: "/notifications/" + $(this).closest(".stream_element,.notification_element").data("guid"), data: { set_unread: true }, type: "PUT", success: self.clickSuccess diff --git a/app/views/notifications/_notify_popup_item.haml b/app/views/notifications/_notify_popup_item.haml index e2c30fa27..b1a74de70 100644 --- a/app/views/notifications/_notify_popup_item.haml +++ b/app/views/notifications/_notify_popup_item.haml @@ -1,7 +1,7 @@ -.notification_element{:data=>{:guid => n.id},:class => (n.unread ? "unread" : "read")} +.notification_element{:data=>{:guid => n.id}, :class => (n.unread ? "unread" : "read")} %img{:src => n.actors.first.image_url(:thumb_medium)} - = notification_message_for(n) - %br/ - %abbr.timeago{:title=>n.created_at.iso8601} - %a{:class => 'unread-setter'} - = t('notifications.index.mark_unread') + = notification_message_for(n) + %div + %time + = timeago(n.created_at) + = link_to t('notifications.index.mark_unread'), "#", :class => "unread-setter" diff --git a/spec/javascripts/widgets/notifications-spec.js b/spec/javascripts/widgets/notifications-spec.js index 787154d4b..84ded9b46 100644 --- a/spec/javascripts/widgets/notifications-spec.js +++ b/spec/javascripts/widgets/notifications-spec.js @@ -17,7 +17,7 @@ describe("Diaspora.Widgets.Notifications", function() { }); describe("clickSuccess", function(){ - it("changes the css to a read cell", function() { + it("changes the css to a read cell at stream element", function() { this.view.$(".notifications").html( '
' + '
' @@ -25,7 +25,15 @@ describe("Diaspora.Widgets.Notifications", function() { notifications.clickSuccess({guid:2,unread:false}); expect( this.view.$('.stream_element#2')).toHaveClass("read"); }); - it("changes the css to an unread cell", function() { + it("changes the css to a read cell at notications element", function() { + this.view.$(".notifications").html( + '
' + + '
' + ); + notifications.clickSuccess({guid:2,unread:false}); + expect( this.view.$('.notification_element#2')).toHaveClass("read"); + }); + it("changes the css to an unread cell at stream element", function() { this.view.$(".notifications").html( '
' + '
' @@ -33,13 +41,21 @@ describe("Diaspora.Widgets.Notifications", function() { notifications.clickSuccess({guid:1,unread:true}); expect( this.view.$('.stream_element#1')).toHaveClass("unread"); }); + it("changes the css to an unread cell at notications element", function() { + this.view.$(".notifications").html( + '
' + + '
' + ); + notifications.clickSuccess({guid:1,unread:true}); + expect( this.view.$('.notification_element#1')).toHaveClass("unread"); + }); - it("calls Notifications.decrementCount on a read cell", function() { + it("calls Notifications.decrementCount on a read cell at stream/notification element", function() { notifications.clickSuccess(JSON.stringify({guid:1,unread:false})); expect(notifications.decrementCount).toHaveBeenCalled(); }); - it("calls Notifications.incrementCount on a unread cell", function() { + it("calls Notifications.incrementCount on a unread cell at stream/notification element", function() { notifications.clickSuccess({guid:1,unread:true}); expect(notifications.incrementCount).toHaveBeenCalled(); }); @@ -103,4 +119,4 @@ describe("Diaspora.Widgets.Notifications", function() { }); }); -}); \ No newline at end of file +});