Skip to content

Commit

Permalink
Make sure next/prev links are always in the same place, otherwise bro…
Browse files Browse the repository at this point in the history
…wsing this way is not really useable
  • Loading branch information
flack committed Mar 4, 2019
1 parent 7ca205b commit 886fb9b
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 69 deletions.
34 changes: 16 additions & 18 deletions lib/org/openpsa/expenses/handler/index.php
Expand Up @@ -78,24 +78,22 @@ private function _populate_toolbar($previous_week, $next_week)
{ {
$week_start = strftime('%Y-%m-%d', $this->_request_data['week_start']); $week_start = strftime('%Y-%m-%d', $this->_request_data['week_start']);
$week_end = strftime('%Y-%m-%d', $this->_request_data['week_end']); $week_end = strftime('%Y-%m-%d', $this->_request_data['week_end']);
$buttons = [
[ $this->_view_toolbar->add_item([
MIDCOM_TOOLBAR_URL => $this->router->generate('list_hours') . '?date[from]=' . $week_start . '&date[to]=' . $week_end, 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_LABEL => $this->_l10n->get('list view'),
MIDCOM_TOOLBAR_GLYPHICON => 'list', MIDCOM_TOOLBAR_GLYPHICON => 'list',
], ]);
[
MIDCOM_TOOLBAR_URL => $this->router->generate('index_timestamp', ['timestamp' => $previous_week]), org_openpsa_widgets_ui::add_navigation_toolbar([[
MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('previous week'), MIDCOM_TOOLBAR_URL => $this->router->generate('index_timestamp', ['timestamp' => $previous_week]),
MIDCOM_TOOLBAR_GLYPHICON => 'chevron-left', 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_URL => $this->router->generate('index_timestamp', ['timestamp' => $next_week]),
MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('next week'), MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('next week'),
MIDCOM_TOOLBAR_GLYPHICON => 'chevron-right', MIDCOM_TOOLBAR_GLYPHICON => 'chevron-right',
] ]]);
];
$this->_view_toolbar->add_items($buttons);
} }


