mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
fix saving & refreshing attributes across compoments
This commit is contained in:
parent
935e5de493
commit
ae909d1079
@ -432,4 +432,10 @@ export default class AttributeEditorWidget extends TabAwareWidget {
|
|||||||
updateAttributeList(attributes) {
|
updateAttributeList(attributes) {
|
||||||
this.renderOwnedAttributes(attributes, false);
|
this.renderOwnedAttributes(attributes, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
entitiesReloadedEvent({loadResults}) {
|
||||||
|
if (loadResults.getAttributes(this.componentId).find(attr => attr.isAffecting(this.note))) {
|
||||||
|
this.refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -162,9 +162,10 @@ export default class AttributeListWidget extends TabAwareWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async refreshWithNote(note) {
|
async refreshWithNote(note) {
|
||||||
const hasPromotedAttrs = this.promotedAttributesWidget.getPromotedAttributes().length > 0;
|
const hasPromotedAttrs = this.promotedAttributesWidget.getPromotedDefinitionAttributes().length > 0;
|
||||||
|
|
||||||
if (hasPromotedAttrs) {
|
if (hasPromotedAttrs) {
|
||||||
|
this.$promotedExpander.show();
|
||||||
this.$allAttrWrapper.toggle(options.is('promotedAttributesExpanded'));
|
this.$allAttrWrapper.toggle(options.is('promotedAttributesExpanded'));
|
||||||
this.$ownedAndInheritedWrapper.hide();
|
this.$ownedAndInheritedWrapper.hide();
|
||||||
this.$inheritedAttributesWrapper.hide();
|
this.$inheritedAttributesWrapper.hide();
|
||||||
|
@ -10,9 +10,7 @@ const TPL = `
|
|||||||
<div class="calendar-header">
|
<div class="calendar-header">
|
||||||
<button class="calendar-btn bx bx-left-arrow-alt" data-calendar-toggle="previous"></button>
|
<button class="calendar-btn bx bx-left-arrow-alt" data-calendar-toggle="previous"></button>
|
||||||
|
|
||||||
<div class="calendar-header-label" data-calendar-label="month">
|
<div class="calendar-header-label" data-calendar-label="month"></div>
|
||||||
March 2017
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button class="calendar-btn bx bx-right-arrow-alt" data-calendar-toggle="next"></button>
|
<button class="calendar-btn bx bx-right-arrow-alt" data-calendar-toggle="next"></button>
|
||||||
</div>
|
</div>
|
||||||
@ -161,4 +159,4 @@ export default class CalendarWidget extends CollapsibleWidget {
|
|||||||
'December'
|
'December'
|
||||||
][monthIndex];
|
][monthIndex];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,26 +43,26 @@ export default class PromotedAttributesWidget extends TabAwareWidget {
|
|||||||
async refreshWithNote(note) {
|
async refreshWithNote(note) {
|
||||||
this.$container.empty();
|
this.$container.empty();
|
||||||
|
|
||||||
const promotedAttributes = this.getPromotedAttributes();
|
const promotedDefAttrs = this.getPromotedDefinitionAttributes();
|
||||||
const attributes = note.getAttributes();
|
const ownedAttributes = note.getOwnedAttributes();
|
||||||
|
|
||||||
const cells = [];
|
if (promotedDefAttrs.length === 0) {
|
||||||
|
|
||||||
if (promotedAttributes.length === 0) {
|
|
||||||
this.toggleInt(false);
|
this.toggleInt(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const definitionAttr of promotedAttributes) {
|
const cells = [];
|
||||||
const definitionType = definitionAttr.name.startsWith('label:') ? 'label' : 'relation';
|
|
||||||
const valueName = definitionAttr.name.substr(definitionType.length + 1);
|
|
||||||
|
|
||||||
let valueAttrs = attributes.filter(el => el.name === valueName && el.type === definitionType);
|
for (const definitionAttr of promotedDefAttrs) {
|
||||||
|
const valueType = definitionAttr.name.startsWith('label:') ? 'label' : 'relation';
|
||||||
|
const valueName = definitionAttr.name.substr(valueType.length + 1);
|
||||||
|
|
||||||
|
let valueAttrs = ownedAttributes.filter(el => el.name === valueName && el.type === valueType);
|
||||||
|
|
||||||
if (valueAttrs.length === 0) {
|
if (valueAttrs.length === 0) {
|
||||||
valueAttrs.push({
|
valueAttrs.push({
|
||||||
attributeId: "",
|
attributeId: "",
|
||||||
type: definitionType,
|
type: valueType,
|
||||||
name: valueName,
|
name: valueName,
|
||||||
value: ""
|
value: ""
|
||||||
});
|
});
|
||||||
@ -85,7 +85,7 @@ export default class PromotedAttributesWidget extends TabAwareWidget {
|
|||||||
this.toggleInt(true);
|
this.toggleInt(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
getPromotedAttributes() {
|
getPromotedDefinitionAttributes() {
|
||||||
if (this.note.hasLabel('hidePromotedAttributes')) {
|
if (this.note.hasLabel('hidePromotedAttributes')) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,7 @@
|
|||||||
|
|
||||||
.calendar-widget .calendar-date {
|
.calendar-widget .calendar-date {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
color: var(--main-text-color);
|
||||||
background-color: var(--main-background-color);
|
background-color: var(--main-background-color);
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@ -90,4 +91,4 @@
|
|||||||
|
|
||||||
.calendar-widget .calendar-date:not(.calendar-date-active) {
|
.calendar-widget .calendar-date:not(.calendar-date-active) {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ function updateNoteAttributes(req) {
|
|||||||
|
|
||||||
const note = repository.getNote(noteId);
|
const note = repository.getNote(noteId);
|
||||||
|
|
||||||
let existingAttrs = note.getAttributes();
|
let existingAttrs = note.getOwnedAttributes();
|
||||||
|
|
||||||
let position = 0;
|
let position = 0;
|
||||||
|
|
||||||
|
@ -121,7 +121,10 @@ eventService.subscribe([eventService.ENTITY_CHANGED, eventService.ENTITY_DELETED
|
|||||||
}
|
}
|
||||||
|
|
||||||
delete noteCache.attributes[attributeId];
|
delete noteCache.attributes[attributeId];
|
||||||
delete noteCache.attributeIndex[`${attr.type}-${attr.name}`];
|
|
||||||
|
if (attr) {
|
||||||
|
delete noteCache.attributeIndex[`${attr.type}-${attr.name}`];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (attributeId in noteCache.attributes) {
|
else if (attributeId in noteCache.attributes) {
|
||||||
const attr = noteCache.attributes[attributeId];
|
const attr = noteCache.attributes[attributeId];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user