fix saving & refreshing attributes across compoments

This commit is contained in:
zadam 2020-08-12 00:02:19 +02:00
parent 935e5de493
commit ae909d1079
7 changed files with 28 additions and 19 deletions

View file

@ -432,4 +432,10 @@ export default class AttributeEditorWidget extends TabAwareWidget {
updateAttributeList(attributes) {
this.renderOwnedAttributes(attributes, false);
}
entitiesReloadedEvent({loadResults}) {
if (loadResults.getAttributes(this.componentId).find(attr => attr.isAffecting(this.note))) {
this.refresh();
}
}
}

View file

@ -162,9 +162,10 @@ export default class AttributeListWidget extends TabAwareWidget {
}
async refreshWithNote(note) {
const hasPromotedAttrs = this.promotedAttributesWidget.getPromotedAttributes().length > 0;
const hasPromotedAttrs = this.promotedAttributesWidget.getPromotedDefinitionAttributes().length > 0;
if (hasPromotedAttrs) {
this.$promotedExpander.show();
this.$allAttrWrapper.toggle(options.is('promotedAttributesExpanded'));
this.$ownedAndInheritedWrapper.hide();
this.$inheritedAttributesWrapper.hide();

View file

@ -10,9 +10,7 @@ const TPL = `
<div class="calendar-header">
<button class="calendar-btn bx bx-left-arrow-alt" data-calendar-toggle="previous"></button>
<div class="calendar-header-label" data-calendar-label="month">
March 2017
</div>
<div class="calendar-header-label" data-calendar-label="month"></div>
<button class="calendar-btn bx bx-right-arrow-alt" data-calendar-toggle="next"></button>
</div>
@ -161,4 +159,4 @@ export default class CalendarWidget extends CollapsibleWidget {
'December'
][monthIndex];
}
}
}

View file

@ -43,26 +43,26 @@ export default class PromotedAttributesWidget extends TabAwareWidget {
async refreshWithNote(note) {
this.$container.empty();
const promotedAttributes = this.getPromotedAttributes();
const attributes = note.getAttributes();
const promotedDefAttrs = this.getPromotedDefinitionAttributes();
const ownedAttributes = note.getOwnedAttributes();
const cells = [];
if (promotedAttributes.length === 0) {
if (promotedDefAttrs.length === 0) {
this.toggleInt(false);
return;
}
for (const definitionAttr of promotedAttributes) {
const definitionType = definitionAttr.name.startsWith('label:') ? 'label' : 'relation';
const valueName = definitionAttr.name.substr(definitionType.length + 1);
const cells = [];
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) {
valueAttrs.push({
attributeId: "",
type: definitionType,
type: valueType,
name: valueName,
value: ""
});
@ -85,7 +85,7 @@ export default class PromotedAttributesWidget extends TabAwareWidget {
this.toggleInt(true);
}
getPromotedAttributes() {
getPromotedDefinitionAttributes() {
if (this.note.hasLabel('hidePromotedAttributes')) {
return [];
}

View file

@ -61,6 +61,7 @@
.calendar-widget .calendar-date {
align-items: center;
color: var(--main-text-color);
background-color: var(--main-background-color);
display: flex;
flex-direction: column;
@ -90,4 +91,4 @@
.calendar-widget .calendar-date:not(.calendar-date-active) {
cursor: pointer;
}
}

View file

@ -89,7 +89,7 @@ function updateNoteAttributes(req) {
const note = repository.getNote(noteId);
let existingAttrs = note.getAttributes();
let existingAttrs = note.getOwnedAttributes();
let position = 0;

View file

@ -121,7 +121,10 @@ eventService.subscribe([eventService.ENTITY_CHANGED, eventService.ENTITY_DELETED
}
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) {
const attr = noteCache.attributes[attributeId];