dce-reactkit 3.2.2-beta.32 → 3.2.2-beta.34

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dce-reactkit",
3
- "version": "3.2.2-beta.32",
3
+ "version": "3.2.2-beta.34",
4
4
  "description": "Shared components for Harvard DCE apps",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -84,8 +84,8 @@ const CSVDownloadButton: React.FC<Props> = (props) => {
84
84
  <>
85
85
  <FontAwesomeIcon
86
86
  icon={faCloudDownloadAlt}
87
- className="mr-2"
88
87
  />
88
+ {' '}
89
89
  Download CSV
90
90
  </>
91
91
  )}
@@ -272,12 +272,14 @@ const IntelliTable: React.FC<Props> = (props) => {
272
272
  // Custom info based on current sort type
273
273
  let sortButtonAriaLabel;
274
274
  let sortIcon = faSort;
275
+ let sortingByThisColumn = false;
275
276
  if (!sortColumnParam) {
276
277
  // Not being sorted yet
277
278
  sortButtonAriaLabel = `sort ascending by ${column.title}`;
278
279
  sortIcon = faSort;
279
280
  } else if (column.param === sortColumnParam) {
280
281
  // Already sorted by this column
282
+ sortingByThisColumn = true;
281
283
  if (sortType === SortType.Ascending) {
282
284
  // Sorted ascending
283
285
  sortButtonAriaLabel = `sort descending by ${column.title}`;
@@ -299,6 +301,11 @@ const IntelliTable: React.FC<Props> = (props) => {
299
301
  key={column.param}
300
302
  scope="col"
301
303
  id={`IntelliTable-${id}-header-${column.param}`}
304
+ className="text-start"
305
+ style={{
306
+ borderRight: '0.05rem solid #555',
307
+ borderLeft: '0.05rem solid #555',
308
+ }}
302
309
  >
303
310
  <div className="d-flex align-items-center justify-content-center flex-row h-100">
304
311
  {/* Title */}
@@ -309,7 +316,8 @@ const IntelliTable: React.FC<Props> = (props) => {
309
316
  <div>
310
317
  <button
311
318
  type="button"
312
- className="btn btn-light btn-sm ms-1"
319
+ id={`IntelliTable-${id}-sort-by-${column.param}-button`}
320
+ className={`btn btn-${sortingByThisColumn ? 'light' : 'secondary'} btn-sm ms-1 ps-1 pe-1 pt-0 pb-0`}
313
321
  aria-label={sortButtonAriaLabel}
314
322
  onClick={() => {
315
323
  dispatch({
@@ -372,10 +380,10 @@ const IntelliTable: React.FC<Props> = (props) => {
372
380
  // > String
373
381
  if (paramType === ParamType.String) {
374
382
  if (aVal < bVal) {
375
- return (descending ? -1 : 1);
383
+ return (descending ? 1 : -1);
376
384
  }
377
385
  if (aVal > bVal) {
378
- return (descending ? 1 : -1);
386
+ return (descending ? -1 : 1);
379
387
  }
380
388
  return 0;
381
389
  }
@@ -469,7 +477,11 @@ const IntelliTable: React.FC<Props> = (props) => {
469
477
  title = String(fullValue);
470
478
  } else if (column.type === ParamType.String) {
471
479
  fullValue = String(value).trim();
472
- const noValue = (String(fullValue).trim().length === 0);
480
+ const noValue = (
481
+ value === undefined
482
+ || value === null
483
+ || String(fullValue).trim().length === 0
484
+ );
473
485
  visibleValue = (
474
486
  noValue
475
487
  ? (
@@ -503,6 +515,10 @@ const IntelliTable: React.FC<Props> = (props) => {
503
515
  <td
504
516
  key={`${datum.id}-${column.param}`}
505
517
  title={title}
518
+ style={{
519
+ borderRight: '0.05rem solid #555',
520
+ borderLeft: '0.05rem solid #555',
521
+ }}
506
522
  >
507
523
  {visibleValue}
508
524
  </td>
@@ -549,8 +565,10 @@ const IntelliTable: React.FC<Props> = (props) => {
549
565
  // Build main UI
550
566
  return (
551
567
  <div className={`IntelliTable-container-${id}`}>
568
+ {/* Modal */}
569
+ {modal}
552
570
  {/* Header */}
553
- <div className="d-flex align-items-center justify-content-center">
571
+ <div className="d-flex align-items-center justify-content-start">
554
572
  {/* Title */}
555
573
  <h3 className="m-0">
556
574
  {title}
@@ -591,7 +609,7 @@ const IntelliTable: React.FC<Props> = (props) => {
591
609
  </div>
592
610
  {/* Table */}
593
611
  <div
594
- className={`IntelliTable-table-${id}`}
612
+ className={`IntelliTable-table-${id} mt-2`}
595
613
  style={{
596
614
  overflowX: 'auto',
597
615
  }}
@@ -592,8 +592,8 @@ const LogReviewer: React.FC<Props> = (props) => {
592
592
 
593
593
  // Create initial tag filter state
594
594
  const initTagFilterState: TagFilterState = {};
595
- Object.values(LogMetadata.Tag ?? {}).forEach((tagValue) => {
596
- initTagFilterState[tagValue] = false;
595
+ Object.keys(LogMetadata.Tag ?? {}).forEach((tag) => {
596
+ initTagFilterState[tag] = false;
597
597
  });
598
598
 
599
599
  // Create advanced filter state
@@ -1055,7 +1055,7 @@ const LogReviewer: React.FC<Props> = (props) => {
1055
1055
  filterDrawer = (
1056
1056
  <TabBox title="Tags">
1057
1057
  {
1058
- Object.keys(tagFilterState)
1058
+ Object.keys(LogMetadata.Tag ?? {})
1059
1059
  .map((tag, i) => {
1060
1060
  const description = genHumanReadableName(tag);
1061
1061
  return (
@@ -1961,18 +1961,18 @@ const LogReviewer: React.FC<Props> = (props) => {
1961
1961
  type: ParamType.Int,
1962
1962
  },
1963
1963
  {
1964
- title: 'Student',
1964
+ title: 'Student?',
1965
1965
  param: 'isLearner',
1966
1966
  type: ParamType.Boolean,
1967
1967
  },
1968
1968
  {
1969
- title: 'Teaching Staff',
1969
+ title: 'Teaching Staff?',
1970
1970
  param: 'isTTM',
1971
1971
  type: ParamType.Boolean,
1972
1972
  startsHidden: true,
1973
1973
  },
1974
1974
  {
1975
- title: 'Admin',
1975
+ title: 'Admin?',
1976
1976
  param: 'isAdmin',
1977
1977
  type: ParamType.Boolean,
1978
1978
  startsHidden: true,
@@ -2007,7 +2007,7 @@ const LogReviewer: React.FC<Props> = (props) => {
2007
2007
  startsHidden: true,
2008
2008
  },
2009
2009
  {
2010
- title: 'Mobile',
2010
+ title: 'Mobile?',
2011
2011
  param: 'device.isMobile',
2012
2012
  type: ParamType.Boolean,
2013
2013
  startsHidden: true,
@@ -46,7 +46,24 @@ const genCSV = (
46
46
  csv += (
47
47
  columns
48
48
  .map((column) => {
49
- return escapeCellText(datum[column.param]);
49
+ let contents: string;
50
+ const cell = datum[column.param];
51
+ if (
52
+ typeof cell === 'string'
53
+ || typeof cell === 'number'
54
+ ) {
55
+ contents = String(cell);
56
+ } else if (
57
+ typeof cell === 'undefined'
58
+ || cell === null
59
+ ) {
60
+ contents = '';
61
+ } else if (typeof cell === 'object') {
62
+ contents = JSON.stringify(cell);
63
+ } else {
64
+ contents = '';
65
+ }
66
+ return escapeCellText(contents);
50
67
  })
51
68
  .join(',')
52
69
  );
@@ -500,7 +500,7 @@ const genRouteHandler = (
500
500
  isAdmin: !!launchInfo.isAdmin,
501
501
  isTTM: !!launchInfo.isTTM,
502
502
  courseId: launchInfo.courseId,
503
- courseName: launchInfo.courseName,
503
+ courseName: launchInfo.contextLabel,
504
504
  browser,
505
505
  device,
506
506
  year,