@capillarytech/creatives-library 2.0.31 → 2.0.33

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.
@@ -15,7 +15,7 @@ import { createStructuredSelector } from 'reselect';
15
15
  import _ from 'lodash';
16
16
  import { bindActionCreators } from 'redux';
17
17
  import { makeSelectEdit, makeSelectEditResponse, makeSelectTemplateDetailsResponse } from './selectors';
18
- import { makeSelectMetaEntities } from '../../Cap/selectors';
18
+ import { makeSelectMetaEntities, isLoadingMetaEntities } from '../../Cap/selectors';
19
19
  import { UserIsAuthenticated } from '../../../utils/authWrapper';
20
20
  import FormBuilder from '../../../components/FormBuilder';
21
21
  import * as actions from './actions';
@@ -30,6 +30,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
30
30
  constructor(props) {
31
31
  super(props);
32
32
  this.state = {
33
+ loadingStatus: 0,
33
34
  formData: {},
34
35
  tabCount: 1,
35
36
  schema: {},
@@ -127,7 +128,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
127
128
  this.setEditState(nextProps.templateDetails);
128
129
  }
129
130
  if (nextProps.metaEntities && nextProps.metaEntities.layouts && nextProps.metaEntities.layouts.length > 0 && _.isEmpty(this.state.schema)) {
130
- this.setState({schema: nextProps.metaEntities.layouts[0].definition}, () => {
131
+ this.setState({schema: nextProps.metaEntities.layouts[0].definition, loadingStatus: this.state.loadingStatus + 1}, () => {
131
132
  this.injectEvents(nextProps.metaEntities.layouts[0].definition);
132
133
  });
133
134
  if (this.props.location.query.module !== 'library' || (this.props.location.query.module === 'library' && this.props.getDefaultTags)) {
@@ -477,7 +478,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
477
478
  tempContainer = this.injectContainer(tempContainer);
478
479
  return tempContainer;
479
480
  });
480
- this.setState({schema});
481
+ this.setState({schema, loadingStatus: this.state.loadingStatus + 1});
481
482
  return schema;
482
483
  }
483
484
 
@@ -871,7 +872,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
871
872
  }
872
873
  });
873
874
  console.log('final data after removing', formData);
874
- this.setState({ schema, formData, tabCount: 1, tabKey: formData.base.tabKey, currentTab: 1 });
875
+ this.setState({ schema, loadingStatus: this.state.loadingStatus + 1, formData, tabCount: 1, tabKey: formData.base.tabKey, currentTab: 1 });
875
876
  }
876
877
 
877
878
  validateContent = (e) => {
@@ -909,11 +910,20 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
909
910
  console.log('edit obj', obj);
910
911
  this.props.actions.editTemplate(obj);
911
912
  }
913
+ isSmsLoading = () => {
914
+ //let {isLoading} = this.props;
915
+ let isLoading = this.props.isLoadingMetaEntities || this.state.loading || (this.props.Edit && (("getTemplateDetailsInProgress" in this.props.Edit && this.props.Edit.getTemplateDetailsInProgress) || ("editTemplateInProgress" in this.props.Edit && this.props.Edit.editTemplateInProgress)));
916
+
917
+ if (!isLoading) {
918
+ isLoading = this.state.loadingStatus < 3;
919
+ }
920
+ return isLoading;
921
+ }
912
922
  render() {
913
923
  const schema = this.state.schema;
914
924
  let tipText = this.props.Edit && ("getTemplateDetailsInProgress" in this.props.Edit && this.props.Edit.getTemplateDetailsInProgress) ? this.props.intl.formatMessage(messages.getTemplateDetailsLoader) : '';
915
925
  tipText = this.props.Edit && ("editTemplateInProgress" in this.props.Edit && this.props.Edit.editTemplateInProgress) ? this.props.intl.formatMessage(messages.saveTemplateLoader) : '';
916
- const spinning = this.state.loading || (this.props.Edit && (("getTemplateDetailsInProgress" in this.props.Edit && this.props.Edit.getTemplateDetailsInProgress) || ("editTemplateInProgress" in this.props.Edit && this.props.Edit.editTemplateInProgress)));
926
+ const spinning = this.isSmsLoading();
917
927
  let tags = this.props.metaEntities && this.props.metaEntities.tags ? this.props.metaEntities.tags.standard : [];
918
928
  if (this.props.location.query.type === 'embedded' && this.props.location.query.module === 'library' && !this.props.getDefaultTags) {
919
929
  tags = this.props.supportedTags;
@@ -975,7 +985,7 @@ Edit.propTypes = {
975
985
  templateData: PropTypes.object,
976
986
  supportedTags: PropTypes.array,
977
987
  getDefaultTags: PropTypes.string,
978
- // route: PropTypes.object,
988
+ isLoadingMetaEntities: PropTypes.bool,
979
989
  };
980
990
 
981
991
  const mapStateToProps = createStructuredSelector({
@@ -983,6 +993,7 @@ const mapStateToProps = createStructuredSelector({
983
993
  editResponse: makeSelectEditResponse(),
984
994
  templateDetails: makeSelectTemplateDetailsResponse(),
985
995
  metaEntities: makeSelectMetaEntities(),
996
+ isLoadingMetaEntities: isLoadingMetaEntities(),
986
997
  });
987
998
 
988
999
  function mapDispatchToProps(dispatch) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "2.0.31",
4
+ "version": "2.0.33",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",