Repository navigation
Make custom model box work with dragging markers, changing vehicle, adding points etc. - #2301
Conversation
…dding points etc.
| $("#custom-model-search-button").prop('disabled', !valid); | ||
| }; | ||
| $("#custom-model-button").click(function() { | ||
| ghRequest.cmEditor = cmEditor; |
There was a problem hiding this comment.
ghRequest now keeps a reference to the custom model editor. rather hacky, but it 'works' :)
| ghRequest.cmEditorActive = false; | ||
| $("#custom-model-button").click(function () { | ||
| $("#custom-model-box").toggle(); | ||
| ghRequest.cmEditorActive = !ghRequest.cmEditorActive; |
There was a problem hiding this comment.
here we simply keep track whether or not the custom model box is opened or not. if it is we will later send a custom request, otherwise we ignore the custom model box and send the same request we did before.
There was a problem hiding this comment.
I really like this idea and solution! Then it is also easy to see what is changed due to the custom model.
| cmEditor.cm.focus(); | ||
| cmEditor.cm.setCursor(cmEditor.cm.lineCount()) | ||
| cmEditor.cm.setCursor(cmEditor.cm.lineCount()); | ||
| sendCustomData(); |
There was a problem hiding this comment.
I thought it is helpful to also update the route whenever we open/close the custom model box
| var sendCustomData = function() { | ||
| mapLayer.clearElevation(); |
There was a problem hiding this comment.
clicking the custom model search button now triggers just a normal search, but before we send the request we check whether it should be custom or not.
| var sendCustomDataIgnoreErrors = function () { | ||
| ghRequest.ignoreCustomErrors = true; | ||
| mySubmit(); | ||
| } |
There was a problem hiding this comment.
I thought it might be useful to ignore errors when pressing ctrl-enter, so this way we can force sending the request even when the custom model box reports an invalid custom model.
| if (request.cmEditorActive) { | ||
| doCustomRequest(request, routeResultsDiv); | ||
| } else { | ||
| var urlForAPI = request.createURL(); | ||
| request.doRequest(urlForAPI, createRouteCallback(request, routeResultsDiv, urlForHistory, doZoom)); | ||
| } |
There was a problem hiding this comment.
Here we finally check whether the custom box was active or not and send either the custom or the standard request. Since this logic is now down here, we can use the custom model box when we drag markers, change the marker order, change the vehicle, add/delete points etc.
There was a problem hiding this comment.
Maybe we should not run the code block above that starts with if (!doQuery && History.enabled) { when the custom model editor is active? -> Hm not sure, I'll leave it as is for now.
karussell
left a comment
There was a problem hiding this comment.
Thank you - works for me :D
This is my attempt to better integrate the custom model box in the web client. I think it 'works', but for example it kind of breaks the url history as we cannot store the custom model via the url parameters.