@mjhls/mjh-framework 1.0.945 → 1.0.946

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.
@@ -69,7 +69,8 @@ var DeckQueue = function (_React$Component) {
69
69
  total_pages: null,
70
70
  scrolling: true,
71
71
  query: _this.query,
72
- currentPage: _this.props.currentPage || 1
72
+ currentPage: _this.props.currentPage || 1,
73
+ lastDataSize: _this.data ? _this.data.length : 0
73
74
  }, _this.loadMore = debounce.debounce_1(function () {
74
75
  _this.setState(function (state) {
75
76
  var page = state.page,
@@ -109,11 +110,13 @@ var DeckQueue = function (_React$Component) {
109
110
  if (dataArr.length > 0) {
110
111
  return {
111
112
  data: [].concat(toConsumableArray._toConsumableArray(data), toConsumableArray._toConsumableArray(dataArr)),
113
+ lastDataSize: dataArr.length,
112
114
  scrolling: true
113
115
  };
114
116
  } else {
115
117
  return {
116
- scrolling: false
118
+ scrolling: false,
119
+ lastDataSize: 0
117
120
  };
118
121
  }
119
122
  });
@@ -199,8 +202,12 @@ var DeckQueue = function (_React$Component) {
199
202
  { style: { display: 'flex', flex: '1 0 auto' } },
200
203
  rightItems[i].component
201
204
  );
202
- }, _this.renderManualPagination = function () {
203
- var currentPage = _this.state.currentPage;
205
+ }, _this.renderManualPagination = function (_ref2) {
206
+ var nextPagePostsCount = _ref2.nextPagePostsCount;
207
+ var _this$state2 = _this.state,
208
+ currentPage = _this$state2.currentPage,
209
+ per = _this$state2.per,
210
+ lastDataSize = _this$state2.lastDataSize;
204
211
 
205
212
  return React__default['default'].createElement(
206
213
  'div',
@@ -210,7 +217,7 @@ var DeckQueue = function (_React$Component) {
210
217
  { href: '?page=' + (currentPage - 1) },
211
218
  '<< Previous'
212
219
  ),
213
- React__default['default'].createElement(
220
+ !(lastDataSize < per) && nextPagePostsCount > 0 && React__default['default'].createElement(
214
221
  'a',
215
222
  { href: '?page=' + (currentPage + 1) },
216
223
  'Next >>'
@@ -325,19 +332,30 @@ var DeckQueue = function (_React$Component) {
325
332
  columns = _props.columns,
326
333
  variant = _props.variant,
327
334
  autoScroll = _props.autoScroll,
328
- page = _props.page;
335
+ page = _props.page,
336
+ _props$nextPagePostsC = _props.nextPagePostsCount,
337
+ nextPagePostsCount = _props$nextPagePostsC === undefined ? 3 : _props$nextPagePostsC;
329
338
 
330
339
 
331
340
  return React__default['default'].createElement(
332
341
  'div',
333
342
  { className: 'contentDeck' },
334
343
  autoScroll ? React__default['default'].createElement(
335
- index_es.InfiniteScroll,
336
- { dataLength: this.state.data.length, next: this.loadMore, hasMore: this.state.scrolling },
344
+ React__default['default'].Fragment,
345
+ null,
337
346
  React__default['default'].createElement(
338
- Container__default['default'],
347
+ index_es.InfiniteScroll,
348
+ { dataLength: this.state.data.length, next: this.loadMore, hasMore: this.state.scrolling },
349
+ React__default['default'].createElement(
350
+ Container__default['default'],
351
+ null,
352
+ this.cardLoader(page, columns, variant)
353
+ )
354
+ ),
355
+ React__default['default'].createElement(
356
+ 'noscript',
339
357
  null,
340
- this.cardLoader(page, columns, variant)
358
+ this.renderManualPagination({ nextPagePostsCount: nextPagePostsCount })
341
359
  )
342
360
  ) : React__default['default'].createElement(
343
361
  React__default['default'].Fragment,
@@ -371,7 +389,7 @@ var DeckQueue = function (_React$Component) {
371
389
  React__default['default'].createElement(
372
390
  'noscript',
373
391
  null,
374
- this.renderManualPagination()
392
+ this.renderManualPagination({ nextPagePostsCount: nextPagePostsCount })
375
393
  )
376
394
  )
377
395
  );
@@ -128,7 +128,9 @@ var IssueLanding = function IssueLanding(props) {
128
128
  _props$imageHeight = props.imageHeight,
129
129
  imageHeight = _props$imageHeight === undefined ? 270 : _props$imageHeight,
130
130
  _props$imageWidth = props.imageWidth,
131
- imageWidth = _props$imageWidth === undefined ? 480 : _props$imageWidth;
131
+ imageWidth = _props$imageWidth === undefined ? 480 : _props$imageWidth,
132
+ _props$nextPagePostsC = props.nextPagePostsCount,
133
+ nextPagePostsCount = _props$nextPagePostsC === undefined ? 1 : _props$nextPagePostsC;
132
134
 
133
135
  return React__default['default'].createElement(
134
136
  'div',
@@ -162,7 +164,8 @@ var IssueLanding = function IssueLanding(props) {
162
164
  showPubInfo: showPubInfo,
163
165
  columns: 'rotate',
164
166
  variant: 'top',
165
- contentCategoryMapping: settings.contentCategoryMapping ? settings.contentCategoryMapping : []
167
+ contentCategoryMapping: settings.contentCategoryMapping ? settings.contentCategoryMapping : [],
168
+ nextPagePostsCount: nextPagePostsCount
166
169
  })
167
170
  );
168
171
  };
@@ -246,7 +246,8 @@ var MediaSeriesLanding = function MediaSeriesLanding(props) {
246
246
  pageview = props.pageview,
247
247
  currentPage = props.currentPage,
248
248
  docGroupID = props.docGroupID,
249
- parentUrl = props.parentUrl;
249
+ parentUrl = props.parentUrl,
250
+ nextPagePostsCount = props.nextPagePostsCount;
250
251
 
251
252
  var _useState7 = React.useState(false),
252
253
  _useState8 = slicedToArray._slicedToArray(_useState7, 2),
@@ -374,14 +375,15 @@ var MediaSeriesLanding = function MediaSeriesLanding(props) {
374
375
  currentPage: currentPage,
375
376
  pageview: pageview,
376
377
  autoScroll: true,
377
- seoPaginate: true
378
+ seoPaginate: true,
379
+ nextPagePostsCount: nextPagePostsCount
378
380
  })
379
381
  );
380
382
  };
381
383
 
382
384
  MediaSeriesLanding.getInitialData = function () {
383
385
  var _ref3 = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee2(ctx, client, cache) {
384
- var urlQuery, pathname, identifier, itemsPerPage, currentPage, start, statusCode, params, docGroupID, seriesQuery, seriesData, allSeries, buildUsedTopicsArray, usedTopics, taxonomyFilter;
386
+ var urlQuery, pathname, identifier, itemsPerPage, currentPage, start, statusCode, params, docGroupID, seriesQuery, seriesData, nextPagePostsCount, allSeries, buildUsedTopicsArray, usedTopics, taxonomyFilter;
385
387
  return asyncToGenerator.regenerator.wrap(function _callee2$(_context2) {
386
388
  while (1) {
387
389
  switch (_context2.prev = _context2.next) {
@@ -411,9 +413,14 @@ MediaSeriesLanding.getInitialData = function () {
411
413
  case 13:
412
414
  seriesData = _context2.sent;
413
415
  _context2.next = 16;
414
- return client.fetch('*[_type == \'documentGroup\' && references(\'' + docGroupID._id + '\') && isSeries != false && isShow != false && defined(published) && dateTime(published) <= dateTime(now()) ] {\n topicMapping[]->\n }');
416
+ return client.fetch('count(' + seriesQuery + ')', _extends._extends({}, params, { from: params.to, to: params.to + itemsPerPage }));
415
417
 
416
418
  case 16:
419
+ nextPagePostsCount = _context2.sent;
420
+ _context2.next = 19;
421
+ return client.fetch('*[_type == \'documentGroup\' && references(\'' + docGroupID._id + '\') && isSeries != false && isShow != false && defined(published) && dateTime(published) <= dateTime(now()) ] {\n topicMapping[]->\n }');
422
+
423
+ case 19:
417
424
  allSeries = _context2.sent;
418
425
 
419
426
  //Take all series topicMapping and put in an array
@@ -434,10 +441,10 @@ MediaSeriesLanding.getInitialData = function () {
434
441
  };
435
442
 
436
443
  usedTopics = buildUsedTopicsArray(allSeries);
437
- _context2.next = 21;
444
+ _context2.next = 24;
438
445
  return client.fetch('\n *[_type == \'taxonomy\' && !defined(parent) && isMainTopic] | order(name asc) {\n _id,\n identifier,\n name,\n "children": *[_type == \'taxonomy\' && references(^._id)] | order(name asc){\n _id,\n name,\n identifier,\n "grandchildren": *[_type == \'taxonomy\' && references(^._id)] | order(name asc) {...}\n }\t\n }');
439
446
 
440
- case 21:
447
+ case 24:
441
448
  taxonomyFilter = _context2.sent;
442
449
 
443
450
 
@@ -478,10 +485,11 @@ MediaSeriesLanding.getInitialData = function () {
478
485
  docGroupID: docGroupID._id,
479
486
  parentUrl: identifier,
480
487
  statusCode: statusCode,
481
- docGroup: docGroupID
488
+ docGroup: docGroupID,
489
+ nextPagePostsCount: nextPagePostsCount
482
490
  });
483
491
 
484
- case 25:
492
+ case 28:
485
493
  case 'end':
486
494
  return _context2.stop();
487
495
  }
@@ -59,7 +59,8 @@ var DeckQueue = function (_React$Component) {
59
59
  total_pages: null,
60
60
  scrolling: true,
61
61
  query: _this.query,
62
- currentPage: _this.props.currentPage || 1
62
+ currentPage: _this.props.currentPage || 1,
63
+ lastDataSize: _this.data ? _this.data.length : 0
63
64
  }, _this.loadMore = debounce_1(function () {
64
65
  _this.setState(function (state) {
65
66
  var page = state.page,
@@ -99,11 +100,13 @@ var DeckQueue = function (_React$Component) {
99
100
  if (dataArr.length > 0) {
100
101
  return {
101
102
  data: [].concat(_toConsumableArray(data), _toConsumableArray(dataArr)),
103
+ lastDataSize: dataArr.length,
102
104
  scrolling: true
103
105
  };
104
106
  } else {
105
107
  return {
106
- scrolling: false
108
+ scrolling: false,
109
+ lastDataSize: 0
107
110
  };
108
111
  }
109
112
  });
@@ -189,8 +192,12 @@ var DeckQueue = function (_React$Component) {
189
192
  { style: { display: 'flex', flex: '1 0 auto' } },
190
193
  rightItems[i].component
191
194
  );
192
- }, _this.renderManualPagination = function () {
193
- var currentPage = _this.state.currentPage;
195
+ }, _this.renderManualPagination = function (_ref2) {
196
+ var nextPagePostsCount = _ref2.nextPagePostsCount;
197
+ var _this$state2 = _this.state,
198
+ currentPage = _this$state2.currentPage,
199
+ per = _this$state2.per,
200
+ lastDataSize = _this$state2.lastDataSize;
194
201
 
195
202
  return React__default.createElement(
196
203
  'div',
@@ -200,7 +207,7 @@ var DeckQueue = function (_React$Component) {
200
207
  { href: '?page=' + (currentPage - 1) },
201
208
  '<< Previous'
202
209
  ),
203
- React__default.createElement(
210
+ !(lastDataSize < per) && nextPagePostsCount > 0 && React__default.createElement(
204
211
  'a',
205
212
  { href: '?page=' + (currentPage + 1) },
206
213
  'Next >>'
@@ -315,19 +322,30 @@ var DeckQueue = function (_React$Component) {
315
322
  columns = _props.columns,
316
323
  variant = _props.variant,
317
324
  autoScroll = _props.autoScroll,
318
- page = _props.page;
325
+ page = _props.page,
326
+ _props$nextPagePostsC = _props.nextPagePostsCount,
327
+ nextPagePostsCount = _props$nextPagePostsC === undefined ? 3 : _props$nextPagePostsC;
319
328
 
320
329
 
321
330
  return React__default.createElement(
322
331
  'div',
323
332
  { className: 'contentDeck' },
324
333
  autoScroll ? React__default.createElement(
325
- InfiniteScroll,
326
- { dataLength: this.state.data.length, next: this.loadMore, hasMore: this.state.scrolling },
334
+ React__default.Fragment,
335
+ null,
327
336
  React__default.createElement(
328
- Container,
337
+ InfiniteScroll,
338
+ { dataLength: this.state.data.length, next: this.loadMore, hasMore: this.state.scrolling },
339
+ React__default.createElement(
340
+ Container,
341
+ null,
342
+ this.cardLoader(page, columns, variant)
343
+ )
344
+ ),
345
+ React__default.createElement(
346
+ 'noscript',
329
347
  null,
330
- this.cardLoader(page, columns, variant)
348
+ this.renderManualPagination({ nextPagePostsCount: nextPagePostsCount })
331
349
  )
332
350
  ) : React__default.createElement(
333
351
  React__default.Fragment,
@@ -361,7 +379,7 @@ var DeckQueue = function (_React$Component) {
361
379
  React__default.createElement(
362
380
  'noscript',
363
381
  null,
364
- this.renderManualPagination()
382
+ this.renderManualPagination({ nextPagePostsCount: nextPagePostsCount })
365
383
  )
366
384
  )
367
385
  );
@@ -122,7 +122,9 @@ var IssueLanding = function IssueLanding(props) {
122
122
  _props$imageHeight = props.imageHeight,
123
123
  imageHeight = _props$imageHeight === undefined ? 270 : _props$imageHeight,
124
124
  _props$imageWidth = props.imageWidth,
125
- imageWidth = _props$imageWidth === undefined ? 480 : _props$imageWidth;
125
+ imageWidth = _props$imageWidth === undefined ? 480 : _props$imageWidth,
126
+ _props$nextPagePostsC = props.nextPagePostsCount,
127
+ nextPagePostsCount = _props$nextPagePostsC === undefined ? 1 : _props$nextPagePostsC;
126
128
 
127
129
  return React__default.createElement(
128
130
  'div',
@@ -156,7 +158,8 @@ var IssueLanding = function IssueLanding(props) {
156
158
  showPubInfo: showPubInfo,
157
159
  columns: 'rotate',
158
160
  variant: 'top',
159
- contentCategoryMapping: settings.contentCategoryMapping ? settings.contentCategoryMapping : []
161
+ contentCategoryMapping: settings.contentCategoryMapping ? settings.contentCategoryMapping : [],
162
+ nextPagePostsCount: nextPagePostsCount
160
163
  })
161
164
  );
162
165
  };
@@ -239,7 +239,8 @@ var MediaSeriesLanding = function MediaSeriesLanding(props) {
239
239
  pageview = props.pageview,
240
240
  currentPage = props.currentPage,
241
241
  docGroupID = props.docGroupID,
242
- parentUrl = props.parentUrl;
242
+ parentUrl = props.parentUrl,
243
+ nextPagePostsCount = props.nextPagePostsCount;
243
244
 
244
245
  var _useState7 = useState(false),
245
246
  _useState8 = _slicedToArray(_useState7, 2),
@@ -367,14 +368,15 @@ var MediaSeriesLanding = function MediaSeriesLanding(props) {
367
368
  currentPage: currentPage,
368
369
  pageview: pageview,
369
370
  autoScroll: true,
370
- seoPaginate: true
371
+ seoPaginate: true,
372
+ nextPagePostsCount: nextPagePostsCount
371
373
  })
372
374
  );
373
375
  };
374
376
 
375
377
  MediaSeriesLanding.getInitialData = function () {
376
378
  var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(ctx, client, cache) {
377
- var urlQuery, pathname, identifier, itemsPerPage, currentPage, start, statusCode, params, docGroupID, seriesQuery, seriesData, allSeries, buildUsedTopicsArray, usedTopics, taxonomyFilter;
379
+ var urlQuery, pathname, identifier, itemsPerPage, currentPage, start, statusCode, params, docGroupID, seriesQuery, seriesData, nextPagePostsCount, allSeries, buildUsedTopicsArray, usedTopics, taxonomyFilter;
378
380
  return regenerator.wrap(function _callee2$(_context2) {
379
381
  while (1) {
380
382
  switch (_context2.prev = _context2.next) {
@@ -404,9 +406,14 @@ MediaSeriesLanding.getInitialData = function () {
404
406
  case 13:
405
407
  seriesData = _context2.sent;
406
408
  _context2.next = 16;
407
- return client.fetch('*[_type == \'documentGroup\' && references(\'' + docGroupID._id + '\') && isSeries != false && isShow != false && defined(published) && dateTime(published) <= dateTime(now()) ] {\n topicMapping[]->\n }');
409
+ return client.fetch('count(' + seriesQuery + ')', _extends({}, params, { from: params.to, to: params.to + itemsPerPage }));
408
410
 
409
411
  case 16:
412
+ nextPagePostsCount = _context2.sent;
413
+ _context2.next = 19;
414
+ return client.fetch('*[_type == \'documentGroup\' && references(\'' + docGroupID._id + '\') && isSeries != false && isShow != false && defined(published) && dateTime(published) <= dateTime(now()) ] {\n topicMapping[]->\n }');
415
+
416
+ case 19:
410
417
  allSeries = _context2.sent;
411
418
 
412
419
  //Take all series topicMapping and put in an array
@@ -427,10 +434,10 @@ MediaSeriesLanding.getInitialData = function () {
427
434
  };
428
435
 
429
436
  usedTopics = buildUsedTopicsArray(allSeries);
430
- _context2.next = 21;
437
+ _context2.next = 24;
431
438
  return client.fetch('\n *[_type == \'taxonomy\' && !defined(parent) && isMainTopic] | order(name asc) {\n _id,\n identifier,\n name,\n "children": *[_type == \'taxonomy\' && references(^._id)] | order(name asc){\n _id,\n name,\n identifier,\n "grandchildren": *[_type == \'taxonomy\' && references(^._id)] | order(name asc) {...}\n }\t\n }');
432
439
 
433
- case 21:
440
+ case 24:
434
441
  taxonomyFilter = _context2.sent;
435
442
 
436
443
 
@@ -471,10 +478,11 @@ MediaSeriesLanding.getInitialData = function () {
471
478
  docGroupID: docGroupID._id,
472
479
  parentUrl: identifier,
473
480
  statusCode: statusCode,
474
- docGroup: docGroupID
481
+ docGroup: docGroupID,
482
+ nextPagePostsCount: nextPagePostsCount
475
483
  });
476
484
 
477
- case 25:
485
+ case 28:
478
486
  case 'end':
479
487
  return _context2.stop();
480
488
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mjhls/mjh-framework",
3
- "version": "1.0.945",
3
+ "version": "1.0.946",
4
4
  "description": "Foundation Framework",
5
5
  "author": "mjh-framework",
6
6
  "license": "MIT",