mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Add logic to dismiss unread announcements, styling fixes.
This commit is contained in:
parent
e6eeb86046
commit
c716b86def
3 changed files with 19 additions and 14 deletions
|
@ -28,21 +28,21 @@ block content
|
|||
)
|
||||
.announcements-backdrop(
|
||||
ng-if="ui.isOpen"
|
||||
ng-click="ui.isOpen = false;"
|
||||
ng-click="toggleAnnouncementsUI();"
|
||||
)
|
||||
a.announcements-btn(
|
||||
href
|
||||
ng-if="announcements.length"
|
||||
ng-click="ui.isOpen = !ui.isOpen"
|
||||
ng-class="{ 'announcements-btn-open': ui.isOpen, 'announcements-btn-has-new': ui.hasNew }"
|
||||
ng-click="toggleAnnouncementsUI();"
|
||||
ng-class="{ 'announcements-btn-open': ui.isOpen, 'announcements-btn-has-new': ui.newItems }"
|
||||
)
|
||||
span.announcements-badge(ng-if="ui.hasNew") {{ announcements.length }}
|
||||
span.announcements-badge(ng-if="ui.newItems") {{ ui.newItems }}
|
||||
.announcements-body(
|
||||
ng-if="ui.isOpen"
|
||||
)
|
||||
.announcements-scroller
|
||||
.announcement(
|
||||
ng-repeat="announcement in announcements"
|
||||
ng-repeat="announcement in announcements | filter:(ui.newItems ? { read: false } : '') track by announcement.id"
|
||||
)
|
||||
h2.announcement-header {{ announcement.title }}
|
||||
p.announcement-description {{ announcement.excerpt }}
|
||||
|
|
|
@ -1,23 +1,27 @@
|
|||
define [
|
||||
"base"
|
||||
], (App) ->
|
||||
App.controller "AnnouncementsController", ($scope, $http, event_tracking, $window) ->
|
||||
App.controller "AnnouncementsController", ($scope, $http, event_tracking, $window, _) ->
|
||||
$scope.announcements = []
|
||||
$scope.ui =
|
||||
isOpen: false
|
||||
hasNew: false
|
||||
|
||||
newItems: 0
|
||||
|
||||
refreshAnnouncements = ->
|
||||
$http.get("/announcements").success (announcements) ->
|
||||
$scope.announcements = announcements
|
||||
$scope.ui.newItems = _.filter(announcements, (announcement) -> !announcement.read).length
|
||||
|
||||
dismissCurrentAnnouncement = ->
|
||||
event_tracking.sendMB "announcement-alert-dismissed", { blogPostId:announcement.id }
|
||||
markAnnouncementsAsRead = ->
|
||||
event_tracking.sendMB "announcement-alert-dismissed", { blogPostId: $scope.announcements[0].id }
|
||||
|
||||
refreshAnnouncements()
|
||||
|
||||
$scope.openLink = ->
|
||||
dismissCurrentAnnouncement()
|
||||
.then(refreshAnnouncements)
|
||||
$scope.toggleAnnouncementsUI = ->
|
||||
$scope.ui.isOpen = !$scope.ui.isOpen
|
||||
|
||||
if !$scope.ui.isOpen and $scope.ui.newItems
|
||||
$scope.ui.newItems = 0
|
||||
markAnnouncementsAsRead()
|
||||
|
||||
|
||||
$window.open = announcement.url
|
||||
|
|
|
@ -394,6 +394,7 @@ ul.project-list {
|
|||
|
||||
.announcements-body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
position: absolute;
|
||||
right: 3%;
|
||||
|
|
Loading…
Reference in a new issue