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

fix modal behavior

https://youtrack.weseek.co.jp/issue/GW-7771
- Fix modal behavior ,  prevent scroll top on modal open
- Implement onClick props on AdminUpdateButtonRow
- Update onCropCompleted function
I Komang Mudana 4 лет назад
Родитель
Сommit
5efe5c1189

+ 4 - 1
packages/app/src/components/Admin/Customize/CropLogoModal.jsx

@@ -35,6 +35,9 @@ class CropLogoModal extends React.Component {
     this.imageRef = null;
     this.imageRef = null;
   }
   }
 
 
+  componentDidMount() {
+    document.body.style.position = 'static';
+  }
 
 
   onImageLoaded(image) {
   onImageLoaded(image) {
     this.setState({ imageRef: image }, () => this.reset());
     this.setState({ imageRef: image }, () => this.reset());
@@ -87,7 +90,7 @@ class CropLogoModal extends React.Component {
 
 
   render() {
   render() {
     return (
     return (
-      <Modal style={this.style} isOpen={this.props.show} toggle={this.props.onModalClose}>
+      <Modal isOpen={this.props.show} toggle={this.props.onModalClose}>
         <ModalHeader tag="h4" toggle={this.props.onModalClose} className="bg-info text-light">
         <ModalHeader tag="h4" toggle={this.props.onModalClose} className="bg-info text-light">
           Image Crop
           Image Crop
         </ModalHeader>
         </ModalHeader>

+ 4 - 10
packages/app/src/components/Admin/Customize/CustomizeLogoSetting.jsx

@@ -19,6 +19,7 @@ class CustomizeLogoSetting extends React.Component {
     this.state = {
     this.state = {
       show: false,
       show: false,
       src: null,
       src: null,
+      croppedImage: null,
     };
     };
 
 
     // this.imageRef = null;
     // this.imageRef = null;
@@ -43,7 +44,7 @@ class CustomizeLogoSetting extends React.Component {
     const { t, adminCustomizeContainer } = this.props;
     const { t, adminCustomizeContainer } = this.props;
 
 
     try {
     try {
-      await adminCustomizeContainer.updateCustomizeScript();
+      await adminCustomizeContainer.uploadAttachment(this.state.croppedImage);
       toastSuccess(t('toaster.update_successed', { target: t('admin:customize_setting.custom_script') }));
       toastSuccess(t('toaster.update_successed', { target: t('admin:customize_setting.custom_script') }));
     }
     }
     catch (err) {
     catch (err) {
@@ -63,14 +64,7 @@ class CustomizeLogoSetting extends React.Component {
   }
   }
 
 
   async onCropCompleted(croppedImage) {
   async onCropCompleted(croppedImage) {
-    const { t, adminCustomizeContainer } = this.props;
-    try {
-      await adminCustomizeContainer.uploadAttachment(croppedImage);
-      toastSuccess(t('toaster.update_successed', { target: t('Current Image') }));
-    }
-    catch (err) {
-      toastError(err);
-    }
+    this.setState({ croppedImage });
     this.hideModal();
     this.hideModal();
   }
   }
 
 
@@ -113,7 +107,7 @@ class CustomizeLogoSetting extends React.Component {
                 </div>
                 </div>
               </div>
               </div>
             </div>
             </div>
-            <AdminUpdateButtonRow />
+            <AdminUpdateButtonRow onClick={this.onClickSubmit} disabled={adminCustomizeContainer.state.retrieveError != null} />
           </div>
           </div>
         </div>
         </div>