mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +01:00 
			
		
		
		
	attribute definition work in progress
This commit is contained in:
		| @@ -19,10 +19,27 @@ function AttributesModel() { | |||||||
|         { text: "Relation", value: "relation" } |         { text: "Relation", value: "relation" } | ||||||
|     ]; |     ]; | ||||||
|  |  | ||||||
|  |     this.availableValueTypes = [ | ||||||
|  |         { text: "Text", value: "text" }, | ||||||
|  |         { text: "Integer", value: "integer" }, | ||||||
|  |         { text: "Decimal", value: "decimal" }, | ||||||
|  |         { text: "Boolean", value: "boolean" }, | ||||||
|  |         { text: "Date", value: "date" } | ||||||
|  |     ]; | ||||||
|  |  | ||||||
|  |     this.multiplicityTypes = [ | ||||||
|  |         { text: "Single value", value: "singlevalue" }, | ||||||
|  |         { text: "Multi value", value: "multivalue" } | ||||||
|  |     ]; | ||||||
|  |  | ||||||
|     this.typeChanged = function(data, event) { |     this.typeChanged = function(data, event) { | ||||||
|         self.getTargetAttribute(event.target).valueHasMutated(); |         self.getTargetAttribute(event.target).valueHasMutated(); | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
|  |     this.valueTypeChanged = function(data, event) { | ||||||
|  |         self.getTargetAttribute(event.target).valueHasMutated(); | ||||||
|  |     }; | ||||||
|  |  | ||||||
|     this.updateAttributePositions = function() { |     this.updateAttributePositions = function() { | ||||||
|         let position = 0; |         let position = 0; | ||||||
|  |  | ||||||
| @@ -43,6 +60,11 @@ function AttributesModel() { | |||||||
|         for (const attr of attributes) { |         for (const attr of attributes) { | ||||||
|             attr.labelValue = attr.type === 'label' ? attr.value : ''; |             attr.labelValue = attr.type === 'label' ? attr.value : ''; | ||||||
|             attr.relationValue = attr.type === 'relation' ? attr.value : ''; |             attr.relationValue = attr.type === 'relation' ? attr.value : ''; | ||||||
|  |             attr.definition = { | ||||||
|  |                 valueType: "text", | ||||||
|  |                 multiplicityType: "singlevalue", | ||||||
|  |                 showInUi: "true" | ||||||
|  |             }; | ||||||
|  |  | ||||||
|             delete attr.value; |             delete attr.value; | ||||||
|         } |         } | ||||||
| @@ -127,7 +149,12 @@ function AttributesModel() { | |||||||
|                 relationValue: '', |                 relationValue: '', | ||||||
|                 isInheritable: false, |                 isInheritable: false, | ||||||
|                 isDeleted: 0, |                 isDeleted: 0, | ||||||
|                 position: 0 |                 position: 0, | ||||||
|  |                 definition: { | ||||||
|  |                     valueType: "text", | ||||||
|  |                     multiplicityType: "singlevalue", | ||||||
|  |                     showInUi: "true" | ||||||
|  |                 } | ||||||
|             })); |             })); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -566,7 +566,6 @@ | |||||||
|             <thead> |             <thead> | ||||||
|             <tr> |             <tr> | ||||||
|               <th></th> |               <th></th> | ||||||
|               <th>ID</th> |  | ||||||
|               <th>Type</th> |               <th>Type</th> | ||||||
|               <th>Name</th> |               <th>Name</th> | ||||||
|               <th>Value</th> |               <th>Value</th> | ||||||
| @@ -575,41 +574,47 @@ | |||||||
|             </tr> |             </tr> | ||||||
|             </thead> |             </thead> | ||||||
|             <tbody data-bind="foreach: attributes"> |             <tbody data-bind="foreach: attributes"> | ||||||
|             <tr data-bind="if: isDeleted == 0" class="attribute-row"> |               <tr data-bind="if: isDeleted == 0"> | ||||||
|               <td class="handle"> |                 <td class="handle"> | ||||||
|                 <span class="glyphicon glyphicon-resize-vertical"></span> |                   <span class="glyphicon glyphicon-resize-vertical"></span> | ||||||
|                 <input type="hidden" name="position" data-bind="value: position"/> |                   <input type="hidden" name="position" data-bind="value: position"/> | ||||||
|               </td> |                 </td> | ||||||
|               <!-- ID column has specific width because if it's empty its size can be deformed when dragging --> |                 <td> | ||||||
|               <td data-bind="text: attributeId" style="min-width: 10em; font-size: smaller;"></td> |                     <select data-bind="options: $parent.availableTypes, optionsText: 'text', optionsValue: 'value', value: type, event: { change: $parent.typeChanged }"></select> | ||||||
|               <td> |                 </td> | ||||||
|                   <select data-bind="options: $parent.availableTypes, optionsText: 'text', optionsValue: 'value', value: type, event: { change: $parent.typeChanged }"></select> |                 <td> | ||||||
|               </td> |                   <!-- Change to valueUpdate: blur is necessary because jQuery UI autocomplete hijacks change event --> | ||||||
|               <td> |                   <input type="text" class="attribute-name form-control" data-bind="value: name, valueUpdate: 'blur',  event: { blur: $parent.attributeChanged }"/> | ||||||
|                 <!-- Change to valueUpdate: blur is necessary because jQuery UI autocomplete hijacks change event --> |                   <div style="color: yellowgreen" data-bind="if: $parent.isNotUnique($index())"><span class="glyphicon glyphicon-info-sign"></span> Duplicate attribute.</div> | ||||||
|                 <input type="text" class="attribute-name form-control" data-bind="value: name, valueUpdate: 'blur',  event: { blur: $parent.attributeChanged }"/> |                   <div style="color: red" data-bind="if: $parent.isEmptyName($index())">Attribute name can't be empty.</div> | ||||||
|                 <div style="color: yellowgreen" data-bind="if: $parent.isNotUnique($index())"><span class="glyphicon glyphicon-info-sign"></span> Duplicate attribute.</div> |                 </td> | ||||||
|                 <div style="color: red" data-bind="if: $parent.isEmptyName($index())">Attribute name can't be empty.</div> |                 <td> | ||||||
|               </td> |                   <input type="text" class="label-value form-control" data-bind="visible: type == 'label', value: labelValue, valueUpdate: 'blur', event: { blur: $parent.attributeChanged }" style="width: 300px"/> | ||||||
|               <td> |  | ||||||
|                 <input type="text" class="label-value form-control" data-bind="visible: type == 'label', value: labelValue, valueUpdate: 'blur', event: { blur: $parent.attributeChanged }" style="width: 300px"/> |  | ||||||
|  |  | ||||||
|                 <div class="relation-value input-group" data-bind="visible: type == 'relation'"> |                   <div class="relation-value input-group" data-bind="visible: type == 'relation'"> | ||||||
|                   <input class="form-control relation-target-note-id" |                     <input class="form-control relation-target-note-id" | ||||||
|                          placeholder="search for note by its name" |                            placeholder="search for note by its name" | ||||||
|                          data-bind="value: relationValue, valueUpdate: 'blur', event: { blur: $parent.attributeChanged }" |                            data-bind="value: relationValue, valueUpdate: 'blur', event: { blur: $parent.attributeChanged }" | ||||||
|                          style="width: 300px;"> |                            style="width: 300px;"> | ||||||
|  |  | ||||||
|                   <span class="input-group-addon relations-show-recent-notes" title="Show recent notes" style="background: url('/images/icons/clock-16.png') no-repeat center; cursor: pointer;"></span> |                     <span class="input-group-addon relations-show-recent-notes" title="Show recent notes" style="background: url('/images/icons/clock-16.png') no-repeat center; cursor: pointer;"></span> | ||||||
|                 </div> |                   </div> | ||||||
|               </td> |  | ||||||
|               <td title="Inheritable relations are automatically inherited to the child notes"> |                   <div data-bind="visible: type == 'definition'"> | ||||||
|                 <input type="checkbox" value="1" data-bind="checked: isInheritable" /> |                     <select data-bind="options: $parent.availableValueTypes, optionsText: 'text', optionsValue: 'value', value: definition.valueType"></select> | ||||||
|               </td> |  | ||||||
|               <td title="Delete" style="padding: 13px; cursor: pointer;"> |                     <select data-bind="options: $parent.multiplicityTypes, optionsText: 'text', optionsValue: 'value', value: definition.multiplicityType"></select> | ||||||
|                 <span class="glyphicon glyphicon-trash" data-bind="click: $parent.deleteAttribute"></span> |  | ||||||
|               </td> |                     <input type="checkbox" value="true" data-bind="checked: definition.showInUi" /> Show In UI | ||||||
|             </tr> |                   </div> | ||||||
|  |                 </td> | ||||||
|  |                 <td title="Inheritable relations are automatically inherited to the child notes"> | ||||||
|  |                   <input type="checkbox" value="1" data-bind="checked: isInheritable" /> | ||||||
|  |                 </td> | ||||||
|  |                 <td title="Delete" style="padding: 13px; cursor: pointer;"> | ||||||
|  |                   <span class="glyphicon glyphicon-trash" data-bind="click: $parent.deleteAttribute"></span> | ||||||
|  |                 </td> | ||||||
|  |               </tr> | ||||||
|             </tbody> |             </tbody> | ||||||
|           </table> |           </table> | ||||||
|         </div> |         </div> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user