@capillarytech/creatives-library 2.0.34 → 2.0.35

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.
@@ -24,6 +24,7 @@ import * as charCount from '../../../utils/smsCharCount';
24
24
  import { checkUnicode} from '../../../utils/smsCharCountV2';
25
25
  import * as globalActions from '../../../containers/Cap/actions';
26
26
  import {getMessageObject} from '../../../utils/messageUtils';
27
+ import * as creativesContainerActions from '../../CreativesContainer/actions';
27
28
  // import callNativeEvent from '../../../utils/callNativeEvent';
28
29
 
29
30
  export class Create extends React.Component { // eslint-disable-line react/prefer-stateless-function
@@ -85,7 +86,6 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
85
86
  }
86
87
 
87
88
  componentWillMount() {
88
- console.log('create mounting');
89
89
  if (this.props.route.name === 'view') {
90
90
  this.setState({loading: false});
91
91
  // this.removeStandAlone();
@@ -93,7 +93,6 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
93
93
  }
94
94
 
95
95
  componentDidMount() {
96
- console.log('added listener create,', this.props);
97
96
  const query = {
98
97
  layout: 'SMS',
99
98
  type: 'LAYOUT',
@@ -127,12 +126,10 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
127
126
  }
128
127
 
129
128
  componentWillReceiveProps(nextProps) {
130
- console.log('recieved props ', nextProps, nextProps.Create, this.props.Create);
131
129
  if (nextProps.location.query.module === 'library' && nextProps.isGetFormData) {
132
130
  nextProps.getFormSubscriptionData(this.getFormData());
133
131
  }
134
132
  if (nextProps.createResponse && nextProps.createResponse.templateId) {
135
- console.log('create response', nextProps.createResponse);
136
133
  this.discardValues();
137
134
  const message = getMessageObject('success', 'SMS Template Created Successfully', true);
138
135
  this.props.globalActions.addMessageToQueue(message);
@@ -150,7 +147,6 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
150
147
  this.props.globalActions.addMessageToQueue(message);
151
148
  }
152
149
  if (nextProps.metaEntities && nextProps.metaEntities.layouts && nextProps.metaEntities.layouts.length > 0 && _.isEmpty(this.state.schema)) {
153
- console.log('final schema is**', nextProps.metaEntities.layouts[0].definition);
154
150
  this.injectEvents(nextProps.metaEntities.layouts[0].definition);
155
151
  if (this.props.location.query.module !== 'library' || (this.props.location.query.module === 'library' && this.props.getDefaultTags)) {
156
152
  const query = {
@@ -174,7 +170,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
174
170
  delete injectedTags["Store custom fields"];
175
171
  delete injectedTags["Transaction custom fields"];
176
172
  injectedTags = _.merge({}, injectedTags, nextProps.metaEntities.tags.custom);
177
- console.log('new injected tags', nextProps.metaEntities.tags.custom);
173
+
178
174
  if (!_.has(nextProps.metaEntities.tags.custom, "Registration custom fields")) {
179
175
  delete injectedTags["Registration custom fields"];
180
176
  }
@@ -187,30 +183,28 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
187
183
  this.setState({injectedTags, loadingStatus: this.state.loadingStatus + 1});
188
184
  }
189
185
  // if (nextProps.metaEntities && nextProps.metaEntities.tags && nextProps.metaEntities.tags.length > 0 && _.isEmpty(this.state.schema)) {
190
- // console.log('final schema is**', nextProps.metaEntities.layouts[0].definition);
186
+ //
191
187
  // this.injectEvents(nextProps.metaEntities.layouts[0].definition);
192
188
  // }
193
189
  }
194
190
 
195
191
  componentWillUnmount() {
196
- console.log('removed listener create');
197
192
  window.removeEventListener("message", this.handleFrameTasks);
198
193
  }
199
194
 
200
195
  onTemplateNameChange(name) {
201
- console.log('Template name changed to ', name);
196
+
202
197
  }
203
198
 
204
199
  onTemplateContentChange(content) {
205
- console.log('Template content changed to ', content);
200
+
206
201
  }
207
202
 
208
203
  onVersionNameChange(data, versionIndex) {
209
- console.log('version name changed to', data, versionIndex);
204
+
210
205
  }
211
206
 
212
207
  onFormDataChange(formData, tabCount, currentTab) {
213
- console.log('Form data changed is ', formData, tabCount, currentTab);
214
208
  this.setState({formData, tabCount});
215
209
  if (currentTab) {
216
210
  this.setState({currentTab});
@@ -218,24 +212,20 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
218
212
  }
219
213
 
220
214
  onTagSelect(data, currentTab) {
221
- console.log('parent data tag', data, currentTab);
222
215
  const editorId = currentTab > 1 ? `sms-editor${currentTab}` : 'sms-editor';
223
216
  this.insertAtCursor(document.getElementById(editorId), `{{${data}}}`, currentTab);
224
217
  document.getElementById(editorId).focus();
225
218
  }
226
219
 
227
220
  onTabChange(data) {
228
- console.log('inside parent ontabchange', data, this.state);
229
221
  this.setState({currentTab: data});
230
222
  }
231
223
 
232
224
  getFormData(e, value) {
233
- console.log('posting final result', this.state.formData);
234
225
  const formData = _.cloneDeep(this.state.formData);
235
226
  let baseData = {};
236
227
  let versionIdx;
237
228
  _.forEach(formData, (val, idx) => {
238
- console.log('val', val);
239
229
  if (val.base && idx !== 'base') {
240
230
  baseData = val;
241
231
  versionIdx = idx;
@@ -249,7 +239,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
249
239
  result.base = baseData;
250
240
  const msgObj = charCount.updateCharCount(baseData['sms-editor']);
251
241
  result.base.msg_count = msgObj.msgCount;
252
- console.log("Message Count", msgObj.msgCount);
242
+
253
243
  const response = {
254
244
  action: "getFormData",
255
245
  value: result,
@@ -257,8 +247,8 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
257
247
  validity: this.state.isFormValid,
258
248
  type: 'SMS',
259
249
  };
260
- this.setState({checkValidation: true});
261
- console.log('posting final result internal', response);
250
+ this.setState({checkValidation: true, loading: true});
251
+
262
252
  if (e) {
263
253
  e.source.postMessage(JSON.stringify(response), e.origin);
264
254
  }
@@ -266,7 +256,6 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
266
256
  }
267
257
 
268
258
  getCurrentWindow(e) {
269
- console.log('in sms create', e);
270
259
  const response = {
271
260
  action: e.action,
272
261
  value: 'edit',
@@ -356,7 +345,6 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
356
345
  }
357
346
 
358
347
  moveToTemplates() {
359
- console.log('in move to Templates');
360
348
  const modalContent = {
361
349
  title: "Alert",
362
350
  body: "Do you really want to go back? All your temporary changes will be lost!",
@@ -383,7 +371,6 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
383
371
  }
384
372
 
385
373
  injectEvents(schema) {
386
- console.log('now injecting events');
387
374
  const temp = schema;
388
375
  temp.standalone.sections = this.injectSections(temp.standalone.sections);
389
376
  _.forEach(temp.containers, (container) => {
@@ -391,7 +378,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
391
378
  tempContainer = this.injectContainer(tempContainer);
392
379
  return tempContainer;
393
380
  });
394
- console.log('final injected schema', schema);
381
+
395
382
  this.setState({schema, loadingStatus: this.state.loadingStatus + 1}, () => {
396
383
  const type = this.props.location.query.type;
397
384
  if (type === 'embedded') {
@@ -430,10 +417,9 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
430
417
  }
431
418
  temp.injectedEvents = {};
432
419
  _.forEach(col.supportedEvents, (event) => {
433
- console.log('injected event for ', col, event, this.getMappedEvent(col.id, event));
434
420
  temp.injectedEvents[event] = this.getMappedEvent(col.id, event);
435
421
  });
436
- console.log('should translate multicol', temp);
422
+
437
423
  if (temp.type === 'icon') {
438
424
  return true;
439
425
  }
@@ -464,7 +450,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
464
450
  _.forEach(col.supportedEvents, (event) => {
465
451
  temp.injectedEvents[event] = this.getMappedEvent(col.id, event);
466
452
  });
467
- console.log('should translate multicol action', temp);
453
+
468
454
  if (temp.type === 'icon') {
469
455
  return true;
470
456
  }
@@ -498,7 +484,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
498
484
  _.forEach(inputField.supportedEvents, (event) => {
499
485
  temp.injectedEvents[event] = this.getMappedEvent(inputField.id, event);
500
486
  });
501
- console.log('should translate collabel', temp);
487
+
502
488
  if (temp.type === 'icon') {
503
489
  return true;
504
490
  }
@@ -527,7 +513,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
527
513
  _.forEach(actionField.supportedEvents, (event) => {
528
514
  temp.injectedEvents[event] = this.getMappedEvent(actionField.id, event);
529
515
  });
530
- console.log('should translate collabel action', temp);
516
+
531
517
  if (temp.type === 'icon') {
532
518
  return true;
533
519
  }
@@ -577,7 +563,6 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
577
563
  }
578
564
 
579
565
  cloneColLabel(sectionObj, tabIndex) {
580
- console.log('cloning cloneColLabel', sectionObj, tabIndex);
581
566
  const section = _.cloneDeep(sectionObj);
582
567
  const inputFields = _.forEach(section.inputFields, (inputField) => {
583
568
  const inputF = inputField;
@@ -586,12 +571,11 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
586
571
  return inputF;
587
572
  });
588
573
  section.inputFields = inputFields;
589
- console.log('cloned ifs are', section);
574
+
590
575
  return section;
591
576
  }
592
577
 
593
578
  cloneMultiCol(sectionObj, tabIndex) {
594
- console.log('cloning multicol ', sectionObj, tabIndex);
595
579
  const section = _.cloneDeep(sectionObj);
596
580
  const inputFields = _.forEach(section.inputFields, (inputField) => {
597
581
  const inputF = inputField;
@@ -605,12 +589,11 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
605
589
  return inputF;
606
590
  });
607
591
  section.inputFields = inputFields;
608
- console.log('cloned cols are', section);
592
+
609
593
  return section;
610
594
  }
611
595
 
612
596
  cloneParent(section, tabIndex) {
613
- console.log('trying to clone', JSON.stringify(section), tabIndex);
614
597
  const parentsect = section;
615
598
  const childSectionsBeforeCloning = parentsect.childSections.slice();
616
599
  const childSections = [];
@@ -623,19 +606,17 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
623
606
  } else if (childSection.type === 'parent') {
624
607
  sect = this.cloneParent(childSection, tabIndex);
625
608
  }
626
- console.log('returning cloned parent section', sect);
609
+
627
610
  childSections.push(sect);
628
611
  return true;
629
612
  });
630
- console.log('returning cloned parent section final 1', JSON.stringify(childSections));
613
+
631
614
  parentsect.childSections = childSections;
632
- console.log('returning cloned parent section final', parentsect);
615
+
633
616
  return _.cloneDeep(parentsect);
634
617
  }
635
618
 
636
619
  deleteVersion(data, currentTab) {
637
- console.log('trying to delete version in parent sms create');
638
- console.log('deleting version', data, currentTab);
639
620
  if (this.state.tabCount === 1) {
640
621
  return;
641
622
  }
@@ -646,22 +627,19 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
646
627
  }
647
628
 
648
629
  renameVersion(data, currentTab) {
649
- console.log('renaming version', data, currentTab);
630
+
650
631
  }
651
632
 
652
633
  markFinalVersion(data, currentTab) {
653
634
  const message = getMessageObject('success', 'Template Marked as Final Successfully', true);
654
635
  this.props.globalActions.addMessageToQueue(message);
655
- console.log('markFinal version', data, currentTab);
656
636
  }
657
637
 
658
638
  duplicateVersion(data, currentTab) {
659
- console.log('duplicate version', data, currentTab);
660
639
  this.addVersion(this.state.tabCount);
661
640
  }
662
641
 
663
642
  addVersion(data, addNow) {
664
- console.log('adding version', data);
665
643
  let tabIndex = data + 1;
666
644
  const schema = _.cloneDeep(this.state.schema);
667
645
  const containers = schema.containers.slice();
@@ -685,7 +663,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
685
663
  });
686
664
  firstPane.sections = sections;
687
665
  schema.containers[0].panes.push(firstPane);
688
- console.log('adding version tabIndex', tabIndex, tabIndex === 5, schema.containers[0].tabBarExtraContent.sections[0].actionFields[0].cols);
666
+
689
667
  if (tabIndex === 5) {
690
668
  schema.containers[0].tabBarExtraContent.sections[0].actionFields[0].cols[0].disabled = true;
691
669
  }
@@ -710,7 +688,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
710
688
  });
711
689
  firstPane.sections = sections;
712
690
  schema.containers[0].panes.push(firstPane);
713
- console.log('adding version tabIndex', tabIndex, tabIndex === 5, schema.containers[0].tabBarExtraContent.sections[0].actionFields[0].cols);
691
+
714
692
  if (tabIndex === 5) {
715
693
  schema.containers[0].tabBarExtraContent.sections[0].actionFields[0].cols[0].disabled = true;
716
694
  }
@@ -733,12 +711,11 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
733
711
  }
734
712
  }
735
713
  if (isValid) {
736
- console.log('isValid');
737
714
  return true;
738
715
  }
739
716
  const message = getMessageObject('error', 'Template data is not valid', true);
740
717
  this.props.globalActions.addMessageToQueue(message);
741
- console.log('not valid');
718
+
742
719
  return false;
743
720
  }
744
721
 
@@ -769,9 +746,8 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
769
746
 
770
747
  startTemplateCreation(data) {
771
748
  if (data.edit) {
772
- console.log('startTemplateCreation');
773
749
  const ifUnicode = checkUnicode(data.content ? data.content : '');
774
- console.log('smsDetails', ifUnicode, data.content);
750
+
775
751
  const content = data.content;
776
752
  const id = _.uniqueId();
777
753
  const tempData = {
@@ -792,18 +768,15 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
792
768
  }
793
769
 
794
770
  startLoading(ifEdit) {
795
- console.log('startLoading', ifEdit);
796
771
  if (ifEdit) {
797
772
  this.setState({loading: true});
798
773
  }
799
774
  }
800
775
 
801
776
  handleFrameTasks = (e) => {
802
- console.log('data listened to is', e.data);
803
777
  const type = e.data;
804
- console.log('data type', typeof type);
778
+
805
779
  if (typeof type === 'object') {
806
- console.log('received something', type);
807
780
  const action = type.action;
808
781
  switch (action) {
809
782
  case "startTemplateCreation":
@@ -827,15 +800,15 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
827
800
  this.getFormData(e);
828
801
  break;
829
802
  case "startTemplateCreation":
830
- console.log('Starting to create template');
803
+
831
804
  //this.getFormData(e);
832
805
  break;
833
806
  case "moveToTemplates":
834
- console.log('moving to templates');
807
+
835
808
  this.moveToTemplates();
836
809
  break;
837
810
  case "validateContent":
838
- console.log('validating Content');
811
+
839
812
  this.validateContent(e);
840
813
  break;
841
814
  default:
@@ -845,7 +818,6 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
845
818
  }
846
819
 
847
820
  handleOnTagsContextChange = (data) => {
848
- console.log('parent tags context', data);
849
821
  const query = {
850
822
  layout: 'SMS',
851
823
  type: 'TAG',
@@ -876,7 +848,6 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
876
848
  }
877
849
 
878
850
  validateContent = (e) => {
879
- console.log('posting final validation result', this.state.isFormValid);
880
851
  const response = {
881
852
  action: "validateContent",
882
853
  value: this.state.isFormValid,
@@ -913,11 +884,11 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
913
884
  saveFormData(formData) {
914
885
  //Logic to save in db etc
915
886
  // const isValidated = this.validateFormData(formData);
916
- // console.log('whyyyy');
887
+ //
917
888
  // if (!isValidated) {
918
889
  // return;
919
890
  // }
920
- console.log('Saving form data', formData, this.state.tabCount);
891
+
921
892
  const obj = {};
922
893
  obj.versions = {
923
894
  base: {},
@@ -930,7 +901,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
930
901
  }
931
902
  obj.name = formData['template-name'];
932
903
  obj.versions.base = formData.base;
933
- console.log('obj', obj);
904
+
934
905
  this.props.actions.createTemplate(obj);
935
906
  }
936
907
  isSmsLoading = () => {
@@ -940,6 +911,9 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
940
911
  if (!isLoading) {
941
912
  isLoading = this.state.loadingStatus < 2;
942
913
  }
914
+ if (isLoading) {
915
+ this.props.creativesContainerActions.hideCreativesContanerLoader();
916
+ }
943
917
  return isLoading;
944
918
  }
945
919
  render() {
@@ -1005,6 +979,7 @@ Create.propTypes = {
1005
979
  supportedTags: PropTypes.array,
1006
980
  getDefaultTags: PropTypes.string,
1007
981
  isLoadingMetaEntities: PropTypes.bool,
982
+ creativesContainerActions: PropTypes.object,
1008
983
  };
1009
984
 
1010
985
  const mapStateToProps = createStructuredSelector({
@@ -1018,6 +993,7 @@ function mapDispatchToProps(dispatch) {
1018
993
  return {
1019
994
  actions: bindActionCreators(actions, dispatch),
1020
995
  globalActions: bindActionCreators(globalActions, dispatch),
996
+ creativesContainerActions: bindActionCreators(creativesContainerActions, dispatch),
1021
997
  };
1022
998
  }
1023
999