add shift calendar to angeltype view fix tab jumps

main
msquare 7 years ago
parent 928e707015
commit e54a10b816

@ -192,6 +192,11 @@ function angeltype_controller()
$shiftsFilterRenderer->enableDaySelection($days); $shiftsFilterRenderer->enableDaySelection($days);
$shiftCalendarRenderer = shiftCalendarRendererByShiftFilter($shiftsFilter); $shiftCalendarRenderer = shiftCalendarRendererByShiftFilter($shiftsFilter);
$request = request();
$tab = 0;
if($request->has('shifts_filter_day')) {
$tab = 1;
}
return [ return [
sprintf(_('Team %s'), $angeltype['name']), sprintf(_('Team %s'), $angeltype['name']),
@ -205,7 +210,8 @@ function angeltype_controller()
$user_driver_license, $user_driver_license,
$user, $user,
$shiftsFilterRenderer, $shiftsFilterRenderer,
$shiftCalendarRenderer $shiftCalendarRenderer,
$tab
) )
]; ];
} }

@ -4,15 +4,16 @@
* Renders tabs from the array. Array key is tab name, array value is tab content. * Renders tabs from the array. Array key is tab name, array value is tab content.
* *
* @param array $tabs * @param array $tabs
* @param int $selected The selected tab, default 0
* @return string HTML * @return string HTML
*/ */
function tabs($tabs) function tabs($tabs, $selected = 0)
{ {
$tab_header = []; $tab_header = [];
$tab_content = []; $tab_content = [];
foreach($tabs as $header => $content) { foreach($tabs as $header => $content) {
$class = ''; $class = '';
if(count($tab_header) == 0) { if(count($tab_header) == $selected) {
$class = 'active'; $class = 'active';
} }
$tab_header[] = '<li role="presentation" class="' . $class . '"> $tab_header[] = '<li role="presentation" class="' . $class . '">

@ -312,6 +312,9 @@ function AngelType_view_table_headers($angeltype, $supporter, $admin_angeltypes)
* @param bool $supporter * @param bool $supporter
* @param array $user_driver_license * @param array $user_driver_license
* @param array $user * @param array $user
* @param ShiftsFilterRenderer $shiftsFilterRenderer
* @param ShiftCalendarRenderer $shiftCalendarRenderer
* @param int $tab The selected tab
* @return string * @return string
*/ */
function AngelType_view( function AngelType_view(
@ -324,7 +327,8 @@ function AngelType_view(
$user_driver_license, $user_driver_license,
$user, $user,
ShiftsFilterRenderer $shiftsFilterRenderer, ShiftsFilterRenderer $shiftsFilterRenderer,
ShiftCalendarRenderer $shiftCalendarRenderer ShiftCalendarRenderer $shiftCalendarRenderer,
$tab
) { ) {
return page_with_title(sprintf(_('Team %s'), $angeltype['name']), [ return page_with_title(sprintf(_('Team %s'), $angeltype['name']), [
AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes, $supporter, $user_driver_license, $user), AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes, $supporter, $user_driver_license, $user),
@ -342,7 +346,7 @@ function AngelType_view(
$shiftsFilterRenderer, $shiftsFilterRenderer,
$shiftCalendarRenderer $shiftCalendarRenderer
) )
]) ], $tab)
]); ]);
} }

Loading…
Cancel
Save