forked from MapComplete/MapComplete
Add overrie capabilities
This commit is contained in:
parent
66018cb421
commit
93a16944a3
7 changed files with 113 additions and 41 deletions
39
Utils.ts
39
Utils.ts
|
@ -175,6 +175,45 @@ export class Utils {
|
|||
console.error("Key ", objectKey, "might be not supported (in context",context,")")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static Merge(source: any, target: any){
|
||||
target = JSON.parse(JSON.stringify(target));
|
||||
source = JSON.parse(JSON.stringify(source));
|
||||
for (const key in source) {
|
||||
const sourceV = source[key];
|
||||
const targetV = target[key]
|
||||
if(typeof sourceV === "object"){
|
||||
if(targetV === undefined){
|
||||
target[key] = sourceV;
|
||||
}else{
|
||||
Utils.Merge(sourceV, targetV);
|
||||
}
|
||||
|
||||
}else{
|
||||
target[key] = sourceV;
|
||||
}
|
||||
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
static ToMuchTags(source: any, toCheck: any, context: string){
|
||||
|
||||
for (const key in toCheck) {
|
||||
const toCheckV = toCheck[key];
|
||||
const sourceV = source[key];
|
||||
if(sourceV === undefined){
|
||||
console.error("Probably a wrong tag in ", context, ": ", key, "might be wrong")
|
||||
}
|
||||
if(typeof toCheckV === "object"){
|
||||
if(typeof sourceV !== "object"){
|
||||
console.error("Probably a wrong value in ", context, ": ", key, "is a fixed value in the source")
|
||||
}else{
|
||||
Utils.ToMuchTags(sourceV, toCheckV, context+"."+key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue