Просмотр исходного кода

change state by boolean argument

Shun Miyazawa 4 лет назад
Родитель
Сommit
b4fa474d7d

+ 4 - 4
packages/app/src/client/services/AdminGeneralSecurityContainer.js

@@ -152,15 +152,15 @@ export default class AdminGeneralSecurityContainer extends Container {
   /**
    * Switch ExpandOtherOptionsForDeletion
    */
-  switchExpandOtherOptionsForDeletion() {
-    this.setState({ expandOtherOptionsForDeletion:  !this.state.expandOtherOptionsForDeletion });
+  switchExpandOtherOptionsForDeletion(bool) {
+    this.setState({ expandOtherOptionsForDeletion: bool });
   }
 
   /**
    * Switch ExpandOtherOptionsForDeletion
    */
-  switchExpandOtherOptionsForCompleteDeletion() {
-    this.setState({ expandOtherOptionsForCompleteDeletion:  !this.state.expandOtherOptionsForCompleteDeletion });
+  switchExpandOtherOptionsForCompleteDeletion(bool) {
+    this.setState({ expandOtherOptionsForCompleteDeletion: bool });
   }
 
   /**

+ 5 - 5
packages/app/src/components/Admin/Security/SecuritySetting.jsx

@@ -109,14 +109,14 @@ class SecuritySetting extends React.Component {
       : adminGeneralSecurityContainer.state.expandOtherOptionsForCompleteDeletion;
   }
 
-  setExpantOtherDeleteOptionsState(deletionType) {
+  setExpantOtherDeleteOptionsState(deletionType, bool) {
     const { adminGeneralSecurityContainer } = this.props;
 
     if (isTypeDeletion(deletionType)) {
-      adminGeneralSecurityContainer.switchExpandOtherOptionsForDeletion();
+      adminGeneralSecurityContainer.switchExpandOtherOptionsForDeletion(bool);
       return;
     }
-    adminGeneralSecurityContainer.switchExpandOtherOptionsForCompleteDeletion();
+    adminGeneralSecurityContainer.switchExpandOtherOptionsForCompleteDeletion(bool);
     return;
   }
 
@@ -136,7 +136,7 @@ class SecuritySetting extends React.Component {
     if (shouldForceUpdate) {
       setState(newState);
       setRecursiveState(newState);
-      this.setExpantOtherDeleteOptionsState(deletionType);
+      this.setExpantOtherDeleteOptionsState(deletionType, true);
     }
     else {
       setState(newState);
@@ -235,7 +235,7 @@ class SecuritySetting extends React.Component {
                     type="button"
                     className="btn btn-link p-0 mb-4"
                     aria-expanded="false"
-                    onClick={() => this.setExpantOtherDeleteOptionsState(deletionType)}
+                    onClick={() => this.setExpantOtherDeleteOptionsState(deletionType, !this.expantDeleteOptionsState(deletionType))}
                   >
                     <i className={`fa fa-fw fa-arrow-right ${this.expantDeleteOptionsState(deletionType) ? 'fa-rotate-90' : ''}`}></i>
                     { t('security_setting.other_options') }