-
Notifications
You must be signed in to change notification settings - Fork 67
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
Menu Refactor #30
Menu Refactor #30
Conversation
|
||
}, | ||
L.DNC.GeoMenu = L.DNC.Menu.extend({ | ||
title: "Geoprocessing Tools", |
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.
Should this go into this.options
? Probably...
Thinking more about this, I think this still has quite a ways to go. There should probably be a single location (likely within L.DNC.MenuBar = L.Class.extend({
initialize : function( options ) {
new L.DNC.Menu("Geoprocessing Tools", {
operations: [
// The meat of the tooling can either be defined here or in a class that subclasses L.DNC.MenuOperartion
new L.DNC.MenuOperation("Buffer", function() {
// Do some buffering stuff
}),
new L.DNC.MenuOperation("Erase", new L.DNC.EraseOperation({}))
]
});
new L.DNC.Menu("Save Data", {
operations: [
// ...
]
})
}
}); or probably more like: L.DNC.MenuBar = L.Class.extend({
initialize : function( options ) {
new L.DNC.Menu("Geoprocessing Tools", {})
// These operations would all extend the same MenuOperation (and maybe GeoOperation) class
.addOperation(new L.DNC.BufferOperation({}))
.addOperation(new L.DNC.EraseOperation({}))
.addOperation(new L.DNC.UnionOperation({}))
;
new L.DNC.Menu("Save Data", {position: "right", icon: "fa-floppy-o"}) // Pass in menu options
.addOperation(new L.DNC.DownloadJsonOperation({}))
.addOperation(new L.DNC.DownloadShapeFileOperation({}))
.addOperation(new L.DNC.CreateGistOperation({}))
;
}
}); To reiterate from the last conversation, a menu operation should be aware of:
|
Continuing with this, I think abstracting all Turf operations would be even more ideal: L.DNC.MenuBar = L.Class.extend({
initialize : function( options ) {
new L.DNC.Menu("Geoprocessing Tools", {})
.addOperation(new L.DNC.TurfOperation("buffer", {
maxFeatures: 1
}))
.addOperation(new L.DNC.TurfOperation("erase", {
minFeatures: 2,
maxFeatures: 2,
orderImportant: true
}))
.addOperation(new L.DNC.TurfOperation("union", {
maxFeatures: 2,
minFeatures: 2
}))
;
new L.DNC.Menu("Save Data", {position: "right", icon: "fa-floppy-o"}) // Pass in menu options
.addOperation(new L.DNC.DownloadJsonOperation({}))
.addOperation(new L.DNC.DownloadShapeFileOperation({}))
.addOperation(new L.DNC.CreateGistOperation({}))
;
}
}); Turf Operations Options
Experimental
Abstracting every turf operation may be lofty, but if we can do it correctly it could allow us to quickly support all operations with little code. |
This is really cool - I'm super into the last example that you're showing. The structure seems really straightforward and easy to manage. It will be particularly helpful as we make decisions on what goes into each menu and need to change order/location quickly. Doesn't involve going to individual files for each of the processes. |
|
||
initialize: function ( title, options ) { | ||
L.DNC.Operation.prototype.initialize.call(this, title, options); | ||
}, |
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.
No need to override method to simply call parent method.
I wonder if we could also add an "info" parameter that allows us to write a paragraph about the specific type of operation. I.e. when you hover on |
@svmatthews That's funny, I was thinking about the exact same thing today. I think I'm going to take up tooltips as the next feature. For now, I think that this is complete. I've met the minimum I also went ahead and moved that event handler into the FileReader logic that you mentioned in #31. It wasn't as big of a deal as I originally thought. This stuff probably is worthy of creating some tests, although I haven't gotten to that just yet. |
Oh man this is amazing. This whole pub/sub system seems really powerful. I'm going to work around on this and will merge it asap, then rebase for #33 to have notifications listen for publishers all in one file, rather than having them spread all around. |
💥 shakalaka! |
When these refactors happen, I'm going to start making wiki pages so we can document once they are settled. Here's the placeholder for the menu architecture. https://github.com/cugos/drop-n-chop/wiki/Menu-Items |
I've opened this up for review/discussion. It was built off of the
feature/grunt_helpers
branch (#29), so for sake of a cleaner diff I've set this to merge into that branch.What's changed
In efforts to prepare for more menu options, I've broken all of the geo-tooling out of
L.DNC.Menu
and placed it in aL.DNC.GeoMenu
object that inherits fromL.DNC.Menu
. The menu now builds itself based on it's ownbuildMenu()
function.