@capillarytech/creatives-library 3.1.7 → 3.1.9

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.
Files changed (30) hide show
  1. package/package.json +2 -2
  2. package/translations/en.json +1 -1
  3. package/v2Components/CapTagList/index.js +1 -1
  4. package/v2Components/CapTagList/messages.js +1 -1
  5. package/v2Components/TemplatePreview/WechatRichmediaTemplatePreview/_wechatRichmediaTemplatePrev.scss +0 -1
  6. package/v2Components/TemplatePreview/WechatRichmediaTemplatePreview/index.js +1 -3
  7. package/v2Containers/Templates/index.js +7 -12
  8. package/v2Containers/WeChat/RichmediaTemplates/Create/_createRichmedia.scss +3 -0
  9. package/v2Containers/WeChat/RichmediaTemplates/Create/index.js +2 -4
  10. package/containers/Cap/messsages.js +0 -63
  11. package/v2Components/DateFilter/index.js +0 -349
  12. package/v2Components/DateFilter/messages.js +0 -17
  13. package/v2Components/DateFilter/tests/index.test.js +0 -15
  14. package/v2Components/DateRange/index.js +0 -113
  15. package/v2Components/DateRange/messages.js +0 -13
  16. package/v2Components/DateRange/tests/index.test.js +0 -10
  17. package/v2Components/Header/index.js +0 -46
  18. package/v2Components/Header/tests/index.test.js +0 -10
  19. package/v2Components/PageHeader/_pageHeader.scss +0 -22
  20. package/v2Components/PageHeader/index.js +0 -37
  21. package/v2Components/PageHeader/messages.js +0 -13
  22. package/v2Components/PageHeader/tests/index.test.js +0 -10
  23. package/v2Components/Sidebar/_sidebar.scss +0 -115
  24. package/v2Components/Sidebar/index.js +0 -208
  25. package/v2Components/Sidebar/messages.js +0 -21
  26. package/v2Components/Sidebar/tests/index.test.js +0 -10
  27. package/v2Components/SmsEditor/index.js +0 -55
  28. package/v2Components/SmsEditor/tests/index.test.js +0 -10
  29. package/v2Components/TopBar/_topbar.scss +0 -46
  30. package/v2Containers/TemplatesV2/_templatesV2.scss +0 -5
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "3.1.7",
4
+ "version": "3.1.9",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -12,7 +12,7 @@
12
12
  },
13
13
  "license": "LicenseRef-LICENSE",
