mirror of
https://github.com/zadam/trilium.git
synced 2025-02-24 15:05:31 +08:00
attribute definition work in progress
This commit is contained in:
parent
96dc56098d
commit
f437be7af0
2 changed files with 67 additions and 35 deletions
|
@ -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,13 +574,11 @@
|
||||||
</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 data-bind="text: attributeId" style="min-width: 10em; font-size: smaller;"></td>
|
|
||||||
<td>
|
<td>
|
||||||
<select data-bind="options: $parent.availableTypes, optionsText: 'text', optionsValue: 'value', value: type, event: { change: $parent.typeChanged }"></select>
|
<select data-bind="options: $parent.availableTypes, optionsText: 'text', optionsValue: 'value', value: type, event: { change: $parent.typeChanged }"></select>
|
||||||
</td>
|
</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>
|
<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>
|
||||||
|
|
||||||
|
<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>
|
||||||
<td title="Inheritable relations are automatically inherited to the child notes">
|
<td title="Inheritable relations are automatically inherited to the child notes">
|
||||||
<input type="checkbox" value="1" data-bind="checked: isInheritable" />
|
<input type="checkbox" value="1" data-bind="checked: isInheritable" />
|
||||||
|
|
Loading…
Reference in a new issue