Skip to content

Commit

Permalink
removes old code path for reportsave
Browse files Browse the repository at this point in the history
  • Loading branch information
jhmullen authored and davelandry committed May 30, 2019
1 parent fd7c67f commit f46db6b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 22 deletions.
27 changes: 6 additions & 21 deletions packages/cms/src/profile/ProfileBuilder.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -341,39 +341,24 @@ class ProfileBuilder extends Component {
}

/**
* If a save occurred in one of the editors, the user may have changed the slug/title. This callback is responsible for
* updating the tree labels accordingly. If the user has changed a slug, the "masterSlug" reference that ALL children
* of a profile use must be recursively updated as well.
* If a save occurred in the TopicEditor, the user may have changed the slug/title. This callback is responsible for
* updating the tree labels accordingly.
*/
reportSave(type, id, newValue) {
reportSave(id, newValue) {
const {nodes} = this.state;
const {variablesHash, currentPid} = this.state;
const {localeDefault} = this.props;
const formatters = this.context.formatters[localeDefault];
const {stripHTML} = formatters;
const variables = variablesHash[currentPid] && variablesHash[currentPid][localeDefault] ? deepClone(variablesHash[currentPid][localeDefault]) : null;
const node = this.locateNode.bind(this)(type, id);
// Update the label based on the new value. If this is a topic, this is the only thing needed
if (type === "topic" && node) {
const node = this.locateNode.bind(this)("topic", id);
// Update the label based on the new value.
if (node) {
const defCon = node.data.content.find(c => c.lang === localeDefault);
if (defCon) defCon.title = newValue;
// todo: determine if this could be merged with formatTreeVariables
node.label = varSwap(this.decode(stripHTML(newValue)), formatters, variables);
}
// However, if this is a profile changing its slug, then all children must be informed so their masterSlug is up to date.
// TODO bivariate: when a save comes from the dimensionEditor, this will have to do something special
if (type === "profile") {
console.log("bivariate: handle this better!");
/*
node.masterSlug = newValue;
node.data.slug = newValue;
node.label = newValue;
node.childNodes = node.childNodes.map(t => {
t.masterSlug = newValue;
return t;
});
*/
}
this.setState({nodes});
}

Expand Down
2 changes: 1 addition & 1 deletion packages/cms/src/profile/TopicEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class TopicEditor extends Component {
const {localeDefault} = this.props;
const defCon = minData.content.find(c => c.lang === localeDefault);
const title = defCon && defCon.title ? defCon.title : minData.slug;
if (this.props.reportSave) this.props.reportSave("topic", minData.id, title);
if (this.props.reportSave) this.props.reportSave(minData.id, title);
}

onMove() {
Expand Down

0 comments on commit f46db6b

Please sign in to comment.