From c1940edeba894691965266d2cf7d072cd7c9e70a Mon Sep 17 00:00:00 2001 From: MickaelK Date: Thu, 16 May 2024 21:27:13 +1000 Subject: [PATCH] chore (rewrite): filesystem --- .../decorator_shell_filemanager.css | 9 +- .../components/decorator_shell_filemanager.js | 18 +- public/assets/components/menubar.css | 6 +- public/assets/components/menubar.js | 2 +- .../assets/pages/filespage/ctrl_filesystem.js | 64 ++++-- .../assets/pages/filespage/ctrl_newitem.css | 2 +- public/assets/pages/filespage/ctrl_newitem.js | 5 +- .../assets/pages/filespage/ctrl_submenu.css | 3 +- public/assets/pages/filespage/ctrl_submenu.js | 34 ++- .../assets/pages/filespage/state_selection.js | 32 ++- public/assets/pages/filespage/thing.css | 209 ++++++------------ public/assets/pages/filespage/thing.js | 105 +++++---- 12 files changed, 260 insertions(+), 229 deletions(-) diff --git a/public/assets/components/decorator_shell_filemanager.css b/public/assets/components/decorator_shell_filemanager.css index bdd62007..7fabfbce 100644 --- a/public/assets/components/decorator_shell_filemanager.css +++ b/public/assets/components/decorator_shell_filemanager.css @@ -72,13 +72,14 @@ background: rgba(100,100,100,.05); } -.component_filemanager_shell [data-bind="filemanager-children"] .container, -.component_filemanager_shell [is="component-breadcrumb"] .container { - max-width: 2100px; -} +/* .component_filemanager_shell [data-bind="filemanager-children"] .container, */ +/* .component_filemanager_shell [is="component-breadcrumb"] .container { */ +/* max-width: 2100px; */ +/* } */ .component_filemanager_shell [data-bind="sidebar"] ~ div [is="component_filesystem"], .component_filemanager_shell [data-bind="sidebar"] ~ div [is="component_newitem"], +.component_filemanager_shell [data-bind="sidebar"] ~ div component-menubar, .component_filemanager_shell [data-bind="sidebar"] ~ div [is="component-breadcrumb"], .component_filemanager_shell [data-bind="sidebar"] ~ div [is="component_submenu"] .component_submenu{ padding: 0 30px; diff --git a/public/assets/components/decorator_shell_filemanager.js b/public/assets/components/decorator_shell_filemanager.js index 3e870d0b..5bf6fea6 100644 --- a/public/assets/components/decorator_shell_filemanager.js +++ b/public/assets/components/decorator_shell_filemanager.js @@ -1,5 +1,6 @@ import { createElement, createRender } from "../lib/skeleton/index.js"; -import rxjs, { effect } from "../lib/rx.js"; +import { navigate } from "../lib/skeleton/router.js"; +import rxjs, { effect, preventDefault } from "../lib/rx.js"; import { onDestroy } from "../lib/skeleton/lifecycle.js"; import { animate, slideYOut } from "../lib/animate.js"; import { qs } from "../lib/dom.js"; @@ -22,7 +23,8 @@ export default function(ctrl) { render($page); // feature1: setup the breadcrumb path - qs($page, `[is="component-breadcrumb"]`).setAttribute("path", urlToPath(location.pathname + location.hash)); + const $breadcrumb = qs($page, `[is="component-breadcrumb"]`); + $breadcrumb.setAttribute("path", urlToPath(location.pathname + location.hash)); // feature2: setup the childrens const $main = qs($page, `[data-bind="filemanager-children"]`); @@ -44,6 +46,16 @@ export default function(ctrl) { rxjs.mapTo($page.firstElementChild), rxjs.tap(($sidebar) => document.body.clientWidth > 1250 ? $sidebar.classList.remove("hidden") : $sidebar.classList.add("hidden")), )); + + // feature4: key shortcut + effect(rxjs.fromEvent(window, "keydown").pipe( + rxjs.filter((e) => new RegExp("^/files/.+").test(location.pathname) && e.keyCode === 8), // backspace in filemanager + rxjs.tap(() => { + const p = location.pathname.replace(new RegExp("/$"), "").split("/"); + p.pop(); + navigate(p.join("/") + "/" + location.hash); + }), + )); }; } @@ -56,7 +68,7 @@ async function ctrlSidebar(render) { // Tags: // - name + color const $comp = createElement(` -
+