@capillarytech/creatives-library 2.0.89 → 2.0.91
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/assets/android-message-gui-2.svg +55 -0
- package/components/CallTaskPreview/_callTaskPreview.scss +17 -0
- package/components/CallTaskPreview/images/Footer.png +0 -0
- package/components/CallTaskPreview/images/Header.png +0 -0
- package/components/CallTaskPreview/index.js +37 -0
- package/components/CallTaskPreview/messages.js +13 -0
- package/components/CallTaskPreview/tests/index.test.js +15 -0
- package/components/CmsTemplatesComponent/index.js +33 -0
- package/components/CmsTemplatesComponent/messages.js +17 -0
- package/components/CmsTemplatesComponent/tests/index.test.js +10 -0
- package/components/EmailMobilePreview/index.js +129 -0
- package/components/EmailMobilePreview/index.scss +55 -0
- package/components/EmailPreviewV2/_emailPreviewV2.scss +69 -0
- package/components/EmailPreviewV2/index.js +132 -0
- package/components/EmailPreviewV2/messages.js +41 -0
- package/components/EmailPreviewV2/tests/index.test.js +10 -0
- package/components/MobilePushPreviewV2/index.js +120 -0
- package/components/MobilePushPreviewV2/messages.js +13 -0
- package/components/MobilePushPreviewV2/tests/index.test.js +10 -0
- package/components/NewCallTask/_newCallTask.scss +9 -0
- package/components/NewCallTask/index.js +152 -0
- package/components/NewCallTask/messages.js +29 -0
- package/components/NewCallTask/tests/index.test.js +10 -0
- package/components/SmsPreviewV2/_smsPreviewV2.scss +353 -0
- package/components/SmsPreviewV2/index.js +69 -0
- package/components/SmsPreviewV2/messages.js +13 -0
- package/components/SmsPreviewV2/tests/index.test.js +10 -0
- package/containers/Cap/index.js +1 -2
- package/containers/Email/index.js +20 -22
- package/containers/Sms/Create/index.js +5 -4
- package/containers/Sms/Edit/index.js +5 -4
- package/containers/WeChat/MapTemplates/index.js +7 -4
- package/package.json +2 -2
- package/v2Components/FormBuilder/index.js +25 -15
- package/v2Components/NavigationBar/index.js +2 -2
- package/v2Components/TopBar/index.js +2 -1
- package/v2Containers/Assets/Gallery/index.js +4 -4
- package/v2Containers/Cap/constants.js +1 -1
- package/v2Containers/Cap/index.js +3 -2
- package/v2Containers/CreativesContainer/SlideBoxContent.js +4 -0
- package/v2Containers/CreativesContainer/SlideBoxHeader.js +9 -8
- package/v2Containers/CreativesContainer/index.js +39 -23
- package/v2Containers/CreativesContainer/messages.js +1 -1
- package/v2Containers/Email/index.js +19 -16
- package/v2Containers/Email/sagas.js +7 -4
- package/v2Containers/EmailWrapper/index.js +3 -1
- package/v2Containers/Sms/Create/_smsCreate.scss +0 -44
- package/v2Containers/Sms/Create/index.js +16 -14
- package/v2Containers/Sms/Edit/index.js +33 -31
- package/v2Containers/Sms/initialSchema.js +17 -17
- package/v2Containers/Templates/index.js +21 -22
|
@@ -279,6 +279,9 @@ class Creatives extends React.Component {
|
|
|
279
279
|
saveMessage = () => {
|
|
280
280
|
this.setState({ isGetFormData: true });
|
|
281
281
|
};
|
|
282
|
+
onValidationFail = () => {
|
|
283
|
+
this.setState({ isGetFormData: false });
|
|
284
|
+
}
|
|
282
285
|
discardMessage = () => {
|
|
283
286
|
this.setState({ isDiscardMessage: true });
|
|
284
287
|
}
|
|
@@ -342,34 +345,35 @@ class Creatives extends React.Component {
|
|
|
342
345
|
|
|
343
346
|
return showDone;
|
|
344
347
|
}
|
|
348
|
+
templateNameComponentHeader = ({formData, onFormDataChange, name}) => (
|
|
349
|
+
<CapHeader
|
|
350
|
+
inline
|
|
351
|
+
title={name}
|
|
352
|
+
description={<CapLink
|
|
353
|
+
title={<FormattedMessage {...messages.creativesTemplatesEditName}/>}
|
|
354
|
+
onClick={() => { this.setState({isEditName: true}, () => { this.showTemplateName({formData, onFormDataChange}); }); }}/>
|
|
355
|
+
}/>)
|
|
356
|
+
templateNameComponentInput = ({formData, onFormDataChange, name}) => (<CapInput
|
|
357
|
+
|
|
358
|
+
value={name}
|
|
359
|
+
suffix={<span/>}
|
|
360
|
+
onBlur={() => { this.setState({isEditName: false}, () => { this.showTemplateName({formData, onFormDataChange}); }); }}
|
|
361
|
+
onChange={(ev) => {
|
|
362
|
+
const value = ev.currentTarget.value;
|
|
363
|
+
const newFormData = {...formData, 'template-name': value};
|
|
364
|
+
onFormDataChange(newFormData);
|
|
365
|
+
}}
|
|
366
|
+
/>)
|
|
345
367
|
showTemplateName = ({formData, onFormDataChange}) => { //gets called from email/index after template data is fetched
|
|
346
368
|
const {slidBoxContent, currentChannel, isEditName} = this.state;
|
|
347
369
|
const channel = currentChannel.toUpperCase();
|
|
348
370
|
if ((channel === constants.EMAIL || channel === constants.MOBILE_PUSH) && (slidBoxContent === 'editTemplate' || slidBoxContent === 'createTemplate')) {
|
|
349
371
|
const name = get(formData, 'template-name');
|
|
372
|
+
this.templateContainerDetails = {formData, onFormDataChange};
|
|
350
373
|
if (name && !isEditName) {
|
|
351
|
-
|
|
352
|
-
<CapHeader
|
|
353
|
-
inline
|
|
354
|
-
title={name}
|
|
355
|
-
description={<CapLink
|
|
356
|
-
title={<FormattedMessage {...messages.creativesTemplatesEditName}/>}
|
|
357
|
-
onClick={() => { this.setState({isEditName: true}, () => { this.showTemplateName({formData, onFormDataChange}); }); }}/>
|
|
358
|
-
}/>);
|
|
359
|
-
this.setState({templateNameComponent: TemplateNameComponent});
|
|
374
|
+
this.setState({showTemplateNameComponentEdit: false});
|
|
360
375
|
} else if (isEditName) {
|
|
361
|
-
|
|
362
|
-
key="cap-input-template-name"
|
|
363
|
-
value={name}
|
|
364
|
-
suffix={<span/>}
|
|
365
|
-
onBlur={() => { this.setState({isEditName: false}, () => { this.showTemplateName({formData, onFormDataChange}); }); }}
|
|
366
|
-
onChange={(ev) => {
|
|
367
|
-
const value = ev.currentTarget.value;
|
|
368
|
-
const newFormData = {...formData, 'template-name': value};
|
|
369
|
-
onFormDataChange(newFormData);
|
|
370
|
-
}}
|
|
371
|
-
/>);
|
|
372
|
-
this.setState({templateNameComponent: TemplateNameComponent});
|
|
376
|
+
this.setState({showTemplateNameComponentEdit: true});
|
|
373
377
|
}
|
|
374
378
|
}
|
|
375
379
|
}
|
|
@@ -390,8 +394,18 @@ class Creatives extends React.Component {
|
|
|
390
394
|
|
|
391
395
|
return isShowContinueFooter;
|
|
392
396
|
}
|
|
397
|
+
templateNameRenderProp = () => {
|
|
398
|
+
const {showTemplateNameComponentEdit, currentChannel, slidBoxContent} = this.state;
|
|
399
|
+
const {templateContainerDetails} = this;
|
|
400
|
+
const {formData, onFormDataChange} = templateContainerDetails;
|
|
401
|
+
const channel = currentChannel.toUpperCase();
|
|
402
|
+
if ((channel === constants.EMAIL || channel === constants.MOBILE_PUSH) && (slidBoxContent === 'editTemplate' || slidBoxContent === 'createTemplate')) {
|
|
403
|
+
const name = get(formData, 'template-name');
|
|
404
|
+
return showTemplateNameComponentEdit ? this.templateNameComponentInput({formData, onFormDataChange, name}) : this.templateNameComponentHeader({formData, onFormDataChange, name});
|
|
405
|
+
}
|
|
406
|
+
}
|
|
393
407
|
render() {
|
|
394
|
-
const {
|
|
408
|
+
const {slidBoxContent, isGetFormData, showSlideBox, templateData, currentChannel, emailCreateMode, templateStep, isLoadingContent, mobilePushCreateMode, isDiscardMessage} = this.state;
|
|
395
409
|
const {isFullMode, creativesMode, cap, isUploading} = this.props;
|
|
396
410
|
return (
|
|
397
411
|
<SlideBoxWrapper className={classnames(`${classPrefix} ${isFullMode ? 'creatives-full-mode' : 'creatives-library-mode'}`)}>
|
|
@@ -407,7 +421,8 @@ class Creatives extends React.Component {
|
|
|
407
421
|
creativesMode={creativesMode}
|
|
408
422
|
isFullMode={isFullMode}
|
|
409
423
|
isLoadingContent={isLoadingContent}
|
|
410
|
-
|
|
424
|
+
shouldShowTemplateName={this.templateContainerDetails}
|
|
425
|
+
templateNameRenderProp={this.templateNameRenderProp}
|
|
411
426
|
showPrefix={!isUploading} // not show back button when email template is being uploaded
|
|
412
427
|
/>
|
|
413
428
|
}
|
|
@@ -440,6 +455,7 @@ class Creatives extends React.Component {
|
|
|
440
455
|
onMobilepushModeChange={this.onMobilepushModeChange}
|
|
441
456
|
mobilePushCreateMode={mobilePushCreateMode}
|
|
442
457
|
showTemplateName={this.showTemplateName}
|
|
458
|
+
onValidationFail={this.onValidationFail}
|
|
443
459
|
/>
|
|
444
460
|
}
|
|
445
461
|
footer={this.shouldShowFooter() &&
|
|
@@ -11,7 +11,7 @@ import { connect } from 'react-redux';
|
|
|
11
11
|
import { bindActionCreators } from 'redux';
|
|
12
12
|
import { Row, Col, Popover, Modal } from 'antd';
|
|
13
13
|
import { injectIntl, intlShape, FormattedMessage } from 'react-intl';
|
|
14
|
-
import { CapButton, CapInput, CapSpin, CapSlideBox, CapCustomCard } from '@capillarytech/cap-ui-library';
|
|
14
|
+
import { CapButton, CapInput, CapSpin, CapSlideBox, CapCustomCard, CapNotification } from '@capillarytech/cap-ui-library';
|
|
15
15
|
import { createStructuredSelector } from 'reselect';
|
|
16
16
|
import _ from 'lodash';
|
|
17
17
|
import moment from "moment";
|
|
@@ -216,6 +216,11 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
216
216
|
// if (this.props.location.query.type === 'embedded') {
|
|
217
217
|
// this.showNext();
|
|
218
218
|
// }
|
|
219
|
+
const {isFullMode, isGetFormData} = nextProps;
|
|
220
|
+
if (isFullMode && isGetFormData && !_.isEqual(isGetFormData, this.props.isGetFormData)) {
|
|
221
|
+
//when create button is clicked in full mode
|
|
222
|
+
this.startValidation(true);
|
|
223
|
+
}
|
|
219
224
|
if (this.state.languageDataSet && nextProps.Templates.selectedEmailLayout && nextProps.Templates.selectedEmailLayout !== '' && !_.isEqual(this.props.Templates.selectedEmailLayout, nextProps.Templates.selectedEmailLayout )) {
|
|
220
225
|
this.setNewLanguageContent(nextProps.Templates.selectedEmailLayout);
|
|
221
226
|
}
|
|
@@ -632,7 +637,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
632
637
|
} else {
|
|
633
638
|
message = getMessageObject('success', this.props.intl.formatMessage(messages.emailCreateSuccess), true);
|
|
634
639
|
}
|
|
635
|
-
|
|
640
|
+
CapNotification.success({message});
|
|
636
641
|
const module = this.props.location.query.module ? this.props.location.query.module : 'default';
|
|
637
642
|
const type = this.props.location.query.type;
|
|
638
643
|
const isLanguageSupport = this.props.location.query.isLanguageSupport || false;
|
|
@@ -944,13 +949,18 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
944
949
|
shouldStartValidation = () => {
|
|
945
950
|
this.setState((prevState) => ({ cmsDataCount: prevState.cmsDataCount + 1}), () => {
|
|
946
951
|
if (this.state.targetSaveCount === this.state.cmsDataCount) {
|
|
947
|
-
|
|
952
|
+
//gets called when org is edm editor enabled, whenever the edm data get saved
|
|
953
|
+
this.startValidation(this.props.isGetFormData);
|
|
948
954
|
}
|
|
949
955
|
});
|
|
950
956
|
}
|
|
951
|
-
|
|
957
|
+
startValidation = (shouldSave) => {
|
|
958
|
+
if (!this.state.startValidation && shouldSave) {
|
|
959
|
+
this.setState({startValidation: true});
|
|
960
|
+
}
|
|
961
|
+
}
|
|
952
962
|
stopValidation = () => {
|
|
953
|
-
this.setState({startValidation: false});
|
|
963
|
+
this.setState({startValidation: false}, this.props.onValidationFail);
|
|
954
964
|
}
|
|
955
965
|
saveValidationData = () => {
|
|
956
966
|
let saveCount = 0;
|
|
@@ -965,7 +975,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
965
975
|
}
|
|
966
976
|
});
|
|
967
977
|
if (saveCount === 0) {
|
|
968
|
-
this.
|
|
978
|
+
this.startValidation();
|
|
969
979
|
return;
|
|
970
980
|
}
|
|
971
981
|
this.setState({targetSaveCount: saveCount, mode: "save", saveCount: 0, cmsDataCount: 0}, () => {
|
|
@@ -2310,16 +2320,8 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
2310
2320
|
}
|
|
2311
2321
|
|
|
2312
2322
|
saveFormData = (passedData) => {
|
|
2313
|
-
//
|
|
2314
|
-
|
|
2315
|
-
//
|
|
2316
|
-
// if (!isValidated) {
|
|
2317
|
-
// return;
|
|
2318
|
-
// }
|
|
2319
|
-
//if (!this.state.startValidation) {
|
|
2320
|
-
// this.saveValidationData();
|
|
2321
|
-
// return;
|
|
2322
|
-
//}
|
|
2323
|
+
//saveFormData gets called only when validation result is true
|
|
2324
|
+
|
|
2323
2325
|
|
|
2324
2326
|
if (this.state.gettingFormData && !this.props.isFullMode) {
|
|
2325
2327
|
const response = {
|
|
@@ -2682,6 +2684,7 @@ Email.propTypes = {
|
|
|
2682
2684
|
injectedTags: PropTypes.object,
|
|
2683
2685
|
defaultData: PropTypes.object,
|
|
2684
2686
|
showTemplateName: PropTypes.func,
|
|
2687
|
+
onValidationFail: PropTypes.func,
|
|
2685
2688
|
};
|
|
2686
2689
|
|
|
2687
2690
|
const mapStateToProps = (state, props) => createStructuredSelector({
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import { take, cancel, call, put, takeLatest, takeEvery } from 'redux-saga/effects';
|
|
2
2
|
import { LOCATION_CHANGE } from 'react-router-redux';
|
|
3
|
+
import {CapNotification} from '@capillarytech/cap-ui-library';
|
|
3
4
|
import * as Api from '../../services/api';
|
|
4
5
|
import * as types from './constants';
|
|
5
6
|
|
|
6
|
-
|
|
7
7
|
export function* createTemplate(template) {
|
|
8
8
|
let errorMsg;
|
|
9
9
|
try {
|
|
10
10
|
const result = yield call(Api.createEmailTemplate, template);
|
|
11
|
-
if (result.
|
|
11
|
+
if (result.status.code === 500) {
|
|
12
12
|
errorMsg = result.message;
|
|
13
|
+
CapNotification.error({message: errorMsg, key: 'create-email-template-error'});
|
|
14
|
+
yield put({ type: types.CREATE_TEMPLATE_FAILURE, errorMsg });
|
|
15
|
+
} else {
|
|
16
|
+
yield put({ type: types.CREATE_TEMPLATE_SUCCESS, data: result.response, statusCode: result.status ? result.status.code : '', errorMsg });
|
|
17
|
+
yield template.onCreateTemplateComplete(result.response);
|
|
13
18
|
}
|
|
14
|
-
yield put({ type: types.CREATE_TEMPLATE_SUCCESS, data: result.response, statusCode: result.status ? result.status.code : '', errorMsg });
|
|
15
|
-
yield template.onCreateTemplateComplete(result.response);
|
|
16
19
|
} catch (error) {
|
|
17
20
|
yield put({ type: types.CREATE_TEMPLATE_FAILURE, error, errorMsg });
|
|
18
21
|
}
|
|
@@ -158,7 +158,7 @@ export class EmailWrapper extends React.Component { // eslint-disable-line react
|
|
|
158
158
|
|
|
159
159
|
isShowEmailCreate = () => !_.isEmpty(this.state.selectedCreateMode) && (!_.isEmpty(this.props.EmailLayout) || this.props.SelectedEdmDefaultTemplate)
|
|
160
160
|
render() {
|
|
161
|
-
const {showTemplateName, emailCreateMode, isGetFormData, getFormdata, type, CmsTemplates, step, cap, isFullMode, EmailLayout, setIsLoadingContent} = this.props;
|
|
161
|
+
const {showTemplateName, emailCreateMode, isGetFormData, getFormdata, type, CmsTemplates, step, cap, isFullMode, EmailLayout, setIsLoadingContent, onValidationFail} = this.props;
|
|
162
162
|
const {templateName, modeContent} = this.state;
|
|
163
163
|
const isShowEmailCreate = this.isShowEmailCreate();
|
|
164
164
|
return (
|
|
@@ -211,6 +211,7 @@ export class EmailWrapper extends React.Component { // eslint-disable-line react
|
|
|
211
211
|
defaultData={{'template-name': templateName}}
|
|
212
212
|
cap={cap}
|
|
213
213
|
showTemplateName={showTemplateName}
|
|
214
|
+
onValidationFail={onValidationFail}
|
|
214
215
|
/>}
|
|
215
216
|
{CmsTemplates && !isShowEmailCreate && <CmsTemplatesComponent cmsTemplates={CmsTemplates} handleEdmDefaultTemplateSelection={this.useEditor}/>}
|
|
216
217
|
</div>
|
|
@@ -240,6 +241,7 @@ EmailWrapper.propTypes = {
|
|
|
240
241
|
isUploading: PropTypes.bool,
|
|
241
242
|
setIsLoadingContent: PropTypes.func,
|
|
242
243
|
showTemplateName: PropTypes.func,
|
|
244
|
+
onValidationFail: PropTypes.func,
|
|
243
245
|
};
|
|
244
246
|
|
|
245
247
|
const mapStateToProps = createStructuredSelector({
|
|
@@ -12,47 +12,3 @@
|
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
.ant-breadcrumb{
|
|
16
|
-
color: #707070;
|
|
17
|
-
font-family: open-sans;
|
|
18
|
-
line-height: 16px;
|
|
19
|
-
font-size: 12px;
|
|
20
|
-
padding-left: 8px;
|
|
21
|
-
}
|
|
22
|
-
.ant-checkbox{
|
|
23
|
-
vertical-align: middle !important;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
#template-name.ant-input{
|
|
27
|
-
font-size: 20px !important;
|
|
28
|
-
// font-family: proxima-nova, sans-serif;
|
|
29
|
-
font-style: normal;
|
|
30
|
-
font-weight: 600;
|
|
31
|
-
}
|
|
32
|
-
.ant-tabs-bar{
|
|
33
|
-
margin-bottom: 0 !important;
|
|
34
|
-
display: flex;
|
|
35
|
-
align-items: center;
|
|
36
|
-
flex-direction: row-reverse;
|
|
37
|
-
justify-content: flex-end;
|
|
38
|
-
}
|
|
39
|
-
.ant-tabs-tabpane{
|
|
40
|
-
border: 1px solid #d9d9d9;
|
|
41
|
-
border-top: none;
|
|
42
|
-
margin-top: -0.2%;
|
|
43
|
-
min-height: calc(70vh);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
.ant-tabs-extra-content{
|
|
47
|
-
flex: 1;
|
|
48
|
-
align-self: flex-end;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.version-popover {
|
|
52
|
-
line-height: 24px;
|
|
53
|
-
cursor: pointer;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
.version-popover:hover{
|
|
57
|
-
background-color: #ecf6fd;
|
|
58
|
-
}
|
|
@@ -8,7 +8,7 @@ import PropTypes from 'prop-types';
|
|
|
8
8
|
|
|
9
9
|
import React from 'react';
|
|
10
10
|
import { connect } from 'react-redux';
|
|
11
|
-
import { CapRow, CapColumn, CapSpin } from '@capillarytech/cap-ui-library';
|
|
11
|
+
import { CapRow, CapColumn, CapSpin, CapNotification } from '@capillarytech/cap-ui-library';
|
|
12
12
|
import { injectIntl, intlShape } from 'react-intl';
|
|
13
13
|
import { createStructuredSelector } from 'reselect';
|
|
14
14
|
import _ from 'lodash';
|
|
@@ -25,6 +25,7 @@ import {checkUnicode, updateCharCount} from '../../../utils/smsCharCountV2';
|
|
|
25
25
|
import * as globalActions from '../../Cap/actions';
|
|
26
26
|
import {getMessageObject} from '../../../utils/messageUtils';
|
|
27
27
|
import * as creativesContainerActions from '../../CreativesContainer/actions';
|
|
28
|
+
import {SMS} from '../../CreativesContainer/constants';
|
|
28
29
|
// import callNativeEvent from '../../../utils/callNativeEvent';
|
|
29
30
|
import {showError} from '../commonMethods';
|
|
30
31
|
export class Create extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
|
@@ -137,8 +138,8 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
137
138
|
this.startValidation();
|
|
138
139
|
}
|
|
139
140
|
if (nextProps.Create.createTemplateError && !_.isEqual(nextProps.Create.createTemplateError, this.props.Create.createTemplateError)) {
|
|
140
|
-
const message =
|
|
141
|
-
|
|
141
|
+
const message = (nextProps.Create.createTemplateErrorMessage && nextProps.Create.createTemplateErrorMessage !== '') ? nextProps.Create.createTemplateErrorMessage : this.props.intl.formatMessage(messages.somethingWentWrong);
|
|
142
|
+
CapNotification.error({key: 'createTemplateError', message });
|
|
142
143
|
}
|
|
143
144
|
if (nextProps.metaEntities && nextProps.metaEntities.layouts && nextProps.metaEntities.layouts.length > 0 && _.isEmpty(this.state.schema)) {
|
|
144
145
|
this.injectEvents(nextProps.metaEntities.layouts[0].definition);
|
|
@@ -209,8 +210,8 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
209
210
|
currentTab: 1,
|
|
210
211
|
editData: {},
|
|
211
212
|
});
|
|
212
|
-
const message =
|
|
213
|
-
|
|
213
|
+
const message = 'SMS Template Created Successfully';
|
|
214
|
+
CapNotification.success({key: 'createMessageSuccess', message});
|
|
214
215
|
const module = this.props.location.query.module ? this.props.location.query.module : 'default';
|
|
215
216
|
const type = this.props.location.query.type;
|
|
216
217
|
if (this.props.isFullMode) {
|
|
@@ -279,7 +280,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
279
280
|
cancelTemplate: this.cancelTemplate,
|
|
280
281
|
},
|
|
281
282
|
"save-button": {
|
|
282
|
-
saveFormData: this.
|
|
283
|
+
saveFormData: this.validateAndSaveFormData,
|
|
283
284
|
},
|
|
284
285
|
"sms-editor": {
|
|
285
286
|
onChange: this.onTemplateContentChange,
|
|
@@ -879,20 +880,21 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
879
880
|
this.setState({showModal: false});
|
|
880
881
|
}
|
|
881
882
|
|
|
882
|
-
|
|
883
|
+
validateAndSaveFormData = () => {
|
|
884
|
+
this.setState({startValidation: true});
|
|
885
|
+
}
|
|
886
|
+
stopValidation = () => {
|
|
887
|
+
this.setState({startValidation: false});
|
|
888
|
+
}
|
|
889
|
+
saveFormData() {
|
|
883
890
|
//Logic to save in db etc
|
|
884
|
-
const
|
|
885
|
-
|
|
886
|
-
if (!validatedFormData.validity) {
|
|
887
|
-
return;
|
|
888
|
-
}
|
|
889
|
-
|
|
891
|
+
const formData = _.cloneDeep(this.state.formData);
|
|
890
892
|
const obj = {};
|
|
891
893
|
obj.versions = {
|
|
892
894
|
base: {},
|
|
893
895
|
history: [],
|
|
894
896
|
};
|
|
895
|
-
obj.type =
|
|
897
|
+
obj.type = SMS;
|
|
896
898
|
for (let index = 0; index < this.state.tabCount; index += 1 ) {
|
|
897
899
|
obj.versions.history.push(formData[index]);
|
|
898
900
|
// if (formData[index])
|
|
@@ -9,7 +9,7 @@ import PropTypes from 'prop-types';
|
|
|
9
9
|
|
|
10
10
|
import React from 'react';
|
|
11
11
|
import { connect } from 'react-redux';
|
|
12
|
-
import {
|
|
12
|
+
import { CapRow, CapColumn, CapSpinner, CapNotification } from '@capillarytech/cap-ui-library';
|
|
13
13
|
import { injectIntl, intlShape } from 'react-intl';
|
|
14
14
|
import { createStructuredSelector } from 'reselect';
|
|
15
15
|
import _ from 'lodash';
|
|
@@ -161,8 +161,8 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
161
161
|
currentTab: 1,
|
|
162
162
|
editData: {},
|
|
163
163
|
});
|
|
164
|
-
const message =
|
|
165
|
-
|
|
164
|
+
const message = 'SMS Template Edited Successfully';
|
|
165
|
+
CapNotification.success({key: 'messageCreateSuccess', message });
|
|
166
166
|
this.props.actions.clearEditResponse();
|
|
167
167
|
const module = this.props.location.query.module ? this.props.location.query.module : 'default';
|
|
168
168
|
const type = this.props.location.query.type;
|
|
@@ -173,8 +173,8 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
if (nextProps.Edit.editTemplateError && !_.isEqual(nextProps.Edit.editTemplateError, this.props.Edit.editTemplateError)) {
|
|
176
|
-
const message =
|
|
177
|
-
|
|
176
|
+
const message = (nextProps.Edit.editTemplateErrorMessage && nextProps.Edit.editTemplateErrorMessage !== '') ? nextProps.Edit.editTemplateErrorMessage : this.props.intl.formatMessage(messages.somethingWentWrong);
|
|
177
|
+
CapNotification.error({key: 'templateEditFailed', message});
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
|
|
@@ -228,8 +228,8 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
228
228
|
currentTab: 1,
|
|
229
229
|
editData: {},
|
|
230
230
|
});
|
|
231
|
-
const message =
|
|
232
|
-
|
|
231
|
+
const message = 'SMS Template Edited Successfully';
|
|
232
|
+
CapNotification.success({key: 'editTemplateSuccess', message});
|
|
233
233
|
this.props.actions.clearEditResponse();
|
|
234
234
|
const module = this.props.location.query.module ? this.props.location.query.module : 'default';
|
|
235
235
|
const type = this.props.location.query.type;
|
|
@@ -351,7 +351,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
351
351
|
cancelTemplate: this.cancelTemplate,
|
|
352
352
|
},
|
|
353
353
|
"save-button": {
|
|
354
|
-
saveFormData: this.
|
|
354
|
+
saveFormData: this.validateAndSaveFormData,
|
|
355
355
|
},
|
|
356
356
|
"sms-editor": {
|
|
357
357
|
onChange: this.onTemplateContentChange,
|
|
@@ -889,22 +889,22 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
889
889
|
handleCancelModal = () => {
|
|
890
890
|
this.setState({showModal: false});
|
|
891
891
|
}
|
|
892
|
-
|
|
893
|
-
|
|
892
|
+
validateAndSaveFormData = () => {
|
|
893
|
+
this.setState({startValidation: true});
|
|
894
|
+
}
|
|
895
|
+
stopValidation = () => {
|
|
896
|
+
this.setState({startValidation: false});
|
|
897
|
+
}
|
|
898
|
+
saveFormData() {
|
|
894
899
|
//Logic to save in db etc
|
|
900
|
+
//saveFormData gets called only when validation result is true
|
|
895
901
|
|
|
896
|
-
const
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
};
|
|
901
|
-
for (let index = 0; index < this.state.tabCount; index += 1 ) {
|
|
902
|
-
obj.versions.history.push(formData[index]);
|
|
903
|
-
}
|
|
904
|
-
obj.name = formData['template-name'];
|
|
905
|
-
obj.versions.base = formData.base;
|
|
902
|
+
const editData = _.cloneDeep(this.state.editData);
|
|
903
|
+
const formData = _.cloneDeep(this.state.formData);
|
|
904
|
+
editData.name = formData['template-name'];
|
|
905
|
+
editData.versions.base = formData.base;
|
|
906
906
|
|
|
907
|
-
this.props.actions.editTemplate(
|
|
907
|
+
this.props.actions.editTemplate(editData, this.onUpdateTemplateComplete);
|
|
908
908
|
}
|
|
909
909
|
isSmsLoading = () => {
|
|
910
910
|
//let {isLoading} = this.props;
|
|
@@ -932,18 +932,18 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
932
932
|
}
|
|
933
933
|
return (
|
|
934
934
|
<div className="sms-email-container">
|
|
935
|
-
<
|
|
936
|
-
{/*<
|
|
937
|
-
<
|
|
935
|
+
<CapSpinner tip={tipText} spinning={spinning}>
|
|
936
|
+
{/*<CapRow style={{marginBottom: '16px', marginLeft: '-40px'}}>
|
|
937
|
+
<CapColumn offset={1}>
|
|
938
938
|
<Breadcrumb>
|
|
939
939
|
<Breadcrumb.Item>Campaigns</Breadcrumb.Item>
|
|
940
940
|
<Breadcrumb.Item>Creatives</Breadcrumb.Item>
|
|
941
941
|
<Breadcrumb.Item>SMS</Breadcrumb.Item>
|
|
942
942
|
</Breadcrumb>
|
|
943
|
-
</
|
|
944
|
-
</
|
|
945
|
-
<
|
|
946
|
-
<
|
|
943
|
+
</CapColumn>
|
|
944
|
+
</CapRow>*/}
|
|
945
|
+
<CapRow>
|
|
946
|
+
<CapColumn>
|
|
947
947
|
<FormBuilder
|
|
948
948
|
isFullMode={this.props.isFullMode}
|
|
949
949
|
refs={this.componentRefs}
|
|
@@ -968,10 +968,12 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
968
968
|
onContextChange={this.handleOnTagsContextChange}
|
|
969
969
|
handleCancelModal={this.handleCancelModal}
|
|
970
970
|
router={this.props.router}
|
|
971
|
+
startValidation={this.state.startValidation}
|
|
972
|
+
stopValidation={this.stopValidation}
|
|
971
973
|
/>
|
|
972
|
-
</
|
|
973
|
-
</
|
|
974
|
-
</
|
|
974
|
+
</CapColumn>
|
|
975
|
+
</CapRow>
|
|
976
|
+
</CapSpinner>
|
|
975
977
|
</div>
|
|
976
978
|
);
|
|
977
979
|
}
|
|
@@ -235,24 +235,24 @@ export const response = {
|
|
|
235
235
|
"saveFormData",
|
|
236
236
|
],
|
|
237
237
|
},
|
|
238
|
-
{
|
|
239
|
-
|
|
240
|
-
|
|
238
|
+
// {
|
|
239
|
+
// id: "discard-button",
|
|
240
|
+
// metaType: "submit-button",
|
|
241
241
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
},
|
|
242
|
+
// type: "button",
|
|
243
|
+
// buttonType: "secondary",
|
|
244
|
+
// value: "Discard changes",
|
|
245
|
+
// customComponent: false,
|
|
246
|
+
// standalone: true,
|
|
247
|
+
// styling: "semantic",
|
|
248
|
+
// order: 3,
|
|
249
|
+
// fluid: true,
|
|
250
|
+
// submitAction: "discardValues",
|
|
251
|
+
// onlyDisplay: true,
|
|
252
|
+
// supportedEvents: [
|
|
253
|
+
// "discardValues",
|
|
254
|
+
// ],
|
|
255
|
+
// },
|
|
256
256
|
|
|
257
257
|
|
|
258
258
|
],
|