@mjhls/mjh-framework 1.0.790-filter-test → 1.0.790-scroll-change-test

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.
@@ -2,7 +2,6 @@
2
2
 
3
3
  var defineProperty = require('./defineProperty-0cb76d99.js');
4
4
  var asyncToGenerator = require('./asyncToGenerator-58c289d9.js');
5
- var _typeof = require('./typeof-88a668c5.js');
6
5
  var _extends$1 = require('./extends-29bdbc6d.js');
7
6
  var slicedToArray = require('./slicedToArray-5d1bc3b3.js');
8
7
  var React = require('react');
@@ -10,7 +9,9 @@ var _commonjsHelpers = require('./_commonjsHelpers-06173234.js');
10
9
  var PropTypes = require('prop-types');
11
10
  var ReactDOM = require('react-dom');
12
11
  var Link = require('next/link');
12
+ require('./iconBase-68959171.js');
13
13
  var MasterDeck = require('./MasterDeck.js');
14
+ var _typeof = require('./typeof-88a668c5.js');
14
15
  var index$1 = require('./index-eadd5035.js');
15
16
  var index = require('./index-efca863c.js');
16
17
  var moment = require('./moment-aca40de1.js');
@@ -24,7 +25,6 @@ require('./web.dom.iterable-46657b5c.js');
24
25
  require('./_library-dd23b178.js');
25
26
  require('./core.get-iterator-method-f474eacc.js');
26
27
  require('./_iter-detect-55a5657a.js');
27
- require('./_is-array-6128bd56.js');
28
28
  require('./_object-pie-083f2dd6.js');
29
29
  require('./toConsumableArray-ddb70795.js');
30
30
  require('./inherits-c2065b95.js');
@@ -48,6 +48,7 @@ require('./stringify-c9ac1214.js');
48
48
  require('./Segment.js');
49
49
  require('./main-025fdc78.js');
50
50
  require('./ADInfeed-e7aecdf9.js');
51
+ require('./_is-array-6128bd56.js');
51
52
  require('react-bootstrap');
52
53
  require('./index-187c967e.js');
53
54
  require('./util-6f784d85.js');
@@ -62,7 +63,6 @@ require('react-bootstrap/Pagination');
62
63
  require('react-bootstrap/Button');
63
64
  require('./entities-3f9d0f2f.js');
64
65
  require('./index.esm-974f47d9.js');
65
- require('./iconBase-68959171.js');
66
66
  require('react-bootstrap/Figure');
67
67
 
