Commit 6d3d2c3a authored by Florent Chehab's avatar Florent Chehab
Browse files

Better editor comments and fixed incorrectForcedSave

parent 32a0a937
...@@ -19,14 +19,14 @@ import Form from "./Form"; ...@@ -19,14 +19,14 @@ import Form from "./Form";
/** /**
* Class to handle editions of models on the frontend. It should be extended, eg: * Class to handle editions of models on the frontend. It should be extended, eg:
* *
class BlablaEditor extends Editor { * class BlablaEditor extends Editor {
renderForm() { * renderForm() {
return <blablaForm * return <blablaForm
modelData={this.props.modelData} * modelData={this.props.modelData}
ref={this.formRef} * ref={this.formRef}
/>; * />;
} * }
} * }
* *
* @class Editor * @class Editor
* @extends {Component} * @extends {Component}
...@@ -97,7 +97,6 @@ class Editor extends Component { ...@@ -97,7 +97,6 @@ class Editor extends Component {
handleSaveEditorRequest() { handleSaveEditorRequest() {
const formHasError = this.formHasError(); const formHasError = this.formHasError();
if (!formHasError.status) { // no error, we can save if necessary if (!formHasError.status) { // no error, we can save if necessary
if (this.props.forceSave || this.formHasChanges()) { if (this.props.forceSave || this.formHasChanges()) {
// Copy the model data and copy above the data from the form // Copy the model data and copy above the data from the form
// So that we don't forget anything. // So that we don't forget anything.
...@@ -137,7 +136,10 @@ class Editor extends Component { ...@@ -137,7 +136,10 @@ class Editor extends Component {
/** /**
* This function is extended to handle custom behaviors on component update * This function is extended to handle all the logic such as
* - opening the editor
* - Detecting when there was a successful save
* - etc.
* *
* @memberof Editor * @memberof Editor
*/ */
......
...@@ -97,7 +97,7 @@ class GenericModule extends CustomComponentForAPI { ...@@ -97,7 +97,7 @@ class GenericModule extends CustomComponentForAPI {
handleEditPendingModeration = (rawModelData) => { handleEditPendingModeration = (rawModelData) => {
this.setState({ this.setState({
rawModelDataForEditor: rawModelData, rawModelDataForEditor: rawModelData,
forceSave: true, forceSave: this.userCanModerate(),
}); });
this.handleClosePendingModeration(); this.handleClosePendingModeration();
this.handleOpenEditor(true); this.handleOpenEditor(true);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment