Skip to content

Commit

Permalink
Merge pull request #48 from edtechhub/gh-27
Browse files Browse the repository at this point in the history
Gh 27
  • Loading branch information
bjohas authored Apr 13, 2020
2 parents 3c54406 + 97dd1d5 commit 3fc1178
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions eth-migrate-archiveLocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,25 @@ async function moveArchiveLocation(item) {
let save = false
let extra = (item.getField('extra') || '').split('\n')
if (extra.length == 1 && !extra[0]) extra = []

/*
let prevItemAlsoKnownAs = ''
check extra for EdTechHub.ItemAlsoKnownAs
if already there, then
prevItemAlsoKnownAs = value
remove line from extra
*/
if (Zotero.ItemFields.isValidForType(fieldID.archiveLocation, item.itemTypeID)) {
const archiveLocation = item.getField('archiveLocation') || ''
if (archiveLocation) {
// Better if this was:
// if (archiveLocation && archiveLocation.match(/\b\d{7}:[A-Z\d]{8}\b/) {
item.setField('archiveLocation', '')
extra.push(`EdTechHub.ItemAlsoKnownAs: ${archiveLocation}`)
// if (prevItemAlsoKnownAs == '') {
extra.push(`EdTechHub.ItemAlsoKnownAs: ${archiveLocation}`)
// } else {
// extra.push(`EdTechHub.ItemAlsoKnownAs: ${prevItemAlsoKnownAs};${archiveLocation}`)
// }
save = true
}
}
Expand Down

0 comments on commit 3fc1178

Please sign in to comment.