diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 83c530a4f..d9679ac66 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -369,3 +369,13 @@ This release is composed of porting over bug fixes for bugs we carried over from #### Infrastructure - Better track and export data on decks for analytics and machine learning. + +### v1.4.6.8 + +#### Features + +- Support overriden name in CSV export and import. + +#### Bug Fixes + +- Fix for specifying color category in csv import. diff --git a/client/components/modals/CardModal.js b/client/components/modals/CardModal.js index 953846106..d775107e4 100644 --- a/client/components/modals/CardModal.js +++ b/client/components/modals/CardModal.js @@ -106,7 +106,7 @@ const CardModal = ({
- Overriden Name + Overridden Name diff --git a/server/__tests__/routes/cube/export.test.js b/server/__tests__/routes/cube/export.test.js index 58b4f6326..d25a214cc 100644 --- a/server/__tests__/routes/cube/export.test.js +++ b/server/__tests__/routes/cube/export.test.js @@ -129,6 +129,7 @@ test('csv download', () => { 'Tags', 'Notes', 'MTGO ID', + 'Overridden Name', ]; const faerieGuidemotherData = { @@ -148,6 +149,7 @@ test('csv download', () => { 'Image Back URL': '', Tags: 'New', Notes: '', + 'Overridden Name': '', }; return request(app) diff --git a/server/__tests__/serverjs/cubefn.test.js b/server/__tests__/serverjs/cubefn.test.js index 7dd8ff03a..a251d012a 100644 --- a/server/__tests__/serverjs/cubefn.test.js +++ b/server/__tests__/serverjs/cubefn.test.js @@ -145,11 +145,13 @@ describe('CSVtoCards', () => { finish: 'Is Foil', imgUrl: 'http://example.com/', tags: ['tag1', 'tag2'], + colorCategory: null, + overriddenName: null, }; const expectedMaybe = { name: 'Embercleave', cmc: '2', - type_line: 'Creature - Type', + type_line: null, colors: ['R', 'W'], set: 'ELD', collector_number: '120', @@ -157,21 +159,27 @@ describe('CSVtoCards', () => { finish: 'Is Not Foil', imgUrl: null, tags: ['tag3', 'tag4'], + overriddenName: 'Testingcleave', + colorCategory: 'R', }; const cards = [ - 'Name,CMC,Type,Color,Set,Collector Number,Status,Finish,Maybeboard,Image URL,Tags', - `"${expectedCard.name}",${expectedCard.cmc},${expectedCard.type_line.replace( + 'Name,CMC,Type,Color,Set,Collector Number,Status,Finish,Maybeboard,Image URL,Tags,Overridden Name,Color Category', + `"${expectedCard.name}",${expectedCard.cmc},${(expectedCard.type_line || '').replace( '—', '-', )},${expectedCard.colors.join('')},${expectedCard.set},${expectedCard.collector_number},${expectedCard.status},${ expectedCard.finish - },false,${expectedCard.imgUrl},"${expectedCard.tags.join(';')}"`, - `"${expectedMaybe.name}",${expectedMaybe.cmc},${expectedMaybe.type_line.replace( + },false,${expectedCard.imgUrl},"${expectedCard.tags.join(';')}","${expectedCard.overriddenName || ''}",${ + expectedCard.colorCategory || '' + }`, + `"${expectedMaybe.name}",${expectedMaybe.cmc},${(expectedMaybe.type_line || '').replace( '—', '-', )},${expectedMaybe.colors.join('')},${expectedMaybe.set},${expectedMaybe.collector_number},${ expectedMaybe.status - },${expectedMaybe.finish},true,undefined,"${expectedMaybe.tags.join(';')}"`, + },${expectedMaybe.finish},true,undefined,"${expectedMaybe.tags.join(';')}","${ + expectedMaybe.overriddenName || '' + }",${expectedMaybe.colorCategory || ''}`, ]; await carddb.initializeCardDb(fixturesPath, true); const { newCards, newMaybe, missing } = CSVtoCards(cards.join('\n'), carddb); @@ -183,7 +191,7 @@ describe('CSVtoCards', () => { }); const expectSame = (card, expected) => { expect(card.cardID).toBe(expectedId); - expect(card.name).toBe(expected.name); + expect(card.name).toBe(expected.overriddenName); expect(card.cmc).toBe(expected.cmc); expect(card.colors).equalsArray(expected.colors); expect(card.collector_number).toBe(expected.collector_number); @@ -191,6 +199,7 @@ describe('CSVtoCards', () => { expect(card.finish).toBe(expected.finish); expect(card.imgUrl).toBe(expected.imgUrl); expect(card.tags).equalsArray(expected.tags); + expect(card.colorCategory).toBe(expected.colorCategory); }; expect(newCards.length).toBe(1); expectSame(newCards[0], expectedCard); diff --git a/server/routes/cube/helper.js b/server/routes/cube/helper.js index 138d5d192..443a49c7a 100644 --- a/server/routes/cube/helper.js +++ b/server/routes/cube/helper.js @@ -18,7 +18,7 @@ export const DEFAULT_BASICS = [ export const CARD_HEIGHT = 680; export const CARD_WIDTH = 488; export const CSV_HEADER = - 'Name,CMC,Type,Color,Set,Collector Number,Rarity,Color Category,Status,Finish,Maybeboard,Image URL,Image Back URL,Tags,Notes,MTGO ID'; + 'Name,CMC,Type,Color,Set,Collector Number,Rarity,Color Category,Status,Finish,Maybeboard,Image URL,Image Back URL,Tags,Notes,MTGO ID,Overridden Name'; export const updateCubeAndBlog = async (req, res, cube, changelog, added, missing) => { try { @@ -173,7 +173,8 @@ export const writeCard = (res, card, maybe) => { res.write(tag); }); res.write(`","${card.notes || ''}",`); - res.write(`${carddb.cardFromId(card.cardID).mtgo_id || ''}`); + res.write(`${carddb.cardFromId(card.cardID).mtgo_id || ''},`); + res.write(`${card.name || ''}`); res.write('\n'); }; diff --git a/server/serverjs/cubefn.js b/server/serverjs/cubefn.js index dae79f388..7b4d1155a 100644 --- a/server/serverjs/cubefn.js +++ b/server/serverjs/cubefn.js @@ -242,8 +242,9 @@ export const CSVtoCards = (csvString, carddb) => { 'image back url': imageBackUrl, tags, notes, - 'Color Category': colorCategory, + 'color category': colorCategory, rarity, + 'overridden name': overriddenName, } of data) { if (name) { const upperSet = (set || '').toUpperCase(); @@ -277,6 +278,7 @@ export const CSVtoCards = (csvString, carddb) => { const nonPromo = potentialIds.find(carddb.reasonableId); const first = potentialIds[0]; card.cardID = matchingSetAndNumber || matchingSet || nonPromo || first; + card.name = overriddenName || null; if (maybeboard.toLowerCase() === 'true') { newMaybe.push(card); } else { diff --git a/yarn.lock b/yarn.lock index f000a39c6..6da6b9152 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3743,9 +3743,9 @@ can-use-dom@^0.1.0: integrity sha1-IsxKNKCrxDlQ9CxkEQJKP2NmtFo= caniuse-lite@^1.0.30001280: - version "1.0.30001474" - resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001474.tgz" - integrity sha512-iaIZ8gVrWfemh5DG3T9/YqarVZoYf0r188IjaGwx68j4Pf0SGY6CQkmJUIE+NZHkkecQGohzXmBGEwWDr9aM3Q== + version "1.0.30001561" + resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001561.tgz" + integrity sha512-NTt0DNoKe958Q0BE0j0c1V9jbUzhBxHIEJy7asmGrpE0yG63KTV7PLHPnK2E1O9RsQrQ081I3NLuXGS6zht3cw== capture-exit@^2.0.0: version "2.0.0"