Added drop-animation to sortable-list

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

Added icon-change on drag

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

Fixed Navbar-closing in app when favorites-list is toggled on mobile

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

Refactored Code

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

Changed to alphabetical sorting

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

Fixed deletion of folder with identical names

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

Removed ability to add files to the quickaccess

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

Fixed wrong path-generation when added from favorites-star

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

Removed Element from navbar when favorite-star in detailview is toggled off

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

Changed Quota-Text to prevent boundarybreaks

Reverted last commit
This commit is contained in:
fnuesse 2018-06-27 10:40:32 +02:00 committed by John Molakvoæ (skjnldsv)
parent 55ebdc9344
commit c9995de2db
No known key found for this signature in database
GPG key ID: 60C25B8C072916CF
6 changed files with 108 additions and 41 deletions

View file

@ -131,6 +131,11 @@ $application->registerRoutes(
'url' => '/api/v1/quickaccess/get/CustomSortingOrder',
'verb' => 'GET',
],
[
'name' => 'API#getNodeType',
'url' => '/api/v1/quickaccess/get/NodeType',
'verb' => 'GET',
],
]
]
);

View file

@ -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();
});
},
@ -162,7 +166,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")) {
@ -172,30 +176,54 @@
scroll: false,
zIndex: 0,
opacity: 0.5,
delay: 150,
tolerance: "pointer",
start:function(event, ui){
//revert: 0.05,
//delay: 150,
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');
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 ) {
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');
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';
}
}
@ -220,13 +248,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) {
});
@ -269,7 +296,6 @@
scope.reverse(list);
});
} else if (this.$sortingStrategy === 'alphabet') {
sort = true;
} else if (this.$sortingStrategy === 'date') {
@ -277,7 +303,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()) {
@ -287,7 +313,6 @@
}
scope.QuickSort(list, 0, list.length - 1);
});
sort = false;
}
@ -357,7 +382,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();

View file

@ -73,10 +73,14 @@
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 apppath=appfolder;
if(appfolder.startsWith("//")){
apppath=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=" + apppath)) {
listLIElements[i].remove();
}
}
@ -100,29 +104,40 @@
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);
$.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);
collapsibleButton.style.display = '';
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);
}
$("#button-collapse-parent-favorites").addClass('collapsible');
} else {
listLIElements[listLIElements.length - 1].after(innerTagLI);
}
}
}
);
}
OCA.Files = OCA.Files || {};
@ -327,6 +342,7 @@
});
}
};
})(OCA);
})
(OCA);
OC.Plugins.register('OCA.Files.FileList', OCA.Files.TagsPlugin);

View file

@ -215,6 +215,7 @@ class ApiController extends Controller {
$favorites[$i]['id'] = $node->getId();
$favorites[$i]['name'] = $node->getName();
$favorites[$i]['path'] = $node->getInternalPath();
$favorites[$i]['mtime'] = $node->getMTime();
$i++;
}
@ -336,7 +337,7 @@ class ApiController extends Controller {
* @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');
}
/**
@ -411,11 +412,24 @@ class ApiController extends Controller {
*
* @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();
}
}

View file

@ -207,6 +207,13 @@ class ViewController extends Controller {
$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 @@ class ViewController extends Controller {
'order' => 5,
'name' => $this->l10n->t('Favorites'),
'sublist' => $favoritesSublistArray,
'draggableSublist' => 'true',
'draggableSublist' => $quickAccessDraggable,
'defaultExpandedState' => $defaultExpandedState,
'enableMenuButton' => 0,
]

View file

@ -80,7 +80,7 @@ function NavigationListElements($item, $l, $pinned) {
if (isset($item['sublist'])) {
?>
<button id="button-collapse-<?php p($item['id']); ?>"
class="collapse" <?php if (sizeof($item['sublist']) == 0) { ?> style="display: none" <?php } ?>></button>
class="collapse app-navigation-noclose" <?php if (sizeof($item['sublist']) == 0) { ?> style="display: none" <?php } ?>></button>
<ul id="sublist-<?php p($item['id']); ?>" <?php if ($item['draggableSublist'] === 'true') { ?> draggable="true" style="resize: none;"<?php } ?>>
<?php
foreach ($item['sublist'] as $item) {
@ -121,4 +121,4 @@ function NavigationElementMenu($item) {
</ul>
</div>
<?php }
}
}