@capillarytech/creatives-library 2.0.80 → 2.0.82
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/components/FormBuilder/index.js +6 -5
- package/package.json +1 -1
- package/v2Containers/Email/index.js +9 -9
- package/v2Containers/MobilePush/Create/index.js +68 -11
- package/v2Containers/MobilePush/Create/messages.js +16 -0
- package/v2Containers/MobilePush/Edit/index.js +85 -28
- package/v2Containers/MobilePush/Edit/messages.js +17 -1
- package/v2Containers/MobilePush/commonMethods.js +9 -7
- package/v2Containers/MobilePush/initialSchema.js +2 -0
|
@@ -595,6 +595,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
595
595
|
errorData[parseInt(index)][`message-editor${selector}`] = false;
|
|
596
596
|
} else {
|
|
597
597
|
errorData[parseInt(index)][`message-editor${selector}`] = true;
|
|
598
|
+
errorData[parseInt(index)]['invalid-tags'] = tagValidationResponse.unsupportedTags;
|
|
598
599
|
isValid = false;
|
|
599
600
|
}
|
|
600
601
|
}
|
|
@@ -921,7 +922,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
921
922
|
}
|
|
922
923
|
this.setState({isFormValid : isValid, errorData});
|
|
923
924
|
|
|
924
|
-
this.props.onFormValidityChange(isValid);
|
|
925
|
+
this.props.onFormValidityChange(isValid, errorData);
|
|
925
926
|
return isValid;
|
|
926
927
|
}
|
|
927
928
|
|
|
@@ -1802,7 +1803,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1802
1803
|
}
|
|
1803
1804
|
|
|
1804
1805
|
if (!((event === 'onSelect' && data === 'New Version') || event === 'onContentChange')) {
|
|
1805
|
-
this.props.onChange(formData, this.state.tabCount, currentTab);
|
|
1806
|
+
this.props.onChange(formData, this.state.tabCount, currentTab, val);
|
|
1806
1807
|
}
|
|
1807
1808
|
}
|
|
1808
1809
|
|
|
@@ -1844,7 +1845,6 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1844
1845
|
if (!event) {
|
|
1845
1846
|
return;
|
|
1846
1847
|
}
|
|
1847
|
-
|
|
1848
1848
|
const tab = this.state.tabCount;
|
|
1849
1849
|
// const parent = this._reactInternalInstance._currentElement._owner._instance;
|
|
1850
1850
|
if (event === 'onTabChange') {
|
|
@@ -1854,7 +1854,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1854
1854
|
if (this.props.isNewVersionFlow) {
|
|
1855
1855
|
const formData = _.cloneDeep(this.state.formData);
|
|
1856
1856
|
let activeTabIndex = '1';
|
|
1857
|
-
const elems = document.
|
|
1857
|
+
const elems = document.querySelectorAll(`.cap-tabs-${val.id} .ant-tabs-tab`);
|
|
1858
1858
|
|
|
1859
1859
|
for (let i = 0; i < elems.length; i += 1) {
|
|
1860
1860
|
if (elems.item(i).classList.contains("ant-tabs-tab-active")) {
|
|
@@ -1874,7 +1874,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1874
1874
|
});
|
|
1875
1875
|
} else {
|
|
1876
1876
|
let activeTabIndex = '1';
|
|
1877
|
-
const elems = document.
|
|
1877
|
+
const elems = document.querySelectorAll(`.cap-tabs-${val.id} .ant-tabs-tab`);
|
|
1878
1878
|
|
|
1879
1879
|
for (let i = 0; i < elems.length; i += 1) {
|
|
1880
1880
|
if (elems.item(i).classList.contains("ant-tabs-tab-active")) {
|
|
@@ -3167,6 +3167,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
3167
3167
|
}
|
|
3168
3168
|
return (
|
|
3169
3169
|
<Tabs
|
|
3170
|
+
className={`cap-tabs-${container.id}`}
|
|
3170
3171
|
activeKey={activeTabKey && activeTabKey !== '' ? `${activeTabKey}` : '1'}
|
|
3171
3172
|
defaultActiveKey={activeTabKey && activeTabKey !== '' ? `${activeTabKey}` : '1'}
|
|
3172
3173
|
onChange={(data, e) => { this.callChildEvent(data, container, 'onTabChange', e); }}
|
package/package.json
CHANGED
|
@@ -604,15 +604,13 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
604
604
|
const langIndex = formData[this.state.currentTab - 1].selectedLanguages.indexOf(langId);
|
|
605
605
|
const win = document.getElementById(`edmeditor${(langIndex + 1) > 1 ? (langIndex + 1) : ''}`).contentWindow;
|
|
606
606
|
win.postMessage(msgString, '*');
|
|
607
|
+
} else if (data === "unsubscribe") {
|
|
608
|
+
const anchor = `<a href='{{${data}}}'>${data}</a>`;
|
|
609
|
+
this.state.editorInstanse.insertHtml(`${anchor}`);
|
|
607
610
|
} else {
|
|
608
|
-
|
|
609
|
-
const anchor = `<a href='{{${data}}}'>${data}</a>`;
|
|
610
|
-
this.state.editorInstanse.insertHtml(`${anchor}`);
|
|
611
|
-
} else {
|
|
612
|
-
this.state.editorInstanse.insertHtml(`{{${data}}}`);
|
|
613
|
-
}
|
|
614
|
-
//this.resetCkEditorInstance(currentTab, formData, true, data);
|
|
611
|
+
this.state.editorInstanse.insertHtml(`{{${data}}}`);
|
|
615
612
|
}
|
|
613
|
+
//this.resetCkEditorInstance(currentTab, formData, true, data);
|
|
616
614
|
}
|
|
617
615
|
|
|
618
616
|
onImageSelect = () => {
|
|
@@ -866,7 +864,9 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
866
864
|
|
|
867
865
|
|
|
868
866
|
this.setState({ formData, schema, tabKey, currentTab, tabCount: editData.versions.history.length, loadingStatus: this.state.loadingStatus + 1 }, () => {
|
|
869
|
-
this.props.
|
|
867
|
+
if (this.props.isFullMode) {
|
|
868
|
+
this.props.showTemplateName({formData, onFormDataChange: this.onFormDataChange});
|
|
869
|
+
}
|
|
870
870
|
_.forEach((editData.versions.base.selectedLanguages), (language) => {
|
|
871
871
|
// if (formData[this.state.currentTab - 1].tabKey === formData[this.state.currentTab - 1][language].tabKey) {
|
|
872
872
|
// formData[this.state.currentTab - 1].activeTab = language;
|
|
@@ -1214,7 +1214,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
1214
1214
|
const baseData = {};
|
|
1215
1215
|
const baseLanguage = props.currentOrgDetails.basic_details.base_language;
|
|
1216
1216
|
this.supportedLanguages = this.getSupportedLanguages(props);
|
|
1217
|
-
const languageObject = this.supportedLanguages[_.findIndex(this.supportedLanguages, {iso_code: baseLanguage})];
|
|
1217
|
+
const languageObject = this.supportedLanguages[_.findIndex(this.supportedLanguages, {iso_code: baseLanguage})] || {iso_code: 'en', lang_id: 1, language: "English"};
|
|
1218
1218
|
baseData.activeTab = baseLanguage;
|
|
1219
1219
|
baseData[languageObject.iso_code] = {};
|
|
1220
1220
|
baseData[languageObject.iso_code].is_drag_drop = false;
|
|
@@ -110,7 +110,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
110
110
|
const message = getMessageObject('error', (nextProps.Create.createTemplateErrorMessage && nextProps.Create.createTemplateErrorMessage !== '') ? nextProps.Create.createTemplateErrorMessage : this.props.intl.formatMessage(messages.somethingWentWrong), true);
|
|
111
111
|
this.props.globalActions.addMessageToQueue(message);
|
|
112
112
|
}
|
|
113
|
-
if (nextProps.iosCtasData) {
|
|
113
|
+
if (nextProps.iosCtasData && isEmpty(this.state.templateCta)) {
|
|
114
114
|
this.setState({showIosCtaTable: true});
|
|
115
115
|
}
|
|
116
116
|
if (nextProps.metaEntities && nextProps.metaEntities.layouts && nextProps.metaEntities.layouts.length > 0 && isEmpty(this.state.schema)) {
|
|
@@ -151,15 +151,15 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
151
151
|
|
|
152
152
|
};
|
|
153
153
|
|
|
154
|
-
onFormDataChange = (formData, tabCount) => {
|
|
154
|
+
onFormDataChange = (formData, tabCount, currentTab, inputField) => {
|
|
155
155
|
const newFormData = cloneDeep(formData);
|
|
156
156
|
const {templateCta} = this.state;
|
|
157
157
|
if (!isEmpty(templateCta)) {
|
|
158
|
-
newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-label`] = templateCta
|
|
159
|
-
newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action`] = templateCta
|
|
158
|
+
newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-label`] = get(templateCta, 'name');
|
|
159
|
+
newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action`] = get(templateCta, 'ctaTemplateDetails[0].buttonText');
|
|
160
160
|
delete newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action2`];
|
|
161
|
-
if (templateCta
|
|
162
|
-
newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action2`] = templateCta
|
|
161
|
+
if (get(templateCta, 'ctaTemplateDetails[1]')) {
|
|
162
|
+
newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action2`] = get(templateCta, 'ctaTemplateDetails[1].buttonText');
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
165
|
|
|
@@ -187,6 +187,11 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
187
187
|
if (this.props.isFullMode && this.props.defaultData && isEmpty(formData['template-name'])) {
|
|
188
188
|
newFormData['template-name'] = get(this.props, "defaultData['template-name']");
|
|
189
189
|
}
|
|
190
|
+
if (inputField && inputField.id === "add-sec-cta") {
|
|
191
|
+
if (!newFormData[0]["add-sec-cta"]) {
|
|
192
|
+
newFormData[0]["add-sec-cta-2"] = false;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
190
195
|
this.setState({formData: newFormData, tabCount, isSchemaChanged: !this.state.isSchemaChanged}, () => {
|
|
191
196
|
if (this.props.isFullMode) {
|
|
192
197
|
this.props.showTemplateName({formData: this.state.formData, onFormDataChange: this.onFormDataChange});
|
|
@@ -351,14 +356,46 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
351
356
|
validity: this.state.isFormValid,
|
|
352
357
|
type: templateData.type,
|
|
353
358
|
};
|
|
354
|
-
this.setState({checkValidation: true});
|
|
359
|
+
this.setState({checkValidation: true}, this.showError);
|
|
355
360
|
if (e) {
|
|
356
361
|
e.source.postMessage(JSON.stringify(response), e.origin);
|
|
357
362
|
}
|
|
358
363
|
return response;
|
|
359
364
|
};
|
|
360
|
-
|
|
361
|
-
this.
|
|
365
|
+
showError = () => {
|
|
366
|
+
const {intl} = this.props;
|
|
367
|
+
const {errorData} = this.state;
|
|
368
|
+
const errorMessage = {key: 'validation-error', message: intl.formatMessage(messages.validationError)};
|
|
369
|
+
if (!isEmpty(this.state.formData) && !this.state.isFormValid) {
|
|
370
|
+
let tab = this.state.currentTab;
|
|
371
|
+
const isAndroidInvalid = Object.values(errorData[0]).includes(true);
|
|
372
|
+
const isIosInvalid = Object.values(errorData[1]).includes(true);
|
|
373
|
+
let isTagErrorExist = false;
|
|
374
|
+
if (isAndroidInvalid) {
|
|
375
|
+
tab = 1;
|
|
376
|
+
errorMessage.description = intl.formatMessage(messages.invalidAndroidMessage);
|
|
377
|
+
const invalidTags = errorData[0]['invalid-tags'];
|
|
378
|
+
if (!isEmpty(invalidTags)) {
|
|
379
|
+
isTagErrorExist = true;
|
|
380
|
+
errorMessage.description = `${intl.formatMessage(messages.invalidAndroidMessage)} ${intl.formatMessage(messages.invalidTags)}: ${invalidTags.join(',')} `;
|
|
381
|
+
}
|
|
382
|
+
} else if (isIosInvalid) {
|
|
383
|
+
tab = 2;
|
|
384
|
+
errorMessage.description = intl.formatMessage(messages.invalidIosMessage);
|
|
385
|
+
const invalidTags = errorData[1]['invalid-tags'];
|
|
386
|
+
if (!isEmpty(invalidTags)) {
|
|
387
|
+
isTagErrorExist = true;
|
|
388
|
+
errorMessage.description = `${intl.formatMessage(messages.invalidIosMessage)} ${intl.formatMessage(messages.invalidTags)}: ${invalidTags.join(',')} `;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
if (tab !== this.state.currentTab || isTagErrorExist) {
|
|
392
|
+
CapNotification.error(errorMessage);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
setFormValidity = (isFormValid, errorData) => {
|
|
397
|
+
const newState = {isFormValid, errorData};
|
|
398
|
+
this.setState(newState);
|
|
362
399
|
};
|
|
363
400
|
getTransformedData = (formData) => {
|
|
364
401
|
const obj = {};
|
|
@@ -987,7 +1024,9 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
987
1024
|
|
|
988
1025
|
],
|
|
989
1026
|
});
|
|
990
|
-
|
|
1027
|
+
const selectedConfigTemplateCtaId = get(selectedConfig, 'ctaTemplateDetails[0].id');
|
|
1028
|
+
// the option to select deeplink and externa link should not come for these ctas
|
|
1029
|
+
if (selectedConfigTemplateCtaId && (selectedConfigTemplateCtaId.id !== "3heicig" && selectedConfigTemplateCtaId.id !== "6eigf4f" && selectedConfigTemplateCtaId.id !== "c97d0ed")) {
|
|
991
1030
|
inputFields.splice(fieldIndex + 2, 0, {
|
|
992
1031
|
rowClassName: "mobile-push-row",
|
|
993
1032
|
cols: [
|
|
@@ -1135,6 +1174,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
1135
1174
|
addSecondoryCta = (flag, formData, schemaField) => {
|
|
1136
1175
|
const id = schemaField.id;
|
|
1137
1176
|
const schema = cloneDeep(this.state.schema);
|
|
1177
|
+
const formDataCopy = cloneDeep(formData);
|
|
1138
1178
|
const ck = this.props.Templates.selectedWeChatAccount.configs ? !!this.props.Templates.selectedWeChatAccount.configs.deeplink : false;
|
|
1139
1179
|
const deeplinks = ck ? this.props.Templates.selectedWeChatAccount.configs.deeplink : '[]';
|
|
1140
1180
|
const deepLinkOptions = this.props.Templates.selectedWeChatAccount ? map(JSON.parse(deeplinks), (link) => ({label: link.name, value: link.link, title: link.link }) ) : [];
|
|
@@ -1236,7 +1276,24 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
1236
1276
|
}
|
|
1237
1277
|
});
|
|
1238
1278
|
});
|
|
1239
|
-
|
|
1279
|
+
if (id === "add-sec-cta") {
|
|
1280
|
+
//The following block of code enables and disables add secondary button based on the primary button
|
|
1281
|
+
const indexOfSecondary = findIndex(inputFields, {identifier: 'add-sec-cta-2'});
|
|
1282
|
+
inputFields[indexOfSecondary].cols[0].disabled = !formData[this.state.currentTab - 1][id];
|
|
1283
|
+
//Calling the following function to unset the data set under secondary button
|
|
1284
|
+
if (!formData[this.state.currentTab - 1][id]) {
|
|
1285
|
+
formDataCopy[this.state.currentTab - 1]['add-sec-cta-2'] = false;
|
|
1286
|
+
}
|
|
1287
|
+
//Calling set state here to update the state and schema before manually triggering secondarycta update
|
|
1288
|
+
this.setState(
|
|
1289
|
+
{schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true},
|
|
1290
|
+
() => {
|
|
1291
|
+
this.injectEvents(schema);
|
|
1292
|
+
this.addSecondoryCta(true, formDataCopy, inputFields[indexOfSecondary].cols[0]);
|
|
1293
|
+
});
|
|
1294
|
+
} else {
|
|
1295
|
+
this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true}, () => { this.injectEvents(schema); });
|
|
1296
|
+
}
|
|
1240
1297
|
};
|
|
1241
1298
|
copyIphoneContent = () => {
|
|
1242
1299
|
const formData = cloneDeep(this.state.formData);
|
|
@@ -246,4 +246,20 @@ export default defineMessages({
|
|
|
246
246
|
id: 'app.containers.MobilePush.Create.uploadImageSizeErrorDescription',
|
|
247
247
|
defaultMessage: 'File size cannot be more than 3mb',
|
|
248
248
|
},
|
|
249
|
+
"validationError": {
|
|
250
|
+
id: 'app.containers.MobilePush.Create.validationError',
|
|
251
|
+
defaultMessage: 'Validation error',
|
|
252
|
+
},
|
|
253
|
+
"invalidIosMessage": {
|
|
254
|
+
id: 'app.containers.MobilePush.Create.invalidIosMessage',
|
|
255
|
+
defaultMessage: 'Validation failed for IOS',
|
|
256
|
+
},
|
|
257
|
+
"invalidAndroidMessage": {
|
|
258
|
+
id: 'app.containers.MobilePush.Create.invalidAndroidMessage',
|
|
259
|
+
defaultMessage: 'Validation failed for Android',
|
|
260
|
+
},
|
|
261
|
+
"invalidTags": {
|
|
262
|
+
id: 'app.containers.MobilePush.Create.invalidTags',
|
|
263
|
+
defaultMessage: 'Invalid tags',
|
|
264
|
+
},
|
|
249
265
|
});
|
|
@@ -14,7 +14,7 @@ import { notification } from 'antd';
|
|
|
14
14
|
import { createStructuredSelector } from 'reselect';
|
|
15
15
|
import { injectIntl, intlShape, FormattedMessage } from 'react-intl';
|
|
16
16
|
import _, {get, findIndex, set, forEach, cloneDeep} from 'lodash';
|
|
17
|
-
import { CapSpin, CapSlideBox, CapHeader, CapTable, CapLink, CapRow, CapColumn, CapIcons} from '@capillarytech/cap-ui-library';
|
|
17
|
+
import { CapSpin, CapSlideBox, CapHeader, CapTable, CapLink, CapRow, CapColumn, CapIcons, CapNotification} from '@capillarytech/cap-ui-library';
|
|
18
18
|
import styled from 'styled-components';
|
|
19
19
|
import {makeSelectEdit, makeSelectEditResponse, makeSelectTemplateDetailsResponse, makeSelectIosCta} from "./selectors";
|
|
20
20
|
import {makeSelectMetaEntities, setInjectedTags, isLoadingMetaEntities} from "../../Cap/selectors";
|
|
@@ -168,7 +168,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
168
168
|
this.setState({formData});
|
|
169
169
|
this.props.actions.clearAsset();
|
|
170
170
|
}
|
|
171
|
-
if (nextProps.iosCtasData) {
|
|
171
|
+
if (nextProps.iosCtasData && _.isEmpty(this.state.templateCta)) {
|
|
172
172
|
this.setState({showIosCtaTable: true});
|
|
173
173
|
}
|
|
174
174
|
if (nextProps.Edit.editTemplateError && !_.isEqual(nextProps.Edit.editTemplateError, this.props.Edit.editTemplateError)) {
|
|
@@ -189,16 +189,16 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
189
189
|
}
|
|
190
190
|
});
|
|
191
191
|
};
|
|
192
|
-
onFormDataChange = (formData, tabCount, currentTab) => {
|
|
192
|
+
onFormDataChange = (formData, tabCount, currentTab, inputField) => {
|
|
193
193
|
console.log('Form data changed is ', formData, tabCount, currentTab);
|
|
194
194
|
const newFormData = _.cloneDeep(formData);
|
|
195
195
|
const {templateCta} = this.state;
|
|
196
196
|
if (!_.isEmpty(templateCta) && this.state.currentTab === 2) {
|
|
197
|
-
newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-label`] = templateCta
|
|
198
|
-
newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action`] = templateCta
|
|
197
|
+
newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-label`] = get(templateCta, 'name');
|
|
198
|
+
newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action`] = get(templateCta, 'ctaTemplateDetails[0].buttonText');
|
|
199
199
|
delete newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action2`];
|
|
200
|
-
if (templateCta
|
|
201
|
-
newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action2`] = templateCta
|
|
200
|
+
if (get(templateCta, 'ctaTemplateDetails[1]')) {
|
|
201
|
+
newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action2`] = get(templateCta, 'ctaTemplateDetails[1].buttonText');
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
204
|
if (newFormData["mobilepush-accounts"] !== this.state.formData["mobilepush-accounts"]) {
|
|
@@ -218,6 +218,11 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
218
218
|
if (this.props.isFullMode && this.props.defaultData && _.isEmpty(formData['template-name'])) {
|
|
219
219
|
newFormData['template-name'] = _.get(this.props, "defaultData['template-name']");
|
|
220
220
|
}
|
|
221
|
+
if (inputField && inputField.id === "add-sec-cta") {
|
|
222
|
+
if (!newFormData[0]["add-sec-cta"]) {
|
|
223
|
+
newFormData[0]["add-sec-cta-2"] = false;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
221
226
|
this.setState({formData: newFormData, tabCount}, () => {
|
|
222
227
|
this.props.showTemplateName({formData: this.state.formData, onFormDataChange: this.onFormDataChange});
|
|
223
228
|
});
|
|
@@ -239,7 +244,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
239
244
|
// if (field.id === "cta-deeplink-secondary-cta-1" && (tabIndex > 1 || this.state.currentTab > 1)) {
|
|
240
245
|
// inputId = `${inputId}${tabIndex || this.state.currentTab}`;
|
|
241
246
|
// }
|
|
242
|
-
const newInputFields = this.getLinkTypeFields({inputFieldsArgs: inputFields, fieldIndex, deepLinkOptions, formData, field});
|
|
247
|
+
const newInputFields = this.getLinkTypeFields({inputFieldsArgs: inputFields, fieldIndex, deepLinkOptions, formData, field, tab: currentTab});
|
|
243
248
|
set(schema, `containers[0].panes[${tabIndex - 1}].sections[0].childSections[0].childSections[0].inputFields`, newInputFields);
|
|
244
249
|
|
|
245
250
|
if (currentTab) { // identifying where ist called from setEditData or by event handler
|
|
@@ -512,7 +517,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
512
517
|
actionLabel: ios['secondary-cta-1-action'],
|
|
513
518
|
actionLabel2: ios['secondary-cta-1-action2'],
|
|
514
519
|
type: ios['cta-deeplink-secondary-cta-1'] && (ios['cta-deeplink-secondary-cta-1'].toLowerCase() === "deeplink" ? "DEEP_LINK" : "EXTERNAL_URL"),
|
|
515
|
-
actionLink: ios['cta-deeplink-secondary-cta-1'] && (ios['cta-deeplink-secondary-cta-1'].toLowerCase() === "deeplink" ? ios['cta-deeplink-secondary-cta-1-select2'] : ios['cta-deeplink-secondary-cta-1-
|
|
520
|
+
actionLink: ios['cta-deeplink-secondary-cta-1'] && (ios['cta-deeplink-secondary-cta-1'].toLowerCase() === "deeplink" ? ios['cta-deeplink-secondary-cta-1-select2'] : ios['cta-deeplink-secondary-cta-1-text']),
|
|
516
521
|
ioscdeepLinkName: this.getLinkName(ios['cta-deeplink-secondary-cta-1-select']),
|
|
517
522
|
templateCtaId,
|
|
518
523
|
};
|
|
@@ -546,9 +551,41 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
546
551
|
}
|
|
547
552
|
return undefined;
|
|
548
553
|
};
|
|
554
|
+
showError = () => {
|
|
555
|
+
const {intl} = this.props;
|
|
556
|
+
const {errorData} = this.state;
|
|
557
|
+
const errorMessage = {key: 'validation-error', message: intl.formatMessage(messages.validationError)};
|
|
558
|
+
let isTagErrorExist = false;
|
|
559
|
+
if (!_.isEmpty(this.state.formData) && !this.state.isFormValid) {
|
|
560
|
+
let tab = this.state.currentTab;
|
|
561
|
+
const isAndroidInvalid = Object.values(errorData[0]).includes(true);
|
|
562
|
+
const isIosInvalid = Object.values(errorData[1]).includes(true);
|
|
563
|
+
if (isAndroidInvalid) {
|
|
564
|
+
tab = 1;
|
|
565
|
+
errorMessage.description = intl.formatMessage(messages.invalidAndroidMessage);
|
|
566
|
+
const invalidTags = errorData[0]['invalid-tags'];
|
|
567
|
+
if (!_.isEmpty(invalidTags)) {
|
|
568
|
+
isTagErrorExist = true;
|
|
569
|
+
errorMessage.description = `${intl.formatMessage(messages.invalidAndroidMessage)} ${intl.formatMessage(messages.invalidTags)}: ${invalidTags.join(',')} `;
|
|
570
|
+
}
|
|
571
|
+
} else if (isIosInvalid) {
|
|
572
|
+
tab = 2;
|
|
573
|
+
errorMessage.description = intl.formatMessage(messages.invalidIosMessage);
|
|
574
|
+
const invalidTags = errorData[1]['invalid-tags'];
|
|
575
|
+
if (!_.isEmpty(invalidTags)) {
|
|
576
|
+
isTagErrorExist = true;
|
|
577
|
+
errorMessage.description = `${intl.formatMessage(messages.invalidIosMessage)} ${intl.formatMessage(messages.invalidTags)}: ${invalidTags.join(',')} `;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
549
580
|
|
|
550
|
-
|
|
551
|
-
|
|
581
|
+
if (tab !== this.state.currentTab || isTagErrorExist) {
|
|
582
|
+
CapNotification.error(errorMessage);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
setFormValidity = (isFormValid, errorData) => {
|
|
587
|
+
const newState = {isFormValid, errorData};
|
|
588
|
+
this.setState(newState);
|
|
552
589
|
};
|
|
553
590
|
|
|
554
591
|
getMappedEvent = (id, event) => {
|
|
@@ -577,7 +614,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
577
614
|
validity: this.state.isFormValid,
|
|
578
615
|
};
|
|
579
616
|
console.log('GetForm Data ', response);
|
|
580
|
-
this.setState({checkValidation: true});
|
|
617
|
+
this.setState({checkValidation: true}, this.showError);
|
|
581
618
|
if (e) {
|
|
582
619
|
e.source.postMessage(JSON.stringify(response), e.origin);
|
|
583
620
|
}
|
|
@@ -693,14 +730,14 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
693
730
|
ios.image = iosData.expandableDetails.image;
|
|
694
731
|
}
|
|
695
732
|
if (iosData.expandableDetails && iosData.expandableDetails.ctas && iosData.expandableDetails.ctas.length) {
|
|
696
|
-
|
|
733
|
+
ios['add-sec-cta-ios'] = true;
|
|
697
734
|
if (iosData.expandableDetails.ctas[0].type) {
|
|
698
735
|
ios['cta-deeplink-secondary-cta-1'] = iosData.expandableDetails.ctas[0].type === "DEEP_LINK" ? "Deeplink" : "External Link";
|
|
699
736
|
}
|
|
700
737
|
if (iosData.expandableDetails.ctas[0].type === "DEEP_LINK") {
|
|
701
738
|
ios['cta-deeplink-secondary-cta-1-select2'] = iosData.expandableDetails.ctas[0].actionLink;
|
|
702
739
|
} else {
|
|
703
|
-
ios['cta-deeplink-secondary-cta-1-
|
|
740
|
+
ios['cta-deeplink-secondary-cta-1-text'] = iosData.expandableDetails.ctas[0].actionLink;
|
|
704
741
|
}
|
|
705
742
|
ios['secondary-cta-1-label'] = iosData.expandableDetails.ctas[0].actionText;
|
|
706
743
|
if (iosData.expandableDetails.ctas[0].type === "DEEP_LINK" && ios['cta-deeplink-secondary-cta-1-select2']) {
|
|
@@ -768,7 +805,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
768
805
|
if (formData[1]['secondary-cta-1-action']) {
|
|
769
806
|
formData[1]['add-sec-cta-ios'] = true;
|
|
770
807
|
|
|
771
|
-
schema = this.showSelectedIosCta(schema, {id: 'add-sec-cta-ios'}, 2,
|
|
808
|
+
schema = this.showSelectedIosCta(schema, {id: 'add-sec-cta-ios'}, 2, this.state.templateCta, formData[1]['cta-deeplink-secondary-cta-1']);
|
|
772
809
|
schema = this.onLinkTypeChange(true, formData, {id: 'cta-deeplink-secondary-cta-1'}, 2, schema);
|
|
773
810
|
schema = this.showCtaKeys(true, formData, {id: 'cta-deeplink-secondary-cta-1-select2'}, 2, schema);
|
|
774
811
|
}
|
|
@@ -966,7 +1003,9 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
966
1003
|
|
|
967
1004
|
],
|
|
968
1005
|
});
|
|
969
|
-
|
|
1006
|
+
const selectedConfigTemplateCtaId = get(selectedConfig, 'ctaTemplateDetails[0].id');
|
|
1007
|
+
// the option to select deeplink and externa link should not come for these ctas
|
|
1008
|
+
if (selectedConfigTemplateCtaId && (selectedConfigTemplateCtaId.id !== "3heicig" && selectedConfigTemplateCtaId.id !== "6eigf4f" && selectedConfigTemplateCtaId.id !== "c97d0ed")) {
|
|
970
1009
|
inputFields.splice(fieldIndex + 2, 0, {
|
|
971
1010
|
rowClassName: "mobile-push-row",
|
|
972
1011
|
identifier: `cta-deeplink-${inputId}`,
|
|
@@ -1028,10 +1067,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1028
1067
|
}
|
|
1029
1068
|
});
|
|
1030
1069
|
});
|
|
1031
|
-
|
|
1032
|
-
this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true});
|
|
1033
|
-
this.injectEvents(schema);
|
|
1034
|
-
}
|
|
1070
|
+
this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true}, () => { this.injectEvents(schema); });
|
|
1035
1071
|
return schema;
|
|
1036
1072
|
};
|
|
1037
1073
|
|
|
@@ -1553,7 +1589,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1553
1589
|
const fieldIndex = findIndex(inputFields, {identifier: id});
|
|
1554
1590
|
let newInputFields;
|
|
1555
1591
|
if (formData[tabIndex - 1][id]) {
|
|
1556
|
-
newInputFields = this.getPrimaryCtaFields({inputFields, fieldIndex, deepLinkOptions});
|
|
1592
|
+
newInputFields = this.getPrimaryCtaFields({inputFields, fieldIndex, deepLinkOptions, tab: currentTab});
|
|
1557
1593
|
} else {
|
|
1558
1594
|
const identifier = (tabIndex - 1) ? 'add-sec-cta-ios' : 'add-sec-cta';
|
|
1559
1595
|
const indexOfNextField = findIndex(inputFields, {identifier});
|
|
@@ -1564,14 +1600,16 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1564
1600
|
if (inputSchema) {
|
|
1565
1601
|
return schema;
|
|
1566
1602
|
}
|
|
1567
|
-
this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true})
|
|
1568
|
-
|
|
1603
|
+
this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true}, () => {
|
|
1604
|
+
this.injectEvents(schema);
|
|
1605
|
+
});
|
|
1569
1606
|
return schema;
|
|
1570
1607
|
};
|
|
1571
1608
|
|
|
1572
1609
|
addSecondoryCta = (flag, formData, field, inputSchema, currentTab) => {
|
|
1573
1610
|
const id = field.id;
|
|
1574
1611
|
const tabIndex = currentTab || this.state.currentTab;
|
|
1612
|
+
const formDataCopy = cloneDeep(formData);
|
|
1575
1613
|
const schema = inputSchema ? _.cloneDeep(inputSchema) : _.cloneDeep(this.state.schema);
|
|
1576
1614
|
const selectedWeChatAccount = (!_.isEmpty(this.props.Templates.selectedWeChatAccount) ? this.props.Templates.selectedWeChatAccount : this.props.Edit.selectedWeChatAccount);
|
|
1577
1615
|
const ck = selectedWeChatAccount.configs ? !!selectedWeChatAccount.configs.deeplink : false;
|
|
@@ -1587,13 +1625,32 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1587
1625
|
const deleteCount = indexOfNextField - fieldIndex;
|
|
1588
1626
|
newInputFields = [...inputFields.slice(0, fieldIndex + 1), ...inputFields.slice(fieldIndex + deleteCount, inputFields.length)];
|
|
1589
1627
|
}
|
|
1590
|
-
|
|
1591
|
-
|
|
1628
|
+
if (id === "add-sec-cta") {
|
|
1629
|
+
//The following block of code enables and disables add secondary button based on the primary button
|
|
1630
|
+
const indexOfSecondary = findIndex(newInputFields, {identifier: 'add-sec-cta-2'});
|
|
1631
|
+
newInputFields[indexOfSecondary].cols[0].disabled = !formData[this.state.currentTab - 1][id];
|
|
1632
|
+
//Calling the following function to unset the data set under secondary button
|
|
1633
|
+
if (!formData[this.state.currentTab - 1][id]) {
|
|
1634
|
+
formDataCopy[this.state.currentTab - 1]['add-sec-cta-2'] = false;
|
|
1635
|
+
}
|
|
1636
|
+
set(schema, `containers[0].panes[${tabIndex - 1}].sections[0].childSections[0].childSections[0].inputFields`, newInputFields);
|
|
1637
|
+
//Calling set state here to update the state and schema before manually triggering secondarycta update
|
|
1638
|
+
this.setState(
|
|
1639
|
+
{schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true},
|
|
1640
|
+
() => {
|
|
1641
|
+
this.injectEvents(schema);
|
|
1642
|
+
this.addSecondoryCta(true, formDataCopy, newInputFields[indexOfSecondary].cols[0]);
|
|
1643
|
+
});
|
|
1644
|
+
} else {
|
|
1645
|
+
set(schema, `containers[0].panes[${tabIndex - 1}].sections[0].childSections[0].childSections[0].inputFields`, newInputFields);
|
|
1646
|
+
if (inputSchema) {
|
|
1647
|
+
return schema;
|
|
1648
|
+
}
|
|
1649
|
+
this.setState({schema, initialState: this.state.initialState ? this.state.initialState : this.state.schema, isSchemaChanged: true});
|
|
1650
|
+
this.injectEvents(schema);
|
|
1592
1651
|
return schema;
|
|
1593
1652
|
}
|
|
1594
|
-
|
|
1595
|
-
this.injectEvents(schema);
|
|
1596
|
-
return schema;
|
|
1653
|
+
return true;
|
|
1597
1654
|
};
|
|
1598
1655
|
|
|
1599
1656
|
addSecondoryCtaIos = (flag, formData, schemaField) => {
|
|
@@ -247,7 +247,23 @@ export default defineMessages({
|
|
|
247
247
|
defaultMessage: 'IOS template is not configured, Save without IOS template',
|
|
248
248
|
},
|
|
249
249
|
"selectActionButton": {
|
|
250
|
-
id: 'app.containers.MobilePush.
|
|
250
|
+
id: 'app.containers.MobilePush.Edit.mobilePush',
|
|
251
251
|
defaultMessage: 'Select action buttons',
|
|
252
252
|
},
|
|
253
|
+
"validationError": {
|
|
254
|
+
id: 'app.containers.MobilePush.Edit.validationError',
|
|
255
|
+
defaultMessage: 'Validation error',
|
|
256
|
+
},
|
|
257
|
+
"invalidIosMessage": {
|
|
258
|
+
id: 'app.containers.MobilePush.Edit.invalidIosMessage',
|
|
259
|
+
defaultMessage: 'Validation failed for IOS',
|
|
260
|
+
},
|
|
261
|
+
"invalidAndroidMessage": {
|
|
262
|
+
id: 'app.containers.MobilePush.Edit.invalidAndroidMessage',
|
|
263
|
+
defaultMessage: 'Validation failed for Android',
|
|
264
|
+
},
|
|
265
|
+
"invalidTags": {
|
|
266
|
+
id: 'app.containers.MobilePush.Create.invalidTags',
|
|
267
|
+
defaultMessage: 'Invalid tags',
|
|
268
|
+
},
|
|
253
269
|
});
|
|
@@ -2,15 +2,16 @@ import {get, filter, cloneDeep} from 'lodash';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import {FormattedMessage} from 'react-intl';
|
|
4
4
|
import messages from './Create/messages';
|
|
5
|
-
function getPrimaryCtaFields({inputFields, fieldIndex, deepLinkOptions}) {
|
|
5
|
+
function getPrimaryCtaFields({inputFields, fieldIndex, deepLinkOptions, tab}) {
|
|
6
|
+
const currentTab = tab || this.state.currentTab;
|
|
6
7
|
const newInputFields = cloneDeep(inputFields);
|
|
7
8
|
newInputFields.splice(fieldIndex + 1, 0, {
|
|
8
9
|
rowClassName: 'mobile-push-row',
|
|
9
|
-
identifier: `cta-deeplink${
|
|
10
|
+
identifier: `cta-deeplink${currentTab > 1 ? currentTab : ''}`,
|
|
10
11
|
|
|
11
12
|
cols: [
|
|
12
13
|
{
|
|
13
|
-
id: `cta-deeplink${
|
|
14
|
+
id: `cta-deeplink${currentTab > 1 ? currentTab : ''}`,
|
|
14
15
|
type: "radioGroup", //Resembles component to be used
|
|
15
16
|
metaType: "text",
|
|
16
17
|
datatype: "string",
|
|
@@ -33,12 +34,12 @@ function getPrimaryCtaFields({inputFields, fieldIndex, deepLinkOptions}) {
|
|
|
33
34
|
newInputFields.splice(fieldIndex + 2, 0, {
|
|
34
35
|
rowClassName: 'mobile-push-row',
|
|
35
36
|
id: 'cta-deeplink-select-section',
|
|
36
|
-
identifier: `cta-deeplink${
|
|
37
|
+
identifier: `cta-deeplink${currentTab > 1 ? currentTab : ''}-select`,
|
|
37
38
|
|
|
38
39
|
cols: [
|
|
39
40
|
|
|
40
41
|
{
|
|
41
|
-
id: `cta-deeplink${
|
|
42
|
+
id: `cta-deeplink${currentTab > 1 ? currentTab : ''}-select`,
|
|
42
43
|
placeholder: "Select DeepLink",
|
|
43
44
|
type: "select", //Resembles component to be used
|
|
44
45
|
options: deepLinkOptions,
|
|
@@ -153,10 +154,11 @@ function getSecondaryCtaFields({inputFields, fieldIndex, deepLinkOptions}) {
|
|
|
153
154
|
});
|
|
154
155
|
return newInputFields;
|
|
155
156
|
}
|
|
156
|
-
function getLinkTypeFields({inputFieldsArgs, fieldIndex, deepLinkOptions, formData, field}) {
|
|
157
|
+
function getLinkTypeFields({inputFieldsArgs, fieldIndex, deepLinkOptions, formData, field, tab}) {
|
|
158
|
+
const currentTab = tab || this.state.currentTab;
|
|
157
159
|
const inputFields = cloneDeep(inputFieldsArgs);
|
|
158
160
|
const deeplinks = this.props.Templates.selectedWeChatAccount && this.props.Templates.selectedWeChatAccount.configs && !!this.props.Templates.selectedWeChatAccount.configs.deeplink ? this.props.Templates.selectedWeChatAccount.configs.deeplink : '[]';
|
|
159
|
-
const deeplinkValue = formData[
|
|
161
|
+
const deeplinkValue = formData[currentTab - 1][field.id];
|
|
160
162
|
const componentIndex = fieldIndex + 1;
|
|
161
163
|
const inputId = deeplinkValue && deeplinkValue.toLowerCase() === "deeplink" ? `${field.id}-select` : `${field.id}-text`;
|
|
162
164
|
if ( deeplinkValue && deeplinkValue.toLowerCase() === "deeplink" && (fieldIndex === inputFields.length - 1 || inputFields[componentIndex].id !== "cta-deeplink-select-section")) {
|
|
@@ -441,6 +441,7 @@ export const response = {
|
|
|
441
441
|
id: "add-sec-cta-2",
|
|
442
442
|
metaType: "label",
|
|
443
443
|
dynamicTab: false,
|
|
444
|
+
disabled: true,
|
|
444
445
|
label: "Add secondary button to notification",
|
|
445
446
|
styling: "semantic",
|
|
446
447
|
type: "checkbox",
|
|
@@ -1323,6 +1324,7 @@ export const response = {
|
|
|
1323
1324
|
id: "add-sec-cta-2",
|
|
1324
1325
|
metaType: "label",
|
|
1325
1326
|
dynamicTab: false,
|
|
1327
|
+
disabled: true,
|
|
1326
1328
|
label: "Add secondary button to notification",
|
|
1327
1329
|
styling: "semantic",
|
|
1328
1330
|
type: "checkbox",
|