Skip to content

Commit

Permalink
Merge pull request #660 from akashgp09/fix-revision
Browse files Browse the repository at this point in the history
fix(revision): show type changes in revision page
  • Loading branch information
MonkeyDo committed Jul 15, 2021
2 parents e46af6b + a510820 commit c7421f4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
10 changes: 9 additions & 1 deletion src/server/helpers/diffFormatters/base.js
Expand Up @@ -76,7 +76,15 @@ export function formatEndedChange(change) {
}

export function formatTypeChange(change, label) {
return formatChange(change, label, (side) => side && [side.label]);
// eslint-disable-next-line consistent-return
return formatChange(change, label, (side) => {
if (typeof side === 'string') {
return [side];
}
else if (side) {
return [side.label];
}
});
}

export function formatScalarChange(change, label) {
Expand Down
21 changes: 12 additions & 9 deletions src/server/routes/revision.js
Expand Up @@ -58,8 +58,8 @@ function formatAuthorChange(change) {
if (_.isEqual(change.path, ['ended'])) {
return baseFormatter.formatEndedChange(change);
}

if (_.isEqual(change.path, ['type'])) {
if (_.isEqual(change.path, ['authorType']) ||
_.isEqual(change.path, ['authorType', 'label'])) {
return baseFormatter.formatTypeChange(change, 'Author Type');
}

Expand Down Expand Up @@ -106,11 +106,13 @@ function formatEditionChange(change) {
return baseFormatter.formatScalarChange(change, 'Page Count');
}

if (_.isEqual(change.path, ['editionFormat'])) {
if (_.isEqual(change.path, ['editionFormat']) ||
_.isEqual(change.path, ['editionFormat', 'label'])) {
return baseFormatter.formatTypeChange(change, 'Edition Format');
}

if (_.isEqual(change.path, ['editionStatus'])) {
if (_.isEqual(change.path, ['editionStatus']) ||
_.isEqual(change.path, ['editionStatus', 'label'])) {
return baseFormatter.formatTypeChange(change, 'Edition Status');
}

Expand All @@ -129,8 +131,8 @@ function formatPublisherChange(change) {
if (_.isEqual(change.path, ['ended'])) {
return baseFormatter.formatEndedChange(change);
}

if (_.isEqual(change.path, ['type'])) {
if (_.isEqual(change.path, ['publisherType']) ||
_.isEqual(change.path, ['publisherType', 'label'])) {
return baseFormatter.formatTypeChange(change, 'Publisher Type');
}

Expand All @@ -146,16 +148,17 @@ function formatWorkChange(change) {
if (languageSetFormatter.changed(change)) {
return languageSetFormatter.format(change);
}

if (_.isEqual(change.path, ['type'])) {
if (_.isEqual(change.path, ['workType']) ||
_.isEqual(change.path, ['workType', 'label'])) {
return baseFormatter.formatTypeChange(change, 'Work Type');
}

return null;
}

function formatEditionGroupChange(change) {
if (_.isEqual(change.path, ['type'])) {
if (_.isEqual(change.path, ['editionGroupType']) ||
_.isEqual(change.path, ['editionGroupType', 'label'])) {
return baseFormatter.formatTypeChange(change, 'Edition Group Type');
}

Expand Down

0 comments on commit c7421f4

Please sign in to comment.