mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 18:36:30 +01:00 
			
		
		
		
	fix #32, could not open attribute dialog if it didn't have any attributes yet
This commit is contained in:
		| @@ -22,7 +22,8 @@ const attributesDialog = (function() { | |||||||
|  |  | ||||||
|             attributeNames = await server.get('attributes/names'); |             attributeNames = await server.get('attributes/names'); | ||||||
|  |  | ||||||
|             $(".attribute-name:last").focus(); |             // attribute might not be rendered immediatelly so could not focus | ||||||
|  |             setTimeout(() => $(".attribute-name:last").focus(), 100); | ||||||
|         }; |         }; | ||||||
|  |  | ||||||
|         function isValid() { |         function isValid() { | ||||||
| @@ -65,9 +66,9 @@ const attributesDialog = (function() { | |||||||
|  |  | ||||||
|         function addLastEmptyRow() { |         function addLastEmptyRow() { | ||||||
|             const attrs = self.attributes(); |             const attrs = self.attributes(); | ||||||
|             const last = attrs[attrs.length - 1](); |             const last = attrs.length === 0 ? null : attrs[attrs.length - 1](); | ||||||
|  |  | ||||||
|             if (last.name.trim() !== "" || last.value !== "") { |             if (!last || last.name.trim() !== "" || last.value !== "") { | ||||||
|                 self.attributes.push(ko.observable({ |                 self.attributes.push(ko.observable({ | ||||||
|                     attributeId: '', |                     attributeId: '', | ||||||
|                     name: '', |                     name: '', | ||||||
| @@ -149,8 +150,6 @@ const attributesDialog = (function() { | |||||||
|         $(this).autocomplete("search", $(this).val()); |         $(this).autocomplete("search", $(this).val()); | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|     $(document).on('blur', '.attribute-name', function (e) { console.log("blur!"); }); |  | ||||||
|  |  | ||||||
|     $(document).on('focus', '.attribute-value', async function (e) { |     $(document).on('focus', '.attribute-value', async function (e) { | ||||||
|         if (!$(this).hasClass("ui-autocomplete-input")) { |         if (!$(this).hasClass("ui-autocomplete-input")) { | ||||||
|             const attributeName = $(this).parent().parent().find('.attribute-name').val(); |             const attributeName = $(this).parent().parent().find('.attribute-name').val(); | ||||||
|   | |||||||
| @@ -389,7 +389,7 @@ | |||||||
|     <div id="attributes-dialog" title="Note attributes" style="display: none; padding: 20px;"> |     <div id="attributes-dialog" title="Note attributes" style="display: none; padding: 20px;"> | ||||||
|       <form data-bind="submit: save"> |       <form data-bind="submit: save"> | ||||||
|       <div style="text-align: center"> |       <div style="text-align: center"> | ||||||
|         <button class="btn-primary btn-large" id="save-attributes-button" type="submit">Save</button> |         <button class="btn btn-large" style="width: 200px;" id="save-attributes-button" type="submit">Save <kbd>enter</kbd></button> | ||||||
|       </div> |       </div> | ||||||
|  |  | ||||||
|       <div style="height: 97%; overflow: auto"> |       <div style="height: 97%; overflow: auto"> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user