From 8f3fd0bf8b60a9babbc406f173dba4a43f07d8a1 Mon Sep 17 00:00:00 2001 From: Eduardo Esparza <92958867+eduebernal@users.noreply.github.com> Date: Sun, 26 Jun 2022 09:55:49 -0700 Subject: [PATCH] Cli: Resolves #6478: Added note count indicator per notebook (#6526) --- packages/app-cli/app/gui/FolderListWidget.js | 13 +++++++++++++ packages/lib/models/Setting.ts | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/app-cli/app/gui/FolderListWidget.js b/packages/app-cli/app/gui/FolderListWidget.js index c87e75872..9db40e94e 100644 --- a/packages/app-cli/app/gui/FolderListWidget.js +++ b/packages/app-cli/app/gui/FolderListWidget.js @@ -2,6 +2,7 @@ const Folder = require('@joplin/lib/models/Folder').default; const Tag = require('@joplin/lib/models/Tag').default; const BaseModel = require('@joplin/lib/BaseModel').default; const ListWidget = require('tkwidgets/ListWidget.js'); +const Setting = require('@joplin/lib/models/Setting').default; const _ = require('@joplin/lib/locale')._; class FolderListWidget extends ListWidget { @@ -25,6 +26,18 @@ class FolderListWidget extends ListWidget { output.push('-'.repeat(this.innerWidth)); } else if (item.type_ === Folder.modelType()) { output.push(' '.repeat(this.folderDepth(this.folders, item.id)) + Folder.displayTitle(item)); + if (Setting.value('showNoteCounts')) { + let noteCount = item.note_count; + // Subtract children note_count from parent folder. + if (this.folderHasChildren_(this.folders,item.id)) { + for (let i = 0; i < this.folders.length; i++) { + if (this.folders[i].parent_id === item.id) { + noteCount -= this.folders[i].note_count; + } + } + } + output.push(noteCount); + } } else if (item.type_ === Tag.modelType()) { output.push(`[${Folder.displayTitle(item)}]`); } else if (item.type_ === BaseModel.TYPE_SEARCH) { diff --git a/packages/lib/models/Setting.ts b/packages/lib/models/Setting.ts index b5e320986..4b511ca2c 100644 --- a/packages/lib/models/Setting.ts +++ b/packages/lib/models/Setting.ts @@ -864,7 +864,7 @@ class Setting extends BaseModel { public: false, }, - showNoteCounts: { value: true, type: SettingItemType.Bool, storage: SettingStorage.File, isGlobal: true, public: false, advanced: true, appTypes: [AppType.Desktop], label: () => _('Show note counts') }, + showNoteCounts: { value: true, type: SettingItemType.Bool, storage: SettingStorage.File, isGlobal: true, public: false, advanced: true, appTypes: [AppType.Desktop,AppType.Cli], label: () => _('Show note counts') }, layoutButtonSequence: { value: Setting.LAYOUT_ALL,