Commit 27ba592f authored by Janis Streib's avatar Janis Streib

FIX: cast to json data types

parent 04828843
Pipeline #118773 passed with stages
in 9 minutes and 48 seconds
......@@ -32,10 +32,10 @@ export default {
for (let i = 0; i < obj.length; i++) {
const app = { name: `${obj[i].object_fq_name}.${obj[i].object_function}` }
if (Object.keys(obj[i].parameters.old).length > 0) {
app.old = obj[i].object_functions === null ? obj[i].parameters.old : transactionutil.filter_old_data(obj[i].object_functions[obj[i].object_function].parameters, obj[i].parameters.old)
app.old = obj[i].object_functions === null ? obj[i].parameters.old : transactionutil.cast_to_json_type(obj[i].object_functions[obj[i].object_function].parameters, transactionutil.filter_old_data(obj[i].object_functions[obj[i].object_function].parameters, obj[i].parameters.old))
}
if (Object.keys(obj[i].parameters.new).length > 0) {
app.new = transactionutil.filter_unchanged_data(obj[i].parameters.new, obj[i].parameters.old)
app.new = transactionutil.cast_to_json_type(obj[i].object_functions[obj[i].object_function].parameters, transactionutil.filter_unchanged_data(obj[i].parameters.new, obj[i].parameters.old))
}
res.push(app)
}
......
import { v4 as uuidv4 } from 'uuid'
import {v4 as uuidv4} from 'uuid'
import ObjectTypeService from '@/api-services.gen/wapi.object_type'
import FunctionService from '@/api-services.gen/wapi.function'
import ApiUtil from '@/util/apiutil'
export default {
function2variant (function_name, outline = false) {
function2variant(function_name, outline = false) {
const prefix = outline ? 'outline-' : ''
switch (function_name) {
case 'create':
......@@ -18,7 +18,7 @@ export default {
return prefix + 'default'
}
},
function2text (function_name) {
function2text(function_name) {
switch (function_name) {
case 'create':
return 'anlegen'
......@@ -32,32 +32,47 @@ export default {
return function_name
}
},
nullify (data) {
nullify(data) {
if (data === '__NULL') {
return null
}
return data
},
filter_unchanged_data (d1, d2) {
filter_unchanged_data(d1, d2) {
const self = this
return Object.keys(d1).reduce(function (filtered, key) {
if (!(key in d2) || d1[key] !== d2[key]) filtered[key] = self.nullify(d1[key])
return filtered
}, {})
},
filter_old_data (params_list, old_data) {
filter_old_data(params_list, old_data) {
return Object.keys(old_data).reduce(function (filtered, key) {
if (key in params_list && 'old' in params_list[key]) filtered[key] = old_data[key]
return filtered
}, {})
},
remove_empty_data (params_list, data) {
remove_empty_data(params_list, data) {
return Object.keys(data).reduce(function (filtered, key) {
if (!(data[key] === '')) filtered[key] = data[key]
return filtered
}, {})
},
generateDeleteElement (object_fq_name, params_list, old_data, title) {
cast_to_json_type(params_list, data) {
return Object.keys(data).reduce(function (filtered, key) {
switch (params_list[key].json_data_type) {
case 'boolean':
filtered[key] = data[key] === 'true'
break
case 'number':
filtered[key] = Number(data[key])
break
default:
filtered[key] = data[key]
}
return filtered
}, {})
},
generateDeleteElement(object_fq_name, params_list, old_data, title) {
const ta = {}
ta.parameters = {
new: {},
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment