Skip to content

Commit fd61207

Browse files
newhintonrullzer
authored andcommitted
Cleanup of leftover-sorting-code from quickaccess-feature #9714 #9720
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
1 parent 71028fd commit fd61207

3 files changed

Lines changed: 2 additions & 279 deletions

File tree

apps/files/appinfo/routes.php

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -81,56 +81,6 @@
8181
'url' => '/api/v1/toggleShowFolder/{key}',
8282
'verb' => 'POST'
8383
],
84-
[
85-
'name' => 'API#getShowQuickaccessSettings',
86-
'url' => '/api/v1/quickaccess/showsettings',
87-
'verb' => 'GET',
88-
],
89-
[
90-
'name' => 'API#setShowQuickaccessSettings',
91-
'url' => '/api/v1/quickaccess/set/showsettings',
92-
'verb' => 'GET',
93-
],
94-
[
95-
'name' => 'API#setSortingStrategy',
96-
'url' => '/api/v1/quickaccess/set/SortingStrategy',
97-
'verb' => 'GET',
98-
],
99-
[
100-
'name' => 'API#setReverseQuickaccess',
101-
'url' => '/api/v1/quickaccess/set/ReverseList',
102-
'verb' => 'GET',
103-
],
104-
[
105-
'name' => 'API#getSortingStrategy',
106-
'url' => '/api/v1/quickaccess/get/SortingStrategy',
107-
'verb' => 'GET',
108-
],
109-
[
110-
'name' => 'API#getReverseQuickaccess',
111-
'url' => '/api/v1/quickaccess/get/ReverseList',
112-
'verb' => 'GET',
113-
],
114-
[
115-
'name' => 'API#getFavoritesFolder',
116-
'url' => '/api/v1/quickaccess/get/FavoriteFolders/',
117-
'verb' => 'GET'
118-
],
119-
[
120-
'name' => 'API#setSortingOrder',
121-
'url' => '/api/v1/quickaccess/set/CustomSortingOrder',
122-
'verb' => 'GET',
123-
],
124-
[
125-
'name' => 'API#getSortingOrder',
126-
'url' => '/api/v1/quickaccess/get/CustomSortingOrder',
127-
'verb' => 'GET',
128-
],
129-
[
130-
'name' => 'API#getNodeType',
131-
'url' => '/api/v1/quickaccess/get/NodeType',
132-
'verb' => 'GET',
133-
],
13484
]
13585
]
13686
);

apps/files/js/navigation.js

Lines changed: 2 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,6 @@
3939
*/
4040
$currentContent: null,
4141

42-
/**
43-
* Strategy by which the quickaccesslist is sorted
44-
*
45-
* Possible Strategies:
46-
* customorder
47-
* datemodified
48-
* date
49-
* alphabet
50-
*
51-
*/
52-
$sortingStrategy: 'alphabet',
53-
5442
/**
5543
* Key for the quick-acces-list
5644
*/
@@ -67,12 +55,7 @@
6755
this.$currentContent = null;
6856
this._setupEvents();
6957

70-
var scope=this;
71-
$.get(OC.generateUrl("/apps/files/api/v1/quickaccess/get/SortingStrategy"), function (data, status) {
72-
scope.$sortingStrategy=data;
73-
scope.setInitialQuickaccessSettings();
74-
});
75-
58+
this.setInitialQuickaccessSettings();
7659
},
7760

7861
/**
@@ -198,56 +181,9 @@
198181
* Sort initially as setup of sidebar for QuickAccess
199182
*/
200183
setInitialQuickaccessSettings: function () {
201-
202184
var quickAccesKey = this.$quickAccessListKey;
203185
var list = document.getElementById(quickAccesKey).getElementsByTagName('li');
204-
205-
var sort = true;
206-
var reverse = false;
207-
if (this.$sortingStrategy === 'datemodified') {
208-
sort = false;
209-
reverse = false;
210-
211-
var scope = this;
212-
$.get(OC.generateUrl("/apps/files/api/v1/quickaccess/get/FavoriteFolders/"), function (data, status) {
213-
for (var i = 0; i < data.favoriteFolders.length; i++) {
214-
for (var j = 0; j < list.length; j++) {
215-
if (scope.getCompareValue(list, j, 'alphabet').toLowerCase() === data.favoriteFolders[i].name.toLowerCase()) {
216-
list[j].setAttribute("mtime", data.favoriteFolders[i].mtime);
217-
}
218-
}
219-
}
220-
scope.QuickSort(list, 0, list.length - 1);
221-
scope.reverse(list);
222-
});
223-
224-
} else if (this.$sortingStrategy === 'alphabet') {
225-
sort = true;
226-
} else if (this.$sortingStrategy === 'date') {
227-
sort = true;
228-
} else if (this.$sortingStrategy === 'customorder') {
229-
var scope = this;
230-
$.get(OC.generateUrl("/apps/files/api/v1/quickaccess/get/CustomSortingOrder"), function (data, status) {
231-
var ordering = JSON.parse(data);
232-
for (var i = 0; i < ordering.length; i++) {
233-
for (var j = 0; j < list.length; j++) {
234-
if (scope.getCompareValue(list, j, 'alphabet').toLowerCase() === ordering[i].name.toLowerCase()) {
235-
list[j].setAttribute("folderPosition", ordering[i].id);
236-
}
237-
}
238-
}
239-
scope.QuickSort(list, 0, list.length - 1);
240-
});
241-
sort = false;
242-
}
243-
244-
if (sort) {
245-
this.QuickSort(list, 0, list.length - 1);
246-
}
247-
if (reverse) {
248-
this.reverse(list);
249-
}
250-
186+
this.QuickSort(list, 0, list.length - 1);
251187
},
252188

