@capillarytech/creatives-library 7.17.11 → 7.17.13
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/containers/TagList/constants.js +11 -0
- package/package.json +1 -1
- package/v2Components/CapTagList/index.js +21 -11
- package/v2Containers/Line/Container/Text/index.js +16 -1
- package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +2 -2
- package/v2Containers/TagList/index.js +6 -2
- package/v2Containers/TagList/tests/utils.test.js +17 -0
- package/v2Containers/TagList/utils.js +15 -0
- package/.npmrc copy +0 -2
|
@@ -17,3 +17,14 @@ export const GET_TRANSLATION_MAPPED = {
|
|
|
17
17
|
'en-US': 'en-US',
|
|
18
18
|
'ja-JP': 'ja-JP',
|
|
19
19
|
};
|
|
20
|
+
|
|
21
|
+
export const JAPANESE_HIDE_DATE_ARRAY = [
|
|
22
|
+
"mm/dd/yyyy",
|
|
23
|
+
"dd/mm/yyyy",
|
|
24
|
+
"mm/dd/yy",
|
|
25
|
+
"dd Mon yyyy",
|
|
26
|
+
"Day, Mon dd, yy",
|
|
27
|
+
"dd.mm.yy",
|
|
28
|
+
"dd Mon",
|
|
29
|
+
"dd/m/yyyy",
|
|
30
|
+
];
|
package/package.json
CHANGED
|
@@ -19,7 +19,14 @@ import { CARD_RELATED_TAGS } from '../../containers/App/constants';
|
|
|
19
19
|
import { hasCardBasedScope } from '../../utils/common';
|
|
20
20
|
import moment from 'moment';
|
|
21
21
|
import { FONT_COLOR_05 } from '@capillarytech/cap-ui-library/styled/variables';
|
|
22
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
GET_TRANSLATION_MAPPED,
|
|
24
|
+
JAPANESE_HELP_TEXT,
|
|
25
|
+
TAG_TRANSLATION_DOC,
|
|
26
|
+
} from "../../containers/TagList/constants";
|
|
27
|
+
import { HIDE_ENGAGEMENT_CHANNELS } from '../../v2Containers/App/constants';
|
|
28
|
+
import { hideDateLocale } from '../../v2Containers/TagList/utils';
|
|
29
|
+
|
|
23
30
|
|
|
24
31
|
const {Search} = CapInput;
|
|
25
32
|
const {CapTreeNode} = CapTree;
|
|
@@ -155,7 +162,9 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
155
162
|
};
|
|
156
163
|
|
|
157
164
|
renderTags(tags, searchString = '') {
|
|
158
|
-
const { disableRelatedTags, childTagsToDisable, parentTagstoDisable, showCardsRelatedTags} = this
|
|
165
|
+
const { disableRelatedTags, childTagsToDisable, parentTagstoDisable, showCardsRelatedTags } = this?.props?.disableTagsDetails;
|
|
166
|
+
const { accessibleFeatures = [] } = this?.props?.currentOrgDetails || {};
|
|
167
|
+
const hideDateTagsForJpLocale = accessibleFeatures.includes(HIDE_ENGAGEMENT_CHANNELS);
|
|
159
168
|
const list = [];
|
|
160
169
|
const loyaltyAttrDisableText = <FormattedMessage {...messages.loyaltyAttributeDisable} />;
|
|
161
170
|
let clonedTags = _.cloneDeep(tags);
|
|
@@ -171,7 +180,7 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
171
180
|
if (_.has(val, 'subtags')) {
|
|
172
181
|
const disabled = disableRelatedTags ? parentTagstoDisable.includes(key) : false;
|
|
173
182
|
const temp = this.renderTags(val.subtags, '', disabled);
|
|
174
|
-
|
|
183
|
+
const tagValue = (
|
|
175
184
|
<CapTreeNode
|
|
176
185
|
title={disabled ? <CapTooltip title={loyaltyAttrDisableText}>{val.name}</CapTooltip> : val.name}
|
|
177
186
|
tag={val}
|
|
@@ -180,7 +189,8 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
180
189
|
>
|
|
181
190
|
{temp}
|
|
182
191
|
</CapTreeNode>
|
|
183
|
-
)
|
|
192
|
+
);
|
|
193
|
+
hideDateLocale(hideDateTagsForJpLocale, val, list, tagValue);
|
|
184
194
|
} else if (searchString === '' || !searchString || ((val.name || '').toLowerCase().indexOf(searchString.toLowerCase()) !== -1)) {
|
|
185
195
|
const childDisabled = disableRelatedTags ? childTagsToDisable.includes(key) : false;
|
|
186
196
|
const tempNode = (
|
|
@@ -192,7 +202,7 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
192
202
|
disabled={childDisabled}
|
|
193
203
|
>
|
|
194
204
|
</CapTreeNode>);
|
|
195
|
-
list
|
|
205
|
+
hideDateLocale(hideDateTagsForJpLocale, val, list, tempNode);
|
|
196
206
|
}
|
|
197
207
|
});
|
|
198
208
|
return list;
|
|
@@ -243,7 +253,7 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
243
253
|
expandedKeys={expandedKeys}
|
|
244
254
|
autoExpandParent={autoExpandParent}
|
|
245
255
|
onExpand={this.onExpand}
|
|
246
|
-
|
|
256
|
+
>
|
|
247
257
|
{this.renderTags(tg, searchValue)}
|
|
248
258
|
</CapTree>
|
|
249
259
|
{translationLang === "ja-JP" &&
|
|
@@ -251,7 +261,7 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
251
261
|
<CapIcon
|
|
252
262
|
type="help"
|
|
253
263
|
size="s"
|
|
254
|
-
/>
|
|
264
|
+
/>
|
|
255
265
|
<CapLink>
|
|
256
266
|
<CapButton id="translationtagfooter" type="flat" onClick={this.openTranslationLink} >
|
|
257
267
|
<div className="tag-list-footer-icon">
|
|
@@ -264,8 +274,8 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
264
274
|
</div>
|
|
265
275
|
</CapButton>
|
|
266
276
|
</CapLink>
|
|
267
|
-
|
|
268
|
-
|
|
277
|
+
</div>
|
|
278
|
+
}
|
|
269
279
|
|
|
270
280
|
</CapSpin>
|
|
271
281
|
</div>);
|
|
@@ -275,7 +285,7 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
275
285
|
visible={this.props.visibleTaglist}
|
|
276
286
|
footer={[]}
|
|
277
287
|
{...modalProps}
|
|
278
|
-
|
|
288
|
+
>
|
|
279
289
|
{contentSection}
|
|
280
290
|
</CapModal> :
|
|
281
291
|
<CapPopover
|
|
@@ -320,6 +330,7 @@ CapTagList.propTypes = {
|
|
|
320
330
|
hidePopover: PropTypes.bool,
|
|
321
331
|
modalProps: PropTypes.any,
|
|
322
332
|
disableTagsDetails: PropTypes.object,
|
|
333
|
+
currentOrgDetails: PropTypes.object,
|
|
323
334
|
};
|
|
324
335
|
|
|
325
336
|
CapTagList.defaultValue = {
|
|
@@ -337,4 +348,3 @@ const mapStateToProps = createStructuredSelector({
|
|
|
337
348
|
|
|
338
349
|
|
|
339
350
|
export default connect(mapStateToProps, mapDispatchToProps)(injectIntl(CapTagList));
|
|
340
|
-
|
|
@@ -16,6 +16,8 @@ import style from './style';
|
|
|
16
16
|
import withStyles from '../../../../hoc/withStyles';
|
|
17
17
|
import globalMessages from '../../../Cap/messages';
|
|
18
18
|
import { validateTags } from '../../../../utils/tagValidations';
|
|
19
|
+
import moment from 'moment';
|
|
20
|
+
import { GET_TRANSLATION_MAPPED } from '../../../../containers/TagList/constants';
|
|
19
21
|
|
|
20
22
|
const { TextArea } = CapInput;
|
|
21
23
|
const {CapCustomCardList} = CapCustomCard;
|
|
@@ -54,6 +56,7 @@ export const LineText = ({
|
|
|
54
56
|
const [messageTitle, updateTextMessageTitle] = useState('');
|
|
55
57
|
const [isDrawerRequired, updateDrawerRequirement] = useState(false);
|
|
56
58
|
const [selectedTemplate, updateSelectedTemplate] = useState();
|
|
59
|
+
const [translationLang, updateTranslationLang] = useState('en');
|
|
57
60
|
|
|
58
61
|
useEffect(() => {
|
|
59
62
|
const { messageTitle = '', messageContent = '', type, isInit } = content;
|
|
@@ -71,6 +74,18 @@ export const LineText = ({
|
|
|
71
74
|
}
|
|
72
75
|
}, [content]);
|
|
73
76
|
|
|
77
|
+
//To Find from which locale user is loggedin
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
const user = localStorage.getItem("user");
|
|
80
|
+
let locale = "en";
|
|
81
|
+
if (user) {
|
|
82
|
+
locale = JSON.parse(user).lang || locale;
|
|
83
|
+
}
|
|
84
|
+
locale = GET_TRANSLATION_MAPPED?.[locale];
|
|
85
|
+
moment.locale(locale);
|
|
86
|
+
updateTranslationLang(locale);
|
|
87
|
+
}, []);
|
|
88
|
+
|
|
74
89
|
useEffect(() => {
|
|
75
90
|
if (messageContent && (isFullMode ? messageTitle : true)) {
|
|
76
91
|
updateMessageState({
|
|
@@ -260,7 +275,7 @@ export const LineText = ({
|
|
|
260
275
|
injectedTags={injectedTags || {}}
|
|
261
276
|
// className={val.className ? val.className : ''}
|
|
262
277
|
id={`${id}_tags`}
|
|
263
|
-
userLocale={
|
|
278
|
+
userLocale={translationLang}
|
|
264
279
|
selectedOfferDetails={selectedOfferDetails}
|
|
265
280
|
/>
|
|
266
281
|
</>
|
|
@@ -23077,7 +23077,7 @@ new message content.",
|
|
|
23077
23077
|
onContextChange={[Function]}
|
|
23078
23078
|
onTagSelect={[Function]}
|
|
23079
23079
|
tags={Array []}
|
|
23080
|
-
userLocale="en"
|
|
23080
|
+
userLocale="en-US"
|
|
23081
23081
|
>
|
|
23082
23082
|
<UserIsAuthenticated(Connect(TagList))
|
|
23083
23083
|
authData={
|
|
@@ -23123,7 +23123,7 @@ new message content.",
|
|
|
23123
23123
|
onTagSelect={[Function]}
|
|
23124
23124
|
redirect={[Function]}
|
|
23125
23125
|
tags={Array []}
|
|
23126
|
-
userLocale="en"
|
|
23126
|
+
userLocale="en-US"
|
|
23127
23127
|
/>
|
|
23128
23128
|
</Connect(UserIsAuthenticated(Connect(TagList)))>
|
|
23129
23129
|
<CapDrawer
|
|
@@ -19,6 +19,7 @@ import * as globalActions from '../Cap/actions';
|
|
|
19
19
|
// import styled from styled-components;
|
|
20
20
|
import CapTagList from '../../v2Components/CapTagList';
|
|
21
21
|
import './_tagList.scss';
|
|
22
|
+
import { selectCurrentOrgDetails } from '../Cap/selectors';
|
|
22
23
|
const TreeNode = Tree.TreeNode;
|
|
23
24
|
|
|
24
25
|
export class TagList extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
|
@@ -76,7 +77,7 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
|
|
|
76
77
|
if (!tag['tag-header']) {
|
|
77
78
|
mainTags[tag.value] = {
|
|
78
79
|
name: tag.label[userLocale] ? tag.label[userLocale] : tag.label.en,
|
|
79
|
-
desc: tag.
|
|
80
|
+
desc: tag.label[userLocale] ? tag.label[userLocale] : tag.label.en,
|
|
80
81
|
};
|
|
81
82
|
} else if (tag['tag-header'] && mainTags[tag.value]) {
|
|
82
83
|
mainTags[tag.value].subtags = _.concat(mainTags[tag.value].subtags, tag.subtags);
|
|
@@ -85,7 +86,7 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
|
|
|
85
86
|
mainTags[tag.value] = {
|
|
86
87
|
'tag-header': true,
|
|
87
88
|
"name": tag.label[userLocale] ? tag.label[userLocale] : tag.label.en,
|
|
88
|
-
"desc": tag.
|
|
89
|
+
"desc": tag.label[userLocale] ? tag.label[userLocale] : tag.label.en,
|
|
89
90
|
"subtags": tag.subtags,
|
|
90
91
|
};
|
|
91
92
|
}
|
|
@@ -248,6 +249,7 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
|
|
|
248
249
|
onContextChange={this.getTagsforContext}
|
|
249
250
|
moduleFilterEnabled={this.props.moduleFilterEnabled}
|
|
250
251
|
modalProps={this.props.modalProps}
|
|
252
|
+
currentOrgDetails={this.props.currentOrgDetails}
|
|
251
253
|
/>
|
|
252
254
|
</div>
|
|
253
255
|
);
|
|
@@ -272,10 +274,12 @@ TagList.propTypes = {
|
|
|
272
274
|
visibleTaglist: PropTypes.bool,
|
|
273
275
|
hidePopover: PropTypes.bool,
|
|
274
276
|
modalProps: PropTypes.any,
|
|
277
|
+
currentOrgDetails: PropTypes.object,
|
|
275
278
|
};
|
|
276
279
|
|
|
277
280
|
const mapStateToProps = createStructuredSelector({
|
|
278
281
|
TagList: makeSelectTagList(),
|
|
282
|
+
currentOrgDetails: selectCurrentOrgDetails(),
|
|
279
283
|
});
|
|
280
284
|
|
|
281
285
|
function mapDispatchToProps(dispatch) {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import "@testing-library/jest-dom";
|
|
2
|
+
import { hideDateLocale } from "../utils";
|
|
3
|
+
|
|
4
|
+
describe("Test utils", () => {
|
|
5
|
+
it("it should test when hideDateTagsForJpLocale is available", () => {
|
|
6
|
+
const result = hideDateLocale(true, { name: "店舗名" }, [], { name: "店舗名" });
|
|
7
|
+
expect(result).toEqual([{name: "店舗名"}]);
|
|
8
|
+
});
|
|
9
|
+
it("it should test when hideDateTagsForJpLocale is available", () => {
|
|
10
|
+
const result = hideDateLocale(true, { name: "mm/dd/yyyy" }, [], { name: "mm/dd/yyyy" });
|
|
11
|
+
expect(result).toEqual([]);
|
|
12
|
+
});
|
|
13
|
+
it("it should test when val name is not available", () => {
|
|
14
|
+
const result = hideDateLocale(false, { name: "店舗名" }, [], { name: "店舗名" });
|
|
15
|
+
expect(result).toEqual([{name: "店舗名"}]);
|
|
16
|
+
});
|
|
17
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { JAPANESE_HIDE_DATE_ARRAY } from "../../containers/TagList/constants";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export const hideDateLocale = (hideDateTagsForJpLocale, val, list, value) => {
|
|
5
|
+
|
|
6
|
+
if (hideDateTagsForJpLocale) {
|
|
7
|
+
// hidden date tags from the japanese locale
|
|
8
|
+
if (!JAPANESE_HIDE_DATE_ARRAY?.includes(val.name)) {
|
|
9
|
+
list.push(value);
|
|
10
|
+
}
|
|
11
|
+
} else {
|
|
12
|
+
list.push(value);
|
|
13
|
+
}
|
|
14
|
+
return list;
|
|
15
|
+
};
|
package/.npmrc copy
DELETED