Skip to content
Merged
43 changes: 24 additions & 19 deletions apps/files/appinfo/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,29 @@
$templateManager->registerTemplate('application/vnd.oasis.opendocument.text', 'core/templates/filetemplates/template.odt');
$templateManager->registerTemplate('application/vnd.oasis.opendocument.spreadsheet', 'core/templates/filetemplates/template.ods');

\OCA\Files\App::getNavigationManager()->add(function () use ($l) {
return [
'id' => 'files',
'appname' => 'files',
'script' => 'list.php',
'order' => 0,
'name' => $l->t('All files'),
];
});

\OCA\Files\App::getNavigationManager()->add(function () use ($l) {
return [
'id' => 'recent',
'appname' => 'files',
'script' => 'recentlist.php',
'order' => 2,
'name' => $l->t('Recent'),
];
});
\OCA\Files\App::getNavigationManager()->add([
'id' => 'files',
'appname' => 'files',
'script' => 'list.php',
'order' => 0,
'name' => $l->t('All files')
]);

\OCA\Files\App::getNavigationManager()->add([
'id' => 'recent',
'appname' => 'files',
'script' => 'recentlist.php',
'order' => 2,
'name' => $l->t('Recent')
]);

\OCA\Files\App::getNavigationManager()->add([
'id' => 'favorites',
'appname' => 'files',
'script' => 'simplelist.php',
'order' => 5,
'name' => $l->t('Favorites'),
'expandedState' => 'show_Quick_Access'
]);

\OCP\Util::connectHook('\OCP\Config', 'js', '\OCA\Files\App', 'extendJsConfig');
11 changes: 3 additions & 8 deletions apps/files/appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,9 @@
'verb' => 'GET',
],
[
'name' => 'API#showQuickAccess',
'url' => '/api/v1/quickaccess/set/showList',
'verb' => 'GET',
],
[
'name' => 'API#getShowQuickAccess',
'url' => '/api/v1/quickaccess/get/showList',
'verb' => 'GET',
'name' => 'API#toggleShowFolder',
'url' => '/api/v1/toggleShowFolder/{key}',
'verb' => 'POST'
],
[
'name' => 'API#getShowQuickaccessSettings',
Expand Down
3 changes: 2 additions & 1 deletion apps/files/css/files.scss
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@
background-image: url('../img/star.svg?v=1');
}
.nav-icon-sharingin,
.nav-icon-sharingout {
.nav-icon-sharingout,
.nav-icon-shareoverview {
background-image: url('../img/share.svg?v=1');
}
.nav-icon-sharinglinks {
Expand Down
26 changes: 7 additions & 19 deletions apps/files/js/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,30 +172,18 @@
*/
_onClickMenuButton: function (ev) {
var $target = $(ev.target);
var $menu = $target.parent('li');
var itemId = $target.closest('button').attr('id');

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.
collapsibleToggles.push(["#button-collapse-favorites", "#button-collapse-parent-favorites"]);

// The dotmenuToggles-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.
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;
}
$.get(OC.generateUrl("/apps/files/api/v1/quickaccess/set/showList"), {show: show}, function (data, status) {
});
}
});
if ($menu.hasClass('collapsible') && $menu.data('expandedstate')) {
$menu.toggleClass('open');
var show = $menu.hasClass('open') ? 1 : 0;
var key = $menu.data('expandedstate');
$.post(OC.generateUrl("/apps/files/api/v1/toggleShowFolder/" + key), {show: show});
}

dotmenuToggles.forEach(function foundToggle (item) {
if (item[0] === ("#" + itemId)) {
Expand Down
33 changes: 13 additions & 20 deletions apps/files/js/tagsplugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,29 +68,22 @@
* @param {String} appfolder folder to be removed
*/
function removeFavoriteFromList (appfolder) {

var quickAccessList = 'sublist-favorites';
var collapsibleButtonId = 'button-collapse-favorites';
var listULElements = document.getElementById(quickAccessList);
if (!listULElements) {
return;
}
var listLIElements = listULElements.getElementsByTagName('li');

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();
}
}
$(listULElements).find('[data-dir="' + apppath + '"]').remove();

if (listULElements.childElementCount === 0) {
var collapsibleButton = document.getElementById("button-collapse-favorites");
collapsibleButton.style.display = 'none';
var collapsibleButton = $(listULElements).parent().find('button.collapse');
collapsibleButton.hide();
$("#button-collapse-parent-favorites").removeClass('collapsible');
}
}
Expand All @@ -102,21 +95,20 @@
*/
function addFavoriteToList (appfolder) {
var quickAccessList = 'sublist-favorites';
var collapsibleButtonId = 'button-collapse-favorites';
var listULElements = document.getElementById(quickAccessList);
if (!listULElements) {
return;
}
var listLIElements = listULElements.getElementsByTagName('li');

var appName = appfolder.substring(appfolder.lastIndexOf("/") + 1, appfolder.length);
var apppath=appfolder;
var apppath = appfolder;

if(appfolder.startsWith("//")){
apppath=appfolder.substring(1, appfolder.length);
apppath = appfolder.substring(1, appfolder.length);
}
var url=OC.generateUrl('/apps/files/?dir=')+apppath;

var url = OC.generateUrl('/apps/files/?dir=' + apppath + '&view=files');

var innerTagA = document.createElement('A');
innerTagA.setAttribute("href", url);
Expand All @@ -125,7 +117,9 @@

var length = listLIElements.length + 1;
var innerTagLI = document.createElement('li');
innerTagLI.setAttribute("data-id", url);
innerTagLI.setAttribute("data-id", apppath.replace('/', '-'));
innerTagLI.setAttribute("data-dir", apppath);
innerTagLI.setAttribute("data-view", 'files');
innerTagLI.setAttribute("class", "nav-" + appName);
innerTagLI.setAttribute("folderpos", length.toString());
innerTagLI.appendChild(innerTagA);
Expand All @@ -134,10 +128,9 @@
if (data === "dir") {
if (listULElements.childElementCount <= 0) {
listULElements.appendChild(innerTagLI);
var collapsibleButton = document.getElementById(collapsibleButtonId);
collapsibleButton.style.display = '';

$("#button-collapse-parent-favorites").addClass('collapsible');
var collapsibleButton = $(listULElements).parent().find('button.collapse');
collapsibleButton.show();
$(listULElements).parent().addClass('collapsible');
} else {
listLIElements[listLIElements.length - 1].after(innerTagLI);
}
Expand Down
33 changes: 16 additions & 17 deletions apps/files/lib/Controller/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,29 +291,28 @@ public function showHiddenFiles($show) {
}

/**
* Toggle default for showing/hiding QuickAccess folder
* Toggle default for showing/hiding xxx folder
*
* @NoAdminRequired
*
* @param bool $show
* @param bool $show
* @param bool $key the key of the folder
*
* @return Response
*/
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
*
* @NoAdminRequired
*
* @return String
*/
public function getShowQuickAccess() {

return $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'show_Quick_Access', 0);
public function toggleShowFolder(int $show, string $key) {
// ensure the edited key exists
$navItems = \OCA\Files\App::getNavigationManager()->getAll();
foreach ($navItems as $item) {
// check if data is valid
if (($show === 0 || $show === 1) && isset($item['expandedState']) && $key === $item['expandedState']) {
$this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', $key, (int)$show);
return new Response();
}
}
$response = new Response();
$response->setStatus(Http::STATUS_FORBIDDEN);
return $response;
}

/**
Expand Down
Loading