@capillarytech/creatives-library 0.1.16 → 0.1.17
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/Templates/index.js +27 -8
- package/containers/WeChat/index.js +16 -2
- package/index.js +1 -1
- package/package.json +1 -1
|
@@ -117,7 +117,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
componentDidMount() {
|
|
120
|
-
if (this.props.location.query.type === 'embedded' && this.
|
|
120
|
+
if (this.props.location.query.type === 'embedded' && this.isEnabledInLibraryModule("setLocale")) {
|
|
121
121
|
this.setLocale();
|
|
122
122
|
}
|
|
123
123
|
if (this.state.channel.toLowerCase() === 'sms' || this.state.channel.toLowerCase() === 'email' || this.state.channel.toLowerCase() === 'ebill' || ((this.state.channel.toLowerCase() === 'wechat' || this.state.channel.toLowerCase() === 'mobilepush') && !_.isEmpty(this.props.Templates.selectedWeChatAccount))) {
|
|
@@ -194,7 +194,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
194
194
|
if (this.state.channel.toLowerCase() === "mobilepush" && nextProps.Templates.selectedWeChatAccount) {
|
|
195
195
|
params.accountId = nextProps.Templates.selectedWeChatAccount.id;
|
|
196
196
|
}
|
|
197
|
-
if ((this.state.channel.toLowerCase() === 'wechat' || this.state.channel.toLowerCase() === 'mobilepush') && _.isEmpty(nextProps.Templates.selectedWeChatAccount) && (this.props.location.query.type === 'embedded')) {
|
|
197
|
+
if ((this.state.channel.toLowerCase() === 'wechat' || this.state.channel.toLowerCase() === 'mobilepush') && _.isEmpty(nextProps.Templates.selectedWeChatAccount) && (this.props.location.query.type === 'embedded') && !this.isEnabledInLibraryModule("showAccountSelection")) {
|
|
198
198
|
let selectedAccount = '';
|
|
199
199
|
if (_.isEmpty(nextProps.Templates.weCrmAccounts)) {
|
|
200
200
|
return;
|
|
@@ -283,7 +283,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
283
283
|
const isLanguageSupport = (this.props.location.query.isLanguageSupport) ? this.props.location.query.isLanguageSupport : true;
|
|
284
284
|
const isEdmSupport = (this.props.location.query.isEdmSupport !== "false") || false;
|
|
285
285
|
const type = this.props.location.query.type;
|
|
286
|
-
if (
|
|
286
|
+
if (this.isEnabledInLibraryModule("callCreateFromProps")) {
|
|
287
287
|
this.props.createNew();
|
|
288
288
|
return;
|
|
289
289
|
}
|
|
@@ -508,7 +508,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
508
508
|
this.props.actions.handleHtmlUpload(text);
|
|
509
509
|
document.getElementById("filename").value = "";
|
|
510
510
|
const type = this.props.location.query.type;
|
|
511
|
-
if (
|
|
511
|
+
if (this.isEnabledInLibraryModule("callCreateFromProps")) {
|
|
512
512
|
this.props.createNew();
|
|
513
513
|
return;
|
|
514
514
|
}
|
|
@@ -693,7 +693,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
693
693
|
createTemplate(ev) {
|
|
694
694
|
const type = this.props.location.query.type;
|
|
695
695
|
const module = this.props.location.query.module ? this.props.location.query.module : 'default';
|
|
696
|
-
if (this.
|
|
696
|
+
if (this.isEnabledInLibraryModule("callCreateFromProps")) {
|
|
697
697
|
this.props.createNew();
|
|
698
698
|
} else if (ev.key && (ev.key.toLowerCase() === "text" || ev.key.toLowerCase() === "image")) {
|
|
699
699
|
this.props.router.push({
|
|
@@ -827,7 +827,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
827
827
|
} else {
|
|
828
828
|
getQuery = (type === 'embedded') ? {type: 'embedded', module} : {module};
|
|
829
829
|
}
|
|
830
|
-
if (
|
|
830
|
+
if (this.isEnabledInLibraryModule("callCreateFromProps")) {
|
|
831
831
|
this.props.createNew();
|
|
832
832
|
return;
|
|
833
833
|
}
|
|
@@ -864,7 +864,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
864
864
|
if (this.state.channel.toLowerCase() === 'ebill') {
|
|
865
865
|
pathName = `/ebill/edit/${id}`;
|
|
866
866
|
}
|
|
867
|
-
if (
|
|
867
|
+
if (this.isEnabledInLibraryModule("callSelectFromProps")) {
|
|
868
868
|
this.props.onSelectTemplate(id);
|
|
869
869
|
} else {
|
|
870
870
|
if (this.state.channel.toLowerCase() === 'ebill') {
|
|
@@ -1131,6 +1131,25 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1131
1131
|
</Modal>);
|
|
1132
1132
|
return modal;
|
|
1133
1133
|
};
|
|
1134
|
+
//Gets called only when creatives gets used as node library
|
|
1135
|
+
isEnabledInLibraryModule = (property) => {
|
|
1136
|
+
if (this.props.location.query.type === "embedded" && this.props.location.query.module === "library") {
|
|
1137
|
+
switch (property) {
|
|
1138
|
+
case "showAccountSelection":
|
|
1139
|
+
return (this.props.route && (this.props.route.name.toLowerCase() === "wechat" || this.props.route.name.toLowerCase() === "mobilepush"));
|
|
1140
|
+
case "setLocale":
|
|
1141
|
+
return true;
|
|
1142
|
+
case "callCreateFromProps":
|
|
1143
|
+
return true;
|
|
1144
|
+
case "callSelectFromProps":
|
|
1145
|
+
return true;
|
|
1146
|
+
default:
|
|
1147
|
+
return false;
|
|
1148
|
+
}
|
|
1149
|
+
} else {
|
|
1150
|
+
return false;
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1134
1153
|
|
|
1135
1154
|
render() {
|
|
1136
1155
|
console.log('templates props', this.props);
|
|
@@ -1232,7 +1251,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1232
1251
|
const pageHeader = (
|
|
1233
1252
|
<div>
|
|
1234
1253
|
{(this.props.location.query.type !== 'embedded') ? `${pageHeaderText}` : templateText}
|
|
1235
|
-
{((this.state.channel.toUpperCase() === 'WECHAT' || this.state.channel.toUpperCase() === "MOBILEPUSH") && (this.props.location.query.type !== 'embedded') && !_.isEmpty(this.props.Templates.weCrmAccounts)) &&
|
|
1254
|
+
{(this.isEnabledInLibraryModule("showAccountSelection") || (((this.state.channel.toUpperCase() === 'WECHAT' || this.state.channel.toUpperCase() === "MOBILEPUSH") && (this.props.location.query.type !== 'embedded') && !_.isEmpty(this.props.Templates.weCrmAccounts)))) &&
|
|
1236
1255
|
<Select className="selectAccount" onSelect={this.onAccountSelect} value={this.props.Templates.selectedWeChatAccount ? this.props.Templates.selectedWeChatAccount.name : undefined} placeholder={this.props.intl.formatMessage(messages.selectAccount)}>
|
|
1237
1256
|
{accountOptions}
|
|
1238
1257
|
</Select>}
|
|
@@ -433,6 +433,9 @@ export class WeChat extends React.Component { // eslint-disable-line react/prefe
|
|
|
433
433
|
}
|
|
434
434
|
|
|
435
435
|
componentWillReceiveProps(nextProps) {
|
|
436
|
+
if (nextProps.location.query.module === 'library' && nextProps.isGetFormData) {
|
|
437
|
+
this.getFormData();
|
|
438
|
+
}
|
|
436
439
|
console.log('MetaEntity nextprops ', nextProps.metaEntities);
|
|
437
440
|
if (nextProps.metaEntities && nextProps.metaEntities.layouts && nextProps.metaEntities.layouts.length > 0 && _.isEmpty(this.state.schema)) {
|
|
438
441
|
this.injectEvents(nextProps.metaEntities.layouts[0].definition);
|
|
@@ -465,6 +468,11 @@ export class WeChat extends React.Component { // eslint-disable-line react/prefe
|
|
|
465
468
|
}
|
|
466
469
|
});
|
|
467
470
|
}
|
|
471
|
+
if (nextProps.location.query.type === "embedded" && nextProps.location.query.module === "library" && nextProps.templateData) {
|
|
472
|
+
this.setState({editTemplateData: nextProps.templateData}, () => {
|
|
473
|
+
this.setEditData();
|
|
474
|
+
});
|
|
475
|
+
}
|
|
468
476
|
if (nextProps.params.id && !_.isEqual(nextProps.params.id, this.props.params.id)) {
|
|
469
477
|
this.setState({isEdit: true});
|
|
470
478
|
}
|
|
@@ -616,7 +624,7 @@ export class WeChat extends React.Component { // eslint-disable-line react/prefe
|
|
|
616
624
|
}
|
|
617
625
|
});
|
|
618
626
|
}
|
|
619
|
-
} else if (this.state.isEdit) {
|
|
627
|
+
} else if (this.state.isEdit && this.state.editTemplateData.versions) {
|
|
620
628
|
console.log('this.state.editTemplateData', this.state.editTemplateData);
|
|
621
629
|
selectedTemplateData = _.cloneDeep(this.state.editTemplateData);
|
|
622
630
|
selectedTemplate = {
|
|
@@ -716,7 +724,11 @@ export class WeChat extends React.Component { // eslint-disable-line react/prefe
|
|
|
716
724
|
};
|
|
717
725
|
console.log('response ', response);
|
|
718
726
|
this.setState({checkValidation: true});
|
|
719
|
-
|
|
727
|
+
if (this.props.location.query.module === 'library') {
|
|
728
|
+
this.props.getLibraryFormData(response);
|
|
729
|
+
} else {
|
|
730
|
+
e.source.postMessage(JSON.stringify(response), e.origin);
|
|
731
|
+
}
|
|
720
732
|
}
|
|
721
733
|
|
|
722
734
|
getCurrentWindow(e) {
|
|
@@ -1579,6 +1591,8 @@ WeChat.propTypes = {
|
|
|
1579
1591
|
params: PropTypes.object,
|
|
1580
1592
|
metaEntities: PropTypes.object,
|
|
1581
1593
|
intl: intlShape.isRequired,
|
|
1594
|
+
isGetFormData: PropTypes.bool,
|
|
1595
|
+
getLibraryFormData: PropTypes.func,
|
|
1582
1596
|
};
|
|
1583
1597
|
|
|
1584
1598
|
const mapStateToProps = createStructuredSelector({
|
package/index.js
CHANGED