From cb6025a6e4990b5ed691106f26de01322f93063c Mon Sep 17 00:00:00 2001
From: Terry Truong <terry06890@gmail.com>
Date: Sat, 9 Jul 2022 15:24:34 +1000
Subject: Make clicking 'Tilo' collapse the tree

---
 src/App.vue | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

(limited to 'src/App.vue')

diff --git a/src/App.vue b/src/App.vue
index 6dc5440..dc9b167 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -3,7 +3,7 @@
 	:style="{backgroundColor: uiOpts.bgColor}">
 	<!-- Title bar -->
 	<div class="flex shadow gap-2 p-2" :style="{backgroundColor: uiOpts.bgColorDark2, color: uiOpts.altColor}">
-		<h1 class="my-auto ml-2 text-4xl">Tilo</h1>
+		<h1 class="my-auto ml-2 text-4xl hover:cursor-pointer" @click="collapseTree">Tilo</h1>
 		<div class="mx-auto"/> <!-- Spacer -->
 		<!-- Icons -->
 		<icon-button :disabled="isDisabled('help')" :size="45" :style="buttonStyles" @click="onHelpIconClick">
@@ -922,6 +922,14 @@ export default defineComponent({
 			await this.onNonleafClick(this.layoutTree, true);
 			await this.initTreeFromServer(false);
 		},
+		async collapseTree(){
+			if (this.activeRoot != this.layoutTree){
+				await this.onDetachedAncestorClick(this.layoutTree, true);
+			}
+			if (this.layoutTree.children.length > 0){
+				await this.onNonleafClick(this.layoutTree);
+			}
+		},
 		getLytOpts(): LayoutOptions {
 			let opts = getDefaultLytOpts();
 			for (let prop of Object.getOwnPropertyNames(opts) as (keyof LayoutOptions)[]){
-- 
cgit v1.2.3

