mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-03 20:06:08 +01:00 
			
		
		
		
	mobile layout fixes + fix mobile delete note
This commit is contained in:
		@@ -76,11 +76,11 @@ export default class MobileLayout {
 | 
				
			|||||||
                .child(new NoteTreeWidget("main").cssBlock(FANCYTREE_CSS)))
 | 
					                .child(new NoteTreeWidget("main").cssBlock(FANCYTREE_CSS)))
 | 
				
			||||||
            .child(new ScreenContainer("detail", "column")
 | 
					            .child(new ScreenContainer("detail", "column")
 | 
				
			||||||
                .class("d-sm-flex d-md-flex d-lg-flex d-xl-flex col-12 col-sm-7 col-md-8 col-lg-8")
 | 
					                .class("d-sm-flex d-md-flex d-lg-flex d-xl-flex col-12 col-sm-7 col-md-8 col-lg-8")
 | 
				
			||||||
                .child(new FlexContainer('row')
 | 
					                .child(new FlexContainer('row').overflowing()
 | 
				
			||||||
 | 
					                    .css('font-size', 'larger')
 | 
				
			||||||
 | 
					                    .css('align-items', 'center')
 | 
				
			||||||
                    .child(new MobileDetailMenuWidget())
 | 
					                    .child(new MobileDetailMenuWidget())
 | 
				
			||||||
                    .child(new NoteTitleWidget()
 | 
					                    .child(new NoteTitleWidget())
 | 
				
			||||||
                        .css('padding', '10px')
 | 
					 | 
				
			||||||
                        .css('font-size', 'larger'))
 | 
					 | 
				
			||||||
                    .child(new CloseDetailButtonWidget()))
 | 
					                    .child(new CloseDetailButtonWidget()))
 | 
				
			||||||
                .child(new NoteDetailWidget()
 | 
					                .child(new NoteDetailWidget()
 | 
				
			||||||
                    .css('padding', '5px 20px 10px 0')));
 | 
					                    .css('padding', '5px 20px 10px 0')));
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -158,6 +158,12 @@ function getNoteIdFromNotePath(notePath) {
 | 
				
			|||||||
    return lastSegment.split("-")[0];
 | 
					    return lastSegment.split("-")[0];
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					async function getBranchIdFromNotePath(notePath) {
 | 
				
			||||||
 | 
					    const {noteId, parentNoteId} = getNoteIdAndParentIdFromNotePath(notePath);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return await treeCache.getBranchId(parentNoteId, noteId);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function getNoteIdAndParentIdFromNotePath(notePath) {
 | 
					function getNoteIdAndParentIdFromNotePath(notePath) {
 | 
				
			||||||
    if (notePath === 'root') {
 | 
					    if (notePath === 'root') {
 | 
				
			||||||
        return {
 | 
					        return {
 | 
				
			||||||
@@ -185,7 +191,7 @@ function getNoteIdAndParentIdFromNotePath(notePath) {
 | 
				
			|||||||
    return {
 | 
					    return {
 | 
				
			||||||
        parentNoteId,
 | 
					        parentNoteId,
 | 
				
			||||||
        noteId
 | 
					        noteId
 | 
				
			||||||
    }
 | 
					    };
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function getNotePath(node) {
 | 
					function getNotePath(node) {
 | 
				
			||||||
@@ -286,6 +292,7 @@ export default {
 | 
				
			|||||||
    getNotePath,
 | 
					    getNotePath,
 | 
				
			||||||
    getNoteIdFromNotePath,
 | 
					    getNoteIdFromNotePath,
 | 
				
			||||||
    getNoteIdAndParentIdFromNotePath,
 | 
					    getNoteIdAndParentIdFromNotePath,
 | 
				
			||||||
 | 
					    getBranchIdFromNotePath,
 | 
				
			||||||
    getNoteTitle,
 | 
					    getNoteTitle,
 | 
				
			||||||
    getNotePathTitle,
 | 
					    getNotePathTitle,
 | 
				
			||||||
    getHashValueFromAddress,
 | 
					    getHashValueFromAddress,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,13 +1,14 @@
 | 
				
			|||||||
import BasicWidget from "../basic_widget.js";
 | 
					import BasicWidget from "../basic_widget.js";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const TPL = `
 | 
					const TPL = `
 | 
				
			||||||
<button type="button" class="action-button d-sm-none d-md-none d-lg-none d-xl-none" aria-label="Close">
 | 
					<button type="button" class="action-button d-sm-none d-md-none d-lg-none d-xl-none" aria-label="Close" style="padding-top: 10px;">
 | 
				
			||||||
    <span aria-hidden="true">×</span>
 | 
					    <span aria-hidden="true">×</span>
 | 
				
			||||||
</button>`;
 | 
					</button>`;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class CloseDetailButtonWidget extends BasicWidget {
 | 
					class CloseDetailButtonWidget extends BasicWidget {
 | 
				
			||||||
    doRender() {
 | 
					    doRender() {
 | 
				
			||||||
        this.$widget = $(TPL);
 | 
					        this.$widget = $(TPL);
 | 
				
			||||||
 | 
					        this.overflowing();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.$widget.on('click', () => this.triggerCommand('setActiveScreen', {screen:'tree'}));
 | 
					        this.$widget.on('click', () => this.triggerCommand('setActiveScreen', {screen:'tree'}));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,12 +3,14 @@ import appContext from "../../services/app_context.js";
 | 
				
			|||||||
import contextMenu from "../../services/context_menu.js";
 | 
					import contextMenu from "../../services/context_menu.js";
 | 
				
			||||||
import noteCreateService from "../../services/note_create.js";
 | 
					import noteCreateService from "../../services/note_create.js";
 | 
				
			||||||
import branchService from "../../services/branches.js";
 | 
					import branchService from "../../services/branches.js";
 | 
				
			||||||
 | 
					import treeService from "../../services/tree.js";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const TPL = `<button type="button" class="action-button bx bx-menu"></button>`;
 | 
					const TPL = `<button type="button" class="action-button bx bx-menu" style="padding-top: 10px;"></button>`;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class MobileDetailMenuWidget extends BasicWidget {
 | 
					class MobileDetailMenuWidget extends BasicWidget {
 | 
				
			||||||
    doRender() {
 | 
					    doRender() {
 | 
				
			||||||
        this.$widget = $(TPL);
 | 
					        this.$widget = $(TPL);
 | 
				
			||||||
 | 
					        this.overflowing();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.$widget.on("click", async e => {
 | 
					        this.$widget.on("click", async e => {
 | 
				
			||||||
            const note = appContext.tabManager.getActiveTabNote();
 | 
					            const note = appContext.tabManager.getActiveTabNote();
 | 
				
			||||||
@@ -27,9 +29,15 @@ class MobileDetailMenuWidget extends BasicWidget {
 | 
				
			|||||||
                        noteCreateService.createNote(note.noteId);
 | 
					                        noteCreateService.createNote(note.noteId);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    else if (command === "delete") {
 | 
					                    else if (command === "delete") {
 | 
				
			||||||
                        if (await branchService.deleteNotes(note.getBranchIds()[0])) {
 | 
					                        const notePath = appContext.tabManager.getActiveTabNotePath();
 | 
				
			||||||
                            // move to the tree
 | 
					                        const branchId = await treeService.getBranchIdFromNotePath(notePath);
 | 
				
			||||||
                            togglePanes();
 | 
					
 | 
				
			||||||
 | 
					                        if (!branchId) {
 | 
				
			||||||
 | 
					                            throw new Error(`Cannot get branchId for notePath ${notePath}`);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        if (await branchService.deleteNotes([branchId])) {
 | 
				
			||||||
 | 
					                            this.triggerCommand('setActiveScreen', {screen:'tree'})
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    else {
 | 
					                    else {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -32,7 +32,8 @@ const WIDGET_TPL = `
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
class MobileGlobalButtonsWidget extends BasicWidget {
 | 
					class MobileGlobalButtonsWidget extends BasicWidget {
 | 
				
			||||||
    doRender() {
 | 
					    doRender() {
 | 
				
			||||||
        return this.$widget = $(WIDGET_TPL);
 | 
					        this.$widget = $(WIDGET_TPL);
 | 
				
			||||||
 | 
					        this.overflowing();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -101,6 +101,8 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
<div class="dropdown-menu dropdown-menu-sm" id="context-menu-container"></div>
 | 
					<div class="dropdown-menu dropdown-menu-sm" id="context-menu-container"></div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<%- include('dialogs/confirm.ejs') %>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<script type="text/javascript">
 | 
					<script type="text/javascript">
 | 
				
			||||||
    window.baseApiUrl = 'api/';
 | 
					    window.baseApiUrl = 'api/';
 | 
				
			||||||
    window.device = "mobile";
 | 
					    window.device = "mobile";
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user