Skip to content

Commit

Permalink
Use the same extra_field key on the frontend as on the backend.
Browse files Browse the repository at this point in the history
  • Loading branch information
rtibbles committed Sep 23, 2024
1 parent 8a3d383 commit be2ddcd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@
// as to be inherited or not by a previous interaction with the modal.
return Boolean(
this.parent &&
this.parent?.extra_fields?.inherit_metadata &&
this.parent?.extra_fields?.inherited_metadata &&
Object.keys(this.inheritableMetadataItems).every(
field => !isUndefined(this.parent.extra_fields.inherit_metadata[field])
field => !isUndefined(this.parent.extra_fields.inherited_metadata[field])
)
);
},
Expand Down Expand Up @@ -203,10 +203,10 @@
ContentNode.getAncestors(this.parent.id).then(ancestors => {
for (const field of inheritableFields) {
if (
this.parent.extra_fields.inherit_metadata &&
this.parent.extra_fields.inherit_metadata[field]
this.parent.extra_fields.inherited_metadata &&
this.parent.extra_fields.inherited_metadata[field]
) {
this.checks[field] = this.parent.extra_fields.inherit_metadata[field];
this.checks[field] = this.parent.extra_fields.inherited_metadata[field];
}
}
this.categories = ancestors.reduce((acc, ancestor) => {
Expand Down Expand Up @@ -258,19 +258,19 @@
// but just in case, return
return;
}
const inherit_metadata = {
...(this.parent?.extra_fields.inherit_metadata || {}),
const inherited_metadata = {
...(this.parent?.extra_fields.inherited_metadata || {}),
};
for (const field of inheritableFields) {
if (this.inheritableMetadataItems[field]) {
// Only store preferences for fields that have been shown to the user as inheritable
inherit_metadata[field] = this.checks[field];
inherited_metadata[field] = this.checks[field];
}
}
this.updateContentNode({
id: this.parent.id,
extra_fields: {
inherit_metadata,
inherited_metadata,
},
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,8 @@ function generateContentNodeData({
if (extra_fields.suggested_duration_type) {
contentNodeData.extra_fields.suggested_duration_type = extra_fields.suggested_duration_type;
}
if (extra_fields.inherit_metadata) {
contentNodeData.extra_fields.inherit_metadata = extra_fields.inherit_metadata;
if (extra_fields.inherited_metadata) {
contentNodeData.extra_fields.inherited_metadata = { ...extra_fields.inherited_metadata };
}
}
if (prerequisite !== NOVALUE) {
Expand Down Expand Up @@ -369,11 +369,11 @@ export function updateContentNode(context, { id, mergeMapFields, ...payload } =
};
}

if (contentNodeData.extra_fields.inherit_metadata) {
// Don't set inherit_metadata on non-topic nodes
if (contentNodeData.extra_fields.inherited_metadata) {
// Don't set inherited_metadata on non-topic nodes
// as they cannot have children to bequeath metadata to
if (node.kind !== ContentKindsNames.TOPIC) {
delete contentNodeData.extra_fields.inherit_metadata;
delete contentNodeData.extra_fields.inherited_metadata;
}
}

Expand Down

0 comments on commit be2ddcd

Please sign in to comment.