mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-07 18:03:48 +00:00
update term adn condition
This commit is contained in:
@@ -13,6 +13,14 @@ const propTypes = {
|
||||
|
||||
class TermsEditorDialog extends React.Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
isValueChanged: false,
|
||||
};
|
||||
this.editorRef = React.createRef();
|
||||
}
|
||||
|
||||
static defaultProps = {
|
||||
title: gettext('Terms'),
|
||||
};
|
||||
@@ -22,20 +30,20 @@ class TermsEditorDialog extends React.Component {
|
||||
};
|
||||
|
||||
toggle = () => {
|
||||
if (this.isContentChanged()) {
|
||||
const { isValueChanged } = this.state;
|
||||
if (isValueChanged) {
|
||||
let currentContent = this.getCurrentContent();
|
||||
this.props.onCommit(currentContent);
|
||||
}
|
||||
this.props.onCloseEditorDialog();
|
||||
};
|
||||
|
||||
isContentChanged = () => {
|
||||
return this.simpleEditor.hasContentChange();
|
||||
onValueChanged = () => {
|
||||
return this.setState({isValueChanged: true});
|
||||
};
|
||||
|
||||
getCurrentContent = () => {
|
||||
let markdownContent = this.simpleEditor.getMarkdown();
|
||||
return markdownContent;
|
||||
return this.editorRef.current.getValue();
|
||||
};
|
||||
|
||||
setSimpleEditorRef = (editor) => {
|
||||
@@ -58,8 +66,9 @@ class TermsEditorDialog extends React.Component {
|
||||
<ModalHeader className="conditions-editor-dialog-title" toggle={this.toggle}>{title}</ModalHeader>
|
||||
<ModalBody className={'conditions-editor-dialog-main'}>
|
||||
<SimpleEditor
|
||||
onRef={this.setSimpleEditorRef.bind(this)}
|
||||
ref={this.editorRef}
|
||||
value={content || ''}
|
||||
onValueChanged={this.onValueChanged}
|
||||
/>
|
||||
</ModalBody>
|
||||
</Modal>
|
||||
|
Reference in New Issue
Block a user