@capillarytech/creatives-library 2.0.82 → 2.0.83
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/CapTagList/index.js +24 -21
- package/components/CardGrid/index.js +10 -16
- package/components/Ckeditor/index.js +1 -2
- package/components/CustomPopOver/index.js +1 -1
- package/components/EmailPreview/index.js +2 -3
- package/components/FormBuilder/_formBuilder.scss +15 -8
- package/components/FormBuilder/index.js +194 -260
- package/components/Header/index.js +1 -4
- package/components/PreviewSideBar/_previewsidebar.scss +1 -1
- package/components/PreviewSideBar/index.js +5 -3
- package/components/TemplatePreview/WechatRichmediaTemplatePreview/index.js +3 -2
- package/components/TemplatePreview/_templatePreview.scss +1 -1
- package/components/TemplatePreview/index.js +47 -47
- package/components/TemplatePreview/messages.js +1 -9
- package/containers/Assets/Gallery/index.js +1 -1
- package/containers/Email/index.js +1 -1
- package/containers/Login/components/LoginForm/index.js +1 -1
- package/containers/Templates/index.js +1 -1
- package/containers/WeChat/RichmediaTemplates/Create/index.js +1 -1
- package/package.json +2 -1
- package/v2Components/BreadCrumbs/index.js +65 -0
- package/v2Components/BreadCrumbs/messages.js +13 -0
- package/v2Components/BreadCrumbs/tests/index.test.js +10 -0
- package/v2Components/CallTaskPreview/_callTaskPreview.scss +17 -0
- package/v2Components/CallTaskPreview/images/Footer.png +0 -0
- package/v2Components/CallTaskPreview/images/Header.png +0 -0
- package/v2Components/CallTaskPreview/index.js +37 -0
- package/v2Components/CallTaskPreview/messages.js +13 -0
- package/v2Components/CallTaskPreview/tests/index.test.js +15 -0
- package/v2Components/CapTagList/index.js +232 -0
- package/v2Components/CapTagList/messages.js +25 -0
- package/v2Components/CapTagList/tests/index.test.js +10 -0
- package/v2Components/Card/_customCard.scss +27 -0
- package/v2Components/Card/index.js +78 -0
- package/{containers/WeChat → v2Components/Card}/tests/index.test.js +2 -2
- package/v2Components/CardGrid/index.js +77 -0
- package/v2Components/CardGrid/tests/index.test.js +10 -0
- package/v2Components/Ckeditor/index.js +234 -0
- package/v2Components/Ckeditor/messages.js +13 -0
- package/v2Components/Ckeditor/tests/index.test.js +10 -0
- package/v2Components/CmsTemplatesComponent/index.js +33 -0
- package/v2Components/CmsTemplatesComponent/messages.js +17 -0
- package/v2Components/CmsTemplatesComponent/tests/index.test.js +10 -0
- package/v2Components/Component/index.js +29 -0
- package/v2Components/Component/tests/index.test.js +10 -0
- package/v2Components/CustomPopOver/index.js +82 -0
- package/v2Components/CustomPopOver/messages.js +13 -0
- package/v2Components/CustomPopOver/tests/index.test.js +10 -0
- package/v2Components/DateFilter/index.js +349 -0
- package/v2Components/DateFilter/messages.js +17 -0
- package/v2Components/DateFilter/tests/index.test.js +15 -0
- package/v2Components/DateRange/index.js +113 -0
- package/v2Components/DateRange/messages.js +13 -0
- package/v2Components/DateRange/tests/index.test.js +10 -0
- package/v2Components/Edmeditor/index.js +65 -0
- package/v2Components/Edmeditor/messages.js +13 -0
- package/v2Components/Edmeditor/tests/index.test.js +10 -0
- package/v2Components/EmailMobilePreview/index.js +129 -0
- package/v2Components/EmailMobilePreview/index.scss +55 -0
- package/v2Components/EmailPreview/_emailPreview.scss +119 -0
- package/v2Components/EmailPreview/index.js +106 -0
- package/v2Components/EmailPreview/messages.js +17 -0
- package/v2Components/EmailPreview/tests/index.test.js +10 -0
- package/v2Components/EmailPreviewV2/_emailPreviewV2.scss +69 -0
- package/v2Components/EmailPreviewV2/index.js +132 -0
- package/v2Components/EmailPreviewV2/messages.js +41 -0
- package/v2Components/EmailPreviewV2/tests/index.test.js +10 -0
- package/v2Components/Footer/index.js +27 -0
- package/v2Components/Footer/messages.js +13 -0
- package/v2Components/Footer/tests/index.test.js +10 -0
- package/v2Components/FormBuilder/_formBuilder.scss +78 -0
- package/v2Components/FormBuilder/index.js +3309 -0
- package/v2Components/FormBuilder/messages.js +13 -0
- package/v2Components/FormBuilder/tests/index.test.js +10 -0
- package/v2Components/Header/index.js +46 -0
- package/v2Components/Header/messages.js +25 -0
- package/v2Components/Header/tests/index.test.js +10 -0
- package/v2Components/ImagePreview/_imagePreview.scss +63 -0
- package/v2Components/ImagePreview/index.js +52 -0
- package/v2Components/ImagePreview/messages.js +13 -0
- package/v2Components/ImagePreview/tests/index.test.js +10 -0
- package/v2Components/MobilePushPreviewV2/index.js +120 -0
- package/v2Components/MobilePushPreviewV2/messages.js +13 -0
- package/v2Components/MobilePushPreviewV2/tests/index.test.js +10 -0
- package/v2Components/NewCallTask/_newCallTask.scss +9 -0
- package/v2Components/NewCallTask/index.js +152 -0
- package/v2Components/NewCallTask/messages.js +29 -0
- package/v2Components/NewCallTask/tests/index.test.js +10 -0
- package/v2Components/PageHeader/_pageHeader.scss +22 -0
- package/v2Components/PageHeader/index.js +37 -0
- package/v2Components/PageHeader/messages.js +13 -0
- package/v2Components/PageHeader/tests/index.test.js +10 -0
- package/v2Components/Pagination/_pagination.scss +5 -0
- package/v2Components/Pagination/index.js +49 -0
- package/v2Components/Pagination/tests/index.test.js +10 -0
- package/v2Components/PreviewSideBar/_previewsidebar.scss +28 -0
- package/v2Components/PreviewSideBar/index.js +150 -0
- package/v2Components/PreviewSideBar/messages.js +33 -0
- package/v2Components/PreviewSideBar/tests/index.test.js +10 -0
- package/v2Components/Sidebar/_sidebar.scss +115 -0
- package/v2Components/Sidebar/index.js +208 -0
- package/v2Components/Sidebar/messages.js +21 -0
- package/v2Components/Sidebar/tests/index.test.js +10 -0
- package/v2Components/SlideBox/_slideBox.scss +63 -0
- package/v2Components/SlideBox/index.js +48 -0
- package/v2Components/SlideBox/tests/index.test.js +103 -0
- package/v2Components/SmsEditor/index.js +55 -0
- package/v2Components/SmsEditor/tests/index.test.js +10 -0
- package/v2Components/SmsTest/index.js +115 -0
- package/v2Components/SmsTest/messages.js +13 -0
- package/v2Components/SmsTest/tests/index.test.js +10 -0
- package/v2Components/TemplatePreview/WechatRichmediaTemplatePreview/_wechatRichmediaTemplatePrev.scss +42 -0
- package/v2Components/TemplatePreview/WechatRichmediaTemplatePreview/index.js +139 -0
- package/v2Components/TemplatePreview/WechatRichmediaTemplatePreview/messages.js +21 -0
- package/v2Components/TemplatePreview/WechatRichmediaTemplatePreview/tests/index.test.js +10 -0
- package/v2Components/TemplatePreview/_templatePreview.scss +352 -0
- package/v2Components/TemplatePreview/assets/images/WECHAT_5x.png +0 -0
- package/v2Components/TemplatePreview/assets/images/androidPushMessage.svg +45 -0
- package/v2Components/TemplatePreview/assets/images/iPhonePushMessage.svg +135 -0
- package/v2Components/TemplatePreview/assets/images/mobile.svg +24 -0
- package/v2Components/TemplatePreview/assets/images/sms-body.png +0 -0
- package/v2Components/TemplatePreview/assets/images/sms-icon.png +0 -0
- package/v2Components/TemplatePreview/assets/images/sms_mobile.png +0 -0
- package/v2Components/TemplatePreview/assets/images/user-icon.svg +19 -0
- package/v2Components/TemplatePreview/assets/images/wechat-mobile.svg +78 -0
- package/v2Components/TemplatePreview/index.js +175 -0
- package/v2Components/TemplatePreview/messages.js +37 -0
- package/v2Components/TemplatePreview/tests/index.test.js +10 -0
- package/v2Components/Toastr/index.js +60 -0
- package/v2Components/Toastr/messages.js +13 -0
- package/v2Components/Toastr/tests/index.test.js +10 -0
- package/v2Components/ToastrMessage/index.js +110 -0
- package/v2Components/ToastrMessage/messages.js +13 -0
- package/v2Components/ToastrMessage/tests/index.test.js +10 -0
- package/v2Components/TopBar/_topbar.scss +46 -0
- package/v2Components/TopBar/assets/images/capillary_logo.png +0 -0
- package/v2Components/TopBar/index.js +113 -0
- package/v2Components/TopBar/messages.js +29 -0
- package/v2Components/TopBar/tests/index.test.js +10 -0
- package/v2Containers/Assets/Gallery/index.js +1 -1
- package/v2Containers/CallTask/index.js +1 -1
- package/v2Containers/Cap/index.js +2 -2
- package/v2Containers/CreativesContainer/SlideBoxContent.js +3 -3
- package/v2Containers/CreativesContainer/index.js +1 -0
- package/v2Containers/Dashboard/index.js +2 -2
- package/v2Containers/Ebill/index.js +2 -2
- package/v2Containers/Email/index.js +4 -4
- package/v2Containers/EmailWrapper/index.js +1 -1
- package/v2Containers/Line/Create/index.js +1 -1
- package/v2Containers/Line/Edit/index.js +1 -1
- package/v2Containers/Login/index.js +1 -1
- package/v2Containers/MobilePush/Create/index.js +1 -1
- package/v2Containers/MobilePush/Edit/index.js +1 -1
- package/v2Containers/Sms/Create/index.js +1 -1
- package/v2Containers/Sms/Edit/index.js +1 -1
- package/v2Containers/TagList/index.js +1 -1
- package/v2Containers/Templates/index.js +4 -4
- package/v2Containers/TestPage/index.js +1 -1
- package/v2Containers/WeChat/MapTemplates/index.js +3 -3
- package/v2Containers/WeChat/RichmediaTemplates/Create/index.js +3 -3
- package/containers/WeChat/_wechat.scss +0 -8
- package/containers/WeChat/actions.js +0 -46
- package/containers/WeChat/constants.js +0 -28
- package/containers/WeChat/index.js +0 -1617
- package/containers/WeChat/messages.js +0 -73
- package/containers/WeChat/reducer.js +0 -74
- package/containers/WeChat/sagas.js +0 -86
- package/containers/WeChat/selectors.js +0 -25
- package/containers/WeChat/tests/actions.test.js +0 -18
- package/containers/WeChat/tests/reducer.test.js +0 -9
- package/containers/WeChat/tests/sagas.test.js +0 -15
- package/containers/WeChat/tests/selectors.test.js +0 -10
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* CardGrid
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import './_pagination.scss';
|
|
11
|
+
class Pagination extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
|
12
|
+
|
|
13
|
+
componentDidMount() {
|
|
14
|
+
if (document.getElementsByClassName('pagination-container').length > 0) {
|
|
15
|
+
document.getElementsByClassName('pagination-container')[0].addEventListener('scroll', this.handleScroll);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
handleScroll = (e) => {
|
|
19
|
+
const offset = 50;
|
|
20
|
+
if ((e.target.scrollHeight - e.target.scrollTop) - offset <= e.target.clientHeight) {
|
|
21
|
+
this.props.onPageChange();
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
componentDidUnMount() {
|
|
25
|
+
if ( document.getElementsByClassName(this.props.paginationContainer).length > 0) {
|
|
26
|
+
document.getElementsByClassName(this.props.paginationContainer)[0].removeEventListener('scroll', this.handleScroll);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
render() {
|
|
30
|
+
return (
|
|
31
|
+
<div style={this.props.style ? this.props.style : {}}>
|
|
32
|
+
{this.props.children}
|
|
33
|
+
</div>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
Pagination.propTypes = {
|
|
39
|
+
children: PropTypes.element,
|
|
40
|
+
onPageChange: PropTypes.func,
|
|
41
|
+
style: PropTypes.object,
|
|
42
|
+
paginationContainer: PropTypes.string,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
Pagination.defaultProps = {
|
|
46
|
+
paginationContainer: "pagination-container",
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export default Pagination;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
.seperator-line{
|
|
2
|
+
color: #e9e9e9;
|
|
3
|
+
border-style: solid;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.preview-info{
|
|
7
|
+
text-align: center;
|
|
8
|
+
color: #333333;
|
|
9
|
+
// font-family: Open-Sans;
|
|
10
|
+
line-height: 24px;
|
|
11
|
+
font-size: 14px;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.preview-buttons{
|
|
15
|
+
width: 80px;
|
|
16
|
+
height: 32px;
|
|
17
|
+
text-align: center;
|
|
18
|
+
padding: 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.preview-action-container{
|
|
22
|
+
display:flex;
|
|
23
|
+
justify-content: flex-end;
|
|
24
|
+
}
|
|
25
|
+
.devices{
|
|
26
|
+
text-align: center;
|
|
27
|
+
margin: 16px;
|
|
28
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* PreviewSideBar
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import { CapButton } from '@capillarytech/cap-ui-library';
|
|
11
|
+
// import styled from 'styled-components';
|
|
12
|
+
|
|
13
|
+
import { FormattedMessage } from 'react-intl';
|
|
14
|
+
import { Button } from 'antd';
|
|
15
|
+
import _ from 'lodash';
|
|
16
|
+
import TemplatePreview from '../TemplatePreview';
|
|
17
|
+
import SlideBox from '../SlideBox';
|
|
18
|
+
import './_previewsidebar.scss';
|
|
19
|
+
import messages from './messages';
|
|
20
|
+
const ButtonGroup = Button.Group;
|
|
21
|
+
|
|
22
|
+
class PreviewSideBar extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
|
23
|
+
constructor(props) {
|
|
24
|
+
super(props);
|
|
25
|
+
this.goToEdit = this.goToEdit.bind(this);
|
|
26
|
+
this.goToDuplicate = this.goToDuplicate.bind(this);
|
|
27
|
+
this.changeDevice = this.changeDevice.bind(this);
|
|
28
|
+
this.state = {
|
|
29
|
+
device: "android",
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
componentWillReceiveProps(nextProps) {
|
|
33
|
+
if (nextProps.templateData.versions && nextProps.templateData.versions.base.ANDROID && nextProps.templateData.versions.base.IOS) {
|
|
34
|
+
this.setState({device: 'android'});
|
|
35
|
+
} else if (nextProps.templateData.versions && nextProps.templateData.versions.base.IOS) {
|
|
36
|
+
this.setState({device: 'ios'});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
goToDuplicate() {
|
|
40
|
+
this.props.onDuplicateClick(this.props.templateData);
|
|
41
|
+
this.props.handleClose();
|
|
42
|
+
}
|
|
43
|
+
changeDevice(ev) {
|
|
44
|
+
this.setState({device: ev.target.value});
|
|
45
|
+
}
|
|
46
|
+
goToEdit(e, path) {
|
|
47
|
+
this.props.onEditClick(e, this.props.templateData._id, this.props.templateData.modeType, path);
|
|
48
|
+
}
|
|
49
|
+
render() {
|
|
50
|
+
console.log('preview sidebar', this.props);
|
|
51
|
+
let content = '';
|
|
52
|
+
if (this.props.channel.toLowerCase() === 'wechat') {
|
|
53
|
+
console.log('Template Infog ', this.props.templateData);
|
|
54
|
+
content = this.props.templateData.content;
|
|
55
|
+
} else if (this.props.channel.toLowerCase() === "mobilepush" && !_.isEmpty(this.props.templateData)) {
|
|
56
|
+
const data = this.state.device === "android" ? this.props.templateData.versions.base.ANDROID : this.props.templateData.versions.base.IOS;
|
|
57
|
+
content = {
|
|
58
|
+
header: data.title,
|
|
59
|
+
bodyText: data.message,
|
|
60
|
+
bodyImage: data.expandableDetails && data.expandableDetails.image,
|
|
61
|
+
actions: [],
|
|
62
|
+
appName: this.props.templateData.appName,
|
|
63
|
+
};
|
|
64
|
+
if (data.expandableDetails && data.expandableDetails.ctas && data.expandableDetails.ctas.length) {
|
|
65
|
+
if (this.state.device === "android" ) {
|
|
66
|
+
content.actions = _.map(data.expandableDetails.ctas, (cta) => ({label: cta.actionText}));
|
|
67
|
+
} else {
|
|
68
|
+
content.actions = [{label: data.expandableDetails.ctas[0].actionLabel}, {label: data.expandableDetails.ctas[0].actionLabel2}];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
} else if (this.props.channel.toLowerCase() === "line") {
|
|
72
|
+
const isMsgReady = (this.props.templateData && this.props.templateData.versions && this.props.templateData.versions.base);
|
|
73
|
+
if (isMsgReady) {
|
|
74
|
+
content = {
|
|
75
|
+
bodyText: this.props.templateData.versions.base.content.messages[0].text ? this.props.templateData.versions.base.content.messages[0].text : '',
|
|
76
|
+
bodyImage: this.props.templateData.versions.base.content.messages[0].previewImageUrl ? this.props.templateData.versions.base.content.messages[0].previewImageUrl : '',
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
} else {
|
|
80
|
+
content = this.props.templateData && this.props.templateData.versions && this.props.templateData.versions.base ? this.props.templateData.versions.base['sms-editor'] : '';
|
|
81
|
+
for (let idx = 2; idx <= 5; idx += 1) {
|
|
82
|
+
if ((content === '' || !content) && this.props.templateData && this.props.templateData.versions && this.props.templateData.versions.base && this.props.templateData && this.props.templateData.versions && this.props.templateData.versions.base[`sms-editor${idx}`]) {
|
|
83
|
+
content = this.props.templateData.versions.base[`sms-editor${idx}`];
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
let path = '';
|
|
88
|
+
if (this.props.channel.toLowerCase() === 'wechat') {
|
|
89
|
+
path = this.props.templateData && this.props.templateData.definition && this.props.templateData.definition.msgcontent === "RICH_MEDIA_WECHAT" ? `/wechat/richmedia/edit/${this.props.templateData._id}` : `/wechat/edit/${this.props.templateData._id}`;
|
|
90
|
+
}
|
|
91
|
+
console.log('final content is', content);
|
|
92
|
+
return (
|
|
93
|
+
<SlideBox
|
|
94
|
+
header={this.props.templateData && this.props.templateData.name ? this.props.templateData.name : ''}
|
|
95
|
+
content={
|
|
96
|
+
<div>
|
|
97
|
+
<div className="devices">
|
|
98
|
+
{!_.isEmpty(this.props.templateData) && this.props.templateData.versions.base.ANDROID && this.props.templateData.versions.base.IOS &&
|
|
99
|
+
<ButtonGroup onClick={this.changeDevice}>
|
|
100
|
+
<CapButton type={this.state.device === "android" ? "primary" : "secondary"} value={"android"}>Android</CapButton>
|
|
101
|
+
<CapButton type={this.state.device === "iphone" ? "primary" : "secondary"} value={"iphone"}>IOS</CapButton>
|
|
102
|
+
</ButtonGroup>}
|
|
103
|
+
</div>
|
|
104
|
+
{this.props.channel.toLowerCase() === "mobilepush" ?
|
|
105
|
+
<TemplatePreview
|
|
106
|
+
device={this.state.device === "android" ? "android" : "iphone"}
|
|
107
|
+
channel={this.props.channel}
|
|
108
|
+
content={content || ''}
|
|
109
|
+
templateData={this.props.templateData}
|
|
110
|
+
>
|
|
111
|
+
</TemplatePreview>
|
|
112
|
+
:
|
|
113
|
+
<TemplatePreview
|
|
114
|
+
content={content || ''}
|
|
115
|
+
channel={this.props.channel}
|
|
116
|
+
location={this.props.location}
|
|
117
|
+
charCounterEnabled={this.props.channel.toLowerCase() === 'sms'}
|
|
118
|
+
unicodeEnabled={this.props.channel.toLowerCase() === 'sms'}
|
|
119
|
+
templateData={this.props.templateData}
|
|
120
|
+
>
|
|
121
|
+
</TemplatePreview>
|
|
122
|
+
}
|
|
123
|
+
<hr className="seperator-line" />
|
|
124
|
+
<div className="preview-action-container" style={{margin: '16px'}}>
|
|
125
|
+
{this.props.channel.toLowerCase() === 'sms' && !this.props.embedded && <CapButton onClick={() => this.goToDuplicate()}className="preview-buttons" style={{marginRight: '8px'}} type="secondary"><FormattedMessage {...messages.duplicate} /></CapButton>}
|
|
126
|
+
<CapButton onClick={(e) => this.goToEdit(e, path)} className="preview-buttons" type="primary">{this.props.location.query.type === 'embedded' ? <FormattedMessage {...messages.select} /> : <FormattedMessage {...messages.edit} />}</CapButton>
|
|
127
|
+
</div>
|
|
128
|
+
</div>
|
|
129
|
+
}
|
|
130
|
+
show={this.props.showPreview}
|
|
131
|
+
handleClose={this.props.handleClose}
|
|
132
|
+
>
|
|
133
|
+
</SlideBox>
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
PreviewSideBar.propTypes = {
|
|
140
|
+
templateData: PropTypes.object.isRequired,
|
|
141
|
+
channel: PropTypes.string.isRequired,
|
|
142
|
+
showPreview: PropTypes.bool,
|
|
143
|
+
handleClose: PropTypes.func,
|
|
144
|
+
onEditClick: PropTypes.func,
|
|
145
|
+
onDuplicateClick: PropTypes.func,
|
|
146
|
+
location: PropTypes.object,
|
|
147
|
+
embedded: PropTypes.bool,
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export default PreviewSideBar;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* PreviewSideBar Messages
|
|
3
|
+
*
|
|
4
|
+
* This contains all the text for the PreviewSideBar component.
|
|
5
|
+
*/
|
|
6
|
+
import { defineMessages } from 'react-intl';
|
|
7
|
+
|
|
8
|
+
export default defineMessages({
|
|
9
|
+
header: {
|
|
10
|
+
id: 'app.components.PreviewSideBar.header',
|
|
11
|
+
defaultMessage: 'This is the PreviewSideBar component !',
|
|
12
|
+
},
|
|
13
|
+
lastModified: {
|
|
14
|
+
id: 'app.components.PreviewSideBar.lastModified',
|
|
15
|
+
defaultMessage: 'Last Modified On',
|
|
16
|
+
},
|
|
17
|
+
uploadedBy: {
|
|
18
|
+
id: 'app.components.PreviewSideBar.uploadedBy',
|
|
19
|
+
defaultMessage: 'Last Modified By',
|
|
20
|
+
},
|
|
21
|
+
edit: {
|
|
22
|
+
id: 'app.components.PreviewSideBar.edit',
|
|
23
|
+
defaultMessage: 'Edit',
|
|
24
|
+
},
|
|
25
|
+
select: {
|
|
26
|
+
id: 'app.components.PreviewSideBar.select',
|
|
27
|
+
defaultMessage: 'Select',
|
|
28
|
+
},
|
|
29
|
+
duplicate: {
|
|
30
|
+
id: 'app.components.PreviewSideBar.duplicate',
|
|
31
|
+
defaultMessage: 'Duplicate',
|
|
32
|
+
},
|
|
33
|
+
});
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
#cap-sidebar{
|
|
2
|
+
padding: 8px 0 8px 0;
|
|
3
|
+
max-width: 200px;
|
|
4
|
+
min-width: 200px;
|
|
5
|
+
width: 16%;
|
|
6
|
+
overflow-y: hidden;
|
|
7
|
+
// height: 100%;
|
|
8
|
+
// display: -webkit-box; /* OLD - iOS 6-, Safari 3.1-6 */
|
|
9
|
+
// display: -moz-box; /* OLD - Firefox 19- (buggy but mostly works) */
|
|
10
|
+
// display: -ms-flexbox; /* TWEENER - IE 10 */
|
|
11
|
+
// display: -webkit-flex; /* NEW - Chrome */
|
|
12
|
+
// display: flex;
|
|
13
|
+
overflow-x: hidden;
|
|
14
|
+
.header.item{
|
|
15
|
+
padding-left: 8px !important;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.sidebar-container {
|
|
20
|
+
display: -webkit-box; /* OLD - iOS 6-, Safari 3.1-6 */
|
|
21
|
+
display: -moz-box; /* OLD - Firefox 19- (buggy but mostly works) */
|
|
22
|
+
display: -ms-flexbox; /* TWEENER - IE 10 */
|
|
23
|
+
display: -webkit-flex; /* NEW - Chrome */
|
|
24
|
+
display: flex;
|
|
25
|
+
flex: 1;
|
|
26
|
+
-webkit-box-flex: 1;
|
|
27
|
+
-webkit-flex: 1;
|
|
28
|
+
-ms-flex: 1;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.sidebar-accordian .content .item.menu-item:hover{
|
|
32
|
+
margin-left: 0 !important;
|
|
33
|
+
text-indent: 0 !important;
|
|
34
|
+
}
|
|
35
|
+
.sidebar-accordian .content .item.menu-item.selected{
|
|
36
|
+
margin-left: 0 !important;
|
|
37
|
+
text-indent: 0 !important;
|
|
38
|
+
}
|
|
39
|
+
.ui.accordion.sidebar-accordian .content .item.selected{
|
|
40
|
+
background: #F2F3F7 !important;
|
|
41
|
+
padding-left: 40px !important;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.item.menu-item{
|
|
45
|
+
// margin-left: 0px;
|
|
46
|
+
padding-left: 40px !important;
|
|
47
|
+
border-left-width: 0 !important;
|
|
48
|
+
text-decoration: none;
|
|
49
|
+
}
|
|
50
|
+
.item.menu-item.selected{
|
|
51
|
+
border-left: 4px solid #2e89df !important;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.item.menu-item.assetItem{
|
|
55
|
+
padding-left: 28px !important;
|
|
56
|
+
line-height: 28px;
|
|
57
|
+
padding-top: 8px;
|
|
58
|
+
padding-bottom: 8px;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.ui.accordion.sidebar-accordian {
|
|
62
|
+
padding-top: 8px !important;
|
|
63
|
+
margin-left: 0;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.ui.accordion.sidebar-accordian .title{
|
|
67
|
+
font-size: 12px !important;
|
|
68
|
+
line-height: 32px !important;
|
|
69
|
+
padding-top: 0 !important;
|
|
70
|
+
padding-bottom: 0 !important;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.sidebar-width {
|
|
74
|
+
// width: 200px !important;
|
|
75
|
+
max-width: 250px;
|
|
76
|
+
min-width: 190px;
|
|
77
|
+
width: 200px;
|
|
78
|
+
}
|
|
79
|
+
.module-menu-header {
|
|
80
|
+
padding-top: 8px!important;
|
|
81
|
+
line-height: 32px!important;
|
|
82
|
+
font-size: 16px!important;
|
|
83
|
+
margin-left: 0!important;
|
|
84
|
+
padding-left: 8px;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// .searchbar {
|
|
88
|
+
// height: 32px;
|
|
89
|
+
// padding-left: 8px;
|
|
90
|
+
// }
|
|
91
|
+
|
|
92
|
+
.menu-header {
|
|
93
|
+
font-size: 12px!important;
|
|
94
|
+
line-height: 32px!important;
|
|
95
|
+
margin: 0!important;
|
|
96
|
+
padding: 0 0 0 8px!important;
|
|
97
|
+
width: 100%;
|
|
98
|
+
}
|
|
99
|
+
.menu-title {
|
|
100
|
+
flex: 0 0 90%!important;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.product-select-menu {
|
|
104
|
+
width: 100%;
|
|
105
|
+
padding-left: 2px;
|
|
106
|
+
background: #F2F3F7;
|
|
107
|
+
font-family: proxima-nova;
|
|
108
|
+
font-size: 16px !important;
|
|
109
|
+
font-weight: 600;
|
|
110
|
+
|
|
111
|
+
.ant-select-selection {
|
|
112
|
+
background: #F2F3F7;
|
|
113
|
+
border: none !important;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
// import styled from 'styled-components';
|
|
4
|
+
import { Accordion, Icon, Input, Button } from 'semantic-ui-react';
|
|
5
|
+
import { FormattedMessage } from 'react-intl';
|
|
6
|
+
import _ from 'lodash';
|
|
7
|
+
import { Link } from 'react-router';
|
|
8
|
+
import messages from './messages';
|
|
9
|
+
import './_sidebar.scss';
|
|
10
|
+
|
|
11
|
+
class Sidebar extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
|
12
|
+
constructor(props) {
|
|
13
|
+
super(props);
|
|
14
|
+
this.state = {
|
|
15
|
+
isOpen: false,
|
|
16
|
+
activeItem: '',
|
|
17
|
+
activeIndex: 0,
|
|
18
|
+
menuItems: this.props.menuData,
|
|
19
|
+
searchText: '',
|
|
20
|
+
visible: true,
|
|
21
|
+
};
|
|
22
|
+
this.handleItemClick = this.handleItemClick.bind(this);
|
|
23
|
+
this.handleTitleClick = this.handleTitleClick.bind(this);
|
|
24
|
+
this.handleSearch = this.handleSearch.bind(this);
|
|
25
|
+
this.toggleSideNav = this.toggleSideNav.bind(this);
|
|
26
|
+
this.getLinkElement = this.getLinkElement.bind(this);
|
|
27
|
+
this.selectActiveLinkFromUrl = this.selectActiveLinkFromUrl.bind(this);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
componentWillMount() {
|
|
31
|
+
this.selectActiveLinkFromUrl(this.props);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
componentWillReceiveProps(nextProp) {
|
|
35
|
+
this.selectActiveLinkFromUrl(nextProp);
|
|
36
|
+
this.setState({ menuItems: nextProp.menuData });
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
getAccordian(content, keyValue) {
|
|
40
|
+
return (<Accordion key={keyValue}>{content}</Accordion>);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
getAccordionTitle(title) {
|
|
44
|
+
return (<Accordion.Title>
|
|
45
|
+
<div className="header item">
|
|
46
|
+
<Icon name="dropdown" /> {title}
|
|
47
|
+
</div>
|
|
48
|
+
</Accordion.Title>);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
getAccordionContent(links, keyValue) {
|
|
52
|
+
return (<Accordion.Content key={keyValue}>{links}</Accordion.Content>);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
getLinkElement(to, text, value, isExternal) {
|
|
56
|
+
const selectedItem = (value && value.trim().toLowerCase() === this.state.activeItem) ? 'selected' : '';
|
|
57
|
+
if (text.toLowerCase().includes(this.state.searchText.toLowerCase())) {
|
|
58
|
+
if (isExternal) {
|
|
59
|
+
return ((text.toLowerCase().includes(this.state.searchText.toLowerCase())) ? <a key={to} className={`item menu-item ${selectedItem}`} href={to}>{text}</a> : '');
|
|
60
|
+
}
|
|
61
|
+
return (
|
|
62
|
+
(text.toLowerCase().includes(this.state.searchText.toLowerCase())) ?
|
|
63
|
+
<Link to={to} className={`item menu-item ${selectedItem}`} onClick={this.handleItemClick} key={to} title={text}>{text}</Link>
|
|
64
|
+
: ''
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
return '';
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
selectActiveLinkFromUrl(props) {
|
|
71
|
+
const activeRoute = props.router.routes[props.router.routes.length - 1];
|
|
72
|
+
const activeRouteName = (activeRoute.name && activeRoute.name.trim().toLowerCase()) || '';
|
|
73
|
+
let selectedItem = '';
|
|
74
|
+
let selectedIndex = -1;
|
|
75
|
+
_.forEach(props.menuData, (menuItem, menuIndex) => {
|
|
76
|
+
if (menuItem.items && typeof menuItem.items === 'object') {
|
|
77
|
+
_.forEach(menuItem.items, (menuData) => {
|
|
78
|
+
// console.log('Menua Data ', menuData, activeRouteName, menuItem);
|
|
79
|
+
if ((menuItem.id && menuData.id.toLowerCase() === activeRouteName.toLowerCase()) || (menuData.value.toLowerCase() === activeRouteName.toLowerCase())) {
|
|
80
|
+
selectedIndex = menuIndex;
|
|
81
|
+
selectedItem = activeRouteName.toLowerCase();
|
|
82
|
+
} else if (activeRouteName === 'assets') {
|
|
83
|
+
selectedIndex = menuIndex;
|
|
84
|
+
selectedItem = 'gallery';
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
} else if (menuItem.value.toLowerCase() === activeRouteName.toLowerCase()) {
|
|
88
|
+
selectedIndex = menuIndex;
|
|
89
|
+
selectedItem = activeRouteName.toLowerCase();
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
this.setState({ activeIndex: selectedIndex, activeItem: selectedItem });
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
toggleSideNav(e) {
|
|
96
|
+
e.preventDefault();
|
|
97
|
+
this.setState({ visible: !this.state.visible }, () => {
|
|
98
|
+
window.dispatchEvent(new Event('resize'));
|
|
99
|
+
if (!this.state.visible) {
|
|
100
|
+
document.getElementById('cap-sidebar').classList.add('sidebar-collapse');
|
|
101
|
+
} else {
|
|
102
|
+
document.getElementById('cap-sidebar').classList.remove('sidebar-collapse');
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
createAccordianElements(title, contentItems) {
|
|
108
|
+
const accordian = [];
|
|
109
|
+
accordian.push(this.getAccordionTitle(title));
|
|
110
|
+
const contentLink = contentItems.map((key) =>
|
|
111
|
+
this.getLinkElement(key.link, key.text, key.value, key.external),
|
|
112
|
+
);
|
|
113
|
+
accordian.push(this.getAccordionContent(contentLink));
|
|
114
|
+
return accordian;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
createNavigationElement(menuItems) {
|
|
118
|
+
const navArray = [];
|
|
119
|
+
_.forEach(menuItems, (key, index) => {
|
|
120
|
+
const headerTitle = key.group;
|
|
121
|
+
const isCategory = Object.prototype.hasOwnProperty.call(key, 'categories');
|
|
122
|
+
if (isCategory) { // attach nested Accordion
|
|
123
|
+
const accordian = [];
|
|
124
|
+
const nestedAcordian = [];
|
|
125
|
+
accordian.push(this.getAccordionTitle(headerTitle));
|
|
126
|
+
const contentAccordian = this.getAccordian(this.createNavigationElement(key.categories), `nestedAccordian-${index}`);
|
|
127
|
+
nestedAcordian.push(contentAccordian);
|
|
128
|
+
const content = this.getAccordionContent(nestedAcordian, `content-${index}`);
|
|
129
|
+
accordian.push(content);
|
|
130
|
+
navArray.push(accordian);
|
|
131
|
+
} else { // attach items to existing accordian
|
|
132
|
+
const accordianElem = this.createAccordianElements(headerTitle, key.items);
|
|
133
|
+
navArray.push(accordianElem);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
// const selectedItem = (this.state.activeItem === 'gallery') ? 'selected' : '';
|
|
137
|
+
// navArray.push(
|
|
138
|
+
// <Link
|
|
139
|
+
// to={'/assets'}
|
|
140
|
+
// className={`item menu-item ${selectedItem} assetItem`}
|
|
141
|
+
// key={'assets'}
|
|
142
|
+
// title={'Gallery'}
|
|
143
|
+
// onClick={(e) => this.handleItemClick(e)}
|
|
144
|
+
// >Gallery</Link>
|
|
145
|
+
// );
|
|
146
|
+
return navArray;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
handleOpen() {
|
|
150
|
+
this.setState({ isOpen: true });
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
handleClose() {
|
|
154
|
+
this.setState({ isOpen: false });
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
handleItemClick(e) {
|
|
158
|
+
this.setState({ activeItem: (e.target.text && e.target.text.trim().toLowerCase()) || '' });
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
handleTitleClick(e, i) {
|
|
162
|
+
this.setState({ activeIndex: this.state.activeIndex === i ? -1 : i });
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
handleSearch(e) {
|
|
166
|
+
this.setState({ searchText: e.target.value });
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
render() {
|
|
171
|
+
const visible = this.state.visible;
|
|
172
|
+
const push = !visible ? 'push' : '';
|
|
173
|
+
const collapse = !visible ? 'collapse' : '';
|
|
174
|
+
const toggle = visible ? 'hide' : '';
|
|
175
|
+
|
|
176
|
+
// const types = [{ text: 'Creatives', value: 'Creatives' }];
|
|
177
|
+
return (
|
|
178
|
+
<div className="sidebar-container">
|
|
179
|
+
<div className={`sidebar sidebar-width ${collapse}`}>
|
|
180
|
+
<div className="searchbar">
|
|
181
|
+
<FormattedMessage {...messages.inputPlaceholder}>{(message) => <Input icon="search" className="sidebar-search" placeholder={message} fluid onChange={this.handleSearch} />}</FormattedMessage>
|
|
182
|
+
<a href="" onClick={this.toggleSideNav}><i className="material-icons control-arrow">arrow_back</i></a>
|
|
183
|
+
</div>
|
|
184
|
+
|
|
185
|
+
<div className="menu-header">
|
|
186
|
+
<span className="menu-title"><FormattedMessage {...messages.menuTitle} /> </span>
|
|
187
|
+
{this.props.actionComponents}
|
|
188
|
+
</div>
|
|
189
|
+
<Accordion className="sidebar-accordian" activeIndex={this.state.activeIndex} onTitleClick={this.handleTitleClick}>
|
|
190
|
+
{this.props.menuData && this.createNavigationElement(this.props.menuData)}
|
|
191
|
+
</Accordion>
|
|
192
|
+
</div>
|
|
193
|
+
<div className={`togglebar ${toggle} ${push}`}>
|
|
194
|
+
<Button icon className="btn-toggle" onClick={this.toggleSideNav}>
|
|
195
|
+
<Icon name="bars" />
|
|
196
|
+
</Button>
|
|
197
|
+
</div>
|
|
198
|
+
</div>
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
Sidebar.propTypes = {
|
|
204
|
+
menuData: PropTypes.array.isRequired,
|
|
205
|
+
actionComponents: PropTypes.oneOfType([PropTypes.element, PropTypes.string]),
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
export default Sidebar;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Sidebar Messages
|
|
3
|
+
*
|
|
4
|
+
* This contains all the text for the Sidebar component.
|
|
5
|
+
*/
|
|
6
|
+
import { defineMessages } from 'react-intl';
|
|
7
|
+
|
|
8
|
+
export default defineMessages({
|
|
9
|
+
inputPlaceholder: {
|
|
10
|
+
id: 'app.components.Sidebar.input.placeholder',
|
|
11
|
+
defaultMessage: 'Search...',
|
|
12
|
+
},
|
|
13
|
+
menuTitle: {
|
|
14
|
+
id: 'app.components.Sidebar.menuTitle',
|
|
15
|
+
defaultMessage: 'Menu',
|
|
16
|
+
},
|
|
17
|
+
creatives: {
|
|
18
|
+
id: 'app.components.Sidebar.creatives',
|
|
19
|
+
defaultMessage: 'Creatives',
|
|
20
|
+
},
|
|
21
|
+
});
|