From e86df3b1bd871b472c127197699db721b6f09c9e Mon Sep 17 00:00:00 2001 From: fnuesse Date: Fri, 1 Jun 2018 20:29:43 +0200 Subject: [PATCH 01/75] Added FavoritesQuickaccess-Sidebar --- apps/files/lib/Controller/ViewController.php | 21 ++++++++++++++++++++ apps/files/templates/appnavigation.php | 10 ++++++++++ 2 files changed, 31 insertions(+) diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index 7cb0f112f7209..3567ae00b8768 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -175,6 +175,27 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal }); $nav->assign('navigationItems', $navItems); + $tagger=\OC::$server->getTagManager(); + + + $helper= new \OCA\Files\Activity\Helper($tagger); + $favElements = $helper->getFavoriteFilePaths($this->userSession->getUser()->getUID()); + $favItems = $favElements["items"]; + + $i=0; + foreach($favElements["folders"] as $elem){ + $item['path']=$elem; + $item['name']=substr( $elem, strrpos($elem,'/')+1, strlen($elem)); + $item['serverroot']=\OC::$WEBROOT; + $favFolder[$i]=$item; + $i++; + } + + $nav->assign('favoritesItems', $favItems); + + $nav->assign('favoritesFolders', $favFolder); + + $webdavurl = $this->urlGenerator->linkTo('', 'remote.php') . '/dav/files/' . $this->userSession->getUser()->getUID() . diff --git a/apps/files/templates/appnavigation.php b/apps/files/templates/appnavigation.php index c811ace8abe59..cfd70007c455d 100644 --- a/apps/files/templates/appnavigation.php +++ b/apps/files/templates/appnavigation.php @@ -11,6 +11,16 @@ class="nav-icon- s + + + +
  • > + +
  • + +
  • - From 245e1c0a22531a92ee62992397b8ec500cb5b9b8 Mon Sep 17 00:00:00 2001 From: fnuesse Date: Sun, 17 Jun 2018 19:53:51 +0200 Subject: [PATCH 22/75] Implemented persistence for reverse-list and sorting-strategy Signed-off-by: fnuesse --- apps/files/appinfo/routes.php | 10 ++++++++ apps/files/js/navigation.js | 12 +++++---- apps/files/lib/Controller/ApiController.php | 27 ++++++++++++++++++-- apps/files/lib/Controller/ViewController.php | 11 ++++++-- apps/files/templates/appnavigation.php | 6 ++--- 5 files changed, 54 insertions(+), 12 deletions(-) diff --git a/apps/files/appinfo/routes.php b/apps/files/appinfo/routes.php index 3273d6d97db23..7779fb1a90d32 100644 --- a/apps/files/appinfo/routes.php +++ b/apps/files/appinfo/routes.php @@ -86,6 +86,16 @@ 'url' => '/api/v1/hidequickaccess', 'verb' => 'GET', ], + [ + 'name' => 'API#setSortingStrategy', + 'url' => '/api/v1/setsortingstrategy', + 'verb' => 'GET', + ], + [ + 'name' => 'API#setReverseQuickaccess', + 'url' => '/api/v1/setreversequickaccess', + 'verb' => 'GET', + ], ] ] ); diff --git a/apps/files/js/navigation.js b/apps/files/js/navigation.js index a2e15354a9a69..761dcc34edc4e 100644 --- a/apps/files/js/navigation.js +++ b/apps/files/js/navigation.js @@ -157,20 +157,23 @@ var qaKey= 'quickaccess-list'; var itemId = $(ev.target).closest('input').attr('id'); - var list = document.getElementById(qaKey).getElementsByTagName('li'); if(itemId==='enableReverse'){ this.reverse(list); + var state = document.getElementById('enableReverse').checked; + $.get(OC.generateUrl("/apps/files/api/v1/setreversequickaccess"), {reverse: state},function(data, status){}); document.getElementById('menu-favorites').classList.toggle('open'); } if(itemId==='sortByAlphabet'){ this.sortingStrategy='alphabet'; + $.get(OC.generateUrl("/apps/files/api/v1/setsortingstrategy"), {strategy: this.sortingStrategy},function(data, status){}); this.quickSort(list, 0, list.length - 1); document.getElementById('menu-favorites').classList.toggle('open'); } if(itemId==='sortByDate'){ this.sortingStrategy='date'; + $.get(OC.generateUrl("/apps/files/api/v1/setsortingstrategy"), {strategy: this.sortingStrategy},function(data, status){}); this.quickSort(list, 0, list.length - 1); document.getElementById('menu-favorites').classList.toggle('open'); } @@ -182,13 +185,12 @@ url="/apps/files/api/v1/showquickaccess"; } - $.get(OC.generateUrl(url),function(data, status){ - }); + $.get(OC.generateUrl(url), function(data, status){}); $(qaSelector ).toggle(); document.getElementById('menu-favorites').classList.toggle('open'); } - ev.preventDefault(); + //ev.preventDefault(); }, /** @@ -248,7 +250,7 @@ */ getCompareValue: function(nodes, int){ if(this.sortingStrategy==='alphabet'){ - return nodes[int].getElementsByTagName('a')[0].innerHTML.toLowerCase(); + ; return nodes[int].getElementsByTagName('a')[0].innerHTML.toLowerCase() }else if(this.sortingStrategy==='date'){ return nodes[int].getAttribute('folderPos').toLowerCase(); } diff --git a/apps/files/lib/Controller/ApiController.php b/apps/files/lib/Controller/ApiController.php index b1af121ed6e9b..6e95d46a4e36f 100644 --- a/apps/files/lib/Controller/ApiController.php +++ b/apps/files/lib/Controller/ApiController.php @@ -45,6 +45,7 @@ use OCP\Share\IManager; use OC\Files\Node\Node; use OCP\IUserSession; +use Sabre\VObject\Property\Boolean; /** * Class ApiController @@ -270,7 +271,6 @@ public function showHiddenFiles($show) { * * @NoAdminRequired * - * @param int $value * @return Response */ public function showQuickAccess() { @@ -283,7 +283,6 @@ public function showQuickAccess() { * * @NoAdminRequired * - * @param int $value * @return Response */ public function hideQuickAccess() { @@ -291,6 +290,30 @@ public function hideQuickAccess() { return new Response(); } + /** + * quickaccess-sorting-strategy + * + * @NoAdminRequired + * + * @param string $strategy + * @return Response + */ + public function setSortingStrategy($strategy) { + $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_sporting_strategy', (String) $strategy); + return new Response(); + } + /** + * Toggle for reverse quickaccess-list + * + * @NoAdminRequired + * + * @param bool $reverse + * @return Response + */ + public function setReverseQuickaccess($reverse) { + $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_reverse_list', (int) $reverse); + return new Response(); + } } diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index 9726d6f9b4e0f..a95e2d602d0fc 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -162,18 +162,23 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal $user = $this->userSession->getUser()->getUID(); $key='show_Quick_Access'; - if($this->config->getUserValue($user,$this->appName,$key,true)){ $expanded='true'; }else{ $expanded='false'; } + + $sorting=$this->config->getUserValue($user,$this->appName,'quickaccess_sporting_strategy','notset'); + $reverseListSetting=$this->config->getUserValue($user,$this->appName,'quickaccess_reverse_list',false); + \OCA\Files\App::getNavigationManager()->add( [ 'id' => 'favorites', 'appname' => 'files', 'script' => 'simplelist.php', 'enableQuickaccess' => $expanded, + 'quickaccessSortingStrategy' => $sorting, + 'quickaccessSortingReverse' => $reverseListSetting, 'order' => 5, 'name' => $this->l10n->t('Favorites') ] @@ -188,11 +193,13 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal $FavoritesFolderCount=sizeof($favElements['folders']); if($FavoritesFolderCount>0){ - $orderPosition=6; + $orderPosition=6; $currentCount=0; foreach($favElements['folders'] as $elem){ + + $currentCount++; $SortingValue=$currentCount; if($currentCount!=$FavoritesFolderCount){ diff --git a/apps/files/templates/appnavigation.php b/apps/files/templates/appnavigation.php index 3f9400be22fa4..0e11803765a8f 100644 --- a/apps/files/templates/appnavigation.php +++ b/apps/files/templates/appnavigation.php @@ -29,19 +29,19 @@ class="nav-icon- s
  • - + checked/>
  • - + checked/>
  • - + checked/>
  • From 69f52fa28289aaf61f58fa58c6ef40656214a511 Mon Sep 17 00:00:00 2001 From: fnuesse Date: Sun, 17 Jun 2018 21:05:47 +0200 Subject: [PATCH 23/75] Implemented initial sorting for reverse-list and sorting-strategy Signed-off-by: fnuesse --- apps/files/appinfo/routes.php | 10 ++ apps/files/js/navigation.js | 99 +++++++++++++++----- apps/files/lib/Controller/ApiController.php | 39 +++++--- apps/files/lib/Controller/ViewController.php | 6 +- apps/files/templates/appnavigation.php | 4 +- 5 files changed, 119 insertions(+), 39 deletions(-) diff --git a/apps/files/appinfo/routes.php b/apps/files/appinfo/routes.php index 7779fb1a90d32..ed2373149f29e 100644 --- a/apps/files/appinfo/routes.php +++ b/apps/files/appinfo/routes.php @@ -96,6 +96,16 @@ 'url' => '/api/v1/setreversequickaccess', 'verb' => 'GET', ], + [ + 'name' => 'API#getSortingStrategy', + 'url' => '/api/v1/getsortingstrategy', + 'verb' => 'GET', + ], + [ + 'name' => 'API#getReverseQuickaccess', + 'url' => '/api/v1/getreversequickaccess', + 'verb' => 'GET', + ] ] ] ); diff --git a/apps/files/js/navigation.js b/apps/files/js/navigation.js index 761dcc34edc4e..020e67f692d6d 100644 --- a/apps/files/js/navigation.js +++ b/apps/files/js/navigation.js @@ -55,6 +55,7 @@ this._activeItem = null; this.$currentContent = null; this._setupEvents(); + this.initialSort(); }, /** @@ -159,57 +160,109 @@ var itemId = $(ev.target).closest('input').attr('id'); var list = document.getElementById(qaKey).getElementsByTagName('li'); - if(itemId==='enableReverse'){ - this.reverse(list); - var state = document.getElementById('enableReverse').checked; - $.get(OC.generateUrl("/apps/files/api/v1/setreversequickaccess"), {reverse: state},function(data, status){}); + if(itemId==='enableQuickAccess'){ + var state = document.getElementById('enableQuickAccess').checked; + $.get(OC.generateUrl("/apps/files/api/v1/showquickaccess"), {show: state}, function(data, status){ + }); + + $(qaSelector ).toggle(); document.getElementById('menu-favorites').classList.toggle('open'); } if(itemId==='sortByAlphabet'){ + //Prevents deselecting Group-Item + if(!document.getElementById('sortByAlphabet').checked){ + ev.preventDefault(); + return; + } this.sortingStrategy='alphabet'; - $.get(OC.generateUrl("/apps/files/api/v1/setsortingstrategy"), {strategy: this.sortingStrategy},function(data, status){}); - this.quickSort(list, 0, list.length - 1); + document.getElementById('sortByDate').checked=false; + $.get(OC.generateUrl("/apps/files/api/v1/setsortingstrategy"), {strategy: this.sortingStrategy}, function(data, status){}); + this.QuickSort(list, 0, list.length - 1); document.getElementById('menu-favorites').classList.toggle('open'); } if(itemId==='sortByDate'){ + //Prevents deselecting Group-Item + if(!document.getElementById('sortByDate').checked){ + ev.preventDefault(); + return; + } this.sortingStrategy='date'; - $.get(OC.generateUrl("/apps/files/api/v1/setsortingstrategy"), {strategy: this.sortingStrategy},function(data, status){}); - this.quickSort(list, 0, list.length - 1); + document.getElementById('sortByAlphabet').checked=false; + $.get(OC.generateUrl("/apps/files/api/v1/setsortingstrategy"), {strategy: this.sortingStrategy}, function(data, status){}); + this.QuickSort(list, 0, list.length - 1); + document.getElementById('menu-favorites').classList.toggle('open'); + } + if(itemId==='enableReverse'){ + this.reverse(list); + var state = document.getElementById('enableReverse').checked; + $.get(OC.generateUrl("/apps/files/api/v1/setreversequickaccess"), {reverse: state}, function(data, status){}); document.getElementById('menu-favorites').classList.toggle('open'); } - if(itemId==='enableQuickAccess'){ - var qa =$(qaSelector).is(":visible"); - var url="/apps/files/api/v1/hidequickaccess"; - if(qa){ - url="/apps/files/api/v1/showquickaccess"; - } + //ev.preventDefault(); + }, - $.get(OC.generateUrl(url), function(data, status){}); + /** + * Sort initially as setup of sidebar for QuickAccess + */ + initialSort: function() { - $(qaSelector ).toggle(); - document.getElementById('menu-favorites').classList.toggle('open'); + var domRevState=document.getElementById('enableReverse').checked; + var domSortAlphabetState=document.getElementById('sortByAlphabet').checked; + var domSortDateState=document.getElementById('sortByDate').checked; + + + var qaKey= 'quickaccess-list'; + var list = document.getElementById(qaKey).getElementsByTagName('li'); + + + if(domSortAlphabetState){ + this.sortingStrategy='alphabet'; } - //ev.preventDefault(); + + if(domSortDateState){ + this.sortingStrategy='date'; + } + + this.QuickSort(list, 0, list.length - 1); + + if(domRevState){ + this.reverse(list); + } + + /*This creates flashes the UI, which is bad userexperience. It is the cleaner way to do it, that is why i haven't deleted it yet. + var scope=this; + $.get(OC.generateUrl("/apps/files/api/v1/getsortingstrategy"), function(data, status){ + scope.sortingStrategy=data; + scope.QuickSort(list, 0, list.length - 1); + + }); + + $.get(OC.generateUrl("/apps/files/api/v1/getreversequickaccess"), function(data, status){ + if(data){ + scope.reverse(list); + } + }); + */ }, /** * Sorting-Algorithm for QuickAccess */ - quickSort: function(list, start, end) { + QuickSort: function(list, start, end) { var lastmatch; if (list.length > 1) { - lastmatch = this.partition(list, start, end); + lastmatch = this.quicksort_helper(list, start, end); if (start < lastmatch - 1) { - this.quickSort(list, start, lastmatch - 1); + this.QuickSort(list, start, lastmatch - 1); } if (lastmatch < end) { - this.quickSort(list, lastmatch, end); + this.QuickSort(list, lastmatch, end); } } @@ -218,7 +271,7 @@ /** * Sorting-Algorithm-Helper for QuickAccess */ - partition: function(list, start, end) { + quicksort_helper: function(list, start, end) { var pivot = Math.floor((end + start) / 2); var pivotelem = this.getCompareValue(list,pivot); diff --git a/apps/files/lib/Controller/ApiController.php b/apps/files/lib/Controller/ApiController.php index 6e95d46a4e36f..53a8e1b55eefb 100644 --- a/apps/files/lib/Controller/ApiController.php +++ b/apps/files/lib/Controller/ApiController.php @@ -271,36 +271,37 @@ public function showHiddenFiles($show) { * * @NoAdminRequired * + * @param bool $show + * * @return Response */ - public function showQuickAccess() { - $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'show_Quick_Access', 1); + public function showQuickAccess($show) { + $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'show_Quick_Access', (int) $show); return new Response(); } /** - * Toggle default for showing/hiding QuickAccess folder + * quickaccess-sorting-strategy * * @NoAdminRequired * + * @param string $strategy * @return Response */ - public function hideQuickAccess() { - $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'show_Quick_Access', 0); + public function setSortingStrategy($strategy) { + $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_sorting_strategy', (String) $strategy); return new Response(); - } + } /** - * quickaccess-sorting-strategy + * Get reverse-state for quickaccess-list * * @NoAdminRequired * - * @param string $strategy - * @return Response + * @return String */ - public function setSortingStrategy($strategy) { - $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_sporting_strategy', (String) $strategy); - return new Response(); + public function getSortingStrategy() { + return $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_sorting_strategy', 'date'); } /** @@ -316,4 +317,18 @@ public function setReverseQuickaccess($reverse) { return new Response(); } + /** + * Get reverse-state for quickaccess-list + * + * @NoAdminRequired + * + * @return bool + */ + public function getReverseQuickaccess() { + if($this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_reverse_list', false)){ + return true; + } + return false; + } + } diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index a95e2d602d0fc..a78cd14cd9bf2 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -168,8 +168,10 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal $expanded='false'; } - $sorting=$this->config->getUserValue($user,$this->appName,'quickaccess_sporting_strategy','notset'); - $reverseListSetting=$this->config->getUserValue($user,$this->appName,'quickaccess_reverse_list',false); + $sorting=$this->config->getUserValue($user,$this->appName,'quickaccess_sorting_strategy','date'); + $reverseListSetting=$this->config->getUserValue($user,$this->appName,'quickaccess_reverse_list','false'); + + $teststr=' exp: '.$expanded.' sort: '.$sorting.' rev: '.$reverseListSetting; \OCA\Files\App::getNavigationManager()->add( [ diff --git a/apps/files/templates/appnavigation.php b/apps/files/templates/appnavigation.php index 0e11803765a8f..68254c4f49015 100644 --- a/apps/files/templates/appnavigation.php +++ b/apps/files/templates/appnavigation.php @@ -23,7 +23,7 @@ class="nav-icon- s
    • - + checked/>
    • @@ -41,7 +41,7 @@ class="nav-icon- s
    • - checked/> + checked/>
    • From 9a073454edf4018c17c0c1efc2497b2bc085a50e Mon Sep 17 00:00:00 2001 From: fnuesse Date: Sun, 17 Jun 2018 21:09:40 +0200 Subject: [PATCH 24/75] Refactored Code Signed-off-by: fnuesse --- apps/files/js/navigation.js | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/apps/files/js/navigation.js b/apps/files/js/navigation.js index 020e67f692d6d..cf4de7d61e53f 100644 --- a/apps/files/js/navigation.js +++ b/apps/files/js/navigation.js @@ -161,13 +161,12 @@ var list = document.getElementById(qaKey).getElementsByTagName('li'); if(itemId==='enableQuickAccess'){ - var state = document.getElementById('enableQuickAccess').checked; - $.get(OC.generateUrl("/apps/files/api/v1/showquickaccess"), {show: state}, function(data, status){ + $.get(OC.generateUrl("/apps/files/api/v1/showquickaccess"), {show: document.getElementById('enableQuickAccess').checked}, function(data, status){ }); - $(qaSelector ).toggle(); document.getElementById('menu-favorites').classList.toggle('open'); } + if(itemId==='sortByAlphabet'){ //Prevents deselecting Group-Item if(!document.getElementById('sortByAlphabet').checked){ @@ -180,6 +179,7 @@ this.QuickSort(list, 0, list.length - 1); document.getElementById('menu-favorites').classList.toggle('open'); } + if(itemId==='sortByDate'){ //Prevents deselecting Group-Item if(!document.getElementById('sortByDate').checked){ @@ -192,13 +192,13 @@ this.QuickSort(list, 0, list.length - 1); document.getElementById('menu-favorites').classList.toggle('open'); } + if(itemId==='enableReverse'){ this.reverse(list); var state = document.getElementById('enableReverse').checked; $.get(OC.generateUrl("/apps/files/api/v1/setreversequickaccess"), {reverse: state}, function(data, status){}); document.getElementById('menu-favorites').classList.toggle('open'); } - //ev.preventDefault(); }, @@ -211,15 +211,12 @@ var domSortAlphabetState=document.getElementById('sortByAlphabet').checked; var domSortDateState=document.getElementById('sortByDate').checked; - var qaKey= 'quickaccess-list'; var list = document.getElementById(qaKey).getElementsByTagName('li'); - if(domSortAlphabetState){ this.sortingStrategy='alphabet'; } - if(domSortDateState){ this.sortingStrategy='date'; } @@ -250,21 +247,15 @@ * Sorting-Algorithm for QuickAccess */ QuickSort: function(list, start, end) { - var lastmatch; - - if (list.length > 1) { - + if(list.length > 1){ lastmatch = this.quicksort_helper(list, start, end); - - if (start < lastmatch - 1) { + if(start < lastmatch - 1){ this.QuickSort(list, start, lastmatch - 1); } - - if (lastmatch < end) { + if(lastmatch < end){ this.QuickSort(list, lastmatch, end); } - } }, @@ -272,22 +263,18 @@ * Sorting-Algorithm-Helper for QuickAccess */ quicksort_helper: function(list, start, end) { - var pivot = Math.floor((end + start) / 2); var pivotelem = this.getCompareValue(list,pivot); var i = start; var j = end; - while(i <= j){ while(this.getCompareValue(list,i) < pivotelem){ i++; } - while(this.getCompareValue(list,j) > pivotelem){ j--; } - if(i <= j){ this.swap(list, i, j); i++; From 916fbd7f9302f5d7ee523b7c23e605d60512d8ad Mon Sep 17 00:00:00 2001 From: fnuesse Date: Sun, 17 Jun 2018 21:15:10 +0200 Subject: [PATCH 25/75] Refactored Code Signed-off-by: fnuesse --- apps/files/templates/appnavigation.php | 74 +++++++++++--------------- 1 file changed, 30 insertions(+), 44 deletions(-) diff --git a/apps/files/templates/appnavigation.php b/apps/files/templates/appnavigation.php index 68254c4f49015..c2f15fde8013e 100644 --- a/apps/files/templates/appnavigation.php +++ b/apps/files/templates/appnavigation.php @@ -5,14 +5,14 @@ + - - - - - - - -
    • s - - t('Use this address to access your Files via WebDAV', array(link_to_docs('user-webdav'))));?> From deb20490d859f09ceca5fbab8716fcbf11f958a4 Mon Sep 17 00:00:00 2001 From: fnuesse Date: Sun, 17 Jun 2018 21:23:50 +0200 Subject: [PATCH 26/75] Refactored Code Signed-off-by: fnuesse --- apps/files/lib/Controller/ViewController.php | 100 +++++++------------ 1 file changed, 38 insertions(+), 62 deletions(-) diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index a78cd14cd9bf2..11a42fb5291db 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -159,20 +159,16 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal // FIXME: Make non static $storageInfo = $this->getStorageInfo(); - $user = $this->userSession->getUser()->getUID(); - $key='show_Quick_Access'; - if($this->config->getUserValue($user,$this->appName,$key,true)){ + + $sorting=$this->config->getUserValue($user,$this->appName,'quickaccess_sorting_strategy','date'); + $reverseListSetting=$this->config->getUserValue($user,$this->appName,'quickaccess_reverse_list','false'); + if($this->config->getUserValue($user,$this->appName,'show_Quick_Access',true)){ $expanded='true'; }else{ $expanded='false'; } - $sorting=$this->config->getUserValue($user,$this->appName,'quickaccess_sorting_strategy','date'); - $reverseListSetting=$this->config->getUserValue($user,$this->appName,'quickaccess_reverse_list','false'); - - $teststr=' exp: '.$expanded.' sort: '.$sorting.' rev: '.$reverseListSetting; - \OCA\Files\App::getNavigationManager()->add( [ 'id' => 'favorites', @@ -190,66 +186,46 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal $helper= new \OCA\Files\Activity\Helper($tagger); $favElements = $helper->getFavoriteFilePaths($this->userSession->getUser()->getUID()); - $favItems = $favElements['items']; $FavoritesFolderCount=sizeof($favElements['folders']); if($FavoritesFolderCount>0){ - - $orderPosition=6; - $currentCount=0; - foreach($favElements['folders'] as $elem){ - - - - $currentCount++; - $SortingValue=$currentCount; - if($currentCount!=$FavoritesFolderCount){ - \OCA\Files\App::getNavigationManager()->add( - [ - 'id' => substr( $elem, strrpos($elem,'/')+1, strlen($elem)), - 'href' => \OC::$WEBROOT.'/index.php/apps/files/?dir='.$elem, - 'order' => $orderPosition, - 'folderPosition' => $SortingValue, - 'name' => substr( $elem, strrpos($elem,'/')+1, strlen($elem)), - 'icon' => 'files', - 'quickaccesselement' => 'true' - ] - ); - }else{ - \OCA\Files\App::getNavigationManager()->add( - [ - 'id' => substr( $elem, strrpos($elem,'/')+1, strlen($elem)), - 'href' => \OC::$WEBROOT.'/index.php/apps/files/?dir='.$elem, - 'order' => $orderPosition, - 'folderPosition' => $SortingValue, - 'name' => substr( $elem, strrpos($elem,'/')+1, strlen($elem)), - 'icon' => 'files', - 'quickaccesselement' => 'last' - ] - ); + $NavBarPositionPosition=6; + $currentCount=0; + foreach($favElements['folders'] as $elem){ + + $id=substr( $elem, strrpos($elem,'/')+1, strlen($elem)); + $link=\OC::$WEBROOT.'/index.php/apps/files/?dir='.$elem; + + $SortingValue=++$currentCount; + if($currentCount!=$FavoritesFolderCount){ + \OCA\Files\App::getNavigationManager()->add( + [ + 'id' => $id, + 'href' => $link, + 'order' => $NavBarPositionPosition, + 'folderPosition' => $SortingValue, + 'name' => $id, + 'icon' => 'files', + 'quickaccesselement' => 'true' + ] + ); + }else{ + \OCA\Files\App::getNavigationManager()->add( + [ + 'id' => $id, + 'href' => $link, + 'order' => $NavBarPositionPosition, + 'folderPosition' => $SortingValue, + 'name' => $id, + 'icon' => 'files', + 'quickaccesselement' => 'last' + ] + ); + } + $NavBarPositionPosition++; } - - $orderPosition++; - } - } - $linkname="Collapse Folders!"; - $linkhref="#&test=1234"; - if(!$expanded){ - $linkname="Expand Folders!"; - $linkhref="#&test=56789"; - $orderPosition=6; - } - /* \OCA\Files\App::getNavigationManager()->add( - [ - 'id' => $linkname, - 'href' => $linkhref, - 'order' => $orderPosition, - 'classes' => 'app-navigation-subelement-link', - 'name' => $linkname, - ] - );*/ $navItems = \OCA\Files\App::getNavigationManager()->getAll(); From 1f579885bfbee2f021c0d69a06c152ac162889d3 Mon Sep 17 00:00:00 2001 From: fnuesse Date: Sun, 17 Jun 2018 22:21:11 +0200 Subject: [PATCH 27/75] Fixed complete app-breakdown if no favorites are set Signed-off-by: fnuesse --- apps/files/lib/Controller/ViewController.php | 25 +++++++++++++++----- apps/files/templates/appnavigation.php | 4 +++- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index 11a42fb5291db..936f09154dd0f 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -161,6 +161,7 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal $user = $this->userSession->getUser()->getUID(); + //Load QuickAccess-Defaults $sorting=$this->config->getUserValue($user,$this->appName,'quickaccess_sorting_strategy','date'); $reverseListSetting=$this->config->getUserValue($user,$this->appName,'quickaccess_reverse_list','false'); if($this->config->getUserValue($user,$this->appName,'show_Quick_Access',true)){ @@ -169,6 +170,20 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal $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( [ 'id' => 'favorites', @@ -178,16 +193,14 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal 'quickaccessSortingStrategy' => $sorting, 'quickaccessSortingReverse' => $reverseListSetting, '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); - $favElements = $helper->getFavoriteFilePaths($this->userSession->getUser()->getUID()); - $FavoritesFolderCount=sizeof($favElements['folders']); + //Add Favorite-folder as menuentries, if there are any if($FavoritesFolderCount>0){ $NavBarPositionPosition=6; diff --git a/apps/files/templates/appnavigation.php b/apps/files/templates/appnavigation.php index c2f15fde8013e..ba0d09f3915e2 100644 --- a/apps/files/templates/appnavigation.php +++ b/apps/files/templates/appnavigation.php @@ -47,8 +47,10 @@ class="nav-icon- s
    -
      style="display: none"> +
        style="display: none"> +
      +
    From 7596d029a831954054323121626f7938661c2b2a Mon Sep 17 00:00:00 2001 From: fnuesse Date: Mon, 18 Jun 2018 09:31:37 +0200 Subject: [PATCH 28/75] Hid three-dot menu if no favorites are selected Signed-off-by: fnuesse --- apps/files/templates/appnavigation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/files/templates/appnavigation.php b/apps/files/templates/appnavigation.php index ba0d09f3915e2..1488bee40d917 100644 --- a/apps/files/templates/appnavigation.php +++ b/apps/files/templates/appnavigation.php @@ -14,7 +14,7 @@ class="nav- svg"> -
    +
    style="display: none">
    From cc41b9fb84e6218c7e8032cb0d2b712907e9376b Mon Sep 17 00:00:00 2001 From: fnuesse Date: Mon, 18 Jun 2018 11:13:52 +0200 Subject: [PATCH 29/75] Added responsive folderadding Signed-off-by: fnuesse --- apps/files/js/navigation.js | 2 +- apps/files/js/tagsplugin.js | 65 ++++++++++++++++++++++++++ apps/files/templates/appnavigation.php | 2 +- 3 files changed, 67 insertions(+), 2 deletions(-) diff --git a/apps/files/js/navigation.js b/apps/files/js/navigation.js index cf4de7d61e53f..6f180a4fdb77d 100644 --- a/apps/files/js/navigation.js +++ b/apps/files/js/navigation.js @@ -290,7 +290,7 @@ */ getCompareValue: function(nodes, int){ if(this.sortingStrategy==='alphabet'){ - ; return nodes[int].getElementsByTagName('a')[0].innerHTML.toLowerCase() + return nodes[int].getElementsByTagName('a')[0].innerHTML.toLowerCase(); }else if(this.sortingStrategy==='date'){ return nodes[int].getAttribute('folderPos').toLowerCase(); } diff --git a/apps/files/js/tagsplugin.js b/apps/files/js/tagsplugin.js index b174aa7d76620..8cdc26ab3bb81 100644 --- a/apps/files/js/tagsplugin.js +++ b/apps/files/js/tagsplugin.js @@ -62,6 +62,68 @@ $favoriteMarkEl.toggleClass('permanent', state); } + /** + * Remove Item from Quickaccesslist + * + * @param {String} $appfolder folder to be removed + */ + function removeFavoriteFromList(appfolder) { + + var qaKey= 'quickaccess-list'; + var listUL = document.getElementById(qaKey); + var list = listUL.getElementsByTagName('li'); + var appname=appfolder.substring(appfolder.lastIndexOf("/")+1, appfolder.length); + + for(var i = 0; i <= list.length-1; i++) { + if(appname === list[i].getElementsByTagName('a')[0].innerHTML){ + list[i].remove(); + } + } + + if(listUL.childElementCount==0){ + var dotmenu = document.getElementById("quickaccessbutton"); + dotmenu.style.display='none'; + } + } + + /** + * Add Item to Quickaccesslist + * + * @param {String} $appfolder folder to be added + */ + function addFavoriteToList(appfolder) { + var qaKey= 'quickaccess-list'; + var listUL = document.getElementById(qaKey); + var list = listUL.getElementsByTagName('li'); + + var appname=appfolder.substring(appfolder.lastIndexOf("/")+1, appfolder.length); + + var a = document.createElement('A'); + a.setAttribute("href","/cloud/index.php/apps/files/?dir="+appfolder); + a.setAttribute("class","nav-icon-files svg"); + a.innerHTML=appname; + + var len=list.length+1; + var li = document.createElement('li'); + li.setAttribute("data-id", "/cloud/index.php/apps/files/?dir="+appfolder); + li.setAttribute("class", "nav-"+appname); + li.setAttribute("folderpos", len.toString()); + li.appendChild(a); + + + if(listUL.childElementCount<=0){ + listUL.appendChild(li); + var dotmenu = document.getElementById("quickaccessbutton"); + dotmenu.style.display=''; + }else{ + list[list.length-1].after(li); + } + + //list[list.length-1].after(li); + //document.getElementById('menu-favorites').classList.toggle('open'); + //this.QuickSort(list, 0, list.length - 1); + } + OCA.Files = OCA.Files || {}; /** @@ -121,6 +183,7 @@ var fileInfo = context.fileList.files[$file.index()]; var dir = context.dir || context.fileList.getCurrentDirectory(); var tags = $file.attr('data-tags'); + if (_.isUndefined(tags)) { tags = ''; } @@ -130,8 +193,10 @@ if (isFavorite) { // remove tag from list tags = _.without(tags, OC.TAG_FAVORITE); + removeFavoriteFromList(dir + '/' + fileName); } else { tags.push(OC.TAG_FAVORITE); + addFavoriteToList(dir + '/' + fileName); } // pre-toggle the star diff --git a/apps/files/templates/appnavigation.php b/apps/files/templates/appnavigation.php index 1488bee40d917..dada66a3d3a50 100644 --- a/apps/files/templates/appnavigation.php +++ b/apps/files/templates/appnavigation.php @@ -14,7 +14,7 @@ class="nav- svg"> -
    style="display: none"> +
    style="display: none">
    From 3be815dc9e02c85ee321344b9e3355733cba3b04 Mon Sep 17 00:00:00 2001 From: fnuesse Date: Mon, 18 Jun 2018 12:07:47 +0200 Subject: [PATCH 30/75] Added collapsible to quickaccesslist Signed-off-by: fnuesse --- apps/files/js/navigation.js | 14 ++++++++++++-- apps/files/lib/Controller/ViewController.php | 1 + apps/files/templates/appnavigation.php | 8 +++++--- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/apps/files/js/navigation.js b/apps/files/js/navigation.js index 6f180a4fdb77d..04c9143581cbd 100644 --- a/apps/files/js/navigation.js +++ b/apps/files/js/navigation.js @@ -143,6 +143,16 @@ _onClickMenuButton: function(ev) { var $target = $(ev.target); var itemId = $target.closest('button').attr('id'); + var qaSelector= '#quickaccess-list'; + + if(itemId==='button-collapseQuickAccess'){ + $.get(OC.generateUrl("/apps/files/api/v1/showquickaccess"), {show: document.getElementById('enableQuickAccess').checked}, function(data, status){ + }); + $("#quickaccess-list" ).toggle('open'); + var dotmenu = document.getElementById("quickaccess-list"); + dotmenu.style.display=''; + } + if(itemId==='button-favorites'){ document.getElementById('menu-favorites').classList.toggle('open'); } @@ -160,10 +170,10 @@ var itemId = $(ev.target).closest('input').attr('id'); var list = document.getElementById(qaKey).getElementsByTagName('li'); - if(itemId==='enableQuickAccess'){ + if(itemId==='enableQuickAccess' ){ $.get(OC.generateUrl("/apps/files/api/v1/showquickaccess"), {show: document.getElementById('enableQuickAccess').checked}, function(data, status){ }); - $(qaSelector ).toggle(); + $(qaSelector).toggle('open'); document.getElementById('menu-favorites').classList.toggle('open'); } diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index 936f09154dd0f..c218063f979bd 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -189,6 +189,7 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal 'id' => 'favorites', 'appname' => 'files', 'script' => 'simplelist.php', + 'classes' => 'collapsible', 'enableQuickaccess' => $expanded, 'quickaccessSortingStrategy' => $sorting, 'quickaccessSortingReverse' => $reverseListSetting, diff --git a/apps/files/templates/appnavigation.php b/apps/files/templates/appnavigation.php index dada66a3d3a50..67cd02d45bc1a 100644 --- a/apps/files/templates/appnavigation.php +++ b/apps/files/templates/appnavigation.php @@ -7,13 +7,15 @@ ?> From 4e16832cd4076c25621b6f48222369d659e42949 Mon Sep 17 00:00:00 2001 From: fnuesse Date: Wed, 20 Jun 2018 22:28:05 +0200 Subject: [PATCH 37/75] Fixed Codestyle (Renamed Variables) Signed-off-by: fnuesse --- apps/files/lib/Controller/ViewController.php | 37 ++++++++++---------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index 2a74b00383073..787216e36a7ca 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -165,15 +165,14 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal $sorting = $this->config->getUserValue($user, $this->appName, 'quickaccess_sorting_strategy', 'date'); $reverseListSetting = $this->config->getUserValue($user, $this->appName, 'quickaccess_reverse_list', 'false'); if ($this->config->getUserValue($user, $this->appName, 'show_Quick_Access', true)) { - $expanded = 'true'; + $quickAccessExpandedState = 'true'; } else { - $expanded = 'false'; + $quickAccessExpandedState = 'false'; } //Get Favorite-Folder $tagger = \OC::$server->getTagManager(); - $helper = new \OCA\Files\Activity\Helper($tagger); try { @@ -182,11 +181,11 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal $favElements['folders'] = null; } - $FavoritesFolderCount = sizeof($favElements['folders']); + $favoritesFolderCount = sizeof($favElements['folders']); - $collapsClasses = ''; - if ($FavoritesFolderCount > 0) { - $collapsClasses = 'collapsible'; + $collapseClasses = ''; + if ($favoritesFolderCount > 0) { + $collapseClasses = 'collapsible'; } \OCA\Files\App::getNavigationManager()->add( @@ -194,36 +193,36 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal 'id' => 'favorites', 'appname' => 'files', 'script' => 'simplelist.php', - 'classes' => $collapsClasses, - 'enableQuickaccess' => $expanded, + 'classes' => $collapseClasses, + 'enableQuickaccess' => $quickAccessExpandedState, 'quickaccessSortingStrategy' => $sorting, 'quickaccessSortingReverse' => $reverseListSetting, 'order' => 5, 'name' => $this->l10n->t('Favorites'), //If there are zero elements, add ul end tag directly. - 'favoritescount' => $FavoritesFolderCount + 'favoritescount' => $favoritesFolderCount ] ); //Add Favorite-folder as menuentries, if there are any - if ($FavoritesFolderCount > 0) { + if ($favoritesFolderCount > 0) { - $NavBarPositionPosition = 6; + $navBarPositionPosition = 6; $currentCount = 0; foreach ($favElements['folders'] as $elem) { $id = substr($elem, strrpos($elem, '/') + 1, strlen($elem)); $link = $this->urlGenerator->linkToRouteAbsolute('files.view.index', ['dir' => $elem]); - $SortingValue = ++$currentCount; - if ($currentCount != $FavoritesFolderCount) { + $sortingValue = ++$currentCount; + if ($currentCount != $favoritesFolderCount) { \OCA\Files\App::getNavigationManager()->add( [ 'id' => $id, 'href' => $link, - 'order' => $NavBarPositionPosition, - 'folderPosition' => $SortingValue, + 'order' => $navBarPositionPosition, + 'folderPosition' => $sortingValue, 'name' => $id, 'icon' => 'files', 'quickaccesselement' => 'true' @@ -234,15 +233,15 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal [ 'id' => $id, 'href' => $link, - 'order' => $NavBarPositionPosition, - 'folderPosition' => $SortingValue, + 'order' => $navBarPositionPosition, + 'folderPosition' => $sortingValue, 'name' => $id, 'icon' => 'files', 'quickaccesselement' => 'last' ] ); } - $NavBarPositionPosition++; + $navBarPositionPosition++; } } From 38f5c52809b4f7a107da29a18e0989395c39ffbf Mon Sep 17 00:00:00 2001 From: fnuesse Date: Wed, 20 Jun 2018 22:33:21 +0200 Subject: [PATCH 38/75] Added copyright notice Signed-off-by: fnuesse --- apps/files/lib/Controller/ViewController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index 787216e36a7ca..8afec0be9093e 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -8,6 +8,7 @@ * @author Roeland Jago Douma * @author Thomas Müller * @author Vincent Petry + * @author Felix Nüsse Petry * * @license AGPL-3.0 * From 52c501e15cd846c6bd7ec23fedd1e7af3b9310a0 Mon Sep 17 00:00:00 2001 From: fnuesse Date: Wed, 20 Jun 2018 22:40:10 +0200 Subject: [PATCH 39/75] Removed old code Signed-off-by: fnuesse --- apps/files/js/navigation.js | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/apps/files/js/navigation.js b/apps/files/js/navigation.js index db39cac987e18..58038f8069d8a 100644 --- a/apps/files/js/navigation.js +++ b/apps/files/js/navigation.js @@ -238,21 +238,6 @@ if(domRevState){ this.reverse(list); } - - /*This creates flashes the UI, which is bad userexperience. It is the cleaner way to do it, that is why i haven't deleted it yet. - var scope=this; - $.get(OC.generateUrl("/apps/files/api/v1/getsortingstrategy"), function(data, status){ - scope.sortingStrategy=data; - scope.QuickSort(list, 0, list.length - 1); - - }); - - $.get(OC.generateUrl("/apps/files/api/v1/getreversequickaccess"), function(data, status){ - if(data){ - scope.reverse(list); - } - }); - */ }, /** From adc990736063b59d0bce6aee15a6fc0d35a13e7a Mon Sep 17 00:00:00 2001 From: fnuesse Date: Wed, 20 Jun 2018 22:54:28 +0200 Subject: [PATCH 40/75] Removed duplicate collapse-button and changed api-endpoints Signed-off-by: fnuesse --- apps/files/appinfo/routes.php | 15 +++++---------- apps/files/js/navigation.js | 17 +++++++++-------- apps/files/js/tagsplugin.js | 4 ---- apps/files/templates/appnavigation.php | 12 +++--------- 4 files changed, 17 insertions(+), 31 deletions(-) diff --git a/apps/files/appinfo/routes.php b/apps/files/appinfo/routes.php index ed2373149f29e..d8942e6489cb9 100644 --- a/apps/files/appinfo/routes.php +++ b/apps/files/appinfo/routes.php @@ -78,32 +78,27 @@ ], [ 'name' => 'API#showQuickAccess', - 'url' => '/api/v1/showquickaccess', - 'verb' => 'GET', - ], - [ - 'name' => 'API#hideQuickAccess', - 'url' => '/api/v1/hidequickaccess', + 'url' => '/api/v1/quickaccess/show', 'verb' => 'GET', ], [ 'name' => 'API#setSortingStrategy', - 'url' => '/api/v1/setsortingstrategy', + 'url' => '/api/v1/quickaccess/setsortingstrategy', 'verb' => 'GET', ], [ 'name' => 'API#setReverseQuickaccess', - 'url' => '/api/v1/setreversequickaccess', + 'url' => '/api/v1/quickaccess/setreversequickaccess', 'verb' => 'GET', ], [ 'name' => 'API#getSortingStrategy', - 'url' => '/api/v1/getsortingstrategy', + 'url' => '/api/v1/quickaccess/getsortingstrategy', 'verb' => 'GET', ], [ 'name' => 'API#getReverseQuickaccess', - 'url' => '/api/v1/getreversequickaccess', + 'url' => '/api/v1/quickaccess/getreversequickaccess', 'verb' => 'GET', ] ] diff --git a/apps/files/js/navigation.js b/apps/files/js/navigation.js index 58038f8069d8a..52bd63a09f1b2 100644 --- a/apps/files/js/navigation.js +++ b/apps/files/js/navigation.js @@ -144,14 +144,15 @@ var $target = $(ev.target); var itemId = $target.closest('button').attr('id'); var qaSelector= '#quickaccess-list'; + var collapsibleToggle=$("#favorites-toggle"); if(itemId==='button-collapseQuickAccess'){ - - document.getElementById('enableQuickAccess').checked=!document.getElementById('enableQuickAccess').checked; - $.get(OC.generateUrl("/apps/files/api/v1/showquickaccess"), {show: document.getElementById('enableQuickAccess').checked}, function(data, status){ + $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/show"), + {show: !collapsibleToggle.hasClass('open')}, + function(data, status){ }); - $("#favorites-toggle" ).toggleClass('open'); + collapsibleToggle.toggleClass('open'); } @@ -173,7 +174,7 @@ var list = document.getElementById(qaKey).getElementsByTagName('li'); if(itemId==='enableQuickAccess' ){ - $.get(OC.generateUrl("/apps/files/api/v1/showquickaccess"), {show: document.getElementById('enableQuickAccess').checked}, function(data, status){ + $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/show"), {show: document.getElementById('enableQuickAccess').checked}, function(data, status){ }); $("#favorites-toggle" ).toggleClass('open'); document.getElementById('menu-favorites').classList.toggle('open'); @@ -187,7 +188,7 @@ } this.sortingStrategy='alphabet'; document.getElementById('sortByDate').checked=false; - $.get(OC.generateUrl("/apps/files/api/v1/setsortingstrategy"), {strategy: this.sortingStrategy}, function(data, status){}); + $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/setsortingstrategy"), {strategy: this.sortingStrategy}, function(data, status){}); this.QuickSort(list, 0, list.length - 1); document.getElementById('menu-favorites').classList.toggle('open'); } @@ -200,7 +201,7 @@ } this.sortingStrategy='date'; document.getElementById('sortByAlphabet').checked=false; - $.get(OC.generateUrl("/apps/files/api/v1/setsortingstrategy"), {strategy: this.sortingStrategy}, function(data, status){}); + $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/setsortingstrategy"), {strategy: this.sortingStrategy}, function(data, status){}); this.QuickSort(list, 0, list.length - 1); document.getElementById('menu-favorites').classList.toggle('open'); } @@ -208,7 +209,7 @@ if(itemId==='enableReverse'){ this.reverse(list); var state = document.getElementById('enableReverse').checked; - $.get(OC.generateUrl("/apps/files/api/v1/setreversequickaccess"), {reverse: state}, function(data, status){}); + $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/setreversequickaccess"), {reverse: state}, function(data, status){}); document.getElementById('menu-favorites').classList.toggle('open'); } //ev.preventDefault(); diff --git a/apps/files/js/tagsplugin.js b/apps/files/js/tagsplugin.js index ce35f8bcdfd20..72ac8d3bf1db6 100644 --- a/apps/files/js/tagsplugin.js +++ b/apps/files/js/tagsplugin.js @@ -128,10 +128,6 @@ }else{ list[list.length-1].after(li); } - - //list[list.length-1].after(li); - //document.getElementById('menu-favorites').classList.toggle('open'); - //this.QuickSort(list, 0, list.length - 1); } OCA.Files = OCA.Files || {}; diff --git a/apps/files/templates/appnavigation.php b/apps/files/templates/appnavigation.php index 7bf92995de6c3..8cbefdb4619aa 100644 --- a/apps/files/templates/appnavigation.php +++ b/apps/files/templates/appnavigation.php @@ -28,25 +28,19 @@ class="nav-icon- s
    • - checked/> - - -
    • -
    • - - checked/> + checked/>
    • - checked/> + checked/>
    • - checked/> + checked/>
    • From 77ad5b5749428ed6399e7ad66e2cffcf55e8b688 Mon Sep 17 00:00:00 2001 From: fnuesse Date: Wed, 20 Jun 2018 22:55:04 +0200 Subject: [PATCH 41/75] Removed app-navigation-caption from apps.scss Signed-off-by: fnuesse --- core/css/apps.scss | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/core/css/apps.scss b/core/css/apps.scss index a4c62c991242f..b15e8551c8579 100644 --- a/core/css/apps.scss +++ b/core/css/apps.scss @@ -561,24 +561,6 @@ kbd { .app-navigation-entry-menu ul { list-style-type: none; } - - .app-navigation-caption { - font-weight: bold; - line-height: 44px; - white-space: nowrap; - text-overflow: ellipsis; - float: left; - margin-left:10px; - margin-top:10px; - margin-bottom:10px; - //Make the Link in the spacer not selectable and prevent mouseevents - -moz-user-select: -moz-none; - -khtml-user-select: none; - -webkit-user-select: none; - -o-user-select: none; - user-select: none; - pointer-events:none; - } } /* APP-CONTENT ---------------------------------------------------------------*/ From 47a862c3b702cf73151be9102ad72016b0cb44ff Mon Sep 17 00:00:00 2001 From: fnuesse Date: Wed, 20 Jun 2018 22:57:13 +0200 Subject: [PATCH 42/75] Changed api-endpoints Signed-off-by: fnuesse --- apps/files/appinfo/routes.php | 8 ++++---- apps/files/js/navigation.js | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/files/appinfo/routes.php b/apps/files/appinfo/routes.php index d8942e6489cb9..338182657d8f9 100644 --- a/apps/files/appinfo/routes.php +++ b/apps/files/appinfo/routes.php @@ -83,22 +83,22 @@ ], [ 'name' => 'API#setSortingStrategy', - 'url' => '/api/v1/quickaccess/setsortingstrategy', + 'url' => '/api/v1/quickaccess/setSortingStrategy', 'verb' => 'GET', ], [ 'name' => 'API#setReverseQuickaccess', - 'url' => '/api/v1/quickaccess/setreversequickaccess', + 'url' => '/api/v1/quickaccess/setReverseList', 'verb' => 'GET', ], [ 'name' => 'API#getSortingStrategy', - 'url' => '/api/v1/quickaccess/getsortingstrategy', + 'url' => '/api/v1/quickaccess/getSortingStrategy', 'verb' => 'GET', ], [ 'name' => 'API#getReverseQuickaccess', - 'url' => '/api/v1/quickaccess/getreversequickaccess', + 'url' => '/api/v1/quickaccess/getReverseList', 'verb' => 'GET', ] ] diff --git a/apps/files/js/navigation.js b/apps/files/js/navigation.js index 52bd63a09f1b2..aeb3476983989 100644 --- a/apps/files/js/navigation.js +++ b/apps/files/js/navigation.js @@ -188,7 +188,7 @@ } this.sortingStrategy='alphabet'; document.getElementById('sortByDate').checked=false; - $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/setsortingstrategy"), {strategy: this.sortingStrategy}, function(data, status){}); + $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/setSortingStrategy"), {strategy: this.sortingStrategy}, function(data, status){}); this.QuickSort(list, 0, list.length - 1); document.getElementById('menu-favorites').classList.toggle('open'); } @@ -201,7 +201,7 @@ } this.sortingStrategy='date'; document.getElementById('sortByAlphabet').checked=false; - $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/setsortingstrategy"), {strategy: this.sortingStrategy}, function(data, status){}); + $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/setSortingStrategy"), {strategy: this.sortingStrategy}, function(data, status){}); this.QuickSort(list, 0, list.length - 1); document.getElementById('menu-favorites').classList.toggle('open'); } @@ -209,7 +209,7 @@ if(itemId==='enableReverse'){ this.reverse(list); var state = document.getElementById('enableReverse').checked; - $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/setreversequickaccess"), {reverse: state}, function(data, status){}); + $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/setReverseList"), {reverse: state}, function(data, status){}); document.getElementById('menu-favorites').classList.toggle('open'); } //ev.preventDefault(); From b346a57203956166a81b854d4937004daebeba05 Mon Sep 17 00:00:00 2001 From: fnuesse Date: Wed, 20 Jun 2018 23:06:36 +0200 Subject: [PATCH 43/75] Fixed Codestyle (.js) Signed-off-by: fnuesse --- apps/files/js/navigation.js | 172 +++++++++++++++++++----------------- apps/files/js/tagsplugin.js | 68 +++++++------- 2 files changed, 126 insertions(+), 114 deletions(-) diff --git a/apps/files/js/navigation.js b/apps/files/js/navigation.js index aeb3476983989..c5269212a721d 100644 --- a/apps/files/js/navigation.js +++ b/apps/files/js/navigation.js @@ -13,7 +13,7 @@ * */ -(function() { +(function () { /** * @class OCA.Files.Navigation @@ -21,7 +21,7 @@ * * @param $el element containing the navigation */ - var Navigation = function($el) { + var Navigation = function ($el) { this.initialize($el); }; @@ -50,7 +50,7 @@ * @private * @param $el element containing the navigation */ - initialize: function($el) { + initialize: function ($el) { this.$el = $el; this._activeItem = null; this.$currentContent = null; @@ -61,7 +61,7 @@ /** * Setup UI events */ - _setupEvents: function() { + _setupEvents: function () { this.$el.on('click', 'li a', _.bind(this._onClickItem, this)) this.$el.on('click', 'li button', _.bind(this._onClickMenuButton, this)); this.$el.on('click', 'li input', _.bind(this._onClickMenuItem, this)); @@ -72,16 +72,16 @@ * * @return app container */ - getActiveContainer: function() { + getActiveContainer: function () { return this.$currentContent; }, /** * Returns the currently active item - * + * * @return item ID */ - getActiveItem: function() { + getActiveItem: function () { return this._activeItem; }, @@ -92,12 +92,15 @@ * @param string itemId id of the navigation item to select * @param array options "silent" to not trigger event */ - setActiveItem: function(itemId, options) { + setActiveItem: function (itemId, options) { var oldItemId = this._activeItem; if (itemId === this._activeItem) { if (!options || !options.silent) { this.$el.trigger( - new $.Event('itemChanged', {itemId: itemId, previousItemId: oldItemId}) + new $.Event('itemChanged', { + itemId: itemId, + previousItemId: oldItemId + }) ); } return; @@ -114,7 +117,10 @@ if (!options || !options.silent) { this.$currentContent.trigger(jQuery.Event('show')); this.$el.trigger( - new $.Event('itemChanged', {itemId: itemId, previousItemId: oldItemId}) + new $.Event('itemChanged', { + itemId: itemId, + previousItemId: oldItemId + }) ); } }, @@ -122,14 +128,14 @@ /** * Returns whether a given item exists */ - itemExists: function(itemId) { + itemExists: function (itemId) { return this.$el.find('li[data-id=' + itemId + ']').length; }, /** * Event handler for when clicking on an item. */ - _onClickItem: function(ev) { + _onClickItem: function (ev) { var $target = $(ev.target); var itemId = $target.closest('li').attr('data-id'); if (!_.isUndefined(itemId)) { @@ -137,26 +143,24 @@ } ev.preventDefault(); }, + /** * Event handler for when clicking on an three-dot-menu. */ - _onClickMenuButton: function(ev) { + _onClickMenuButton: function (ev) { var $target = $(ev.target); var itemId = $target.closest('button').attr('id'); - var qaSelector= '#quickaccess-list'; - var collapsibleToggle=$("#favorites-toggle"); + var collapsibleToggle = $("#favorites-toggle"); - if(itemId==='button-collapseQuickAccess'){ + if (itemId === 'button-collapseQuickAccess') { $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/show"), {show: !collapsibleToggle.hasClass('open')}, - function(data, status){ - }); - + function (data, status) { + }); collapsibleToggle.toggleClass('open'); - } - if(itemId==='button-favorites'){ + if (itemId === 'button-favorites') { document.getElementById('menu-favorites').classList.toggle('open'); } ev.preventDefault(); @@ -165,78 +169,88 @@ /** * Event handler for when clicking on a menuitem. */ - _onClickMenuItem: function(ev) { - - var qaSelector= '#quickaccess-list'; - var qaKey= 'quickaccess-list'; - + _onClickMenuItem: function (ev) { + var quickAccessKey = 'quickaccess-list'; var itemId = $(ev.target).closest('input').attr('id'); - var list = document.getElementById(qaKey).getElementsByTagName('li'); + var list = document.getElementById(quickAccessKey).getElementsByTagName('li'); - if(itemId==='enableQuickAccess' ){ - $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/show"), {show: document.getElementById('enableQuickAccess').checked}, function(data, status){ + if (itemId === 'enableQuickAccess') { + $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/show"), + {show: document.getElementById('enableQuickAccess').checked}, + function (data, status) { }); - $("#favorites-toggle" ).toggleClass('open'); + $("#favorites-toggle").toggleClass('open'); document.getElementById('menu-favorites').classList.toggle('open'); } - if(itemId==='sortByAlphabet'){ + if (itemId === 'sortByAlphabet') { //Prevents deselecting Group-Item - if(!document.getElementById('sortByAlphabet').checked){ + if (!document.getElementById('sortByAlphabet').checked) { ev.preventDefault(); return; } - this.sortingStrategy='alphabet'; - document.getElementById('sortByDate').checked=false; - $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/setSortingStrategy"), {strategy: this.sortingStrategy}, function(data, status){}); + + this.sortingStrategy = 'alphabet'; + document.getElementById('sortByDate').checked = false; + $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/setSortingStrategy"), + {strategy: this.sortingStrategy}, + function (data, status) { + }); + this.QuickSort(list, 0, list.length - 1); document.getElementById('menu-favorites').classList.toggle('open'); } - if(itemId==='sortByDate'){ + if (itemId === 'sortByDate') { //Prevents deselecting Group-Item - if(!document.getElementById('sortByDate').checked){ + if (!document.getElementById('sortByDate').checked) { ev.preventDefault(); return; } - this.sortingStrategy='date'; - document.getElementById('sortByAlphabet').checked=false; - $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/setSortingStrategy"), {strategy: this.sortingStrategy}, function(data, status){}); + + this.sortingStrategy = 'date'; + document.getElementById('sortByAlphabet').checked = false; + $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/setSortingStrategy"), + {strategy: this.sortingStrategy}, + function (data, status) { + }); + this.QuickSort(list, 0, list.length - 1); document.getElementById('menu-favorites').classList.toggle('open'); } - if(itemId==='enableReverse'){ + if (itemId === 'enableReverse') { this.reverse(list); var state = document.getElementById('enableReverse').checked; - $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/setReverseList"), {reverse: state}, function(data, status){}); + $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/setReverseList"), + {reverse: state}, + function (data, status) { + }); document.getElementById('menu-favorites').classList.toggle('open'); } - //ev.preventDefault(); }, /** * Sort initially as setup of sidebar for QuickAccess */ - initialSort: function() { - - var domRevState=document.getElementById('enableReverse').checked; - var domSortAlphabetState=document.getElementById('sortByAlphabet').checked; - var domSortDateState=document.getElementById('sortByDate').checked; + initialSort: function () { + var domRevState = document.getElementById('enableReverse').checked; + var domSortAlphabetState = document.getElementById('sortByAlphabet').checked; + var domSortDateState = document.getElementById('sortByDate').checked; - var qaKey= 'quickaccess-list'; - var list = document.getElementById(qaKey).getElementsByTagName('li'); + var quickAccesKey = 'quickaccess-list'; + var list = document.getElementById(quickAccesKey).getElementsByTagName('li'); - if(domSortAlphabetState){ - this.sortingStrategy='alphabet'; + if (domSortAlphabetState) { + this.sortingStrategy = 'alphabet'; } - if(domSortDateState){ - this.sortingStrategy='date'; + if (domSortDateState) { + this.sortingStrategy = 'date'; } this.QuickSort(list, 0, list.length - 1); - if(domRevState){ + if (domRevState) { this.reverse(list); } }, @@ -244,15 +258,15 @@ /** * Sorting-Algorithm for QuickAccess */ - QuickSort: function(list, start, end) { - var lastmatch; - if(list.length > 1){ - lastmatch = this.quicksort_helper(list, start, end); - if(start < lastmatch - 1){ - this.QuickSort(list, start, lastmatch - 1); + QuickSort: function (list, start, end) { + var lastMatch; + if (list.length > 1) { + lastMatch = this.quicksort_helper(list, start, end); + if (start < lastMatch - 1) { + this.QuickSort(list, start, lastMatch - 1); } - if(lastmatch < end){ - this.QuickSort(list, lastmatch, end); + if (lastMatch < end) { + this.QuickSort(list, lastMatch, end); } } }, @@ -260,20 +274,20 @@ /** * Sorting-Algorithm-Helper for QuickAccess */ - quicksort_helper: function(list, start, end) { + quicksort_helper: function (list, start, end) { var pivot = Math.floor((end + start) / 2); - var pivotelem = this.getCompareValue(list,pivot); - var i = start; - var j = end; + var pivotElement = this.getCompareValue(list, pivot); + var i = start; + var j = end; - while(i <= j){ - while(this.getCompareValue(list,i) < pivotelem){ + while (i <= j) { + while (this.getCompareValue(list, i) < pivotElement) { i++; } - while(this.getCompareValue(list,j) > pivotelem){ + while (this.getCompareValue(list, j) > pivotElement) { j--; } - if(i <= j){ + if (i <= j) { this.swap(list, i, j); i++; j--; @@ -286,10 +300,10 @@ * Sorting-Algorithm-Helper for QuickAccess * This method allows easy access to the element which is sorted by. */ - getCompareValue: function(nodes, int){ - if(this.sortingStrategy==='alphabet'){ + getCompareValue: function (nodes, int) { + if (this.sortingStrategy === 'alphabet') { return nodes[int].getElementsByTagName('a')[0].innerHTML.toLowerCase(); - }else if(this.sortingStrategy==='date'){ + } else if (this.sortingStrategy === 'date') { return nodes[int].getAttribute('folderPos').toLowerCase(); } return nodes[int].getElementsByTagName('a')[0].innerHTML.toLowerCase(); @@ -299,7 +313,7 @@ * Sorting-Algorithm-Helper for QuickAccess * This method allows easy swapping of elements. */ - swap: function(list, j, i){ + swap: function (list, j, i) { list[i].before(list[j]); list[j].before(list[i]); }, @@ -307,10 +321,10 @@ /** * Reverse QuickAccess-List */ - reverse: function(list){ - var len=list.length-1; - for(var i = 0; i < len/2; i++) { - this.swap(list, i, len-i); + reverse: function (list) { + var len = list.length - 1; + for (var i = 0; i < len / 2; i++) { + this.swap(list, i, len - i); } } diff --git a/apps/files/js/tagsplugin.js b/apps/files/js/tagsplugin.js index 72ac8d3bf1db6..1c5a4da8538fa 100644 --- a/apps/files/js/tagsplugin.js +++ b/apps/files/js/tagsplugin.js @@ -65,68 +65,66 @@ /** * Remove Item from Quickaccesslist * - * @param {String} $appfolder folder to be removed + * @param {String} appfolder folder to be removed */ function removeFavoriteFromList(appfolder) { - var qaKey= 'quickaccess-list'; - var listUL = document.getElementById(qaKey); - var list = listUL.getElementsByTagName('li'); - var appname=appfolder.substring(appfolder.lastIndexOf("/")+1, appfolder.length); + var quickAccessKey= 'quickaccess-list'; + var listULElements = document.getElementById(quickAccessKey); + var listLIElements = listULElements.getElementsByTagName('li'); + var appName=appfolder.substring(appfolder.lastIndexOf("/")+1, appfolder.length); - for(var i = 0; i <= list.length-1; i++) { - if(appname === list[i].getElementsByTagName('a')[0].innerHTML){ - list[i].remove(); + for (var i = 0; i <= listLIElements.length-1; i++) { + if (appName === listLIElements[i].getElementsByTagName('a')[0].innerHTML) { + listLIElements[i].remove(); } } - if(listUL.childElementCount==0){ - var dotmenu = document.getElementById("quickaccessbutton"); - dotmenu.style.display='none'; - + if (listULElements.childElementCount === 0) { + var dotMenu = document.getElementById("quickaccessbutton"); + dotMenu.style.display='none'; var collapsibleButton = document.getElementById("button-collapseQuickAccess"); collapsibleButton.style.display='none'; - $("#favorites-toggle" ).removeClass('collapsible'); + $("#favorites-toggle").removeClass('collapsible'); } } /** * Add Item to Quickaccesslist * - * @param {String} $appfolder folder to be added + * @param {String} appfolder folder to be added */ function addFavoriteToList(appfolder) { - var qaKey= 'quickaccess-list'; - var listUL = document.getElementById(qaKey); - var list = listUL.getElementsByTagName('li'); - - var appname=appfolder.substring(appfolder.lastIndexOf("/")+1, appfolder.length); + var quickAccessKey= 'quickaccess-list'; + var listULElements = document.getElementById(quickAccessKey); + var listLIElements = listULElements.getElementsByTagName('li'); - var a = document.createElement('A'); - a.setAttribute("href","/cloud/index.php/apps/files/?dir="+appfolder); - a.setAttribute("class","nav-icon-files svg"); - a.innerHTML=appname; + var appName=appfolder.substring(appfolder.lastIndexOf("/")+1, appfolder.length); - var len=list.length+1; - var li = document.createElement('li'); - li.setAttribute("data-id", "/cloud/index.php/apps/files/?dir="+appfolder); - li.setAttribute("class", "nav-"+appname); - li.setAttribute("folderpos", len.toString()); - li.appendChild(a); + var innerTagA = document.createElement('A'); + innerTagA.setAttribute("href","/cloud/index.php/apps/files/?dir="+appfolder); + innerTagA.setAttribute("class","nav-icon-files svg"); + innerTagA.innerHTML=appName; + var length=listLIElements.length+1; + var innerTagLI = document.createElement('li'); + innerTagLI.setAttribute("data-id", "/cloud/index.php/apps/files/?dir="+appfolder); + innerTagLI.setAttribute("class", "nav-"+appName); + innerTagLI.setAttribute("folderpos", length.toString()); + innerTagLI.appendChild(innerTagA); - if(listUL.childElementCount<=0){ - listUL.appendChild(li); - var dotmenu = document.getElementById("quickaccessbutton"); - dotmenu.style.display=''; + if (listULElements.childElementCount <= 0) { + listULElements.appendChild(innerTagLI); + var dotMenu = document.getElementById("quickaccessbutton"); + dotMenu.style.display=''; var collapsibleButton = document.getElementById("button-collapseQuickAccess"); collapsibleButton.style.display=''; $("#favorites-toggle" ).addClass('collapsible'); - }else{ - list[list.length-1].after(li); + } else { + listLIElements[listLIElements.length-1].after(innerTagLI); } } From 8b1cf58a0174dad7e3163bbee397d6c07b6323c8 Mon Sep 17 00:00:00 2001 From: fnuesse Date: Thu, 21 Jun 2018 11:40:25 +0200 Subject: [PATCH 44/75] Hid away extended Settings Signed-off-by: fnuesse --- apps/files/appinfo/routes.php | 18 +++++-- apps/files/js/navigation.js | 49 ++++++++++++++++++-- apps/files/lib/Controller/ApiController.php | 26 +++++++++++ apps/files/lib/Controller/ViewController.php | 2 +- apps/files/templates/appnavigation.php | 4 ++ 5 files changed, 89 insertions(+), 10 deletions(-) diff --git a/apps/files/appinfo/routes.php b/apps/files/appinfo/routes.php index 338182657d8f9..549a52d6ee4a7 100644 --- a/apps/files/appinfo/routes.php +++ b/apps/files/appinfo/routes.php @@ -81,24 +81,34 @@ 'url' => '/api/v1/quickaccess/show', 'verb' => 'GET', ], + [ + 'name' => 'API#getShowQuickaccessSettings', + 'url' => '/api/v1/quickaccess/showsettings', + 'verb' => 'GET', + ], + [ + 'name' => 'API#setShowQuickaccessSettings', + 'url' => '/api/v1/quickaccess/set/showsettings', + 'verb' => 'GET', + ], [ 'name' => 'API#setSortingStrategy', - 'url' => '/api/v1/quickaccess/setSortingStrategy', + 'url' => '/api/v1/quickaccess/set/SortingStrategy', 'verb' => 'GET', ], [ 'name' => 'API#setReverseQuickaccess', - 'url' => '/api/v1/quickaccess/setReverseList', + 'url' => '/api/v1/quickaccess/set/ReverseList', 'verb' => 'GET', ], [ 'name' => 'API#getSortingStrategy', - 'url' => '/api/v1/quickaccess/getSortingStrategy', + 'url' => '/api/v1/quickaccess/get/SortingStrategy', 'verb' => 'GET', ], [ 'name' => 'API#getReverseQuickaccess', - 'url' => '/api/v1/quickaccess/getReverseList', + 'url' => '/api/v1/quickaccess/get/ReverseList', 'verb' => 'GET', ] ] diff --git a/apps/files/js/navigation.js b/apps/files/js/navigation.js index c5269212a721d..a8b890e1106bc 100644 --- a/apps/files/js/navigation.js +++ b/apps/files/js/navigation.js @@ -55,7 +55,7 @@ this._activeItem = null; this.$currentContent = null; this._setupEvents(); - this.initialSort(); + this.setInitialQuickaccessSettings(); }, /** @@ -65,6 +65,7 @@ this.$el.on('click', 'li a', _.bind(this._onClickItem, this)) this.$el.on('click', 'li button', _.bind(this._onClickMenuButton, this)); this.$el.on('click', 'li input', _.bind(this._onClickMenuItem, this)); + this.$el.on('click', 'div input', _.bind(this._onClickAppSettings, this)); }, /** @@ -166,6 +167,33 @@ ev.preventDefault(); }, + /** + * Event handler for when clicking on an app setting. + */ + _onClickAppSettings: function (ev) { + + var itemId = $(ev.target).closest('input').attr('id'); + if (itemId === 'showQuickAccessSortingToggle') { + + var togglestate=false; + var dotMenu = document.getElementById("quickaccessbutton"); + if (document.getElementById('showQuickAccessSortingToggle').checked) { + dotMenu.style.display=''; + togglestate=true; + } else { + dotMenu.style.display='none'; + togglestate=false; + + } + + $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/set/showsettings"), + {show: togglestate}, + function (data, status) { + }); + document.getElementById('showQuickAccessSortingToggle').checked=togglestate; + } + }, + /** * Event handler for when clicking on a menuitem. */ @@ -192,7 +220,7 @@ this.sortingStrategy = 'alphabet'; document.getElementById('sortByDate').checked = false; - $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/setSortingStrategy"), + $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/set/SortingStrategy"), {strategy: this.sortingStrategy}, function (data, status) { }); @@ -210,7 +238,7 @@ this.sortingStrategy = 'date'; document.getElementById('sortByAlphabet').checked = false; - $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/setSortingStrategy"), + $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/set/SortingStrategy"), {strategy: this.sortingStrategy}, function (data, status) { }); @@ -222,7 +250,7 @@ if (itemId === 'enableReverse') { this.reverse(list); var state = document.getElementById('enableReverse').checked; - $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/setReverseList"), + $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/set/ReverseList"), {reverse: state}, function (data, status) { }); @@ -233,7 +261,7 @@ /** * Sort initially as setup of sidebar for QuickAccess */ - initialSort: function () { + setInitialQuickaccessSettings: function () { var domRevState = document.getElementById('enableReverse').checked; var domSortAlphabetState = document.getElementById('sortByAlphabet').checked; var domSortDateState = document.getElementById('sortByDate').checked; @@ -253,6 +281,17 @@ if (domRevState) { this.reverse(list); } + + $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/showsettings"), + function (data, status) { + document.getElementById('showQuickAccessSortingToggle').checked=data; + if (data) { + document.getElementById("quickaccessbutton").style.display=''; + } else { + document.getElementById("quickaccessbutton").style.display='none'; + } + }); + }, /** diff --git a/apps/files/lib/Controller/ApiController.php b/apps/files/lib/Controller/ApiController.php index 53a8e1b55eefb..597d1842f90fb 100644 --- a/apps/files/lib/Controller/ApiController.php +++ b/apps/files/lib/Controller/ApiController.php @@ -331,4 +331,30 @@ public function getReverseQuickaccess() { return false; } + /** + * Set state for show sorting menu + * + * @NoAdminRequired + * + * @param bool $show + * @return Response + */ + public function setShowQuickaccessSettings($show) { + $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_show_settings', (int) $show); + return new Response(); + } + /** + * Get state for show sorting menu + * + * @NoAdminRequired + * + * @return bool + */ + public function getShowQuickaccessSettings() { + if($this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_show_settings', false)){ + return true; + } + return false; + } + } diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index 8afec0be9093e..de9a62dda8a2c 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -199,7 +199,7 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal 'quickaccessSortingStrategy' => $sorting, 'quickaccessSortingReverse' => $reverseListSetting, 'order' => 5, - 'name' => $this->l10n->t('Favorites'), + 'name' => $this->l10n->t('Favorites'.$reverseListSetting), //If there are zero elements, add ul end tag directly. 'favoritescount' => $favoritesFolderCount ] diff --git a/apps/files/templates/appnavigation.php b/apps/files/templates/appnavigation.php index 8cbefdb4619aa..c7515b9766552 100644 --- a/apps/files/templates/appnavigation.php +++ b/apps/files/templates/appnavigation.php @@ -86,6 +86,10 @@ class="nav-icon- s
    +
    + + +
    t('Use this address to access your Files via WebDAV', array(link_to_docs('user-webdav'))));?> From f597a935349a85517702ae4630de4ba967420cfa Mon Sep 17 00:00:00 2001 From: fnuesse Date: Thu, 21 Jun 2018 11:43:16 +0200 Subject: [PATCH 45/75] Fixed reverse state Signed-off-by: fnuesse --- apps/files/lib/Controller/ViewController.php | 4 ++-- apps/files/templates/appnavigation.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index de9a62dda8a2c..dec4f58e932be 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -197,9 +197,9 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal 'classes' => $collapseClasses, 'enableQuickaccess' => $quickAccessExpandedState, 'quickaccessSortingStrategy' => $sorting, - 'quickaccessSortingReverse' => $reverseListSetting, + 'quickaccessSortingReverse' => $reverseListSetting ? 1 : 0, 'order' => 5, - 'name' => $this->l10n->t('Favorites'.$reverseListSetting), + 'name' => $this->l10n->t('Favorites'), //If there are zero elements, add ul end tag directly. 'favoritescount' => $favoritesFolderCount ] diff --git a/apps/files/templates/appnavigation.php b/apps/files/templates/appnavigation.php index c7515b9766552..67b89c58d705e 100644 --- a/apps/files/templates/appnavigation.php +++ b/apps/files/templates/appnavigation.php @@ -40,7 +40,7 @@ class="nav-icon- s
  • - checked/> + checked/>
  • From 9191f0e6f62bc3f6cff5ff752009120d430b4c06 Mon Sep 17 00:00:00 2001 From: fnuesse Date: Thu, 21 Jun 2018 11:44:43 +0200 Subject: [PATCH 46/75] Fixed Missing reverse after changing sort-strategy Signed-off-by: fnuesse --- apps/files/js/navigation.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/files/js/navigation.js b/apps/files/js/navigation.js index a8b890e1106bc..0e369fa4f6937 100644 --- a/apps/files/js/navigation.js +++ b/apps/files/js/navigation.js @@ -226,6 +226,7 @@ }); this.QuickSort(list, 0, list.length - 1); + if (document.getElementById('enableReverse').checked) {this.reverse(list);} document.getElementById('menu-favorites').classList.toggle('open'); } @@ -244,6 +245,7 @@ }); this.QuickSort(list, 0, list.length - 1); + if (document.getElementById('enableReverse').checked) {this.reverse(list);} document.getElementById('menu-favorites').classList.toggle('open'); } From 01773fa8dc79ea03ba51278cf6496f07cdc69532 Mon Sep 17 00:00:00 2001 From: fnuesse Date: Thu, 21 Jun 2018 11:47:02 +0200 Subject: [PATCH 47/75] Fixed Copyright-Header Signed-off-by: fnuesse --- apps/files/js/navigation.js | 5 ++--- apps/files/lib/Controller/ApiController.php | 2 +- apps/files/lib/Controller/ViewController.php | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/apps/files/js/navigation.js b/apps/files/js/navigation.js index 0e369fa4f6937..32e8ca99c6b81 100644 --- a/apps/files/js/navigation.js +++ b/apps/files/js/navigation.js @@ -1,10 +1,9 @@ /* - * Copyright (c) 2014 + * @Copyright 2014 Vincent Petry * * @author Vincent Petry - * @copyright 2014 Vincent Petry + * @author Felix Nüsse * - * Edited by: Felix Nüsse 2018 * * This file is licensed under the Affero General Public License version 3 * or later. diff --git a/apps/files/lib/Controller/ApiController.php b/apps/files/lib/Controller/ApiController.php index 597d1842f90fb..c50de1bbf8424 100644 --- a/apps/files/lib/Controller/ApiController.php +++ b/apps/files/lib/Controller/ApiController.php @@ -11,7 +11,7 @@ * @author Roeland Jago Douma * @author Tobias Kaminsky * @author Vincent Petry - * + * @author Felix Nüsse * @license AGPL-3.0 * * This code is free software: you can redistribute it and/or modify diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index dec4f58e932be..c1ab77060188a 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -8,7 +8,7 @@ * @author Roeland Jago Douma * @author Thomas Müller * @author Vincent Petry - * @author Felix Nüsse Petry + * @author Felix Nüsse * * @license AGPL-3.0 * From b1a6eb7cdccc00829d70dd8fcd17471fc4565f3d Mon Sep 17 00:00:00 2001 From: fnuesse Date: Fri, 22 Jun 2018 01:05:49 +0200 Subject: [PATCH 48/75] Removed UI-Flickering Signed-off-by: fnuesse --- apps/files/templates/appnavigation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/files/templates/appnavigation.php b/apps/files/templates/appnavigation.php index 67b89c58d705e..7fab1ff25def4 100644 --- a/apps/files/templates/appnavigation.php +++ b/apps/files/templates/appnavigation.php @@ -17,7 +17,7 @@ class="nav- " class="nav-icon- svg"> -
    style="display: none"> + -
    - - -
    t('Use this address to access your Files via WebDAV', array(link_to_docs('user-webdav'))));?> @@ -97,3 +45,72 @@ class="nav-icon- s
    + + + +
  • id="button-collapse-parent-" data-id=" " + class="nav- open" + folderPos="" + > + + + + + + +
      + +
    + +
  • + + + +
    style="display: none"> +
      +
    • + +
    • +
    +
    +
    +
      + +
    +
    +entries[] = $entry; } + /** + * Adds a new Sublistentry to a given array + * + * @param array|\Closure $entry Array containing: id, name, order, icon and href key + * The use of a closure is preferred, because it will avoid + * loading the routing of your app, unless required. + * @param array Array to append item to + * + * @return void + */ + public function addToSublist($entry, $entryArray) { + $entry['active'] = false; + if(!isset($entry['icon'])) { + $entry['icon'] = ''; + } + if(!isset($entry['classes'])) { + $entry['classes'] = ''; + } + if(!isset($entry['type'])) { + $entry['type'] = 'link'; + } + array_push($entryArray, $entry); + } + + /** + * Adds a new, draggable Sublistentry to a given array + * + * @param array|\Closure $entry Array containing: id, name, order, icon and href key + * The use of a closure is preferred, because it will avoid + * loading the routing of your app, unless required. + * @param array Array to append item to + * + * @return void + */ + public function addToSublistDraggable($entry, $entryArray) { + $entry['active'] = false; + if(!isset($entry['icon'])) { + $entry['icon'] = ''; + } + if(!isset($entry['classes'])) { + $entry['classes'] = ''; + } + if(!isset($entry['draggable'])) { + $entry['draggable'] = 'true'; + } + if(!isset($entry['type'])) { + $entry['type'] = 'link'; + } + array_push($entryArray, $entry); + } + /** * Get a list of navigation entries * From 7724d4ce121e4f5c826b663fca7b393a7da58f42 Mon Sep 17 00:00:00 2001 From: fnuesse Date: Mon, 25 Jun 2018 19:29:51 +0200 Subject: [PATCH 52/75] Fixed draggable Sublist-Elements Signed-off-by: fnuesse --- apps/files/js/navigation.js | 38 ++++++++++++-------- apps/files/lib/Controller/ViewController.php | 6 ++-- apps/files/templates/appnavigation.php | 5 ++- 3 files changed, 28 insertions(+), 21 deletions(-) diff --git a/apps/files/js/navigation.js b/apps/files/js/navigation.js index 9bca2ff55cc91..6362c3c2988fe 100644 --- a/apps/files/js/navigation.js +++ b/apps/files/js/navigation.js @@ -63,8 +63,11 @@ _setupEvents: function () { this.$el.on('click', 'li a', _.bind(this._onClickItem, this)) this.$el.on('click', 'li button', _.bind(this._onClickMenuButton, this)); + this._setOnDrag(); //this.$el.on('click', 'li input', _.bind(this._onClickMenuItem, this)); //this.$el.on('click', 'div input', _.bind(this._onClickAppSettings, this)); + + }, /** @@ -145,7 +148,27 @@ }, /** - * Event handler for when clicking on an three-dot-menu. + * Event handler for when dragging an item + */ + _setOnDrag: function () { + $(function () { + var start_pos; + if(document.getElementById("sublist-favorites").hasAttribute("draggable")){ + $("#sublist-favorites").sortable({ + start: function (event, ui) { + start_pos = ui.item.index(); + ui.item.data('start_pos', start_pos); + }, + update: function (event, ui) { + //alert(ui.item.data('start_pos', start_pos).attr('data-id') + " at " + start_pos); + } + }); + } + }); + }, + + /** + * Event handler for clicking a button */ _onClickMenuButton: function (ev) { var $target = $(ev.target); @@ -284,20 +307,7 @@ */ setInitialQuickaccessSettings: function () { - $( function() { - $( "#quickaccess-list" ).sortable({ - start: function(event, ui) { - var start_pos = ui.item.index(); - ui.item.data('start_pos', start_pos); - }, - change: function(event, ui) { - }, - update: function(event, ui) { - alert(ui.item.data('start_pos', start_pos).attr('data-id')+" at "+start_pos); - } - }); - } ); var domRevState = document.getElementById('enableReverse').checked; var domSortAlphabetState = document.getElementById('sortByAlphabet').checked; diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index 686575f767535..d80e1e443ebb6 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -208,11 +208,10 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal 'order' => $navBarPositionPosition, 'folderPosition' => $sortingValue, 'name' => $id, - 'classes' => 'draggable', - 'draggable' => true, 'icon' => 'files', 'quickaccesselement' => 'true' ]; + array_push($favoritesSublistArray, $element); $navBarPositionPosition++; } @@ -230,10 +229,9 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal 'order' => 5, 'name' => $this->l10n->t('Favorites'), 'sublist' => $favoritesSublistArray, + 'draggableSublist' => 'false', 'defaultExpandedState' => 'true', 'enableMenuButton' => 0, - //If there are zero elements, add ul end tag directly. - 'favoritescount' => $favoritesFolderCount ] ); diff --git a/apps/files/templates/appnavigation.php b/apps/files/templates/appnavigation.php index aa3d76453eedc..b0726587de91c 100644 --- a/apps/files/templates/appnavigation.php +++ b/apps/files/templates/appnavigation.php @@ -63,8 +63,7 @@ function NavigationListElements($item, $pinned, $l){ ?>
  • id="button-collapse-parent-" data-id=" " class="nav- open" - folderPos="" - > + folderPos="" > @@ -75,7 +74,7 @@ class="nav-icon- s if (isset($item['sublist'])){ ?> -
      +
        draggable="true"> Date: Mon, 25 Jun 2018 19:31:30 +0200 Subject: [PATCH 53/75] Fixed draggable Sublist-Elements Signed-off-by: fnuesse --- apps/files/js/navigation.js | 33 ++++--- apps/files/js/tagsplugin.js | 82 ++++++++--------- apps/files/lib/Controller/ViewController.php | 46 ++++------ apps/files/templates/appnavigation.php | 97 +++++++++++--------- lib/private/NavigationManager.php | 51 ---------- 5 files changed, 130 insertions(+), 179 deletions(-) diff --git a/apps/files/js/navigation.js b/apps/files/js/navigation.js index 6362c3c2988fe..416dffc8093e3 100644 --- a/apps/files/js/navigation.js +++ b/apps/files/js/navigation.js @@ -153,16 +153,16 @@ _setOnDrag: function () { $(function () { var start_pos; - if(document.getElementById("sublist-favorites").hasAttribute("draggable")){ - $("#sublist-favorites").sortable({ - start: function (event, ui) { - start_pos = ui.item.index(); - ui.item.data('start_pos', start_pos); - }, - update: function (event, ui) { - //alert(ui.item.data('start_pos', start_pos).attr('data-id') + " at " + start_pos); - } - }); + if (document.getElementById("sublist-favorites").hasAttribute("draggable")) { + $("#sublist-favorites").sortable({ + start: function (event, ui) { + start_pos = ui.item.index(); + ui.item.data('start_pos', start_pos); + }, + update: function (event, ui) { + //alert(ui.item.data('start_pos', start_pos).attr('data-id') + " at " + start_pos); + } + }); } }); }, @@ -174,8 +174,8 @@ var $target = $(ev.target); var itemId = $target.closest('button').attr('id'); - var collapsibleToggles=[]; - var dotmenuToggles=[]; + var collapsibleToggles = []; + var dotmenuToggles = []; // The collapsibleToggles-Array consists of a list of Arrays. Every subarray must contain the Button to listen to at the 0th index, // and the parent, which should be toggled at the first arrayindex. @@ -186,14 +186,14 @@ dotmenuToggles.push(["#dotmenu-button-favorites", "dotmenu-content-favorites"]); - collapsibleToggles.forEach(function foundToggle(item) { - if (item[0] === ("#"+itemId)) { + collapsibleToggles.forEach(function foundToggle (item) { + if (item[0] === ("#" + itemId)) { $(item[1]).toggleClass('open'); } }); - dotmenuToggles.forEach(function foundToggle(item) { - if (item[0] === ("#"+itemId)) { + dotmenuToggles.forEach(function foundToggle (item) { + if (item[0] === ("#" + itemId)) { document.getElementById(item[1]).classList.toggle('open'); } }); @@ -308,7 +308,6 @@ setInitialQuickaccessSettings: function () { - var domRevState = document.getElementById('enableReverse').checked; var domSortAlphabetState = document.getElementById('sortByAlphabet').checked; var domSortDateState = document.getElementById('sortByDate').checked; diff --git a/apps/files/js/tagsplugin.js b/apps/files/js/tagsplugin.js index 99b0d0a39ddd1..7729a540d3218 100644 --- a/apps/files/js/tagsplugin.js +++ b/apps/files/js/tagsplugin.js @@ -10,11 +10,11 @@ /* global Handlebars */ -(function(OCA) { +(function (OCA) { _.extend(OC.Files.Client, { - PROPERTY_TAGS: '{' + OC.Files.Client.NS_OWNCLOUD + '}tags', - PROPERTY_FAVORITE: '{' + OC.Files.Client.NS_OWNCLOUD + '}favorite' + PROPERTY_TAGS: '{' + OC.Files.Client.NS_OWNCLOUD + '}tags', + PROPERTY_FAVORITE: '{' + OC.Files.Client.NS_OWNCLOUD + '}favorite' }); var TEMPLATE_FAVORITE_MARK = @@ -30,7 +30,7 @@ * @param {boolean} state true if starred, false otherwise * @return {string} icon class for star image */ - function getStarIconClass(state) { + function getStarIconClass (state) { return state ? 'icon-starred' : 'icon-star'; } @@ -40,7 +40,7 @@ * @param {boolean} state true if starred, false otherwise * @return {Object} jQuery object */ - function renderStar(state) { + function renderStar (state) { if (!this._template) { this._template = Handlebars.compile(TEMPLATE_FAVORITE_MARK); } @@ -57,7 +57,7 @@ * @param {Object} $favoriteMarkEl favorite mark element * @param {boolean} state true if starred, false otherwise */ - function toggleStar($favoriteMarkEl, state) { + function toggleStar ($favoriteMarkEl, state) { $favoriteMarkEl.removeClass('icon-star icon-starred').addClass(getStarIconClass(state)); $favoriteMarkEl.toggleClass('permanent', state); } @@ -67,15 +67,15 @@ * * @param {String} appfolder folder to be removed */ - function removeFavoriteFromList(appfolder) { + function removeFavoriteFromList (appfolder) { - var quickAccessList= 'sublist-favorites'; - var collapsibleButtonId= 'button-collapse-favorites'; + var quickAccessList = 'sublist-favorites'; + var collapsibleButtonId = 'button-collapse-favorites'; var listULElements = document.getElementById(quickAccessList); var listLIElements = listULElements.getElementsByTagName('li'); - var appName=appfolder.substring(appfolder.lastIndexOf("/")+1, appfolder.length); + var appName = appfolder.substring(appfolder.lastIndexOf("/") + 1, appfolder.length); - for (var i = 0; i <= listLIElements.length-1; i++) { + for (var i = 0; i <= listLIElements.length - 1; i++) { if (appName === listLIElements[i].getElementsByTagName('a')[0].innerHTML) { listLIElements[i].remove(); } @@ -83,7 +83,7 @@ if (listULElements.childElementCount === 0) { var collapsibleButton = document.getElementById(collapsibleButtonId); - collapsibleButton.style.display='none'; + collapsibleButton.style.display = 'none'; $("#favorites-toggle").removeClass('collapsible'); } } @@ -93,23 +93,23 @@ * * @param {String} appfolder folder to be added */ - function addFavoriteToList(appfolder) { - var quickAccessList= 'sublist-favorites'; - var collapsibleButtonId= 'button-collapse-favorites'; + function addFavoriteToList (appfolder) { + var quickAccessList = 'sublist-favorites'; + var collapsibleButtonId = 'button-collapse-favorites'; var listULElements = document.getElementById(quickAccessList); var listLIElements = listULElements.getElementsByTagName('li'); - var appName=appfolder.substring(appfolder.lastIndexOf("/")+1, appfolder.length); + var appName = appfolder.substring(appfolder.lastIndexOf("/") + 1, appfolder.length); var innerTagA = document.createElement('A'); - innerTagA.setAttribute("href","/cloud/index.php/apps/files/?dir="+appfolder); - innerTagA.setAttribute("class","nav-icon-files svg"); - innerTagA.innerHTML=appName; + innerTagA.setAttribute("href", "/cloud/index.php/apps/files/?dir=" + appfolder); + innerTagA.setAttribute("class", "nav-icon-files svg"); + innerTagA.innerHTML = appName; - var length=listLIElements.length+1; + var length = listLIElements.length + 1; var innerTagLI = document.createElement('li'); - innerTagLI.setAttribute("data-id", "/cloud/index.php/apps/files/?dir="+appfolder); - innerTagLI.setAttribute("class", "nav-"+appName); + innerTagLI.setAttribute("data-id", "/cloud/index.php/apps/files/?dir=" + appfolder); + innerTagLI.setAttribute("class", "nav-" + appName); innerTagLI.setAttribute("folderpos", length.toString()); innerTagLI.appendChild(innerTagA); @@ -117,11 +117,11 @@ if (listULElements.childElementCount <= 0) { listULElements.appendChild(innerTagLI); var collapsibleButton = document.getElementById(collapsibleButtonId); - collapsibleButton.style.display=''; + collapsibleButton.style.display = ''; - $("#favorites-toggle" ).addClass('collapsible'); + $("#favorites-toggle").addClass('collapsible'); } else { - listLIElements[listLIElements.length-1].after(innerTagLI); + listLIElements[listLIElements.length - 1].after(innerTagLI); } } @@ -146,12 +146,12 @@ 'shares.link' ], - _extendFileActions: function(fileActions) { + _extendFileActions: function (fileActions) { var self = this; fileActions.registerAction({ name: 'Favorite', - displayName: function(context) { + displayName: function (context) { var $file = context.$file; var isFavorite = $file.data('favorite') === true; @@ -168,7 +168,7 @@ mime: 'all', order: -100, permissions: OC.PERMISSION_NONE, - iconClass: function(fileName, context) { + iconClass: function (fileName, context) { var $file = context.$file; var isFavorite = $file.data('favorite') === true; @@ -178,7 +178,7 @@ return 'icon-starred'; }, - actionHandler: function(fileName, context) { + actionHandler: function (fileName, context) { var $favoriteMarkEl = context.$file.find('.favorite-mark'); var $file = context.$file; var fileInfo = context.fileList.files[$file.index()]; @@ -210,7 +210,7 @@ tags, $favoriteMarkEl, isFavorite - ).then(function(result) { + ).then(function (result) { context.fileInfoModel.trigger('busy', context.fileInfoModel, false); // response from server should contain updated tags var newTags = result.tags; @@ -226,10 +226,10 @@ }); }, - _extendFileList: function(fileList) { + _extendFileList: function (fileList) { // extend row prototype var oldCreateRow = fileList._createRow; - fileList._createRow = function(fileData) { + fileList._createRow = function (fileData) { var $tr = oldCreateRow.apply(this, arguments); var isFavorite = false; if (fileData.tags) { @@ -244,7 +244,7 @@ return $tr; }; var oldElementToFile = fileList.elementToFile; - fileList.elementToFile = function($el) { + fileList.elementToFile = function ($el) { var fileInfo = oldElementToFile.apply(this, arguments); var tags = $el.attr('data-tags'); if (_.isUndefined(tags)) { @@ -257,22 +257,22 @@ }; var oldGetWebdavProperties = fileList._getWebdavProperties; - fileList._getWebdavProperties = function() { + fileList._getWebdavProperties = function () { var props = oldGetWebdavProperties.apply(this, arguments); props.push(OC.Files.Client.PROPERTY_TAGS); props.push(OC.Files.Client.PROPERTY_FAVORITE); return props; }; - fileList.filesClient.addFileInfoParser(function(response) { + fileList.filesClient.addFileInfoParser(function (response) { var data = {}; var props = response.propStat[0].properties; var tags = props[OC.Files.Client.PROPERTY_TAGS]; var favorite = props[OC.Files.Client.PROPERTY_FAVORITE]; if (tags && tags.length) { - tags = _.chain(tags).filter(function(xmlvalue) { + tags = _.chain(tags).filter(function (xmlvalue) { return (xmlvalue.namespaceURI === OC.Files.Client.NS_OWNCLOUD && xmlvalue.nodeName.split(':')[1] === 'tag'); - }).map(function(xmlvalue) { + }).map(function (xmlvalue) { return xmlvalue.textContent || xmlvalue.text; }).value(); } @@ -287,7 +287,7 @@ }); }, - attach: function(fileList) { + attach: function (fileList) { if (this.allowedLists.indexOf(fileList.id) < 0) { return; } @@ -303,7 +303,7 @@ * @param {Object} $favoriteMarkEl favorite mark element * @param {boolean} isFavorite Was the item favorited before */ - applyFileTags: function(fileName, tagNames, $favoriteMarkEl, isFavorite) { + applyFileTags: function (fileName, tagNames, $favoriteMarkEl, isFavorite) { var encodedPath = OC.encodePath(fileName); while (encodedPath[0] === '/') { encodedPath = encodedPath.substr(1); @@ -316,10 +316,10 @@ }), dataType: 'json', type: 'POST' - }).fail(function(response) { + }).fail(function (response) { var message = ''; // show message if it is available - if(response.responseJSON && response.responseJSON.message) { + if (response.responseJSON && response.responseJSON.message) { message = ': ' + response.responseJSON.message; } OC.Notification.show(t('files', 'An error occurred while trying to update the tags' + message), {type: 'error'}); diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index d80e1e443ebb6..6861b7246e9e4 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -182,40 +182,34 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal $favElements['folders'] = null; } - $favoritesFolderCount = sizeof($favElements['folders']); - $collapseClasses = ''; - if ($favoritesFolderCount > 0) { + if (sizeof($favElements['folders']) > 0) { $collapseClasses = 'collapsible'; } + $favoritesSublistArray = Array(); + $navBarPositionPosition = 6; + $currentCount = 0; + foreach ($favElements['folders'] as $elem) { + $id = substr($elem, strrpos($elem, '/') + 1, strlen($elem)); + $link = $this->urlGenerator->linkToRouteAbsolute('files.view.index', ['dir' => $elem]); + $sortingValue = ++$currentCount; - $favoritesSublistArray= Array(); - - $navBarPositionPosition = 6; - $currentCount = 0; - foreach ($favElements['folders'] as $elem) { - - $id = substr($elem, strrpos($elem, '/') + 1, strlen($elem)); - $link = $this->urlGenerator->linkToRouteAbsolute('files.view.index', ['dir' => $elem]); - $sortingValue = ++$currentCount; - - $element = [ - 'id' => $id, - 'href' => $link, - 'order' => $navBarPositionPosition, - 'folderPosition' => $sortingValue, - 'name' => $id, - 'icon' => 'files', - 'quickaccesselement' => 'true' - ]; - - array_push($favoritesSublistArray, $element); - $navBarPositionPosition++; - } + $element = [ + 'id' => $id, + 'href' => $link, + 'order' => $navBarPositionPosition, + 'folderPosition' => $sortingValue, + 'name' => $id, + 'icon' => 'files', + 'quickaccesselement' => 'true' + ]; + array_push($favoritesSublistArray, $element); + $navBarPositionPosition++; + } \OCA\Files\App::getNavigationManager()->add( diff --git a/apps/files/templates/appnavigation.php b/apps/files/templates/appnavigation.php index b0726587de91c..56a84edf3b669 100644 --- a/apps/files/templates/appnavigation.php +++ b/apps/files/templates/appnavigation.php @@ -9,9 +9,10 @@ } ?> -
      • t('%s used', [$_['usage']])); } ?>

        - 80): ?> class="warn" > + 80): ?> class="warn" >
      -
      - +
      - - - t('Use this address to access your Files via WebDAV', array(link_to_docs('user-webdav'))));?> + + + t('Use this address to access your Files via WebDAV', array(link_to_docs('user-webdav')))); ?>
      @@ -58,34 +63,36 @@ * * @return int Returns the pinned value */ -function NavigationListElements($item, $pinned, $l){ - strpos($item['classes'], 'pinned')!==false ? $pinned++ : ''; +function NavigationListElements($item, $pinned, $l) { + strpos($item['classes'], 'pinned') !== false ? $pinned++ : ''; ?> -
    • id="button-collapse-parent-" data-id=" " - class="nav- open" - folderPos="" > +
    • id="button-collapse-parent-" + data-id=" " + class="nav- open" + folderPos="" > + class="nav-icon- svg"> - - -
        draggable="true"> - -
      - + +
        draggable="true"> + +
      +
    • - s * * @return void */ -function NavigationElementMenu($item){ +function NavigationElementMenu($item) { if ($item['menubuttons'] === 'true') { -?> -
      style="display: none"> -
        -
      • - -
      • -
      -
      -
      -
        + ?> +
        style="display: none"> +
          +
        • + +
        • +
        +
        +
        +
          -
        -
        - +
      + entries[] = $entry; } - /** - * Adds a new Sublistentry to a given array - * - * @param array|\Closure $entry Array containing: id, name, order, icon and href key - * The use of a closure is preferred, because it will avoid - * loading the routing of your app, unless required. - * @param array Array to append item to - * - * @return void - */ - public function addToSublist($entry, $entryArray) { - $entry['active'] = false; - if(!isset($entry['icon'])) { - $entry['icon'] = ''; - } - if(!isset($entry['classes'])) { - $entry['classes'] = ''; - } - if(!isset($entry['type'])) { - $entry['type'] = 'link'; - } - array_push($entryArray, $entry); - } - - /** - * Adds a new, draggable Sublistentry to a given array - * - * @param array|\Closure $entry Array containing: id, name, order, icon and href key - * The use of a closure is preferred, because it will avoid - * loading the routing of your app, unless required. - * @param array Array to append item to - * - * @return void - */ - public function addToSublistDraggable($entry, $entryArray) { - $entry['active'] = false; - if(!isset($entry['icon'])) { - $entry['icon'] = ''; - } - if(!isset($entry['classes'])) { - $entry['classes'] = ''; - } - if(!isset($entry['draggable'])) { - $entry['draggable'] = 'true'; - } - if(!isset($entry['type'])) { - $entry['type'] = 'link'; - } - array_push($entryArray, $entry); - } - /** * Get a list of navigation entries * From 38219e941f27c6b65a3f3bb9268d62ad96b0183d Mon Sep 17 00:00:00 2001 From: fnuesse Date: Tue, 26 Jun 2018 23:16:10 +0200 Subject: [PATCH 54/75] Added date-modified sorting option to quickaccess Signed-off-by: fnuesse --- apps/files/appinfo/routes.php | 7 +- apps/files/js/navigation.js | 173 +++++-------------- apps/files/lib/Controller/ApiController.php | 23 +++ apps/files/lib/Controller/ViewController.php | 12 -- 4 files changed, 70 insertions(+), 145 deletions(-) diff --git a/apps/files/appinfo/routes.php b/apps/files/appinfo/routes.php index 549a52d6ee4a7..ad35d4cf76071 100644 --- a/apps/files/appinfo/routes.php +++ b/apps/files/appinfo/routes.php @@ -110,7 +110,12 @@ 'name' => 'API#getReverseQuickaccess', 'url' => '/api/v1/quickaccess/get/ReverseList', 'verb' => 'GET', - ] + ], + [ + 'name' => 'API#getFavoritesFolder', + 'url' => '/api/v1/quickaccess/get/FavoriteFolders/', + 'verb' => 'GET' + ], ] ] ); diff --git a/apps/files/js/navigation.js b/apps/files/js/navigation.js index 416dffc8093e3..1a213e5f08baa 100644 --- a/apps/files/js/navigation.js +++ b/apps/files/js/navigation.js @@ -42,7 +42,7 @@ /** * Strategy by which the quickaccesslist is sorted */ - $sortingStrategy: 'alphabet', + $sortingStrategy: 'datemodified', /** * Initializes the navigation from the given container * @@ -54,7 +54,9 @@ this._activeItem = null; this.$currentContent = null; this._setupEvents(); - //this.setInitialQuickaccessSettings(); + this.setInitialQuickaccessSettings(); + + }, /** @@ -64,9 +66,6 @@ this.$el.on('click', 'li a', _.bind(this._onClickItem, this)) this.$el.on('click', 'li button', _.bind(this._onClickMenuButton, this)); this._setOnDrag(); - //this.$el.on('click', 'li input', _.bind(this._onClickMenuItem, this)); - //this.$el.on('click', 'div input', _.bind(this._onClickAppSettings, this)); - }, @@ -201,150 +200,53 @@ ev.preventDefault(); }, - /** - * Event handler for when clicking on an app setting. + * Sort initially as setup of sidebar for QuickAccess */ - /* - _onClickAppSettings: function (ev) { - - var itemId = $(ev.target).closest('input').attr('id'); - if (itemId === 'showQuickAccessSortingToggle') { + setInitialQuickaccessSettings: function () { - var togglestate=false; - var dotMenu = document.getElementById("quickaccessbutton"); - if (document.getElementById('showQuickAccessSortingToggle').checked) { - if($("#favorites-toggle" ).hasClass('collapsible')){ - dotMenu.style.display=''; + var quickAccesKey = 'sublist-favorites'; + var list = document.getElementById(quickAccesKey).getElementsByTagName('li'); + var scope = this; + console.log(OC.TAG_FAVORITE); + $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/get/FavoriteFolders/"), function (data, status) { + for (var i = 0; i < data.favoriteFolders.length; i++) { + for (var j = 0; j < list.length; j++) { + if (scope.getCompareValue(list, j, 'alphabet').toLowerCase() === data.favoriteFolders[i].name.toLowerCase()) { + list[j].setAttribute("mtime", data.favoriteFolders[i].mtime); + } } - togglestate=true; - } else { - dotMenu.style.display='none'; - togglestate=false; - - } - - $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/set/showsettings"), - {show: togglestate}, - function (data, status) { - }); - document.getElementById('showQuickAccessSortingToggle').checked=togglestate; - } - }, - */ - - /** - * Event handler for when clicking on a menuitem. - */ - - /* - _onClickMenuItem: function (ev) { - var quickAccessKey = 'quickaccess-list'; - var itemId = $(ev.target).closest('input').attr('id'); - var list = document.getElementById(quickAccessKey).getElementsByTagName('li'); - - if (itemId === 'enableQuickAccess') { - $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/show"), - {show: document.getElementById('enableQuickAccess').checked}, - function (data, status) { - }); - $("#favorites-toggle").toggleClass('open'); - document.getElementById('menu-favorites').classList.toggle('open'); - } - - if (itemId === 'sortByAlphabet') { - //Prevents deselecting Group-Item - if (!document.getElementById('sortByAlphabet').checked) { - ev.preventDefault(); - return; } + }); - this.sortingStrategy = 'alphabet'; - document.getElementById('sortByDate').checked = false; - $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/set/SortingStrategy"), - {strategy: this.sortingStrategy}, - function (data, status) { - }); - this.QuickSort(list, 0, list.length - 1); - if (document.getElementById('enableReverse').checked) {this.reverse(list);} - document.getElementById('menu-favorites').classList.toggle('open'); + var sort = false; + var reverse = false; + if (this.$sortingStrategy === 'datemodified') { + sort = true; + reverse = true; + } else if (this.$sortingStrategy === 'alphabet') { + sort = true; + } else if (this.$sortingStrategy === 'date') { + sort = true; + }else if (this.$sortingStrategy === 'customorder') { + sort = true; } - if (itemId === 'sortByDate') { - //Prevents deselecting Group-Item - if (!document.getElementById('sortByDate').checked) { - ev.preventDefault(); - return; - } - - this.sortingStrategy = 'date'; - document.getElementById('sortByAlphabet').checked = false; - $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/set/SortingStrategy"), - {strategy: this.sortingStrategy}, - function (data, status) { - }); - + if (sort) { this.QuickSort(list, 0, list.length - 1); - if (document.getElementById('enableReverse').checked) {this.reverse(list);} - document.getElementById('menu-favorites').classList.toggle('open'); - } - - if (itemId === 'enableReverse') { - this.reverse(list); - var state = document.getElementById('enableReverse').checked; - $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/set/ReverseList"), - {reverse: state}, - function (data, status) { - }); - document.getElementById('menu-favorites').classList.toggle('open'); - } - }, - */ - - /** - * Sort initially as setup of sidebar for QuickAccess - */ - setInitialQuickaccessSettings: function () { - - - var domRevState = document.getElementById('enableReverse').checked; - var domSortAlphabetState = document.getElementById('sortByAlphabet').checked; - var domSortDateState = document.getElementById('sortByDate').checked; - - var quickAccesKey = 'quickaccess-list'; - var list = document.getElementById(quickAccesKey).getElementsByTagName('li'); - - if (domSortAlphabetState) { - this.sortingStrategy = 'alphabet'; - } - if (domSortDateState) { - this.sortingStrategy = 'date'; } - - /* - this.QuickSort(list, 0, list.length - 1); - - if (domRevState) { + if (reverse) { this.reverse(list); } - $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/showsettings"), - function (data, status) { - document.getElementById('showQuickAccessSortingToggle').checked=data; - if (data && $("#favorites-toggle" ).hasClass('collapsible')) { - document.getElementById("quickaccessbutton").style.display=''; - } else { - document.getElementById("quickaccessbutton").style.display='none'; - } - }); - */ }, /** * Sorting-Algorithm for QuickAccess */ QuickSort: function (list, start, end) { + console.log("sorting by: " + this.$sortingStrategy); var lastMatch; if (list.length > 1) { lastMatch = this.quicksort_helper(list, start, end); @@ -386,11 +288,18 @@ * Sorting-Algorithm-Helper for QuickAccess * This method allows easy access to the element which is sorted by. */ - getCompareValue: function (nodes, int) { - if (this.sortingStrategy === 'alphabet') { + getCompareValue: function (nodes, int, strategy) { + + if ((typeof strategy === 'undefined')) { + strategy = this.$sortingStrategy; + } + + if (strategy === 'alphabet') { return nodes[int].getElementsByTagName('a')[0].innerHTML.toLowerCase(); - } else if (this.sortingStrategy === 'date') { + } else if (strategy === 'date') { return nodes[int].getAttribute('folderPos').toLowerCase(); + } else if (strategy === 'datemodified') { + return nodes[int].getAttribute('mtime'); } return nodes[int].getElementsByTagName('a')[0].innerHTML.toLowerCase(); }, diff --git a/apps/files/lib/Controller/ApiController.php b/apps/files/lib/Controller/ApiController.php index c50de1bbf8424..7603f1a037164 100644 --- a/apps/files/lib/Controller/ApiController.php +++ b/apps/files/lib/Controller/ApiController.php @@ -199,6 +199,29 @@ public function getRecentFiles() { return new DataResponse(['files' => $files]); } + /** + * Returns a list of favorites modifed folder. + * + * @NoAdminRequired + * + * @return DataResponse + */ + public function getFavoritesFolder() { + $nodes = $this->userFolder->searchByTag('_$!!$_', $this->userSession->getUser()->getUID()); + + $favorites = []; + $i = 0; + foreach ($nodes as &$node) { + + $favorites[$i]['id'] = $node->getId(); + $favorites[$i]['name'] = $node->getName(); + $favorites[$i]['mtime'] = $node->getMTime(); + $i++; + } + + return new DataResponse(['favoriteFolders' => $favorites]); + } + /** * Return a list of share types for outgoing shares * diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index 6861b7246e9e4..af9606aa0473e 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -162,16 +162,6 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal $user = $this->userSession->getUser()->getUID(); - //Load QuickAccess-Defaults - $sorting = $this->config->getUserValue($user, $this->appName, 'quickaccess_sorting_strategy', 'date'); - $reverseListSetting = $this->config->getUserValue($user, $this->appName, 'quickaccess_reverse_list', 'false'); - if ($this->config->getUserValue($user, $this->appName, 'show_Quick_Access', true)) { - $quickAccessExpandedState = 'true'; - } else { - $quickAccessExpandedState = 'false'; - } - - //Get Favorite-Folder $tagger = \OC::$server->getTagManager(); $helper = new \OCA\Files\Activity\Helper($tagger); @@ -218,8 +208,6 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal 'appname' => 'files', 'script' => 'simplelist.php', 'classes' => $collapseClasses, - 'quickaccessSortingStrategy' => $sorting, - 'quickaccessSortingReverse' => $reverseListSetting ? 1 : 0, 'order' => 5, 'name' => $this->l10n->t('Favorites'), 'sublist' => $favoritesSublistArray, From 1620cac9c11c98145b042384ae6cc0b340cc2cbd Mon Sep 17 00:00:00 2001 From: fnuesse Date: Tue, 26 Jun 2018 23:55:35 +0200 Subject: [PATCH 55/75] Added custom order sorting option to quickaccess Signed-off-by: fnuesse --- apps/files/appinfo/routes.php | 10 +++ apps/files/js/navigation.js | 83 +++++++++++++++----- apps/files/lib/Controller/ApiController.php | 48 ++++++++--- apps/files/lib/Controller/ViewController.php | 2 +- 4 files changed, 110 insertions(+), 33 deletions(-) diff --git a/apps/files/appinfo/routes.php b/apps/files/appinfo/routes.php index ad35d4cf76071..fa3739c668943 100644 --- a/apps/files/appinfo/routes.php +++ b/apps/files/appinfo/routes.php @@ -116,6 +116,16 @@ 'url' => '/api/v1/quickaccess/get/FavoriteFolders/', 'verb' => 'GET' ], + [ + 'name' => 'API#setSortingOrder', + 'url' => '/api/v1/quickaccess/set/CustomSortingOrder', + 'verb' => 'GET', + ], + [ + 'name' => 'API#getSortingOrder', + 'url' => '/api/v1/quickaccess/get/CustomSortingOrder', + 'verb' => 'GET', + ], ] ] ); diff --git a/apps/files/js/navigation.js b/apps/files/js/navigation.js index 1a213e5f08baa..c4895ef99d8e6 100644 --- a/apps/files/js/navigation.js +++ b/apps/files/js/navigation.js @@ -41,8 +41,20 @@ /** * Strategy by which the quickaccesslist is sorted + * + * Possible Strategies: + * customorder + * datemodified + * date + * alphabet + * + */ + $sortingStrategy: 'customorder', + + /** + * Key for the quick-acces-list */ - $sortingStrategy: 'datemodified', + $quickAccessListKey: 'sublist-favorites', /** * Initializes the navigation from the given container * @@ -150,16 +162,26 @@ * Event handler for when dragging an item */ _setOnDrag: function () { + var scope=this; $(function () { var start_pos; - if (document.getElementById("sublist-favorites").hasAttribute("draggable")) { + if (document.getElementById(scope.$quickAccessListKey.toString()).hasAttribute("draggable")) { $("#sublist-favorites").sortable({ start: function (event, ui) { start_pos = ui.item.index(); ui.item.data('start_pos', start_pos); }, update: function (event, ui) { - //alert(ui.item.data('start_pos', start_pos).attr('data-id') + " at " + start_pos); + var list = document.getElementById(scope.$quickAccessListKey.toString()).getElementsByTagName('li'); + var string=[]; + for (var j = 0; j < list.length; j++) { + var Object = {id:j, name:scope.getCompareValue(list,j,'alphabet') }; + string.push(Object); + } + var resultorder=JSON.stringify(string); + console.log(resultorder); + $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/set/CustomSortingOrder"),{ + order: resultorder}, function (data, status) {}); } }); } @@ -205,32 +227,50 @@ */ setInitialQuickaccessSettings: function () { - var quickAccesKey = 'sublist-favorites'; + var quickAccesKey = this.$quickAccessListKey; var list = document.getElementById(quickAccesKey).getElementsByTagName('li'); - var scope = this; - console.log(OC.TAG_FAVORITE); - $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/get/FavoriteFolders/"), function (data, status) { - for (var i = 0; i < data.favoriteFolders.length; i++) { - for (var j = 0; j < list.length; j++) { - if (scope.getCompareValue(list, j, 'alphabet').toLowerCase() === data.favoriteFolders[i].name.toLowerCase()) { - list[j].setAttribute("mtime", data.favoriteFolders[i].mtime); + + var sort = true; + var reverse = false; + if (this.$sortingStrategy === 'datemodified') { + sort = false; + reverse = false; + + var scope = this; + $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/get/FavoriteFolders/"), function (data, status) { + for (var i = 0; i < data.favoriteFolders.length; i++) { + for (var j = 0; j < list.length; j++) { + if (scope.getCompareValue(list, j, 'alphabet').toLowerCase() === data.favoriteFolders[i].name.toLowerCase()) { + list[j].setAttribute("mtime", data.favoriteFolders[i].mtime); + } } } - } - }); + scope.QuickSort(list, 0, list.length - 1); + scope.reverse(list); + }); - var sort = false; - var reverse = false; - if (this.$sortingStrategy === 'datemodified') { - sort = true; - reverse = true; } else if (this.$sortingStrategy === 'alphabet') { sort = true; } else if (this.$sortingStrategy === 'date') { sort = true; - }else if (this.$sortingStrategy === 'customorder') { - sort = true; + } else if (this.$sortingStrategy === 'customorder') { + var scope = this; + $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/get/CustomSortingOrder"), function (data, status) { + console.log("load order:"); + var ordering=JSON.parse(data) + console.log(ordering); + for (var i = 0; i < ordering.length; i++) { + for (var j = 0; j < list.length; j++) { + if (scope.getCompareValue(list, j, 'alphabet').toLowerCase() === ordering[i].name.toLowerCase()) { + list[j].setAttribute("folderPosition", ordering[i].id); + } + } + } + scope.QuickSort(list, 0, list.length - 1); + }); + + sort = false; } if (sort) { @@ -246,7 +286,6 @@ * Sorting-Algorithm for QuickAccess */ QuickSort: function (list, start, end) { - console.log("sorting by: " + this.$sortingStrategy); var lastMatch; if (list.length > 1) { lastMatch = this.quicksort_helper(list, start, end); @@ -300,6 +339,8 @@ return nodes[int].getAttribute('folderPos').toLowerCase(); } else if (strategy === 'datemodified') { return nodes[int].getAttribute('mtime'); + }else if (strategy === 'customorder') { + return nodes[int].getAttribute('folderPosition'); } return nodes[int].getElementsByTagName('a')[0].innerHTML.toLowerCase(); }, diff --git a/apps/files/lib/Controller/ApiController.php b/apps/files/lib/Controller/ApiController.php index 7603f1a037164..80263c2c73ebf 100644 --- a/apps/files/lib/Controller/ApiController.php +++ b/apps/files/lib/Controller/ApiController.php @@ -55,7 +55,7 @@ class ApiController extends Controller { /** @var TagService */ private $tagService; - /** @var IManager **/ + /** @var IManager * */ private $shareManager; /** @var IPreview */ private $previewManager; @@ -108,7 +108,7 @@ public function __construct($appName, * @return DataResponse|FileDisplayResponse */ public function getThumbnail($x, $y, $file) { - if($x < 1 || $y < 1) { + if ($x < 1 || $y < 1) { return new DataResponse(['message' => 'Requested size must be numeric and a positive value.'], Http::STATUS_BAD_REQUEST); } @@ -207,7 +207,7 @@ public function getRecentFiles() { * @return DataResponse */ public function getFavoritesFolder() { - $nodes = $this->userFolder->searchByTag('_$!!$_', $this->userSession->getUser()->getUID()); + $nodes = $this->userFolder->searchByTag('_$!!$_', $this->userSession->getUser()->getUID()); $favorites = []; $i = 0; @@ -285,7 +285,7 @@ public function updateFileSorting($mode, $direction) { * @param bool $show */ public function showHiddenFiles($show) { - $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'show_hidden', (int) $show); + $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'show_hidden', (int)$show); return new Response(); } @@ -299,9 +299,9 @@ public function showHiddenFiles($show) { * @return Response */ public function showQuickAccess($show) { - $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'show_Quick_Access', (int) $show); + $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'show_Quick_Access', (int)$show); return new Response(); - } + } /** * quickaccess-sorting-strategy @@ -312,7 +312,7 @@ public function showQuickAccess($show) { * @return Response */ public function setSortingStrategy($strategy) { - $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_sorting_strategy', (String) $strategy); + $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_sorting_strategy', (String)$strategy); return new Response(); } @@ -336,7 +336,7 @@ public function getSortingStrategy() { * @return Response */ public function setReverseQuickaccess($reverse) { - $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_reverse_list', (int) $reverse); + $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_reverse_list', (int)$reverse); return new Response(); } @@ -348,7 +348,7 @@ public function setReverseQuickaccess($reverse) { * @return bool */ public function getReverseQuickaccess() { - if($this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_reverse_list', false)){ + if ($this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_reverse_list', false)) { return true; } return false; @@ -363,9 +363,10 @@ public function getReverseQuickaccess() { * @return Response */ public function setShowQuickaccessSettings($show) { - $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_show_settings', (int) $show); + $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_show_settings', (int)$show); return new Response(); } + /** * Get state for show sorting menu * @@ -374,10 +375,35 @@ public function setShowQuickaccessSettings($show) { * @return bool */ public function getShowQuickaccessSettings() { - if($this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_show_settings', false)){ + if ($this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_show_settings', false)) { return true; } return false; } + /** + * Set sorting-order for custom sorting + * + * @NoAdminRequired + * + * @param String $order + * @return Response + */ + public function setSortingOrder($order) { + $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_custom_sorting_order', (String)$order); + return new Response(); + } + + /** + * Get sorting-order for custom sorting + * + * @NoAdminRequired + * + * @param String + * @return String + */ + public function getSortingOrder() { + return $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_custom_sorting_order',""); + } + } diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index af9606aa0473e..383ab6ff08ab3 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -211,7 +211,7 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal 'order' => 5, 'name' => $this->l10n->t('Favorites'), 'sublist' => $favoritesSublistArray, - 'draggableSublist' => 'false', + 'draggableSublist' => 'true', 'defaultExpandedState' => 'true', 'enableMenuButton' => 0, ] From 24c2209fe8840e23da21e816c01a9987c53462bd Mon Sep 17 00:00:00 2001 From: fnuesse Date: Wed, 27 Jun 2018 00:06:30 +0200 Subject: [PATCH 56/75] Added custom order sorting option to quickaccess Signed-off-by: fnuesse --- apps/files/appinfo/routes.php | 7 ++++++- apps/files/js/navigation.js | 6 ++++++ apps/files/lib/Controller/ApiController.php | 14 +++++++++++++- apps/files/lib/Controller/ViewController.php | 7 ++++++- 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/apps/files/appinfo/routes.php b/apps/files/appinfo/routes.php index fa3739c668943..ec8c3e03b7ec4 100644 --- a/apps/files/appinfo/routes.php +++ b/apps/files/appinfo/routes.php @@ -78,7 +78,12 @@ ], [ 'name' => 'API#showQuickAccess', - 'url' => '/api/v1/quickaccess/show', + 'url' => '/api/v1/quickaccess/set/showList', + 'verb' => 'GET', + ], + [ + 'name' => 'API#getShowQuickAccess', + 'url' => '/api/v1/quickaccess/get/showList', 'verb' => 'GET', ], [ diff --git a/apps/files/js/navigation.js b/apps/files/js/navigation.js index c4895ef99d8e6..c89c66d6d5b38 100644 --- a/apps/files/js/navigation.js +++ b/apps/files/js/navigation.js @@ -210,6 +210,12 @@ collapsibleToggles.forEach(function foundToggle (item) { if (item[0] === ("#" + itemId)) { $(item[1]).toggleClass('open'); + var show=1; + if(!$(item[1]).hasClass('open')){ + show=0; + } + $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/set/showList"), {show: show}, function (data, status) { + }); } }); diff --git a/apps/files/lib/Controller/ApiController.php b/apps/files/lib/Controller/ApiController.php index 80263c2c73ebf..9269f336f35ca 100644 --- a/apps/files/lib/Controller/ApiController.php +++ b/apps/files/lib/Controller/ApiController.php @@ -303,6 +303,18 @@ public function showQuickAccess($show) { return new Response(); } + /** + * Toggle default for showing/hiding QuickAccess folder + * + * @NoAdminRequired + * + * @return String + */ + public function getShowQuickAccess() { + + return $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'show_Quick_Access', 1); + } + /** * quickaccess-sorting-strategy * @@ -403,7 +415,7 @@ public function setSortingOrder($order) { * @return String */ public function getSortingOrder() { - return $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_custom_sorting_order',""); + return $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_custom_sorting_order', ""); } } diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index 383ab6ff08ab3..7a07df678b2fe 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -202,6 +202,11 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal } + $defaultExpandedState='true'; + if(!$this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'show_Quick_Access', 1)){ + $defaultExpandedState='false'; + } + \OCA\Files\App::getNavigationManager()->add( [ 'id' => 'favorites', @@ -212,7 +217,7 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal 'name' => $this->l10n->t('Favorites'), 'sublist' => $favoritesSublistArray, 'draggableSublist' => 'true', - 'defaultExpandedState' => 'true', + 'defaultExpandedState' => $defaultExpandedState, 'enableMenuButton' => 0, ] ); From 63ce668ca822437e2063188011367d6ca9fa3250 Mon Sep 17 00:00:00 2001 From: fnuesse Date: Wed, 27 Jun 2018 00:10:52 +0200 Subject: [PATCH 57/75] Added fallback for custom ordering Signed-off-by: fnuesse --- apps/files/js/navigation.js | 9 ++++----- apps/files/lib/Controller/ViewController.php | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/apps/files/js/navigation.js b/apps/files/js/navigation.js index c89c66d6d5b38..b83cd82128c40 100644 --- a/apps/files/js/navigation.js +++ b/apps/files/js/navigation.js @@ -164,13 +164,8 @@ _setOnDrag: function () { var scope=this; $(function () { - var start_pos; if (document.getElementById(scope.$quickAccessListKey.toString()).hasAttribute("draggable")) { $("#sublist-favorites").sortable({ - start: function (event, ui) { - start_pos = ui.item.index(); - ui.item.data('start_pos', start_pos); - }, update: function (event, ui) { var list = document.getElementById(scope.$quickAccessListKey.toString()).getElementsByTagName('li'); var string=[]; @@ -184,6 +179,10 @@ order: resultorder}, function (data, status) {}); } }); + }else{ + if(scope.$sortingStrategy === 'customorder'){ + scope.$sortingStrategy = 'datemodified'; + } } }); }, diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index 7a07df678b2fe..165cf86a1ce2c 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -216,7 +216,7 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal 'order' => 5, 'name' => $this->l10n->t('Favorites'), 'sublist' => $favoritesSublistArray, - 'draggableSublist' => 'true', + 'draggableSublist' => 'false', 'defaultExpandedState' => $defaultExpandedState, 'enableMenuButton' => 0, ] From 2cfae6fb4fc34d51af4af3e1283416db8b7740a1 Mon Sep 17 00:00:00 2001 From: fnuesse Date: Wed, 27 Jun 2018 00:26:52 +0200 Subject: [PATCH 58/75] Set Quickaccess-ordering to custom order Signed-off-by: fnuesse --- apps/files/lib/Controller/ViewController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index 165cf86a1ce2c..7a07df678b2fe 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -216,7 +216,7 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal 'order' => 5, 'name' => $this->l10n->t('Favorites'), 'sublist' => $favoritesSublistArray, - 'draggableSublist' => 'false', + 'draggableSublist' => 'true', 'defaultExpandedState' => $defaultExpandedState, 'enableMenuButton' => 0, ] From c7a4bed3af4182d4dd8cf8b0641e1bd9dac67fdc Mon Sep 17 00:00:00 2001 From: fnuesse Date: Wed, 27 Jun 2018 00:35:28 +0200 Subject: [PATCH 59/75] Fix collapsible-Button when list was emptied (or got first element) Signed-off-by: fnuesse --- apps/files/js/tagsplugin.js | 6 +++--- apps/files/templates/appnavigation.php | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/apps/files/js/tagsplugin.js b/apps/files/js/tagsplugin.js index 7729a540d3218..43e18a88710cc 100644 --- a/apps/files/js/tagsplugin.js +++ b/apps/files/js/tagsplugin.js @@ -82,9 +82,9 @@ } if (listULElements.childElementCount === 0) { - var collapsibleButton = document.getElementById(collapsibleButtonId); + var collapsibleButton = document.getElementById("button-collapse-favorites"); collapsibleButton.style.display = 'none'; - $("#favorites-toggle").removeClass('collapsible'); + $("#button-collapse-parent-favorites").removeClass('collapsible'); } } @@ -119,7 +119,7 @@ var collapsibleButton = document.getElementById(collapsibleButtonId); collapsibleButton.style.display = ''; - $("#favorites-toggle").addClass('collapsible'); + $("#button-collapse-parent-favorites").addClass('collapsible'); } else { listLIElements[listLIElements.length - 1].after(innerTagLI); } diff --git a/apps/files/templates/appnavigation.php b/apps/files/templates/appnavigation.php index 56a84edf3b669..cc8afff7bc6a6 100644 --- a/apps/files/templates/appnavigation.php +++ b/apps/files/templates/appnavigation.php @@ -79,8 +79,7 @@ class="nav-icon- s NavigationElementMenu($item); if (isset($item['sublist'])) { ?> - +
        draggable="true"> Date: Wed, 27 Jun 2018 00:46:38 +0200 Subject: [PATCH 60/75] Fixed Bad url-generation in javascript for new quickaccessitems Signed-off-by: fnuesse --- apps/files/js/tagsplugin.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/files/js/tagsplugin.js b/apps/files/js/tagsplugin.js index 43e18a88710cc..853874f4e8376 100644 --- a/apps/files/js/tagsplugin.js +++ b/apps/files/js/tagsplugin.js @@ -102,13 +102,13 @@ var appName = appfolder.substring(appfolder.lastIndexOf("/") + 1, appfolder.length); var innerTagA = document.createElement('A'); - innerTagA.setAttribute("href", "/cloud/index.php/apps/files/?dir=" + appfolder); + innerTagA.setAttribute("href", OC.generateUrl('/apps/files/?dir=') + appfolder); innerTagA.setAttribute("class", "nav-icon-files svg"); innerTagA.innerHTML = appName; var length = listLIElements.length + 1; var innerTagLI = document.createElement('li'); - innerTagLI.setAttribute("data-id", "/cloud/index.php/apps/files/?dir=" + appfolder); + innerTagLI.setAttribute("data-id", OC.generateUrl('/apps/files/?dir=') + appfolder); innerTagLI.setAttribute("class", "nav-" + appName); innerTagLI.setAttribute("folderpos", length.toString()); innerTagLI.appendChild(innerTagA); From 8b3dbba4d919cf205f7eaeb08ed0190781557b8d Mon Sep 17 00:00:00 2001 From: fnuesse Date: Wed, 27 Jun 2018 08:25:59 +0200 Subject: [PATCH 61/75] Fixed vertical scrolling in sortable-list which leads to "hidden" navbar Signed-off-by: fnuesse --- apps/files/js/navigation.js | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/files/js/navigation.js b/apps/files/js/navigation.js index b83cd82128c40..ed10dc6edb9ec 100644 --- a/apps/files/js/navigation.js +++ b/apps/files/js/navigation.js @@ -166,6 +166,7 @@ $(function () { if (document.getElementById(scope.$quickAccessListKey.toString()).hasAttribute("draggable")) { $("#sublist-favorites").sortable({ + axis: "y", update: function (event, ui) { var list = document.getElementById(scope.$quickAccessListKey.toString()).getElementsByTagName('li'); var string=[]; From 71317075162ad53f7eeeb933e21e2f5d210b3d8c Mon Sep 17 00:00:00 2001 From: fnuesse Date: Wed, 27 Jun 2018 08:28:12 +0200 Subject: [PATCH 62/75] Removed unnessessary console logs Signed-off-by: fnuesse --- apps/files/js/navigation.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/apps/files/js/navigation.js b/apps/files/js/navigation.js index ed10dc6edb9ec..9dd4aaff6a7d7 100644 --- a/apps/files/js/navigation.js +++ b/apps/files/js/navigation.js @@ -175,7 +175,6 @@ string.push(Object); } var resultorder=JSON.stringify(string); - console.log(resultorder); $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/set/CustomSortingOrder"),{ order: resultorder}, function (data, status) {}); } @@ -263,9 +262,7 @@ } else if (this.$sortingStrategy === 'customorder') { var scope = this; $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/get/CustomSortingOrder"), function (data, status) { - console.log("load order:"); - var ordering=JSON.parse(data) - console.log(ordering); + var ordering=JSON.parse(data); for (var i = 0; i < ordering.length; i++) { for (var j = 0; j < list.length; j++) { if (scope.getCompareValue(list, j, 'alphabet').toLowerCase() === ordering[i].name.toLowerCase()) { From 6059ec9e2a8f964380fd61980d89088f2228e56c Mon Sep 17 00:00:00 2001 From: fnuesse Date: Wed, 27 Jun 2018 09:02:10 +0200 Subject: [PATCH 63/75] Fixed Bounds in custom sorting Signed-off-by: fnuesse --- apps/files/js/navigation.js | 1 + apps/files/templates/appnavigation.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/files/js/navigation.js b/apps/files/js/navigation.js index 9dd4aaff6a7d7..6693c47bfccc3 100644 --- a/apps/files/js/navigation.js +++ b/apps/files/js/navigation.js @@ -167,6 +167,7 @@ if (document.getElementById(scope.$quickAccessListKey.toString()).hasAttribute("draggable")) { $("#sublist-favorites").sortable({ axis: "y", + containment: "parent", update: function (event, ui) { var list = document.getElementById(scope.$quickAccessListKey.toString()).getElementsByTagName('li'); var string=[]; diff --git a/apps/files/templates/appnavigation.php b/apps/files/templates/appnavigation.php index cc8afff7bc6a6..9fb1849eac040 100644 --- a/apps/files/templates/appnavigation.php +++ b/apps/files/templates/appnavigation.php @@ -80,7 +80,7 @@ class="nav-icon- s if (isset($item['sublist'])) { ?> -
          draggable="true"> +
            draggable="true" style="resize: none;"> Date: Wed, 27 Jun 2018 09:11:59 +0200 Subject: [PATCH 64/75] Reformatted code Signed-off-by: fnuesse --- apps/files/lib/Controller/ViewController.php | 6 +++--- apps/files/templates/appnavigation.php | 11 ++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index 7a07df678b2fe..82f9ea000afa0 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -202,9 +202,9 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal } - $defaultExpandedState='true'; - if(!$this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'show_Quick_Access', 1)){ - $defaultExpandedState='false'; + $defaultExpandedState = 'true'; + if (!$this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'show_Quick_Access', 1)) { + $defaultExpandedState = 'false'; } \OCA\Files\App::getNavigationManager()->add( diff --git a/apps/files/templates/appnavigation.php b/apps/files/templates/appnavigation.php index 9fb1849eac040..0314c83ad08c8 100644 --- a/apps/files/templates/appnavigation.php +++ b/apps/files/templates/appnavigation.php @@ -5,7 +5,7 @@ $pinned = 0; foreach ($_['navigationItems'] as $item) { - $pinned = NavigationListElements($item, $pinned, $l); + $pinned = NavigationListElements($item, $l, $pinned); } ?> @@ -58,12 +58,12 @@ class="pinned
          • id="button-collapse-parent-" @@ -79,11 +79,12 @@ class="nav-icon- s NavigationElementMenu($item); if (isset($item['sublist'])) { ?> - +
              draggable="true" style="resize: none;">
            From b7fe0be64cdf083d5d91764c231ae61b4d6d948f Mon Sep 17 00:00:00 2001 From: fnuesse Date: Wed, 27 Jun 2018 10:39:23 +0200 Subject: [PATCH 65/75] Fixed horizontalscroll on sortable-list Fixed "stuck element" where you could not switch back to the original ordering in the sortable-list Signed-off-by: fnuesse --- apps/files/js/navigation.js | 18 ++++++++++++++++-- apps/files/templates/appnavigation.php | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/apps/files/js/navigation.js b/apps/files/js/navigation.js index 6693c47bfccc3..799e265bdffa3 100644 --- a/apps/files/js/navigation.js +++ b/apps/files/js/navigation.js @@ -163,11 +163,25 @@ */ _setOnDrag: function () { var scope=this; + var element = $("#sublist-favorites"); $(function () { if (document.getElementById(scope.$quickAccessListKey.toString()).hasAttribute("draggable")) { - $("#sublist-favorites").sortable({ + element.sortable({ axis: "y", containment: "parent", + scroll: false, + zIndex: 0, + opacity: 0.5, + delay: 150, + tolerance: "pointer", + start:function(event, ui){ + //Fix for offset + ui.helper[0].style.left ='0px'; + }, + stop: function( event, ui ) { + //Clean up offset + ui.item.removeAttr("style"); + }, update: function (event, ui) { var list = document.getElementById(scope.$quickAccessListKey.toString()).getElementsByTagName('li'); var string=[]; @@ -340,7 +354,7 @@ if (strategy === 'alphabet') { return nodes[int].getElementsByTagName('a')[0].innerHTML.toLowerCase(); } else if (strategy === 'date') { - return nodes[int].getAttribute('folderPos').toLowerCase(); + return nodes[int].getAttribute('folderPosition').toLowerCase(); } else if (strategy === 'datemodified') { return nodes[int].getAttribute('mtime'); }else if (strategy === 'customorder') { diff --git a/apps/files/templates/appnavigation.php b/apps/files/templates/appnavigation.php index 0314c83ad08c8..1302225c9193d 100644 --- a/apps/files/templates/appnavigation.php +++ b/apps/files/templates/appnavigation.php @@ -69,7 +69,7 @@ function NavigationListElements($item, $l, $pinned) {
          • id="button-collapse-parent-" data-id=" " class="nav- open" - folderPos="" > + folderposition="" > From c395b8ca6113a6447fbbaf32dd3e1c3c86bef11d Mon Sep 17 00:00:00 2001 From: fnuesse Date: Wed, 27 Jun 2018 10:40:32 +0200 Subject: [PATCH 66/75] Added drop-animation to sortable-list Signed-off-by: fnuesse --- apps/files/js/navigation.js | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/files/js/navigation.js b/apps/files/js/navigation.js index 799e265bdffa3..b06986d4cf12c 100644 --- a/apps/files/js/navigation.js +++ b/apps/files/js/navigation.js @@ -174,6 +174,7 @@ opacity: 0.5, delay: 150, tolerance: "pointer", + revert: 0.05, start:function(event, ui){ //Fix for offset ui.helper[0].style.left ='0px'; From 8b9a6cba1273bbfaa8f4254cfdceb0828a08e2be Mon Sep 17 00:00:00 2001 From: fnuesse Date: Thu, 28 Jun 2018 09:20:55 +0200 Subject: [PATCH 67/75] Added icon-change on drag Signed-off-by: fnuesse --- apps/files/js/navigation.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/apps/files/js/navigation.js b/apps/files/js/navigation.js index b06986d4cf12c..d17c09bebd905 100644 --- a/apps/files/js/navigation.js +++ b/apps/files/js/navigation.js @@ -172,16 +172,34 @@ scroll: false, zIndex: 0, opacity: 0.5, - delay: 150, tolerance: "pointer", - revert: 0.05, + //revert: 0.05, + //delay: 150, start:function(event, ui){ //Fix for offset ui.helper[0].style.left ='0px'; + + //Change Icon while dragging + var list = document.getElementById(scope.$quickAccessListKey).getElementsByTagName('li'); + for (var j = 0; j < list.length; j++) { + if (!(typeof list[j].getElementsByTagName('a')[0] === 'undefined')) { + list[j].getElementsByTagName('a')[0].classList.remove("nav-icon-files"); + list[j].getElementsByTagName('a')[0].classList.add('icon-menu'); + } + } }, stop: function( event, ui ) { //Clean up offset ui.item.removeAttr("style"); + + //Change Icon back after dragging + var list = document.getElementById(scope.$quickAccessListKey.toString()).getElementsByTagName('li'); + for (var j = 0; j < list.length; j++) { + if (!(typeof list[j].getElementsByTagName('a')[0] === 'undefined')) { + list[j].getElementsByTagName('a')[0].classList.add("nav-icon-files"); + list[j].getElementsByTagName('a')[0].classList.remove('icon-menu'); + } + } }, update: function (event, ui) { var list = document.getElementById(scope.$quickAccessListKey.toString()).getElementsByTagName('li'); From 80031f78824196902ac316246b274ef3f2b26c32 Mon Sep 17 00:00:00 2001 From: fnuesse Date: Tue, 3 Jul 2018 11:29:30 +0200 Subject: [PATCH 68/75] Fixed Navbar-closing in app when favorites-list is toggled on mobile Signed-off-by: fnuesse --- apps/files/templates/appnavigation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/files/templates/appnavigation.php b/apps/files/templates/appnavigation.php index 1302225c9193d..254855ade4e98 100644 --- a/apps/files/templates/appnavigation.php +++ b/apps/files/templates/appnavigation.php @@ -80,7 +80,7 @@ class="nav-icon- s if (isset($item['sublist'])) { ?> + class="collapse app-navigation-noclose" style="display: none" >
              draggable="true" style="resize: none;"> Date: Tue, 3 Jul 2018 11:31:06 +0200 Subject: [PATCH 69/75] Refactored Code Signed-off-by: fnuesse --- apps/files/js/navigation.js | 40 +++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/apps/files/js/navigation.js b/apps/files/js/navigation.js index d17c09bebd905..4df09237b82e1 100644 --- a/apps/files/js/navigation.js +++ b/apps/files/js/navigation.js @@ -162,7 +162,7 @@ * Event handler for when dragging an item */ _setOnDrag: function () { - var scope=this; + var scope = this; var element = $("#sublist-favorites"); $(function () { if (document.getElementById(scope.$quickAccessListKey.toString()).hasAttribute("draggable")) { @@ -175,9 +175,9 @@ tolerance: "pointer", //revert: 0.05, //delay: 150, - start:function(event, ui){ + start: function (event, ui) { //Fix for offset - ui.helper[0].style.left ='0px'; + ui.helper[0].style.left = '0px'; //Change Icon while dragging var list = document.getElementById(scope.$quickAccessListKey).getElementsByTagName('li'); @@ -188,7 +188,7 @@ } } }, - stop: function( event, ui ) { + stop: function (event, ui) { //Clean up offset ui.item.removeAttr("style"); @@ -203,18 +203,23 @@ }, update: function (event, ui) { var list = document.getElementById(scope.$quickAccessListKey.toString()).getElementsByTagName('li'); - var string=[]; + var string = []; for (var j = 0; j < list.length; j++) { - var Object = {id:j, name:scope.getCompareValue(list,j,'alphabet') }; + var Object = { + id: j, + name: scope.getCompareValue(list, j, 'alphabet') + }; string.push(Object); } - var resultorder=JSON.stringify(string); - $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/set/CustomSortingOrder"),{ - order: resultorder}, function (data, status) {}); + var resultorder = JSON.stringify(string); + $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/set/CustomSortingOrder"), { + order: resultorder + }, function (data, status) { + }); } }); - }else{ - if(scope.$sortingStrategy === 'customorder'){ + } else { + if (scope.$sortingStrategy === 'customorder') { scope.$sortingStrategy = 'datemodified'; } } @@ -239,13 +244,12 @@ // and the parent, which should be toggled at the first arrayindex. dotmenuToggles.push(["#dotmenu-button-favorites", "dotmenu-content-favorites"]); - collapsibleToggles.forEach(function foundToggle (item) { if (item[0] === ("#" + itemId)) { $(item[1]).toggleClass('open'); - var show=1; - if(!$(item[1]).hasClass('open')){ - show=0; + var show = 1; + if (!$(item[1]).hasClass('open')) { + show = 0; } $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/set/showList"), {show: show}, function (data, status) { }); @@ -288,7 +292,6 @@ scope.reverse(list); }); - } else if (this.$sortingStrategy === 'alphabet') { sort = true; } else if (this.$sortingStrategy === 'date') { @@ -296,7 +299,7 @@ } else if (this.$sortingStrategy === 'customorder') { var scope = this; $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/get/CustomSortingOrder"), function (data, status) { - var ordering=JSON.parse(data); + var ordering = JSON.parse(data); for (var i = 0; i < ordering.length; i++) { for (var j = 0; j < list.length; j++) { if (scope.getCompareValue(list, j, 'alphabet').toLowerCase() === ordering[i].name.toLowerCase()) { @@ -306,7 +309,6 @@ } scope.QuickSort(list, 0, list.length - 1); }); - sort = false; } @@ -376,7 +378,7 @@ return nodes[int].getAttribute('folderPosition').toLowerCase(); } else if (strategy === 'datemodified') { return nodes[int].getAttribute('mtime'); - }else if (strategy === 'customorder') { + } else if (strategy === 'customorder') { return nodes[int].getAttribute('folderPosition'); } return nodes[int].getElementsByTagName('a')[0].innerHTML.toLowerCase(); From e79f749b171bd99e27335d3f2f95a39a47d12435 Mon Sep 17 00:00:00 2001 From: fnuesse Date: Thu, 5 Jul 2018 14:44:37 +0200 Subject: [PATCH 70/75] Changed to alphabetical sorting Signed-off-by: fnuesse --- apps/files/js/navigation.js | 8 ++++++-- apps/files/lib/Controller/ApiController.php | 2 +- apps/files/lib/Controller/ViewController.php | 9 ++++++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/apps/files/js/navigation.js b/apps/files/js/navigation.js index 4df09237b82e1..207f9b1c2067a 100644 --- a/apps/files/js/navigation.js +++ b/apps/files/js/navigation.js @@ -49,7 +49,7 @@ * alphabet * */ - $sortingStrategy: 'customorder', + $sortingStrategy: 'alphabet', /** * Key for the quick-acces-list @@ -66,8 +66,12 @@ this._activeItem = null; this.$currentContent = null; this._setupEvents(); - this.setInitialQuickaccessSettings(); + var scope=this; + $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/get/SortingStrategy"), function (data, status) { + scope.$sortingStrategy=data; + scope.setInitialQuickaccessSettings(); + }); }, diff --git a/apps/files/lib/Controller/ApiController.php b/apps/files/lib/Controller/ApiController.php index 9269f336f35ca..dfc1eb9c7f0a1 100644 --- a/apps/files/lib/Controller/ApiController.php +++ b/apps/files/lib/Controller/ApiController.php @@ -336,7 +336,7 @@ public function setSortingStrategy($strategy) { * @return String */ public function getSortingStrategy() { - return $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_sorting_strategy', 'date'); + return $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_sorting_strategy', 'alphabet'); } /** diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index 82f9ea000afa0..13b33b96cc89e 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -207,6 +207,13 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal $defaultExpandedState = 'false'; } + $quickAccessDraggable = 'false'; + //See Javascript navigation.js for possible sorting strategies + if($this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_sorting_strategy', 'alphabet')=='customorder'){ + $quickAccessDraggable = 'true'; + } + + \OCA\Files\App::getNavigationManager()->add( [ 'id' => 'favorites', @@ -216,7 +223,7 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal 'order' => 5, 'name' => $this->l10n->t('Favorites'), 'sublist' => $favoritesSublistArray, - 'draggableSublist' => 'true', + 'draggableSublist' => $quickAccessDraggable, 'defaultExpandedState' => $defaultExpandedState, 'enableMenuButton' => 0, ] From 9809a7e8e2fc0225d17534e35432df9f16bdbe38 Mon Sep 17 00:00:00 2001 From: fnuesse Date: Thu, 5 Jul 2018 14:54:33 +0200 Subject: [PATCH 71/75] Fixed deletion of folder with identical names Signed-off-by: fnuesse --- apps/files/js/tagsplugin.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/files/js/tagsplugin.js b/apps/files/js/tagsplugin.js index 853874f4e8376..b9874e847b2cb 100644 --- a/apps/files/js/tagsplugin.js +++ b/apps/files/js/tagsplugin.js @@ -73,10 +73,11 @@ var collapsibleButtonId = 'button-collapse-favorites'; var listULElements = document.getElementById(quickAccessList); var listLIElements = listULElements.getElementsByTagName('li'); - var appName = appfolder.substring(appfolder.lastIndexOf("/") + 1, appfolder.length); + //var appName = appfolder.substring(appfolder.lastIndexOf("/") + 1, appfolder.length); + var appName = appfolder.substring(1, appfolder.length); for (var i = 0; i <= listLIElements.length - 1; i++) { - if (appName === listLIElements[i].getElementsByTagName('a')[0].innerHTML) { + if ( listLIElements[i].getElementsByTagName('a')[0].href.endsWith("dir="+appName)) { listLIElements[i].remove(); } } From 372122829379d4cdec5c50c95ba9b09025af6575 Mon Sep 17 00:00:00 2001 From: fnuesse Date: Thu, 5 Jul 2018 15:20:12 +0200 Subject: [PATCH 72/75] Removed ability to add files to the quickaccess Signed-off-by: fnuesse --- apps/files/appinfo/routes.php | 5 ++++ apps/files/js/tagsplugin.js | 33 +++++++++++++-------- apps/files/lib/Controller/ApiController.php | 16 +++++++++- 3 files changed, 40 insertions(+), 14 deletions(-) diff --git a/apps/files/appinfo/routes.php b/apps/files/appinfo/routes.php index ec8c3e03b7ec4..a9d8ba0a1b96f 100644 --- a/apps/files/appinfo/routes.php +++ b/apps/files/appinfo/routes.php @@ -131,6 +131,11 @@ 'url' => '/api/v1/quickaccess/get/CustomSortingOrder', 'verb' => 'GET', ], + [ + 'name' => 'API#getNodeType', + 'url' => '/api/v1/quickaccess/get/NodeType', + 'verb' => 'GET', + ], ] ] ); diff --git a/apps/files/js/tagsplugin.js b/apps/files/js/tagsplugin.js index b9874e847b2cb..4f7d5a29fe173 100644 --- a/apps/files/js/tagsplugin.js +++ b/apps/files/js/tagsplugin.js @@ -73,11 +73,10 @@ var collapsibleButtonId = 'button-collapse-favorites'; var listULElements = document.getElementById(quickAccessList); var listLIElements = listULElements.getElementsByTagName('li'); - //var appName = appfolder.substring(appfolder.lastIndexOf("/") + 1, appfolder.length); var appName = appfolder.substring(1, appfolder.length); for (var i = 0; i <= listLIElements.length - 1; i++) { - if ( listLIElements[i].getElementsByTagName('a')[0].href.endsWith("dir="+appName)) { + if (listLIElements[i].getElementsByTagName('a')[0].href.endsWith("dir=" + appName)) { listLIElements[i].remove(); } } @@ -114,16 +113,23 @@ innerTagLI.setAttribute("folderpos", length.toString()); innerTagLI.appendChild(innerTagA); - - if (listULElements.childElementCount <= 0) { - listULElements.appendChild(innerTagLI); - var collapsibleButton = document.getElementById(collapsibleButtonId); - collapsibleButton.style.display = ''; - - $("#button-collapse-parent-favorites").addClass('collapsible'); - } else { - listLIElements[listLIElements.length - 1].after(innerTagLI); - } + console.log("fetch: "+appfolder); + $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/get/NodeType"),{folderpath: appfolder}, function (data, status) { + console.log(status); + console.log(data); + if (data !== "file") { + if (listULElements.childElementCount <= 0) { + listULElements.appendChild(innerTagLI); + var collapsibleButton = document.getElementById(collapsibleButtonId); + collapsibleButton.style.display = ''; + + $("#button-collapse-parent-favorites").addClass('collapsible'); + } else { + listLIElements[listLIElements.length - 1].after(innerTagLI); + } + } + } + ); } OCA.Files = OCA.Files || {}; @@ -328,6 +334,7 @@ }); } }; -})(OCA); +}) +(OCA); OC.Plugins.register('OCA.Files.FileList', OCA.Files.TagsPlugin); diff --git a/apps/files/lib/Controller/ApiController.php b/apps/files/lib/Controller/ApiController.php index dfc1eb9c7f0a1..3738358bfb0ca 100644 --- a/apps/files/lib/Controller/ApiController.php +++ b/apps/files/lib/Controller/ApiController.php @@ -215,6 +215,7 @@ public function getFavoritesFolder() { $favorites[$i]['id'] = $node->getId(); $favorites[$i]['name'] = $node->getName(); + $favorites[$i]['path'] = $node->getInternalPath(); $favorites[$i]['mtime'] = $node->getMTime(); $i++; } @@ -411,11 +412,24 @@ public function setSortingOrder($order) { * * @NoAdminRequired * - * @param String * @return String */ public function getSortingOrder() { return $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_custom_sorting_order', ""); } + /** + * Get sorting-order for custom sorting + * + * @NoAdminRequired + * + * @param String + * @return String + */ + public function getNodeType($folderpath) { + $node = $this->userFolder->get($folderpath); + return $node->getType(); + } + + } From c2fb31d3f27062630b55ea2accd19c159dbd2192 Mon Sep 17 00:00:00 2001 From: fnuesse Date: Thu, 5 Jul 2018 15:37:49 +0200 Subject: [PATCH 73/75] Fixed wrong path-generation when added from favorites-star Signed-off-by: fnuesse --- apps/files/js/tagsplugin.js | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/apps/files/js/tagsplugin.js b/apps/files/js/tagsplugin.js index 4f7d5a29fe173..68e65b080f39e 100644 --- a/apps/files/js/tagsplugin.js +++ b/apps/files/js/tagsplugin.js @@ -73,10 +73,12 @@ var collapsibleButtonId = 'button-collapse-favorites'; var listULElements = document.getElementById(quickAccessList); var listLIElements = listULElements.getElementsByTagName('li'); - var appName = appfolder.substring(1, appfolder.length); for (var i = 0; i <= listLIElements.length - 1; i++) { - if (listLIElements[i].getElementsByTagName('a')[0].href.endsWith("dir=" + appName)) { + console.log(listLIElements[i].getElementsByTagName('a')[0].href); + if (listLIElements[i].getElementsByTagName('a')[0].href.endsWith("dir=" + appfolder)) { + console.log("f "+listLIElements[i].getElementsByTagName('a')[0].href); + listLIElements[i].remove(); } } @@ -100,24 +102,28 @@ var listLIElements = listULElements.getElementsByTagName('li'); var appName = appfolder.substring(appfolder.lastIndexOf("/") + 1, appfolder.length); + var apppath=appfolder; + + if(appfolder.startsWith("//")){ + apppath=appfolder.substring(1, appfolder.length); + } + var url=OC.generateUrl('/apps/files/?dir=')+apppath; + var innerTagA = document.createElement('A'); - innerTagA.setAttribute("href", OC.generateUrl('/apps/files/?dir=') + appfolder); + innerTagA.setAttribute("href", url); innerTagA.setAttribute("class", "nav-icon-files svg"); innerTagA.innerHTML = appName; var length = listLIElements.length + 1; var innerTagLI = document.createElement('li'); - innerTagLI.setAttribute("data-id", OC.generateUrl('/apps/files/?dir=') + appfolder); + innerTagLI.setAttribute("data-id", url); innerTagLI.setAttribute("class", "nav-" + appName); innerTagLI.setAttribute("folderpos", length.toString()); innerTagLI.appendChild(innerTagA); - console.log("fetch: "+appfolder); - $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/get/NodeType"),{folderpath: appfolder}, function (data, status) { - console.log(status); - console.log(data); - if (data !== "file") { + $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/get/NodeType"),{folderpath: apppath}, function (data, status) { + if (data === "dir") { if (listULElements.childElementCount <= 0) { listULElements.appendChild(innerTagLI); var collapsibleButton = document.getElementById(collapsibleButtonId); From abec4ea6ccac2c85409990c851155b8de18f63ac Mon Sep 17 00:00:00 2001 From: fnuesse Date: Thu, 5 Jul 2018 18:49:41 +0200 Subject: [PATCH 74/75] Removed Element from navbar when favorite-star in detailview is toggled off Signed-off-by: fnuesse --- apps/files/js/tagsplugin.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/files/js/tagsplugin.js b/apps/files/js/tagsplugin.js index 68e65b080f39e..3a1378cc9ad7e 100644 --- a/apps/files/js/tagsplugin.js +++ b/apps/files/js/tagsplugin.js @@ -74,11 +74,13 @@ var listULElements = document.getElementById(quickAccessList); var listLIElements = listULElements.getElementsByTagName('li'); - for (var i = 0; i <= listLIElements.length - 1; i++) { - console.log(listLIElements[i].getElementsByTagName('a')[0].href); - if (listLIElements[i].getElementsByTagName('a')[0].href.endsWith("dir=" + appfolder)) { - console.log("f "+listLIElements[i].getElementsByTagName('a')[0].href); + var apppath=appfolder; + if(appfolder.startsWith("//")){ + apppath=appfolder.substring(1, appfolder.length); + } + for (var i = 0; i <= listLIElements.length - 1; i++) { + if (listLIElements[i].getElementsByTagName('a')[0].href.endsWith("dir=" + apppath)) { listLIElements[i].remove(); } } From d9d6285d324dab6830dfe04ccf37b4c9d28b00f0 Mon Sep 17 00:00:00 2001 From: fnuesse Date: Sun, 15 Jul 2018 18:49:33 +0200 Subject: [PATCH 75/75] removed sorting code from files app Signed-off-by: fnuesse --- apps/files/js/navigation.js | 96 +-------------- apps/files/lib/Controller/ApiController.php | 127 +------------------- 2 files changed, 4 insertions(+), 219 deletions(-) diff --git a/apps/files/js/navigation.js b/apps/files/js/navigation.js index d4fa06cb45ef5..cb336b4ba3adc 100644 --- a/apps/files/js/navigation.js +++ b/apps/files/js/navigation.js @@ -39,18 +39,6 @@ */ $currentContent: null, - /** - * Strategy by which the quickaccesslist is sorted - * - * Possible Strategies: - * customorder - * datemodified - * date - * alphabet - * - */ - $sortingStrategy: 'alphabet', - /** * Key for the quick-acces-list */ @@ -66,13 +54,7 @@ this._activeItem = null; this.$currentContent = null; this._setupEvents(); - - var scope=this; - $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/get/SortingStrategy"), function (data, status) { - scope.$sortingStrategy=data; - scope.setInitialQuickaccessSettings(); - }); - + this.setInitialQuickaccessSettings(); }, /** @@ -210,56 +192,8 @@ * Sort initially as setup of sidebar for QuickAccess */ setInitialQuickaccessSettings: function () { - - var quickAccesKey = this.$quickAccessListKey; - var list = document.getElementById(quickAccesKey).getElementsByTagName('li'); - - var sort = true; - var reverse = false; - if (this.$sortingStrategy === 'datemodified') { - sort = false; - reverse = false; - - var scope = this; - $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/get/FavoriteFolders/"), function (data, status) { - for (var i = 0; i < data.favoriteFolders.length; i++) { - for (var j = 0; j < list.length; j++) { - if (scope.getCompareValue(list, j, 'alphabet').toLowerCase() === data.favoriteFolders[i].name.toLowerCase()) { - list[j].setAttribute("mtime", data.favoriteFolders[i].mtime); - } - } - } - scope.QuickSort(list, 0, list.length - 1); - scope.reverse(list); - }); - - } else if (this.$sortingStrategy === 'alphabet') { - sort = true; - } else if (this.$sortingStrategy === 'date') { - sort = true; - } else if (this.$sortingStrategy === 'customorder') { - var scope = this; - $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/get/CustomSortingOrder"), function (data, status) { - var ordering = JSON.parse(data); - for (var i = 0; i < ordering.length; i++) { - for (var j = 0; j < list.length; j++) { - if (scope.getCompareValue(list, j, 'alphabet').toLowerCase() === ordering[i].name.toLowerCase()) { - list[j].setAttribute("folderPosition", ordering[i].id); - } - } - } - scope.QuickSort(list, 0, list.length - 1); - }); - sort = false; - } - - if (sort) { - this.QuickSort(list, 0, list.length - 1); - } - if (reverse) { - this.reverse(list); - } - + var list = document.getElementById( this.$quickAccessListKey).getElementsByTagName('li'); + this.QuickSort(list, 0, list.length - 1); }, /** @@ -308,21 +242,7 @@ * This method allows easy access to the element which is sorted by. */ getCompareValue: function (nodes, int, strategy) { - - if ((typeof strategy === 'undefined')) { - strategy = this.$sortingStrategy; - } - - if (strategy === 'alphabet') { return nodes[int].getElementsByTagName('a')[0].innerHTML.toLowerCase(); - } else if (strategy === 'date') { - return nodes[int].getAttribute('folderPosition').toLowerCase(); - } else if (strategy === 'datemodified') { - return nodes[int].getAttribute('mtime'); - } else if (strategy === 'customorder') { - return nodes[int].getAttribute('folderPosition'); - } - return nodes[int].getElementsByTagName('a')[0].innerHTML.toLowerCase(); }, /** @@ -332,16 +252,6 @@ swap: function (list, j, i) { list[i].before(list[j]); list[j].before(list[i]); - }, - - /** - * Reverse QuickAccess-List - */ - reverse: function (list) { - var len = list.length - 1; - for (var i = 0; i < len / 2; i++) { - this.swap(list, i, len - i); - } } }; diff --git a/apps/files/lib/Controller/ApiController.php b/apps/files/lib/Controller/ApiController.php index aae1bec2e7894..20d900e7a08b6 100644 --- a/apps/files/lib/Controller/ApiController.php +++ b/apps/files/lib/Controller/ApiController.php @@ -199,30 +199,6 @@ public function getRecentFiles() { return new DataResponse(['files' => $files]); } - /** - * Returns a list of favorites modifed folder. - * - * @NoAdminRequired - * - * @return DataResponse - */ - public function getFavoritesFolder() { - $nodes = $this->userFolder->searchByTag('_$!!$_', $this->userSession->getUser()->getUID()); - - $favorites = []; - $i = 0; - foreach ($nodes as &$node) { - - $favorites[$i]['id'] = $node->getId(); - $favorites[$i]['name'] = $node->getName(); - $favorites[$i]['path'] = $node->getInternalPath(); - $favorites[$i]['mtime'] = $node->getMTime(); - $i++; - } - - return new DataResponse(['favoriteFolders' => $favorites]); - } - /** * Return a list of share types for outgoing shares * @@ -284,6 +260,7 @@ public function updateFileSorting($mode, $direction) { * @NoAdminRequired * * @param bool $show + * @return Response */ public function showHiddenFiles($show) { $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'show_hidden', (int)$show); @@ -316,108 +293,6 @@ public function getShowQuickAccess() { return $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'show_Quick_Access', 0); } - /** - * quickaccess-sorting-strategy - * - * @NoAdminRequired - * - * @param string $strategy - * @return Response - */ - public function setSortingStrategy($strategy) { - $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_sorting_strategy', (String)$strategy); - return new Response(); - } - - /** - * Get reverse-state for quickaccess-list - * - * @NoAdminRequired - * - * @return String - */ - public function getSortingStrategy() { - return $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_sorting_strategy', 'alphabet'); - } - - /** - * Toggle for reverse quickaccess-list - * - * @NoAdminRequired - * - * @param bool $reverse - * @return Response - */ - public function setReverseQuickaccess($reverse) { - $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_reverse_list', (int)$reverse); - return new Response(); - } - - /** - * Get reverse-state for quickaccess-list - * - * @NoAdminRequired - * - * @return bool - */ - public function getReverseQuickaccess() { - if ($this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_reverse_list', false)) { - return true; - } - return false; - } - - /** - * Set state for show sorting menu - * - * @NoAdminRequired - * - * @param bool $show - * @return Response - */ - public function setShowQuickaccessSettings($show) { - $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_show_settings', (int)$show); - return new Response(); - } - - /** - * Get state for show sorting menu - * - * @NoAdminRequired - * - * @return bool - */ - public function getShowQuickaccessSettings() { - if ($this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_show_settings', false)) { - return true; - } - return false; - } - - /** - * Set sorting-order for custom sorting - * - * @NoAdminRequired - * - * @param String $order - * @return Response - */ - public function setSortingOrder($order) { - $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_custom_sorting_order', (String)$order); - return new Response(); - } - - /** - * Get sorting-order for custom sorting - * - * @NoAdminRequired - * - * @return String - */ - public function getSortingOrder() { - return $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_custom_sorting_order', ""); - } - /** * Get sorting-order for custom sorting *