learningtribes-studio-frontend 1.4.1 → 1.4.2-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -110,7 +110,8 @@ export default class EditImageModal extends React.Component {
110
110
  nextProps.clearAssetsStatus();
111
111
  newState.currentUploadErrorMessage = null;
112
112
  newState.isStatusAlertOpen = false;
113
- newState.pageNumber = 2;
113
+ // Stay on page 1 - the form fields are now shown on the same page
114
+ newState.pageNumber = 1;
114
115
  break;
115
116
  }
116
117
  case assetActions.upload.UPLOAD_EXCEED_MAX_COUNT_ERROR: {
@@ -274,7 +275,9 @@ export default class EditImageModal extends React.Component {
274
275
  });
275
276
 
276
277
  if (isValidFormContent) {
277
- this.imageFormRef.dispatchEvent(new CustomEvent('submitForm',
278
+ // Use the form ref if available, otherwise dispatch from modal wrapper
279
+ const targetElement = this.imageFormRef || this.modalWrapperRef;
280
+ targetElement.dispatchEvent(new CustomEvent('submitForm',
278
281
  {
279
282
  bubbles: true,
280
283
  detail: {
@@ -293,7 +296,9 @@ export default class EditImageModal extends React.Component {
293
296
 
294
297
  this.resetImageSelection();
295
298
  } else {
296
- this.statusAlertRef.focus();
299
+ if (this.statusAlertRef) {
300
+ this.statusAlertRef.focus();
301
+ }
297
302
  }
298
303
  }
299
304
 
@@ -662,7 +667,7 @@ export default class EditImageModal extends React.Component {
662
667
  {this.getStatusAlert()}
663
668
  </div>
664
669
  </div>
665
- <div className="row mb-5">
670
+ <div className="row mb-3">
666
671
  <div className="col">
667
672
  <WrappedAssetsDropZone
668
673
  maxFileCount={1}
@@ -673,38 +678,39 @@ export default class EditImageModal extends React.Component {
673
678
  />
674
679
  </div>
675
680
  </div>
676
- <div className="row no-gutters">
677
- <div className="col">
678
- <WrappedMessage message={messages.editImageModalInsertHeader} tagName="h3" />
679
- </div>
680
- </div>
681
- <div className="row">
682
- <div className="col-6 order-2">
683
- {(this.state.assetsPageType === pageTypes.NORMAL ||
684
- this.state.assetsPageType === pageTypes.NO_RESULTS) && (
685
- <WrappedAssetsSearch />
686
- )}
687
- </div>
688
- <div className="col-6 order-1">
689
- {this.state.assetsPageType === pageTypes.NORMAL && (
690
- <div aria-hidden>
691
- <WrappedAssetsResultsCount />
692
- </div>
693
- )}
694
- </div>
695
- </div>
696
681
  <div className="row">
697
682
  <div className="col">
698
683
  {this.getImageSelectionModalBodyAssetsList(this.state.assetsPageType)}
699
684
  </div>
700
685
  </div>
701
686
  {this.state.assetsPageType === pageTypes.NORMAL && (
702
- <div className="row mt-3 no-gutters">
687
+ <div className="row mt-2 no-gutters">
703
688
  <div className="col">
704
689
  <WrappedPagination />
705
690
  </div>
706
691
  </div>
707
692
  )}
693
+ {this.isAssetSelected() && (
694
+ <div className="row mt-3">
695
+ <div className="col">
696
+ {/* Hidden image to load dimensions */}
697
+ {this.state.imageSource && (
698
+ <img
699
+ alt=""
700
+ src={this.getImageAssetSource()}
701
+ onLoad={this.onImageLoad}
702
+ onError={this.onImageError}
703
+ ref={this.setImageRef}
704
+ style={{ display: 'none' }}
705
+ />
706
+ )}
707
+ <form ref={this.setImageFormRef}>
708
+ {this.getImageDescriptionInput()}
709
+ {this.getImageDimensionsInput()}
710
+ </form>
711
+ </div>
712
+ </div>
713
+ )}
708
714
  </React.Fragment>
709
715
  );
710
716
 
@@ -731,7 +737,12 @@ export default class EditImageModal extends React.Component {
731
737
  getModalButtons = () => {
732
738
  let buttons;
733
739
  if (this.state.pageNumber === 1) {
734
- buttons = this.getNextPageButton();
740
+ // Show Save button if asset is selected, otherwise show Next button
741
+ if (this.isAssetSelected()) {
742
+ buttons = this.getInsertImageButton();
743
+ } else {
744
+ buttons = this.getNextPageButton();
745
+ }
735
746
  } else if (this.state.pageNumber === 2) {
736
747
  buttons = this.getInsertImageButton();
737
748
  }