Ver Fonte

WIP: GC-572 get option values when submit button clicked

* impl getCurrentOptionsToSave method
Yuki Takei há 7 anos atrás
pai
commit
0f30e59f18

+ 3 - 3
resource/js/components/SavePageControls.jsx

@@ -29,9 +29,9 @@ class SavePageControls extends React.PureComponent {
   }
 
   submit() {
-    const slackNotificationState = this.refs.slackNotification.state;
-    const grantSelectorState = this.refs.grantSelector.state;
-    const options = Object.assign(slackNotificationState, grantSelectorState);
+    const slackNotificationOptions = this.refs.slackNotification.getCurrentOptionsToSave();
+    const grantSelectorOptions = this.refs.grantSelector.getCurrentOptionsToSave();
+    const options = Object.assign(slackNotificationOptions, grantSelectorOptions);
     this.props.onSubmit(options);
   }
 

+ 11 - 0
resource/js/components/SavePageControls/GrantSelector.jsx

@@ -46,6 +46,7 @@ class GrantSelector extends React.Component {
     // retrieve xss library from window
     this.xss = window.xss;
 
+    this.getCurrentOptionsToSave = this.getCurrentOptionsToSave.bind(this);
     this.showSelectGroupModal = this.showSelectGroupModal.bind(this);
     this.hideSelectGroupModal = this.hideSelectGroupModal.bind(this);
 
@@ -74,6 +75,16 @@ class GrantSelector extends React.Component {
 
   }
 
+  getCurrentOptionsToSave() {
+    const options = {
+      grant: this.state.pageGrant
+    };
+    if (this.state.pageGrantGroup != null) {
+      options.grantGroup = this.state.pageGrantGroup._id;
+    }
+    return options;
+  }
+
   showSelectGroupModal() {
     this.retrieveUserGroupRelations();
     this.setState({ isSelectGroupModalShown: true });

+ 4 - 0
resource/js/components/SlackNotification.jsx

@@ -31,6 +31,10 @@ export default class SlackNotification extends React.Component {
     });
   }
 
+  getCurrentOptionsToSave() {
+    return Object.assign({}, this.state);
+  }
+
   updateState(value) {
     this.setState({slackChannels: value});
     // dispatch event