@plusscommunities/pluss-core-web 1.2.7 → 1.2.11

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.esm.js CHANGED
@@ -664,6 +664,14 @@ var isVideo = function isVideo(url) {
664
664
  return ['mov', 'mp4'].includes(extension);
665
665
  };
666
666
 
667
+ var getFirstName = function getFirstName(string) {
668
+ if (_.isEmpty(string)) {
669
+ return '';
670
+ }
671
+
672
+ return string.split(' ')[0];
673
+ };
674
+
667
675
  var isEmail = function isEmail(email) {
668
676
  if (_.isEmpty(email)) return false;
669
677
  var atpos = email.indexOf('@');
@@ -740,6 +748,14 @@ var getSiteNameFromRoles = function getSiteNameFromRoles(site, roles) {
740
748
  }));
741
749
  };
742
750
 
751
+ var getSiteSettingFromState = function getSiteSettingFromState(state, key, defaultValue) {
752
+ if (state && state.auth && state.auth.siteSettings && !_.isUndefined(state.auth.siteSettings[key])) {
753
+ return state.auth.siteSettings[key];
754
+ }
755
+
756
+ return defaultValue || null;
757
+ };
758
+
743
759
  var readJSONFromStorage = function readJSONFromStorage(storage, key, fallback) {
744
760
  var value = storage.getItem(key);
745
761
 
@@ -812,12 +828,6 @@ var setLocalStorage = function setLocalStorage(key, value, isJson) {
812
828
  // }
813
829
  // return string.charAt(0).toUpperCase() + string.slice(1);
814
830
  // };
815
- // export const getFirstName = (string) => {
816
- // if (_.isEmpty(string)) {
817
- // return '';
818
- // }
819
- // return string.split(' ')[0];
820
- // };
821
831
  // export const get300 = (url) => {
822
832
  // if (!url) {
823
833
  // return url;
@@ -1539,6 +1549,7 @@ var index$3 = /*#__PURE__*/Object.freeze({
1539
1549
  getFileName: getFileName,
1540
1550
  getThumb300: getThumb300,
1541
1551
  isVideo: isVideo,
1552
+ getFirstName: getFirstName,
1542
1553
  isEmail: isEmail,
1543
1554
  isUrl: isUrl,
1544
1555
  randomString: randomString,
@@ -1546,6 +1557,7 @@ var index$3 = /*#__PURE__*/Object.freeze({
1546
1557
  onlyAlphanumeric: onlyAlphanumeric,
1547
1558
  getSiteName: getSiteName,
1548
1559
  getSiteNameFromRoles: getSiteNameFromRoles,
1560
+ getSiteSettingFromState: getSiteSettingFromState,
1549
1561
  readJSONFromStorage: readJSONFromStorage,
1550
1562
  setLocalStorage: setLocalStorage,
1551
1563
  getTimepickerTime: getTimepickerTime,
@@ -4315,10 +4327,10 @@ var Text = /*#__PURE__*/function (_Component) {
4315
4327
  }, {
4316
4328
  key: "render",
4317
4329
  value: function render() {
4318
- return /*#__PURE__*/React.createElement("p", {
4330
+ return /*#__PURE__*/React.createElement("p", _extends({}, this.props, {
4319
4331
  className: "text-".concat(this.props.type).concat(this.getClassName()),
4320
4332
  style: this.props.style
4321
- }, this.props.children);
4333
+ }), this.props.children);
4322
4334
  }
4323
4335
  }]);
4324
4336
 
@@ -4404,8 +4416,8 @@ var Comment = /*#__PURE__*/function (_Component) {
4404
4416
  }
4405
4417
 
4406
4418
  _createClass(Comment, [{
4407
- key: "render",
4408
- value: function render() {
4419
+ key: "renderComment",
4420
+ value: function renderComment() {
4409
4421
  var comment = this.props.comment;
4410
4422
  return /*#__PURE__*/React.createElement("div", {
4411
4423
  key: comment.Id,
@@ -4424,6 +4436,11 @@ var Comment = /*#__PURE__*/function (_Component) {
4424
4436
  className: "comment_time"
4425
4437
  }, moment.utc(comment.Timestamp).local().format('D MMM YYYY • h:mma'))));
4426
4438
  }
4439
+ }, {
4440
+ key: "render",
4441
+ value: function render() {
4442
+ return /*#__PURE__*/React.createElement("div", null, this.renderComment(), this.props.bottomContent);
4443
+ }
4427
4444
  }]);
4428
4445
 
4429
4446
  return Comment;
@@ -4474,6 +4491,58 @@ var CommentSection = /*#__PURE__*/function (_Component) {
4474
4491
  }, _callee);
4475
4492
  })));
