mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
promoted attributes widget is now auto-updating, fixes #700
This commit is contained in:
parent
11b73b79ed
commit
2c609e8136
@ -105,7 +105,7 @@ class Attribute extends Entity {
|
|||||||
|
|
||||||
// cannot be static!
|
// cannot be static!
|
||||||
updatePojo(pojo) {
|
updatePojo(pojo) {
|
||||||
delete pojo.__note;
|
delete pojo.__note; // FIXME: probably note necessary anymore
|
||||||
}
|
}
|
||||||
|
|
||||||
createClone(type, name, value) {
|
createClone(type, name, value) {
|
||||||
|
@ -152,10 +152,10 @@ function AttributesModel() {
|
|||||||
attr.value = treeService.getNoteIdFromNotePath(attr.selectedPath);
|
attr.value = treeService.getNoteIdFromNotePath(attr.selectedPath);
|
||||||
}
|
}
|
||||||
else if (attr.type === 'label-definition') {
|
else if (attr.type === 'label-definition') {
|
||||||
attr.value = attr.labelDefinition;
|
attr.value = JSON.stringify(attr.labelDefinition);
|
||||||
}
|
}
|
||||||
else if (attr.type === 'relation-definition') {
|
else if (attr.type === 'relation-definition') {
|
||||||
attr.value = attr.relationDefinition;
|
attr.value = JSON.stringify(attr.relationDefinition);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete attr.labelValue;
|
delete attr.labelValue;
|
||||||
|
@ -54,8 +54,9 @@ export default class LoadResults {
|
|||||||
this.attributes.push({attributeId, sourceId});
|
this.attributes.push({attributeId, sourceId});
|
||||||
}
|
}
|
||||||
|
|
||||||
getAttributes() {
|
getAttributes(sourceId = 'none') {
|
||||||
return this.attributes
|
return this.attributes
|
||||||
|
.filter(row => row.sourceId !== sourceId)
|
||||||
.map(row => this.treeCache.attributes[row.attributeId])
|
.map(row => this.treeCache.attributes[row.attributeId])
|
||||||
.filter(attr => !!attr);
|
.filter(attr => !!attr);
|
||||||
}
|
}
|
||||||
|
@ -229,7 +229,7 @@ export default class PromotedAttributesWidget extends TabAwareWidget {
|
|||||||
.prop("title", "Remove this attribute")
|
.prop("title", "Remove this attribute")
|
||||||
.on('click', async () => {
|
.on('click', async () => {
|
||||||
if (valueAttr.attributeId) {
|
if (valueAttr.attributeId) {
|
||||||
await server.remove("notes/" + this.noteId + "/attributes/" + valueAttr.attributeId);
|
await server.remove("notes/" + this.noteId + "/attributes/" + valueAttr.attributeId, this.componentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
$tr.remove();
|
$tr.remove();
|
||||||
@ -263,13 +263,18 @@ export default class PromotedAttributesWidget extends TabAwareWidget {
|
|||||||
type: $attr.prop("attribute-type"),
|
type: $attr.prop("attribute-type"),
|
||||||
name: $attr.prop("attribute-name"),
|
name: $attr.prop("attribute-name"),
|
||||||
value: value
|
value: value
|
||||||
});
|
}, this.componentId);
|
||||||
|
|
||||||
$attr.prop("attribute-id", result.attributeId);
|
$attr.prop("attribute-id", result.attributeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
entitiesReloadedEvent({loadResults}) {
|
entitiesReloadedEvent({loadResults}) {console.log("loadResults", loadResults);
|
||||||
if (loadResults.getAttributes().find(attr => attr.noteId === this.noteId)) {
|
// relation/label definitions are very often inherited by tree or template,
|
||||||
|
// it's difficult to detect inheritance so we will
|
||||||
|
if (loadResults.getAttributes(this.componentId).find(attr =>
|
||||||
|
attr.noteId === this.noteId
|
||||||
|
|| ['label-definition', 'relation-definition'].includes(attr.type))) {
|
||||||
|
|
||||||
this.refresh();
|
this.refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user