@davereid implemented a way to select items in the new Views Library (Views based media browser). We need to fix the way media items are 'selected' to be more like the current browser library. The original request for this fix is at #1224766-30: Remove default media browser and replace with a default view

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

becw’s picture

Assigned: Unassigned » arthurf

Arthur, I think this is related to some of the javascript work you're doing.

arthurf’s picture

Status: Active » Needs review
FileSize
4.37 KB

This is a rough patch as a proof of concept. This should replace the current library

Dave Reid’s picture

Status: Needs review » Needs work

I'm not getting a submit button on my views now. :(

arthurf’s picture

Did you clear your views cache?

Dave Reid’s picture

My views cache is disabled, but I re-reverted the view, cleared cache, and checked again. :/

arthurf’s picture

edited for lack of coffee:

I discovered that the issue is with how the fake submit buttons are created- the JS searches for submits inside the tab HTML to decide if it should append them to the tab or display submit/cancel if they are already present. In the case of the upload tab, the submit/cancel buttons already exist so it does not create them. Likewise, in the case of the view tab since the view has a form (the filters) it will not add the submit.

I think the model of having the JS decide if it should generate the buttons is not a great one- the code assumes somethings about the structure of the submit button which I don't think can be considered consistent. I'm guessing we want to handle this during the plugin declaration and handle it with a theme function if the tab requests the buttons.

Any thoughts on this approach?

arthurf’s picture

FileSize
9.49 KB

For lack of feedback, I went for it. This patch should make views select/cancel work. The upload form also works. For some reason the older library is no longer returning content for me, but I'm pleasantly ignoring it.

Oh, there seems to be a bug if you have a validation error on a file upload and then attempt to browse files from the view tab. The view tab no longer has any files uploaded. I don't think this is a bug specific to this code but figured I'd note it.

agentrickard’s picture

FileSize
122.27 KB
99.04 KB

After the patch, I get a Submit button on the 'View Library' page, but clicking an image submits the form and closes the window.

Trying to use the "Library" tab throws a pretty nasty error (modals within modals).

agentrickard’s picture

And this is what I get when I hit 'Cancel' on the 'Library View'. -- in the modal window

agentrickard’s picture

Here's what happens when I hit 'Submit" without selecting anything -- same behavior as 'Cancel'.

michaelfavia’s picture

Patch applied cleanly and i can confirm the exact same experience as agentrickard with regards to every screenshot he posted.

arthurf’s picture

Status: Needs work » Needs review
FileSize
11.09 KB

Note to self: include new files in your diff.

Ok, one more go here. Includes the JS for views.

agentrickard’s picture

Status: Needs review » Reviewed & tested by the community

Now it works ;-).

Brief test in FF 6 (Mac) suggests this is ready for commit, and further improvements can be done after that.

Dave Reid’s picture

Tested this as well and it worked for me. Committed #12 to Git.
http://drupalcode.org/project/media.git/commit/30fb270

Dave Reid’s picture

Status: Reviewed & tested by the community » Fixed

Note that #12 broke the existing non-Views based media library as now it errors out with "Error getting media" now when the tab is selected. Not sure we really care about this through if we're removing it eventually.

Dave Reid’s picture

http://drupalcode.org/project/media.git/commit/7a2b4e1 was all that was required to fix the JS error. Now both the non-Views and the Views libraries work and select items well. Awesome job arthur!

arthurf’s picture

Crap. I moved that line to make the code more readable. Bad Arthur

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.