MrDys / blacklight

Blacklight Plugin
http://projectblacklight.org/
Other
1 stars 1 forks source link

folder js code assumes app is mounted at a root path #464

Closed MrDys closed 12 years ago

MrDys commented 12 years ago

CODEBASE-278: The folder handling code in application.js examines and rewrites URLs on a form action. But the code assumes that the app is mounted at the HTTP root '/' path, it looks for and sets URLs that it assumes always begins "/folder".

When in fact a Rails app can be at some other prefix, "/demo/folder" in my case, or whatever, "/path/to/my/blacklight/folder"

The JS code should be fixed to work regardless.

This can be done if the js code simply looks at the existing form=action, and uses regexp matches on just the tail end of it, or to search and replace just the tail end of it, etc.

Additionally, the JS code to do an ajax form submit doesn't need to be looking through the inputs and constructing a query string by hand, it can just call form.serialize() and pass the results as the 'data' argument to jQuery.post.

MrDys commented 12 years ago

Original reporter: jrochkind

MrDys commented 12 years ago

jrochkind: Believe this is no longer relevant.

MrDys commented 12 years ago

jrochkind: bullk change, pushing past 3.1 in preperation for 3.0.

MrDys commented 12 years ago

jrochkind: Just brainstorming some more, but maybe ideally the JS shouldn't be sniffing/parsing/rewriting URI's at all, but a better design would be to have it recognize current state by looking at HTML classes (or HTML5 data-* attributes), and getting new URLs from response returned by the server on an ajaxy post to the add/remove actions. That might lead to simpler and more robust code than continuing to sniff and modify URLs as strings from the DOM but adding regex.

MrDys commented 12 years ago

jrochkind: [the server could even just return an HTML snippet for "new folder button" that the JS just drops into place, so the JS doesn't need to know anything about URLs, the JS just makes the POST and then gets back the new HTML for the button in it's now correct state]