253189
/**
@@ -296,21 +232,7 @@
296232
* This method allows easy access to the element which is sorted by.
297233
*/
298234
getCompareValue: function (nodes, int, strategy) {
299-
300-
if ((typeof strategy === 'undefined')) {
301-
strategy = this.$sortingStrategy;
302-
}
303-
304-
if (strategy === 'alphabet') {
305235
return nodes[int].getElementsByTagName('a')[0].innerHTML.toLowerCase();
306-
} else if (strategy === 'date') {
307-
return nodes[int].getAttribute('folderPosition').toLowerCase();
308-
} else if (strategy === 'datemodified') {
309-
return nodes[int].getAttribute('mtime');
310-
} else if (strategy === 'customorder') {
311-
return nodes[int].getAttribute('folderPosition');
312-
}
313-
return nodes[int].getElementsByTagName('a')[0].innerHTML.toLowerCase();
314236
},
315237

316238
/**
@@ -320,16 +242,6 @@
320242
swap: function (list, j, i) {
321243
list[i].before(list[j]);
322244
list[j].before(list[i]);
323-
},
324-
325-
/**
326-
* Reverse QuickAccess-List
327-
*/
328-
reverse: function (list) {
329-
var len = list.length - 1;
330-
for (var i = 0; i < len / 2; i++) {
331-
this.swap(list, i, len - i);
332-
}
333245
}
334246

335247
};

apps/files/lib/Controller/ApiController.php

Lines changed: 0 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -199,30 +199,6 @@ public function getRecentFiles() {
199199
return new DataResponse(['files' => $files]);
200200
}
201201

202-
/**
203-
* Returns a list of favorites modifed folder.
204-
*
205-
* @NoAdminRequired
206-
*
207-
* @return DataResponse
208-
*/
209-
public function getFavoritesFolder() {
210-
$nodes = $this->userFolder->searchByTag('_$!<Favorite>!$_', $this->userSession->getUser()->getUID());
211-
212-
$favorites = [];
213-
$i = 0;
214-
foreach ($nodes as &$node) {
215-
216-
$favorites[$i]['id'] = $node->getId();
217-
$favorites[$i]['name'] = $node->getName();
218-
$favorites[$i]['path'] = $node->getInternalPath();
219-
$favorites[$i]['mtime'] = $node->getMTime();
220-
$i++;
221-
}
222-
223-
return new DataResponse(['favoriteFolders' => $favorites]);
224-
}
225-
226202
/**
227203
* Return a list of share types for outgoing shares
228204
*
@@ -315,120 +291,5 @@ public function toggleShowFolder(int $show, string $key) {
315291
return $response;
316292
}
317293

318-
/**
319-
* quickaccess-sorting-strategy
320-
*
321-
* @NoAdminRequired
322-
*
323-
* @param string $strategy
324-
* @return Response
325-
*/
326-
public function setSortingStrategy($strategy) {
327-
$this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_sorting_strategy', (String)$strategy);
328-
return new Response();
329-
}
330-
331-
/**
332-
* Get reverse-state for quickaccess-list
333-
*
334-
* @NoAdminRequired
335-
*
336-
* @return String
337-
*/
338-
public function getSortingStrategy() {
339-
return $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_sorting_strategy', 'alphabet');
340-
}
341-
342-
/**
343-
* Toggle for reverse quickaccess-list
344-
*
345-
* @NoAdminRequired
346-
*
347-
* @param bool $reverse
348-
* @return Response
349-
*/
350-
public function setReverseQuickaccess($reverse) {
351-
$this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_reverse_list', (int)$reverse);
352-
return new Response();
353-
}
354-
355-
/**
356-
* Get reverse-state for quickaccess-list
357-
*
358-
* @NoAdminRequired
359-
*
360-
* @return bool
361-
*/
362-
public function getReverseQuickaccess() {
363-
if ($this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_reverse_list', false)) {
364-
return true;
365-
}
366-
return false;
367-
}
368-
369-
/**
370-
* Set state for show sorting menu
371-
*
372-
* @NoAdminRequired
373-
*
374-
* @param bool $show
375-
* @return Response
376-
*/
377-
public function setShowQuickaccessSettings($show) {
378-
$this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_show_settings', (int)$show);
379-
return new Response();
380-
}
381-
382-
/**
383-
* Get state for show sorting menu
384-
*
385-
* @NoAdminRequired
386-
*
387-
* @return bool
388-
*/
389-
public function getShowQuickaccessSettings() {
390-
if ($this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_show_settings', false)) {
391-
return true;
392-
}
393-
return false;
394-
}
395-
396-
/**
397-
* Set sorting-order for custom sorting
398-
*
399-
* @NoAdminRequired
400-
*
401-
* @param String $order
402-
* @return Response
403-
*/
404-
public function setSortingOrder($order) {
405-
$this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_custom_sorting_order', (String)$order);
406-
return new Response();
407-
}
408-
409-
/**
410-
* Get sorting-order for custom sorting
411-
*
412-
* @NoAdminRequired
413-
*
414-
* @return String
415-
*/
416-
public function getSortingOrder() {
417-
return $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_custom_sorting_order', "");
418-
}
419-
420-
/**
421-
* Get sorting-order for custom sorting
422-
*
423-
* @NoAdminRequired
424-
*
425-
* @param String
426-
* @return String
427-
*/
428-
public function getNodeType($folderpath) {
429-
$node = $this->userFolder->get($folderpath);
430-
return $node->getType();
431-
}
432-
433294

434295
}

0 commit comments

Comments
 (0)