mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 19:49:01 +01:00 
			
		
		
		
	add support for number precision in promoted attributes, closes #245
This commit is contained in:
		
							parent
							
								
									4577b03fc9
								
							
						
					
					
						commit
						ba7c8e77e5
					
				
							
								
								
									
										
											BIN
										
									
								
								db/demo.tar
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								db/demo.tar
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							| @ -67,7 +67,8 @@ function AttributesModel() { | ||||
|             attr.labelDefinition = (attr.type === 'label-definition' && attr.value) ? attr.value : { | ||||
|                 labelType: "text", | ||||
|                 multiplicityType: "singlevalue", | ||||
|                 isPromoted: true | ||||
|                 isPromoted: true, | ||||
|                 numberPrecision: 0 | ||||
|             }; | ||||
| 
 | ||||
|             attr.relationDefinition = (attr.type === 'relation-definition' && attr.value) ? attr.value : { | ||||
| @ -187,7 +188,8 @@ function AttributesModel() { | ||||
|                 labelDefinition: { | ||||
|                     labelType: "text", | ||||
|                     multiplicityType: "singlevalue", | ||||
|                     isPromoted: true | ||||
|                     isPromoted: true, | ||||
|                     numberPrecision: 0 | ||||
|                 }, | ||||
|                 relationDefinition: { | ||||
|                     multiplicityType: "singlevalue", | ||||
|  | ||||
| @ -3,9 +3,7 @@ import utils from "./utils.js"; | ||||
| import messagingService from "./messaging.js"; | ||||
| import treeUtils from "./tree_utils.js"; | ||||
| import noteAutocompleteService from "./note_autocomplete.js"; | ||||
| import treeService from "./tree.js"; | ||||
| import linkService from "./link.js"; | ||||
| import infoService from "./info.js"; | ||||
| import noteDetailService from "./note_detail.js"; | ||||
| 
 | ||||
| const $attributeList = $("#attribute-list"); | ||||
| @ -163,6 +161,14 @@ async function createPromotedAttributeRow(definitionAttr, valueAttr) { | ||||
|         } | ||||
|         else if (definition.labelType === 'number') { | ||||
|             $input.prop("type", "number"); | ||||
| 
 | ||||
|             let step = 1; | ||||
| 
 | ||||
|             for (let i = 0; i < (definition.numberPrecision || 0) && i < 10; i++) { | ||||
|                 step /= 10; | ||||
|             } | ||||
| 
 | ||||
|             $input.prop("step", step); | ||||
|         } | ||||
|         else if (definition.labelType === 'boolean') { | ||||
|             $input.prop("type", "checkbox"); | ||||
|  | ||||
| @ -64,6 +64,11 @@ | ||||
|                            data-bind="checked: labelDefinition.isPromoted"/> | ||||
|                       Promoted | ||||
|                     </label> | ||||
| 
 | ||||
|                     <div data-bind="visible: labelDefinition.labelType === 'number'" | ||||
|                         title="Precision of floating point numbers - 0 means effectively integer, 2 allows entering e.g. 1.23"> | ||||
|                       Number precision: <input type="number" min="0" max="9" data-bind="value: labelDefinition.numberPrecision" style="width: 50px;"/> | ||||
|                     </div> | ||||
|                   </div> | ||||
| 
 | ||||
|                   <div data-bind="visible: type == 'relation-definition'"> | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 azivner
						azivner