@plusscommunities/pluss-newsletter-web-sharing 1.4.37 → 1.4.38
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/dist/index.cjs.js +127 -55
- package/dist/index.esm.js +127 -55
- package/dist/index.umd.js +130 -58
- package/package.json +1 -1
- package/src/screens/Newsletter/ListNewsletterEntries.js +110 -34
- package/src/screens/Newsletter/NewsHub.js +1 -16
package/dist/index.cjs.js
CHANGED
|
@@ -12,9 +12,9 @@ var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
|
12
12
|
var React = require('react');
|
|
13
13
|
var reactRedux = require('react-redux');
|
|
14
14
|
var _ = require('lodash');
|
|
15
|
-
var moment = require('moment');
|
|
16
15
|
var FontAwesome = require('react-fontawesome');
|
|
17
16
|
var PlussCore = require('@plusscommunities/pluss-core-web');
|
|
17
|
+
var moment = require('moment');
|
|
18
18
|
var reactBootstrap = require('react-bootstrap');
|
|
19
19
|
var reactRouterDom = require('react-router-dom');
|
|
20
20
|
var reactRouter = require('react-router');
|
|
@@ -57,9 +57,9 @@ var _getPrototypeOf__default = /*#__PURE__*/_interopDefaultLegacy(_getPrototypeO
|
|
|
57
57
|
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
58
58
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
59
59
|
var ___default = /*#__PURE__*/_interopDefaultLegacy(_);
|
|
60
|
-
var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
|
|
61
60
|
var FontAwesome__default = /*#__PURE__*/_interopDefaultLegacy(FontAwesome);
|
|
62
61
|
var PlussCore__namespace = /*#__PURE__*/_interopNamespace(PlussCore);
|
|
62
|
+
var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
|
|
63
63
|
var _toConsumableArray__default = /*#__PURE__*/_interopDefaultLegacy(_toConsumableArray);
|
|
64
64
|
var $__default = /*#__PURE__*/_interopDefaultLegacy($);
|
|
65
65
|
var _asyncToGenerator__default = /*#__PURE__*/_interopDefaultLegacy(_asyncToGenerator);
|
|
@@ -711,7 +711,7 @@ var COLOUR_BRANDING_MAIN = Colours.COLOUR_BRANDING_MAIN;
|
|
|
711
711
|
var COLOUR_BRANDING_OFF = Colours.COLOUR_BRANDING_OFF;
|
|
712
712
|
Colours.COLOUR_BRANDING_ACTION;
|
|
713
713
|
var COLOUR_BRANDING_APP = Colours.COLOUR_BRANDING_APP;
|
|
714
|
-
Colours.TEXT_LIGHT;
|
|
714
|
+
var TEXT_LIGHT = Colours.TEXT_LIGHT;
|
|
715
715
|
var hexToRGBAstring = Colours.hexToRGBAstring; // Misc
|
|
716
716
|
|
|
717
717
|
var hideChat = Helper$1.hideChat;
|
|
@@ -722,6 +722,7 @@ var Text = Components$1.Text;
|
|
|
722
722
|
function _createSuper$g(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$g(); return function _createSuperInternal() { var Super = _getPrototypeOf__default['default'](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default['default'](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default['default'](this, result); }; }
|
|
723
723
|
|
|
724
724
|
function _isNativeReflectConstruct$g() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
725
|
+
var PAGE_SIZE = 100;
|
|
725
726
|
|
|
726
727
|
var ListNewsletter$1 = /*#__PURE__*/function (_Component) {
|
|
727
728
|
_inherits__default['default'](ListNewsletter, _Component);
|
|
@@ -741,12 +742,43 @@ var ListNewsletter$1 = /*#__PURE__*/function (_Component) {
|
|
|
741
742
|
|
|
742
743
|
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "state", {
|
|
743
744
|
newsletterEntries: [],
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
sortDesc:
|
|
747
|
-
// if true, sort descending rather than ascending
|
|
745
|
+
// Date column sorts on the real UnixTimestamp; defaults to descending so newest posts appear first.
|
|
746
|
+
sortColumn: 'UnixTimestamp',
|
|
747
|
+
sortDesc: true,
|
|
748
748
|
now: moment__default['default'].utc(),
|
|
749
|
-
|
|
749
|
+
search: '',
|
|
750
|
+
startIndex: 0,
|
|
751
|
+
endIndex: PAGE_SIZE
|
|
752
|
+
});
|
|
753
|
+
|
|
754
|
+
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "onSearchChange", function (e) {
|
|
755
|
+
_this.setState({
|
|
756
|
+
search: e.target.value,
|
|
757
|
+
startIndex: 0,
|
|
758
|
+
endIndex: PAGE_SIZE
|
|
759
|
+
});
|
|
760
|
+
});
|
|
761
|
+
|
|
762
|
+
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "prevPage", function () {
|
|
763
|
+
if (_this.state.startIndex === 0) {
|
|
764
|
+
return;
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
_this.setState({
|
|
768
|
+
startIndex: _this.state.startIndex - PAGE_SIZE,
|
|
769
|
+
endIndex: Math.ceil(_this.state.endIndex / PAGE_SIZE) * PAGE_SIZE - PAGE_SIZE
|
|
770
|
+
});
|
|
771
|
+
});
|
|
772
|
+
|
|
773
|
+
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "nextPage", function (filteredCount) {
|
|
774
|
+
if (_this.state.startIndex + PAGE_SIZE >= filteredCount) {
|
|
775
|
+
return;
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
_this.setState({
|
|
779
|
+
startIndex: _this.state.startIndex + PAGE_SIZE,
|
|
780
|
+
endIndex: Math.ceil(_this.state.endIndex / PAGE_SIZE) * PAGE_SIZE + PAGE_SIZE
|
|
781
|
+
});
|
|
750
782
|
});
|
|
751
783
|
|
|
752
784
|
return _this;
|
|
@@ -791,15 +823,24 @@ var ListNewsletter$1 = /*#__PURE__*/function (_Component) {
|
|
|
791
823
|
value: function sortByCol(col) {
|
|
792
824
|
if (this.state.sortColumn === col) {
|
|
793
825
|
this.setState({
|
|
794
|
-
sortDesc: !this.state.sortDesc
|
|
826
|
+
sortDesc: !this.state.sortDesc,
|
|
827
|
+
startIndex: 0,
|
|
828
|
+
endIndex: PAGE_SIZE
|
|
795
829
|
});
|
|
796
830
|
} else {
|
|
797
831
|
this.setState({
|
|
798
832
|
sortColumn: col,
|
|
799
|
-
sortDesc: false
|
|
833
|
+
sortDesc: false,
|
|
834
|
+
startIndex: 0,
|
|
835
|
+
endIndex: PAGE_SIZE
|
|
800
836
|
});
|
|
801
837
|
}
|
|
802
838
|
}
|
|
839
|
+
}, {
|
|
840
|
+
key: "getPaginationText",
|
|
841
|
+
value: function getPaginationText(filteredCount) {
|
|
842
|
+
return "".concat(Math.min(this.state.startIndex + 1, filteredCount), "-").concat(Math.min(this.state.endIndex, filteredCount), "/").concat(filteredCount);
|
|
843
|
+
}
|
|
803
844
|
}, {
|
|
804
845
|
key: "removeNewsletterEntry",
|
|
805
846
|
value: function removeNewsletterEntry(newsletter) {
|
|
@@ -819,22 +860,6 @@ var ListNewsletter$1 = /*#__PURE__*/function (_Component) {
|
|
|
819
860
|
value: function renderNewsletter(source) {
|
|
820
861
|
var _this4 = this;
|
|
821
862
|
|
|
822
|
-
// let source = _.sortBy(this.state.newsletterEntries, this.state.sortColumn);
|
|
823
|
-
// if (this.state.sortDesc) {
|
|
824
|
-
// source.reverse();
|
|
825
|
-
// }
|
|
826
|
-
// source = _.filter(source, (ev) => {
|
|
827
|
-
// if (!ev) {
|
|
828
|
-
// return false
|
|
829
|
-
// }
|
|
830
|
-
// return true;
|
|
831
|
-
// });
|
|
832
|
-
// if (this.props.onlyFuture) {
|
|
833
|
-
// const nownow = moment().startOf('month');
|
|
834
|
-
// source = _.filter(source, (ev) => {
|
|
835
|
-
// return nownow.isSameOrBefore(moment.utc(ev.UnixTimestamp).local());
|
|
836
|
-
// });
|
|
837
|
-
// }
|
|
838
863
|
return source.map(function (ev) {
|
|
839
864
|
if (ev != null) {
|
|
840
865
|
return /*#__PURE__*/React__default['default'].createElement("tr", {
|
|
@@ -923,15 +948,15 @@ var ListNewsletter$1 = /*#__PURE__*/function (_Component) {
|
|
|
923
948
|
condensed: true,
|
|
924
949
|
hover: true
|
|
925
950
|
}, /*#__PURE__*/React__default['default'].createElement("thead", null, /*#__PURE__*/React__default['default'].createElement("tr", null, /*#__PURE__*/React__default['default'].createElement("th", {
|
|
926
|
-
className: "".concat(this.sortIsActive('
|
|
951
|
+
className: "".concat(this.sortIsActive('UnixTimestamp')),
|
|
927
952
|
style: {
|
|
928
953
|
cursor: 'pointer',
|
|
929
954
|
width: 140
|
|
930
955
|
},
|
|
931
956
|
onClick: function onClick() {
|
|
932
|
-
_this5.sortByCol('
|
|
957
|
+
_this5.sortByCol('UnixTimestamp');
|
|
933
958
|
}
|
|
934
|
-
}, "Date published", this.renderSort('
|
|
959
|
+
}, "Date published", this.renderSort('UnixTimestamp')), /*#__PURE__*/React__default['default'].createElement("th", {
|
|
935
960
|
className: "".concat(this.sortIsActive('Title')),
|
|
936
961
|
style: {
|
|
937
962
|
cursor: 'pointer'
|
|
@@ -969,9 +994,57 @@ var ListNewsletter$1 = /*#__PURE__*/function (_Component) {
|
|
|
969
994
|
type: "h3"
|
|
970
995
|
}, values.textThereAreNoNews)));
|
|
971
996
|
}
|
|
997
|
+
}, {
|
|
998
|
+
key: "renderPager",
|
|
999
|
+
value: function renderPager(filteredCount) {
|
|
1000
|
+
var _this6 = this;
|
|
1001
|
+
|
|
1002
|
+
if (filteredCount <= PAGE_SIZE) {
|
|
1003
|
+
return null;
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
1007
|
+
className: "paginationContainer",
|
|
1008
|
+
style: {
|
|
1009
|
+
margin: '8px 0'
|
|
1010
|
+
}
|
|
1011
|
+
}, /*#__PURE__*/React__default['default'].createElement(FontAwesome__default['default'], {
|
|
1012
|
+
className: "pagination__left",
|
|
1013
|
+
name: "chevron-left",
|
|
1014
|
+
style: {
|
|
1015
|
+
cursor: 'pointer',
|
|
1016
|
+
fontSize: 20,
|
|
1017
|
+
color: TEXT_LIGHT
|
|
1018
|
+
},
|
|
1019
|
+
onClick: this.prevPage
|
|
1020
|
+
}), /*#__PURE__*/React__default['default'].createElement("p", {
|
|
1021
|
+
className: "pagination__text",
|
|
1022
|
+
style: {
|
|
1023
|
+
display: 'inline-block',
|
|
1024
|
+
margin: 0,
|
|
1025
|
+
padding: '0 16px',
|
|
1026
|
+
minWidth: 120,
|
|
1027
|
+
textAlign: 'center',
|
|
1028
|
+
color: TEXT_LIGHT
|
|
1029
|
+
}
|
|
1030
|
+
}, this.getPaginationText(filteredCount)), /*#__PURE__*/React__default['default'].createElement(FontAwesome__default['default'], {
|
|
1031
|
+
className: "pagination__right",
|
|
1032
|
+
name: "chevron-right",
|
|
1033
|
+
style: {
|
|
1034
|
+
cursor: 'pointer',
|
|
1035
|
+
fontSize: 20,
|
|
1036
|
+
color: TEXT_LIGHT
|
|
1037
|
+
},
|
|
1038
|
+
onClick: function onClick() {
|
|
1039
|
+
return _this6.nextPage(filteredCount);
|
|
1040
|
+
}
|
|
1041
|
+
}));
|
|
1042
|
+
}
|
|
972
1043
|
}, {
|
|
973
1044
|
key: "renderContent",
|
|
974
1045
|
value: function renderContent() {
|
|
1046
|
+
var _this7 = this;
|
|
1047
|
+
|
|
975
1048
|
var source = ___default['default'].sortBy(this.state.newsletterEntries, this.state.sortColumn);
|
|
976
1049
|
|
|
977
1050
|
if (this.state.sortDesc) {
|
|
@@ -985,20 +1058,25 @@ var ListNewsletter$1 = /*#__PURE__*/function (_Component) {
|
|
|
985
1058
|
|
|
986
1059
|
return true;
|
|
987
1060
|
});
|
|
1061
|
+
var search = this.state.search;
|
|
988
1062
|
|
|
989
|
-
if (
|
|
990
|
-
var
|
|
1063
|
+
if (!___default['default'].isEmpty(search)) {
|
|
1064
|
+
var lowSearch = search.toLowerCase();
|
|
991
1065
|
source = ___default['default'].filter(source, function (ev) {
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
1066
|
+
if (!ev.Title) {
|
|
1067
|
+
return false;
|
|
1068
|
+
}
|
|
995
1069
|
|
|
1070
|
+
return ev.Title.toLowerCase().indexOf(lowSearch) > -1;
|
|
1071
|
+
});
|
|
1072
|
+
} // Total matching the search/sort BEFORE the page slice — drives the pager text.
|
|
996
1073
|
|
|
997
|
-
if (___default['default'].isEmpty(source)) {
|
|
998
|
-
return this.renderEmpty();
|
|
999
|
-
}
|
|
1000
1074
|
|
|
1001
|
-
|
|
1075
|
+
var filteredCount = source.length;
|
|
1076
|
+
source = ___default['default'].filter(source, function (ev, i) {
|
|
1077
|
+
return i >= _this7.state.startIndex && i < _this7.state.endIndex;
|
|
1078
|
+
});
|
|
1079
|
+
return /*#__PURE__*/React__default['default'].createElement("div", null, ___default['default'].isEmpty(source) ? this.renderEmpty() : this.renderView(source), this.renderPager(filteredCount));
|
|
1002
1080
|
}
|
|
1003
1081
|
}, {
|
|
1004
1082
|
key: "render",
|
|
@@ -1007,7 +1085,16 @@ var ListNewsletter$1 = /*#__PURE__*/function (_Component) {
|
|
|
1007
1085
|
style: {
|
|
1008
1086
|
minWidth: '100%'
|
|
1009
1087
|
}
|
|
1010
|
-
},
|
|
1088
|
+
}, /*#__PURE__*/React__default['default'].createElement(reactBootstrap.FormControl, {
|
|
1089
|
+
type: "text",
|
|
1090
|
+
placeholder: "Search news",
|
|
1091
|
+
value: this.state.search,
|
|
1092
|
+
onChange: this.onSearchChange,
|
|
1093
|
+
style: {
|
|
1094
|
+
marginBottom: 16,
|
|
1095
|
+
maxWidth: 360
|
|
1096
|
+
}
|
|
1097
|
+
}), this.renderContent());
|
|
1011
1098
|
}
|
|
1012
1099
|
}]);
|
|
1013
1100
|
|
|
@@ -1988,9 +2075,6 @@ var NewsHub = /*#__PURE__*/function (_Component) {
|
|
|
1988
2075
|
loadingSubmissions: false,
|
|
1989
2076
|
submissionEntries: [],
|
|
1990
2077
|
allList: [],
|
|
1991
|
-
thisMonth: [],
|
|
1992
|
-
now: moment__default['default'].utc(),
|
|
1993
|
-
onlyFuture: true,
|
|
1994
2078
|
search: ''
|
|
1995
2079
|
};
|
|
1996
2080
|
return _this;
|
|
@@ -2015,18 +2099,8 @@ var NewsHub = /*#__PURE__*/function (_Component) {
|
|
|
2015
2099
|
}, {
|
|
2016
2100
|
key: "updateProps",
|
|
2017
2101
|
value: function updateProps(props) {
|
|
2018
|
-
var thisMonth = [];
|
|
2019
|
-
var nownow = moment__default['default']().startOf('month');
|
|
2020
|
-
props.news.forEach(function (rep) {
|
|
2021
|
-
var isThisMonth = nownow.isSameOrBefore(moment__default['default'].utc(rep.UnixTimestamp).local());
|
|
2022
|
-
|
|
2023
|
-
if (isThisMonth) {
|
|
2024
|
-
thisMonth.push(rep);
|
|
2025
|
-
}
|
|
2026
|
-
});
|
|
2027
2102
|
this.setState({
|
|
2028
2103
|
allList: props.news,
|
|
2029
|
-
thisMonth: thisMonth,
|
|
2030
2104
|
submissionEntries: props.submissions
|
|
2031
2105
|
});
|
|
2032
2106
|
}
|
|
@@ -2230,9 +2304,7 @@ var NewsHub = /*#__PURE__*/function (_Component) {
|
|
|
2230
2304
|
return /*#__PURE__*/React__default['default'].createElement(AvailableNews, null);
|
|
2231
2305
|
}
|
|
2232
2306
|
|
|
2233
|
-
return /*#__PURE__*/React__default['default'].createElement(ListNewsletterEntries,
|
|
2234
|
-
onlyFuture: this.state.selectedSection === 'thisMonth'
|
|
2235
|
-
});
|
|
2307
|
+
return /*#__PURE__*/React__default['default'].createElement(ListNewsletterEntries, null);
|
|
2236
2308
|
}
|
|
2237
2309
|
}, {
|
|
2238
2310
|
key: "render",
|
package/dist/index.esm.js
CHANGED
|
@@ -8,10 +8,10 @@ import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
|
8
8
|
import React, { Component, useState, useEffect } from 'react';
|
|
9
9
|
import { connect } from 'react-redux';
|
|
10
10
|
import _ from 'lodash';
|
|
11
|
-
import moment from 'moment';
|
|
12
11
|
import FontAwesome from 'react-fontawesome';
|
|
13
12
|
import * as PlussCore from '@plusscommunities/pluss-core-web';
|
|
14
|
-
import
|
|
13
|
+
import moment from 'moment';
|
|
14
|
+
import { Table, FormControl, FormGroup } from 'react-bootstrap';
|
|
15
15
|
import { Link } from 'react-router-dom';
|
|
16
16
|
import { withRouter } from 'react-router';
|
|
17
17
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
@@ -667,7 +667,7 @@ var COLOUR_BRANDING_MAIN = Colours.COLOUR_BRANDING_MAIN;
|
|
|
667
667
|
var COLOUR_BRANDING_OFF = Colours.COLOUR_BRANDING_OFF;
|
|
668
668
|
Colours.COLOUR_BRANDING_ACTION;
|
|
669
669
|
var COLOUR_BRANDING_APP = Colours.COLOUR_BRANDING_APP;
|
|
670
|
-
Colours.TEXT_LIGHT;
|
|
670
|
+
var TEXT_LIGHT = Colours.TEXT_LIGHT;
|
|
671
671
|
var hexToRGBAstring = Colours.hexToRGBAstring; // Misc
|
|
672
672
|
|
|
673
673
|
var hideChat = Helper$1.hideChat;
|
|
@@ -678,6 +678,7 @@ var Text = Components$1.Text;
|
|
|
678
678
|
function _createSuper$g(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$g(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
679
679
|
|
|
680
680
|
function _isNativeReflectConstruct$g() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
681
|
+
var PAGE_SIZE = 100;
|
|
681
682
|
|
|
682
683
|
var ListNewsletter$1 = /*#__PURE__*/function (_Component) {
|
|
683
684
|
_inherits(ListNewsletter, _Component);
|
|
@@ -697,12 +698,43 @@ var ListNewsletter$1 = /*#__PURE__*/function (_Component) {
|
|
|
697
698
|
|
|
698
699
|
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
699
700
|
newsletterEntries: [],
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
sortDesc:
|
|
703
|
-
// if true, sort descending rather than ascending
|
|
701
|
+
// Date column sorts on the real UnixTimestamp; defaults to descending so newest posts appear first.
|
|
702
|
+
sortColumn: 'UnixTimestamp',
|
|
703
|
+
sortDesc: true,
|
|
704
704
|
now: moment.utc(),
|
|
705
|
-
|
|
705
|
+
search: '',
|
|
706
|
+
startIndex: 0,
|
|
707
|
+
endIndex: PAGE_SIZE
|
|
708
|
+
});
|
|
709
|
+
|
|
710
|
+
_defineProperty(_assertThisInitialized(_this), "onSearchChange", function (e) {
|
|
711
|
+
_this.setState({
|
|
712
|
+
search: e.target.value,
|
|
713
|
+
startIndex: 0,
|
|
714
|
+
endIndex: PAGE_SIZE
|
|
715
|
+
});
|
|
716
|
+
});
|
|
717
|
+
|
|
718
|
+
_defineProperty(_assertThisInitialized(_this), "prevPage", function () {
|
|
719
|
+
if (_this.state.startIndex === 0) {
|
|
720
|
+
return;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
_this.setState({
|
|
724
|
+
startIndex: _this.state.startIndex - PAGE_SIZE,
|
|
725
|
+
endIndex: Math.ceil(_this.state.endIndex / PAGE_SIZE) * PAGE_SIZE - PAGE_SIZE
|
|
726
|
+
});
|
|
727
|
+
});
|
|
728
|
+
|
|
729
|
+
_defineProperty(_assertThisInitialized(_this), "nextPage", function (filteredCount) {
|
|
730
|
+
if (_this.state.startIndex + PAGE_SIZE >= filteredCount) {
|
|
731
|
+
return;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
_this.setState({
|
|
735
|
+
startIndex: _this.state.startIndex + PAGE_SIZE,
|
|
736
|
+
endIndex: Math.ceil(_this.state.endIndex / PAGE_SIZE) * PAGE_SIZE + PAGE_SIZE
|
|
737
|
+
});
|
|
706
738
|
});
|
|
707
739
|
|
|
708
740
|
return _this;
|
|
@@ -747,15 +779,24 @@ var ListNewsletter$1 = /*#__PURE__*/function (_Component) {
|
|
|
747
779
|
value: function sortByCol(col) {
|
|
748
780
|
if (this.state.sortColumn === col) {
|
|
749
781
|
this.setState({
|
|
750
|
-
sortDesc: !this.state.sortDesc
|
|
782
|
+
sortDesc: !this.state.sortDesc,
|
|
783
|
+
startIndex: 0,
|
|
784
|
+
endIndex: PAGE_SIZE
|
|
751
785
|
});
|
|
752
786
|
} else {
|
|
753
787
|
this.setState({
|
|
754
788
|
sortColumn: col,
|
|
755
|
-
sortDesc: false
|
|
789
|
+
sortDesc: false,
|
|
790
|
+
startIndex: 0,
|
|
791
|
+
endIndex: PAGE_SIZE
|
|
756
792
|
});
|
|
757
793
|
}
|
|
758
794
|
}
|
|
795
|
+
}, {
|
|
796
|
+
key: "getPaginationText",
|
|
797
|
+
value: function getPaginationText(filteredCount) {
|
|
798
|
+
return "".concat(Math.min(this.state.startIndex + 1, filteredCount), "-").concat(Math.min(this.state.endIndex, filteredCount), "/").concat(filteredCount);
|
|
799
|
+
}
|
|
759
800
|
}, {
|
|
760
801
|
key: "removeNewsletterEntry",
|
|
761
802
|
value: function removeNewsletterEntry(newsletter) {
|
|
@@ -775,22 +816,6 @@ var ListNewsletter$1 = /*#__PURE__*/function (_Component) {
|
|
|
775
816
|
value: function renderNewsletter(source) {
|
|
776
817
|
var _this4 = this;
|
|
777
818
|
|
|
778
|
-
// let source = _.sortBy(this.state.newsletterEntries, this.state.sortColumn);
|
|
779
|
-
// if (this.state.sortDesc) {
|
|
780
|
-
// source.reverse();
|
|
781
|
-
// }
|
|
782
|
-
// source = _.filter(source, (ev) => {
|
|
783
|
-
// if (!ev) {
|
|
784
|
-
// return false
|
|
785
|
-
// }
|
|
786
|
-
// return true;
|
|
787
|
-
// });
|
|
788
|
-
// if (this.props.onlyFuture) {
|
|
789
|
-
// const nownow = moment().startOf('month');
|
|
790
|
-
// source = _.filter(source, (ev) => {
|
|
791
|
-
// return nownow.isSameOrBefore(moment.utc(ev.UnixTimestamp).local());
|
|
792
|
-
// });
|
|
793
|
-
// }
|
|
794
819
|
return source.map(function (ev) {
|
|
795
820
|
if (ev != null) {
|
|
796
821
|
return /*#__PURE__*/React.createElement("tr", {
|
|
@@ -879,15 +904,15 @@ var ListNewsletter$1 = /*#__PURE__*/function (_Component) {
|
|
|
879
904
|
condensed: true,
|
|
880
905
|
hover: true
|
|
881
906
|
}, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", {
|
|
882
|
-
className: "".concat(this.sortIsActive('
|
|
907
|
+
className: "".concat(this.sortIsActive('UnixTimestamp')),
|
|
883
908
|
style: {
|
|
884
909
|
cursor: 'pointer',
|
|
885
910
|
width: 140
|
|
886
911
|
},
|
|
887
912
|
onClick: function onClick() {
|
|
888
|
-
_this5.sortByCol('
|
|
913
|
+
_this5.sortByCol('UnixTimestamp');
|
|
889
914
|
}
|
|
890
|
-
}, "Date published", this.renderSort('
|
|
915
|
+
}, "Date published", this.renderSort('UnixTimestamp')), /*#__PURE__*/React.createElement("th", {
|
|
891
916
|
className: "".concat(this.sortIsActive('Title')),
|
|
892
917
|
style: {
|
|
893
918
|
cursor: 'pointer'
|
|
@@ -925,9 +950,57 @@ var ListNewsletter$1 = /*#__PURE__*/function (_Component) {
|
|
|
925
950
|
type: "h3"
|
|
926
951
|
}, values.textThereAreNoNews)));
|
|
927
952
|
}
|
|
953
|
+
}, {
|
|
954
|
+
key: "renderPager",
|
|
955
|
+
value: function renderPager(filteredCount) {
|
|
956
|
+
var _this6 = this;
|
|
957
|
+
|
|
958
|
+
if (filteredCount <= PAGE_SIZE) {
|
|
959
|
+
return null;
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
963
|
+
className: "paginationContainer",
|
|
964
|
+
style: {
|
|
965
|
+
margin: '8px 0'
|
|
966
|
+
}
|
|
967
|
+
}, /*#__PURE__*/React.createElement(FontAwesome, {
|
|
968
|
+
className: "pagination__left",
|
|
969
|
+
name: "chevron-left",
|
|
970
|
+
style: {
|
|
971
|
+
cursor: 'pointer',
|
|
972
|
+
fontSize: 20,
|
|
973
|
+
color: TEXT_LIGHT
|
|
974
|
+
},
|
|
975
|
+
onClick: this.prevPage
|
|
976
|
+
}), /*#__PURE__*/React.createElement("p", {
|
|
977
|
+
className: "pagination__text",
|
|
978
|
+
style: {
|
|
979
|
+
display: 'inline-block',
|
|
980
|
+
margin: 0,
|
|
981
|
+
padding: '0 16px',
|
|
982
|
+
minWidth: 120,
|
|
983
|
+
textAlign: 'center',
|
|
984
|
+
color: TEXT_LIGHT
|
|
985
|
+
}
|
|
986
|
+
}, this.getPaginationText(filteredCount)), /*#__PURE__*/React.createElement(FontAwesome, {
|
|
987
|
+
className: "pagination__right",
|
|
988
|
+
name: "chevron-right",
|
|
989
|
+
style: {
|
|
990
|
+
cursor: 'pointer',
|
|
991
|
+
fontSize: 20,
|
|
992
|
+
color: TEXT_LIGHT
|
|
993
|
+
},
|
|
994
|
+
onClick: function onClick() {
|
|
995
|
+
return _this6.nextPage(filteredCount);
|
|
996
|
+
}
|
|
997
|
+
}));
|
|
998
|
+
}
|
|
928
999
|
}, {
|
|
929
1000
|
key: "renderContent",
|
|
930
1001
|
value: function renderContent() {
|
|
1002
|
+
var _this7 = this;
|
|
1003
|
+
|
|
931
1004
|
var source = _.sortBy(this.state.newsletterEntries, this.state.sortColumn);
|
|
932
1005
|
|
|
933
1006
|
if (this.state.sortDesc) {
|
|
@@ -941,20 +1014,25 @@ var ListNewsletter$1 = /*#__PURE__*/function (_Component) {
|
|
|
941
1014
|
|
|
942
1015
|
return true;
|
|
943
1016
|
});
|
|
1017
|
+
var search = this.state.search;
|
|
944
1018
|
|
|
945
|
-
if (
|
|
946
|
-
var
|
|
1019
|
+
if (!_.isEmpty(search)) {
|
|
1020
|
+
var lowSearch = search.toLowerCase();
|
|
947
1021
|
source = _.filter(source, function (ev) {
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
1022
|
+
if (!ev.Title) {
|
|
1023
|
+
return false;
|
|
1024
|
+
}
|
|
951
1025
|
|
|
1026
|
+
return ev.Title.toLowerCase().indexOf(lowSearch) > -1;
|
|
1027
|
+
});
|
|
1028
|
+
} // Total matching the search/sort BEFORE the page slice — drives the pager text.
|
|
952
1029
|
|
|
953
|
-
if (_.isEmpty(source)) {
|
|
954
|
-
return this.renderEmpty();
|
|
955
|
-
}
|
|
956
1030
|
|
|
957
|
-
|
|
1031
|
+
var filteredCount = source.length;
|
|
1032
|
+
source = _.filter(source, function (ev, i) {
|
|
1033
|
+
return i >= _this7.state.startIndex && i < _this7.state.endIndex;
|
|
1034
|
+
});
|
|
1035
|
+
return /*#__PURE__*/React.createElement("div", null, _.isEmpty(source) ? this.renderEmpty() : this.renderView(source), this.renderPager(filteredCount));
|
|
958
1036
|
}
|
|
959
1037
|
}, {
|
|
960
1038
|
key: "render",
|
|
@@ -963,7 +1041,16 @@ var ListNewsletter$1 = /*#__PURE__*/function (_Component) {
|
|
|
963
1041
|
style: {
|
|
964
1042
|
minWidth: '100%'
|
|
965
1043
|
}
|
|
966
|
-
},
|
|
1044
|
+
}, /*#__PURE__*/React.createElement(FormControl, {
|
|
1045
|
+
type: "text",
|
|
1046
|
+
placeholder: "Search news",
|
|
1047
|
+
value: this.state.search,
|
|
1048
|
+
onChange: this.onSearchChange,
|
|
1049
|
+
style: {
|
|
1050
|
+
marginBottom: 16,
|
|
1051
|
+
maxWidth: 360
|
|
1052
|
+
}
|
|
1053
|
+
}), this.renderContent());
|
|
967
1054
|
}
|
|
968
1055
|
}]);
|
|
969
1056
|
|
|
@@ -1944,9 +2031,6 @@ var NewsHub = /*#__PURE__*/function (_Component) {
|
|
|
1944
2031
|
loadingSubmissions: false,
|
|
1945
2032
|
submissionEntries: [],
|
|
1946
2033
|
allList: [],
|
|
1947
|
-
thisMonth: [],
|
|
1948
|
-
now: moment.utc(),
|
|
1949
|
-
onlyFuture: true,
|
|
1950
2034
|
search: ''
|
|
1951
2035
|
};
|
|
1952
2036
|
return _this;
|
|
@@ -1971,18 +2055,8 @@ var NewsHub = /*#__PURE__*/function (_Component) {
|
|
|
1971
2055
|
}, {
|
|
1972
2056
|
key: "updateProps",
|
|
1973
2057
|
value: function updateProps(props) {
|
|
1974
|
-
var thisMonth = [];
|
|
1975
|
-
var nownow = moment().startOf('month');
|
|
1976
|
-
props.news.forEach(function (rep) {
|
|
1977
|
-
var isThisMonth = nownow.isSameOrBefore(moment.utc(rep.UnixTimestamp).local());
|
|
1978
|
-
|
|
1979
|
-
if (isThisMonth) {
|
|
1980
|
-
thisMonth.push(rep);
|
|
1981
|
-
}
|
|
1982
|
-
});
|
|
1983
2058
|
this.setState({
|
|
1984
2059
|
allList: props.news,
|
|
1985
|
-
thisMonth: thisMonth,
|
|
1986
2060
|
submissionEntries: props.submissions
|
|
1987
2061
|
});
|
|
1988
2062
|
}
|
|
@@ -2186,9 +2260,7 @@ var NewsHub = /*#__PURE__*/function (_Component) {
|
|
|
2186
2260
|
return /*#__PURE__*/React.createElement(AvailableNews, null);
|
|
2187
2261
|
}
|
|
2188
2262
|
|
|
2189
|
-
return /*#__PURE__*/React.createElement(ListNewsletterEntries,
|
|
2190
|
-
onlyFuture: this.state.selectedSection === 'thisMonth'
|
|
2191
|
-
});
|
|
2263
|
+
return /*#__PURE__*/React.createElement(ListNewsletterEntries, null);
|
|
2192
2264
|
}
|
|
2193
2265
|
}, {
|
|
2194
2266
|
key: "render",
|
package/dist/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@babel/runtime/helpers/classCallCheck'), require('@babel/runtime/helpers/createClass'), require('@babel/runtime/helpers/assertThisInitialized'), require('@babel/runtime/helpers/inherits'), require('@babel/runtime/helpers/possibleConstructorReturn'), require('@babel/runtime/helpers/getPrototypeOf'), require('@babel/runtime/helpers/defineProperty'), require('react'), require('react-redux'), require('lodash'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', '@babel/runtime/helpers/classCallCheck', '@babel/runtime/helpers/createClass', '@babel/runtime/helpers/assertThisInitialized', '@babel/runtime/helpers/inherits', '@babel/runtime/helpers/possibleConstructorReturn', '@babel/runtime/helpers/getPrototypeOf', '@babel/runtime/helpers/defineProperty', 'react', 'react-redux', 'lodash', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['@plusscommunities/pluss-newsletter-web'] = {}, global._classCallCheck, global._createClass, global._assertThisInitialized, global._inherits, global._possibleConstructorReturn, global._getPrototypeOf, global._defineProperty, global.React, global.reactRedux, global._, global.
|
|
5
|
-
}(this, (function (exports, _classCallCheck, _createClass, _assertThisInitialized, _inherits, _possibleConstructorReturn, _getPrototypeOf, _defineProperty, React, reactRedux, _,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@babel/runtime/helpers/classCallCheck'), require('@babel/runtime/helpers/createClass'), require('@babel/runtime/helpers/assertThisInitialized'), require('@babel/runtime/helpers/inherits'), require('@babel/runtime/helpers/possibleConstructorReturn'), require('@babel/runtime/helpers/getPrototypeOf'), require('@babel/runtime/helpers/defineProperty'), require('react'), require('react-redux'), require('lodash'), require('react-fontawesome'), require('@plusscommunities/pluss-core-web'), require('moment'), require('react-bootstrap'), require('react-router-dom'), require('react-router'), require('@babel/runtime/helpers/toConsumableArray'), require('jquery'), require('uuid'), require('@babel/runtime/helpers/asyncToGenerator'), require('@babel/runtime/helpers/slicedToArray'), require('@babel/runtime/regenerator'), require('@fortawesome/free-solid-svg-icons')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', '@babel/runtime/helpers/classCallCheck', '@babel/runtime/helpers/createClass', '@babel/runtime/helpers/assertThisInitialized', '@babel/runtime/helpers/inherits', '@babel/runtime/helpers/possibleConstructorReturn', '@babel/runtime/helpers/getPrototypeOf', '@babel/runtime/helpers/defineProperty', 'react', 'react-redux', 'lodash', 'react-fontawesome', '@plusscommunities/pluss-core-web', 'moment', 'react-bootstrap', 'react-router-dom', 'react-router', '@babel/runtime/helpers/toConsumableArray', 'jquery', 'uuid', '@babel/runtime/helpers/asyncToGenerator', '@babel/runtime/helpers/slicedToArray', '@babel/runtime/regenerator', '@fortawesome/free-solid-svg-icons'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['@plusscommunities/pluss-newsletter-web'] = {}, global._classCallCheck, global._createClass, global._assertThisInitialized, global._inherits, global._possibleConstructorReturn, global._getPrototypeOf, global._defineProperty, global.React, global.reactRedux, global._, global.FontAwesome, global.PlussCore, global.moment, global.reactBootstrap, global.reactRouterDom, global.reactRouter, global._toConsumableArray, global.$, global.uuid, global._asyncToGenerator, global._slicedToArray, global._regeneratorRuntime, global.freeSolidSvgIcons));
|
|
5
|
+
}(this, (function (exports, _classCallCheck, _createClass, _assertThisInitialized, _inherits, _possibleConstructorReturn, _getPrototypeOf, _defineProperty, React, reactRedux, _, FontAwesome, PlussCore, moment, reactBootstrap, reactRouterDom, reactRouter, _toConsumableArray, $, uuid, _asyncToGenerator, _slicedToArray, _regeneratorRuntime, freeSolidSvgIcons) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
36
36
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
37
37
|
var ___default = /*#__PURE__*/_interopDefaultLegacy(_);
|
|
38
|
-
var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
|
|
39
38
|
var FontAwesome__default = /*#__PURE__*/_interopDefaultLegacy(FontAwesome);
|
|
40
39
|
var PlussCore__namespace = /*#__PURE__*/_interopNamespace(PlussCore);
|
|
40
|
+
var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
|
|
41
41
|
var _toConsumableArray__default = /*#__PURE__*/_interopDefaultLegacy(_toConsumableArray);
|
|
42
42
|
var $__default = /*#__PURE__*/_interopDefaultLegacy($);
|
|
43
43
|
var _asyncToGenerator__default = /*#__PURE__*/_interopDefaultLegacy(_asyncToGenerator);
|
|
@@ -689,7 +689,7 @@
|
|
|
689
689
|
var COLOUR_BRANDING_OFF = Colours.COLOUR_BRANDING_OFF;
|
|
690
690
|
Colours.COLOUR_BRANDING_ACTION;
|
|
691
691
|
var COLOUR_BRANDING_APP = Colours.COLOUR_BRANDING_APP;
|
|
692
|
-
Colours.TEXT_LIGHT;
|
|
692
|
+
var TEXT_LIGHT = Colours.TEXT_LIGHT;
|
|
693
693
|
var hexToRGBAstring = Colours.hexToRGBAstring; // Misc
|
|
694
694
|
|
|
695
695
|
var hideChat = Helper$1.hideChat;
|
|
@@ -700,6 +700,7 @@
|
|
|
700
700
|
function _createSuper$g(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$g(); return function _createSuperInternal() { var Super = _getPrototypeOf__default['default'](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default['default'](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default['default'](this, result); }; }
|
|
701
701
|
|
|
702
702
|
function _isNativeReflectConstruct$g() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
703
|
+
var PAGE_SIZE = 100;
|
|
703
704
|
|
|
704
705
|
var ListNewsletter$1 = /*#__PURE__*/function (_Component) {
|
|
705
706
|
_inherits__default['default'](ListNewsletter, _Component);
|
|
@@ -719,12 +720,43 @@
|
|
|
719
720
|
|
|
720
721
|
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "state", {
|
|
721
722
|
newsletterEntries: [],
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
sortDesc:
|
|
725
|
-
// if true, sort descending rather than ascending
|
|
723
|
+
// Date column sorts on the real UnixTimestamp; defaults to descending so newest posts appear first.
|
|
724
|
+
sortColumn: 'UnixTimestamp',
|
|
725
|
+
sortDesc: true,
|
|
726
726
|
now: moment__default['default'].utc(),
|
|
727
|
-
|
|
727
|
+
search: '',
|
|
728
|
+
startIndex: 0,
|
|
729
|
+
endIndex: PAGE_SIZE
|
|
730
|
+
});
|
|
731
|
+
|
|
732
|
+
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "onSearchChange", function (e) {
|
|
733
|
+
_this.setState({
|
|
734
|
+
search: e.target.value,
|
|
735
|
+
startIndex: 0,
|
|
736
|
+
endIndex: PAGE_SIZE
|
|
737
|
+
});
|
|
738
|
+
});
|
|
739
|
+
|
|
740
|
+
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "prevPage", function () {
|
|
741
|
+
if (_this.state.startIndex === 0) {
|
|
742
|
+
return;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
_this.setState({
|
|
746
|
+
startIndex: _this.state.startIndex - PAGE_SIZE,
|
|
747
|
+
endIndex: Math.ceil(_this.state.endIndex / PAGE_SIZE) * PAGE_SIZE - PAGE_SIZE
|
|
748
|
+
});
|
|
749
|
+
});
|
|
750
|
+
|
|
751
|
+
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "nextPage", function (filteredCount) {
|
|
752
|
+
if (_this.state.startIndex + PAGE_SIZE >= filteredCount) {
|
|
753
|
+
return;
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
_this.setState({
|
|
757
|
+
startIndex: _this.state.startIndex + PAGE_SIZE,
|
|
758
|
+
endIndex: Math.ceil(_this.state.endIndex / PAGE_SIZE) * PAGE_SIZE + PAGE_SIZE
|
|
759
|
+
});
|
|
728
760
|
});
|
|
729
761
|
|
|
730
762
|
return _this;
|
|
@@ -769,15 +801,24 @@
|
|
|
769
801
|
value: function sortByCol(col) {
|
|
770
802
|
if (this.state.sortColumn === col) {
|
|
771
803
|
this.setState({
|
|
772
|
-
sortDesc: !this.state.sortDesc
|
|
804
|
+
sortDesc: !this.state.sortDesc,
|
|
805
|
+
startIndex: 0,
|
|
806
|
+
endIndex: PAGE_SIZE
|
|
773
807
|
});
|
|
774
808
|
} else {
|
|
775
809
|
this.setState({
|
|
776
810
|
sortColumn: col,
|
|
777
|
-
sortDesc: false
|
|
811
|
+
sortDesc: false,
|
|
812
|
+
startIndex: 0,
|
|
813
|
+
endIndex: PAGE_SIZE
|
|
778
814
|
});
|
|
779
815
|
}
|
|
780
816
|
}
|
|
817
|
+
}, {
|
|
818
|
+
key: "getPaginationText",
|
|
819
|
+
value: function getPaginationText(filteredCount) {
|
|
820
|
+
return "".concat(Math.min(this.state.startIndex + 1, filteredCount), "-").concat(Math.min(this.state.endIndex, filteredCount), "/").concat(filteredCount);
|
|
821
|
+
}
|
|
781
822
|
}, {
|
|
782
823
|
key: "removeNewsletterEntry",
|
|
783
824
|
value: function removeNewsletterEntry(newsletter) {
|
|
@@ -797,22 +838,6 @@
|
|
|
797
838
|
value: function renderNewsletter(source) {
|
|
798
839
|
var _this4 = this;
|
|
799
840
|
|
|
800
|
-
// let source = _.sortBy(this.state.newsletterEntries, this.state.sortColumn);
|
|
801
|
-
// if (this.state.sortDesc) {
|
|
802
|
-
// source.reverse();
|
|
803
|
-
// }
|
|
804
|
-
// source = _.filter(source, (ev) => {
|
|
805
|
-
// if (!ev) {
|
|
806
|
-
// return false
|
|
807
|
-
// }
|
|
808
|
-
// return true;
|
|
809
|
-
// });
|
|
810
|
-
// if (this.props.onlyFuture) {
|
|
811
|
-
// const nownow = moment().startOf('month');
|
|
812
|
-
// source = _.filter(source, (ev) => {
|
|
813
|
-
// return nownow.isSameOrBefore(moment.utc(ev.UnixTimestamp).local());
|
|
814
|
-
// });
|
|
815
|
-
// }
|
|
816
841
|
return source.map(function (ev) {
|
|
817
842
|
if (ev != null) {
|
|
818
843
|
return /*#__PURE__*/React__default['default'].createElement("tr", {
|
|
@@ -901,15 +926,15 @@
|
|
|
901
926
|
condensed: true,
|
|
902
927
|
hover: true
|
|
903
928
|
}, /*#__PURE__*/React__default['default'].createElement("thead", null, /*#__PURE__*/React__default['default'].createElement("tr", null, /*#__PURE__*/React__default['default'].createElement("th", {
|
|
904
|
-
className: "".concat(this.sortIsActive('
|
|
929
|
+
className: "".concat(this.sortIsActive('UnixTimestamp')),
|
|
905
930
|
style: {
|
|
906
931
|
cursor: 'pointer',
|
|
907
932
|
width: 140
|
|
908
933
|
},
|
|
909
934
|
onClick: function onClick() {
|
|
910
|
-
_this5.sortByCol('
|
|
935
|
+
_this5.sortByCol('UnixTimestamp');
|
|
911
936
|
}
|
|
912
|
-
}, "Date published", this.renderSort('
|
|
937
|
+
}, "Date published", this.renderSort('UnixTimestamp')), /*#__PURE__*/React__default['default'].createElement("th", {
|
|
913
938
|
className: "".concat(this.sortIsActive('Title')),
|
|
914
939
|
style: {
|
|
915
940
|
cursor: 'pointer'
|
|
@@ -947,9 +972,57 @@
|
|
|
947
972
|
type: "h3"
|
|
948
973
|
}, values.textThereAreNoNews)));
|
|
949
974
|
}
|
|
975
|
+
}, {
|
|
976
|
+
key: "renderPager",
|
|
977
|
+
value: function renderPager(filteredCount) {
|
|
978
|
+
var _this6 = this;
|
|
979
|
+
|
|
980
|
+
if (filteredCount <= PAGE_SIZE) {
|
|
981
|
+
return null;
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
985
|
+
className: "paginationContainer",
|
|
986
|
+
style: {
|
|
987
|
+
margin: '8px 0'
|
|
988
|
+
}
|
|
989
|
+
}, /*#__PURE__*/React__default['default'].createElement(FontAwesome__default['default'], {
|
|
990
|
+
className: "pagination__left",
|
|
991
|
+
name: "chevron-left",
|
|
992
|
+
style: {
|
|
993
|
+
cursor: 'pointer',
|
|
994
|
+
fontSize: 20,
|
|
995
|
+
color: TEXT_LIGHT
|
|
996
|
+
},
|
|
997
|
+
onClick: this.prevPage
|
|
998
|
+
}), /*#__PURE__*/React__default['default'].createElement("p", {
|
|
999
|
+
className: "pagination__text",
|
|
1000
|
+
style: {
|
|
1001
|
+
display: 'inline-block',
|
|
1002
|
+
margin: 0,
|
|
1003
|
+
padding: '0 16px',
|
|
1004
|
+
minWidth: 120,
|
|
1005
|
+
textAlign: 'center',
|
|
1006
|
+
color: TEXT_LIGHT
|
|
1007
|
+
}
|
|
1008
|
+
}, this.getPaginationText(filteredCount)), /*#__PURE__*/React__default['default'].createElement(FontAwesome__default['default'], {
|
|
1009
|
+
className: "pagination__right",
|
|
1010
|
+
name: "chevron-right",
|
|
1011
|
+
style: {
|
|
1012
|
+
cursor: 'pointer',
|
|
1013
|
+
fontSize: 20,
|
|
1014
|
+
color: TEXT_LIGHT
|
|
1015
|
+
},
|
|
1016
|
+
onClick: function onClick() {
|
|
1017
|
+
return _this6.nextPage(filteredCount);
|
|
1018
|
+
}
|
|
1019
|
+
}));
|
|
1020
|
+
}
|
|
950
1021
|
}, {
|
|
951
1022
|
key: "renderContent",
|
|
952
1023
|
value: function renderContent() {
|
|
1024
|
+
var _this7 = this;
|
|
1025
|
+
|
|
953
1026
|
var source = ___default['default'].sortBy(this.state.newsletterEntries, this.state.sortColumn);
|
|
954
1027
|
|
|
955
1028
|
if (this.state.sortDesc) {
|
|
@@ -963,20 +1036,25 @@
|
|
|
963
1036
|
|
|
964
1037
|
return true;
|
|
965
1038
|
});
|
|
1039
|
+
var search = this.state.search;
|
|
966
1040
|
|
|
967
|
-
if (
|
|
968
|
-
var
|
|
1041
|
+
if (!___default['default'].isEmpty(search)) {
|
|
1042
|
+
var lowSearch = search.toLowerCase();
|
|
969
1043
|
source = ___default['default'].filter(source, function (ev) {
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
1044
|
+
if (!ev.Title) {
|
|
1045
|
+
return false;
|
|
1046
|
+
}
|
|
973
1047
|
|
|
1048
|
+
return ev.Title.toLowerCase().indexOf(lowSearch) > -1;
|
|
1049
|
+
});
|
|
1050
|
+
} // Total matching the search/sort BEFORE the page slice — drives the pager text.
|
|
974
1051
|
|
|
975
|
-
if (___default['default'].isEmpty(source)) {
|
|
976
|
-
return this.renderEmpty();
|
|
977
|
-
}
|
|
978
1052
|
|
|
979
|
-
|
|
1053
|
+
var filteredCount = source.length;
|
|
1054
|
+
source = ___default['default'].filter(source, function (ev, i) {
|
|
1055
|
+
return i >= _this7.state.startIndex && i < _this7.state.endIndex;
|
|
1056
|
+
});
|
|
1057
|
+
return /*#__PURE__*/React__default['default'].createElement("div", null, ___default['default'].isEmpty(source) ? this.renderEmpty() : this.renderView(source), this.renderPager(filteredCount));
|
|
980
1058
|
}
|
|
981
1059
|
}, {
|
|
982
1060
|
key: "render",
|
|
@@ -985,7 +1063,16 @@
|
|
|
985
1063
|
style: {
|
|
986
1064
|
minWidth: '100%'
|
|
987
1065
|
}
|
|
988
|
-
},
|
|
1066
|
+
}, /*#__PURE__*/React__default['default'].createElement(reactBootstrap.FormControl, {
|
|
1067
|
+
type: "text",
|
|
1068
|
+
placeholder: "Search news",
|
|
1069
|
+
value: this.state.search,
|
|
1070
|
+
onChange: this.onSearchChange,
|
|
1071
|
+
style: {
|
|
1072
|
+
marginBottom: 16,
|
|
1073
|
+
maxWidth: 360
|
|
1074
|
+
}
|
|
1075
|
+
}), this.renderContent());
|
|
989
1076
|
}
|
|
990
1077
|
}]);
|
|
991
1078
|
|
|
@@ -1966,9 +2053,6 @@
|
|
|
1966
2053
|
loadingSubmissions: false,
|
|
1967
2054
|
submissionEntries: [],
|
|
1968
2055
|
allList: [],
|
|
1969
|
-
thisMonth: [],
|
|
1970
|
-
now: moment__default['default'].utc(),
|
|
1971
|
-
onlyFuture: true,
|
|
1972
2056
|
search: ''
|
|
1973
2057
|
};
|
|
1974
2058
|
return _this;
|
|
@@ -1993,18 +2077,8 @@
|
|
|
1993
2077
|
}, {
|
|
1994
2078
|
key: "updateProps",
|
|
1995
2079
|
value: function updateProps(props) {
|
|
1996
|
-
var thisMonth = [];
|
|
1997
|
-
var nownow = moment__default['default']().startOf('month');
|
|
1998
|
-
props.news.forEach(function (rep) {
|
|
1999
|
-
var isThisMonth = nownow.isSameOrBefore(moment__default['default'].utc(rep.UnixTimestamp).local());
|
|
2000
|
-
|
|
2001
|
-
if (isThisMonth) {
|
|
2002
|
-
thisMonth.push(rep);
|
|
2003
|
-
}
|
|
2004
|
-
});
|
|
2005
2080
|
this.setState({
|
|
2006
2081
|
allList: props.news,
|
|
2007
|
-
thisMonth: thisMonth,
|
|
2008
2082
|
submissionEntries: props.submissions
|
|
2009
2083
|
});
|
|
2010
2084
|
}
|
|
@@ -2208,9 +2282,7 @@
|
|
|
2208
2282
|
return /*#__PURE__*/React__default['default'].createElement(AvailableNews, null);
|
|
2209
2283
|
}
|
|
2210
2284
|
|
|
2211
|
-
return /*#__PURE__*/React__default['default'].createElement(ListNewsletterEntries,
|
|
2212
|
-
onlyFuture: this.state.selectedSection === 'thisMonth'
|
|
2213
|
-
});
|
|
2285
|
+
return /*#__PURE__*/React__default['default'].createElement(ListNewsletterEntries, null);
|
|
2214
2286
|
}
|
|
2215
2287
|
}, {
|
|
2216
2288
|
key: "render",
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { Component } from 'react';
|
|
2
|
-
import { Table } from 'react-bootstrap';
|
|
2
|
+
import { Table, FormControl } from 'react-bootstrap';
|
|
3
3
|
import { connect } from 'react-redux';
|
|
4
4
|
import moment from 'moment';
|
|
5
5
|
import _ from 'lodash';
|
|
@@ -9,15 +9,21 @@ import { newsLoaded, removeNews } from '../../actions';
|
|
|
9
9
|
import { newsletterActions } from '../../webapi';
|
|
10
10
|
import { checkLoggedIn, validateAccess } from '../../session';
|
|
11
11
|
import { Text } from '../../components/text';
|
|
12
|
+
import { TEXT_LIGHT } from '../../js';
|
|
12
13
|
import { values } from '../../values.config';
|
|
13
14
|
|
|
15
|
+
const PAGE_SIZE = 100;
|
|
16
|
+
|
|
14
17
|
class ListNewsletter extends Component {
|
|
15
18
|
state = {
|
|
16
19
|
newsletterEntries: [],
|
|
17
|
-
|
|
18
|
-
|
|
20
|
+
// Date column sorts on the real UnixTimestamp; defaults to descending so newest posts appear first.
|
|
21
|
+
sortColumn: 'UnixTimestamp',
|
|
22
|
+
sortDesc: true,
|
|
19
23
|
now: moment.utc(),
|
|
20
|
-
|
|
24
|
+
search: '',
|
|
25
|
+
startIndex: 0,
|
|
26
|
+
endIndex: PAGE_SIZE,
|
|
21
27
|
};
|
|
22
28
|
|
|
23
29
|
UNSAFE_componentWillMount() {
|
|
@@ -51,15 +57,51 @@ class ListNewsletter extends Component {
|
|
|
51
57
|
if (this.state.sortColumn === col) {
|
|
52
58
|
this.setState({
|
|
53
59
|
sortDesc: !this.state.sortDesc,
|
|
60
|
+
startIndex: 0,
|
|
61
|
+
endIndex: PAGE_SIZE,
|
|
54
62
|
});
|
|
55
63
|
} else {
|
|
56
64
|
this.setState({
|
|
57
65
|
sortColumn: col,
|
|
58
66
|
sortDesc: false,
|
|
67
|
+
startIndex: 0,
|
|
68
|
+
endIndex: PAGE_SIZE,
|
|
59
69
|
});
|
|
60
70
|
}
|
|
61
71
|
}
|
|
62
72
|
|
|
73
|
+
onSearchChange = (e) => {
|
|
74
|
+
this.setState({
|
|
75
|
+
search: e.target.value,
|
|
76
|
+
startIndex: 0,
|
|
77
|
+
endIndex: PAGE_SIZE,
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
prevPage = () => {
|
|
82
|
+
if (this.state.startIndex === 0) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
this.setState({
|
|
86
|
+
startIndex: this.state.startIndex - PAGE_SIZE,
|
|
87
|
+
endIndex: Math.ceil(this.state.endIndex / PAGE_SIZE) * PAGE_SIZE - PAGE_SIZE,
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
nextPage = (filteredCount) => {
|
|
92
|
+
if (this.state.startIndex + PAGE_SIZE >= filteredCount) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
this.setState({
|
|
96
|
+
startIndex: this.state.startIndex + PAGE_SIZE,
|
|
97
|
+
endIndex: Math.ceil(this.state.endIndex / PAGE_SIZE) * PAGE_SIZE + PAGE_SIZE,
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
getPaginationText(filteredCount) {
|
|
102
|
+
return `${Math.min(this.state.startIndex + 1, filteredCount)}-${Math.min(this.state.endIndex, filteredCount)}/${filteredCount}`;
|
|
103
|
+
}
|
|
104
|
+
|
|
63
105
|
removeNewsletterEntry(newsletter) {
|
|
64
106
|
if (window.confirm(values.textAreYouSureYouWantToDelete)) {
|
|
65
107
|
this.props.removeNews(newsletter.RowId);
|
|
@@ -75,24 +117,6 @@ class ListNewsletter extends Component {
|
|
|
75
117
|
}
|
|
76
118
|
|
|
77
119
|
renderNewsletter(source) {
|
|
78
|
-
// let source = _.sortBy(this.state.newsletterEntries, this.state.sortColumn);
|
|
79
|
-
// if (this.state.sortDesc) {
|
|
80
|
-
// source.reverse();
|
|
81
|
-
// }
|
|
82
|
-
// source = _.filter(source, (ev) => {
|
|
83
|
-
// if (!ev) {
|
|
84
|
-
// return false
|
|
85
|
-
// }
|
|
86
|
-
// return true;
|
|
87
|
-
// });
|
|
88
|
-
|
|
89
|
-
// if (this.props.onlyFuture) {
|
|
90
|
-
// const nownow = moment().startOf('month');
|
|
91
|
-
// source = _.filter(source, (ev) => {
|
|
92
|
-
// return nownow.isSameOrBefore(moment.utc(ev.UnixTimestamp).local());
|
|
93
|
-
// });
|
|
94
|
-
// }
|
|
95
|
-
|
|
96
120
|
return source.map((ev) => {
|
|
97
121
|
if (ev != null) {
|
|
98
122
|
return (
|
|
@@ -157,13 +181,13 @@ class ListNewsletter extends Component {
|
|
|
157
181
|
<thead>
|
|
158
182
|
<tr>
|
|
159
183
|
<th
|
|
160
|
-
className={`${this.sortIsActive('
|
|
184
|
+
className={`${this.sortIsActive('UnixTimestamp')}`}
|
|
161
185
|
style={{ cursor: 'pointer', width: 140 }}
|
|
162
186
|
onClick={() => {
|
|
163
|
-
this.sortByCol('
|
|
187
|
+
this.sortByCol('UnixTimestamp');
|
|
164
188
|
}}
|
|
165
189
|
>
|
|
166
|
-
Date published{this.renderSort('
|
|
190
|
+
Date published{this.renderSort('UnixTimestamp')}
|
|
167
191
|
</th>
|
|
168
192
|
<th
|
|
169
193
|
className={`${this.sortIsActive('Title')}`}
|
|
@@ -193,6 +217,34 @@ class ListNewsletter extends Component {
|
|
|
193
217
|
);
|
|
194
218
|
}
|
|
195
219
|
|
|
220
|
+
renderPager(filteredCount) {
|
|
221
|
+
if (filteredCount <= PAGE_SIZE) {
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
return (
|
|
225
|
+
<div className="paginationContainer" style={{ margin: '8px 0' }}>
|
|
226
|
+
<FontAwesome
|
|
227
|
+
className="pagination__left"
|
|
228
|
+
name="chevron-left"
|
|
229
|
+
style={{ cursor: 'pointer', fontSize: 20, color: TEXT_LIGHT }}
|
|
230
|
+
onClick={this.prevPage}
|
|
231
|
+
/>
|
|
232
|
+
<p
|
|
233
|
+
className="pagination__text"
|
|
234
|
+
style={{ display: 'inline-block', margin: 0, padding: '0 16px', minWidth: 120, textAlign: 'center', color: TEXT_LIGHT }}
|
|
235
|
+
>
|
|
236
|
+
{this.getPaginationText(filteredCount)}
|
|
237
|
+
</p>
|
|
238
|
+
<FontAwesome
|
|
239
|
+
className="pagination__right"
|
|
240
|
+
name="chevron-right"
|
|
241
|
+
style={{ cursor: 'pointer', fontSize: 20, color: TEXT_LIGHT }}
|
|
242
|
+
onClick={() => this.nextPage(filteredCount)}
|
|
243
|
+
/>
|
|
244
|
+
</div>
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
|
|
196
248
|
renderContent() {
|
|
197
249
|
let source = _.sortBy(this.state.newsletterEntries, this.state.sortColumn);
|
|
198
250
|
if (this.state.sortDesc) {
|
|
@@ -205,21 +257,45 @@ class ListNewsletter extends Component {
|
|
|
205
257
|
return true;
|
|
206
258
|
});
|
|
207
259
|
|
|
208
|
-
|
|
209
|
-
|
|
260
|
+
const { search } = this.state;
|
|
261
|
+
if (!_.isEmpty(search)) {
|
|
262
|
+
const lowSearch = search.toLowerCase();
|
|
210
263
|
source = _.filter(source, (ev) => {
|
|
211
|
-
|
|
264
|
+
if (!ev.Title) {
|
|
265
|
+
return false;
|
|
266
|
+
}
|
|
267
|
+
return ev.Title.toLowerCase().indexOf(lowSearch) > -1;
|
|
212
268
|
});
|
|
213
269
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
270
|
+
|
|
271
|
+
// Total matching the search/sort BEFORE the page slice — drives the pager text.
|
|
272
|
+
const filteredCount = source.length;
|
|
273
|
+
|
|
274
|
+
source = _.filter(source, (ev, i) => {
|
|
275
|
+
return i >= this.state.startIndex && i < this.state.endIndex;
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
return (
|
|
279
|
+
<div>
|
|
280
|
+
{_.isEmpty(source) ? this.renderEmpty() : this.renderView(source)}
|
|
281
|
+
{this.renderPager(filteredCount)}
|
|
282
|
+
</div>
|
|
283
|
+
);
|
|
219
284
|
}
|
|
220
285
|
|
|
221
286
|
render() {
|
|
222
|
-
return
|
|
287
|
+
return (
|
|
288
|
+
<div style={{ minWidth: '100%' }}>
|
|
289
|
+
<FormControl
|
|
290
|
+
type="text"
|
|
291
|
+
placeholder="Search news"
|
|
292
|
+
value={this.state.search}
|
|
293
|
+
onChange={this.onSearchChange}
|
|
294
|
+
style={{ marginBottom: 16, maxWidth: 360 }}
|
|
295
|
+
/>
|
|
296
|
+
{this.renderContent()}
|
|
297
|
+
</div>
|
|
298
|
+
);
|
|
223
299
|
}
|
|
224
300
|
}
|
|
225
301
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, { Component } from 'react';
|
|
2
2
|
import { connect } from 'react-redux';
|
|
3
3
|
import _ from 'lodash';
|
|
4
|
-
import moment from 'moment';
|
|
5
4
|
import FontAwesome from 'react-fontawesome';
|
|
6
5
|
import { Header, AddButton, HubSidebar } from '../../components';
|
|
7
6
|
import { isTheBest, validateAccess } from '../../session';
|
|
@@ -37,9 +36,6 @@ class NewsHub extends Component {
|
|
|
37
36
|
submissionEntries: [],
|
|
38
37
|
|
|
39
38
|
allList: [],
|
|
40
|
-
thisMonth: [],
|
|
41
|
-
now: moment.utc(),
|
|
42
|
-
onlyFuture: true,
|
|
43
39
|
search: '',
|
|
44
40
|
};
|
|
45
41
|
}
|
|
@@ -58,19 +54,8 @@ class NewsHub extends Component {
|
|
|
58
54
|
}
|
|
59
55
|
|
|
60
56
|
updateProps(props) {
|
|
61
|
-
const thisMonth = [];
|
|
62
|
-
const nownow = moment().startOf('month');
|
|
63
|
-
|
|
64
|
-
props.news.forEach((rep) => {
|
|
65
|
-
const isThisMonth = nownow.isSameOrBefore(moment.utc(rep.UnixTimestamp).local());
|
|
66
|
-
if (isThisMonth) {
|
|
67
|
-
thisMonth.push(rep);
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
|
|
71
57
|
this.setState({
|
|
72
58
|
allList: props.news,
|
|
73
|
-
thisMonth,
|
|
74
59
|
submissionEntries: props.submissions,
|
|
75
60
|
});
|
|
76
61
|
}
|
|
@@ -240,7 +225,7 @@ class NewsHub extends Component {
|
|
|
240
225
|
if (this.state.selectedSection === 'available') {
|
|
241
226
|
return <AvailableNews />;
|
|
242
227
|
}
|
|
243
|
-
return <ListNewsletterEntries
|
|
228
|
+
return <ListNewsletterEntries />;
|
|
244
229
|
}
|
|
245
230
|
|
|
246
231
|
render() {
|