@capillarytech/creatives-library 7.17.217 → 7.17.219-alpha.0

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.17.217",
4
+ "version": "7.17.219-alpha.0",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -106,13 +106,16 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
106
106
  getSearchedExpandedKeys(tags, value = '') {
107
107
  let list = [];
108
108
  _.forEach(tags, (val = {}, key) => {
109
+ const tagName = typeof(val?.name) === "string" ? _.toLower(_.get(val, 'name', '')) : _.toLower(_.get(val, 'name.props.defaultMessage', ''));
110
+ const tagNameWithoutUnderscore = tagName.replace(/_/g, ' ');
111
+ const searchStringLower = _.toLower(value);
109
112
  if (_.has(val, 'subtags')) {
110
- if (val.name && typeof val.name === 'string' && (val.name || '').toLowerCase().indexOf(value.toLowerCase()) !== -1) {
113
+ if (val.name && (tagName.includes(searchStringLower) || tagNameWithoutUnderscore.includes(searchStringLower))) {
111
114
  list.push(key);
112
115
  }
113
116
  const temp = this.getSearchedExpandedKeys(val.subtags, value);
114
117
  list = list.concat(temp);
115
- } else if (val.name && typeof val.name === 'string' && (val.name || '').toLowerCase().indexOf(value.toLowerCase()) !== -1) {
118
+ } else if (val.name && (tagName.includes(searchStringLower) || tagNameWithoutUnderscore.includes(searchStringLower))) {
116
119
  list.push(key);
117
120
  }
118
121
  });
@@ -185,7 +188,8 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
185
188
  this.setState({showModal: true, visible: false});
186
189
  };
187
190
 
188
- renderTags(tags, searchString = '') {
191
+ renderTags(tags) {
192
+ const searchString = this.state.searchValue || '';
189
193
  const { disableRelatedTags, childTagsToDisable, parentTagstoDisable, showCardsRelatedTags } = this?.props?.disableTagsDetails;
190
194
  const { accessibleFeatures = [] } = this?.props?.currentOrgDetails || {};
191
195
  const hideDateTagsForJpLocale = accessibleFeatures.includes(JP_LOCALE_HIDE_FEATURE);
@@ -210,40 +214,58 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
210
214
  supportedTagsString += `${supportedTag} ,`;
211
215
  });
212
216
  supportedTagsString = supportedTagsString.replace(/,\s*$/, "");
213
- const tagDescriptionOrName = _.toLower(String(_.get(val, 'desc', '') || _.get(val, 'name', '')));
217
+ const tagName = typeof(val?.name) === "string" ? _.toLower(_.get(val, 'name', '')) : _.toLower(_.get(val, 'name.props.defaultMessage', ''));
218
+ const tagNameWithoutUnderscore = tagName.replace(/_/g, ' ');
214
219
  const searchStringLower = _.toLower(searchString);
215
- const tagContainsSearchedString = tagDescriptionOrName.includes(searchStringLower);
220
+ const tagContainsSearchedString = searchStringLower && (tagName.includes(searchStringLower) || tagNameWithoutUnderscore.includes(searchStringLower));
216
221
  if (_.has(val, 'subtags')) {
217
222
  const disabled = disableRelatedTags ? parentTagstoDisable.includes(key) : false;
218
- const temp = this.renderTags(val.subtags, '', disabled);
219
- const tagValue = (
220
- <CapTreeNode
221
- title={disabled ? <CapTooltip title={loyaltyAttrDisableText}>{val?.name}</CapTooltip> : val?.name}
222
- tag={val}
223
- key={val?.incentiveSeriesId ? `${key}(${val?.incentiveSeriesId})` : `${key}`}
224
- disabled={disabled}
225
- >
226
- {temp}
227
- </CapTreeNode>
228
- );
229
- hidingDateTagsForJpLocale(hideDateTagsForJpLocale, val, list, tagValue);
230
- } else if (searchString === '' || !searchString || tagContainsSearchedString) {
223
+ const temp = this.renderTags(val?.subtags);
224
+ if (temp?.length) {
225
+ const tagValue = (
226
+ <CapTreeNode
227
+ title={disabled ? <CapTooltip title={loyaltyAttrDisableText}>{val?.name}</CapTooltip> : val?.name}
228
+ tag={val}
229
+ key={val?.incentiveSeriesId ? `${key}(${val?.incentiveSeriesId})` : `${key}`}
230
+ disabled={disabled}
231
+ >
232
+ {temp}
233
+ </CapTreeNode>
234
+ );
235
+ hidingDateTagsForJpLocale(hideDateTagsForJpLocale, val, list, tagValue);
236
+ }
237
+ } else {
231
238
  let childDisabled = true;
232
239
  if (key === CUSTOMER_BARCODE_TAG && !hasCustomerBarcodeFeatureEnabled()) {
233
240
  childDisabled = true;
234
241
  } else {
235
242
  childDisabled = disableRelatedTags ? childTagsToDisable.includes(key) : false;
236
243
  }
237
- const tempNode = (
238
- <CapTreeNode
239
- title={childDisabled ? <CapTooltip title={key === CUSTOMER_BARCODE_TAG ? customerBarcodeDisableText : loyaltyAttrDisableText}>{val.desc || val.name}</CapTooltip> : (val.desc || val.name)}
240
- tag={val}
241
- isLeaf
242
- key={val?.incentiveSeriesId ? `${key}(${val?.incentiveSeriesId})` : `${key}`}
243
- disabled={childDisabled}
244
- >
245
- </CapTreeNode>);
246
- hidingDateTagsForJpLocale(hideDateTagsForJpLocale, val, list, tempNode);
244
+ if (searchString) {
245
+ if (tagContainsSearchedString) {
246
+ const tempNode = (
247
+ <CapTreeNode
248
+ title={childDisabled ? <CapTooltip title={key === CUSTOMER_BARCODE_TAG ? customerBarcodeDisableText : loyaltyAttrDisableText}>{val?.desc || val?.name}</CapTooltip> : (val?.desc || val?.name)}
249
+ tag={val}
250
+ isLeaf
251
+ key={val?.incentiveSeriesId ? `${key}(${val?.incentiveSeriesId})` : `${key}`}
252
+ disabled={childDisabled}
253
+ >
254
+ </CapTreeNode>);
255
+ hidingDateTagsForJpLocale(hideDateTagsForJpLocale, val, list, tempNode);
256
+ }
257
+ } else {
258
+ const tempNode = (
259
+ <CapTreeNode
260
+ title={childDisabled ? <CapTooltip title={key === CUSTOMER_BARCODE_TAG ? customerBarcodeDisableText : loyaltyAttrDisableText}>{val?.desc || val?.name}</CapTooltip> : (val?.desc || val?.name)}
261
+ tag={val}
262
+ isLeaf
263
+ key={val?.incentiveSeriesId ? `${key}(${val?.incentiveSeriesId})` : `${key}`}
264
+ disabled={childDisabled}
265
+ >
266
+ </CapTreeNode>);
267
+ hidingDateTagsForJpLocale(hideDateTagsForJpLocale, val, list, tempNode);
268
+ }
247
269
  }
248
270
  });
