mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 13:01:31 +08:00 
			
		
		
		
	toggle to expand/collapse attr list is saved and propagated across tabs
This commit is contained in:
		
							parent
							
								
									aa4a645670
								
							
						
					
					
						commit
						e1d4be814f
					
				| @ -75,7 +75,7 @@ | ||||
|   }, | ||||
|   "devDependencies": { | ||||
|     "cross-env": "^7.0.2", | ||||
|     "electron": "10.0.0-beta.11", | ||||
|     "electron": "10.0.0-beta.13", | ||||
|     "electron-builder": "22.7.0", | ||||
|     "electron-packager": "15.0.0", | ||||
|     "electron-rebuild": "1.11.0", | ||||
|  | ||||
| @ -171,7 +171,7 @@ const editorConfig = { | ||||
|     toolbar: { | ||||
|         items: [] | ||||
|     }, | ||||
|     placeholder: "Type the labels and relations here ...", | ||||
|     placeholder: "Type the labels and relations here, e.g. #year=2020", | ||||
|     mention: mentionSetup | ||||
| }; | ||||
| 
 | ||||
|  | ||||
| @ -2,6 +2,7 @@ import TabAwareWidget from "./tab_aware_widget.js"; | ||||
| import AttributeDetailWidget from "./attribute_detail.js"; | ||||
| import attributeRenderer from "../services/attribute_renderer.js"; | ||||
| import AttributeEditorWidget from "./attribute_editor.js"; | ||||
| import options from '../services/options.js'; | ||||
| 
 | ||||
| const TPL = ` | ||||
| <div class="attribute-list"> | ||||
| @ -103,15 +104,15 @@ export default class AttributeListWidget extends TabAwareWidget { | ||||
|         this.$widget = $(TPL); | ||||
| 
 | ||||
|         this.$attrDisplay = this.$widget.find('.attr-display'); | ||||
|         this.$attrDisplay.toggle(options.is('attributeListExpanded')); | ||||
| 
 | ||||
|         this.$ownedExpander = this.$widget.find('.attr-owned-expander'); | ||||
|         this.$ownedExpander.on('click', () => { | ||||
|             if (this.$attrDisplay.is(":visible")) { | ||||
|                 this.$attrDisplay.slideUp(200); | ||||
|             } | ||||
|             else { | ||||
|                 this.$attrDisplay.slideDown(200); | ||||
|             } | ||||
|         this.$ownedExpander.on('click', async () => { | ||||
|             const collapse = this.$attrDisplay.is(":visible"); | ||||
| 
 | ||||
|             await options.save('attributeListExpanded', !collapse); | ||||
| 
 | ||||
|             this.triggerEvent(`attributeListCollapsedStateChanged`, {collapse}); | ||||
|         }); | ||||
| 
 | ||||
|         this.$ownedExpanderText = this.$ownedExpander.find('.attr-expander-text'); | ||||
| @ -137,7 +138,7 @@ export default class AttributeListWidget extends TabAwareWidget { | ||||
|     } | ||||
| 
 | ||||
|     async refreshWithNote(note) { | ||||
|         const ownedAttributes = note.getOwnedAttributes(); | ||||
|         const ownedAttributes = note.getOwnedAttributes().filter(attr => !attr.isAutoLink); | ||||
| 
 | ||||
|         this.$ownedExpanderText.text(ownedAttributes.length + ' owned ' + this.attrPlural(ownedAttributes.length)); | ||||
| 
 | ||||
| @ -191,4 +192,17 @@ export default class AttributeListWidget extends TabAwareWidget { | ||||
|     updateAttributeListCommand({attributes}) { | ||||
|         this.attributeEditorWidget.updateAttributeList(attributes); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * This event is used to synchronize collapsed state of all the tab-cached widgets since they are all rendered | ||||
|      * separately but should behave uniformly for the user. | ||||
|      */ | ||||
|     attributeListCollapsedStateChangedEvent({collapse}) { | ||||
|         if (collapse) { | ||||
|             this.$attrDisplay.slideUp(200); | ||||
|         } | ||||
|         else { | ||||
|             this.$attrDisplay.slideDown(200); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -15,6 +15,7 @@ const TPL = ` | ||||
|         flex-shrink: 0; | ||||
|         flex-grow: 0; | ||||
|         overflow: auto; | ||||
|         max-height: 400px; | ||||
|     } | ||||
|      | ||||
|     .promoted-attributes td, .promoted-attributes th { | ||||
|  | ||||
| @ -37,7 +37,8 @@ const ALLOWED_OPTIONS = new Set([ | ||||
|     'rightPaneWidth', | ||||
|     'leftPaneVisible', | ||||
|     'rightPaneVisible', | ||||
|     'nativeTitleBarVisible' | ||||
|     'nativeTitleBarVisible', | ||||
|     'attributeListExpanded' | ||||
| ]); | ||||
| 
 | ||||
| function getOptions() { | ||||
|  | ||||
| @ -84,7 +84,8 @@ const defaultOptions = [ | ||||
|     { name: 'nativeTitleBarVisible', value: 'false', isSynced: false }, | ||||
|     { name: 'eraseNotesAfterTimeInSeconds', value: '604800', isSynced: true }, // default is 7 days
 | ||||
|     { name: 'hideArchivedNotes_main', value: 'false', isSynced: false }, | ||||
|     { name: 'hideIncludedImages_main', value: 'true', isSynced: false } | ||||
|     { name: 'hideIncludedImages_main', value: 'true', isSynced: false }, | ||||
|     { name: 'attributeListExpanded', value: 'false', isSynced: false } | ||||
| ]; | ||||
| 
 | ||||
| function initStartupOptions() { | ||||
|  | ||||
| @ -1,7 +1,6 @@ | ||||
| const log = require('./log'); | ||||
| const fs = require('fs'); | ||||
| const resourceDir = require('./resource_dir'); | ||||
| const appInfo = require('./app_info'); | ||||
| const sql = require('./sql'); | ||||
| const utils = require('./utils'); | ||||
| const optionService = require('./options'); | ||||
| @ -9,10 +8,11 @@ const port = require('./port'); | ||||
| const Option = require('../entities/option'); | ||||
| const TaskContext = require('./task_context.js'); | ||||
| const migrationService = require('./migration'); | ||||
| const cls = require('./cls'); | ||||
| 
 | ||||
| const dbReady = utils.deferred(); | ||||
| 
 | ||||
| initDbConnection(); | ||||
| cls.init(initDbConnection); | ||||
| 
 | ||||
| function schemaExists() { | ||||
|     return !!sql.getValue(`SELECT name FROM sqlite_master
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zadam
						zadam