-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/map zoom #6835
Fix/map zoom #6835
Changes from 13 commits
e6dbd8c
9ac4961
d7b3cb5
ad62b60
5c7ee7d
6cfe38d
bff8276
3366e81
bd4b5c6
dfdf713
b3bc6c8
ff97284
fd30551
cb758cc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,16 +2,18 @@ import _ from 'lodash'; | |
import AggTypesIndexProvider from 'ui/agg_types/index'; | ||
import RegistryVisTypesProvider from 'ui/registry/vis_types'; | ||
import VisAggConfigsProvider from 'ui/vis/agg_configs'; | ||
import PersistedStateProvider from 'ui/persisted_state/persisted_state'; | ||
export default function VisFactory(Notifier, Private) { | ||
let aggTypes = Private(AggTypesIndexProvider); | ||
let visTypes = Private(RegistryVisTypesProvider); | ||
let AggConfigs = Private(VisAggConfigsProvider); | ||
const PersistedState = Private(PersistedStateProvider); | ||
|
||
let notify = new Notifier({ | ||
location: 'Vis' | ||
}); | ||
|
||
function Vis(indexPattern, state) { | ||
function Vis(indexPattern, state, uiState) { | ||
state = state || {}; | ||
|
||
if (_.isString(state)) { | ||
|
@@ -24,6 +26,7 @@ export default function VisFactory(Notifier, Private) { | |
|
||
// http://aphyr.com/data/posts/317/state.gif | ||
this.setState(state); | ||
this.setUiState(uiState); | ||
} | ||
|
||
Vis.convertOldState = function (type, oldState) { | ||
|
@@ -102,7 +105,8 @@ export default function VisFactory(Notifier, Private) { | |
}; | ||
|
||
Vis.prototype.clone = function () { | ||
return new Vis(this.indexPattern, this.getState()); | ||
const uiJson = this.hasUiState() ? this.getUiState().toJSON() : {}; | ||
return new Vis(this.indexPattern, this.getState(), uiJson); | ||
}; | ||
|
||
Vis.prototype.requesting = function () { | ||
|
@@ -125,5 +129,26 @@ export default function VisFactory(Notifier, Private) { | |
}); | ||
}; | ||
|
||
Vis.prototype.hasUiState = function () { | ||
return !!this.__uiState; | ||
}; | ||
Vis.prototype.setUiState = function (uiState) { | ||
if (uiState instanceof PersistedState) { | ||
this.__uiState = uiState; | ||
} | ||
}; | ||
Vis.prototype.getUiState = function () { | ||
return this.__uiState; | ||
}; | ||
Vis.prototype.uiStateVal = function (key, val) { | ||
if (this.hasUiState()) { | ||
if (_.isUndefined(val)) { | ||
return this.__uiState.get(key); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You never check that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch, I will change. |
||
} | ||
return this.__uiState.set(key, val); | ||
} | ||
return val; | ||
}; | ||
|
||
return Vis; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure its necessary to set the
mapZoom
here. Just setting themapCenter
should be sufficient when moving the map, no?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it was because during the auto fit it didn't call the zoom function, but after testing it seems I'm mistaken. I'll take it out.