fix(views/table): changing column inheritability not working

This commit is contained in:
Elian Doran 2025-07-19 13:31:46 +03:00
parent beb1c15fa5
commit ebff644d24
No known key found for this signature in database

View File

@ -82,17 +82,18 @@ export default class TableColumnEditing extends Component {
const { name, value, isInheritable } = this.newAttribute; const { name, value, isInheritable } = this.newAttribute;
this.api.blockRedraw(); this.api.blockRedraw();
const isRename = (this.existingAttributeToEdit && this.existingAttributeToEdit.name !== name);
try { try {
if (this.existingAttributeToEdit && this.existingAttributeToEdit.name !== name) { if (isRename) {
const oldName = this.existingAttributeToEdit.name.split(":")[1]; const oldName = this.existingAttributeToEdit!.name.split(":")[1];
const [ type, newName ] = name.split(":"); const [ type, newName ] = name.split(":");
await renameColumn(this.parentNote.noteId, type as "label" | "relation", oldName, newName); await renameColumn(this.parentNote.noteId, type as "label" | "relation", oldName, newName);
} }
attributes.setLabel(this.parentNote.noteId, name, value, isInheritable); if (this.existingAttributeToEdit && (isRename || this.existingAttributeToEdit.isInheritable !== isInheritable)) {
if (this.existingAttributeToEdit) {
attributes.removeOwnedLabelByName(this.parentNote, this.existingAttributeToEdit.name); attributes.removeOwnedLabelByName(this.parentNote, this.existingAttributeToEdit.name);
} }
attributes.setLabel(this.parentNote.noteId, name, value, isInheritable);
} finally { } finally {
this.api.restoreRedraw(); this.api.restoreRedraw();
} }
@ -134,17 +135,17 @@ export default class TableColumnEditing extends Component {
return this.parentNote.getLabel(attrName); return this.parentNote.getLabel(attrName);
} }
getAttributeFromField(field: string) { getAttributeFromField(field: string): Attribute | undefined {
const fAttribute = this.getFAttributeFromField(field); const fAttribute = this.getFAttributeFromField(field);
if (fAttribute) { if (fAttribute) {
return { return {
name: fAttribute.name, name: fAttribute.name,
value: fAttribute.value, value: fAttribute.value,
type: fAttribute.type type: fAttribute.type,
isInheritable: fAttribute.isInheritable
}; };
} }
return undefined; return undefined;
} }
} }