Fixed complete app-breakdown if no favorites are set

Signed-off-by: fnuesse <felix.nuesse@t-online.de>

Hid three-dot menu if no favorites are selected

Signed-off-by: fnuesse <felix.nuesse@t-online.de>
This commit is contained in:
fnuesse 2018-06-17 22:21:11 +02:00 committed by John Molakvoæ (skjnldsv)
parent fc4baed6e5
commit ce05cb371b
No known key found for this signature in database
GPG Key ID: 60C25B8C072916CF
2 changed files with 23 additions and 8 deletions

View File

@ -161,6 +161,7 @@ class ViewController extends Controller {
$user = $this->userSession->getUser()->getUID(); $user = $this->userSession->getUser()->getUID();
//Load QuickAccess-Defaults
$sorting=$this->config->getUserValue($user,$this->appName,'quickaccess_sorting_strategy','date'); $sorting=$this->config->getUserValue($user,$this->appName,'quickaccess_sorting_strategy','date');
$reverseListSetting=$this->config->getUserValue($user,$this->appName,'quickaccess_reverse_list','false'); $reverseListSetting=$this->config->getUserValue($user,$this->appName,'quickaccess_reverse_list','false');
if($this->config->getUserValue($user,$this->appName,'show_Quick_Access',true)){ if($this->config->getUserValue($user,$this->appName,'show_Quick_Access',true)){
@ -169,6 +170,20 @@ class ViewController extends Controller {
$expanded='false'; $expanded='false';
} }
//Get Favorite-Folder
$tagger=\OC::$server->getTagManager();
$helper= new \OCA\Files\Activity\Helper($tagger);
try {
$favElements = $helper->getFavoriteFilePaths($this->userSession->getUser()->getUID());
} catch (\RuntimeException $e) {
$favElements['folders'] = null;
}
$FavoritesFolderCount=sizeof($favElements['folders']);
\OCA\Files\App::getNavigationManager()->add( \OCA\Files\App::getNavigationManager()->add(
[ [
'id' => 'favorites', 'id' => 'favorites',
@ -178,16 +193,14 @@ class ViewController extends Controller {
'quickaccessSortingStrategy' => $sorting, 'quickaccessSortingStrategy' => $sorting,
'quickaccessSortingReverse' => $reverseListSetting, 'quickaccessSortingReverse' => $reverseListSetting,
'order' => 5, 'order' => 5,
'name' => $this->l10n->t('Favorites') 'name' => $this->l10n->t('Favorites'),
//If there are zero elements, add ul end tag directly.
'favoritescount' => $FavoritesFolderCount
] ]
); );
$tagger=\OC::$server->getTagManager();
$helper= new \OCA\Files\Activity\Helper($tagger); //Add Favorite-folder as menuentries, if there are any
$favElements = $helper->getFavoriteFilePaths($this->userSession->getUser()->getUID());
$FavoritesFolderCount=sizeof($favElements['folders']);
if($FavoritesFolderCount>0){ if($FavoritesFolderCount>0){
$NavBarPositionPosition=6; $NavBarPositionPosition=6;

View File

@ -14,7 +14,7 @@
class="nav-icon-<?php p($item['icon'] !== '' ? $item['icon'] : $item['id']) ?> svg"><?php p($item['name']);?></a> class="nav-icon-<?php p($item['icon'] !== '' ? $item['icon'] : $item['id']) ?> svg"><?php p($item['name']);?></a>
<?php if($item['id']=='favorites'){?> <?php if($item['id']=='favorites'){?>
<div class="app-navigation-entry-utils"> <div class="app-navigation-entry-utils" <?php if($item['favoritescount']==0){ ?> style="display: none"<?php } ?>>
<ul> <ul>
<li class="app-navigation-entry-utils-menu-button svg"><button id="button-<?php p($item['id']) ?>"></button></li> <li class="app-navigation-entry-utils-menu-button svg"><button id="button-<?php p($item['id']) ?>"></button></li>
</ul> </ul>
@ -48,7 +48,9 @@
</ul> </ul>
</div> </div>
<ul id="quickaccess-list" <?php if($item['enableQuickaccess']=='false'){ ?> style="display: none"<?php } ?>> <ul id="quickaccess-list" <?php if($item['enableQuickaccess']=='false'){ ?> style="display: none"<?php } ?>>
<?php /*This fixes the styleerrors if no favorites are set*/ if($item['favoritescount']==0){?></ul><?php } ?>
<?php } ?> <?php } ?>
<?php if($item['quickaccesselement']=='last'){?> <?php if($item['quickaccesselement']=='last'){?>
</ul> </ul>
<?php } ?> <?php } ?>