4476
4493
 
4494
+ _defineProperty(_assertThisInitialized(_this), "getComments", function () {
4495
+ if (!_this.props.onlyParents) {
4496
+ return _this.props.comments;
4497
+ }
4498
+
4499
+ return _.filter(_this.props.comments, function (c) {
4500
+ return !c.ParentId;
4501
+ });
4502
+ });
4503
+
4504
+ _defineProperty(_assertThisInitialized(_this), "renderReplyText", function (c) {
4505
+ if (!_this.props.onOpenThread) {
4506
+ return null;
4507
+ }
4508
+
4509
+ var threadComments = _.filter(_this.props.comments, function (innerC) {
4510
+ return innerC.ParentId === c.Id;
4511
+ });
4512
+
4513
+ if (_.isEmpty(threadComments)) {
4514
+ return /*#__PURE__*/React.createElement("div", {
4515
+ className: "comment_reply"
4516
+ }, /*#__PURE__*/React.createElement(Text, {
4517
+ className: "comment_reply_button",
4518
+ type: "button",
4519
+ onClick: function onClick() {
4520
+ _this.props.onOpenThread(c);
4521
+ }
4522
+ }, "Reply to ".concat(getFirstName(c.User ? c.User.displayName : 'comment'))));
4523
+ }
4524
+
4525
+ var profilePics = _.take(_.uniqBy(threadComments, function (c) {
4526
+ return c.UserId;
4527
+ }), 3);
4528
+
4529
+ return /*#__PURE__*/React.createElement("div", {
4530
+ className: "comment_reply comment_reply-hasReplies"
4531
+ }, profilePics.map(function (c) {
4532
+ return /*#__PURE__*/React.createElement(ProfilePic, {
4533
+ className: "comment_reply_profilePic",
4534
+ size: 20,
4535
+ image: c.User.profilePic
4536
+ });
4537
+ }), /*#__PURE__*/React.createElement(Text, {
4538
+ className: "comment_reply_button",
4539
+ type: "button",
4540
+ onClick: function onClick() {
4541
+ _this.props.onOpenThread(c);
4542
+ }
4543
+ }, "".concat(threadComments.length, " repl").concat(getPluralOptions(threadComments.length, 'y', 'ies'))));
4544
+ });
4545
+
4477
4546
  _this.state = {
4478
4547
  commentInput: ''
4479
4548
  };
