@capillarytech/creatives-library 3.2.4 → 3.3.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/app.js +1 -1
- package/components/FormBuilder/index.js +1 -1
- package/components/Header/index.js +4 -3
- package/components/Header/messages.js +4 -0
- package/config/app.js +2 -0
- package/containers/Assets/Gallery/index.js +1 -1
- package/containers/Cap/index.js +4 -5
- package/containers/Email/index.js +2 -2
- package/containers/Email/messages.js +8 -0
- package/containers/LanguageProvider/index.js +28 -4
- package/containers/Templates/index.js +2 -2
- package/containers/Templates/messages.js +24 -4
- package/containers/WeChat/RichmediaTemplates/Create/messages.js +24 -0
- package/i18n.js +16 -9
- package/index.js +6 -0
- package/package.json +1 -4
- package/reducers.js +1 -1
- package/routes.js +2 -1
- package/services/api.js +11 -2
- package/translations/en.json +120 -63
- package/translations/zh.json +117 -60
- package/utils/smsCharCountV2.js +1 -1
- package/v2Components/CapTagList/index.js +2 -2
- package/v2Components/FormBuilder/index.js +7 -4
- package/v2Components/NavigationBar/index.js +11 -17
- package/v2Components/NavigationBar/messages.js +28 -0
- package/v2Components/NewCallTask/index.js +3 -1
- package/v2Components/TopBar/index.js +3 -0
- package/v2Components/TopBar/messages.js +8 -0
- package/v2Containers/Assets/Gallery/index.js +12 -6
- package/v2Containers/Assets/Gallery/messages.js +4 -0
- package/v2Containers/CallTask/index.js +3 -1
- package/v2Containers/Cap/index.js +3 -2
- package/v2Containers/CreativesContainer/SlideBoxContent.js +14 -1
- package/v2Containers/CreativesContainer/index.js +6 -1
- package/v2Containers/Email/index.js +10 -7
- package/v2Containers/Email/messages.js +16 -0
- package/v2Containers/EmailWrapper/index.js +12 -9
- package/v2Containers/LanguageProvider/actions.js +9 -4
- package/v2Containers/LanguageProvider/constants.js +7 -1
- package/v2Containers/LanguageProvider/index.js +49 -12
- package/v2Containers/LanguageProvider/reducer.js +11 -9
- package/v2Containers/LanguageProvider/selectors.js +1 -1
- package/v2Containers/MobilePush/Create/index.js +2 -1
- package/v2Containers/MobilePush/Create/messages.js +4 -0
- package/v2Containers/MobilePush/Edit/index.js +2 -1
- package/v2Containers/MobilePush/Edit/messages.js +4 -0
- package/v2Containers/Sms/Create/index.js +3 -1
- package/v2Containers/Sms/Create/messages.js +16 -0
- package/v2Containers/Sms/Edit/index.js +3 -1
- package/v2Containers/Sms/Edit/messages.js +16 -0
- package/v2Containers/TagList/index.js +43 -0
- package/v2Containers/Templates/_templates.scss +9 -1
- package/v2Containers/Templates/index.js +66 -53
- package/v2Containers/TemplatesV2/index.js +54 -54
- package/v2Containers/WeChat/MapTemplates/index.js +0 -1
- package/v2Containers/WeChat/MapTemplates/messages.js +1 -1
- package/v2Containers/WeChat/RichmediaTemplates/Create/_createRichmedia.scss +10 -0
- package/v2Containers/WeChat/RichmediaTemplates/Create/actions.js +9 -0
- package/v2Containers/WeChat/RichmediaTemplates/Create/constants.js +3 -0
- package/v2Containers/WeChat/RichmediaTemplates/Create/index.js +146 -4
- package/v2Containers/WeChat/RichmediaTemplates/Create/messages.js +86 -57
- package/v2Containers/WeChat/RichmediaTemplates/Create/reducer.js +24 -1
- package/v2Containers/WeChat/RichmediaTemplates/Create/sagas.js +45 -0
- package/v2Containers/WeChat/RichmediaTemplates/Edit/constants.js +4 -0
- package/v2Containers/WeChat/RichmediaTemplates/Edit/index.js +8 -1
- package/v2Containers/WeChat/Wrapper/_wrapper.scss +9 -1
- package/v2Containers/WeChat/Wrapper/messages.js +5 -5
- package/v2Containers/TemplatesV2/_templatesV2.scss +0 -5
|
@@ -17,7 +17,7 @@ import cloneDeep from 'lodash/cloneDeep';
|
|
|
17
17
|
import forEach from 'lodash/forEach';
|
|
18
18
|
import isEqual from 'lodash/isEqual';
|
|
19
19
|
import get from 'lodash/get';
|
|
20
|
-
import { CapRow, CapColumn, CapButton, CapCard, CapSpin, CapInput, CapHeading, CapDivider, CapIcon, CapLink, CapLabel, CapNotification } from '@capillarytech/cap-ui-library';
|
|
20
|
+
import { CapRow, CapColumn, CapButton, CapCard, CapSpin, CapInput, CapHeading, CapDivider, CapIcon, CapLink, CapLabel, CapNotification, CapSlideBox } from '@capillarytech/cap-ui-library';
|
|
21
21
|
import makeSelectCreate, {makeSelectTemplates, getAssetDetails, getContentAssetDetails} from './selectors';
|
|
22
22
|
import * as actions from './actions';
|
|
23
23
|
import richmediaschema from './richmediaschema';
|
|
@@ -26,6 +26,8 @@ import messages from './messages';
|
|
|
26
26
|
import FormBuilder from '../../../../v2Components/FormBuilder';
|
|
27
27
|
import WechatRichmediaTemplatePreview from '../../../../v2Components/TemplatePreview/WechatRichmediaTemplatePreview';
|
|
28
28
|
import noImage from '../../../../assets/noImage.png';
|
|
29
|
+
import Pagination from '../../../../v2Components/Pagination';
|
|
30
|
+
import { CAP_SPACE_08, CAP_SPACE_12, CAP_SPACE_20, CAP_SPACE_16 } from '@capillarytech/cap-ui-library/styled/variables';
|
|
29
31
|
|
|
30
32
|
export class Create extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
|
31
33
|
constructor(props) {
|
|
@@ -102,6 +104,13 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
102
104
|
type: 'confirm',
|
|
103
105
|
id: 'template-back-confirm-modal',
|
|
104
106
|
},
|
|
107
|
+
showExistingTemplates: false,
|
|
108
|
+
existingTemplatesPageNo: 1,
|
|
109
|
+
existingTemplatesPageLimit: 25,
|
|
110
|
+
sortBy: 'Most Recent',
|
|
111
|
+
searchText: '',
|
|
112
|
+
pagination: true,
|
|
113
|
+
scrollDebounce: true,
|
|
105
114
|
};
|
|
106
115
|
this.onFormDataChange = this.onFormDataChange.bind(this);
|
|
107
116
|
this.cancelHandler = this.cancelHandler.bind(this);
|
|
@@ -836,6 +845,126 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
836
845
|
});
|
|
837
846
|
return true;
|
|
838
847
|
}
|
|
848
|
+
|
|
849
|
+
onChooseExistingTemplate = (template, e) => {
|
|
850
|
+
e.stopPropagation();
|
|
851
|
+
const content = get(template, 'versions.base.mediaList[0]', {});
|
|
852
|
+
let postCommentsValue = 'No one';
|
|
853
|
+
const templateData = cloneDeep(this.state.templateData);
|
|
854
|
+
|
|
855
|
+
if (content.only_fans_can_comment && content.need_open_comment) {
|
|
856
|
+
postCommentsValue = 'Only followers';
|
|
857
|
+
} else if (content.need_open_comment) {
|
|
858
|
+
postCommentsValue = 'Anyone';
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
templateData[this.state.currentContentId] = {
|
|
862
|
+
formData: {
|
|
863
|
+
'title-value': content.title,
|
|
864
|
+
'author-value': content.author,
|
|
865
|
+
'cover-abstract-value': content.digest,
|
|
866
|
+
'content-value': content.content,
|
|
867
|
+
'source-link-value': content.content_source_url,
|
|
868
|
+
'post-comments-value': postCommentsValue,
|
|
869
|
+
'show-cover-pic-value': content.show_cover_pic,
|
|
870
|
+
},
|
|
871
|
+
imageUrl: content.image_url,
|
|
872
|
+
mediaId: content.thumb_media_id,
|
|
873
|
+
};
|
|
874
|
+
this.setState({ templateData });
|
|
875
|
+
this.onCloseExistingTemplatesSlideBox();
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
getExistingTemplates = () => {
|
|
879
|
+
const { searchText, sortBy, existingTemplatesPageNo, existingTemplatesPageLimit } = this.state;
|
|
880
|
+
const { selectedWeChatAccount } = this.props.Templates;
|
|
881
|
+
|
|
882
|
+
this.setState({showExistingTemplates: true});
|
|
883
|
+
const queryParams = {
|
|
884
|
+
name: searchText || '',
|
|
885
|
+
sortBy: sortBy,
|
|
886
|
+
wecrmId: selectedWeChatAccount.configs.wecrm_app_id,
|
|
887
|
+
wecrmToken: selectedWeChatAccount.configs.wecrm_token,
|
|
888
|
+
originalId: selectedWeChatAccount.sourceAccountIdentifier,
|
|
889
|
+
page: existingTemplatesPageNo,
|
|
890
|
+
perPage: existingTemplatesPageLimit,
|
|
891
|
+
};
|
|
892
|
+
this.props.actions.getAllTemplates('wechat', queryParams);
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
searchTemplate = (data) => {
|
|
896
|
+
this.setState({searchText: data}, () => {
|
|
897
|
+
this.getExistingTemplates();
|
|
898
|
+
});
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
onPaginationChange = () => {
|
|
902
|
+
if (this.props.Create.pagination && this.state.scrollDebounce) {
|
|
903
|
+
this.setState((prevState) => ({
|
|
904
|
+
existingTemplatesPageNo: prevState.existingTemplatesPageNo + 1,
|
|
905
|
+
scrollDebounce: false,
|
|
906
|
+
}),
|
|
907
|
+
() => {
|
|
908
|
+
this.getExistingTemplates();
|
|
909
|
+
setTimeout(() => {
|
|
910
|
+
this.setState({ scrollDebounce: true })
|
|
911
|
+
}, 500);
|
|
912
|
+
});
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
existingTemplatesContent = () => {
|
|
917
|
+
const { getAllTemplatesInProgress, templates = [] } = this.props.Create;
|
|
918
|
+
return (
|
|
919
|
+
<CapSpin style={{textAlign: "center"}} spinning={getAllTemplatesInProgress}>
|
|
920
|
+
<CapInput.Search
|
|
921
|
+
className="search-text"
|
|
922
|
+
style={{ width: '100%', marginBottom: CAP_SPACE_16 }}
|
|
923
|
+
placeholder={this.props.intl.formatMessage(messages.searchText)}
|
|
924
|
+
value={this.state.searchText}
|
|
925
|
+
onChange={(e) => this.searchTemplate(e.target.value)}
|
|
926
|
+
onClear={() => this.searchTemplate('')}
|
|
927
|
+
/>
|
|
928
|
+
<Pagination style={{ height: 'calc(100vh - 150px)', overflowY: 'auto' }} onPageChange={templates.length && this.onPaginationChange}>
|
|
929
|
+
{ templates.map((template) => (
|
|
930
|
+
<CapCard
|
|
931
|
+
key={template._id}
|
|
932
|
+
bordered={false}
|
|
933
|
+
bodyStyle={{
|
|
934
|
+
padding: 0,
|
|
935
|
+
borderRadius: '4px',
|
|
936
|
+
width: '276px',
|
|
937
|
+
border: '16px solid #f4f5f7',
|
|
938
|
+
}}
|
|
939
|
+
onClick={(e) => this.onChooseExistingTemplate(template, e)}
|
|
940
|
+
style={{ paddingBottom: CAP_SPACE_12 }}
|
|
941
|
+
>
|
|
942
|
+
<div>
|
|
943
|
+
<div className="custom-image">
|
|
944
|
+
<img alt="" width="244px" height="136px" src={template.versions.base.mediaList[0].image_url} />
|
|
945
|
+
</div>
|
|
946
|
+
<div className="existing-template-title-card">
|
|
947
|
+
<CapHeading type="h5" className="overflow-wrap-fields">{template.name || "Title"}</CapHeading>
|
|
948
|
+
</div>
|
|
949
|
+
</div>
|
|
950
|
+
</CapCard>
|
|
951
|
+
))
|
|
952
|
+
}
|
|
953
|
+
</Pagination>
|
|
954
|
+
</CapSpin>
|
|
955
|
+
);
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
onCloseExistingTemplatesSlideBox = () => {
|
|
959
|
+
this.setState({
|
|
960
|
+
showExistingTemplates: false,
|
|
961
|
+
existingTemplatesPageNo: 1,
|
|
962
|
+
existingTemplatesPageLimit: 25,
|
|
963
|
+
searchText: '',
|
|
964
|
+
pagination: true,
|
|
965
|
+
});
|
|
966
|
+
}
|
|
967
|
+
|
|
839
968
|
updateContentData = () => {
|
|
840
969
|
this.state.editorInstanse.insertHtml(`<img src='${this.props.ContentImageData.metaInfo.wechatUrl}' alt='Capillary Image'>`);
|
|
841
970
|
this.props.actions.clearContentImageStore();
|
|
@@ -845,8 +974,9 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
845
974
|
const addRichMediaMenu = (
|
|
846
975
|
<>
|
|
847
976
|
<div style={{width: '292px'}}><CapDivider /></div>
|
|
848
|
-
<CapHeading type="h5" style={{marginBottom: '8px'}}>
|
|
849
|
-
<CapButton type="dashed" onClick={this.
|
|
977
|
+
<CapHeading type="h5" style={{marginBottom: '8px'}}>{this.props.intl.formatMessage(messages.addRichMediaContent)}</CapHeading>
|
|
978
|
+
<CapButton type="dashed" onClick={this.getExistingTemplates} prefix={<CapIcon size="s" type="media" />} style={{backgroundColor: 'white', width: '142px', marginRight: CAP_SPACE_08, paddingLeft: CAP_SPACE_12}}>{this.props.intl.formatMessage(messages.existingMedia)}</CapButton>
|
|
979
|
+
<CapButton type="dashed" onClick={this.menuOnClickEvent} prefix={<CapIcon size="s" type="add-media" />} style={{backgroundColor: 'white'}}>{this.props.intl.formatMessage(messages.newMedia)}</CapButton>
|
|
850
980
|
</>
|
|
851
981
|
);
|
|
852
982
|
return addRichMediaMenu;
|
|
@@ -902,6 +1032,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
902
1032
|
const schema = this.returnCurrentSchema();
|
|
903
1033
|
const formData = this.returnCurrentFormData();
|
|
904
1034
|
const { isIframe } = this.state;
|
|
1035
|
+
const { intl } = this.props;
|
|
905
1036
|
this.updateImageData();
|
|
906
1037
|
if (this.props.ContentImageData && this.props.ContentImageData.metaInfo && this.props.ContentImageData.metaInfo.wechatUrl) {
|
|
907
1038
|
this.updateContentData();
|
|
@@ -927,7 +1058,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
927
1058
|
</CapColumn>
|
|
928
1059
|
<CapColumn span={15}>
|
|
929
1060
|
{ !isIframe && <CapInput
|
|
930
|
-
label=
|
|
1061
|
+
label={this.props.intl.formatMessage(messages.nameOfTemplate)}
|
|
931
1062
|
value={this.state.templateName}
|
|
932
1063
|
onChange={this.templateNameHandler}
|
|
933
1064
|
size="large"
|
|
@@ -956,6 +1087,17 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
956
1087
|
</CapRow>
|
|
957
1088
|
</div>
|
|
958
1089
|
</div>
|
|
1090
|
+
<CapSlideBox
|
|
1091
|
+
header={(
|
|
1092
|
+
<CapHeading type="h3">
|
|
1093
|
+
{intl.formatMessage(messages.existingMediaHeader)}
|
|
1094
|
+
</CapHeading>
|
|
1095
|
+
)}
|
|
1096
|
+
content={this.existingTemplatesContent()}
|
|
1097
|
+
show={this.state.showExistingTemplates}
|
|
1098
|
+
handleClose={this.onCloseExistingTemplatesSlideBox}
|
|
1099
|
+
size="size-s"
|
|
1100
|
+
/>
|
|
959
1101
|
</CapSpin>
|
|
960
1102
|
</div>
|
|
961
1103
|
);
|
|
@@ -5,233 +5,262 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { defineMessages } from 'react-intl';
|
|
7
7
|
|
|
8
|
+
const scope = 'creatives.containersV2.richMedia.Create';
|
|
8
9
|
export default defineMessages({
|
|
9
10
|
"header": {
|
|
10
|
-
id:
|
|
11
|
+
id: `${scope}.header`,
|
|
11
12
|
defaultMessage: 'This is Create container !',
|
|
12
13
|
},
|
|
13
14
|
"titleCharacterCount": {
|
|
14
|
-
id:
|
|
15
|
+
id: `${scope}.titleCharacterCount`,
|
|
15
16
|
defaultMessage: 'Title exceeds character count limit by',
|
|
16
17
|
},
|
|
17
18
|
"authorCharacterCount": {
|
|
18
|
-
id:
|
|
19
|
+
id: `${scope}.authorCharacterCount`,
|
|
19
20
|
defaultMessage: 'Author exceeds character count limit by',
|
|
20
21
|
},
|
|
21
22
|
"coverAbstractCharacterCount": {
|
|
22
|
-
id:
|
|
23
|
+
id: `${scope}.coverAbstractCharacterCount`,
|
|
23
24
|
defaultMessage: 'Cover abstract exceeds character count limit by',
|
|
24
25
|
},
|
|
25
26
|
"saveSuccess": {
|
|
26
|
-
id:
|
|
27
|
+
id: `${scope}.saveSuccess`,
|
|
27
28
|
defaultMessage: 'Template saved successfully',
|
|
28
29
|
},
|
|
29
30
|
"modalTitle": {
|
|
30
|
-
id:
|
|
31
|
+
id: `${scope}.modalTitle`,
|
|
31
32
|
defaultMessage: 'Alert',
|
|
32
33
|
},
|
|
33
34
|
"modalBody": {
|
|
34
|
-
id:
|
|
35
|
+
id: `${scope}.modalBody`,
|
|
35
36
|
defaultMessage: 'Do you really want to go back? All your temporary changes will be lost!',
|
|
36
37
|
},
|
|
37
38
|
"deleteContent": {
|
|
38
|
-
id:
|
|
39
|
+
id: `${scope}.deleteContent`,
|
|
39
40
|
defaultMessage: 'Do you really want to delete? All your temporary changes will be lost!',
|
|
40
41
|
},
|
|
41
42
|
"emptyTemplateName": {
|
|
42
|
-
id:
|
|
43
|
+
id: `${scope}.emptyTemplateName`,
|
|
43
44
|
defaultMessage: 'Cannot leave template name empty',
|
|
44
45
|
},
|
|
45
46
|
"wrongFormatFile": {
|
|
46
|
-
id:
|
|
47
|
+
id: `${scope}.wrongFormatFile`,
|
|
47
48
|
defaultMessage: 'Wrong file upoaded. Please upload image file',
|
|
48
49
|
},
|
|
49
50
|
"formEmpty": {
|
|
50
|
-
id:
|
|
51
|
+
id: `${scope}.formEmpty`,
|
|
51
52
|
defaultMessage: 'Cannot leave form empty',
|
|
52
53
|
},
|
|
53
54
|
"titleEmpty": {
|
|
54
|
-
id:
|
|
55
|
+
id: `${scope}.titleEmpty`,
|
|
55
56
|
defaultMessage: 'Cannot leave title field empty',
|
|
56
57
|
},
|
|
57
58
|
"noImage": {
|
|
58
|
-
id:
|
|
59
|
+
id: `${scope}.noImage`,
|
|
59
60
|
defaultMessage: 'Please upload an image',
|
|
60
61
|
},
|
|
61
62
|
"sourceLinkEmpty": {
|
|
62
|
-
id:
|
|
63
|
+
id: `${scope}.sourceLinkEmpty`,
|
|
63
64
|
defaultMessage: 'Cannot leave source link field empty',
|
|
64
65
|
},
|
|
65
66
|
"contentEmpty": {
|
|
66
|
-
id:
|
|
67
|
+
id: `${scope}.contentEmpty`,
|
|
67
68
|
defaultMessage: 'Cannot leave content field empty',
|
|
68
69
|
},
|
|
69
70
|
"titleNameRepeated": {
|
|
70
|
-
id:
|
|
71
|
+
id: `${scope}.titleNameRepeated`,
|
|
71
72
|
defaultMessage: 'Title name cannot be repeated',
|
|
72
73
|
},
|
|
73
74
|
"wrongUrl": {
|
|
74
|
-
id:
|
|
75
|
+
id: `${scope}.wrongUrl`,
|
|
75
76
|
defaultMessage: 'Enter correct URL',
|
|
76
77
|
},
|
|
77
78
|
"maxContentCount": {
|
|
78
|
-
id:
|
|
79
|
+
id: `${scope}.maxContentCount`,
|
|
79
80
|
defaultMessage: 'You have reached the maximum template size',
|
|
80
81
|
},
|
|
81
82
|
"addNewRichmedia": {
|
|
82
|
-
id:
|
|
83
|
+
id: `${scope}.addNewRichmedia`,
|
|
83
84
|
defaultMessage: 'Add richmedia content',
|
|
84
85
|
},
|
|
85
86
|
'Title': {
|
|
86
|
-
id:
|
|
87
|
+
id: `${scope}.Title`,
|
|
87
88
|
defaultMessage: 'Title',
|
|
88
89
|
},
|
|
89
90
|
'Please input title': {
|
|
90
|
-
id:
|
|
91
|
+
id: `${scope}.Please_input_title`,
|
|
91
92
|
defaultMessage: 'Please input title',
|
|
92
93
|
},
|
|
93
94
|
'Author': {
|
|
94
|
-
id:
|
|
95
|
+
id: `${scope}.Author`,
|
|
95
96
|
defaultMessage: 'Author',
|
|
96
97
|
},
|
|
97
98
|
'Please input author': {
|
|
98
|
-
id:
|
|
99
|
+
id: `${scope}.Please_input_author`,
|
|
99
100
|
defaultMessage: 'Please input author',
|
|
100
101
|
},
|
|
101
102
|
'Cover image': {
|
|
102
|
-
id:
|
|
103
|
+
id: `${scope}.Cover_image`,
|
|
103
104
|
defaultMessage: 'Cover image',
|
|
104
105
|
},
|
|
105
106
|
'Cover abstract': {
|
|
106
|
-
id:
|
|
107
|
+
id: `${scope}.Cover_abstract`,
|
|
107
108
|
defaultMessage: 'Cover abstract',
|
|
108
109
|
},
|
|
109
110
|
'Please input cover abstract': {
|
|
110
|
-
id:
|
|
111
|
+
id: `${scope}.Please_input_cover_abstract`,
|
|
111
112
|
defaultMessage: 'Please input cover abstract',
|
|
112
113
|
},
|
|
113
114
|
'Content': {
|
|
114
|
-
id:
|
|
115
|
+
id: `${scope}.Content`,
|
|
115
116
|
defaultMessage: 'Content',
|
|
116
117
|
},
|
|
117
118
|
'Please input content': {
|
|
118
|
-
id:
|
|
119
|
+
id: `${scope}.Please_input_content`,
|
|
119
120
|
defaultMessage: 'Please input content',
|
|
120
121
|
},
|
|
121
122
|
'Show cover picture': {
|
|
122
|
-
id:
|
|
123
|
+
id: `${scope}.Show_cover_picture`,
|
|
123
124
|
defaultMessage: 'Show cover picture',
|
|
124
125
|
},
|
|
125
126
|
'Who can post comments on this content': {
|
|
126
|
-
id:
|
|
127
|
+
id: `${scope}.Who_can_post_comments_on_this_content`,
|
|
127
128
|
defaultMessage: 'Who can post comments on this content',
|
|
128
129
|
},
|
|
129
130
|
'No one': {
|
|
130
|
-
id:
|
|
131
|
+
id: `${scope}.No_one`,
|
|
131
132
|
defaultMessage: 'No one',
|
|
132
133
|
},
|
|
133
134
|
'Anyone': {
|
|
134
|
-
id:
|
|
135
|
+
id: `${scope}.Anyone`,
|
|
135
136
|
defaultMessage: 'Anyone',
|
|
136
137
|
},
|
|
137
138
|
'Only followers': {
|
|
138
|
-
id:
|
|
139
|
+
id: `${scope}.Only_followers`,
|
|
139
140
|
defaultMessage: 'Only followers',
|
|
140
141
|
},
|
|
141
142
|
'visibility': {
|
|
142
|
-
id:
|
|
143
|
+
id: `${scope}.visibility`,
|
|
143
144
|
defaultMessage: 'visibility',
|
|
144
145
|
},
|
|
145
146
|
'delete': {
|
|
146
|
-
id:
|
|
147
|
+
id: `${scope}.delete`,
|
|
147
148
|
defaultMessage: 'delete',
|
|
148
149
|
},
|
|
149
150
|
'This field is required!': {
|
|
150
|
-
id:
|
|
151
|
+
id: `${scope}.requiredField`,
|
|
151
152
|
defaultMessage: 'This field is required!',
|
|
152
153
|
},
|
|
153
154
|
"Write a brief headline to draw customer's attention": {
|
|
154
|
-
id:
|
|
155
|
+
id: `${scope}.titleInductiveText`,
|
|
155
156
|
defaultMessage: "Write a brief headline to draw customer's attention",
|
|
156
157
|
},
|
|
157
158
|
"Brand/name that your customer will recognise": {
|
|
158
|
-
id:
|
|
159
|
+
id: `${scope}.authorInductiveText`,
|
|
159
160
|
defaultMessage: "Brand/name that your customer will recognise",
|
|
160
161
|
},
|
|
161
162
|
'Resolution 360 x 200': {
|
|
162
|
-
id:
|
|
163
|
+
id: `${scope}.resolutionText`,
|
|
163
164
|
defaultMessage: 'Resolution 360 x 200',
|
|
164
165
|
},
|
|
165
166
|
'The relevant image that complements title.': {
|
|
166
|
-
id:
|
|
167
|
+
id: `${scope}.coverImageTitle`,
|
|
167
168
|
defaultMessage: 'The relevant image that complements title.',
|
|
168
169
|
},
|
|
169
170
|
'Upload Image': {
|
|
170
|
-
id:
|
|
171
|
+
id: `${scope}.uploadImage`,
|
|
171
172
|
defaultMessage: 'Upload Image',
|
|
172
173
|
},
|
|
173
174
|
'A short description help customers learn more': {
|
|
174
|
-
id:
|
|
175
|
+
id: `${scope}.coverAbstractInductive`,
|
|
175
176
|
defaultMessage: 'A short description help customers learn more',
|
|
176
177
|
},
|
|
177
178
|
'Article content': {
|
|
178
|
-
id:
|
|
179
|
+
id: `${scope}.articleContent`,
|
|
179
180
|
defaultMessage: 'Article content',
|
|
180
181
|
},
|
|
181
182
|
'Insert Image': {
|
|
182
|
-
id:
|
|
183
|
+
id: `${scope}.insertImage`,
|
|
183
184
|
defaultMessage: 'Insert Image',
|
|
184
185
|
},
|
|
185
186
|
'Read more link': {
|
|
186
|
-
id:
|
|
187
|
+
id: `${scope}.readMoreLink`,
|
|
187
188
|
defaultMessage: 'Read more link',
|
|
188
189
|
},
|
|
189
190
|
'Link to help customers discover more about the brand.': {
|
|
190
|
-
id:
|
|
191
|
+
id: `${scope}.linkInductiveText`,
|
|
191
192
|
defaultMessage: 'Link to help customers discover more about the brand.',
|
|
192
193
|
},
|
|
193
194
|
'somethingWentWrong': {
|
|
194
|
-
id:
|
|
195
|
+
id: `${scope}.somethingWentWrong`,
|
|
195
196
|
defaultMessage: 'Something went wrong!!',
|
|
196
197
|
},
|
|
197
198
|
'Template with the same name exists. Please try another template name.': {
|
|
198
|
-
id:
|
|
199
|
+
id: `${scope}.templateNameExists`,
|
|
199
200
|
defaultMessage: 'Template with the same name exists. Please try another template name.',
|
|
200
201
|
},
|
|
202
|
+
'Template name already exists': {
|
|
203
|
+
id: 'creatives.containersV2.richMedia.create.templateNameAlreadyExists',
|
|
204
|
+
defaultMessage: 'Template name already exists',
|
|
205
|
+
},
|
|
201
206
|
'Template name cannot be blank!': {
|
|
202
|
-
id:
|
|
207
|
+
id: `${scope}.templateNameBlank`,
|
|
203
208
|
defaultMessage: 'Template name cannot be blank',
|
|
204
209
|
},
|
|
205
210
|
'Template name contains only whitespaces': {
|
|
206
|
-
id:
|
|
211
|
+
id: `${scope}.templateNameContainsWS`,
|
|
207
212
|
defaultMessage: 'Template name contains only whitespaces',
|
|
208
213
|
},
|
|
209
214
|
'Please provide payload to the wechat template': {
|
|
210
|
-
id:
|
|
215
|
+
id: `${scope}.payloadMissing`,
|
|
211
216
|
defaultMessage: 'Please provide payload to create wechat template',
|
|
212
217
|
},
|
|
213
218
|
'Please provide source account identifier': {
|
|
214
|
-
id:
|
|
219
|
+
id: `${scope}.sourceIdentMissing`,
|
|
215
220
|
defaultMessage: 'Please provide source account identifier',
|
|
216
221
|
},
|
|
217
222
|
'Please provide sufficient parameters to generate richmedia message payload': {
|
|
218
|
-
id:
|
|
223
|
+
id: `${scope}.sufficientPayload`,
|
|
219
224
|
defaultMessage: 'Please provide sufficient parameters to generate richmedia message payload',
|
|
220
225
|
},
|
|
221
226
|
'Please provide sufficient params to create richmedia wechat template': {
|
|
222
|
-
id:
|
|
227
|
+
id: `${scope}.sufficientParam`,
|
|
223
228
|
defaultMessage: 'Please provide sufficient params to create richmedia wechat template',
|
|
224
229
|
},
|
|
225
230
|
'Upload has failed': {
|
|
226
|
-
id:
|
|
231
|
+
id: `${scope}.uploadFailed`,
|
|
227
232
|
defaultMessage: 'Upload has failed',
|
|
228
233
|
},
|
|
229
234
|
'Template with the same name exists': {
|
|
230
|
-
id:
|
|
235
|
+
id: `${scope}.sameTemplateExists`,
|
|
231
236
|
defaultMessage: 'Template with the same name exists',
|
|
232
237
|
},
|
|
233
238
|
'Failed to get File content': {
|
|
234
|
-
id:
|
|
239
|
+
id: `${scope}.fileContentFailed`,
|
|
235
240
|
defaultMessage: 'Failed to get File content',
|
|
236
241
|
},
|
|
242
|
+
'addRichMediaContent': {
|
|
243
|
+
id: `${scope}.addRichMediaContent`,
|
|
244
|
+
defaultMessage: 'Add rich media content',
|
|
245
|
+
},
|
|
246
|
+
'newMedia': {
|
|
247
|
+
id: `${scope}.newMedia`,
|
|
248
|
+
defaultMessage: 'New media',
|
|
249
|
+
},
|
|
250
|
+
'nameOfTemplate': {
|
|
251
|
+
id: `${scope}.nameOfTemplate`,
|
|
252
|
+
defaultMessage: 'Name of the template',
|
|
253
|
+
},
|
|
254
|
+
'existingMedia': {
|
|
255
|
+
id: `${scope}.existingMedia`,
|
|
256
|
+
defaultMessage: 'Existing media',
|
|
257
|
+
},
|
|
258
|
+
'existingMediaHeader': {
|
|
259
|
+
id: `${scope}.existingMediaHeader`,
|
|
260
|
+
defaultMessage: 'Rich media templates',
|
|
261
|
+
},
|
|
262
|
+
'searchText': {
|
|
263
|
+
id: `${scope}.searchText`,
|
|
264
|
+
defaultMessage: 'Search Templates',
|
|
265
|
+
},
|
|
237
266
|
});
|
|
@@ -5,9 +5,13 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { fromJS } from 'immutable';
|
|
8
|
+
import unionBy from 'lodash/unionBy';
|
|
8
9
|
import * as types from './constants';
|
|
9
10
|
|
|
10
|
-
const initialState = fromJS({
|
|
11
|
+
const initialState = fromJS({
|
|
12
|
+
getAllTemplatesInProgress: false,
|
|
13
|
+
templates: [],
|
|
14
|
+
});
|
|
11
15
|
|
|
12
16
|
function createReducer(state = initialState, action) {
|
|
13
17
|
switch (action.type) {
|
|
@@ -52,6 +56,25 @@ function createReducer(state = initialState, action) {
|
|
|
52
56
|
return state
|
|
53
57
|
.set('saveTemplateSuccess', false)
|
|
54
58
|
.set('savingTemplate', false);
|
|
59
|
+
case types.GET_ALL_TEMPLATES_REQUEST:
|
|
60
|
+
return state
|
|
61
|
+
.set('getAllTemplatesInProgress', true).set('templateError', {});
|
|
62
|
+
case types.GET_ALL_TEMPLATES_SUCCESS:
|
|
63
|
+
const { data, isReset } = action;
|
|
64
|
+
if (isReset) {
|
|
65
|
+
return state
|
|
66
|
+
.set('getAllTemplatesInProgress', false)
|
|
67
|
+
.set('pagination', true)
|
|
68
|
+
.set('templates', data ? data.templates : [])
|
|
69
|
+
.set('isSearch', data ? data.search : false);
|
|
70
|
+
}
|
|
71
|
+
return state
|
|
72
|
+
.set('getAllTemplatesInProgress', false)
|
|
73
|
+
.set('pagination', data ? Boolean(data.templates.length) : true)
|
|
74
|
+
.set('templates', data ? unionBy(state.get('templates'), data.templates, '_id') : state.get('templates'))
|
|
75
|
+
.set('isSearch', data ? data.search : false);
|
|
76
|
+
case types.GET_ALL_TEMPLATES_FAILURE:
|
|
77
|
+
return state.set('getAllTemplatesInProgress', false).set('templateError', action.error);
|
|
55
78
|
default:
|
|
56
79
|
return state;
|
|
57
80
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { take, cancel, call, put, takeLatest } from 'redux-saga/effects';
|
|
2
2
|
import { LOCATION_CHANGE } from 'react-router-redux';
|
|
3
|
+
import orderBy from 'lodash/orderBy';
|
|
4
|
+
import moment from 'moment';
|
|
3
5
|
import * as Api from '../../../../services/api';
|
|
4
6
|
import * as types from './constants';
|
|
5
7
|
// import testschema from './testschema';
|
|
@@ -33,6 +35,48 @@ export function* saveTemplate({template, callback}) {
|
|
|
33
35
|
yield put({ type: types.SAVE_TEMPLATE_FAILURE, error });
|
|
34
36
|
}
|
|
35
37
|
}
|
|
38
|
+
|
|
39
|
+
export function* getAllTemplates(action) {
|
|
40
|
+
try {
|
|
41
|
+
const result = yield call(Api.getAllTemplates, action);
|
|
42
|
+
const channelTemplates = {
|
|
43
|
+
templates: result.response.richmedia,
|
|
44
|
+
};
|
|
45
|
+
if (
|
|
46
|
+
action.channel === 'wechat' &&
|
|
47
|
+
action.queryParams &&
|
|
48
|
+
action.queryParams.sortBy
|
|
49
|
+
) {
|
|
50
|
+
if (action.queryParams.sortBy.toLocaleLowerCase() === ("Most Recent").toLocaleLowerCase()) {
|
|
51
|
+
channelTemplates.templates = orderBy(channelTemplates.templates, (template) => moment(template.updatedAt), ['desc']);
|
|
52
|
+
// channelTemplates.templates.sort((a, b) => {
|
|
53
|
+
// const dateA = new Date(a.updatedAt);
|
|
54
|
+
// const dateB = new Date(b.updatedAt);
|
|
55
|
+
// return dateB - dateA;
|
|
56
|
+
// });
|
|
57
|
+
} else if (action.queryParams.sortBy.toLocaleLowerCase() === ("Alphabetically").toLocaleLowerCase()) {
|
|
58
|
+
channelTemplates.templates.sort((a, b) => b.name - a.name);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
yield put({
|
|
62
|
+
type: types.GET_ALL_TEMPLATES_SUCCESS,
|
|
63
|
+
data: channelTemplates,
|
|
64
|
+
isReset: action.queryParams.page === 1,
|
|
65
|
+
});
|
|
66
|
+
} catch (error) {
|
|
67
|
+
yield put({
|
|
68
|
+
type: types.GET_ALL_TEMPLATES_FAILURE,
|
|
69
|
+
error,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function* watchGetAllTemplates() {
|
|
75
|
+
const watcher = yield takeLatest(types.GET_ALL_TEMPLATES_REQUEST, getAllTemplates);
|
|
76
|
+
yield take(LOCATION_CHANGE);
|
|
77
|
+
yield cancel(watcher);
|
|
78
|
+
}
|
|
79
|
+
|
|
36
80
|
function* watchUploadAsset() {
|
|
37
81
|
const watcher = yield takeLatest(types.UPLOAD_ASSET_REQUEST, uploadAsset);
|
|
38
82
|
yield take(LOCATION_CHANGE);
|
|
@@ -48,4 +92,5 @@ export default [
|
|
|
48
92
|
defaultSaga,
|
|
49
93
|
watchUploadAsset,
|
|
50
94
|
watchSaveTemplate,
|
|
95
|
+
watchGetAllTemplates,
|
|
51
96
|
];
|
|
@@ -8,3 +8,7 @@ export const DEFAULT_ACTION = 'app/Edit/DEFAULT_ACTION';
|
|
|
8
8
|
export const GET_TEMPLATE_DETAILS_REQUEST = 'app/v2Containers/WeChat/RichmediaTemplates/Edit/GET_TEMPLATE_DETAILS_REQUEST';
|
|
9
9
|
export const GET_TEMPLATE_DETAILS_SUCCESS = 'app/v2Containers/WeChat/RichmediaTemplates/Edit/GET_TEMPLATE_DETAILS_SUCCESS';
|
|
10
10
|
export const GET_TEMPLATE_DETAILS_FAILURE = 'app/v2Containers/WeChat/RichmediaTemplates/Edit/GET_TEMPLATE_DETAILS_FAILURE';
|
|
11
|
+
|
|
12
|
+
export const NO_ONE = 'No one';
|
|
13
|
+
export const ONLY_FOLLOWERS = 'Only followers';
|
|
14
|
+
export const ANYONE = 'Anyone';
|
|
@@ -15,6 +15,7 @@ import { CapSpin } from '@capillarytech/cap-ui-library';
|
|
|
15
15
|
import { createStructuredSelector } from 'reselect';
|
|
16
16
|
import makeSelectEdit, { makeSelectTemplates } from './selectors';
|
|
17
17
|
import * as actions from './actions';
|
|
18
|
+
import { NO_ONE, ONLY_FOLLOWERS, ANYONE } from './constants';
|
|
18
19
|
import Create from '../Create';
|
|
19
20
|
import { getCommonProps } from '../../helper';
|
|
20
21
|
|
|
@@ -39,12 +40,18 @@ export class Edit extends React.PureComponent { // eslint-disable-line react/pre
|
|
|
39
40
|
if (!_.isEmpty(templateDetails)) {
|
|
40
41
|
_.forEach(templateDetails.versions.base.mediaList, (content) => {
|
|
41
42
|
const formData = {};
|
|
43
|
+
let postCommentsValue = NO_ONE;
|
|
44
|
+
if (content.only_fans_can_comment && content.need_open_comment) {
|
|
45
|
+
postCommentsValue = ONLY_FOLLOWERS;
|
|
46
|
+
} else if (content.need_open_comment) {
|
|
47
|
+
postCommentsValue = ANYONE;
|
|
48
|
+
}
|
|
42
49
|
formData['title-value'] = content.title;
|
|
43
50
|
formData['author-value'] = content.author;
|
|
44
51
|
formData['cover-abstract-value'] = content.digest;
|
|
45
52
|
formData['content-value'] = content.content;
|
|
46
53
|
formData['source-link-value'] = content.content_source_url;
|
|
47
|
-
formData['post-comments-value'] =
|
|
54
|
+
formData['post-comments-value'] = postCommentsValue;
|
|
48
55
|
formData['show-cover-pic-value'] = content.show_cover_pic;
|
|
49
56
|
templateData[contentId] = {
|
|
50
57
|
formData,
|