mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-29 03:23:25 +08:00 
			
		
		
		
	attribute dialog doesn't allow to (attempt to) save relation without target note
This commit is contained in:
		
							parent
							
								
									3608857f25
								
							
						
					
					
						commit
						5bf5d1cac4
					
				| @ -114,7 +114,7 @@ function AttributesModel() { | ||||
| 
 | ||||
|     function isValid() { | ||||
|         for (let attributes = self.ownedAttributes(), i = 0; i < attributes.length; i++) { | ||||
|             if (self.isEmptyName(i)) { | ||||
|             if (self.isEmptyName(i) || self.isEmptyRelationTarget(i)) { | ||||
|                 return false; | ||||
|             } | ||||
|         } | ||||
| @ -212,6 +212,12 @@ function AttributesModel() { | ||||
|         return cur.name.trim() === "" && !cur.isDeleted && (cur.attributeId !== "" || cur.labelValue !== "" || cur.relationValue); | ||||
|     }; | ||||
| 
 | ||||
|     this.isEmptyRelationTarget = function(index) { | ||||
|         const cur = self.ownedAttributes()[index](); | ||||
| 
 | ||||
|         return cur.type === "relation" && !cur.isDeleted && cur.name && !cur.relationValue; | ||||
|     }; | ||||
| 
 | ||||
|     this.getTargetAttribute = function(target) { | ||||
|         const context = ko.contextFor(target); | ||||
|         const index = context.$index(); | ||||
|  | ||||
| @ -92,7 +92,7 @@ function initNoteAutocomplete($el, options) { | ||||
|         $el.on('autocomplete:selected', (event, suggestion) => $el.setSelectedPath(suggestion.path)); | ||||
|         $el.on('autocomplete:closed', () => { | ||||
|             if (!$el.val().trim()) { | ||||
|                 $el.setSelectedPath(""); | ||||
|                 clearText($el); | ||||
|             } | ||||
|         }); | ||||
|     } | ||||
|  | ||||
| @ -48,6 +48,10 @@ | ||||
|                     <input class="form-control relation-target-note-id" | ||||
|                          placeholder="search for note by its name" | ||||
|                          data-bind="noteAutocomplete, value: relationValue, valueUpdate: 'blur', event: { blur: $parent.attributeChanged }"> | ||||
| 
 | ||||
|                     <div style="color: red" data-bind="if: $parent.isEmptyRelationTarget($index())">Relation target note | ||||
|                       can't be empty. | ||||
|                     </div> | ||||
|                   </div> | ||||
| 
 | ||||
|                   <div data-bind="visible: type == 'label-definition'"> | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 azivner
						azivner