@@ -4490,10 +4559,11 @@ var CommentSection = /*#__PURE__*/function (_Component) {
4490
4559
  className: "marginBottom-16"
4491
4560
  }, "Comments"), /*#__PURE__*/React.createElement("div", {
4492
4561
  className: "commentSection"
4493
- }, this.props.comments.map(function (c) {
4562
+ }, this.getComments().map(function (c) {
4494
4563
  return /*#__PURE__*/React.createElement(Comment, {
4495
4564
  key: c.Id,
4496
- comment: c
4565
+ comment: c,
4566
+ bottomContent: _this2.renderReplyText(c)
4497
4567
  });
4498
4568
  })), /*#__PURE__*/React.createElement("div", {
4499
4569
  className: "commentReply"
@@ -8987,7 +9057,7 @@ var AudienceSelector = /*#__PURE__*/function (_Component) {
8987
9057
  Category = _this$state2.Category,
8988
9058
  Tag = _this$state2.Tag,
8989
9059
  Type = _this$state2.Type;
8990
- if (AudienceType === 'Custom') return AudienceTagList;
9060
+ if (AudienceType === 'Custom') return AudienceTagList || [];
8991
9061
  if (AudienceType === 'Category') return Category;
8992
9062
  if (AudienceType === 'UserTags') return Tag;
8993
9063
  return Type;
@@ -9047,7 +9117,8 @@ var AudienceSelector = /*#__PURE__*/function (_Component) {
9047
9117
  Type: '',
9048
9118
  Category: '',
9049
9119
  includeList: [],
9050
- excludeList: []
9120
+ excludeList: [],
9121
+ AudienceTagList: []
9051
9122
  });
9052
9123
  setTimeout(this.onChangeSelection, 50);
9053
9124
  }
@@ -10160,8 +10231,6 @@ var ExportCsvPopup = /*#__PURE__*/function (_Component) {
10160
10231
  });
10161
10232
 
10162
10233
  _defineProperty(_assertThisInitialized(_this), "onToggleColumn", function (key) {
10163
- var source = _this.props.source;
10164
-
10165
10234
  var columns = _.cloneDeep(_this.state.columns);
10166
10235
 
10167
10236
  var column = columns.find(function (c) {
@@ -10177,25 +10246,132 @@ var ExportCsvPopup = /*#__PURE__*/function (_Component) {
10177
10246
  var selectedHeaders = columns.filter(function (c) {
10178
10247
  return c.key && c.selected;
10179
10248
  });
10180
- var selectedheaderKeys = selectedHeaders.map(function (h) {
10181
- return h.key;
10249
+
10250
+ _this.setState({
10251
+ columns: columns,
10252
+ selectedHeaders: selectedHeaders
10182
10253
  });
10183
- var selectedSource = source.map(function (i) {
10184
- return _.pick(i, selectedheaderKeys);
10254
+ }
10255
+ });
10256
+
10257
+ _defineProperty(_assertThisInitialized(_this), "onToggleStartDateFilter", function () {
10258
+ var filterDateStartVisible = _this.state.filterDateStartVisible;
10259
+
10260
+ if (filterDateStartVisible) {
10261
+ setTimeout(function () {
10262
+ return _this.setState({
10263
+ filterDateStartVisible: false
10264
+ });
10265
+ }, 200);
10266
+ } else {
10267
+ _this.setState({
10268
+ filterDateStartVisible: true
10269
+ });
10270
+ }
10271
+ });
10272
+
10273
+ _defineProperty(_assertThisInitialized(_this), "onToggleEndDateFilter", function () {
10274
+ var filterDateEndVisible = _this.state.filterDateEndVisible;
10275
+
10276
+ if (filterDateEndVisible) {
10277
+ setTimeout(function () {
10278
+ return _this.setState({
10279
+ filterDateEndVisible: false
10280
+ });
10281
+ }, 200);
10282
+ } else {
10283
+ _this.setState({
10284
+ filterDateEndVisible: true
10185
10285
  });
10286
+ }
10287
+ });
10288
+
10289
+ _defineProperty(_assertThisInitialized(_this), "onDateFilterStartChanged", function (date) {
10290
+ var filterDateEnd = _this.state.filterDateEnd;
10291
+ var start = moment(date);
10186
10292
 
10293
+ if (start.isSameOrBefore(filterDateEnd)) {
10187
10294
  _this.setState({
10188
- columns: columns,
10189
- selectedHeaders: selectedHeaders,
10190
- selectedSource: selectedSource
10295
+ filterDateStart: start.startOf('day'),
10296
+ filterDateStartVisible: false
10297
+ });
10298
+ }
10299
+ });
10300
+
10301
+ _defineProperty(_assertThisInitialized(_this), "onDateFilterEndChanged", function (date) {
10302
+ var filterDateStart = _this.state.filterDateStart;
10303
+ var end = moment(date);
10304
+
10305
+ if (end.isSameOrAfter(filterDateStart)) {
10306
+ _this.setState({
10307
+ filterDateEnd: end.endOf('day'),
10308
+ filterDateEndVisible: false
10191
10309
  });
10192
10310
  }
10193
10311
  });
10194
10312
 
10313
+ _defineProperty(_assertThisInitialized(_this), "getSelectedSource", function () {
10314
+ var source = _this.props.source;
10315
+ var selectedHeaders = _this.state.selectedHeaders;
10316
+ var result = source; // apply timestamp filter
10317
+
10318
+ if (_this.props.timestampFilter) {
10319
+ var _this$state = _this.state,
10320
+ filterDateStart = _this$state.filterDateStart,
10321
+ filterDateEnd = _this$state.filterDateEnd;
10322
+ var filterKey = _this.props.timestampFilter.filterKey;
10323
+ var minDate = filterDateStart.valueOf();
10324
+ var maxDate = filterDateEnd.valueOf();
10325
+ result = _.filter(source, function (item) {
10326
+ return item[filterKey] >= minDate && item[filterKey] <= maxDate;
10327
+ });
10328
+ } // map result to columns
10329
+
10330
+
10331
+ var selectedheaderKeys = selectedHeaders.map(function (h) {
10332
+ return h.key;
10333
+ });
10334
+ return result.map(function (i) {
10335
+ return _.pick(i, selectedheaderKeys);
10336
+ });
10337
+ });
10338
+
10339
+ _defineProperty(_assertThisInitialized(_this), "renderTimestampFilter", function () {
10340
+ if (!_this.props.timestampFilter) {
10341
+ return null;
10342
+ }
10343
+
10344
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(GenericInput, {
10345
+ id: "dateStart",
10346
+ label: "Start Date",
10347
+ alwaysShowLabel: true,
10348
+ placeholder: 'Select start date',
10349
+ value: _this.state.filterDateStart.format('DD/MM/YYYY'),
10350
+ onClick: _this.onToggleStartDateFilter,
10351
+ readOnly: true
10352
+ }), _this.state.filterDateStartVisible ? /*#__PURE__*/React.createElement(DatePicker, {
10353
+ hideTop: true,
10354
+ selectedDate: _this.state.filterDateStart,
10355
+ selectDate: _this.onDateFilterStartChanged
10356
+ }) : null, /*#__PURE__*/React.createElement(GenericInput, {
10357
+ id: "dateEnd",
10358
+ label: "End Date",
10359
+ alwaysShowLabel: true,
10360
+ placeholder: 'Select end date',
10361
+ value: _this.state.filterDateEnd.format('DD/MM/YYYY'),
10362
+ onClick: _this.onToggleEndDateFilter,
10363
+ readOnly: true
10364
+ }), _this.state.filterDateEndVisible ? /*#__PURE__*/React.createElement(DatePicker, {
10365
+ hideTop: true,
10366
+ selectedDate: _this.state.filterDateEnd,
10367
+ selectDate: _this.onDateFilterEndChanged
10368
+ }) : null);
10369
+ });
10370
+
10195
10371
  _defineProperty(_assertThisInitialized(_this), "renderContent", function () {
10196
- var _this$state = _this.state,
10197
- saving = _this$state.saving,
10198
- columns = _this$state.columns;
10372
+ var _this$state2 = _this.state,
10373
+ saving = _this$state2.saving,
10374
+ columns = _this$state2.columns;
10199
10375
 
10200
10376
  if (saving) {
10201
10377
  return /*#__PURE__*/React.createElement("div", {
@@ -10230,27 +10406,35 @@ var ExportCsvPopup = /*#__PURE__*/function (_Component) {
10230
10406
  }));
10231
10407
  });
10232
10408
 
10233
- _this.state = {
10409
+ var state = {
10234
10410
  columns: props.columns,
10411
+ selectedHeaders: props.columns.filter(function (c) {
10412
+ return c.key && c.selected;
10413
+ }),
10235
10414
  selectedSource: [],
10236
10415
  saving: false
10237
10416
  };
10417
+
10418
+ if (props.timestampFilter) {
10419
+ state.filterDateStart = props.timestampFilter.startDate;
10420
+ state.filterDateEnd = props.timestampFilter.endDate;
10421
+ }
10422
+
10423
+ _this.state = state;
10238
10424
  return _this;
10239
10425
  }
10240
10426
 
10241
10427
  _createClass(ExportCsvPopup, [{
10242
10428
  key: "render",
10243
10429
  value: function render() {
10244
- var _this$state2 = this.state,
10245
- selectedHeaders = _this$state2.selectedHeaders,
10246
- selectedSource = _this$state2.selectedSource;
10430
+ var selectedHeaders = this.state.selectedHeaders;
10247
10431
  var filename = this.props.filename;
10248
10432
  var buttons = [{
10249
10433
  type: 'primary',
10250
10434
  isActive: this.canSave(),
10251
10435
  text: /*#__PURE__*/React.createElement(CSVLink, {
10252
10436
  headers: selectedHeaders,
10253
- data: selectedSource,
10437
+ data: this.getSelectedSource(),
10254
10438
  style: {
10255
10439
  textDecoration: 'none',
10256
10440
  color: '#fff'
@@ -10266,7 +10450,6 @@ var ExportCsvPopup = /*#__PURE__*/function (_Component) {
10266
10450
  }];
10267
10451
  return /*#__PURE__*/React.createElement(Popup, {
10268
10452
  title: "Confirm Export",
10269
- subtitle: "Select which columns to include in the export",
10270
10453
  boxClasses: "flex flex-column",
10271
10454
  innerClasses: "flex flex-column fillSpace flex-1",
10272
10455
  minWidth: 500,
@@ -10276,7 +10459,9 @@ var ExportCsvPopup = /*#__PURE__*/function (_Component) {
10276
10459
  hasPadding: true,
10277
10460
  onClose: this.onClose,
10278
10461
  buttons: buttons
10279
- }, this.renderContent());
10462
+ }, this.renderTimestampFilter(), /*#__PURE__*/React.createElement(Text, {
10463
+ type: "bodyLarge"
10464
+ }, "Select which columns to include in the export"), this.renderContent());
10280
10465
  }
10281
10466
  }]);
10282
10467