68
68
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -9573,20 +9573,20 @@ var Filter = function Filter(_ref) {
9573
9573
 
9574
9574
  React.useEffect(function () {
9575
9575
  if (filterData.length < 2) {
9576
- setChildData({ name: null, data: filterData[0].children, _id: filterData[0]._id });
9576
+ setChildData({ name: null, data: filterData[0].children });
9577
9577
  } else {
9578
9578
  setParentData({ name: null, data: filterData });
9579
9579
  }
9580
9580
  }, []);
9581
9581
 
9582
9582
  var handleFilterSelect = function handleFilterSelect(group, type) {
9583
+
9583
9584
  if (type === 'parent') {
9584
9585
  setParentData(function (prevState) {
9585
9586
  return _extends$1._extends({}, prevState, { name: group.name ? group.name : null });
9586
9587
  });
9587
9588
  if (group && group.children && group.children.length > 0) {
9588
- setChildData({ data: group.children, _id: group._id });
9589
- setFilterTopicID(group._id);
9589
+ setChildData({ data: group.children });
9590
9590
  } else {
9591
9591
  //handle filter
9592
9592
  setChildData(null);
@@ -9596,17 +9596,10 @@ var Filter = function Filter(_ref) {
9596
9596
  }
9597
9597
  if (type === 'child') {
9598
9598
  setChildData(function (prevState) {
9599
- return _extends$1._extends({}, prevState, { name: group.name ? group.name : null, _id: group._id });
9599
+ return _extends$1._extends({}, prevState, { name: group.name ? group.name : null });
9600
9600
  });
9601
9601
  if (group && group.grandchildren && group.grandchildren.length > 0) {
9602
- setGrandChildData({ data: group.grandchildren, _id: group._id });
9603
- setFilterTopicID(group._id);
9604
- var topics = [];
9605
- topics.push(group._id);
9606
- group.grandchildren.forEach(function (topic) {
9607
- topics.push(topic._id);
9608
- });
9609
- setFilterTopicID(topics);
9602
+ setGrandChildData({ data: group.grandchildren });
9610
9603
  } else {
9611
9604
  //handle filter
9612
9605
  setGrandChildData(null);
@@ -9615,19 +9608,10 @@ var Filter = function Filter(_ref) {
9615
9608
  }
9616
9609
  if (type === 'grandchild') {
9617
9610
  setGrandChildData(function (prevState) {
9618
- return _extends$1._extends({}, prevState, { name: group.name ? group.name : 'All', _id: group._id });
9611
+ return _extends$1._extends({}, prevState, { name: group.name ? group.name : null });
9619
9612
  });
9620
9613
  //handle filter
9621
- if (!group._id) {
9622
- var _topics = [];
9623
- _topics.push(childData._id);
9624
- grandChildData.data.forEach(function (topic) {
9625
- _topics.push(topic._id);
9626
- });
9627
- setFilterTopicID(_topics);
9628
- } else {
9629
- setFilterTopicID([group._id, childData._id]);
9630
- }
9614
+ setFilterTopicID(group._id ? group._id : 'all');
9631
9615
  }
9632
9616
  };
9633
9617
 
@@ -9645,7 +9629,6 @@ var Filter = function Filter(_ref) {
9645
9629
  'All'
9646
9630
  ),
9647
9631
  parentData.data.map(function (docGroup) {
9648
- if (!docGroup._id) return null;
9649
9632
  return React__default['default'].createElement(
9650
9633
  Dropdown.Item,
9651
9634
  { key: docGroup._id, onSelect: function onSelect() {
@@ -9658,7 +9641,7 @@ var Filter = function Filter(_ref) {
9658
9641
  childData && React__default['default'].createElement(
9659
9642
  DropdownButton,
9660
9643
  { drop: 'down', style: { borderRadius: '3px' }, className: 'filter-btn ml-3', title: childData.name ? childData.name : 'Filter By Topic' },
9661
- React__default['default'].createElement(
9644
+ !parentData && React__default['default'].createElement(
9662
9645
  Dropdown.Item,
9663
9646
  { onSelect: function onSelect() {
9664
9647
  return handleFilterSelect({}, 'child');
@@ -9666,7 +9649,6 @@ var Filter = function Filter(_ref) {
9666
9649
  'All'
9667
9650
  ),
9668
9651
  childData.data.map(function (docGroup) {
9669
- if (!docGroup._id) return null;
9670
9652
  return React__default['default'].createElement(
9671
9653
  Dropdown.Item,
9672
9654
  { key: docGroup._id, onSelect: function onSelect() {
@@ -9679,7 +9661,7 @@ var Filter = function Filter(_ref) {
9679
9661
  grandChildData && React__default['default'].createElement(
9680
9662
  DropdownButton,
9681
9663
  { drop: 'down', style: { borderRadius: '3px' }, className: 'filter-btn ml-3', title: grandChildData.name ? grandChildData.name : 'Select Sub Topic' },
9682
- React__default['default'].createElement(
9664
+ !childData && React__default['default'].createElement(
9683
9665
  Dropdown.Item,
9684
9666
  { onSelect: function onSelect() {
9685
9667
  return handleFilterSelect({}, 'grandchild');
@@ -9687,7 +9669,6 @@ var Filter = function Filter(_ref) {
9687
9669
  'All'
9688
9670
  ),
9689
9671
  grandChildData.data.map(function (docGroup) {
9690
- if (!docGroup._id) return null;
9691
9672
  return React__default['default'].createElement(
9692
9673
  Dropdown.Item,
9693
9674
  { key: docGroup._id, onSelect: function onSelect() {
@@ -9740,40 +9721,25 @@ var MediaSeriesLanding = function MediaSeriesLanding(props) {
9740
9721
 
9741
9722
  var fetchFilteredData = function () {
9742
9723
  var _ref2 = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee() {
9743
- var newParams, filterQuery, x, seriesQuery, newData;
9724
+ var newParams, filterQuery, seriesQuery, newData;
9744
9725
  return asyncToGenerator.regenerator.wrap(function _callee$(_context) {
9745
9726
  while (1) {
9746
9727
  switch (_context.prev = _context.next) {
9747
9728
  case 0:
9748
9729
  newParams = _extends$1._extends({}, params, { from: 0, to: 10 });
9749
- filterQuery = void 0;
9750
-
9751
- if ((typeof filterTopicID === 'undefined' ? 'undefined' : _typeof._typeof(filterTopicID)) == 'object') {
9752
- filterQuery = '&& (';
9753
- for (x = 0; x < filterTopicID.length; x++) {
9754
- filterQuery = filterQuery + (' references(\'' + filterTopicID[x] + '\') ');
9755
- if (x == filterTopicID.length - 1) {
9756
- filterQuery = filterQuery + ' )';
9757
- } else {
9758
- filterQuery = filterQuery + ' || ';
9759
- }
9760
- }
9761
- } else {
9762
- filterQuery = filterTopicID !== 'all' ? ' && references(\'' + filterTopicID + '\')' : '';
9763
- }
9764
-
9730
+ filterQuery = filterTopicID !== 'all' ? '&& references(\'' + filterTopicID + '\')' : '';
9765
9731
  seriesQuery = '*[_type == \'documentGroup\' && references(\'' + docGroupID + '\') ' + filterQuery + ' && isSeries != false && isShow != false && defined(published) && dateTime(published) <= dateTime(now())] | order(published desc) [$from...$to] {\n _id,\n name,\n identifier,\n published,\n thumbnail,\n description,\n topicMapping[]->,\n \'pageNumber\': ' + currentPage + ',\n \'parentUrl\': \'' + parentUrl + '\'\n }';
9766
- _context.next = 6;
9732
+ _context.next = 5;
9767
9733
  return client.fetch(seriesQuery, newParams);
9768
9734
 
9769
- case 6:
9735
+ case 5:
9770
9736
  newData = _context.sent;
9771
9737
 
9772
9738
  setParams(newParams);
9773
9739
  setQuery(seriesQuery);
9774
9740
  setSeriesData(newData);
9775
9741
 
9776
- case 10:
9742
+ case 9:
9777
9743
  case 'end':
9778
9744
  return _context.stop();
9779
9745
  }
@@ -9844,7 +9810,7 @@ var MediaSeriesLanding = function MediaSeriesLanding(props) {
9844
9810
 
9845
9811
  MediaSeriesLanding.getInitialData = function () {
9846
9812
  var _ref3 = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee2(ctx, client, cache) {
9847
- var urlQuery, pathname, identifier, itemsPerPage, currentPage, start, statusCode, params, docGroupID, seriesQuery, seriesData, allSeries, buildUsedTopicsArray, usedTopics, taxonomyFilter;
9813
+ var urlQuery, pathname, identifier, itemsPerPage, currentPage, start, statusCode, params, docGroupID, seriesQuery, seriesData, taxonomyFilter;
9848
9814
  return asyncToGenerator.regenerator.wrap(function _callee2$(_context2) {
9849
9815
  while (1) {
9850
9816
  switch (_context2.prev = _context2.next) {
@@ -9873,70 +9839,19 @@ MediaSeriesLanding.getInitialData = function () {
9873
9839
  case 13:
9874
9840
  seriesData = _context2.sent;
9875
9841
  _context2.next = 16;
9876
- return client.fetch('*[_type == \'documentGroup\' && references(\'' + docGroupID._id + '\') && isSeries != false && isShow != false && defined(published) && dateTime(published) <= dateTime(now()) ] {\n topicMapping[]->\n }');
9877
-
9878
- case 16:
9879
- allSeries = _context2.sent;
9880
-
9881
- //Take all series topicMapping and put in an array
9882
- buildUsedTopicsArray = function buildUsedTopicsArray(seriesArray) {
9883
- var usedTopics = [];
9884
- for (var x = 0; x < seriesArray.length; x++) {
9885
- if (seriesArray[x].topicMapping) {
9886
- seriesArray[x].topicMapping.forEach(function (topic) {
9887
- if (!usedTopics.includes(topic._id)) {
9888
- usedTopics.push(topic._id);
9889
- }
9890
- });
9891
- }
9892
- }
9893
- return usedTopics;
9894
- };
9895
-
9896
- usedTopics = buildUsedTopicsArray(allSeries);
9897
- _context2.next = 21;
9898
9842
  return client.fetch('\n *[_type == \'taxonomy\' && !defined(parent) && isMainTopic]{\n _id,\n identifier,\n name,\n "children": *[_type == \'taxonomy\' && references(^._id)]{\n _id,\n name,\n identifier,\n "grandchildren": *[_type == \'taxonomy\' && references(^._id)]\n }\t\n }');
9899
9843
 
9900
- case 21:
9844
+ case 16:
9901
9845
  taxonomyFilter = _context2.sent;
9902
9846
 
9903
9847
 
9904
- taxonomyFilter.forEach(function (topic) {
9905
- if (topic.children) {
9906
- topic.children.forEach(function (child) {
9907
- if (child.grandchildren) {
9908
- child.grandchildren = child.grandchildren.filter(function (grandchild) {
9909
- if (!usedTopics.includes(grandchild._id)) {
9910
- return false;
9911
- }
9912
- return true;
9913
- });
9914
- }
9915
- if (!usedTopics.includes(child._id) || !child.grandchildren) {
9916
- child._id = null;
9917
- child.name = null;
9918
- }
9919
- });
9920
- }
9921
- });
9922
-
9923
9848
  if (currentPage > 1 && seriesData.length === 0) {
9924
9849
  statusCode = 404;
9925
9850
  }
9926
9851
 
9927
- return _context2.abrupt('return', defineProperty._defineProperty({
9928
- seriesData: seriesData,
9929
- query: seriesQuery,
9930
- params: params,
9931
- currentPage: currentPage,
9932
- taxonomyFilter: taxonomyFilter,
9933
- identifier: identifier,
9934
- docGroupID: docGroupID._id,
9935
- parentUrl: identifier,
9936
- statusCode: statusCode
9937
- }, 'taxonomyFilter', taxonomyFilter));
9938
-
9939
- case 25:
9852
+ return _context2.abrupt('return', defineProperty._defineProperty({ seriesData: seriesData, query: seriesQuery, params: params, currentPage: currentPage, taxonomyFilter: taxonomyFilter, identifier: identifier, docGroupID: docGroupID._id, parentUrl: identifier, statusCode: statusCode }, 'taxonomyFilter', taxonomyFilter));
9853
+
9854
+ case 19:
9940
9855
  case 'end':
9941
9856
  return _context2.stop();
9942
9857
  }
@@ -541,32 +541,102 @@ var PublicationLanding = function PublicationLanding(props) {
541
541
  }, _callee2, this, [[1, 9]]);
542
542
  }))();
543
543
  }, []);
544
+ // function for filtering by year
545
+ var filterByYear = function filterByYear(year) {
546
+ return issueData.filter(function (issue) {
547
+ return issue.year == year;
548
+ });
549
+ };
550
+
551
+ //function for filtering by Content-Placement
552
+ var filterByCP = function filterByCP(contentPlacement) {
553
+ var issuesWithTM = issueData.filter(function (issue) {
554
+ return issue.taxonomyMapping;
555
+ });
556
+ return issuesWithTM.filter(function (issue) {
557
+ return issue.taxonomyMapping.find(function (tm) {
558
+ return tm.name == contentPlacement.name;
559
+ });
560
+ });
561
+ };
562
+
563
+ //function takes yearsArray and then assigns the object with year key with corresponding year data values
564
+ var assignDatabyYear = function assignDatabyYear() {
565
+ var data_by_year = {};
566
+ for (var i = 0; i < years.length; i++) {
567
+ data_by_year[years[i]] = sortedData[i];
568
+ }
569
+ return data_by_year;
570
+ };
571
+ var assignDatabyCP = function assignDatabyCP() {
572
+ var data_by_CP = {};
573
+ for (var i = 0; i < contentPlacements.length; i++) {
574
+ data_by_CP[contentPlacements[i].name] = sorted_Content_Placement[i];
575
+ }
576
+ return data_by_CP;
577
+ };
578
+
579
+ var sortedYearly = function sortedYearly() {
580
+ var dataArray = [];
581
+ for (var i = 0; i < years.length; i++) {
582
+ dataArray[i] = filterByYear(years[i]);
583
+ }
584
+ return dataArray;
585
+ };
586
+
587
+ var sortedCP = function sortedCP() {
588
+ var dataArray = [];
589
+ for (var i = 0; i < contentPlacements.length; i++) {
590
+ dataArray[i] = filterByCP(contentPlacements[i]);
591
+ }
592
+ return dataArray;
593
+ };
594
+
595
+ var sortByBoth = function sortByBoth() {
596
+ var sortedObj = {};
597
+ for (var i = 0; i < years.length; i++) {
598
+ var dataYear = filterByYear(years[i]);
599
+ sortedObj[years[i]] = dataYear;
600
+
601
+ var _loop = function _loop(j) {
602
+ sortedObj[years[i]][contentPlacements[j].name] = dataYear.filter(function (issue) {
603
+ return issue.taxonomyMapping && issue.taxonomyMapping.find(function (tm) {
604
+ return tm.name == contentPlacements[j].name;
605
+ });
606
+ });
607
+ };
608
+
609
+ for (var j = 0; j < contentPlacements.length; j++) {
610
+ _loop(j);
611
+ }
612
+ }
613
+ return sortedObj;
614
+ };
615
+
616
+ var dataByBoth = sortByBoth();
617
+
618
+ var sortedData = sortedYearly();
619
+
620
+ var sorted_Content_Placement = sortedCP();
621
+
622
+ var dataByYear = assignDatabyYear();
623
+
624
+ var dataByCP = assignDatabyCP();
544
625
 
545
626
  React.useEffect(function () {
546
627
  if (activeYear && activeContentPlacement && activeContentPlacement.id) {
547
628
  router.push(router.pathname, '/' + (href ? href : 'publications') + '/' + publication.identifier.current + '?year=' + activeYear + '&cp=' + activeContentPlacement.id, { shallow: true });
548
- var filteredResult = issueData.filter(function (issue) {
549
- return issue.year === activeYear;
550
- }).filter(function (issue) {
551
- return issue.taxonomyMapping && issue.taxonomyMapping.find(function (tm) {
552
- return tm.identifier === activeContentPlacement.id;
553
- });
554
- });
629
+ var filteredResult = dataByBoth[activeYear][activeContentPlacement.name];
555
630
  setSortedIssues(filteredResult);
556
631
  } else if (activeYear) {
557
632
  router.push(router.pathname, '/' + (href ? href : 'publications') + '/' + publication.identifier.current + '?year=' + activeYear, { shallow: true });
558
- var _filteredResult = issueData.filter(function (issue) {
559
- return issue.year === activeYear;
560
- });
561
- setSortedIssues(_filteredResult);
633
+
634
+ var filteredData = dataByYear[activeYear];
635
+ setSortedIssues(filteredData);
562
636
  } else if (activeContentPlacement && activeContentPlacement.id) {
563
637
  router.push(router.pathname, '/' + (href ? href : 'publications') + '/' + publication.identifier.current + '?cp=' + activeContentPlacement.id, { shallow: true });
564
- var _filteredResult2 = issueData.filter(function (issue) {
565
- return issue.taxonomyMapping && issue.taxonomyMapping.find(function (tm) {
566
- return tm.identifier === activeContentPlacement.id;
567
- });
568
- });
569
- setSortedIssues(_filteredResult2);
638
+ var filteredPlacement = dataByCP[activeContentPlacement.name];
639
+ setSortedIssues(filteredPlacement);
570
640
  } else {
571
641
  router.push(router.pathname, '/' + (href ? href : 'publications') + '/' + publication.identifier.current, { shallow: true });
572
642
  setSortedIssues(null);
@@ -585,7 +655,7 @@ var PublicationLanding = function PublicationLanding(props) {
585
655
  React__default['default'].createElement(
586
656
  Row__default['default'],
587
657
  null,
588
- publication && publication.issues && publication.issues.length > 0 && years.length > 0 && React__default['default'].createElement(
658
+ issueData && issueData.length > 0 && years.length > 0 && React__default['default'].createElement(
589
659
  Col__default['default'],
590
660
  { className: 'flex-grow-0 mb-3' },
591
661
  React__default['default'].createElement(
@@ -710,7 +780,7 @@ var PublicationLanding = function PublicationLanding(props) {
710
780
  )
711
781
  )
712
782
  );
713
- }) : issueData && issueData.length > 0 && issueData.map(function (issue, key) {
783
+ }) : !activeContentPlacement && !activeYear && issueData && issueData.length > 0 ? issueData.map(function (issue, key) {
714
784
  return React__default['default'].createElement(
715
785
  Card__default['default'],
716
786
  { key: key, className: 'issueCard' },
@@ -773,7 +843,11 @@ var PublicationLanding = function PublicationLanding(props) {
773
843
  )
774
844
  )
775
845
  );
776
- }),
846
+ }) : React__default['default'].createElement(
847
+ 'em',
848
+ null,
849
+ 'New content coming soon, please check back later.'
850
+ ),
777
851
  React__default['default'].createElement(
778
852
  'style',
779
853
  { jsx: 'true' },
package/dist/cjs/View.js CHANGED
@@ -975,7 +975,7 @@ var Article = React.forwardRef(function (props, ref) {
975
975
  visibilitySensor.VisibilitySensor,
976
976
  {
977
977
  partialVisibility: true,
978
- offset: { bottom: triggerOffset, top: containerHeight - triggerOffset },
978
+ offset: { bottom: triggerOffset, top: containerHeight - 80 },
979
979
  onChange: function onChange(isVisible) {
980
980
  if (isVisible && queueData && queueData.length > 1) {
981
981
  onChangeArticle(url, meta);
@@ -1459,6 +1459,7 @@ var ArticleQueue = function ArticleQueue(props) {
1459
1459
  };
1460
1460
 
1461
1461
  var onChangeArticle = function onChangeArticle(path, meta) {
1462
+ console.log('STUFF', path, prevUrl);
1462
1463
  var newPath = '/view/' + path;
1463
1464
  var activeArticle = queueData.find(function (item) {
1464
1465
  return item.url.current === path;
@@ -1,6 +1,5 @@
1
1
  import { _ as _defineProperty } from './defineProperty-f5ff6f5a.js';
2
2
  import { a as _asyncToGenerator, r as regenerator } from './asyncToGenerator-7f8f9219.js';
3
- import { _ as _typeof } from './typeof-a286cf0c.js';
4
3
  import { _ as _extends$1 } from './extends-60e0e1c6.js';
5
4
  import { _ as _slicedToArray } from './slicedToArray-be2f7a22.js';
6
5
  import React, { useCallback, useRef, useState, useContext, useMemo, useEffect, useImperativeHandle, useReducer, forwardRef, cloneElement } from 'react';
@@ -8,7 +7,9 @@ import { c as createCommonjsModule, u as unwrapExports } from './_commonjsHelper
8
7
  import PropTypes from 'prop-types';
9
8
  import ReactDOM from 'react-dom';
10
9
  import Link from 'next/link';
10
+ import './iconBase-602d52fe.js';
11
11
  import MasterDeck from './MasterDeck.js';
12
+ import { _ as _typeof } from './typeof-a286cf0c.js';
12
13
  import { L as LazyLoad } from './index-35bdcc81.js';
13
14
  import { i as imageUrlBuilder } from './index-0dbff1d1.js';
14
15
  import { m as moment } from './moment-bc12cb97.js';
@@ -22,7 +23,6 @@ import './web.dom.iterable-4109ff68.js';
22
23
  import './_library-528f1934.js';
23
24
  import './core.get-iterator-method-133dfacd.js';
24
25
  import './_iter-detect-7e5e5ce2.js';
25
- import './_is-array-3e99e06e.js';
26
26
  import './_object-pie-133f504a.js';
27
27
  import './toConsumableArray-6d9a4616.js';
28
28
  import './inherits-a41fe93f.js';
@@ -46,6 +46,7 @@ import './stringify-59c8f690.js';
46
46
  import './Segment.js';
47
47
  import './main-b5c5aac1.js';
48
48
  import './ADInfeed-e1e18f87.js';
49
+ import './_is-array-3e99e06e.js';
49
50
  import 'react-bootstrap';
50
51
  import './index-c7e2ac95.js';
51
52
  import './util-3ab476bf.js';
@@ -60,7 +61,6 @@ import 'react-bootstrap/Pagination';
60
61
  import 'react-bootstrap/Button';
61
62
  import './entities-932b50cf.js';
62
63
  import './index.esm-3fdda599.js';
63
- import './iconBase-602d52fe.js';
64
64
  import 'react-bootstrap/Figure';
65
65
 
66
66
  function _extends() {
@@ -9564,20 +9564,20 @@ var Filter = function Filter(_ref) {
9564
9564
 
9565
9565
  useEffect(function () {
9566
9566
  if (filterData.length < 2) {
9567
- setChildData({ name: null, data: filterData[0].children, _id: filterData[0]._id });
9567
+ setChildData({ name: null, data: filterData[0].children });
9568
9568
  } else {
9569
9569
  setParentData({ name: null, data: filterData });
9570
9570
  }
9571
9571
  }, []);
9572
9572
 
9573
9573
  var handleFilterSelect = function handleFilterSelect(group, type) {
9574
+
9574
9575
  if (type === 'parent') {
9575
9576
  setParentData(function (prevState) {
9576
9577
  return _extends$1({}, prevState, { name: group.name ? group.name : null });
9577
9578
  });
9578
9579
  if (group && group.children && group.children.length > 0) {
9579
- setChildData({ data: group.children, _id: group._id });
9580
- setFilterTopicID(group._id);
9580
+ setChildData({ data: group.children });
9581
9581
  } else {
9582
9582
  //handle filter
9583
9583
  setChildData(null);
@@ -9587,17 +9587,10 @@ var Filter = function Filter(_ref) {
9587
9587
  }
9588
9588
  if (type === 'child') {
9589
9589
  setChildData(function (prevState) {
9590
- return _extends$1({}, prevState, { name: group.name ? group.name : null, _id: group._id });
9590
+ return _extends$1({}, prevState, { name: group.name ? group.name : null });
9591
9591
  });
9592
9592
  if (group && group.grandchildren && group.grandchildren.length > 0) {
9593
- setGrandChildData({ data: group.grandchildren, _id: group._id });
9594
- setFilterTopicID(group._id);
9595
- var topics = [];
9596
- topics.push(group._id);
9597
- group.grandchildren.forEach(function (topic) {
9598
- topics.push(topic._id);
9599
- });
9600
- setFilterTopicID(topics);
9593
+ setGrandChildData({ data: group.grandchildren });
9601
9594
  } else {
9602
9595
  //handle filter
9603
9596
  setGrandChildData(null);
@@ -9606,19 +9599,10 @@ var Filter = function Filter(_ref) {
9606
9599
  }
9607
9600
  if (type === 'grandchild') {
9608
9601
  setGrandChildData(function (prevState) {
9609
- return _extends$1({}, prevState, { name: group.name ? group.name : 'All', _id: group._id });
9602
+ return _extends$1({}, prevState, { name: group.name ? group.name : null });
9610
9603
  });
9611
9604
  //handle filter
9612
- if (!group._id) {
9613
- var _topics = [];
9614
- _topics.push(childData._id);
9615
- grandChildData.data.forEach(function (topic) {
9616
- _topics.push(topic._id);
9617
- });
9618
- setFilterTopicID(_topics);
9619
- } else {
9620
- setFilterTopicID([group._id, childData._id]);
9621
- }
9605
+ setFilterTopicID(group._id ? group._id : 'all');
9622
9606
  }
9623
9607
  };
9624
9608
 
@@ -9636,7 +9620,6 @@ var Filter = function Filter(_ref) {
9636
9620
  'All'
9637
9621
  ),
9638
9622
  parentData.data.map(function (docGroup) {
9639
- if (!docGroup._id) return null;
9640
9623
  return React.createElement(
9641
9624
  Dropdown.Item,
9642
9625
  { key: docGroup._id, onSelect: function onSelect() {
@@ -9649,7 +9632,7 @@ var Filter = function Filter(_ref) {
9649
9632
  childData && React.createElement(
9650
9633
  DropdownButton,
9651
9634
  { drop: 'down', style: { borderRadius: '3px' }, className: 'filter-btn ml-3', title: childData.name ? childData.name : 'Filter By Topic' },
9652
- React.createElement(
9635
+ !parentData && React.createElement(
9653
9636
  Dropdown.Item,
9654
9637
  { onSelect: function onSelect() {
9655
9638
  return handleFilterSelect({}, 'child');
@@ -9657,7 +9640,6 @@ var Filter = function Filter(_ref) {
9657
9640
  'All'
9658
9641
  ),
9659
9642
  childData.data.map(function (docGroup) {
9660
- if (!docGroup._id) return null;
9661
9643
  return React.createElement(
9662
9644
  Dropdown.Item,
9663
9645
  { key: docGroup._id, onSelect: function onSelect() {
@@ -9670,7 +9652,7 @@ var Filter = function Filter(_ref) {
9670
9652
  grandChildData && React.createElement(
9671
9653
  DropdownButton,
9672
9654
  { drop: 'down', style: { borderRadius: '3px' }, className: 'filter-btn ml-3', title: grandChildData.name ? grandChildData.name : 'Select Sub Topic' },
9673
- React.createElement(
9655
+ !childData && React.createElement(
9674
9656
  Dropdown.Item,
9675
9657
  { onSelect: function onSelect() {
9676
9658
  return handleFilterSelect({}, 'grandchild');
@@ -9678,7 +9660,6 @@ var Filter = function Filter(_ref) {
9678
9660
  'All'
9679
9661
  ),
9680
9662
  grandChildData.data.map(function (docGroup) {
9681
- if (!docGroup._id) return null;
9682
9663
  return React.createElement(
9683
9664
  Dropdown.Item,
9684
9665
  { key: docGroup._id, onSelect: function onSelect() {
@@ -9731,40 +9712,25 @@ var MediaSeriesLanding = function MediaSeriesLanding(props) {
9731
9712
 
9732
9713
  var fetchFilteredData = function () {
9733
9714
  var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
9734
- var newParams, filterQuery, x, seriesQuery, newData;
9715
+ var newParams, filterQuery, seriesQuery, newData;
9735
9716
  return regenerator.wrap(function _callee$(_context) {
9736
9717
  while (1) {
9737
9718
  switch (_context.prev = _context.next) {
9738
9719
  case 0:
9739
9720
  newParams = _extends$1({}, params, { from: 0, to: 10 });
9740
- filterQuery = void 0;
9741
-
9742
- if ((typeof filterTopicID === 'undefined' ? 'undefined' : _typeof(filterTopicID)) == 'object') {
9743
- filterQuery = '&& (';
9744
- for (x = 0; x < filterTopicID.length; x++) {
9745
- filterQuery = filterQuery + (' references(\'' + filterTopicID[x] + '\') ');
9746
- if (x == filterTopicID.length - 1) {
9747
- filterQuery = filterQuery + ' )';
9748
- } else {
9749
- filterQuery = filterQuery + ' || ';
9750
- }
9751
- }
9752
- } else {
9753
- filterQuery = filterTopicID !== 'all' ? ' && references(\'' + filterTopicID + '\')' : '';
9754
- }
9755
-
9721
+ filterQuery = filterTopicID !== 'all' ? '&& references(\'' + filterTopicID + '\')' : '';
9756
9722
  seriesQuery = '*[_type == \'documentGroup\' && references(\'' + docGroupID + '\') ' + filterQuery + ' && isSeries != false && isShow != false && defined(published) && dateTime(published) <= dateTime(now())] | order(published desc) [$from...$to] {\n _id,\n name,\n identifier,\n published,\n thumbnail,\n description,\n topicMapping[]->,\n \'pageNumber\': ' + currentPage + ',\n \'parentUrl\': \'' + parentUrl + '\'\n }';
9757
- _context.next = 6;
9723
+ _context.next = 5;
9758
9724
  return client.fetch(seriesQuery, newParams);
9759
9725
 
9760
- case 6:
9726
+ case 5:
9761
9727
  newData = _context.sent;
9762
9728
 
9763
9729
  setParams(newParams);
9764
9730
  setQuery(seriesQuery);
9765
9731
  setSeriesData(newData);
9766
9732
 
9767
- case 10:
9733
+ case 9:
9768
9734
  case 'end':
9769
9735
  return _context.stop();
9770
9736
  }
@@ -9835,7 +9801,7 @@ var MediaSeriesLanding = function MediaSeriesLanding(props) {
9835
9801
 
9836
9802
  MediaSeriesLanding.getInitialData = function () {
9837
9803
  var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(ctx, client, cache) {
9838
- var urlQuery, pathname, identifier, itemsPerPage, currentPage, start, statusCode, params, docGroupID, seriesQuery, seriesData, allSeries, buildUsedTopicsArray, usedTopics, taxonomyFilter;
9804
+ var urlQuery, pathname, identifier, itemsPerPage, currentPage, start, statusCode, params, docGroupID, seriesQuery, seriesData, taxonomyFilter;
9839
9805
  return regenerator.wrap(function _callee2$(_context2) {
9840
9806
  while (1) {
9841
9807
  switch (_context2.prev = _context2.next) {
@@ -9864,70 +9830,19 @@ MediaSeriesLanding.getInitialData = function () {
9864
9830
  case 13:
9865
9831
  seriesData = _context2.sent;
9866
9832
  _context2.next = 16;
9867
- return client.fetch('*[_type == \'documentGroup\' && references(\'' + docGroupID._id + '\') && isSeries != false && isShow != false && defined(published) && dateTime(published) <= dateTime(now()) ] {\n topicMapping[]->\n }');
9868
-
9869
- case 16:
9870
- allSeries = _context2.sent;
9871
-
9872
- //Take all series topicMapping and put in an array
9873
- buildUsedTopicsArray = function buildUsedTopicsArray(seriesArray) {
9874
- var usedTopics = [];
9875
- for (var x = 0; x < seriesArray.length; x++) {
9876
- if (seriesArray[x].topicMapping) {
9877
- seriesArray[x].topicMapping.forEach(function (topic) {
9878
- if (!usedTopics.includes(topic._id)) {
9879
- usedTopics.push(topic._id);
9880
- }
9881
- });
9882
- }
9883
- }
9884
- return usedTopics;
9885
- };
9886
-
9887
- usedTopics = buildUsedTopicsArray(allSeries);
9888
- _context2.next = 21;
9889
9833
  return client.fetch('\n *[_type == \'taxonomy\' && !defined(parent) && isMainTopic]{\n _id,\n identifier,\n name,\n "children": *[_type == \'taxonomy\' && references(^._id)]{\n _id,\n name,\n identifier,\n "grandchildren": *[_type == \'taxonomy\' && references(^._id)]\n }\t\n }');
9890
9834
 
9891
- case 21:
9835
+ case 16:
9892
9836
  taxonomyFilter = _context2.sent;
9893
9837
 
9894
9838
 
9895
- taxonomyFilter.forEach(function (topic) {
9896
- if (topic.children) {
9897
- topic.children.forEach(function (child) {
9898
- if (child.grandchildren) {
9899
- child.grandchildren = child.grandchildren.filter(function (grandchild) {
9900
- if (!usedTopics.includes(grandchild._id)) {
9901
- return false;
9902
- }
9903
- return true;
9904
- });
9905
- }
9906
- if (!usedTopics.includes(child._id) || !child.grandchildren) {
9907
- child._id = null;
9908
- child.name = null;
9909
- }
9910
- });
9911
- }
9912
- });
9913
-
9914
9839
  if (currentPage > 1 && seriesData.length === 0) {
9915
9840
  statusCode = 404;
9916
9841
  }
9917
9842
 
9918
- return _context2.abrupt('return', _defineProperty({
9919
- seriesData: seriesData,
9920
- query: seriesQuery,
9921
- params: params,
9922
- currentPage: currentPage,
9923
- taxonomyFilter: taxonomyFilter,
9924
- identifier: identifier,
9925
- docGroupID: docGroupID._id,
9926
- parentUrl: identifier,
9927
- statusCode: statusCode
9928
- }, 'taxonomyFilter', taxonomyFilter));
9929
-
9930
- case 25:
9843
+ return _context2.abrupt('return', _defineProperty({ seriesData: seriesData, query: seriesQuery, params: params, currentPage: currentPage, taxonomyFilter: taxonomyFilter, identifier: identifier, docGroupID: docGroupID._id, parentUrl: identifier, statusCode: statusCode }, 'taxonomyFilter', taxonomyFilter));
9844
+
9845
+ case 19:
9931
9846
  case 'end':
9932
9847
  return _context2.stop();
9933
9848
  }
@@ -531,32 +531,102 @@ var PublicationLanding = function PublicationLanding(props) {
531
531
  }, _callee2, this, [[1, 9]]);
532
532
  }))();
533
533
  }, []);
534
+ // function for filtering by year
535
+ var filterByYear = function filterByYear(year) {
536
+ return issueData.filter(function (issue) {
537
+ return issue.year == year;
538
+ });
539
+ };
540
+
541
+ //function for filtering by Content-Placement
542
+ var filterByCP = function filterByCP(contentPlacement) {
543
+ var issuesWithTM = issueData.filter(function (issue) {
544
+ return issue.taxonomyMapping;
545
+ });
546
+ return issuesWithTM.filter(function (issue) {
547
+ return issue.taxonomyMapping.find(function (tm) {
548
+ return tm.name == contentPlacement.name;
549
+ });
550
+ });
551
+ };
552
+
553
+ //function takes yearsArray and then assigns the object with year key with corresponding year data values
554
+ var assignDatabyYear = function assignDatabyYear() {
555
+ var data_by_year = {};
556
+ for (var i = 0; i < years.length; i++) {
557
+ data_by_year[years[i]] = sortedData[i];
558
+ }
559
+ return data_by_year;
560
+ };
561
+ var assignDatabyCP = function assignDatabyCP() {
562
+ var data_by_CP = {};
563
+ for (var i = 0; i < contentPlacements.length; i++) {
564
+ data_by_CP[contentPlacements[i].name] = sorted_Content_Placement[i];
565
+ }
566
+ return data_by_CP;
567
+ };
568
+
569
+ var sortedYearly = function sortedYearly() {
570
+ var dataArray = [];
571
+ for (var i = 0; i < years.length; i++) {
572
+ dataArray[i] = filterByYear(years[i]);
573
+ }
574
+ return dataArray;
575
+ };
576
+
577
+ var sortedCP = function sortedCP() {
578
+ var dataArray = [];
579
+ for (var i = 0; i < contentPlacements.length; i++) {
580
+ dataArray[i] = filterByCP(contentPlacements[i]);
581
+ }
582
+ return dataArray;
583
+ };
584
+
585
+ var sortByBoth = function sortByBoth() {
586
+ var sortedObj = {};
587
+ for (var i = 0; i < years.length; i++) {
588
+ var dataYear = filterByYear(years[i]);
589
+ sortedObj[years[i]] = dataYear;
590
+
591
+ var _loop = function _loop(j) {
592
+ sortedObj[years[i]][contentPlacements[j].name] = dataYear.filter(function (issue) {
593
+ return issue.taxonomyMapping && issue.taxonomyMapping.find(function (tm) {
594
+ return tm.name == contentPlacements[j].name;
595
+ });
596
+ });
597
+ };
598
+
599
+ for (var j = 0; j < contentPlacements.length; j++) {
600
+ _loop(j);
601
+ }
602
+ }
603
+ return sortedObj;
604
+ };
605
+
606
+ var dataByBoth = sortByBoth();
607
+
608
+ var sortedData = sortedYearly();
609
+
610
+ var sorted_Content_Placement = sortedCP();
611
+
612
+ var dataByYear = assignDatabyYear();
613
+
614
+ var dataByCP = assignDatabyCP();
534
615
 
535
616
  useEffect(function () {
536
617
  if (activeYear && activeContentPlacement && activeContentPlacement.id) {
537
618
  router.push(router.pathname, '/' + (href ? href : 'publications') + '/' + publication.identifier.current + '?year=' + activeYear + '&cp=' + activeContentPlacement.id, { shallow: true });
538
- var filteredResult = issueData.filter(function (issue) {
539
- return issue.year === activeYear;
540
- }).filter(function (issue) {
541
- return issue.taxonomyMapping && issue.taxonomyMapping.find(function (tm) {
542
- return tm.identifier === activeContentPlacement.id;
543
- });
544
- });
619
+ var filteredResult = dataByBoth[activeYear][activeContentPlacement.name];
545
620
  setSortedIssues(filteredResult);
546
621
  } else if (activeYear) {
547
622
  router.push(router.pathname, '/' + (href ? href : 'publications') + '/' + publication.identifier.current + '?year=' + activeYear, { shallow: true });
548
- var _filteredResult = issueData.filter(function (issue) {
549
- return issue.year === activeYear;
550
- });
551
- setSortedIssues(_filteredResult);
623
+
624
+ var filteredData = dataByYear[activeYear];
625
+ setSortedIssues(filteredData);
552
626
  } else if (activeContentPlacement && activeContentPlacement.id) {
553
627
  router.push(router.pathname, '/' + (href ? href : 'publications') + '/' + publication.identifier.current + '?cp=' + activeContentPlacement.id, { shallow: true });
554
- var _filteredResult2 = issueData.filter(function (issue) {
555
- return issue.taxonomyMapping && issue.taxonomyMapping.find(function (tm) {
556
- return tm.identifier === activeContentPlacement.id;
557
- });
558
- });
559
- setSortedIssues(_filteredResult2);
628
+ var filteredPlacement = dataByCP[activeContentPlacement.name];
629
+ setSortedIssues(filteredPlacement);
560
630
  } else {
561
631
  router.push(router.pathname, '/' + (href ? href : 'publications') + '/' + publication.identifier.current, { shallow: true });
562
632
  setSortedIssues(null);
@@ -575,7 +645,7 @@ var PublicationLanding = function PublicationLanding(props) {
575
645
  React.createElement(
576
646
  Row,
577
647
  null,
578
- publication && publication.issues && publication.issues.length > 0 && years.length > 0 && React.createElement(
648
+ issueData && issueData.length > 0 && years.length > 0 && React.createElement(
579
649
  Col,
580
650
  { className: 'flex-grow-0 mb-3' },
581
651
  React.createElement(
@@ -700,7 +770,7 @@ var PublicationLanding = function PublicationLanding(props) {
700
770
  )
701
771
  )
702
772
  );
703
- }) : issueData && issueData.length > 0 && issueData.map(function (issue, key) {
773
+ }) : !activeContentPlacement && !activeYear && issueData && issueData.length > 0 ? issueData.map(function (issue, key) {
704
774
  return React.createElement(
705
775
  Card,
706
776
  { key: key, className: 'issueCard' },
@@ -763,7 +833,11 @@ var PublicationLanding = function PublicationLanding(props) {
763
833
  )
764
834
  )
765
835
  );
766
- }),
836
+ }) : React.createElement(
837
+ 'em',
838
+ null,
839
+ 'New content coming soon, please check back later.'
840
+ ),
767
841
  React.createElement(
768
842
  'style',
769
843
  { jsx: 'true' },
package/dist/esm/View.js CHANGED
@@ -965,7 +965,7 @@ var Article = forwardRef(function (props, ref) {
965
965
  VisibilitySensor,
966
966
  {
967
967
  partialVisibility: true,
968
- offset: { bottom: triggerOffset, top: containerHeight - triggerOffset },
968
+ offset: { bottom: triggerOffset, top: containerHeight - 80 },
969
969
  onChange: function onChange(isVisible) {
970
970
  if (isVisible && queueData && queueData.length > 1) {
971
971
  onChangeArticle(url, meta);
@@ -1449,6 +1449,7 @@ var ArticleQueue = function ArticleQueue(props) {
1449
1449
  };
1450
1450
 
1451
1451
  var onChangeArticle = function onChangeArticle(path, meta) {
1452
+ console.log('STUFF', path, prevUrl);
1452
1453
  var newPath = '/view/' + path;
1453
1454
  var activeArticle = queueData.find(function (item) {
1454
1455
  return item.url.current === path;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mjhls/mjh-framework",
3
- "version": "1.0.790-filter-test",
3
+ "version": "1.0.790-scroll-change-test",
4
4
  "description": "Foundation Framework",
5
5
  "author": "mjh-framework",
6
6
  "license": "MIT",