249
271
  return list;
@@ -117,11 +117,11 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
117
117
  const { id: selectedWeChatAccountId } = editSelectedWeChatAccount || {};
118
118
  const { definition } = templateDetails || {};
119
119
  const { accountId: templateAccountId } = definition || {};
120
- const { Edit: nextEdit } = nextProps || {};
120
+ const { Templates: nextTemplates, Edit: nextEdit } = nextProps || {};
121
121
  if (isEmbeddedEditOrPreview(queryType, creativesMode)) {
122
122
  selectedWeChatAccount = !_.isEmpty(editSelectedWeChatAccount)
123
123
  ? editSelectedWeChatAccount
124
- : nextEdit?.selectedWeChatAccount;
124
+ : nextTemplates?.selectedWeChatAccount;
125
125
  } else if (!_.isEmpty(Templates?.selectedWeChatAccount)) {
126
126
  selectedWeChatAccount = Templates?.selectedWeChatAccount;
127
127
  }
@@ -154,11 +154,11 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
154
154
  ) {
155
155
  this.setMobilePushAccountOptions(nextEdit?.weCrmAccounts, templateAccountId);
156
156
  }
157
- if (!_.isEmpty(nextEdit?.selectedWeChatAccount) && !_.isEqual(editSelectedWeChatAccount, nextEdit?.selectedWeChatAccount) && (queryType === EMBEDDED) && this.props.location.query.module === "loyalty") {
157
+ if (!_.isEmpty(nextTemplates?.selectedWeChatAccount) && !_.isEqual(editSelectedWeChatAccount, nextEdit?.selectedWeChatAccount) && (queryType === EMBEDDED) && this.props.location.query.module === "loyalty") {
158
158
  const params = {
159
159
  name: '',
160
160
  sortBy: 'Most Recent',
161
- accountId: nextEdit?.selectedWeChatAccount?.id,
161
+ accountId: nextTemplates?.selectedWeChatAccount?.id,
162
162
  };
163
163
  this.props.actions.getMobilepushTemplatesList('mobilepush', params);
164
164
  }
@@ -169,8 +169,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
169
169
  if (nextProps.location.query.module !== 'loyalty' && templateId && templateId !== 'temp') {
170
170
  this.props.actions.getTemplateDetails(templateId);
171
171
  }
172
- const type = this.props.location.query.type;
173
- if (type === 'embedded' && templateId === 'temp' && _.isEmpty(this.state.formData)) { // when his.props.params.id is temp that means mobile push template content will be passed from post message from parent with startTemplateCreation action
172
+ if (queryType === EMBEDDED && templateId === 'temp' && _.isEmpty(this.state.formData)) { // when his.props.params.id is temp that means mobile push template content will be passed from post message from parent with startTemplateCreation action
174
173
  const response = {
175
174
  action: 'startTemplateCreation',
176
175
  };
@@ -178,12 +177,12 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
178
177
  this.getTags();
179
178
  }
180
179
  });
181
- if (this.props.location.query.type === 'embedded') {
180
+ if (queryType === EMBEDDED) {
182
181
  this.showNext();
183
182
  }
184
183
  }
185
184
  if (nextProps.metaEntities && nextProps.metaEntities.layouts && nextProps.metaEntities.layouts.length > 0 && nextProps.Edit.mobilepushTemplates && !_.isEqual(nextProps.Edit.mobilepushTemplates, this.props.Edit.mobilepushTemplates)) { //used inloyalty
186
- if (nextProps.location.query.type === 'embedded' && nextProps.location.query.module === 'loyalty') {
185
+ if (nextProps.location.query.type === EMBEDDED && nextProps.location.query.module === 'loyalty') {
187
186
  this.setTemplateOptions(nextProps.Edit.mobilepushTemplates);
188
187
  }
189
188
  }