From c8d8c6d342909c5f5c336e561558972798b07d65 Mon Sep 17 00:00:00 2001 From: Bogdanova Olga Date: Sun, 25 Apr 2021 16:22:36 +0300 Subject: [PATCH 1/4] Issues-456: Simplified Announcement --- .../vanilla/views/discussion/helper_functions.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/vanilla/applications/vanilla/views/discussion/helper_functions.php b/vanilla/applications/vanilla/views/discussion/helper_functions.php index bd45793..05e19e8 100644 --- a/vanilla/applications/vanilla/views/discussion/helper_functions.php +++ b/vanilla/applications/vanilla/views/discussion/helper_functions.php @@ -375,6 +375,8 @@ function getDiscussionOptionsDropdown($discussion = null) { // Permissions $canEdit = DiscussionModel::canEdit($discussion, $timeLeft); $canAnnounce = CategoryModel::checkPermission($categoryID, 'Vanilla.Discussions.Announce'); + // FIX: https://github.com/topcoder-platform/forums/issues/456 + $newAnnounceValue = $discussion->Announce > 0? 0 : 1; $canSink = CategoryModel::checkPermission($categoryID, 'Vanilla.Discussions.Sink'); $canClose = CategoryModel::checkPermission($categoryID, 'Vanilla.Discussions.Close'); $canDelete = CategoryModel::checkPermission($categoryID, 'Vanilla.Discussions.Delete'); @@ -392,7 +394,7 @@ function getDiscussionOptionsDropdown($discussion = null) { $dropdown->addLinkIf($canDismiss, t('Dismiss'), "vanilla/discussion/dismissannouncement?discussionid={$discussionID}", 'dismiss', 'DismissAnnouncement Hijack') ->addLinkIf($canEdit, t('Edit').$timeLeft, '/post/editdiscussion/'.$discussionID, 'edit') - ->addLinkIf($canAnnounce, t('Announce'), '/discussion/announce?discussionid='.$discussionID, 'announce', 'AnnounceDiscussion Popup') + ->addLinkIf($canAnnounce, $discussion->Announce > 0 ? t('Don\'t Announce'):t('Announce'), '/discussion/announce?discussionid='.$discussionID.'&announce='.$newAnnounceValue, 'announce', 'AnnounceDiscussion Hijack') ->addLinkIf($canSink, t($discussion->Sink ? 'Unsink' : 'Sink'), '/discussion/sink?discussionid='.$discussionID.'&sink='.(int)!$discussion->Sink, 'sink', 'SinkDiscussion Hijack') ->addLinkIf($canClose, t($discussion->Closed ? 'Reopen' : 'Close'), '/discussion/close?discussionid='.$discussionID.'&close='.(int)!$discussion->Closed, 'close', 'CloseDiscussion Hijack') ->addLinkIf($canRefetch, t('Refetch Page'), '/discussion/refetchpageinfo.json?discussionid='.$discussionID, 'refetch', 'RefetchPage Hijack') From 415b2a459cf7a3bdd7f2f7821de87f1524006425 Mon Sep 17 00:00:00 2001 From: Bogdanova Olga Date: Mon, 26 Apr 2021 00:20:26 +0300 Subject: [PATCH 2/4] Issues-544: Tooltips --- config/vanilla/bootstrap.before.php | 11 ++++------- .../vanilla/views/discussions/helper_functions.php | 12 ++++++------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/config/vanilla/bootstrap.before.php b/config/vanilla/bootstrap.before.php index cf6eba1..80d88fb 100644 --- a/config/vanilla/bootstrap.before.php +++ b/config/vanilla/bootstrap.before.php @@ -339,7 +339,6 @@ function watchIcon($hasWatched = false, $title='') { if($hasWatched) { $icon = << - $title @@ -350,7 +349,6 @@ function watchIcon($hasWatched = false, $title='') { } else { $icon = << - $title @@ -388,15 +386,14 @@ function watchButton($category, $isHijackButton = true) { $categoryID= val('CategoryID', $category); $hasWatched = $categoryModel->hasWatched($categoryID, $userID); - $text = $hasWatched ? t('Stop watching the category') : t('Watch the category'); - $icon = watchIcon($hasWatched, $text); - $cssClasses = 'watchButton' . ($hasWatched ? ' isWatching': ''); + $text = $hasWatched ? t('Stop watching forum') : t('Watch forum'); + $icon = ''.$text.''. watchIcon($hasWatched); + $cssClasses = 'watchButton ' . ($hasWatched ? ' isWatching tooltip': 'tooltip'); if($isHijackButton) { $cssClasses = 'Hijack '.$cssClasses; } - $output .= anchor( - $icon, + $output .= anchor($icon, $hasWatched ? "/category/watched/{$categoryID}/" . Gdn::session()->transientKey() : "/category/watch/{$categoryID}/" . Gdn::session()->transientKey(), $cssClasses, ['title' => $text, 'aria-pressed' => $hasWatched ? 'true' : 'false', 'role' => 'button', 'tabindex' => '0'] diff --git a/vanilla/applications/vanilla/views/discussions/helper_functions.php b/vanilla/applications/vanilla/views/discussions/helper_functions.php index f0680f5..7ec4a2e 100644 --- a/vanilla/applications/vanilla/views/discussions/helper_functions.php +++ b/vanilla/applications/vanilla/views/discussions/helper_functions.php @@ -81,12 +81,12 @@ function bookmarkButton($discussion) { // New value should be opposite $hasWatched = $discussion->Bookmarked == 1; $newValue = $hasWatched ? 0 : 1; - $title = t($hasWatched ? 'Stop watching the discussion' : 'Watch the discussion'); - $icon = watchIcon($hasWatched, $title); + $title = t($hasWatched ? 'Stop watching forum' : 'Watch forum'); + $icon = ''.$title.''.watchIcon($hasWatched); return anchor( $icon, '/discussion/bookmark/' . $discussion->DiscussionID . '/?tkey=' . Gdn::session()->transientKey() . '&bookmarked=' . $newValue, - 'Hijack watchButton ' . ($hasWatched ? ' isWatching' : ''), + 'Hijack watchButton ' . ($hasWatched ? ' isWatching tooltip' : 'tooltip'), ['title' => $title] ); } else { @@ -122,12 +122,12 @@ function bookmarkButton($discussion) { } } - $title = t($hasWatched ? 'Stop watching the discussion' : 'Watch the discussion'); - $icon = watchIcon($hasWatched, $title); + $title = t($hasWatched ? 'Stop watching forum' : 'Watch forum'); + $icon = ''.$title.''.watchIcon($hasWatched, ''); return anchor( $icon, '/discussion/bookmark/' . $discussion->DiscussionID . '/?tkey=' . Gdn::session()->transientKey() . '&bookmarked=' . $newValue, - 'Hijack watchButton ' . ($hasWatched ? ' isWatching' : ''), + 'Hijack watchButton ' . ($hasWatched ? ' isWatching tooltip' : 'tooltip'), ['title' => $title] ); } From 95ad2c6eea8cfb581dd653e70cb59ffbf479fa12 Mon Sep 17 00:00:00 2001 From: Bogdanova Olga Date: Mon, 26 Apr 2021 00:25:46 +0300 Subject: [PATCH 3/4] Issues-544: Tooltips --- .../vanilla/views/discussions/helper_functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vanilla/applications/vanilla/views/discussions/helper_functions.php b/vanilla/applications/vanilla/views/discussions/helper_functions.php index 7ec4a2e..435346a 100644 --- a/vanilla/applications/vanilla/views/discussions/helper_functions.php +++ b/vanilla/applications/vanilla/views/discussions/helper_functions.php @@ -87,7 +87,7 @@ function bookmarkButton($discussion) { $icon, '/discussion/bookmark/' . $discussion->DiscussionID . '/?tkey=' . Gdn::session()->transientKey() . '&bookmarked=' . $newValue, 'Hijack watchButton ' . ($hasWatched ? ' isWatching tooltip' : 'tooltip'), - ['title' => $title] + [] ); } else { $notificationPreferences = $categoryModel->getCategoryNotificationPreferences($discussion->CategoryID, Gdn::session()->UserID); @@ -128,7 +128,7 @@ function bookmarkButton($discussion) { $icon, '/discussion/bookmark/' . $discussion->DiscussionID . '/?tkey=' . Gdn::session()->transientKey() . '&bookmarked=' . $newValue, 'Hijack watchButton ' . ($hasWatched ? ' isWatching tooltip' : 'tooltip'), - ['title' => $title] + [] ); } } From 142e52e412d2aba17b2a82d5d193281b37c523e7 Mon Sep 17 00:00:00 2001 From: Bogdanova Olga Date: Mon, 26 Apr 2021 00:27:42 +0300 Subject: [PATCH 4/4] Issues-544: Tooltips --- config/vanilla/bootstrap.before.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/vanilla/bootstrap.before.php b/config/vanilla/bootstrap.before.php index 80d88fb..3f617fe 100644 --- a/config/vanilla/bootstrap.before.php +++ b/config/vanilla/bootstrap.before.php @@ -396,7 +396,7 @@ function watchButton($category, $isHijackButton = true) { $output .= anchor($icon, $hasWatched ? "/category/watched/{$categoryID}/" . Gdn::session()->transientKey() : "/category/watch/{$categoryID}/" . Gdn::session()->transientKey(), $cssClasses, - ['title' => $text, 'aria-pressed' => $hasWatched ? 'true' : 'false', 'role' => 'button', 'tabindex' => '0'] + [ 'aria-pressed' => $hasWatched ? 'true' : 'false', 'role' => 'button', 'tabindex' => '0'] ); } return $output;