Skip to content
Snippets Groups Projects
Commit ede993b9 authored by Angelina Filippova's avatar Angelina Filippova
Browse files

Remove data from updated settings after setting was removed

parent 39f370e9
No related branches found
No related tags found
1 merge request!77Ability to remove settings from db
import { fetchDescription, fetchSettings, removeSettings, updateSettings, uploadMedia } from '@/api/settings'
import { checkPartialUpdate, parseNonTuples, parseTuples, valueHasTuples, wrapUpdatedSettings } from './normalizers'
import _ from 'lodash'
const settings = {
state: {
......@@ -27,6 +28,12 @@ const settings = {
CLEAR_UPDATED_SETTINGS: (state) => {
state.updatedSettings = {}
},
REMOVE_SETTING_FROM_UPDATED: (state, { group, key, subkey }) => {
if (_.get(state.updatedSettings, [group, key, subkey])) {
const { [subkey]: value, ...updatedSettings } = state.updatedSettings[group][key]
state.updatedSettings = updatedSettings
}
},
SET_DESCRIPTION: (state, data) => {
state.description = data
},
......@@ -74,7 +81,9 @@ const settings = {
},
async RemoveSetting({ commit, getters }, configs) {
const response = await removeSettings(configs, getters.authHost, getters.token)
const { group, key } = response.data.configs[0]
commit('UPDATE_SETTINGS_AFTER_REMOVAL', response.data.configs[0])
commit('REMOVE_SETTING_FROM_UPDATED', { group, key, subkey: configs[0].subkeys[0] })
},
async SubmitChanges({ getters, commit, state }) {
const updatedData = checkPartialUpdate(state.settings, state.updatedSettings, state.description)
......
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