forked from AkkomaGang/admin-fe
Add confirm message when deleting a note and update tests
This commit is contained in:
parent
cbce6e7586
commit
b949ddae60
3 changed files with 29 additions and 11 deletions
|
@ -206,6 +206,11 @@ export default {
|
||||||
from: 'From',
|
from: 'From',
|
||||||
showNotes: 'Show notes',
|
showNotes: 'Show notes',
|
||||||
newNote: 'New note',
|
newNote: 'New note',
|
||||||
submit: 'Submit'
|
submit: 'Submit',
|
||||||
|
confirmMsg: 'Are you sure you want to delete this note?',
|
||||||
|
delete: 'Delete',
|
||||||
|
cancel: 'Cancel',
|
||||||
|
deleteCompleted: 'Delete comleted',
|
||||||
|
deleteCanceled: 'Delete canceled'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,8 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import i18n from '@/lang'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'TimelineItem',
|
name: 'TimelineItem',
|
||||||
props: {
|
props: {
|
||||||
|
@ -59,7 +61,23 @@ export default {
|
||||||
this.$data.note = ''
|
this.$data.note = ''
|
||||||
},
|
},
|
||||||
deleteNote(reportId, noteId) {
|
deleteNote(reportId, noteId) {
|
||||||
this.$store.dispatch('DeleteNote', { reportId, noteId })
|
this.$confirm(i18n.t('reports.confirmMsg'), {
|
||||||
|
confirmButtonText: i18n.t('reports.delete'),
|
||||||
|
cancelButtonText: i18n.t('reports.cancel'),
|
||||||
|
type: 'warning',
|
||||||
|
showClose: false
|
||||||
|
}).then(() => {
|
||||||
|
this.$store.dispatch('DeleteNote', { reportId, noteId })
|
||||||
|
this.$message({
|
||||||
|
type: 'success',
|
||||||
|
message: i18n.t('reports.deleteCompleted')
|
||||||
|
})
|
||||||
|
}).catch(() => {
|
||||||
|
this.$message({
|
||||||
|
type: 'info',
|
||||||
|
message: i18n.t('reports.deleteCanceled')
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,16 +73,11 @@ describe('Reports', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('deletes a note', () => {
|
it('deletes a note', () => {
|
||||||
const wrapper = mount(Reports, {
|
store.dispatch('FetchReports')
|
||||||
store,
|
expect(store.state.reports.fetchedReports[0].notes.length).toBe(3)
|
||||||
localVue
|
|
||||||
})
|
|
||||||
const notes = store.state.reports.fetchedReports[0].notes
|
|
||||||
expect(notes.length).toBe(3)
|
|
||||||
|
|
||||||
wrapper.find('.el-icon-close').trigger('click')
|
store.dispatch('DeleteNote', { reportId: '1', noteId: '2' })
|
||||||
const updatedNotes = store.state.reports.fetchedReports[0].notes
|
expect(store.state.reports.fetchedReports[0].notes.length).toBe(2)
|
||||||
expect(updatedNotes.length).toBe(2)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('loads more reports on scroll', () => {
|
it('loads more reports on scroll', () => {
|
||||||
|
|
Loading…
Reference in a new issue