Skip to content

Commit

Permalink
- reload just the new comments, not the whole dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
severinbeauvais committed Feb 24, 2020
1 parent edcd982 commit 0d3d073
Showing 1 changed file with 33 additions and 8 deletions.
41 changes: 33 additions & 8 deletions src/components/Dashboard/FilingHistoryList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
<script lang="ts">
// Libraries
import axios from '@/axios-auth'
import { mapGetters, mapState, mapActions } from 'vuex'
import { mapGetters, mapState } from 'vuex'
// Dialogs
import { AddCommentDialog, DownloadErrorDialog } from '@/components/dialogs'
Expand Down Expand Up @@ -254,8 +254,6 @@ export default {
},
methods: {
...mapActions(['setTriggerDashboardReload']),
loadData () {
this.filedItems = []
Expand Down Expand Up @@ -314,7 +312,7 @@ export default {
// Method to extract date from a local datetime string
// Returns "yyyy-mm-dd"
formatDate (dateString): string {
formatDate (dateString: string): string {
if (!dateString) return null // safety check
return dateString.split(' ')[0]
},
Expand Down Expand Up @@ -461,7 +459,7 @@ export default {
return type.split(/(?=[A-Z])/).join(' ').replace(/^\w/, c => c.toUpperCase())
},
highlightFiling (highlightId) {
highlightFiling (highlightId: number) {
// expand the panel of the matching filing
for (let i = 0; i < this.filedItems.length; i++) {
// assume there is always a filing document
Expand Down Expand Up @@ -635,14 +633,41 @@ export default {
status === FilingStatus.PAID
},
showCommentDialog (filingId): void {
showCommentDialog (filingId: number): void {
this.currentFilingId = filingId
this.addCommentDialog = true
},
hideCommentDialog (needReload): void {
async hideCommentDialog (needReload: boolean): Promise<void> {
this.addCommentDialog = false
if (needReload) this.setTriggerDashboardReload(true)
// if needed, reload comments for this filing
// NB: no spinner or state change, just do it quietly
if (needReload) await this.reloadComments(this.currentFilingId)
},
async reloadComments (filingId: number): Promise<void> {
// find the filing in the list
const filing = this.filedItems.find(item => (item.filingId === filingId))
if (filing) {
// fetch latest comments for this filing
const url = this.entityIncNo + '/filings/' + filingId
await axios.get(url).then(res => {
if (res && res.data && res.data.filing && res.data.filing.header) {
// reassign just the comments
filing.comments = this.flattenAndSortComments(res.data.filing.header.comments)
} else {
// eslint-disable-next-line no-console
console.log('reloadComments() error - invalid response =', res)
}
}).catch(error => {
// eslint-disable-next-line no-console
console.error('reloadComments() error =', error)
})
} else {
// eslint-disable-next-line no-console
console.error('reloadComments() error - could not find filing id =', filingId)
}
}
},
Expand Down

0 comments on commit 0d3d073

Please sign in to comment.