@capillarytech/creatives-library 7.1.4 → 7.1.6

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": "7.1.4",
4
+ "version": "7.1.6",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -616,7 +616,7 @@ class TemplatePreview extends React.Component { // eslint-disable-line react/pre
616
616
  'text-align': 'center',
617
617
  "width": '140px',
618
618
  "height": '20px',
619
- "margin-left": "2px",
619
+ "margin-left": "8px",
620
620
  }}>
621
621
  <p
622
622
  style={{ 'font-size': '12px',
@@ -2358,6 +2358,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2358
2358
  const response = {
2359
2359
  action: "getFormData",
2360
2360
  postAction: this.state.getFormDataValue || 'next',
2361
+ id : _.get(this.props, 'Email.templateDetails._id', ''),
2361
2362
  value: this.transformFormData(passedData),
2362
2363
  validity: this.state.isFormValid,
2363
2364
  type: 'EMAIL',
@@ -373,17 +373,47 @@ export class FTP extends React.Component {
373
373
  const tags = getTreeStructuredTags({tagsList: (metaEntities.tags || {}).standard, offerDetails: selectedOfferDetails});
374
374
  const clonnedTagsTree = cloneDeep(tags);
375
375
  headerTagList.map((headerTag) => {
376
- const pos = findIndex(clonnedTagsTree, {value: headerTag.tag});
377
- if (pos > -1) {
378
- clonnedTagsTree[pos] = {
376
+ clonnedTagsTree.map((tag, index) => {
377
+ if (!isEmpty(tag.children)) { //if we have subtags it will first resolve subtag values.
378
+ const subTags = this.disableUsedSubTag(tag.children, headerTag);
379
+ clonnedTagsTree[index] = {
380
+ ...clonnedTagsTree[index],
381
+ children: subTags,
382
+ };
383
+ } else { // If first level itself is leaf node then I will match the usedtag value and disable it accordingly.
384
+ const pos = findIndex(clonnedTagsTree, {value: headerTag.tag});
385
+ if (pos > -1) {
386
+ clonnedTagsTree[pos] = {
387
+ disabled: true,
388
+ ...clonnedTagsTree[pos],
389
+ };
390
+ }
391
+ }
392
+ });
393
+ });
394
+ this.setState({tagsTree: clonnedTagsTree});
395
+ };
396
+
397
+ disableUsedSubTag = (subTags, headerTag) => {
398
+ const clonnedSubTags = cloneDeep(subTags);
399
+ clonnedSubTags.map((tag, index) => {
400
+ if (!isEmpty(tag.children)) { //Using recursion here to dig deep into further level if they have subtags.
401
+ //if we still have subtags, it will call same function to resolved deepest subtag value first.
402
+ const subTags1 = this.disableUsedSubTag(tag.children, headerTag);
403
+ clonnedSubTags[index] = {
404
+ ...clonnedSubTags[index],
405
+ children: subTags1,
406
+ };
407
+ } else if (isEqual(tag.value, headerTag.tag)) { // when Leaf node, it will match usedtag value and disable usedtags from tags tree.
408
+ clonnedSubTags[index] = {
379
409
  disabled: true,
380
- ...clonnedTagsTree[pos],
410
+ ...clonnedSubTags[index],
381
411
  };
382
412
  }
383
413
  return null;
384
414
  });
385
- this.setState({tagsTree: clonnedTagsTree});
386
- };
415
+ return clonnedSubTags;
416
+ }
387
417
 
388
418
  handleManageFTPSettings = () => {
389
419
  const path = `/exports/configurations`;
@@ -122,7 +122,7 @@ const Viber = (props) => {
122
122
  }, [viberData.selectedViberAccount]);
123
123
 
124
124
  useEffect(() => {
125
- if ((params && params.id) || templateData.edit) {
125
+ if ((params && params.id) || (templateData || {}).edit) {
126
126
  const { viber: editViberContent = {} } = get(templateData, `versions.base.content`) || get(viber, `templateDetails.versions.base.content`) || {};
127
127
  const editMessageTitle = (templateData || {}).name || get(viber, 'templateDetails.name');
128
128
  updateTextMessageTitle(editMessageTitle);