Skip to content

Commit

Permalink
upload annotated transcript
Browse files Browse the repository at this point in the history
  • Loading branch information
jpvoigt committed Aug 23, 2023
1 parent 953796f commit c5ab73b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/components/AnnotTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,22 @@ export default {
path: svgPath
})
}
},
uploadAnnotTrans ({ target: input }) {
const file = input?.files[0]
console.log(file)
const reader = new FileReader()
// TODO Loader should be a store action, need getters for WZ index (param)
reader.addEventListener('load', () => {
const parser = new DOMParser()
const dom = parser.parseFromString(reader.result, 'application/xml')
console.log(dom)
const path = this.$store.getters.currentWzAtPath
const baseMessage = 'added Annotated Transript for <docName> p. <pageIndex>'
this.$store.dispatch('loadDocumentIntoStore', { path, dom })
this.$store.dispatch('logChange', { path, baseMessage, param: 0, xmlIDs: [], isNewDocument: true })
})
reader.readAsText(file)
}
/* loadAnnotTrans () {
this.$store.dispatch('getFile', {
Expand All @@ -109,7 +125,8 @@ export default {
},
currentAnnotTabFileName () {
// TODO create / retrieve filename
return 'NK_p005_wz02_at.xml'
// return 'NK_p005_wz02_at.xml'
return this.$store.getters.currentWzAtPath
}
}
}
Expand Down
25 changes: 25 additions & 0 deletions src/store/data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1464,6 +1464,31 @@ const dataModule = {
return svgFilePath
},

/**
* retrieves the path of the annotated transcript for currently selected writing zone
* @param {[type]} state [description]
* @param {[type]} getters [description]
* @return {[type]} [description]
*/
currentWzAtPath: (state, getters) => {
const pageIndex = getters.currentPageZeroBased
const path = getters.filepath
const pages = getters.documentPagesForSidebars(path)

const page = pages[pageIndex]
if (!page) {
return null
}

const wz = getters.writingZonesOnCurrentPage.find(wz => wz.id === getters.activeWritingZone)
if (!wz) return

const docName = page.document
const docPath = getters.documentPathByName(docName)
const meipath = docPath.split(docName + '.xml')[0] + 'annotTrans/' + docName + '_p' + String(pageIndex + 1).padStart(3, '0') + '_wz' + wz.label.padStart(3, '0') + '_at.xml'
return meipath
},

/**
* retrieves the svg file of the current page
* @param {[type]} state [description]
Expand Down

0 comments on commit c5ab73b

Please sign in to comment.