Skip to content
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

Refactor taxonomy tree set up javascript to a reusable function #2129

Closed
codeodor opened this issue Oct 22, 2012 · 3 comments
Closed

Refactor taxonomy tree set up javascript to a reusable function #2129

codeodor opened this issue Oct 22, 2012 · 3 comments

Comments

@codeodor
Copy link
Contributor

I've been working on a customization where I needed to display the taxonomy tree some place else.

From that view, it looks nice, but the javascript that sets is up isn't reusable.

Also, there's this setting up of the initial variable and the new_taxon which the document.ready code expects to have been set.

I got my customization done, but if you're interested interested in having this contributed back into the project as a refactoring, I'll make the changes to spree and submit a pull request.

Basically, what I'd do is:

  1. Change that set up code of the initial to use a new method on Taxonomy called to_js_tree which would call a method of the same name on its root taxon. This way any taxonomy can generate its own js tree instead of limiting it to the instance variable in the edit action on the taxonomies controller.
  2. Extract the code in the document.ready into it's own function, and then call it with the appropriate arguments to keep the tree showing up on the taxononmies edit page, without relying on variables defined elsewhere.

I think that's all that needs to change.

Let me know if you're interested in seeing it, or just close this issue if not.

@radar
Copy link
Contributor

radar commented Oct 26, 2012

Yup, would be interested in seeing this patch. Please craft it :)

@codeodor
Copy link
Contributor Author

codeodor commented Nov 1, 2012

Will do. Sorry about the delay!

@codeodor
Copy link
Contributor Author

codeodor commented Nov 7, 2012

Created pull request #2192 to demonstrate.

Tests all pass.

@codeodor codeodor closed this as completed Nov 7, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants