@mjhls/mjh-framework 1.0.704 → 1.0.705

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/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- # mjh-framework v. 1.0.703
2
+ # mjh-framework v. 1.0.705
3
3
 
4
4
  > Foundation Framework
5
5
 
@@ -415,36 +415,86 @@ Publication.getInitialProps = async (ctx) => {
415
415
  export default Publication
416
416
  */
417
417
 
418
+ var generateContentPlacements = function generateContentPlacements(issues) {
419
+ var contentPlacements = [];
420
+ issues && issues.length > 0 && issues.forEach(function (issue) {
421
+ if (issue.taxonomyMapping && issue.taxonomyMapping.length > 0) {
422
+ issue.taxonomyMapping && issue.taxonomyMapping.forEach(function (tm) {
423
+ if (!contentPlacements.find(function (cp) {
424
+ return cp.identifier === tm.identifier;
425
+ })) {
426
+ contentPlacements.push({ _id: tm._id, name: tm.name, identifier: tm.identifier });
427
+ }
428
+ });
429
+ }
430
+ });
431
+ return contentPlacements;
432
+ };
433
+
418
434
  var PublicationLanding = function PublicationLanding(props) {
419
435
  var publication = props.publication,
420
- year = props.year,
436
+ _props$year = props.year,
437
+ year = _props$year === undefined ? '' : _props$year,
421
438
  href = props.href;
422
439
  props.pdf;
440
+ var _props$contentPlaceme = props.contentPlacement,
441
+ contentPlacement = _props$contentPlaceme === undefined ? '' : _props$contentPlaceme;
423
442
 
424
443
 
425
444
  var router = Router.useRouter();
426
445
  var years = [].concat(toConsumableArray._toConsumableArray(new _Set(publication.issues.map(function (issue) {
427
446
  return issue.year;
428
447
  })))).sort().reverse();
448
+ var contentPlacements = generateContentPlacements(publication.issues);
429
449
 
430
450
  var _useState = React.useState(publication.issues),
431
451
  _useState2 = slicedToArray._slicedToArray(_useState, 2),
432
452
  issueData = _useState2[0],
433
453
  setIssueData = _useState2[1];
434
454
 
435
- var _useState3 = React.useState(year ? year : years[0]),
455
+ var _useState3 = React.useState(year),
436
456
  _useState4 = slicedToArray._slicedToArray(_useState3, 2),
437
457
  activeYear = _useState4[0],
438
458
  setActiveYear = _useState4[1];
439
459
 
460
+ var _useState5 = React.useState(contentPlacement),
461
+ _useState6 = slicedToArray._slicedToArray(_useState5, 2),
462
+ activeContentPlacement = _useState6[0],
463
+ setActiveContentPlacement = _useState6[1];
464
+
440
465
  React.useEffect(function () {
441
- router.push(router.pathname, '/' + (href ? href : 'publications') + '/' + publication.identifier.current + '?year=' + activeYear, { shallow: true });
442
- setIssueData(function () {
443
- return publication.issues.filter(function (issue) {
444
- return issue.year === activeYear;
466
+ if (activeYear && activeContentPlacement) {
467
+ router.push(router.pathname, '/' + (href ? href : 'publications') + '/' + publication.identifier.current + '?year=' + activeYear + '&cp=' + activeContentPlacement, { shallow: true });
468
+ setIssueData(function () {
469
+ return publication.issues.filter(function (issue) {
470
+ return issue.year === activeYear;
471
+ }).filter(function (issue) {
472
+ return issue.taxonomyMapping && issue.taxonomyMapping.find(function (tm) {
473
+ return tm.identifier === activeContentPlacement;
474
+ });
475
+ });
445
476
  });
446
- });
447
- }, [activeYear]);
477
+ } else if (activeYear) {
478
+ router.push(router.pathname, '/' + (href ? href : 'publications') + '/' + publication.identifier.current + '?year=' + activeYear, { shallow: true });
479
+ setIssueData(function () {
480
+ return publication.issues.filter(function (issue) {
481
+ return issue.year === activeYear;
482
+ });
483
+ });
484
+ } else if (activeContentPlacement) {
485
+ router.push(router.pathname, '/' + (href ? href : 'publications') + '/' + publication.identifier.current + '?cp=' + activeContentPlacement, { shallow: true });
486
+ setIssueData(function () {
487
+ return publication.issues.filter(function (issue) {
488
+ return issue.taxonomyMapping && issue.taxonomyMapping.find(function (tm) {
489
+ return tm.identifier === activeContentPlacement;
490
+ });
491
+ });
492
+ });
493
+ } else {
494
+ router.push(router.pathname, '/' + (href ? href : 'publications') + '/' + publication.identifier.current, { shallow: true });
495
+ setIssueData(publication.issues);
496
+ }
497
+ }, [activeYear, activeContentPlacement]);
448
498
 
449
499
  return React__default['default'].createElement(
450
500
  'div',
@@ -452,25 +502,28 @@ var PublicationLanding = function PublicationLanding(props) {
452
502
  React__default['default'].createElement(
453
503
  'style',
454
504
  { jsx: true },
455
- '\n #pubYearFilter .dropdown-menu.show {\n max-height: 25vh;\n }\n '
505
+ '\n #pubYearFilter .dropdown-menu.show,\n #contentPlacementFilter .dropdown-menu.show {\n max-height: 25vh;\n overflow: auto;\n }\n '
456
506
  ),
457
507
  React__default['default'].createElement(
458
508
  Row__default['default'],
459
- { style: { marginBottom: '1rem' } },
509
+ null,
460
510
  React__default['default'].createElement(
461
511
  Col__default['default'],
462
- null,
512
+ { className: 'flex-grow-0 mb-3' },
463
513
  React__default['default'].createElement(
464
514
  Dropdown__default['default'],
465
515
  { id: 'pubYearFilter' },
466
516
  React__default['default'].createElement(
467
517
  Dropdown__default['default'].Toggle,
468
518
  null,
469
- activeYear
519
+ activeYear ? activeYear : 'Select Year'
470
520
  ),
471
521
  React__default['default'].createElement(
472
522
  Dropdown__default['default'].Menu,
473
523
  null,
524
+ React__default['default'].createElement(Dropdown__default['default'].Item, { style: { height: '2rem' }, onClick: function onClick() {
525
+ return setActiveYear('');
526
+ } }),
474
527
  years.map(function (yr, key) {
475
528
  return React__default['default'].createElement(
476
529
  Dropdown__default['default'].Item,
@@ -482,6 +535,35 @@ var PublicationLanding = function PublicationLanding(props) {
482
535
  })
483
536
  )
484
537
  )
538
+ ),
539
+ contentPlacements && contentPlacements.length > 0 && React__default['default'].createElement(
540
+ Col__default['default'],
541
+ { className: 'flex-grow-0 mb-3' },
542
+ React__default['default'].createElement(
543
+ Dropdown__default['default'],
544
+ { id: 'contentPlacementFilter' },
545
+ React__default['default'].createElement(
546
+ Dropdown__default['default'].Toggle,
547
+ null,
548
+ activeContentPlacement ? activeContentPlacement : 'Select Content Placement'
549
+ ),
550
+ React__default['default'].createElement(
551
+ Dropdown__default['default'].Menu,
552
+ null,
553
+ React__default['default'].createElement(Dropdown__default['default'].Item, { style: { height: '2rem' }, onClick: function onClick() {
554
+ return setActiveContentPlacement('');
555
+ } }),
556
+ contentPlacements.map(function (cp) {
557
+ return React__default['default'].createElement(
558
+ Dropdown__default['default'].Item,
559
+ { key: cp._id, onClick: function onClick() {
560
+ return setActiveContentPlacement(cp.identifier);
561
+ } },
562
+ cp.name
563
+ );
564
+ })
565
+ )
566
+ )
485
567
  )
486
568
  ),
487
569
  issueData && issueData.length > 0 ? issueData.map(function (issue, key) {
@@ -559,7 +641,7 @@ var PublicationLanding = function PublicationLanding(props) {
559
641
  React__default['default'].createElement(
560
642
  'style',
561
643
  { jsx: 'true' },
562
- '\n .issueCard.card:hover {\n cursor: default;\n }\n .content-category-label {\n margin: 0.5rem 0;\n display: block;\n }\n .sanityDisplayLabel {\n margin: 0.5rem 0;\n border: 1px solid black;\n display: inline;\n width: 100%;\n padding: 5px;\n color: #484848;\n border-radius: 2px;\n }\n '
644
+ '\n .issueCard.card:hover {\n cursor: default;\n }\n .content-category-label {\n margin: 0.5rem 0;\n display: block;\n }\n .sanityDisplayLabel {\n margin: 0.5rem 0;\n border: 1px solid black;\n display: inline;\n width: 100%;\n padding: 5px;\n color: #484848;\n border-radius: 2px;\n }\n .dropdown-toggle {\n min-width: 5rem;\n }\n .dropdown-toggle:empty:after {\n margin-left: 4rem;\n }\n '
563
645
  )
564
646
  );
565
647
  };
@@ -14,7 +14,7 @@ var getQuery = function getQuery(type) {
14
14
  case 'article':
15
15
  return '*[\n _type == "article"\n && !(_id in path("drafts.**"))\n && defined(title)\n && defined(url)\n && url.current == $url\n ' + conditions + '\n ][0]{\n ' + params + '\n title,\n published,\n summary,\n thumbnail,\n ...,\n passwordLock,\n password,\n issueGroup-> { _id, name, identifier, parent-> },\n "authorDetails": authorMapping[]->{ displayName, url, profileImage, biography },\n body[] {\n ...,\n upload_doc {\n _type,\n asset->\n },\n uploadAudio {\n _type,\n asset->\n },\n medias[]{\n ...,\n upload_doc {\n _type,\n asset-> \n } \n },\n articles[]{\n ...,\n "authorDetails": authorMapping[]->{ displayName, url, profileImage, biography },\n text[]{\n ...,\n upload_doc {\n _type,\n asset->\n },\n uploadAudio {\n _type,\n asset->\n },\n }\n }\n },\n \'content_placement\': taxonomyMapping[]-> {\n ...,\n \'ancestor\': parent->parent->identifier,\n \'parent\': parent->identifier,\n \'name\': name,\n \'path\': identifier\n },\n documentGroup-> {\n name,\n thumbnail,\n parent->{...,parent->},\n \'path\': identifier.current\n },\n documentGroupMapping[]-> {\n _id,\n name,\n thumbnail,\n parent->{...,parent->},\n \'path\': identifier.current\n },\n \'category\':contentCategory->{\n name,\n disableAds\n },\n \'issue\' : *[_type == \'publication\' && !(_id in path("drafts.**")) && is_visible == true && _id == ^.issueGroup._ref][0] {\n name,\n volume,\n \'issueNumber\': number,\n \'articleSource\': source,\n \'path\': identifier.current,\n \'publication\' : *[_type == \'publication\' && !(_id in path("drafts.**")) && is_visible == true && _id == ^.parent._ref][0] {\n name,\n \'path\': identifier.current\n },\n \'url\' : pdf.asset-> url\n }\n\n }';
16
16
  case 'publication':
17
- return '*[_type == \'publication\'\n && identifier.current == $publication\n ' + conditions + '][0] {\n ' + params + '\n ...,\n \'issues\': *[_type == \'publication\'\n && is_visible\n && references(^._id)\n && defined(identifier)] {\n ...,\n pdf{asset->}\n } | order(year desc, month desc)\n }';
17
+ return '*[_type == \'publication\'\n && identifier.current == $publication\n ' + conditions + '][0] {\n ' + params + '\n ...,\n \'issues\': *[_type == \'publication\'\n && is_visible\n && references(^._id)\n && defined(identifier)] {\n ...,\n taxonomyMapping[]->,\n pdf{asset->}\n } | order(year desc, month desc)\n }';
18
18
  case 'issue':
19
19
  return '*[_type == \'publication\'\n && identifier.current == $publication\n ' + conditions + '][0] {\n ' + params + '\n ...,\n \'issue\': *[_type == \'publication\'\n && references(^._id)\n && identifier.current == $issue][0] {\n ...,\n \'articles\': *[_type == \'article\'\n && !(_id in path("drafts.**"))\n && defined(title)\n && is_visible\n && defined(url)\n && defined(published) \n && dateTime(published) <= dateTime(now())\n && passwordLock != true\n && references(^._id)] | order(published desc) {\n ...,\n authorMapping[0]->,\n contentCategory->,\n issueSection-> {\n name\n }\n }\n }\n }';
20
20
  case 'externalResources':
@@ -405,36 +405,86 @@ Publication.getInitialProps = async (ctx) => {
405
405
  export default Publication
406
406
  */
407
407
 
408
+ var generateContentPlacements = function generateContentPlacements(issues) {
409
+ var contentPlacements = [];
410
+ issues && issues.length > 0 && issues.forEach(function (issue) {
411
+ if (issue.taxonomyMapping && issue.taxonomyMapping.length > 0) {
412
+ issue.taxonomyMapping && issue.taxonomyMapping.forEach(function (tm) {
413
+ if (!contentPlacements.find(function (cp) {
414
+ return cp.identifier === tm.identifier;
415
+ })) {
416
+ contentPlacements.push({ _id: tm._id, name: tm.name, identifier: tm.identifier });
417
+ }
418
+ });
419
+ }
420
+ });
421
+ return contentPlacements;
422
+ };
423
+
408
424
  var PublicationLanding = function PublicationLanding(props) {
409
425
  var publication = props.publication,
410
- year = props.year,
426
+ _props$year = props.year,
427
+ year = _props$year === undefined ? '' : _props$year,
411
428
  href = props.href;
412
429
  props.pdf;
430
+ var _props$contentPlaceme = props.contentPlacement,
431
+ contentPlacement = _props$contentPlaceme === undefined ? '' : _props$contentPlaceme;
413
432
 
414
433
 
415
434
  var router = useRouter();
416
435
  var years = [].concat(_toConsumableArray(new _Set(publication.issues.map(function (issue) {
417
436
  return issue.year;
418
437
  })))).sort().reverse();
438
+ var contentPlacements = generateContentPlacements(publication.issues);
419
439
 
420
440
  var _useState = useState(publication.issues),
421
441
  _useState2 = _slicedToArray(_useState, 2),
422
442
  issueData = _useState2[0],
423
443
  setIssueData = _useState2[1];
424
444
 
425
- var _useState3 = useState(year ? year : years[0]),
445
+ var _useState3 = useState(year),
426
446
  _useState4 = _slicedToArray(_useState3, 2),
427
447
  activeYear = _useState4[0],
428
448
  setActiveYear = _useState4[1];
429
449
 
450
+ var _useState5 = useState(contentPlacement),
451
+ _useState6 = _slicedToArray(_useState5, 2),
452
+ activeContentPlacement = _useState6[0],
453
+ setActiveContentPlacement = _useState6[1];
454
+
430
455
  useEffect(function () {
431
- router.push(router.pathname, '/' + (href ? href : 'publications') + '/' + publication.identifier.current + '?year=' + activeYear, { shallow: true });
432
- setIssueData(function () {
433
- return publication.issues.filter(function (issue) {
434
- return issue.year === activeYear;
456
+ if (activeYear && activeContentPlacement) {
457
+ router.push(router.pathname, '/' + (href ? href : 'publications') + '/' + publication.identifier.current + '?year=' + activeYear + '&cp=' + activeContentPlacement, { shallow: true });
458
+ setIssueData(function () {
459
+ return publication.issues.filter(function (issue) {
460
+ return issue.year === activeYear;
461
+ }).filter(function (issue) {
462
+ return issue.taxonomyMapping && issue.taxonomyMapping.find(function (tm) {
463
+ return tm.identifier === activeContentPlacement;
464
+ });
465
+ });
435
466
  });
436
- });
437
- }, [activeYear]);
467
+ } else if (activeYear) {
468
+ router.push(router.pathname, '/' + (href ? href : 'publications') + '/' + publication.identifier.current + '?year=' + activeYear, { shallow: true });
469
+ setIssueData(function () {
470
+ return publication.issues.filter(function (issue) {
471
+ return issue.year === activeYear;
472
+ });
473
+ });
474
+ } else if (activeContentPlacement) {
475
+ router.push(router.pathname, '/' + (href ? href : 'publications') + '/' + publication.identifier.current + '?cp=' + activeContentPlacement, { shallow: true });
476
+ setIssueData(function () {
477
+ return publication.issues.filter(function (issue) {
478
+ return issue.taxonomyMapping && issue.taxonomyMapping.find(function (tm) {
479
+ return tm.identifier === activeContentPlacement;
480
+ });
481
+ });
482
+ });
483
+ } else {
484
+ router.push(router.pathname, '/' + (href ? href : 'publications') + '/' + publication.identifier.current, { shallow: true });
485
+ setIssueData(publication.issues);
486
+ }
487
+ }, [activeYear, activeContentPlacement]);
438
488
 
439
489
  return React.createElement(
440
490
  'div',
@@ -442,25 +492,28 @@ var PublicationLanding = function PublicationLanding(props) {
442
492
  React.createElement(
443
493
  'style',
444
494
  { jsx: true },
445
- '\n #pubYearFilter .dropdown-menu.show {\n max-height: 25vh;\n }\n '
495
+ '\n #pubYearFilter .dropdown-menu.show,\n #contentPlacementFilter .dropdown-menu.show {\n max-height: 25vh;\n overflow: auto;\n }\n '
446
496
  ),
447
497
  React.createElement(
448
498
  Row,
449
- { style: { marginBottom: '1rem' } },
499
+ null,
450
500
  React.createElement(
451
501
  Col,
452
- null,
502
+ { className: 'flex-grow-0 mb-3' },
453
503
  React.createElement(
454
504
  Dropdown,
455
505
  { id: 'pubYearFilter' },
456
506
  React.createElement(
457
507
  Dropdown.Toggle,
458
508
  null,
459
- activeYear
509
+ activeYear ? activeYear : 'Select Year'
460
510
  ),
461
511
  React.createElement(
462
512
  Dropdown.Menu,
463
513
  null,
514
+ React.createElement(Dropdown.Item, { style: { height: '2rem' }, onClick: function onClick() {
515
+ return setActiveYear('');
516
+ } }),
464
517
  years.map(function (yr, key) {
465
518
  return React.createElement(
466
519
  Dropdown.Item,
@@ -472,6 +525,35 @@ var PublicationLanding = function PublicationLanding(props) {
472
525
  })
473
526
  )
474
527
  )
528
+ ),
529
+ contentPlacements && contentPlacements.length > 0 && React.createElement(
530
+ Col,
531
+ { className: 'flex-grow-0 mb-3' },
532
+ React.createElement(
533
+ Dropdown,
534
+ { id: 'contentPlacementFilter' },
535
+ React.createElement(
536
+ Dropdown.Toggle,
537
+ null,
538
+ activeContentPlacement ? activeContentPlacement : 'Select Content Placement'
539
+ ),
540
+ React.createElement(
541
+ Dropdown.Menu,
542
+ null,
543
+ React.createElement(Dropdown.Item, { style: { height: '2rem' }, onClick: function onClick() {
544
+ return setActiveContentPlacement('');
545
+ } }),
546
+ contentPlacements.map(function (cp) {
547
+ return React.createElement(
548
+ Dropdown.Item,
549
+ { key: cp._id, onClick: function onClick() {
550
+ return setActiveContentPlacement(cp.identifier);
551
+ } },
552
+ cp.name
553
+ );
554
+ })
555
+ )
556
+ )
475
557
  )
476
558
  ),
477
559
  issueData && issueData.length > 0 ? issueData.map(function (issue, key) {
@@ -549,7 +631,7 @@ var PublicationLanding = function PublicationLanding(props) {
549
631
  React.createElement(
550
632
  'style',
551
633
  { jsx: 'true' },
552
- '\n .issueCard.card:hover {\n cursor: default;\n }\n .content-category-label {\n margin: 0.5rem 0;\n display: block;\n }\n .sanityDisplayLabel {\n margin: 0.5rem 0;\n border: 1px solid black;\n display: inline;\n width: 100%;\n padding: 5px;\n color: #484848;\n border-radius: 2px;\n }\n '
634
+ '\n .issueCard.card:hover {\n cursor: default;\n }\n .content-category-label {\n margin: 0.5rem 0;\n display: block;\n }\n .sanityDisplayLabel {\n margin: 0.5rem 0;\n border: 1px solid black;\n display: inline;\n width: 100%;\n padding: 5px;\n color: #484848;\n border-radius: 2px;\n }\n .dropdown-toggle {\n min-width: 5rem;\n }\n .dropdown-toggle:empty:after {\n margin-left: 4rem;\n }\n '
553
635
  )
554
636
  );
555
637
  };
@@ -12,7 +12,7 @@ var getQuery = function getQuery(type) {
12
12
  case 'article':
13
13
  return '*[\n _type == "article"\n && !(_id in path("drafts.**"))\n && defined(title)\n && defined(url)\n && url.current == $url\n ' + conditions + '\n ][0]{\n ' + params + '\n title,\n published,\n summary,\n thumbnail,\n ...,\n passwordLock,\n password,\n issueGroup-> { _id, name, identifier, parent-> },\n "authorDetails": authorMapping[]->{ displayName, url, profileImage, biography },\n body[] {\n ...,\n upload_doc {\n _type,\n asset->\n },\n uploadAudio {\n _type,\n asset->\n },\n medias[]{\n ...,\n upload_doc {\n _type,\n asset-> \n } \n },\n articles[]{\n ...,\n "authorDetails": authorMapping[]->{ displayName, url, profileImage, biography },\n text[]{\n ...,\n upload_doc {\n _type,\n asset->\n },\n uploadAudio {\n _type,\n asset->\n },\n }\n }\n },\n \'content_placement\': taxonomyMapping[]-> {\n ...,\n \'ancestor\': parent->parent->identifier,\n \'parent\': parent->identifier,\n \'name\': name,\n \'path\': identifier\n },\n documentGroup-> {\n name,\n thumbnail,\n parent->{...,parent->},\n \'path\': identifier.current\n },\n documentGroupMapping[]-> {\n _id,\n name,\n thumbnail,\n parent->{...,parent->},\n \'path\': identifier.current\n },\n \'category\':contentCategory->{\n name,\n disableAds\n },\n \'issue\' : *[_type == \'publication\' && !(_id in path("drafts.**")) && is_visible == true && _id == ^.issueGroup._ref][0] {\n name,\n volume,\n \'issueNumber\': number,\n \'articleSource\': source,\n \'path\': identifier.current,\n \'publication\' : *[_type == \'publication\' && !(_id in path("drafts.**")) && is_visible == true && _id == ^.parent._ref][0] {\n name,\n \'path\': identifier.current\n },\n \'url\' : pdf.asset-> url\n }\n\n }';
14
14
  case 'publication':
15
- return '*[_type == \'publication\'\n && identifier.current == $publication\n ' + conditions + '][0] {\n ' + params + '\n ...,\n \'issues\': *[_type == \'publication\'\n && is_visible\n && references(^._id)\n && defined(identifier)] {\n ...,\n pdf{asset->}\n } | order(year desc, month desc)\n }';
15
+ return '*[_type == \'publication\'\n && identifier.current == $publication\n ' + conditions + '][0] {\n ' + params + '\n ...,\n \'issues\': *[_type == \'publication\'\n && is_visible\n && references(^._id)\n && defined(identifier)] {\n ...,\n taxonomyMapping[]->,\n pdf{asset->}\n } | order(year desc, month desc)\n }';
16
16
  case 'issue':
17
17
  return '*[_type == \'publication\'\n && identifier.current == $publication\n ' + conditions + '][0] {\n ' + params + '\n ...,\n \'issue\': *[_type == \'publication\'\n && references(^._id)\n && identifier.current == $issue][0] {\n ...,\n \'articles\': *[_type == \'article\'\n && !(_id in path("drafts.**"))\n && defined(title)\n && is_visible\n && defined(url)\n && defined(published) \n && dateTime(published) <= dateTime(now())\n && passwordLock != true\n && references(^._id)] | order(published desc) {\n ...,\n authorMapping[0]->,\n contentCategory->,\n issueSection-> {\n name\n }\n }\n }\n }';
18
18
  case 'externalResources':
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mjhls/mjh-framework",
3
- "version": "1.0.704",
3
+ "version": "1.0.705",
4
4
  "description": "Foundation Framework",
5
5
  "author": "mjh-framework",
6
6
  "license": "MIT",