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" } | ||||
|     ]; | ||||
|  | ||||
|     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) { | ||||
|         self.getTargetAttribute(event.target).valueHasMutated(); | ||||
|     }; | ||||
|  | ||||
|     this.valueTypeChanged = function(data, event) { | ||||
|         self.getTargetAttribute(event.target).valueHasMutated(); | ||||
|     }; | ||||
|  | ||||
|     this.updateAttributePositions = function() { | ||||
|         let position = 0; | ||||
|  | ||||
| @@ -43,6 +60,11 @@ function AttributesModel() { | ||||
|         for (const attr of attributes) { | ||||
|             attr.labelValue = attr.type === 'label' ? attr.value : ''; | ||||
|             attr.relationValue = attr.type === 'relation' ? attr.value : ''; | ||||
|             attr.definition = { | ||||
|                 valueType: "text", | ||||
|                 multiplicityType: "singlevalue", | ||||
|                 showInUi: "true" | ||||
|             }; | ||||
|  | ||||
|             delete attr.value; | ||||
|         } | ||||
| @@ -127,7 +149,12 @@ function AttributesModel() { | ||||
|                 relationValue: '', | ||||
|                 isInheritable: false, | ||||
|                 isDeleted: 0, | ||||
|                 position: 0 | ||||
|                 position: 0, | ||||
|                 definition: { | ||||
|                     valueType: "text", | ||||
|                     multiplicityType: "singlevalue", | ||||
|                     showInUi: "true" | ||||
|                 } | ||||
|             })); | ||||
|         } | ||||
|     } | ||||
|   | ||||
| @@ -566,7 +566,6 @@ | ||||
|             <thead> | ||||
|             <tr> | ||||
|               <th></th> | ||||
|               <th>ID</th> | ||||
|               <th>Type</th> | ||||
|               <th>Name</th> | ||||
|               <th>Value</th> | ||||
| @@ -575,13 +574,11 @@ | ||||
|             </tr> | ||||
|             </thead> | ||||
|             <tbody data-bind="foreach: attributes"> | ||||
|             <tr data-bind="if: isDeleted == 0" class="attribute-row"> | ||||
|               <tr data-bind="if: isDeleted == 0"> | ||||
|                 <td class="handle"> | ||||
|                   <span class="glyphicon glyphicon-resize-vertical"></span> | ||||
|                   <input type="hidden" name="position" data-bind="value: position"/> | ||||
|                 </td> | ||||
|               <!-- ID column has specific width because if it's empty its size can be deformed when dragging --> | ||||
|               <td data-bind="text: attributeId" style="min-width: 10em; font-size: smaller;"></td> | ||||
|                 <td> | ||||
|                     <select data-bind="options: $parent.availableTypes, optionsText: 'text', optionsValue: 'value', value: type, event: { change: $parent.typeChanged }"></select> | ||||
|                 </td> | ||||
| @@ -602,6 +599,14 @@ | ||||
|  | ||||
|                     <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 data-bind="visible: type == 'definition'"> | ||||
|                     <select data-bind="options: $parent.availableValueTypes, optionsText: 'text', optionsValue: 'value', value: definition.valueType"></select> | ||||
|  | ||||
|                     <select data-bind="options: $parent.multiplicityTypes, optionsText: 'text', optionsValue: 'value', value: definition.multiplicityType"></select> | ||||
|  | ||||
|                     <input type="checkbox" value="true" data-bind="checked: definition.showInUi" /> Show In UI | ||||
|                   </div> | ||||
|                 </td> | ||||
|                 <td title="Inheritable relations are automatically inherited to the child notes"> | ||||
|                   <input type="checkbox" value="1" data-bind="checked: isInheritable" /> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user