@capillarytech/creatives-library 2.0.32 → 2.0.34

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.
@@ -17,6 +17,10 @@ const makeSelectMetaEntities = () => createSelector(
17
17
  (globalState) => globalState.get('metaEntities')
18
18
  );
19
19
 
20
+ const isLoadingMetaEntities = () => createSelector(
21
+ selectCapDomain,
22
+ (globalState) => globalState.get('fetchingSchema')
23
+ );
20
24
  const makeSelectLocationState = () => {
21
25
  let prevRoutingState;
22
26
  let prevRoutingStateJS;
@@ -54,4 +58,5 @@ export {
54
58
  makeSelectMetaEntities,
55
59
  makeSelectUser,
56
60
  selectCurrentOrgDetails,
61
+ isLoadingMetaEntities,
57
62
  };
@@ -31,9 +31,10 @@ function SlideBoxContent(props) {
31
31
  onChannelChange,
32
32
  onEmailModeChange,
33
33
  emailCreateMode,
34
- emailStep,
34
+ templateStep,
35
35
  onEmailNextStep,
36
36
  cap,
37
+ onResetStep,
37
38
  } = props;
38
39
  const type = messageDetails.type.toLowerCase(); // type is context in get tags values : outbound | dvs | referral | loyalty | coupons
39
40
  const query = { type: 'embedded', module: 'library' };
@@ -114,10 +115,11 @@ function SlideBoxContent(props) {
114
115
  getFormdata={getFormData}
115
116
  templateData={templateData}
116
117
  type={type}
117
- step={emailStep}
118
+ step={templateStep}
118
119
  showNextStep={onEmailNextStep}
119
120
  isFullMode={false}
120
121
  cap={cap}
122
+ onResetStep={onResetStep}
121
123
  />
122
124
  )}