/** /**
Expand Down
10 changes: 6 additions & 4 deletions lib/org/openpsa/invoices/handler.php
Expand Up @@ -70,6 +70,7 @@ public function prepare_toolbar($show_backlink = true)


public function add_next_previous(org_openpsa_invoices_invoice_dba $object, $urlprefix) public function add_next_previous(org_openpsa_invoices_invoice_dba $object, $urlprefix)
{ {
$items = [];
if ($object->number > 1) { if ($object->number > 1) {
$mc = org_openpsa_invoices_invoice_dba::new_collector(); $mc = org_openpsa_invoices_invoice_dba::new_collector();
$mc->add_constraint('number', '<', $object->number); $mc->add_constraint('number', '<', $object->number);
Expand All @@ -78,12 +79,12 @@ public function add_next_previous(org_openpsa_invoices_invoice_dba $object, $url
$results = $mc->list_keys(); $results = $mc->list_keys();


if (!empty($results)) { if (!empty($results)) {
$this->_view_toolbar->add_item([ $items[] = [
MIDCOM_TOOLBAR_URL => $urlprefix . key($results) . '/', MIDCOM_TOOLBAR_URL => $urlprefix . key($results) . '/',
MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('previous'), MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('previous'),
MIDCOM_TOOLBAR_GLYPHICON => 'chevron-left', MIDCOM_TOOLBAR_GLYPHICON => 'chevron-left',
MIDCOM_TOOLBAR_ACCESSKEY => 'p', MIDCOM_TOOLBAR_ACCESSKEY => 'p',
]); ];
} }
} }


Expand All @@ -95,13 +96,14 @@ public function add_next_previous(org_openpsa_invoices_invoice_dba $object, $url
$results = $mc->list_keys(); $results = $mc->list_keys();


if (!empty($results)) { if (!empty($results)) {
$this->_view_toolbar->add_item([ $items[] = [
MIDCOM_TOOLBAR_URL => $urlprefix . key($results) . '/', MIDCOM_TOOLBAR_URL => $urlprefix . key($results) . '/',
MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('next'), MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('next'),
MIDCOM_TOOLBAR_GLYPHICON => 'chevron-right', MIDCOM_TOOLBAR_GLYPHICON => 'chevron-right',
MIDCOM_TOOLBAR_ACCESSKEY => 'n', MIDCOM_TOOLBAR_ACCESSKEY => 'n',
]); ];
} }
} }
org_openpsa_widgets_ui::add_navigation_toolbar($items);
} }
} }
32 changes: 14 additions & 18 deletions lib/org/openpsa/mypage/handler/today.php
Expand Up @@ -20,24 +20,20 @@ class org_openpsa_mypage_handler_today extends midcom_baseclasses_components_han


private function _populate_toolbar() private function _populate_toolbar()
{ {
$buttons = [ $this->_view_toolbar->add_item([
[ MIDCOM_TOOLBAR_URL => $this->router->generate('weekreview', ['date' => $this->_request_data['this_day']]),
MIDCOM_TOOLBAR_URL => $this->router->generate('weekreview', ['date' => $this->_request_data['this_day']]), MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('week review'),
MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('week review'), MIDCOM_TOOLBAR_GLYPHICON => 'list',
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_URL => $this->router->generate('day', ['date' => $this->_request_data['prev_day']]), MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('previous'),
MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('previous'), MIDCOM_TOOLBAR_GLYPHICON => 'chevron-left',
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_URL => $this->router->generate('day', ['date' => $this->_request_data['next_day']]), MIDCOM_TOOLBAR_GLYPHICON => 'chevron-right',
MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('next'), ]]);
MIDCOM_TOOLBAR_GLYPHICON => 'chevron-right',
]
];
$this->_view_toolbar->add_items($buttons);
} }


/** /**
Expand Down
32 changes: 14 additions & 18 deletions lib/org/openpsa/mypage/handler/weekreview.php
Expand Up @@ -26,24 +26,20 @@ public function _handler_redirect()


private function _populate_toolbar() private function _populate_toolbar()
{ {
$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_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_LABEL => $this->_l10n->get('day review'), MIDCOM_TOOLBAR_GLYPHICON => 'dashboard',
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_URL => $this->router->generate('weekreview', ['date' => $this->_request_data['prev_week']]), MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('previous'),
MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('previous'), MIDCOM_TOOLBAR_GLYPHICON => 'chevron-left',
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_URL => $this->router->generate('weekreview', ['date' => $this->_request_data['next_week']]), MIDCOM_TOOLBAR_GLYPHICON => 'chevron-right',
MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('next'), ]]);
MIDCOM_TOOLBAR_GLYPHICON => 'chevron-right',
]
];
$this->_view_toolbar->add_items($buttons);
} }


/** /**
Expand Down
10 changes: 10 additions & 0 deletions lib/org/openpsa/widgets/ui.php
Expand Up @@ -131,4 +131,14 @@ function()
</script> </script>
JSINIT; 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);
}
} }
2 changes: 1 addition & 1 deletion static/org.openpsa.widgets/ui.js
Expand Up @@ -72,7 +72,7 @@ var org_openpsa_layout = {
.appendTo('#org_openpsa_toolbar > ul.view_toolbar'), .appendTo('#org_openpsa_toolbar > ul.view_toolbar'),


dropdown = container.find('ul.midcom_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; over = false;


$('#org_openpsa_toolbar > .view_toolbar > li:not(#toolbar_dropdown)').each(function() { $('#org_openpsa_toolbar > .view_toolbar > li:not(#toolbar_dropdown)').each(function() {
Expand Down
30 changes: 20 additions & 10 deletions themes/OpenPsa2/static/style.css
Expand Up @@ -486,39 +486,44 @@ input#org_openpsa_search_query
position: relative; position: relative;
z-index: 10; z-index: 10;
font-size: 11px; font-size: 11px;
display: flex;
} }


#content .org_openpsa_toolbar #content .org_openpsa_toolbar
{ {
background: #cccec9; 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; 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 #org_openpsa_toolbar:hover
{ {
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2); box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
border-bottom: 1px solid #929293;
} }


.org_openpsa_toolbar ul.midcom_toolbar .org_openpsa_toolbar ul.midcom_toolbar
{ {
margin: 0; margin: 0;
padding: 0; padding: 0;
list-style-type: none; list-style-type: none;
overflow: hidden;
padding: 0.2em 0.4em 0.2em 0; 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; position: absolute;
border-top: 1px solid #eeeee7; 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 .org_openpsa_toolbar ul.midcom_toolbar li
{ {
Expand Down Expand Up @@ -608,10 +613,15 @@ input#org_openpsa_search_query
border: none; border: none;
} }


.org_openpsa_toolbar #toolbar_dropdown
{
position: relative;
}

.org_openpsa_toolbar #toolbar_dropdown.expanded ul .org_openpsa_toolbar #toolbar_dropdown.expanded ul
{ {
position: absolute; position: absolute;
right: 0; left: 0;
top: 4px; top: 4px;
width: auto; width: auto;
height: auto; height: auto;
Expand Down
1 change: 1 addition & 0 deletions themes/OpenPsa2/style/toolbar-bottom.php
@@ -1,3 +1,4 @@
<?php <?php
echo midcom::get()->toolbars->render_view_toolbar(); echo midcom::get()->toolbars->render_view_toolbar();
echo midcom::get()->toolbars->_render_toolbar('navigation');
?> ?>

0 comments on commit 886fb9b

Please sign in to comment.