14
14
  "dependencies": {
15
- "@babel/node": "^7.7.7",
15
+ "@babel/node": "^7.8.3",
16
16
  "@babel/polyfill": "7.4.3",
17
17
  "babel-cli": "^6.26.0",
18
18
  "chalk": "1.1.3",
@@ -73,7 +73,7 @@
73
73
  "creatives.componentsV2.CallTaskPreview.header": "This is the CallTaskPreview component !",
74
74
  "creatives.componentsV2.CapTagList.Cancel": "Cancel",
75
75
  "creatives.componentsV2.CapTagList.Ok": "Ok",
76
- "creatives.componentsV2.CapTagList.all": "Dynamic days before expiry",
76
+ "creatives.componentsV2.CapTagList.all": "All",
77
77
  "creatives.componentsV2.CapTagList.dynamic_days_before_expiry": "Dynamic days before expiry",
78
78
  "creatives.componentsV2.CapTagList.gettingTags": "Getting tags...",
79
79
  "creatives.componentsV2.CapTagList.loyalty": "Loyalty",
@@ -182,7 +182,7 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
182
182
  content={<div>
183
183
  <CapSpin tip={this.props.intl.formatMessage(messages.gettingTags)} spinning={this.props.loading}>
184
184
  <Search style={{ marginBottom: 8, width: '250px'}} placeholder={this.props.intl.formatMessage(messages.search)} onChange={this.onChange} />
185
- {this.props.moduleFilterEnabled ? <CapSelect getPopupContainer={(triggerNode) => triggerNode.parentNode} style={{width: '250px', marginBottom: '16px', minWidth: 'initial', display: 'inherit'}} onChange={this.props.onContextChange} defaultValue="All" options={options}>
185
+ {this.props.moduleFilterEnabled ? <CapSelect getPopupContainer={(triggerNode) => triggerNode.parentNode} style={{width: '250px', marginBottom: '16px', minWidth: 'initial', display: 'inherit'}} onChange={this.props.onContextChange} defaultValue={this.props.intl.formatMessage(messages.all)} options={options}>
186
186
  </CapSelect> : ''}
187
187
  <CapTree
188
188
  styling={{height: '350px', overflow: 'auto'}}
@@ -24,7 +24,7 @@ export default defineMessages({
24
24
  },
25
25
  "all": {
26
26
  id: 'creatives.componentsV2.CapTagList.all',
27
- defaultMessage: 'Dynamic days before expiry',
27
+ defaultMessage: 'All',
28
28
  },
29
29
  "outbound": {
30
30
  id: 'creatives.componentsV2.CapTagList.outbound',
@@ -68,7 +68,6 @@
68
68
  text-align: left;
69
69
  }
70
70
  .overflow-handle-preview {
71
- height: 430px;
72
71
  overflow-y: auto;
73
72
  }
74
73
  .overflow-handle-preview-outbound {
@@ -22,7 +22,6 @@ class WechatRichmediaTemplatePreview extends React.PureComponent { // eslint-dis
22
22
  const content = JSON.parse(JSON.stringify(mediaList));
23
23
  const mediaListLength = content.length;
24
24
  const contentData = content[0];
25
- console.log("archita medialist: ", mediaList, content, mediaListLength);
26
25
  previewMsg.push(
27
26
  <div className="image-container">
28
27
  <img alt="default" width="100%" height="102px" src={contentData.image_url} />
@@ -45,11 +44,10 @@ class WechatRichmediaTemplatePreview extends React.PureComponent { // eslint-dis
45
44
  previewMsg.push(
46
45
  <div className="additional-richmedia-container">
47
46
  <div><CapHeading type="label7" style={{width: '170px', top: '12px', position: 'relative'}}>{data.title}</CapHeading></div>
48
- <img alt="default" width="40px" height="40px" src={data.image_url} />
47
+ <img alt="default" width="34px" height="34px" src={data.image_url} />
49
48
  </div>
50
49
  );
51
50
  });
52
- console.log("archita return obj: ", previewMsg);
53
51
  return (
54
52
  <div className="richmedia-template">
55
53
  {previewMsg}
@@ -387,7 +387,6 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
387
387
 
388
388
  onAccountSelect(e) {
389
389
  const value = e.target.value;
390
- console.log("onAccountSelect", e, value);
391
390
  this.setState({selectedAccount: value}, () => {
392
391
  const params = {
393
392
  name: this.state.searchText,
@@ -532,18 +531,14 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
532
531
  };
533
532
  filterWechatTemplates = (templates) => {
534
533
  const { wechatFilter } = this.state;
535
- switch(wechatFilter) {
534
+ switch (wechatFilter) {
536
535
  case WECHAT_FILTERS.RICHMEDIA:
537
- return templates.filter(function (template) {
538
- return template.definition && template.definition.msgcontent.toUpperCase() === "RICH_MEDIA_WECHAT";
539
- });
536
+ return templates.filter((template) => template.definition && template.definition.msgcontent.toUpperCase() === "RICH_MEDIA_WECHAT");
540
537
  case WECHAT_FILTERS.MAPTEMPLATES:
541
- return templates.filter(function (template) {
542
- return !template.definition;
543
- });
538
+ return templates.filter((template) => !template.definition);
544
539
  default:
545
540
  return templates;
546
- };
541
+ }
547
542
  }
548
543
  getTemplateDataForGrid = ({templates, handlers, filterContent, channel, isLoading, loadingTip}) => {
549
544
  const currentChannel = channel.toUpperCase();
@@ -1585,7 +1580,6 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1585
1580
  <CapRadioCard
1586
1581
  className="select-account"
1587
1582
  onChange={this.onAccountSelect}
1588
- value={this.props.Templates.selectedWeChatAccount ? this.props.Templates.selectedWeChatAccount.name : undefined}
1589
1583
  panes={accountOptions}
1590
1584
  cardHeight="48px"
1591
1585
  cardWidth="276px"
@@ -1611,7 +1605,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1611
1605
  const isMobilePushChannel = channel === MOBILE_PUSH;
1612
1606
  return (<CapHeader
1613
1607
  title={<CapHeading type="h4">{isMobilePushChannel ? this.props.intl.formatMessage(messages.mobilepushAccount) : this.props.intl.formatMessage(messages.wechatAccount)}</CapHeading>}
1614
- description={<><CapHeading type="h3">{selectedAccount} {weCrmAccounts.length > 1 && <CapLink onClick={this.setAccountSelectionMode} style={{display: 'inline-block', position: 'relative', top: '3px'}} fontWeight="regular" fontSize="14px" title="change"/>} </CapHeading></>}
1608
+ description={<><CapHeading type="h3">{selectedAccount} {weCrmAccounts.length > 1 && <CapLink onClick={this.setAccountSelectionMode} style={{display: 'inline-block', position: 'relative', top: '3px'}} fontWeight="regular" fontSize="14px" title="change"/>} </CapHeading></>}
1615
1609
  size="regular"
1616
1610
  />);
1617
1611
  }
@@ -1649,6 +1643,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1649
1643
  //TODO -> uncomment the following line
1650
1644
  // const isfilterContentVisisble = !isEmpty(this.props.TemplatesList) || !isEmpty(this.state.searchText) || !isEmpty(this.props.Templates.templateError);
1651
1645
  const isfilterContentVisisble = true;
1646
+ const isWechatEmbedded = !this.props.isFullMode && channel.toUpperCase() === WECHAT;
1652
1647
  const filterContent = (( isfilterContentVisisble || [WECHAT, MOBILE_PUSH].includes(this.state.channel.toUpperCase())) && <div className="action-container">
1653
1648
  {isfilterContentVisisble && <CapInput.Search
1654
1649
  className="search-text"
@@ -1673,7 +1668,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1673
1668
  </CapRadio.CapRadioGroup>
1674
1669
  }
1675
1670
  <div style={{display: "flex", justifyContent: "space-between", alignItems: 'center'}}>
1676
- {isfilterContentVisisble && <CapButton
1671
+ {isfilterContentVisisble && !isWechatEmbedded && <CapButton
1677
1672
  type={"primary"}
1678
1673
  disabled={this.isCreateDisabled()}
1679
1674
  style={{marginLeft: '8px'}}
@@ -124,6 +124,9 @@
124
124
  cursor: not-allowed;
125
125
  color: #b3bac5;
126
126
  }
127
+ .cap-link-v2 {
128
+ max-height: 100%;
129
+ }
127
130
 
128
131
  }
129
132
  }
@@ -18,8 +18,6 @@ import cloneDeep from 'lodash/cloneDeep';
18
18
  import forEach from 'lodash/forEach';
19
19
  import isEqual from 'lodash/isEqual';
20
20
  import get from 'lodash/get';
21
-
22
- import { Menu } from 'antd';
23
21
  import { CapRow, CapColumn, CapButton, CapCard, CapSpin, CapInput, CapHeading, CapDivider, CapIcon, CapLink } from '@capillarytech/cap-ui-library';
24
22
  import makeSelectCreate, {makeSelectTemplates, getAssetDetails, getContentAssetDetails} from './selectors';
25
23
  import * as actions from './actions';
@@ -925,11 +923,11 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
925
923
  />
926
924
  <div className="wechat-container">
927
925
  <CapRow className="wechat-form-container">
928
- <CapColumn span={8}>
926
+ <CapColumn span={9}>
929
927
  {cardLayout}
930
928
  {!this.state.isIframe && contentMenu}
931
929
  </CapColumn>
932
- <CapColumn span={16}>
930
+ <CapColumn span={15}>
933
931
  { !isIframe && <CapInput
934
932
  label="Name of the template"
935
933
  value={this.state.templateName}
@@ -1,63 +0,0 @@
1
- import { defineMessages } from 'react-intl';
2
- export default defineMessages({
3
- "sms": {
4
- id: 'reon.components.Cap.sms',
5
- defaultMessage: 'SMS',
6
- },
7
- "wechat": {
8
- id: 'reon.components.Cap.wechat',
9
- defaultMessage: 'WeChat',
10
- },
11
- "gallery": {
12
- id: 'reon.components.Cap.gallery',
13
- defaultMessage: 'Gallery',
14
- },
15
- "creativesDashboard": {
16
- id: 'reon.components.Cap.creativesDashboard',
17
- defaultMessage: 'Creatives',
18
- },
19
- "creatives": {
20
- id: 'reon.components.Cap.creatives',
21
- defaultMessage: 'Creatives',
22
- },
23
- "campaigns": {
24
- id: 'reon.components.Cap.campaigns',
25
- defaultMessage: 'Campaigns',
26
- },
27
- "loyalty": {
28
- id: 'reon.components.Cap.loyalty',
29
- defaultMessage: 'Loyalty',
30
- },
31
- "member care": {
32
- id: 'reon.components.Cap.memberCare',
33
- defaultMessage: 'Member Care',
34
- },
35
- "workbench": {
36
- id: 'reon.components.Cap.Workbench',
37
- defaultMessage: 'WorkBench',
38
- },
39
- "store care": {
40
- id: 'reon.components.Cap.storeCare',
41
- defaultMessage: 'Store Care',
42
- },
43
- "store performance": {
44
- id: 'reon.components.Cap.storePerformance',
45
- defaultMessage: 'Store Performance',
46
- },
47
- "email": {
48
- id: 'reon.components.Cap.email',
49
- defaultMessage: 'Email',
50
- },
51
- "ebill": {
52
- id: 'reon.components.Cap.ebill',
53
- defaultMessage: 'Ebill',
54
- },
55
- "campaignsDashboard": {
56
- id: 'reon.components.campaignsDashboard',
57
- defaultMessage: 'Campaigns',
58
- },
59
- "campaignsHome": {
60
- id: 'reon.components.campaignsHome',
61
- defaultMessage: "Campaigns Home",
62
- },
63
- });
@@ -1,349 +0,0 @@
1
- /**
2
- *
3
- * DateFilter
4
- *
5
- */
6
-
7
- import PropTypes from 'prop-types';
8
-
9
- import React from 'react';
10
- // import styled from 'styled-components';
11
-
12
- import { FormattedMessage } from 'react-intl';
13
- import { Popup, Input, Button, Grid, Checkbox, Dimmer, Loader } from 'semantic-ui-react';
14
- import DateRange from 'components/DateRange';
15
- import moment from 'moment';
16
- import _ from 'lodash';
17
- import messages from './messages';
18
-
19
- class DateFilter extends React.Component { // eslint-disable-line react/prefer-stateless-function
20
- constructor(props) {
21
- super(props);
22
- this.state = {
23
- selectedDateRange: this.props.selectedDateRange,
24
- showChartCompareOptions: this.props.isCompareSelected,
25
- compareDateRange: this.props.compareDateRange,
26
- selectedDateText: '',
27
- isDateSelectorOpen: false,
28
- loading: this.props.loading,
29
- openCustomDatePicker: false,
30
- compareCustomDateSelected: false,
31
- customDateSelected: false,
32
- pastStateData: {},
33
- componentWidth: 270,
34
- };
35
- this.handleToggleDateSelector = this.handleToggleDateSelector.bind(this);
36
- this.renderDateSelector = this.renderDateSelector.bind(this);
37
- this.handleDateTypeClick = this.handleDateTypeClick.bind(this);
38
- this.printSelectedDate = this.printSelectedDate.bind(this);
39
- this.handleCancel = this.handleCancel.bind(this);
40
- this.handleChartCompareToggle = this.handleChartCompareToggle.bind(this);
41
- this.handleCompareDateChange = this.handleCompareDateChange.bind(this);
42
- this.handleCustomDatePickerCancel = this.handleCustomDatePickerCancel.bind(this);
43
- this.handleDatePickerApply = this.handleDatePickerApply.bind(this);
44
- this.compareDateValueSetting = this.compareDateValueSetting.bind(this);
45
- this.handleApply = this.handleApply.bind(this);
46
- this.restoreInitialState = this.restoreInitialState.bind(this);
47
- this.storeInitialState = this.storeInitialState.bind(this);
48
- }
49
-
50
- componentWillMount() {
51
- const dateText = this.printSelectedDate(this.state.selectedDateRange.startDate, this.state.selectedDateRange.endDate, this.state.selectedDateRange.dateType);
52
- this.setState({ selectedDateText: dateText });
53
- this.setState({ loading: false });
54
- this.storeInitialState();
55
- }
56
-
57
- componentDidMount() {
58
- }
59
-
60
- componentWillReceiveProps(nextProp) {
61
- this.setState({ selectedDateRange: nextProp.selectedDateRange, showChartCompareOptions: nextProp.isCompareSelected }, () => {
62
- let dateText = this.printSelectedDate(this.state.selectedDateRange.startDate, this.state.selectedDateRange.endDate, this.state.selectedDateRange.dateType);
63
- if (this.state.showChartCompareOptions) {
64
- this.setState({ componentWidth: 450 });
65
- dateText = `${dateText} vs ${this.printSelectedDate(this.state.compareDateRange.startDate, this.state.compareDateRange.endDate, this.state.compareDateRange.dateType, true)}`;
66
- } else {
67
- this.setState({ componentWidth: 270 });
68
- }
69
- this.setState({ selectedDateText: dateText });
70
- });
71
- this.storeInitialState();
72
- }
73
-
74
- storeInitialState() {
75
- const stateData = _.cloneDeep(this.state);
76
- const tmpState = {
77
- selectedDateRange: stateData.selectedDateRange,
78
- showChartCompareOptions: stateData.showChartCompareOptions,
79
- compareDateRange: stateData.compareDateRange,
80
- };
81
- this.setState({ pastStateData: tmpState });
82
- }
83
-
84
- handleToggleDateSelector() {
85
- this.setState({ isDateSelectorOpen: !this.state.isDateSelectorOpen });
86
- }
87
-
88
- handleDateTypeClick(specifier) {
89
- const date = this.state.selectedDateRange;
90
- if (specifier !== 'custom') {
91
- date.dateType = specifier;
92
- if (specifier === 'week') {
93
- date.startDate = moment().isoWeekday(1);
94
- } else {
95
- date.startDate = moment().startOf(specifier);
96
- }
97
- date.endDate = moment();
98
- this.setState({ selectedDateRange: date }, () => {
99
- if (this.state.showChartCompareOptions) {
100
- this.compareDateValueSetting(specifier);
101
- }
102
- });
103
- } else {
104
- this.setState({ customDateSelected: true, openCustomDatePicker: true });
105
- }
106
- }
107
-
108
- printSelectedDate(startDate, endDate, specifier, isCompare) {
109
- let specifierType = '';
110
- if (isCompare) {
111
- if (specifier === 'week') {
112
- specifierType = 'Previous Week';
113
- } else if (specifier === 'month') {
114
- specifierType = 'Previous Month';
115
- } else if (specifier === 'year') {
116
- specifierType = 'Previous Year';
117
- } else {
118
- specifierType = 'Custom';
119
- }
120
- }
121
- if (!isCompare) {
122
- if (specifier === 'week') {
123
- specifierType = 'WTD';
124
- } else if (specifier === 'month') {
125
- specifierType = 'MTD';
126
- } else if (specifier === 'year') {
127
- specifierType = 'YTD';
128
- } else {
129
- specifierType = 'Custom';
130
- }
131
- }
132
-
133
- let tmpDateString = '';
134
- if (moment(startDate).year() === moment(endDate).year()) {
135
- tmpDateString = `${specifierType} ( ${moment(startDate).format('MMM D').toString()} - ${moment(endDate).format('MMM D YYYY').toString()} )`;
136
- } else {
137
- tmpDateString = `${specifierType} ( ${moment(startDate).format('MMM D YYYY').toString()} - ${moment(endDate).format('MMM D YYYY').toString()} )`;
138
- }
139
- return tmpDateString;
140
- }
141
-
142
- handleCancel() {
143
- this.setState({ isDateSelectorOpen: false });
144
- if (this.props.handleCancel !== undefined) {
145
- this.props.handleCancel();
146
- }
147
-
148
- // Need to improve this function
149
- this.restoreInitialState();
150
- }
151
-
152
- compareDateValueSetting(specifier) {
153
- const dateRange = (this.state.compareDateRange) ? this.state.compareDateRange : _.cloneDeep(this.state.selectedDateRange);
154
- if (specifier === 'week') {
155
- dateRange.startDate = moment(this.state.selectedDateRange.startDate).subtract(7, 'days');
156
- dateRange.endDate = moment(this.state.selectedDateRange.endDate).subtract(7, 'days');
157
- dateRange.dateType = specifier;
158
- } else if (specifier === 'month') {
159
- dateRange.startDate = moment(this.state.selectedDateRange.startDate).subtract(1, 'months');
160
- dateRange.endDate = moment(this.state.selectedDateRange.endDate).subtract(1, 'months');
161
- dateRange.dateType = specifier;
162
- } else if (specifier === 'year' || specifier === 'custom') {
163
- dateRange.startDate = moment(this.state.selectedDateRange.startDate).subtract(1, 'years');
164
- dateRange.endDate = moment(this.state.selectedDateRange.endDate).subtract(1, 'years');
165
- dateRange.dateType = specifier;
166
- }
167
- this.setState({ compareDateRange: dateRange });
168
- }
169
-
170
- handleChartCompareToggle() {
171
- this.setState({ showChartCompareOptions: !this.state.showChartCompareOptions });
172
- const compareDateType = (this.state.compareDateRange) ? this.state.compareDateRange.dateType : this.state.selectedDateRange.dateType;
173
- this.compareDateValueSetting(compareDateType);
174
- }
175
-
176
- handleCompareDateChange(specifier) {
177
- if (specifier === 'custom') {
178
- this.setState({ compareCustomDateSelected: true, openCustomDatePicker: true });
179
- } else {
180
- this.compareDateValueSetting(specifier);
181
- }
182
- }
183
-
184
- handleCustomDatePickerCancel(e) {
185
- if (e) {
186
- e.preventDefault();
187
- }
188
- this.setState({ customDateSelected: false });
189
- this.setState({ compareCustomDateSelected: false });
190
- this.setState({ openCustomDatePicker: false });
191
- }
192
-
193
- handleDatePickerApply(startDate, endDate, dateType) {
194
- if (this.state.customDateSelected) {
195
- const dateRange = _.cloneDeep(this.state.selectedDateRange);
196
- dateRange.startDate = startDate;
197
- dateRange.endDate = endDate;
198
- dateRange.dateType = dateType;
199
- this.setState({ selectedDateRange: dateRange });
200
- this.setState({ customDateSelected: false });
201
- } else {
202
- const dateRange = _.cloneDeep(this.state.compareDateRange);
203
- dateRange.startDate = startDate;
204
- dateRange.endDate = endDate;
205
- dateRange.dateType = dateType;
206
- this.setState({ compareDateRange: dateRange });
207
- this.setState({ compareCustomDateSelected: false });
208
- }
209
- }
210
-
211
- handleApply() {
212
- let dateText = this.printSelectedDate(this.state.selectedDateRange.startDate, this.state.selectedDateRange.endDate, this.state.selectedDateRange.dateType);
213
- if (this.state.showChartCompareOptions) {
214
- this.setState({ componentWidth: 450 });
215
- dateText = `${dateText} vs ${this.printSelectedDate(this.state.compareDateRange.startDate, this.state.compareDateRange.endDate, this.state.compareDateRange.dateType, true)}`;
216
- } else {
217
- this.setState({ componentWidth: 270 });
218
- }
219
- this.setState({ selectedDateText: dateText });
220
- this.setState({ isDateSelectorOpen: false });
221
- this.props.handleApply(this.state.selectedDateRange, this.state.showChartCompareOptions, this.state.compareDateRange);
222
- }
223
-
224
- restoreInitialState() {
225
- this.setState({ selectedDateRange: this.state.pastStateData.selectedDateRange });
226
- this.setState({ compareDateRange: this.state.pastStateData.compareDateRange, showChartCompareOptions: this.state.pastStateData.showChartCompareOptions });
227
- }
228
-
229
- renderDateSelector() {
230
- const dateType = this.state.selectedDateRange.dateType;
231
- return (
232
- <div className="date-filter-wrapper">
233
- { this.state.loading ? <Dimmer active inverted className={'hide'}><Loader inverted><FormattedMessage {...messages.loaderMessage} /> </Loader></Dimmer> :
234
- <Grid>
235
- <Grid.Row className={this.state.openCustomDatePicker ? 'hide' : ''}>
236
- <Grid.Column width={16}>
237
- <Button.Group fluid className="btn-group till-date">
238
- <Button className={dateType === 'week' ? 'active' : ''} onClick={() => this.handleDateTypeClick('week')}>WTD</Button>
239
- <Button className={dateType === 'month' ? 'active' : ''} onClick={() => this.handleDateTypeClick('month')}>MTD</Button>
240
- <Button className={dateType === 'year' ? 'active' : ''} onClick={() => this.handleDateTypeClick('year')}>YTD</Button>
241
- <Button className={dateType === 'custom' ? 'active' : ''} onClick={() => this.handleDateTypeClick('custom')}>Custom</Button>
242
- </Button.Group>
243
- </Grid.Column>
244
- <Grid.Column width={16} className="selectedDateText">
245
- {this.printSelectedDate(this.state.selectedDateRange.startDate, this.state.selectedDateRange.endDate, this.state.selectedDateRange.dateType)}
246
- {dateType === 'custom' ? <span className="editSelectedDate" onClick={() => this.handleDateTypeClick('custom')}><FormattedMessage {...messages.editText} /></span> : ''}
247
- </Grid.Column>
248
- </Grid.Row>
249
- <Grid.Row className={this.state.openCustomDatePicker ? 'hide' : 'compareDateToggle'}>
250
- <Grid.Column width={16}>
251
- <Checkbox className={!this.props.compareMode ? 'hide' : 'dateCompareCheckbox'} checked={this.state.showChartCompareOptions} label="Compare" onClick={this.handleChartCompareToggle} />
252
- </Grid.Column>
253
- </Grid.Row>
254
- { this.state.showChartCompareOptions ?
255
- <Grid.Row className={!this.state.openCustomDatePicker ? '' : 'hide'}>
256
- <Grid.Column width={16}>
257
- <Button.Group fluid className="btn-group till-date">
258
- {dateType !== 'week' ? '' :
259
- <Button className={this.state.compareDateRange.dateType !== 'week' ? '' : 'active'} onClick={() => this.handleCompareDateChange('week')}>Previous Week</Button> }
260
- {dateType !== 'month' ? '' :
261
- <Button className={this.state.compareDateRange.dateType !== 'month' ? '' : 'active'} onClick={() => this.handleCompareDateChange('month')}>Previous Month</Button>}
262
- <Button className={this.state.compareDateRange.dateType === 'year' ? 'active' : ''} onClick={() => this.handleCompareDateChange('year')}>Previous Year</Button>
263
- <Button className={this.state.compareDateRange.dateType === 'custom' ? 'active' : ''} onClick={() => this.handleCompareDateChange('custom')}>Custom</Button>
264
- </Button.Group>
265
- </Grid.Column>
266
- <Grid.Column width={16} className="selectedDateText">
267
- {this.printSelectedDate(this.state.compareDateRange.startDate, this.state.compareDateRange.endDate, this.state.compareDateRange.dateType, true)}
268
- {this.state.compareDateRange.dateType === 'custom' ? <span className="editSelectedDate" onClick={() => this.handleCompareDateChange('custom')}><FormattedMessage {...messages.editText} /></span> : ''}
269
- </Grid.Column>
270
- </Grid.Row>
271
- : ''
272
- }
273
- <Grid.Row className={this.state.openCustomDatePicker ? 'hide' : ''}>
274
- <Grid.Column width={16}>
275
- <Button primary onClick={this.handleApply}>Apply</Button>
276
- <Button basic onClick={this.handleCancel}>Cancel</Button>
277
- </Grid.Column>
278
- </Grid.Row>
279
-
280
- { this.state.customDateSelected ?
281
- <Grid.Row className={!this.state.openCustomDatePicker ? 'hide' : ''}>
282
- <Grid.Column className="selectDateRangeTitle" width={16}>
283
- <a href="" className="backButton" onClick={this.handleCustomDatePickerCancel}><i className="material-icons">keyboard_backspace</i></a>
284
- <span className="dateRangeTitle">Select Date Range</span>
285
- </Grid.Column>
286
- <Grid.Column width={16} className="dateRangeWrapper">
287
- <DateRange prevSelectedDate={this.state.selectedDateRange} handleDatePickerApply={this.handleDatePickerApply} handleDatePickerCancel={this.handleCustomDatePickerCancel} />
288
- </Grid.Column>
289
- {/* { this.state.showChartCompareOptions ? <Grid.Column width={16}>
290
- {this.printSelectedDate(this.props.selectedDateRange.startDate, this.props.selectedDateRange.endDate, this.state.selectedDateRange.dateType)} vs
291
- </Grid.Column> : '' } */}
292
- </Grid.Row> : ''
293
- }
294
-
295
- { this.state.compareCustomDateSelected ?
296
- <Grid.Row className={!this.state.openCustomDatePicker ? 'hide' : ''}>
297
- <Grid.Column width={16}>
298
- <a href="" className="backButton" onClick={this.handleCustomDatePickerCancel}><i className="material-icons">keyboard_backspace</i></a>
299
- <span className="dateRangeTitle">Select Date Range</span>
300
- </Grid.Column>
301
- <Grid.Column width={16}>
302
- {this.printSelectedDate(this.state.selectedDateRange.startDate, this.state.selectedDateRange.endDate, this.state.selectedDateRange.dateType)} vs
303
- </Grid.Column>
304
- <Grid.Column width={16} className="dateRangeWrapper">
305
- <DateRange prevSelectedDate={this.state.compareDateRange} handleDatePickerApply={this.handleDatePickerApply} handleDatePickerCancel={this.handleCustomDatePickerCancel} />
306
- </Grid.Column>
307
- </Grid.Row> : ''
308
- }
309
- </Grid>}
310
- </div>
311
- );
312
- }
313
-
314
- render() {
315
- const { isDateSelectorOpen } = this.state;
316
- // const loading = this.state.loading;
317
- return (
318
- <span>
319
- <Popup
320
- trigger={
321
- <Input
322
- id="compareDate"
323
- style={{ width: `${this.state.componentWidth}px` }}
324
- readOnly
325
- icon="caret down"
326
- value={this.state.selectedDateText}
327
- />
328
- }
329
- content={this.renderDateSelector()}
330
- on="click"
331
- open={isDateSelectorOpen}
332
- onOpen={this.handleToggleDateSelector}
333
- />
334
- </span>
335
- );
336
- }
337
- }
338
-
339
- DateFilter.propTypes = {
340
- selectedDateRange: PropTypes.object.isRequired,
341
- compareMode: PropTypes.bool,
342
- compareDateRange: PropTypes.object,
343
- isCompareSelected: PropTypes.bool,
344
- handleApply: PropTypes.func.isRequired,
345
- handleCancel: PropTypes.func,
346
- loading: PropTypes.bool,
347
- };
348
-
349
- export default DateFilter;
@@ -1,17 +0,0 @@
1
- /*
2
- * DateFilter Messages
3
- *
4
- * This contains all the text for the DateFilter component.
5
- */
6
- import { defineMessages } from 'react-intl';
7
-
8
- export default defineMessages({
9
- loaderMessage: {
10
- id: 'reon.components.DateFilter.loaderMessage',
11
- defaultMessage: 'Fetching Data',
12
- },
13
- editText: {
14
- id: 'reon.components.DateFilter.editText',
15
- defaultMessage: 'Edit',
16
- },
17
- });
@@ -1,15 +0,0 @@
1
- // import React from 'react';
2
- // import { shallow } from 'enzyme';
3
- //
4
- // import moment from 'moment';
5
- // import DateFilter from '../index';
6
-
7
- // describe('<DateFilter />', () => {
8
- // it('Expect to have unit tests specified', () => {
9
- // expect(true).toEqual(false);
10
- // });
11
- // it('Expect to have selectDateRange Prop', () => {
12
- // const wrapper = shallow(<DateFilter selectedDateRange={moment()} />);
13
- // expect(wrapper.props().selectedDateRange).toEqual(moment());
14
- // });
15
- // });