[Rt-commit] rt branch, 5.0-trunk, updated. rt-5.0.0alpha1-30-g4a86ae9888
? sunnavy
sunnavy at bestpractical.com
Wed Mar 18 17:03:12 EDT 2020
The branch, 5.0-trunk has been updated
via 4a86ae98886c8d8dfcd277028d8167ce9cde3816 (commit)
via f66ec078dcedd07013b31aa8d29c0b7ef1b8d869 (commit)
via 99a8edfb22c11b6c9cb59dc65f87e389e49cd9ee (commit)
from 30873e18f73fd1fe46a4f337f99f6318063dfb8d (commit)
Summary of changes:
lib/RT/Ticket.pm | 13 ++++++++++---
share/html/Elements/RT__Ticket/ColumnMap | 18 ++++++++++++++++++
share/html/Search/Elements/BuildFormatString | 1 +
3 files changed, 29 insertions(+), 3 deletions(-)
- Log -----------------------------------------------------------------
commit 99a8edfb22c11b6c9cb59dc65f87e389e49cd9ee
Author: Aaron Trevena <ast at bestpractical.com>
Date: Mon Dec 9 15:13:36 2019 +0000
Move unread message count to core
diff --git a/lib/RT/Ticket.pm b/lib/RT/Ticket.pm
index d0946326ba..6a3604fdb8 100644
--- a/lib/RT/Ticket.pm
+++ b/lib/RT/Ticket.pm
@@ -1526,6 +1526,41 @@ sub TotalTimeWorkedPerUser {
return $time;
}
+=head2 SeenUpToCount
+
+Returns the number of transactions marked as seen by this user for this ticket
+
+=cut
+
+sub SeenUpToCount {
+ my $self= shift;
+ my $uid = $self->CurrentUser->id;
+ my $attr = $self->FirstAttribute( "User-". $uid ."-SeenUpTo" );
+ if( $attr && $attr->Content gt $self->LastUpdated) {
+ return ( 0, undef);
+ }
+
+ my $txns = $self->Transactions;
+ $txns->Limit( FIELD => 'Type', VALUE => 'Comment' );
+ $txns->Limit( FIELD => 'Type', VALUE => 'Correspond' );
+ $txns->Limit( FIELD => 'Creator', OPERATOR => '!=', VALUE => $uid );
+ $txns->Limit(
+ FIELD => 'Created',
+ OPERATOR => '>',
+ VALUE => $attr->Content
+ ) if $attr;
+
+ my $count = $txns->Count;
+
+ if( $count) {
+ my $first_unread = $txns->First;
+ return ($count, $first_unread);
+ } else {
+ return (0, undef);
+ }
+}
+
+
=head2 Comment
Comment on this ticket.
diff --git a/share/html/Elements/RT__Ticket/ColumnMap b/share/html/Elements/RT__Ticket/ColumnMap
index 1d9c1be72d..9361543e91 100644
--- a/share/html/Elements/RT__Ticket/ColumnMap
+++ b/share/html/Elements/RT__Ticket/ColumnMap
@@ -353,6 +353,21 @@ $COLUMN_MAP = {
return \($m->scomp("/Ticket/Elements/PopupTimerLink", id => $_[0]->id ) );
},
},
+ UnreadMessages => {
+ title => 'Unread Messages', # loc
+ attribute => 'UnreadMessages',
+ value => sub {
+ my $self = shift;
+
+ my( $count, $first_unread) = $self->SeenUpToCount;
+
+ return '0' if ! $count;
+
+ return \('<a class="unread_nb" title="jump to Unread & Mark as Seen" href="'. RT->Config->Get('WebPath') .'/Ticket/Display.html?id='
+ . $self->id .'&MarkAsSeen=1&Anchor=txn-'. $first_unread->id .'">'),
+ $count, \'</a>';
+ }
+ }
};
my %ranges = RT::Ticket->CustomDateRanges;
diff --git a/share/html/Search/Elements/BuildFormatString b/share/html/Search/Elements/BuildFormatString
index de60f98a9a..901407da74 100644
--- a/share/html/Search/Elements/BuildFormatString
+++ b/share/html/Search/Elements/BuildFormatString
@@ -137,6 +137,7 @@ else {
Parents Children
Bookmark Timer
+ UnreadMessages
NEWLINE
NBSP
commit f66ec078dcedd07013b31aa8d29c0b7ef1b8d869
Author: Aaron Trevena <ast at bestpractical.com>
Date: Fri Jan 24 20:28:03 2020 +0000
Refactor unread message count to be consistent with core
CSS style was un-necessary, simplify it to just be bold. Also merge
SeenUpToCount into SeenUpTo to reduce code duplication.
diff --git a/lib/RT/Ticket.pm b/lib/RT/Ticket.pm
index 6a3604fdb8..0c639fe93a 100644
--- a/lib/RT/Ticket.pm
+++ b/lib/RT/Ticket.pm
@@ -1526,41 +1526,6 @@ sub TotalTimeWorkedPerUser {
return $time;
}
-=head2 SeenUpToCount
-
-Returns the number of transactions marked as seen by this user for this ticket
-
-=cut
-
-sub SeenUpToCount {
- my $self= shift;
- my $uid = $self->CurrentUser->id;
- my $attr = $self->FirstAttribute( "User-". $uid ."-SeenUpTo" );
- if( $attr && $attr->Content gt $self->LastUpdated) {
- return ( 0, undef);
- }
-
- my $txns = $self->Transactions;
- $txns->Limit( FIELD => 'Type', VALUE => 'Comment' );
- $txns->Limit( FIELD => 'Type', VALUE => 'Correspond' );
- $txns->Limit( FIELD => 'Creator', OPERATOR => '!=', VALUE => $uid );
- $txns->Limit(
- FIELD => 'Created',
- OPERATOR => '>',
- VALUE => $attr->Content
- ) if $attr;
-
- my $count = $txns->Count;
-
- if( $count) {
- my $first_unread = $txns->First;
- return ($count, $first_unread);
- } else {
- return (0, undef);
- }
-}
-
-
=head2 Comment
Comment on this ticket.
@@ -2638,6 +2603,10 @@ sub _SetTold {
=head2 SeenUpTo
+Returns the first comment/correspond transaction not seen by current user.
+
+In list context returns the first not-seen comment/correspond transaction
+and also the total number of such not-seen transactions.
=cut
@@ -2645,7 +2614,9 @@ sub SeenUpTo {
my $self = shift;
my $uid = $self->CurrentUser->id;
my $attr = $self->FirstAttribute( "User-". $uid ."-SeenUpTo" );
- return if $attr && $attr->Content gt $self->LastUpdated;
+ if ( $attr && $attr->Content gt $self->LastUpdated ) {
+ return wantarray ? ( undef, 0 ) : undef;
+ }
my $txns = $self->Transactions;
$txns->Limit( FIELD => 'Type', VALUE => 'Comment' );
@@ -2656,8 +2627,9 @@ sub SeenUpTo {
OPERATOR => '>',
VALUE => $attr->Content
) if $attr;
- $txns->RowsPerPage(1);
- return $txns->First;
+
+ my $next_unread_txn = $txns->First;
+ return wantarray ? ( $next_unread_txn, $txns->Count ) : $next_unread_txn;
}
=head2 RanTransactionBatch
diff --git a/share/html/Elements/RT__Ticket/ColumnMap b/share/html/Elements/RT__Ticket/ColumnMap
index 9361543e91..88fe1e8266 100644
--- a/share/html/Elements/RT__Ticket/ColumnMap
+++ b/share/html/Elements/RT__Ticket/ColumnMap
@@ -355,17 +355,20 @@ $COLUMN_MAP = {
},
UnreadMessages => {
title => 'Unread Messages', # loc
- attribute => 'UnreadMessages',
value => sub {
my $self = shift;
- my( $count, $first_unread) = $self->SeenUpToCount;
+ my ( $first_unread, $count ) = $self->SeenUpTo;
- return '0' if ! $count;
+ return '0' if !$count;
- return \('<a class="unread_nb" title="jump to Unread & Mark as Seen" href="'. RT->Config->Get('WebPath') .'/Ticket/Display.html?id='
- . $self->id .'&MarkAsSeen=1&Anchor=txn-'. $first_unread->id .'">'),
- $count, \'</a>';
+ my $link = RT->Config->Get('WebPath');
+ $link .= $session{'CurrentUser'}->Privileged ? '/Ticket/Display.html?id=' : '/SelfService/Display.html?id=';
+ $link .= $self->id . '&MarkAsSeen=1&Anchor=txn-' . $first_unread->id;
+
+ my $title = loc("Jump to Unread & Mark as Seen");
+ return \( '<a data-toggle="tooltip" data-original-title="' . $title . '" href="' . $link . '"><b>' ),
+ $count, \'</b></a>';
}
}
};
commit 4a86ae98886c8d8dfcd277028d8167ce9cde3816
Merge: 30873e18f7 f66ec078dc
Author: sunnavy <sunnavy at bestpractical.com>
Date: Thu Mar 19 04:33:04 2020 +0800
Merge branch '4.6/unread-message-count' into 5.0-trunk
-----------------------------------------------------------------------
More information about the rt-commit
mailing list