@capillarytech/creatives-library 3.11.4 → 3.12.1

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "3.11.4",
4
+ "version": "3.12.1",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -2941,7 +2941,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2941
2941
  type={val.buttonType}
2942
2942
  icon={val.icon}
2943
2943
  disabled={val.disabled ? val.disabled : false}
2944
- onClick={(data) => val.id === 'save-button' ? this.saveForm() : this.callChildEvent(data, val, val.submitAction)}>
2944
+ onClick={(data) => this.callChildEvent(data, val, val.submitAction)}>
2945
2945
  {val.value}
2946
2946
  </CapButton>
2947
2947
  </CapColumn>
@@ -40,7 +40,7 @@ const getLineType = ({
40
40
  isFullMode,
41
41
  templateData,
42
42
  }) => {
43
- if (channel === constants.LINE && slidBoxContent !== 'templates') {
43
+ if ((channel === constants.LINE || (templateData && templateData.type === constants.LINE)) && slidBoxContent !== 'templates') {
44
44
  const isCreate = slidBoxContent === 'createTemplate';
45
45
  const isEdit = slidBoxContent === 'editTemplate';
46
46
  if (isFullMode) {
@@ -371,7 +371,8 @@ export class Line extends Component {
371
371
  msgData.text = formData.base['message-editor'];
372
372
  }
373
373
  } else if (modeType === 'image') {
374
- if (formData['0'].image.length < 1) {
374
+ const formImage = formData['0'].image;
375
+ if (formImage && formImage.length < 1) {
375
376
  return 'IMAGE_ERROR';
376
377
  }
377
378
  if (this.state.isEdit) {
@@ -471,8 +472,8 @@ export class Line extends Component {
471
472
  return schema;
472
473
  };
473
474
 
474
- saveFormData = (formData) => {
475
- const obj = this.getTransformedData(formData);
475
+ saveFormData = () => {
476
+ const obj = this.getTransformedData(this.state.formData);
476
477
  if (obj === 'IMAGE_ERROR') {
477
478
  const message = getMessageObject(
478
479
  'error',
@@ -505,13 +506,17 @@ export class Line extends Component {
505
506
  if (!this.state.startValidation) {
506
507
  this.setState({
507
508
  startValidation: true,
508
- }, () => {
509
- const {
510
- isFullMode,
511
- saveMessage,
512
- actions,
513
- onCreateComplete,
514
- } = this.props;
509
+ });
510
+ } else {
511
+ const {
512
+ isFullMode,
513
+ saveMessage,
514
+ actions,
515
+ onCreateComplete,
516
+ } = this.props;
517
+ const { text, originalContentUrl, image } = get(obj, "versions.base.content.messages[0]", {});
518
+ const { name } = obj || {};
519
+ if ((text || originalContentUrl || image) && (isFullMode ? name : true)) {
515
520
  if (!isFullMode) {
516
521
  saveMessage();
517
522
  } else if (this.state.isEdit) {
@@ -525,7 +530,7 @@ export class Line extends Component {
525
530
  onCreateComplete
526
531
  );
527
532
  }
528
- });
533
+ }
529
534
  }
530
535
  };
531
536
 
@@ -961,6 +966,12 @@ export class Line extends Component {
961
966
  return schema;
962
967
  };
963
968
 
969
+ stopValidation = () => {
970
+ this.setState({
971
+ startValidation: false,
972
+ })
973
+ }
974
+
964
975
  render() {
965
976
  const {
966
977
  Line: {
@@ -971,6 +982,7 @@ export class Line extends Component {
971
982
  params: {
972
983
  id,
973
984
  } = {},
985
+ isFullMode,
974
986
  } = this.props;
975
987
  const {
976
988
  edit,
@@ -989,6 +1001,10 @@ export class Line extends Component {
989
1001
  reUpload,
990
1002
  } = this.state.formData;
991
1003
  loading = typeof reUpload === 'undefined' ? !(msgEditor || uploadedAsset) : !reUpload;
1004
+ if (templateData && !isFullMode) {
1005
+ const { text, originalContentUrl } = get(templateData, "versions.base.content.messages[0]", {});
1006
+ loading = !(text || originalContentUrl);
1007
+ }
992
1008
  }
993
1009
  let tags =
994
1010
  this.props.metaEntities && this.props.metaEntities.tags
@@ -1033,6 +1049,7 @@ export class Line extends Component {
1033
1049
  this.setState({ isDrawerRequired: drawervisibleFlag })
1034
1050
  }
1035
1051
  startValidation={this.state.startValidation}
1052
+ stopValidation={this.stopValidation}
1036
1053
  />
1037
1054
  </CapColumn>
1038
1055
  </CapRow>
@@ -75,7 +75,7 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
75
75
  return pane;
76
76
  });
77
77
 
78
- const channel = ['sms', 'email', 'mobilepush', 'call_task'];
78
+ const channel = ['sms', 'email', 'mobilepush', 'line', 'call_task'];
79
79
  if (!isEmpty(channelsToDisable)) {
80
80
  channel.some((ch) => {
81
81
  if (!channelsToDisable.includes(ch)) {