correctly propagate update to all components
This commit is contained in:
+32
-9
@@ -327,11 +327,18 @@
|
|||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
return {
|
return {
|
||||||
active: this.props.state,
|
active: this.props.state,
|
||||||
text: this.props.text || "",
|
text: this.props.text || ""
|
||||||
changed: false
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
componentWillReceiveProps: function(newProps) {
|
||||||
|
// If text has changed while in read mode, update text and discard changes.
|
||||||
|
// Ignore update if in edit mode.
|
||||||
|
if (this.props.text != newProps.text && !this.state.active) {
|
||||||
|
this.setState({text: newProps.text || ""});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
handeTextChange: function(e) {
|
handeTextChange: function(e) {
|
||||||
this.setState({text: e.target.value});
|
this.setState({text: e.target.value});
|
||||||
},
|
},
|
||||||
@@ -347,8 +354,10 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
handleStartEditing: function() {
|
handleStartEditing: function() {
|
||||||
ReactDOM.findDOMNode(this).focus();
|
if (!this.props.readOnly) {
|
||||||
this.setState({active: !this.props.readOnly});
|
ReactDOM.findDOMNode(this).focus();
|
||||||
|
this.setState({active: true});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
handleEditingFinished: function() {
|
handleEditingFinished: function() {
|
||||||
@@ -1828,9 +1837,21 @@
|
|||||||
if (!topic) {
|
if (!topic) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
var instance = this;
|
||||||
topic.onMetaDesc = this.onMetaDesc;
|
this.previousMetaDesc = topic.onMetaDesc;
|
||||||
topic.onSubsUpdated = this.onSubsUpdated;
|
topic.onMetaDesc = function(desc) {
|
||||||
|
instance.onMetaDesc(desc);
|
||||||
|
if (instance.previousMetaDesc) {
|
||||||
|
instance.previousMetaDesc(desc);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this.previousSubsUpdated = topic.onSubsUpdated;
|
||||||
|
topic.onSubsUpdated = function(subs) {
|
||||||
|
instance.onSubsUpdated(subs);
|
||||||
|
if (instance.previousSubsUpdated) {
|
||||||
|
instance.previousSubsUpdated(subs);
|
||||||
|
}
|
||||||
|
}
|
||||||
this.resetDesc(topic);
|
this.resetDesc(topic);
|
||||||
this.resetSubs(topic);
|
this.resetSubs(topic);
|
||||||
|
|
||||||
@@ -1844,8 +1865,8 @@
|
|||||||
if (!topic) {
|
if (!topic) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
topic.onMetaDesc = undefined;
|
topic.onMetaDesc = this.previousMetaDesc;
|
||||||
topic.onSubsUpdated = undefined;
|
topic.onSubsUpdated = this.previousSubsUpdated;
|
||||||
},
|
},
|
||||||
|
|
||||||
resetSubs: function(topic) {
|
resetSubs: function(topic) {
|
||||||
@@ -1870,6 +1891,8 @@
|
|||||||
resetDesc: function(topic) {
|
resetDesc: function(topic) {
|
||||||
var defacs = topic.getDefaultAccess() || {};
|
var defacs = topic.getDefaultAccess() || {};
|
||||||
var acs = topic.getAccessMode();
|
var acs = topic.getAccessMode();
|
||||||
|
console.log("InfoView: reset desc");
|
||||||
|
console.log(topic.public);
|
||||||
this.setState({
|
this.setState({
|
||||||
owner: acs && acs.isOwner(),
|
owner: acs && acs.isOwner(),
|
||||||
admin: acs && acs.isAdmin(),
|
admin: acs && acs.isAdmin(),
|
||||||
|
|||||||
Reference in New Issue
Block a user