Skip to content

Commit f90bb87

Browse files
committed
feat: render interactive parent directory tile for rapid upward navigation
Automatically prepend a dedicated parent directory (`..`) navigation tile at the top of directory listings when navigating deep within a folder structure. * **Template Integration (`src/pages/fileBrowser/listItem.hbs`):** * Added template parsing support for the `data-one-dir-up` attribute to identify parent navigation controls. * **Dynamic Item Prepending (`src/pages/fileBrowser/fileBrowser.js`):** * Added conditional evaluation during directory rendering: when `navStack.length >= 2`, a non-selectable parent folder item (`..`) is automatically prepended to the top of the rendered list array. * Flagged the parent directory tile with `data-not-selectable` so it is ignored during batch selection operations. * **Navigation Action Dispatch:** * Bound tap and click actions on items bearing `data-one-dir-up` to execute an upward navigation jump directly to `navStack.get(-2)`, streamlining folder hierarchy traversal. (AI generated commit message)
1 parent 5c68300 commit f90bb87

2 files changed

Lines changed: 27 additions & 2 deletions

File tree

‎src/pages/fileBrowser/fileBrowser.js‎

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,7 @@ function FileBrowserInclude(mode, info, doesOpenLast = true) {
903903

904904
let url = $el.dataset.url;
905905
let name = $el.dataset.name;
906+
const isOneDirUp = $el.dataset.oneDirUp != null;
906907
const isOpenDoc = $el.dataset.openDoc != null;
907908
const uuid = $el.dataset.uuid;
908909
const type = $el.dataset.type;
@@ -920,7 +921,14 @@ function FileBrowserInclude(mode, info, doesOpenLast = true) {
920921
return;
921922
}
922923

923-
if (!url && action === "open" && isDir && !isOpenDoc && !isContextMenu) {
924+
if (
925+
!url &&
926+
action === "open" &&
927+
isDir &&
928+
!isOpenDoc &&
929+
!isOneDirUp &&
930+
!isContextMenu
931+
) {
924932
loader.hide();
925933
util.addPath(name, uuid).then((res) => {
926934
const storage = allStorages.find((storage) => storage.uuid === uuid);
@@ -936,6 +944,7 @@ function FileBrowserInclude(mode, info, doesOpenLast = true) {
936944

937945
if (isContextMenu) action = "contextmenu";
938946
else if (isOpenDoc) action = "openDoc";
947+
else if (isOneDirUp) action = "oneDirUp";
939948

940949
switch (action) {
941950
case "navigation":
@@ -950,6 +959,11 @@ function FileBrowserInclude(mode, info, doesOpenLast = true) {
950959
break;
951960
case "openDoc":
952961
openDoc();
962+
break;
963+
case "oneDirUp": {
964+
const dir = navStack.get(-2);
965+
if (dir) navigate(dir.url, dir.name);
966+
}
953967
}
954968

955969
async function folder() {
@@ -995,7 +1009,7 @@ function FileBrowserInclude(mode, info, doesOpenLast = true) {
9951009
}
9961010

9971011
async function contextMenuHandler() {
998-
if (isOpenDoc) return;
1012+
if (isOneDirUp || isOpenDoc) return;
9991013
if (appSettings.value.vibrateOnTap) {
10001014
navigator.vibrate(config.VIBRATION_TIME);
10011015
}
@@ -1539,6 +1553,14 @@ function FileBrowserInclude(mode, info, doesOpenLast = true) {
15391553
const $oldList = $content.get("#list");
15401554
const $list = createListEl();
15411555

1556+
const oneDirUp =
1557+
navStack.length >= 2 &&
1558+
createListItemEl({
1559+
name: "..",
1560+
oneDirUp: true,
1561+
notSelectable: true,
1562+
});
1563+
15421564
if (!$oldList) $content.append($list);
15431565
else {
15441566
const dir = currentDir;
@@ -1555,6 +1577,7 @@ function FileBrowserInclude(mode, info, doesOpenLast = true) {
15551577
let { list } = dir;
15561578
const fg = new DocumentFragment();
15571579
if (!list) {
1580+
if (oneDirUp) fg.append(oneDirUp);
15581581
let plh = { placeholder: true };
15591582
for (let i = Math.ceil($list.clientHeight / 45); i-- > 0; ) {
15601583
const el = createListItemEl(plh);
@@ -1569,6 +1592,7 @@ function FileBrowserInclude(mode, info, doesOpenLast = true) {
15691592

15701593
if (_rndrAbortCtrl === rndrAbortCtrl) _rndrAbortCtrl = null;
15711594

1595+
if (oneDirUp) fg.append(oneDirUp);
15721596
for (let l = list?.length, i = 0; i < l; i++) {
15731597
fg.append(createListItemEl(list[i]));
15741598
}

‎src/pages/fileBrowser/listItem.hbs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
data-name="{{name}}"
77
{{#home}}data-home="{{.}}"{{/home}}
88
{{#notSelectable}}data-not-selectable{{/notSelectable}}
9+
{{#oneDirUp}}data-one-dir-up{{/oneDirUp}}
910
{{#openDoc}}data-open-doc{{/openDoc}}
1011
{{#ftpAccount}}data-ftp-account{{/ftpAccount}}
1112
{{#uuid}}data-uuid="{{uuid}}"{{/uuid}}

0 commit comments

Comments
 (0)