123
125
  {(isEditEmailWithId || isEmailEditWithContent) && (
@@ -153,8 +155,9 @@ SlideBoxContent.propTypes = {
153
155
  currentChannel: PropTypes.string,
154
156
  onEmailModeChange: PropTypes.func,
155
157
  emailCreateMode: PropTypes.string,
156
- emailStep: PropTypes.string,
158
+ templateStep: PropTypes.string,
157
159
  onEmailNextStep: PropTypes.func,
158
160
  cap: PropTypes.object,
161
+ onResetStep: PropTypes.func,
159
162
  };
160
163
  export default SlideBoxContent;
@@ -4,8 +4,8 @@ import { CapButton } from '@capillarytech/cap-ui-library';
4
4
  import PropTypes from 'prop-types';
5
5
  import * as constants from './constants';
6
6
  function SlideBoxFooter(props) {
7
- const { slidBoxContent, onSave, messages, onEditTemplate, currentChannel, onEmailNextStep, emailStep, emailCreateMode } = props;
8
- const isEmailCreate = slidBoxContent === 'createTemplate' && currentChannel === constants.EMAIL && emailStep !== 'createTemplate';
7
+ const { slidBoxContent, onSave, messages, onEditTemplate, currentChannel, onEmailNextStep, templateStep, emailCreateMode } = props;
8
+ const isEmailCreate = slidBoxContent === 'createTemplate' && currentChannel === constants.EMAIL && templateStep !== 'createTemplate';
9
9
  const isCreate = (slidBoxContent === 'editTemplate' || slidBoxContent === 'createTemplate') && !isEmailCreate;
10
10
  return (
11
11
  <div>
@@ -36,7 +36,7 @@ SlideBoxFooter.propTypes = {
36
36
  onEditTemplate: PropTypes.func,
37
37
  currentChannel: PropTypes.string,
38
38
  onEmailNextStep: PropTypes.func,
39
- emailStep: PropTypes.string,
39
+ templateStep: PropTypes.string,
40
40
  emailCreateMode: PropTypes.string,
41
41
  };
42
42
  export default SlideBoxFooter;
@@ -21,15 +21,15 @@ class Creatives extends React.Component {
21
21
  constructor(props) {
22
22
  super(props);
23
23
  this.state = {
24
- emailStep: 1, //modeSelection: for selecting upload or editor, and createTemplate to create template create based on modeSelection
24
+ templateStep: 1, //modeSelection: for template name and (for email selecting upload or editor), and createTemplate to create template create based on modeSelection
25
25
  showSlideBox: true,
26
26
  slidBoxContent: this.getSlideBocContent({mode: props.creativesMode, templateData: props.templateData, isFullMode: props.isFullMode}),
27
27
  templateData: this.getTemplateData(props.templateData),
28
28
  currentChannel: this.props.channel || 'sms',
29
29
  };
30
- this.creativesEmailSteps = {
30
+ this.creativesTemplateSteps = {
31
31
  1: 'modeSelection',
32
- 2: 'templateSelection',
32
+ 2: 'templateSelection', // only for email in current flows wil be used for mpush, line and wechat as well.
33
33
  3: 'createTemplate',
34
34
  };
35
35
  }
@@ -61,9 +61,10 @@ class Creatives extends React.Component {
61
61
  }
62
62
  onEmailNextStep = () => {
63
63
  this.setState((prevState) => ({
64
- emailStep: prevState.emailStep + 1,
64
+ templateStep: prevState.templateStep + 1,
65
65
  }));
66
66
  }
67
+
67
68
  onEmailModeChange = (mode) => {
68
69
  this.setState({ emailCreateMode: mode});
69
70
  }
@@ -140,6 +141,9 @@ class Creatives extends React.Component {
140
141
  );
141
142
  }
142
143
  };
144
+ resetStep = () => {
145
+ this.setState({templateStep: 1});
146
+ }
143
147
  toggleShowSlideBox = () => {
144
148
  this.setState((prevState) => ({
145
149
  ...prevState,
@@ -151,7 +155,7 @@ class Creatives extends React.Component {
151
155
  };
152
156
 
153
157
  render() {
154
- const {slidBoxContent, isGetFormData, showSlideBox, templateData, currentChannel, emailCreateMode, emailStep} = this.state;
158
+ const {slidBoxContent, isGetFormData, showSlideBox, templateData, currentChannel, emailCreateMode, templateStep} = this.state;
155
159
  const {isFullMode, creativesMode, cap} = this.props;
156
160
  return (
157
161
  <div className={classnames(`${classPrefix}`)}>
@@ -183,8 +187,9 @@ class Creatives extends React.Component {
183
187
  onChannelChange={this.onChannelChange}
184
188
  onEmailModeChange={this.onEmailModeChange}//used when create is clicked in email
185
189
  emailCreateMode={emailCreateMode}// upload zip || use editor are values
186
- emailStep={this.creativesEmailSteps[emailStep]}
190
+ templateStep={this.creativesTemplateSteps[templateStep]}
187
191
  onEmailNextStep={this.onEmailNextStep}
192
+ onResetStep={this.resetStep}
188
193
  cap={cap}
189
194
  />
190
195
  }
@@ -196,7 +201,7 @@ class Creatives extends React.Component {
196
201
  slidBoxContent={slidBoxContent}
197
202
  onEmailNextStep={this.onEmailNextStep}
198
203
  currentChannel={currentChannel.toUpperCase()}
199
- emailStep={this.creativesEmailSteps[emailStep]}
204
+ templateStep={this.creativesTemplateSteps[templateStep]}
200
205
  emailCreateMode={emailCreateMode}
201
206
  />
202
207
  }
@@ -9,7 +9,6 @@ import PropTypes from 'prop-types';
9
9
  import React from 'react';
10
10
  import { connect } from 'react-redux';
11
11
  import { bindActionCreators } from 'redux';
12
- import Helmet from 'react-helmet';
13
12
  import { Row, Col, Spin, Popover, Modal, Select } from 'antd';
14
13
  import { injectIntl, intlShape, FormattedMessage } from 'react-intl';
15
14
  import { CapButton, CapInput } from '@capillarytech/cap-react-ui-library';
@@ -17,12 +16,12 @@ import { createStructuredSelector } from 'reselect';
17
16
  import _ from 'lodash';
18
17
  import moment from "moment";
19
18
  import FormBuilder from '../../components/FormBuilder';
20
- import { makeSelectMetaEntities, selectCurrentOrgDetails } from '../Cap/selectors';
19
+ import { makeSelectMetaEntities, selectCurrentOrgDetails, isLoadingMetaEntities } from '../Cap/selectors';
21
20
  import * as actions from './actions';
22
21
  import * as templatesActions from '../Templates/actions';
23
22
  import * as globalActions from '../../containers/Cap/actions';
24
23
  import { UserIsAuthenticated } from '../../utils/authWrapper';
25
- import makeSelectEmail from './selectors';
24
+ import {makeSelectEmail} from './selectors';
26
25
  import { makeSelectTemplates } from '../Templates/selectors';
27
26
  import messages from './messages';
28
27
  // import PageHeader from '../../components/PageHeader';
@@ -37,6 +36,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
37
36
  constructor(props) {
38
37
  super(props);
39
38
  this.state = {
39
+ loadingStatus: 0,
40
40
  formData: {},
41
41
  tabCount: 1,
42
42
  currentTab: 1,
@@ -222,7 +222,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
222
222
  if (nextProps.metaEntities && nextProps.metaEntities.layouts && nextProps.metaEntities.layouts.length > 0 && _.isEmpty(this.state.schema)) {
223
223
  const newSchema = this.injectEvents(nextProps.metaEntities.layouts[0].definition);
224
224
 
225
- this.setState({schema: newSchema});
225
+ this.setState({schema: newSchema, loadingStatus: this.state.loadingStatus + 1});
226
226
  if (this.props.location.query.module !== 'library' || (this.props.location.query.module === 'library' && this.props.getDefaultTags)) {
227
227
  const query = {
228
228
  layout: 'EMAIL',
@@ -285,7 +285,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
285
285
  } else {
286
286
  container.tabBarExtraContent.sections[0].inputFields[0].cols[4].content.sections[0].inputFields[2].cols[0].style = {display: ""};
287
287
  }
288
- this.setState({schema});
288
+ this.setState({schema, loadingStatus: this.state.loadingStatus + 1});
289
289
  }
290
290
 
291
291
  //
@@ -347,7 +347,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
347
347
  }
348
348
  });
349
349
 
350
- this.setState({schema, isSchemaChanged: true});
350
+ this.setState({schema, isSchemaChanged: true, loadingStatus: this.state.loadingStatus + 1});
351
351
  } else {
352
352
  _.forEach(temp.panes, (pane, index) => {
353
353
  const tempPane = pane;
@@ -357,7 +357,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
357
357
  }
358
358
  });
359
359
 
360
- this.setState({schema, isSchemaChanged: true});
360
+ this.setState({schema, isSchemaChanged: true, loadingStatus: this.state.loadingStatus + 1});
361
361
  let html = decodeURIComponent(nextProps.Email.CmsSettings.htmlContent);
362
362
 
363
363
  html = html.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/\\&quot;/g, '"');
@@ -582,7 +582,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
582
582
  } else {
583
583
  container.tabBarExtraContent.sections[0].inputFields[0].cols[4].content.sections[0].inputFields[2].cols[0].style = {display: ""};
584
584
  }
585
- this.setState({currentTab: data, formData, schema});
585
+ this.setState({currentTab: data, formData, schema, loadingStatus: this.state.loadingStatus + 1});
586
586
  }
587
587
 
588
588
  onTemplateNameChange = () => {
@@ -831,7 +831,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
831
831
  });
832
832
 
833
833
 
834
- this.setState({ formData, schema, tabKey, currentTab, tabCount: editData.versions.history.length }, () => {
834
+ this.setState({ formData, schema, tabKey, currentTab, tabCount: editData.versions.history.length, loadingStatus: this.state.loadingStatus + 1 }, () => {
835
835
  _.forEach((editData.versions.base.selectedLanguages), (language) => {
836
836
  // if (formData[this.state.currentTab - 1].tabKey === formData[this.state.currentTab - 1][language].tabKey) {
837
837
  // formData[this.state.currentTab - 1].activeTab = language;
@@ -1939,7 +1939,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
1939
1939
  });
1940
1940
  //}
1941
1941
  temp = type === 'embedded' ? this.removeStandAlone(temp) : temp;
1942
- this.setState({schema: temp, isSchemaChanged: true}, () => {
1942
+ this.setState({schema: temp, isSchemaChanged: true, loadingStatus: this.state.loadingStatus + 1}, () => {
1943
1943
  if (type === 'embedded' && (this.props.route.name === 'EmailView' || (this.props.location.query.module && (this.props.location.query.module.toLowerCase() === 'loyalty' || this.props.location.query.module.toLowerCase() === 'dvs' || this.props.location.query.module.toLowerCase() === 'coupon_expiry' || this.props.location.query.module.toLowerCase() === 'timeline')))) {
1944
1944
  if ((this.props.route.name === "EmailEdit" || this.props.route.name === "EmailCreate") && (this.props.location.query.module === "dvs" || this.props.location.query.module.toLowerCase() === 'coupon_expiry')) {
1945
1945
  return;
@@ -2431,6 +2431,15 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2431
2431
  }
2432
2432
  };
2433
2433
 
2434
+ isEmailLoading = () => {
2435
+ //let {isLoading} = this.props;
2436
+ let isLoading = this.props.isLoadingMetaEntities || this.state.loading || (this.props.Email && "createTemplateInProgress" in this.props.Email && this.props.Email.createTemplateInProgress) || (this.props.Email.assetUploading !== undefined && this.props.Email.assetUploading);
2437
+
2438
+ if (!isLoading) {
2439
+ isLoading = this.state.loadingStatus < 2;
2440
+ }
2441
+ return isLoading;
2442
+ }
2434
2443
  renderConfirmationModal() {
2435
2444
  const modal = (
2436
2445
  <Modal
@@ -2452,7 +2461,6 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2452
2461
  </Modal>);
2453
2462
  return modal;
2454
2463
  }
2455
-
2456
2464
  render() {
2457
2465
  // const pageHeading = (this.state.isEdit) ? this.props.intl.formatMessage(messages.editHeading) : this.props.intl.formatMessage(messages.createHeading);
2458
2466
  // const actionComponents = '';
@@ -2490,7 +2498,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2490
2498
  </div>
2491
2499
  );
2492
2500
  const schema = this.state.schema;
2493
- const spinning = this.state.loading || (this.props.Email && "createTemplateInProgress" in this.props.Email && this.props.Email.createTemplateInProgress) || (this.props.Email.assetUploading !== undefined && this.props.Email.assetUploading);
2501
+ const isLoading = this.isEmailLoading();
2494
2502
  const previewHeader = (<h3>Email Preview</h3>);
2495
2503
  const imagePreviewHeader = (<h3>Image Selection</h3>);
2496
2504
  const imagePreviewContent = (
@@ -2530,14 +2538,9 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2530
2538
  }
2531
2539
  return (
2532
2540
  <div className="email-container">
2533
- <Helmet
2534
- title="Email"
2535
- meta={[
2536
- { name: 'description', content: 'Description of Email' },
2537
- ]}
2538
- />
2541
+
2539
2542
  {/* <PageHeader pageHeading={pageHeading} /> */}
2540
- <Spin tip={loaderText} spinning={spinning}>
2543
+ <Spin tip={loaderText} spinning={isLoading}>
2541
2544
 
2542
2545
  <Row>
2543
2546
  <Col>
@@ -2637,6 +2640,7 @@ Email.propTypes = {
2637
2640
  supportedTags: PropTypes.array,
2638
2641
  getDefaultTags: PropTypes.string,
2639
2642
  currentOrgDetails: PropTypes.object,
2643
+ isLoadingMetaEntities: PropTypes.bool,
2640
2644
  };
2641
2645
 
2642
2646
  const mapStateToProps = (state, props) => createStructuredSelector({
@@ -2644,6 +2648,7 @@ const mapStateToProps = (state, props) => createStructuredSelector({
2644
2648
  Templates: makeSelectTemplates(),
2645
2649
  metaEntities: makeSelectMetaEntities(),
2646
2650
  currentOrgDetails: props.cap ? () => props.cap.currentOrgDetails : selectCurrentOrgDetails(),
2651
+ isLoadingMetaEntities: isLoadingMetaEntities(),
2647
2652
  });
2648
2653
 
2649
2654
  function mapDispatchToProps(dispatch) {
@@ -22,10 +22,13 @@ const makeSelectEmail = () => createSelector(
22
22
  const makeSelectCreateResponse = () => createSelector(
23
23
  selectEmailDomain(), (dimensionState) => dimensionState.get('createResponse')
24
24
  );
25
-
25
+ const selectLoadingStatus = () => createSelector(
26
+ selectEmailDomain(), (email) => email.createTemplateInProgress || (email.assetUploading !== undefined && email.assetUploading)
27
+ );
26
28
 
27
29
  export default makeSelectEmail;
28
30
  export {
29
31
  makeSelectEmail,
30
32
  makeSelectCreateResponse,
33
+ selectLoadingStatus,
31
34
  };
@@ -64,12 +64,17 @@ export class EmailWrapper extends React.Component { // eslint-disable-line react
64
64
  }
65
65
  }
66
66
  }
67
- onChange = (e) => {
68
- this.props.onEmailModeChange( e.target.value );
69
- };
67
+
68
+
69
+ componentWillUnmount() {
70
+ this.props.onResetStep();
71
+ }
70
72
  onTemplateNameChange = (ev) => {
71
73
  this.setState({templateName: ev.target.vale});
72
74
  }
75
+ onChange = (e) => {
76
+ this.props.onEmailModeChange( e.target.value );
77
+ };
73
78
  //isValid = () => !_.isEmpty(this.state.templateName)
74
79
  setCreateMode = (emailCreateMode) => {
75
80
  this.setState({selectedCreateMode: emailCreateMode});
@@ -181,6 +186,7 @@ EmailWrapper.propTypes = {
181
186
  getFormdata: PropTypes.func,
182
187
  intl: intlShape,
183
188
  cap: PropTypes.object,
189
+ onResetStep: PropTypes.func,
184
190
  };
185
191
 
186
192
  const mapStateToProps = createStructuredSelector({
@@ -14,7 +14,7 @@ import { createStructuredSelector } from 'reselect';
14
14
  import _ from 'lodash';
15
15
  import { bindActionCreators } from 'redux';
16
16
  import { makeSelectCreate, makeSelectCreateResponse } from './selectors';
17
- import { makeSelectMetaEntities } from '../../Cap/selectors';
17
+ import { makeSelectMetaEntities, isLoadingMetaEntities } from '../../Cap/selectors';
18
18
  import { UserIsAuthenticated } from '../../../utils/authWrapper';
19
19
  import './_smsCreate.scss';
20
20
  import FormBuilder from '../../../components/FormBuilder';
@@ -30,6 +30,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
30
30
  constructor(props) {
31
31
  super(props);
32
32
  this.state = {
33
+ loadingStatus: 0,
33
34
  formData: {},
34
35
  tabCount: 1,
35
36
  currentTab: 1,
@@ -183,7 +184,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
183
184
  if (!_.has(nextProps.metaEntities.tags.custom, "Transaction custom fields")) {
184
185
  delete injectedTags["Transaction custom fields"];
185
186
  }
186
- this.setState({injectedTags});
187
+ this.setState({injectedTags, loadingStatus: this.state.loadingStatus + 1});
187
188
  }
188
189
  // if (nextProps.metaEntities && nextProps.metaEntities.tags && nextProps.metaEntities.tags.length > 0 && _.isEmpty(this.state.schema)) {
189
190
  // console.log('final schema is**', nextProps.metaEntities.layouts[0].definition);
@@ -391,7 +392,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
391
392
  return tempContainer;
392
393
  });
393
394
  console.log('final injected schema', schema);
394
- this.setState({schema}, () => {
395
+ this.setState({schema, loadingStatus: this.state.loadingStatus + 1}, () => {
395
396
  const type = this.props.location.query.type;
396
397
  if (type === 'embedded') {
397
398
  this.removeStandAlone();
@@ -871,7 +872,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
871
872
  temp.panes.push(basePane);
872
873
  }
873
874
  });
874
- this.setState({ schema });
875
+ this.setState({ schema, loadingStatus: this.state.loadingStatus + 1 });
875
876
  }
876
877
 
877
878
  validateContent = (e) => {
@@ -902,487 +903,6 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
902
903
  });
903
904
  }
904
905
  resetSchema() {
905
- // const schema =
906
- // {
907
- // standalone: {
908
- // sections: [
909
- // {
910
- // type: "multicols",
911
- // inputFields: [
912
- // {
913
- // cols: [
914
- // {
915
- // id: "template-name",
916
- // placeholder: "Enter template name",
917
- // type: "input", //Resembles component to be used
918
- // metaType: "text",
919
- // datatype: "string",
920
- // required: true,
921
- // fluid: true,
922
- // style: {
923
- // fontSize: '20px',
924
- // fontFamily: 'proxima-nova,sans-serif',
925
- // fontStyle: 'normal',
926
- // fontWeight: 600,
927
- // marginBottom: '16px',
928
- // },
929
- // styling: "semantic",
930
- // order: 1,
931
- // width: 9,
932
- // offSet: 10,
933
- // customComponent: false,
934
- // standalone: true,
935
- // supportedEvents: {
936
- // onChange: this.onTemplateNameChange,
937
- // },
938
- // },
939
- // {
940
- // id: "discard-button",
941
- // width: 3,
942
- // offset: 8,
943
- // metaType: "submit-button",
944
- // colStyle: {
945
- // // marginLeft: '47.833%',
946
- // textAlign: 'right',
947
- // paddingRight: '12px',
948
- // },
949
- // type: "button",
950
- // buttonType: "cancel",
951
- // value: "Discard",
952
- // customComponent: false,
953
- // standalone: true,
954
- // styling: "semantic",
955
- // order: 3,
956
- // fluid: false,
957
- // submitAction: "discardValues",
958
- // supportedEvents: {
959
- // discardValues: this.discardValues,
960
- // },
961
- // },
962
- // {
963
- // id: "cancel-button",
964
- // width: 2,
965
- // // offset: 11,
966
- // metaType: "submit-button",
967
- // colStyle: {
968
- // textAlign: 'right',
969
- // width: '9%',
970
- // },
971
- // type: "button",
972
- // buttonType: "cancel",
973
- // value: "Cancel",
974
- // customComponent: false,
975
- // standalone: true,
976
- // styling: "semantic",
977
- // order: 3,
978
- // fluid: false,
979
- // submitAction: "cancelTemplate",
980
- // supportedEvents: {
981
- // cancelTemplate: this.cancelTemplate,
982
- // },
983
- // },
984
- // {
985
- // id: "save-button",
986
- // width: 2,
987
- // metaType: "submit-button",
988
- // colStyle: {
989
- // textAlign: 'right',
990
- // width: '7%',
991
- // },
992
- // type: "button",
993
- // buttonType: "primary",
994
- // value: "Save",
995
- // customComponent: false,
996
- // styling: "semantic",
997
- // order: 3,
998
- // fluid: false,
999
- // standalone: true,
1000
- // submitAction: "saveFormData",
1001
- // supportedEvents: {
1002
- // saveFormData: this.saveFormData,
1003
- // },
1004
- // },
1005
- // ],
1006
- // },
1007
- // ],
1008
- // actionFields: [],
1009
- // },
1010
- // ],
1011
- // },
1012
- // containers: [
1013
- // {
1014
- // panes: [
1015
- // {
1016
- // sections: [
1017
- // {
1018
- // type: "parent",
1019
- // width: 16,
1020
- // rowStyle: {
1021
- // height: '100%',
1022
- // },
1023
- // childSections: [
1024
- // {
1025
- // colStyle: {
1026
- // paddingTop: '16px',
1027
- // borderRight: '1px solid #d9d9d9',
1028
- // height: '100%',
1029
- // },
1030
- // width: 16,
1031
- // type: "parent",
1032
- // childSections: [
1033
- // {
1034
- // type: "col-label",
1035
- // inputFields: [
1036
- // {
1037
- // id: "sms-editor",
1038
- // label: "Message",
1039
- // labelStyle: {
1040
- // backgroundColor: 'white',
1041
- // textAlign: 'left',
1042
- // color: '#333333',
1043
- // lineHeight: '24px',
1044
- // fontSize: '16px',
1045
- // fontWeight: '600',
1046
- // fontFamily: 'proxima-nova, sans-serif',
1047
- // fontStyle: 'normal',
1048
- // },
1049
- // style: {
1050
- // textAlign: 'left',
1051
- // color: '#333333',
1052
- // fontFamily: 'Open-Sans',
1053
- // lineHeight: '24px',
1054
- // fontSize: '14px',
1055
- // },
1056
- // type: "textarea",
1057
- // metaType: "text",
1058
- // datatype: "string",
1059
- // required: true,
1060
- // placeholder: "Please input sms template content.",
1061
- // fluid: false,
1062
- // styling: "semantic",
1063
- // onlyDisplay: false,
1064
- // width: 18,
1065
- // autosize: true,
1066
- // autosizeParams: {
1067
- // minRows: 3,
1068
- // },
1069
- // order: 2,
1070
- // customComponent: true,
1071
- // supportedEvents: {
1072
- // onChange: this.onTemplateContentChange,
1073
- // },
1074
- // },
1075
- // ],
1076
- // actionFields: [
1077
- // ],
1078
- // },
1079
- // {
1080
- // type: "multicols",
1081
- // inputFields: [
1082
- // {
1083
- // cols: [
1084
- // {
1085
- // offset: 19,
1086
- // id: "tagList",
1087
- // label: "Tags",
1088
- // type: "tag-list", //Resembles component to be used
1089
- // metaType: "List",
1090
- // datatype: "select",
1091
- // required: true,
1092
- // fluid: true,
1093
- // onlyDisplay: true,
1094
- // styling: "semantic",
1095
- // order: 1,
1096
- // customComponent: true,
1097
- // supportedEvents: {
1098
- // onTagSelect: this.onTagSelect,
1099
- // },
1100
- // },
1101
- // ],
1102
- // },
1103
- // {
1104
- // cols: [
1105
- // {
1106
- // id: "unicode-validity",
1107
- // label: "Allow Unicode characters?",
1108
- // labelStyle: {
1109
- // backgroundColor: "white",
1110
- // },
1111
- // style: {
1112
- // textAlign: 'left',
1113
- // color: '#262626',
1114
- // fontFamily: 'Open-Sans',
1115
- // lineHeight: '24px',
1116
- // fontSize: '14px',
1117
- // },
1118
- // type: "checkbox", //Resembles component to be used
1119
- // metaType: "text",
1120
- // datatype: "boolean",
1121
- // required: true,
1122
- // fluid: true,
1123
- // styling: "semantic",
1124
- // order: 1,
1125
- // width: 10,
1126
- // offset: 4,
1127
- // onlyDisplay: false,
1128
- // customComponent: false,
1129
- // supportedEvents: {
1130
- // onChange: this.onTemplateNameChange,
1131
- // },
1132
- // },
1133
- // ],
1134
- // },
1135
- // ],
1136
- // actionFields: [],
1137
- // },
1138
- // ],
1139
- // },
1140
- // {
1141
- // width: 6,
1142
- // type: "multicols",
1143
- // offset: 1,
1144
- // colStyle: {
1145
- // paddingTop: '16px',
1146
- // },
1147
- // inputFields: [
1148
- // {
1149
- // cols: [
1150
- // {
1151
- // id: "sms-preview",
1152
- // type: "sms-preview", //Resembles component to be used
1153
- // customComponent: true,
1154
- // customStyling: { padding: '0' },
1155
- // metaType: "preview",
1156
- // required: true,
1157
- // fluid: true,
1158
- // styling: "semantic",
1159
- // order: 1,
1160
- // width: 5,
1161
- // onlyDisplay: true,
1162
- // offset: 7,
1163
- // channel: 'SMS',
1164
- // supportedEvents: {
1165
- // onChange: this.onTemplateNameChange,
1166
- // },
1167
- // },
1168
- // ],
1169
- // },
1170
- // ],
1171
- // },
1172
- // ],
1173
- // },
1174
- // ],
1175
- // },
1176
- // ],
1177
- // type: "tabs",
1178
- // defaultPanes: 1,
1179
- // additionalPanes: 0,
1180
- // id: "pane",
1181
- // tabBarExtraContent: {
1182
- // sections: [
1183
- // {
1184
- // type: "multicols",
1185
- // actionFields: [
1186
- // {
1187
- // cols: [
1188
- // {
1189
- // id: "add-version-button",
1190
- // metaType: "submit-button",
1191
- // type: "button",
1192
- // buttonType: "cancel",
1193
- // icon: "plus-circle-o",
1194
- // value: "New Version",
1195
- // customComponent: false,
1196
- // onlyDisplay: true,
1197
- // styling: "semantic",
1198
- // order: 3,
1199
- // fluid: false,
1200
- // submitAction: "addVersion",
1201
- // supportedEvents: {
1202
- // addVersion: this.addVersion,
1203
- // },
1204
- // },
1205
- // ],
1206
- // },
1207
- // ],
1208
- // inputFields: [],
1209
- // },
1210
- // ],
1211
- // },
1212
- // tabContent: {
1213
- // sections: [
1214
- // {
1215
- // type: "multicols",
1216
- // inputFields: [
1217
- // {
1218
- // rowStyle: {
1219
- // display: "flex",
1220
- // flex: 1,
1221
- // },
1222
- // cols: [
1223
- // {
1224
- // id: "tab-header",
1225
- // metaType: "label",
1226
- // value: "Version",
1227
- // primitive: true,
1228
- // dynamicTab: true,
1229
- // type: "div",
1230
- // width: 5,
1231
- // offset: 0,
1232
- // onlyDisplay: true,
1233
- // colStyle: {
1234
- // flex: 1,
1235
- // },
1236
- // supportedEvents: {
1237
- // onChange: this.onVersionNameChange,
1238
- // },
1239
- // },
1240
- // {
1241
- // id: "tab-options-popover",
1242
- // metaType: "display",
1243
- // colStyle: {
1244
- // flex: 0,
1245
- // },
1246
- // type: "popover",
1247
- // customComponent: false,
1248
- // styling: "semantic",
1249
- // order: 3,
1250
- // fluid: false,
1251
- // onlyDisplay: true,
1252
- // submitAction: "onTabOptionSelect",
1253
- // supportedEvents: {
1254
- // onTabOptionSelect: this.onTabOptionSelect,
1255
- // },
1256
- // content: {
1257
- // sections: [
1258
- // {
1259
- // type: "multicols",
1260
- // inputFields: [
1261
- // {
1262
- // cols: [
1263
- // {
1264
- // id: "mark-final-version-label",
1265
- // metaType: "label",
1266
- // type: "div",
1267
- // primitive: true,
1268
- // value: "Mark as Final",
1269
- // onlyDisplay: true,
1270
- // customComponent: false,
1271
- // order: 3,
1272
- // fluid: false,
1273
- // submitAction: "markFinalVersion",
1274
- // supportedEvents: {
1275
- // markFinalVersion: this.markFinalVersion,
1276
- // },
1277
- // },
1278
- // ],
1279
- // },
1280
- // {
1281
- // cols: [
1282
- // {
1283
- // id: "duplicate-version-label",
1284
- // metaType: "label",
1285
- // type: "div",
1286
- // primitive: true,
1287
- // value: "Duplicate",
1288
- // onlyDisplay: true,
1289
- // customComponent: false,
1290
- // order: 3,
1291
- // fluid: false,
1292
- // submitAction: "duplicateVersion",
1293
- // supportedEvents: {
1294
- // duplicateVersion: this.duplicateVersion,
1295
- // },
1296
- // },
1297
- // ],
1298
- // },
1299
- // {
1300
- // cols: [
1301
- // {
1302
- // id: "rename-version-label",
1303
- // metaType: "label",
1304
- // type: "div",
1305
- // primitive: true,
1306
- // value: "Rename",
1307
- // onlyDisplay: true,
1308
- // customComponent: false,
1309
- // order: 3,
1310
- // fluid: false,
1311
- // submitAction: "renameVersion",
1312
- // supportedEvents: {
1313
- // renameVersion: this.renameVersion,
1314
- // },
1315
- // },
1316
- // ],
1317
- // },
1318
- // {
1319
- // cols: [
1320
- // {
1321
- // id: "delete-version-label",
1322
- // metaType: "label",
1323
- // type: "div",
1324
- // primitive: true,
1325
- // value: "Delete",
1326
- // onlyDisplay: true,
1327
- // customComponent: false,
1328
- // order: 3,
1329
- // fluid: false,
1330
- // submitAction: "deleteVersion",
1331
- // supportedEvents: {
1332
- // deleteVersion: this.deleteVersion,
1333
- // },
1334
- // },
1335
- // ],
1336
- // },
1337
- // ],
1338
- // actionFields: [],
1339
- // },
1340
- // ],
1341
- // },
1342
- // value: {
1343
- // sections: [
1344
- // {
1345
- // type: "multicols",
1346
- // inputFields: [
1347
- // {
1348
- // cols: [
1349
- // {
1350
- // id: "tab-option-icon",
1351
- // metaType: "display",
1352
- // type: "icon",
1353
- // onlyDisplay: true,
1354
- // primitive: false,
1355
- // value: "&#xE313;",
1356
- // customComponent: false,
1357
- // order: 3,
1358
- // fluid: false,
1359
- // },
1360
- // ],
1361
- // },
1362
- // ],
1363
- // actionFields: [],
1364
- // },
1365
- // ],
1366
- // },
1367
- // trigger: "click",
1368
- // placement: "bottomRight",
1369
- // },
1370
- // ],
1371
- // },
1372
- // ],
1373
- // actionFields: [],
1374
- // },
1375
- // ],
1376
- // },
1377
- // label: "Version",
1378
- // supportedEvents: {
1379
- // onTabChange: this.onTabChange,
1380
- // },
1381
- // },
1382
- // ],
1383
- // channel: "SMS",
1384
- // module: "Campaigns",
1385
- // };
1386
906
  this.setState({ schema: this.props.metaEntities.layouts[0].definition });
1387
907
  }
1388
908
 
@@ -1413,16 +933,25 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
1413
933
  console.log('obj', obj);
1414
934
  this.props.actions.createTemplate(obj);
1415
935
  }
936
+ isSmsLoading = () => {
937
+ //let {isLoading} = this.props;
938
+ let isLoading = this.props.isLoadingMetaEntities || this.state.loading || (this.props.Create && "createTemplateInProgress" in this.props.Create && this.props.Create.createTemplateInProgress);
939
+
940
+ if (!isLoading) {
941
+ isLoading = this.state.loadingStatus < 2;
942
+ }
943
+ return isLoading;
944
+ }
1416
945
  render() {
1417
946
  const schema = this.state.schema;
1418
- const spinning = this.state.loading || (this.props.Create && "createTemplateInProgress" in this.props.Create && this.props.Create.createTemplateInProgress);
947
+ const spinning = this.isSmsLoading();
1419
948
  let tags = this.props.metaEntities && this.props.metaEntities.tags ? this.props.metaEntities.tags.standard : [];
1420
949
  if (this.props.location.query.type === 'embedded' && this.props.location.query.module === 'library' && !this.props.getDefaultTags) {
1421
950
  tags = this.props.supportedTags; // if get default tags is not present and supported tags is present use that inlbrary mode
1422
951
  }
1423
952
  return (
1424
953
  <div>
1425
- <Spin tip={this.props.intl.formatMessage(messages.saveTemplateLoader)} spinning={spinning}>
954
+ <Spin spinning={spinning}>
1426
955
  {/*<\Row style={{marginBottom: '16px', marginLeft: '-40px'}}>
1427
956
  <Col offset={1}>
1428
957
  <Breadcrumb>
@@ -1475,12 +1004,14 @@ Create.propTypes = {
1475
1004
  intl: intlShape.isRequired,
1476
1005
  supportedTags: PropTypes.array,
1477
1006
  getDefaultTags: PropTypes.string,
1007
+ isLoadingMetaEntities: PropTypes.bool,
1478
1008
  };
1479
1009
 
1480
1010
  const mapStateToProps = createStructuredSelector({
1481
1011
  Create: makeSelectCreate(),
1482
1012
  createResponse: makeSelectCreateResponse(),
1483
1013
  metaEntities: makeSelectMetaEntities(),
1014
+ isLoadingMetaEntities: isLoadingMetaEntities(),
1484
1015
  });
1485
1016
 
1486
1017
  function mapDispatchToProps(dispatch) {
@@ -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.32",
4
+ "version": "2.0.34",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",