From ff7e4d3db60649bd2e435ecdd632945d5ee4a609 Mon Sep 17 00:00:00 2001 From: Stephen Abello Date: Mon, 4 Mar 2024 14:11:20 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B02039=20-=20Display=20actions=20as=20inde?= =?UTF-8?q?pendent=20icon=20buttons?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- css/backoffice/pages/_notifications.scss | 14 ++++ .../Newsroom/iTopNewsroomController.php | 77 +++++++------------ 2 files changed, 40 insertions(+), 51 deletions(-) diff --git a/css/backoffice/pages/_notifications.scss b/css/backoffice/pages/_notifications.scss index 56a2f5ee3..a968bcec1 100644 --- a/css/backoffice/pages/_notifications.scss +++ b/css/backoffice/pages/_notifications.scss @@ -21,6 +21,9 @@ $ibo-notifications--view-all--empty--svg--max-width: 30% !default; grid-gap: $ibo-notifications--view-all--container--grid-gap; .ibo-object-summary .ibo-panel--title{ font-size: $ibo-font-size-250; + } + .ibo-object-summary .ibo-panel--toolbar{ + min-width: 102px; } .ibo-object-summary > .ibo-panel--body{ box-shadow: none; @@ -53,7 +56,18 @@ $ibo-notifications--view-all--empty--svg--max-width: 30% !default; .ibo-notifications--view-all--item--unread .ibo-panel--body::before{ background-color: $ibo-notifications--view-all--item--unread--highlight--background-color; } + +.ibo-notifications--view-all--read-action, .ibo-notifications--view-all--unread-action { + margin-left: 0 !important; +} +.ibo-notifications--view-all--item--read .ibo-notifications--view-all--read-action { + display: none; +} +.ibo-notifications--view-all--item--unread .ibo-notifications--view-all--unread-action { + display: none; +} + .ibo-notifications--view-all--empty { @extend %ibo-fully-centered-content; flex-direction: column; diff --git a/sources/Controller/Newsroom/iTopNewsroomController.php b/sources/Controller/Newsroom/iTopNewsroomController.php index ed58fea94..5dc1e6cdd 100644 --- a/sources/Controller/Newsroom/iTopNewsroomController.php +++ b/sources/Controller/Newsroom/iTopNewsroomController.php @@ -233,10 +233,6 @@ $.ajax({ type: 'POST', success: function(data) { if (data.status === 'success') { - let MarkAsReadButton = oNotificationToMarkAsRead.find('.ibo-button-group:not(.ibo-is-hidden)'); - let MarkAsUnreadButton = oNotificationToMarkAsRead.find('.ibo-button-group.ibo-is-hidden'); - MarkAsReadButton.addClass('ibo-is-hidden'); - MarkAsUnreadButton.removeClass('ibo-is-hidden'); oNotificationToMarkAsRead.removeClass('ibo-notifications--view-all--item--unread').addClass('ibo-notifications--view-all--item--read'); CombodoToast.OpenSuccessToast(data.message); $('.ibo-notifications--view-all--container').trigger('itop.notification.read'); @@ -273,12 +269,6 @@ $.ajax({ type: 'POST', success: function(data) { if (data.status === 'success') { - let MarkAsUnreadButton = oNotificationToMarkAsUnread.find('.ibo-button-group:not(.ibo-is-hidden)'); - let MarkAsReadButton = oNotificationToMarkAsUnread.find('.ibo-button-group.ibo-is-hidden'); - - MarkAsReadButton.removeClass('ibo-is-hidden'); - MarkAsUnreadButton.addClass('ibo-is-hidden'); - oNotificationToMarkAsUnread.removeClass('ibo-notifications--view-all--item--read').addClass('ibo-notifications--view-all--item--unread'); CombodoToast.OpenSuccessToast(data.message); $('.ibo-notifications--view-all--container').trigger('itop.notification.unread'); @@ -384,15 +374,15 @@ JS $oEventBlock->SetIcon($sIconUrl, Panel::ENUM_ICON_COVER_METHOD_COVER,true); } - // Prepare Event actions - $oMarkAsReadPopoverMenu = new PopoverMenu(); - $oMarkAsUnreadPopoverMenu = new PopoverMenu(); // Common actions $sDeleteUrl = Router::GetInstance()->GenerateUrl(self::ROUTE_NAMESPACE.'.delete_event', ['notification_id' => $oEvent->GetKey(), 'token' => $sCSRFToken]); - $oDeleteButton = new JSPopupMenuItem( + $oDeleteButton = ButtonUIBlockFactory::MakeForAlternativeDestructiveAction( + '', 'UI:Newsroom:iTopNotification:ViewAllPage:Action:Delete:Label', - Dict::S('UI:Newsroom:iTopNotification:ViewAllPage:Action:Delete:Label'), + 'UI:Newsroom:iTopNotification:ViewAllPage:Action:Delete:Label' + ); + $oDeleteButton->SetOnClickJsCode( <<SetIconClass('fas fa-trash-alt') + ->SetTooltip(Dict::S('UI:Newsroom:iTopNotification:ViewAllPage:Action:Delete:Label')); + + $oViewButton = ButtonUIBlockFactory::MakeIconLink('fas fa-external-link-alt', Dict::S('UI:Newsroom:iTopNotification:ViewAllPage:Action:ViewObject:Label'), - Router::GetInstance()->GenerateUrl(self::ROUTE_NAMESPACE.'.view_event', ['event_id' => $oEvent->GetKey()]), + Router::GetInstance()->GenerateUrl(self::ROUTE_NAMESPACE.'.view_event', ['event_id' => $iEventId]), '_blank' ); // Mark as read action $oMarkAsReadButton = ButtonUIBlockFactory::MakeForAlternativeSecondaryAction( - Dict::S('UI:Newsroom:iTopNotification:ViewAllPage:Action:MarkAsRead:Label'), - 'UI:Newsroom:iTopNotification:ViewAllPage:Action:MarkAsRead:Label', + '', 'UI:Newsroom:iTopNotification:ViewAllPage:Action:MarkAsRead:Label', + 'UI:Newsroom:iTopNotification:ViewAllPage:Action:MarkAsRead:Label' ); - - // Mark as read action - $oMarkAsReadPopoverMenu->AddItem('more-actions', PopoverMenuItemFactory::MakeFromApplicationPopupMenuItem($oViewButton))->SetContainer(PopoverMenu::ENUM_CONTAINER_PARENT); - $oMarkAsReadPopoverMenu->AddItem('more-actions', PopoverMenuItemFactory::MakeFromApplicationPopupMenuItem($oDeleteButton))->SetContainer(PopoverMenu::ENUM_CONTAINER_PARENT); - - // Mark as unread action - $oMarkAsUnreadPopoverMenu->AddItem('more-actions', PopoverMenuItemFactory::MakeFromApplicationPopupMenuItem($oViewButton))->SetContainer(PopoverMenu::ENUM_CONTAINER_PARENT); - $oMarkAsUnreadPopoverMenu->AddItem('more-actions', PopoverMenuItemFactory::MakeFromApplicationPopupMenuItem($oDeleteButton))->SetContainer(PopoverMenu::ENUM_CONTAINER_PARENT); - + $oMarkAsReadButton->AddCSSClass('ibo-notifications--view-all--read-action') + ->SetIconClass('far fa-envelope-open') + ->SetTooltip(Dict::S('UI:Newsroom:iTopNotification:ViewAllPage:Action:MarkAsRead:Label')); // Mark as unread action $sMarkAsReadUrl = Router::GetInstance()->GenerateUrl(self::ROUTE_NAMESPACE.'.mark_as_read', ['notification_id' => $oEvent->GetKey(), 'token' => $sCSRFToken]); @@ -446,8 +431,6 @@ JS, type: 'POST', success: function(data) { if (data.status === 'success') { - $(oSelf).parent('.ibo-button-group').addClass('ibo-is-hidden'); - $(oSelf).parent('.ibo-button-group').siblings('.ibo-button-group').removeClass('ibo-is-hidden'); $(oSelf).parents('.ibo-object-summary').removeClass('ibo-notifications--view-all--item--unread').addClass('ibo-notifications--view-all--item--read'); CombodoToast.OpenSuccessToast(data.message); $('.ibo-notifications--view-all--container').trigger('itop.notification.read'); @@ -460,13 +443,14 @@ JS, JS ); - $oMarkAsReadButtonGroup = ButtonGroupUIBlockFactory::MakeButtonWithOptionsMenu($oMarkAsReadButton, $oMarkAsReadPopoverMenu); - $oMarkAsUnreadButton = ButtonUIBlockFactory::MakeForAlternativeSecondaryAction( - Dict::S('UI:Newsroom:iTopNotification:ViewAllPage:Action:MarkAsUnread:Label'), + '', 'UI:Newsroom:iTopNotification:ViewAllPage:Action:MarkAsUnread:Label', 'UI:Newsroom:iTopNotification:ViewAllPage:Action:MarkAsUnread:Label' ); + $oMarkAsUnreadButton->AddCSSClass('ibo-notifications--view-all--unread-action') + ->SetIconClass('far fa-envelope') + ->SetTooltip(Dict::S('UI:Newsroom:iTopNotification:ViewAllPage:Action:MarkAsUnread:Label')); $sMarkAsUnreadUrl = Router::GetInstance()->GenerateUrl(self::ROUTE_NAMESPACE.'.mark_as_unread', ['notification_id' => $oEvent->GetKey(), 'token' => $sCSRFToken]); $oMarkAsUnreadButton->SetOnClickJsCode( <<GetActions()->GetId(); $oEventBlock->RemoveSubBlock($oOldButtonId); - $oEventBlock->SetToolBlocks([$oMarkAsReadButtonGroup, $oMarkAsUnreadButtonGroup]); + $oEventBlock->SetToolBlocks([$oMarkAsUnreadButton, $oMarkAsReadButton, $oViewButton, $oDeleteButton]); $oActionsBlock = new UIContentBlock(); - $oActionsBlock->AddSubBlock($oMarkAsReadButtonGroup); - $oActionsBlock->AddSubBlock($oMarkAsUnreadButtonGroup); + $oActionsBlock->AddSubBlock($oMarkAsUnreadButton); + $oActionsBlock->AddSubBlock($oMarkAsReadButton); + $oActionsBlock->AddSubBlock($oViewButton); + $oActionsBlock->AddSubBlock($oDeleteButton); $oEventBlock->SetActions($oActionsBlock); - // Display the right button depending on the read status - if($oEvent->Get('read') === 'no'){ - $oMarkAsUnreadButtonGroup->SetCSSClasses(['ibo-is-hidden']); - } - else{ - $oMarkAsReadButtonGroup->SetCSSClasses(['ibo-is-hidden']); - } $oMainContentBlock->AddSubBlock($oEventBlock); }