Refactor sources modal

This commit is contained in:
Lukas Martinelli
2017-01-08 19:45:44 +01:00
parent 7c3906fa40
commit 7c9dcb3083
4 changed files with 59 additions and 52 deletions
+1 -1
View File
@@ -60,7 +60,7 @@ export class ApiStyleStore {
json: true,
body: mapStyle
}, (error, response, body) => {
console.log('Saved style');
if(error) console.error(error)
})
return mapStyle
}
+27
View File
@@ -0,0 +1,27 @@
export function deleteSource(mapStyle, sourceId) {
const remainingSources = { ...mapStyle.sources}
delete remainingSources[sourceId]
const changedStyle = {
...mapStyle,
sources: remainingSources
}
return changedStyle
}
export function addSource(mapStyle, sourceId, source) {
return changeSource(mapStyle, sourceId, source)
}
export function changeSource(mapStyle, sourceId, source) {
const changedSources = {
...mapStyle.sources,
[sourceId]: source
}
const changedStyle = {
...mapStyle,
sources: changedSources
}
return changedStyle
}