Skip to content
Snippets Groups Projects
Commit 26d27dca authored by Alexander Kaschta's avatar Alexander Kaschta :owl:
Browse files

FIX: Copy transaction list on error to keep the error message static

Should fix #454
parent ac5ba1c1
No related branches found
No related tags found
No related merge requests found
Pipeline #274699 passed with warnings
......@@ -381,7 +381,7 @@ export default {
return res
},
api_ta() {
return APIUtils.buildAPITaFromTaObjectArray(this.$store.state)
return APIUtils.buildAPITaFromTaObjectArray(this.$store.state, true)
},
config_snippet_text() {
return `[DEFAULT]
......
......@@ -56,9 +56,10 @@ export default {
}
return res
},
buildAPITaFromTaObjectArray(state) {
buildAPITaFromTaObjectArray(state, use_copy_with_errors = false) {
const res = []
const obj = state.ta_list
// Use the ta_list copy with errors only when specified by the parameter
const obj = (use_copy_with_errors) ? state.ta_list_errors : state.ta_list
for (let i = 0; i < obj.length; i++) {
const ta = obj[i].content
if (obj[i].ta_type === 'db_editor_simple') {
......
......@@ -23,6 +23,7 @@ const NetvsVuex = new Vuex.Store({
undone: JSON.parse(window.localStorage.getItem('undone')) || [],
undo_redo_new_mutaion: JSON.parse(window.localStorage.getItem('undo_redo_new_mutation')) || true,
transaction_result: JSON.parse(window.localStorage.getItem('transaction_result')) || null,
ta_list_errors: JSON.parse(window.localStorage.getItem('ta_list_errors')) || [],
executing_transaction: JSON.parse(window.localStorage.getItem('executing_transaction')) || false,
show_sidebar_left: JSON.parse(window.localStorage.getItem('show_sidebar_left')) || true,
show_sidebar_right: JSON.parse(window.localStorage.getItem('show_sidebar_right')) || false,
......@@ -138,6 +139,7 @@ const NetvsVuex = new Vuex.Store({
state.undone = []
state.done = []
state.transaction_result = null
state.ta_list_errors = []
state.executing_transaction = false
state.show_sidebar_right = false
state.macfinder_jobs = []
......@@ -146,6 +148,7 @@ const NetvsVuex = new Vuex.Store({
window.localStorage.removeItem('undone')
window.localStorage.removeItem('undo_redo_new_mutation')
window.localStorage.removeItem('transaction_result')
window.localStorage.removeItem('ta_list_errors')
window.localStorage.removeItem('executing_transaction')
window.localStorage.removeItem('show_sidebar_right')
window.localStorage.removeItem('db_editor_cache')
......@@ -189,7 +192,9 @@ const NetvsVuex = new Vuex.Store({
},
emptyTransactionList(state) {
state.ta_list = []
state.ta_list_errors = []
window.localStorage.setItem('ta_list', JSON.stringify(state.ta_list))
window.localStorage.setItem('ta_list_errors', JSON.stringify(state.ta_list_errors))
},
setNavigationRefreshHandle(state, payload) {
state.refreshHandleObjType = payload.objType
......@@ -199,6 +204,13 @@ const NetvsVuex = new Vuex.Store({
state.transaction_result = result
window.localStorage.setItem('transaction_result', JSON.stringify(state.transaction_result))
},
copyTransactionsWithErrors(state, payload) {
if (state.ta_list_errors == null) {
state.ta_list_errors = []
}
state.ta_list_errors = payload
window.localStorage.setItem('ta_list_errors', JSON.stringify(state.ta_list_errors))
},
showSidebarLeft(state, show) {
state.show_sidebar_left = show
window.localStorage.setItem('show_sidebar_left', show)
......@@ -214,6 +226,8 @@ const NetvsVuex = new Vuex.Store({
removeTransactionResult(state) {
state.transaction_result = null
window.localStorage.removeItem('transaction_result')
state.ta_list_errors = []
window.localStorage.removeItem('ta_list_errors')
},
reloadRouterComp(state) {
state.reload_count++
......@@ -253,6 +267,8 @@ const NetvsVuex = new Vuex.Store({
} catch (e) {
window.console.error(e)
const pos = state.ta_list[APIUtil.getAPIErrorIndexFromDBException(e.response.data.exception)]
// Create a copy of the ta_list in ta_list_errors
commit('copyTransactionsWithErrors', JSON.parse(JSON.stringify(state.ta_list)))
state.transaction_result = {
type: 'error',
error: (typeof e.response.data === 'object' && 'exception' in e.response.data) ? e.response.data.exception : e.response.data,
......@@ -286,6 +302,8 @@ const NetvsVuex = new Vuex.Store({
} catch (e) {
window.console.debug(e.response)
const pos = state.ta_list[APIUtil.getAPIErrorIndexFromDBException(e.response.data.exception)]
// Create a copy of the ta_list in ta_list_errors
commit('copyTransactionsWithErrors', JSON.parse(JSON.stringify(state.ta_list)))
commit('setTransactionResult', {
type: 'error',
error: (typeof e.response.data === 'object' && 'exception' in e.response.data) ? e.response.data.exception : e.response.data,
......@@ -315,6 +333,7 @@ const NetvsVuex = new Vuex.Store({
'removeTransactionElement',
'emptyTransactionList',
'removeTransactionResult',
'copyTransactionsWithErrors',
'setTransactionBusy',
'moveTaElements',
'replaceTransactionList',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment