mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	add support for number precision in promoted attributes, closes #245
This commit is contained in:
		
							
								
								
									
										
											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 : { |             attr.labelDefinition = (attr.type === 'label-definition' && attr.value) ? attr.value : { | ||||||
|                 labelType: "text", |                 labelType: "text", | ||||||
|                 multiplicityType: "singlevalue", |                 multiplicityType: "singlevalue", | ||||||
|                 isPromoted: true |                 isPromoted: true, | ||||||
|  |                 numberPrecision: 0 | ||||||
|             }; |             }; | ||||||
|  |  | ||||||
|             attr.relationDefinition = (attr.type === 'relation-definition' && attr.value) ? attr.value : { |             attr.relationDefinition = (attr.type === 'relation-definition' && attr.value) ? attr.value : { | ||||||
| @@ -187,7 +188,8 @@ function AttributesModel() { | |||||||
|                 labelDefinition: { |                 labelDefinition: { | ||||||
|                     labelType: "text", |                     labelType: "text", | ||||||
|                     multiplicityType: "singlevalue", |                     multiplicityType: "singlevalue", | ||||||
|                     isPromoted: true |                     isPromoted: true, | ||||||
|  |                     numberPrecision: 0 | ||||||
|                 }, |                 }, | ||||||
|                 relationDefinition: { |                 relationDefinition: { | ||||||
|                     multiplicityType: "singlevalue", |                     multiplicityType: "singlevalue", | ||||||
|   | |||||||
| @@ -3,9 +3,7 @@ import utils from "./utils.js"; | |||||||
| import messagingService from "./messaging.js"; | import messagingService from "./messaging.js"; | ||||||
| import treeUtils from "./tree_utils.js"; | import treeUtils from "./tree_utils.js"; | ||||||
| import noteAutocompleteService from "./note_autocomplete.js"; | import noteAutocompleteService from "./note_autocomplete.js"; | ||||||
| import treeService from "./tree.js"; |  | ||||||
| import linkService from "./link.js"; | import linkService from "./link.js"; | ||||||
| import infoService from "./info.js"; |  | ||||||
| import noteDetailService from "./note_detail.js"; | import noteDetailService from "./note_detail.js"; | ||||||
|  |  | ||||||
| const $attributeList = $("#attribute-list"); | const $attributeList = $("#attribute-list"); | ||||||
| @@ -163,6 +161,14 @@ async function createPromotedAttributeRow(definitionAttr, valueAttr) { | |||||||
|         } |         } | ||||||
|         else if (definition.labelType === 'number') { |         else if (definition.labelType === 'number') { | ||||||
|             $input.prop("type", "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') { |         else if (definition.labelType === 'boolean') { | ||||||
|             $input.prop("type", "checkbox"); |             $input.prop("type", "checkbox"); | ||||||
|   | |||||||
| @@ -64,6 +64,11 @@ | |||||||
|                            data-bind="checked: labelDefinition.isPromoted"/> |                            data-bind="checked: labelDefinition.isPromoted"/> | ||||||
|                       Promoted |                       Promoted | ||||||
|                     </label> |                     </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> | ||||||
|  |  | ||||||
|                   <div data-bind="visible: type == 'relation-definition'"> |                   <div data-bind="visible: type == 'relation-definition'"> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user