Skip to content

Commit

Permalink
Merge 5c40158 into fd718f5
Browse files Browse the repository at this point in the history
  • Loading branch information
akashgp09 committed Aug 2, 2021
2 parents fd718f5 + 5c40158 commit f6f26bf
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 20 deletions.
22 changes: 11 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@fortawesome/free-solid-svg-icons": "^5.14.0",
"@fortawesome/react-fontawesome": "^0.1.11",
"array-move": "^3.0.1",
"bookbrainz-data": "^2.11.0",
"bookbrainz-data": "^2.12.0",
"chart.js": "^2.9.4",
"chartjs-adapter-date-fns": "^1.0.0",
"classnames": "^2.3.1",
Expand Down
32 changes: 26 additions & 6 deletions src/server/helpers/diffFormatters/entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,14 @@ function formatIdentifier(change) {
return null;
}

function formatRelationshipAttrubuteAddOrDelete(relationshipAttributes) {
const attributes = [];
relationshipAttributes.forEach((attribute) => {
attributes.push(`${attribute.type.name}: ${attribute.value.textValue}`);
});
return attributes;
}

function formatRelationshipAdd(entity, change) {
const changes = [];
const {rhs} = change.item;
Expand All @@ -244,17 +252,21 @@ function formatRelationshipAdd(entity, change) {
return changes;
}
const key = rhs.type && rhs.type.label ? `Relationship : ${rhs.type.label}` : 'Relationship';
let attributes = [];
if (rhs.attributeSetId) {
attributes = formatRelationshipAttrubuteAddOrDelete(rhs.attributeSet.relationshipAttributes);
}
if (rhs.sourceBbid === entity.get('bbid')) {
changes.push(
base.formatRow(
'N', key, null, [rhs.targetBbid]
'N', key, null, [rhs.targetBbid, ...attributes]
)
);
}
else {
changes.push(
base.formatRow(
'N', key, null, [rhs.sourceBbid]
'N', key, null, [rhs.sourceBbid, ...attributes]
)
);
}
Expand All @@ -276,17 +288,21 @@ function formatAddOrDeleteRelationshipSet(entity, change) {

allRelationships.forEach((relationship) => {
const key = relationship.type && relationship.type.label ? `Relationship: ${relationship.type.label}` : 'Relationship';
let attributes = [];
if (relationship.attributeSetId) {
attributes = formatRelationshipAttrubuteAddOrDelete(relationship.attributeSet.relationshipAttributes);
}
if (relationship.sourceBbid === entity.get('bbid')) {
changes.push(
base.formatRow(
change.kind, key, [relationship.targetBbid], [relationship.targetBbid]
change.kind, key, [relationship.targetBbid, ...attributes], [relationship.targetBbid, ...attributes]
)
);
}
else {
changes.push(
base.formatRow(
change.kind, key, [relationship.sourceBbid], [relationship.sourceBbid]
change.kind, key, [relationship.sourceBbid, ...attributes], [relationship.sourceBbid, ...attributes]
)
);
}
Expand All @@ -302,17 +318,21 @@ function formatRelationshipRemove(entity, change) {
return changes;
}
const key = lhs.type && lhs.type.label ? `Relationship : ${lhs.type.label}` : 'Relationship';
let attributes = [];
if (lhs.attributeSetId) {
attributes = formatRelationshipAttrubuteAddOrDelete(lhs.attributeSet.relationshipAttributes);
}
if (lhs.sourceBbid === entity.get('bbid')) {
changes.push(
base.formatRow(
'D', key, [lhs.targetBbid], null
'D', key, [lhs.targetBbid, ...attributes], null
)
);
}
else {
changes.push(
base.formatRow(
'D', key, [lhs.sourceBbid], null
'D', key, [lhs.sourceBbid, ...attributes], null
)
);
}
Expand Down
3 changes: 2 additions & 1 deletion src/server/helpers/revisions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ import {flatMap} from 'lodash';


function getRevisionModels(orm) {
const {AuthorRevision, EditionRevision, EditionGroupRevision, PublisherRevision, WorkRevision} = orm;
const {AuthorRevision, EditionRevision, EditionGroupRevision, PublisherRevision, SeriesRevision, WorkRevision} = orm;
return [
AuthorRevision,
EditionGroupRevision,
EditionRevision,
PublisherRevision,
SeriesRevision,
WorkRevision
];
}
Expand Down
12 changes: 12 additions & 0 deletions src/server/routes/entity/series.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,18 @@ router.post(
}
);

router.get('/:bbid/revisions', (req, res, next) => {
const {SeriesRevision} = req.app.locals.orm;
_setSeriesTitle(res);
entityRoutes.displayRevisions(req, res, next, SeriesRevision);
});

router.get('/:bbid/revisions/revisions', (req, res, next) => {
const {SeriesRevision} = req.app.locals.orm;
_setSeriesTitle(res);
entityRoutes.updateDisplayedRevisions(req, res, next, SeriesRevision);
});

function seriesToFormState(series) {
const aliases = series.aliasSet ?
series.aliasSet.aliases.map(({languageId, ...rest}) => ({
Expand Down
19 changes: 18 additions & 1 deletion src/server/routes/revision.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,17 @@ function formatPublisherChange(change) {
return null;
}

function formatSeriesChange(change) {
if (_.isEqual(change.path, ['seriesOrderingType']) ||
_.isEqual(change.path, ['seriesOrderingType', 'label'])) {
return baseFormatter.formatTypeChange(change, 'Series Ordering Type');
}
if (_.isEqual(change.path, ['entityType'])) {
return baseFormatter.formatTypeChange(change, 'Series Type');
}
return null;
}

function formatWorkChange(change) {
if (languageSetFormatter.changed(change)) {
return languageSetFormatter.format(change);
Expand Down Expand Up @@ -212,7 +223,7 @@ function diffRevisionsWithParents(orm, entityRevisions, entityType) {
router.get('/:id', async (req, res, next) => {
const {
AuthorRevision, EditionRevision, EditionGroupRevision,
PublisherRevision, Revision, WorkRevision
SeriesRevision, PublisherRevision, Revision, WorkRevision
} = req.app.locals.orm;

let revision;
Expand Down Expand Up @@ -256,6 +267,7 @@ router.get('/:id', async (req, res, next) => {
const editionDiffs = await _createRevision(EditionRevision, 'Edition');
const editionGroupDiffs = await _createRevision(EditionGroupRevision, 'EditionGroup');
const publisherDiffs = await _createRevision(PublisherRevision, 'Publisher');
const seriesDiffs = await _createRevision(SeriesRevision, 'Series');
const workDiffs = await _createRevision(WorkRevision, 'Work');
const diffs = _.concat(
entityFormatter.formatEntityDiffs(
Expand All @@ -278,6 +290,11 @@ router.get('/:id', async (req, res, next) => {
'Publisher',
formatPublisherChange
),
entityFormatter.formatEntityDiffs(
seriesDiffs,
'Series',
formatSeriesChange
),
entityFormatter.formatEntityDiffs(
workDiffs,
'Work',
Expand Down

0 comments on commit f6f26bf

Please sign in to comment.