From 886fb9b2a0fca7c481da3f4f368d0646d714638e Mon Sep 17 00:00:00 2001 From: flack Date: Mon, 4 Mar 2019 20:11:13 +0100 Subject: [PATCH] Make sure next/prev links are always in the same place, otherwise browsing this way is not really useable --- lib/org/openpsa/expenses/handler/index.php | 34 +++++++++---------- lib/org/openpsa/invoices/handler.php | 10 +++--- lib/org/openpsa/mypage/handler/today.php | 32 ++++++++--------- lib/org/openpsa/mypage/handler/weekreview.php | 32 ++++++++--------- lib/org/openpsa/widgets/ui.php | 10 ++++++ static/org.openpsa.widgets/ui.js | 2 +- themes/OpenPsa2/static/style.css | 30 ++++++++++------ themes/OpenPsa2/style/toolbar-bottom.php | 1 + 8 files changed, 82 insertions(+), 69 deletions(-) diff --git a/lib/org/openpsa/expenses/handler/index.php b/lib/org/openpsa/expenses/handler/index.php index 38e2125f63..855993b2bc 100644 --- a/lib/org/openpsa/expenses/handler/index.php +++ b/lib/org/openpsa/expenses/handler/index.php @@ -78,24 +78,22 @@ private function _populate_toolbar($previous_week, $next_week) { $week_start = strftime('%Y-%m-%d', $this->_request_data['week_start']); $week_end = strftime('%Y-%m-%d', $this->_request_data['week_end']); - $buttons = [ - [ - MIDCOM_TOOLBAR_URL => $this->router->generate('list_hours') . '?date[from]=' . $week_start . '&date[to]=' . $week_end, - MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('list view'), - MIDCOM_TOOLBAR_GLYPHICON => 'list', - ], - [ - MIDCOM_TOOLBAR_URL => $this->router->generate('index_timestamp', ['timestamp' => $previous_week]), - MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('previous week'), - MIDCOM_TOOLBAR_GLYPHICON => 'chevron-left', - ], - [ - MIDCOM_TOOLBAR_URL => $this->router->generate('index_timestamp', ['timestamp' => $next_week]), - MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('next week'), - MIDCOM_TOOLBAR_GLYPHICON => 'chevron-right', - ] - ]; - $this->_view_toolbar->add_items($buttons); + + $this->_view_toolbar->add_item([ + MIDCOM_TOOLBAR_URL => $this->router->generate('list_hours') . '?date[from]=' . $week_start . '&date[to]=' . $week_end, + MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('list view'), + MIDCOM_TOOLBAR_GLYPHICON => 'list', + ]); + + org_openpsa_widgets_ui::add_navigation_toolbar([[ + MIDCOM_TOOLBAR_URL => $this->router->generate('index_timestamp', ['timestamp' => $previous_week]), + MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('previous week'), + MIDCOM_TOOLBAR_GLYPHICON => 'chevron-left', + ], [ + MIDCOM_TOOLBAR_URL => $this->router->generate('index_timestamp', ['timestamp' => $next_week]), + MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('next week'), + MIDCOM_TOOLBAR_GLYPHICON => 'chevron-right', + ]]); } /** diff --git a/lib/org/openpsa/invoices/handler.php b/lib/org/openpsa/invoices/handler.php index e05d6c72e1..112aa725ea 100644 --- a/lib/org/openpsa/invoices/handler.php +++ b/lib/org/openpsa/invoices/handler.php @@ -70,6 +70,7 @@ public function prepare_toolbar($show_backlink = true) public function add_next_previous(org_openpsa_invoices_invoice_dba $object, $urlprefix) { + $items = []; if ($object->number > 1) { $mc = org_openpsa_invoices_invoice_dba::new_collector(); $mc->add_constraint('number', '<', $object->number); @@ -78,12 +79,12 @@ public function add_next_previous(org_openpsa_invoices_invoice_dba $object, $url $results = $mc->list_keys(); if (!empty($results)) { - $this->_view_toolbar->add_item([ + $items[] = [ MIDCOM_TOOLBAR_URL => $urlprefix . key($results) . '/', MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('previous'), MIDCOM_TOOLBAR_GLYPHICON => 'chevron-left', MIDCOM_TOOLBAR_ACCESSKEY => 'p', - ]); + ]; } } @@ -95,13 +96,14 @@ public function add_next_previous(org_openpsa_invoices_invoice_dba $object, $url $results = $mc->list_keys(); if (!empty($results)) { - $this->_view_toolbar->add_item([ + $items[] = [ MIDCOM_TOOLBAR_URL => $urlprefix . key($results) . '/', MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('next'), MIDCOM_TOOLBAR_GLYPHICON => 'chevron-right', MIDCOM_TOOLBAR_ACCESSKEY => 'n', - ]); + ]; } } + org_openpsa_widgets_ui::add_navigation_toolbar($items); } } diff --git a/lib/org/openpsa/mypage/handler/today.php b/lib/org/openpsa/mypage/handler/today.php index 6ce0286a77..aa8e27febb 100644 --- a/lib/org/openpsa/mypage/handler/today.php +++ b/lib/org/openpsa/mypage/handler/today.php @@ -20,24 +20,20 @@ class org_openpsa_mypage_handler_today extends midcom_baseclasses_components_han private function _populate_toolbar() { - $buttons = [ - [ - MIDCOM_TOOLBAR_URL => $this->router->generate('weekreview', ['date' => $this->_request_data['this_day']]), - MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('week review'), - MIDCOM_TOOLBAR_GLYPHICON => 'list', - ], - [ - MIDCOM_TOOLBAR_URL => $this->router->generate('day', ['date' => $this->_request_data['prev_day']]), - MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('previous'), - MIDCOM_TOOLBAR_GLYPHICON => 'chevron-left', - ], - [ - MIDCOM_TOOLBAR_URL => $this->router->generate('day', ['date' => $this->_request_data['next_day']]), - MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('next'), - MIDCOM_TOOLBAR_GLYPHICON => 'chevron-right', - ] - ]; - $this->_view_toolbar->add_items($buttons); + $this->_view_toolbar->add_item([ + MIDCOM_TOOLBAR_URL => $this->router->generate('weekreview', ['date' => $this->_request_data['this_day']]), + MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('week review'), + MIDCOM_TOOLBAR_GLYPHICON => 'list', + ]); + org_openpsa_widgets_ui::add_navigation_toolbar([[ + MIDCOM_TOOLBAR_URL => $this->router->generate('day', ['date' => $this->_request_data['prev_day']]), + MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('previous'), + MIDCOM_TOOLBAR_GLYPHICON => 'chevron-left', + ], [ + MIDCOM_TOOLBAR_URL => $this->router->generate('day', ['date' => $this->_request_data['next_day']]), + MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('next'), + MIDCOM_TOOLBAR_GLYPHICON => 'chevron-right', + ]]); } /** diff --git a/lib/org/openpsa/mypage/handler/weekreview.php b/lib/org/openpsa/mypage/handler/weekreview.php index a4a141c925..6713c8abfc 100644 --- a/lib/org/openpsa/mypage/handler/weekreview.php +++ b/lib/org/openpsa/mypage/handler/weekreview.php @@ -26,24 +26,20 @@ public function _handler_redirect() private function _populate_toolbar() { - $buttons = [ - [ - MIDCOM_TOOLBAR_URL => $this->router->generate('day', ['date' => strftime('%Y-%m-%d', $this->_request_data['week_start'])]), - MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('day review'), - MIDCOM_TOOLBAR_GLYPHICON => 'dashboard', - ], - [ - MIDCOM_TOOLBAR_URL => $this->router->generate('weekreview', ['date' => $this->_request_data['prev_week']]), - MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('previous'), - MIDCOM_TOOLBAR_GLYPHICON => 'chevron-left', - ], - [ - MIDCOM_TOOLBAR_URL => $this->router->generate('weekreview', ['date' => $this->_request_data['next_week']]), - MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('next'), - MIDCOM_TOOLBAR_GLYPHICON => 'chevron-right', - ] - ]; - $this->_view_toolbar->add_items($buttons); + $this->_view_toolbar->add_item([ + MIDCOM_TOOLBAR_URL => $this->router->generate('day', ['date' => strftime('%Y-%m-%d', $this->_request_data['week_start'])]), + MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('day review'), + MIDCOM_TOOLBAR_GLYPHICON => 'dashboard', + ]); + org_openpsa_widgets_ui::add_navigation_toolbar([[ + MIDCOM_TOOLBAR_URL => $this->router->generate('weekreview', ['date' => $this->_request_data['prev_week']]), + MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('previous'), + MIDCOM_TOOLBAR_GLYPHICON => 'chevron-left', + ], [ + MIDCOM_TOOLBAR_URL => $this->router->generate('weekreview', ['date' => $this->_request_data['next_week']]), + MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('next'), + MIDCOM_TOOLBAR_GLYPHICON => 'chevron-right', + ]]); } /** diff --git a/lib/org/openpsa/widgets/ui.php b/lib/org/openpsa/widgets/ui.php index f4d5808347..831bc1a2f4 100644 --- a/lib/org/openpsa/widgets/ui.php +++ b/lib/org/openpsa/widgets/ui.php @@ -131,4 +131,14 @@ function() JSINIT; } + + /** + * @param array $items + */ + public static function add_navigation_toolbar(array $items) + { + $toolbar = new midcom_helper_toolbar('midcom_toolbar navigation_toolbar'); + $toolbar->add_items($items); + midcom::get()->toolbars->add_toolbar('navigation', $toolbar); + } } diff --git a/static/org.openpsa.widgets/ui.js b/static/org.openpsa.widgets/ui.js index 87398f79b0..7287391a10 100644 --- a/static/org.openpsa.widgets/ui.js +++ b/static/org.openpsa.widgets/ui.js @@ -72,7 +72,7 @@ var org_openpsa_layout = { .appendTo('#org_openpsa_toolbar > ul.view_toolbar'), dropdown = container.find('ul.midcom_toolbar'), - toolbarWidth = $('#org_openpsa_toolbar').width(), + toolbarWidth = $('#org_openpsa_toolbar').width() - $('#org_openpsa_toolbar .navigation_toolbar').width(), over = false; $('#org_openpsa_toolbar > .view_toolbar > li:not(#toolbar_dropdown)').each(function() { diff --git a/themes/OpenPsa2/static/style.css b/themes/OpenPsa2/static/style.css index 057ed5b9fe..944f92ea9c 100644 --- a/themes/OpenPsa2/static/style.css +++ b/themes/OpenPsa2/static/style.css @@ -486,18 +486,26 @@ input#org_openpsa_search_query position: relative; z-index: 10; font-size: 11px; + display: flex; } #content .org_openpsa_toolbar { background: #cccec9; - background: linear-gradient(to bottom, #cccec9 0%, #bcbfbb 76%, #b1b5b4 93%, #b3b7b6 100%); + background: linear-gradient(to bottom, #cccec9 0%, #bcbfbb 82%, #b1b5b4 97%, #b3b7b6 100%); box-shadow: 0 -2px 7px rgba(0, 0, 0, 0.1) inset; } +#org_openpsa_toolbar +{ + border-top: 1px solid #eeeee7; + border-bottom: 1px solid #a2a2a3; +} + #org_openpsa_toolbar:hover { box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2); + border-bottom: 1px solid #929293; } .org_openpsa_toolbar ul.midcom_toolbar @@ -505,20 +513,17 @@ input#org_openpsa_search_query margin: 0; padding: 0; list-style-type: none; - overflow: hidden; padding: 0.2em 0.4em 0.2em 0; } -#org_openpsa_toolbar ul.midcom_toolbar +#org_openpsa_toolbar ul.navigation_toolbar { - border-bottom: 1px solid #a2a2a3; - border-top: 1px solid #eeeee7; + position: absolute; + right: 0; + z-index: 12; + padding-right: 1.2em; } -#org_openpsa_toolbar:hover ul.midcom_toolbar -{ - border-bottom: 1px solid #929293; -} .org_openpsa_toolbar ul.midcom_toolbar li { @@ -608,10 +613,15 @@ input#org_openpsa_search_query border: none; } +.org_openpsa_toolbar #toolbar_dropdown +{ + position: relative; +} + .org_openpsa_toolbar #toolbar_dropdown.expanded ul { position: absolute; - right: 0; + left: 0; top: 4px; width: auto; height: auto; diff --git a/themes/OpenPsa2/style/toolbar-bottom.php b/themes/OpenPsa2/style/toolbar-bottom.php index 44ecee81ee..59fb1f475a 100644 --- a/themes/OpenPsa2/style/toolbar-bottom.php +++ b/themes/OpenPsa2/style/toolbar-bottom.php @@ -1,3 +1,4 @@ toolbars->render_view_toolbar(); +echo midcom::get()->toolbars->_render_toolbar('navigation'); ?>