Support from Acquia helps fund testing for Drupal Acquia logo

Comments

klaasvw’s picture

The attached patch adds a variable for excluding chosen on admin pages.

klaasvw’s picture

Status: Active » Needs review

Setting status

klaasvw’s picture

Removed a syntax error from the patch.

klaasvw’s picture

Added another fix that prevents chosen being loaded by AJAX in the admin.

mxwitkowski’s picture

Tried applying the patch in #4 to both 7.x-2.0-alpha4 and 7.x-2.x-dev -- both failed:
patching file chosen.admin.inc
Hunk #1 FAILED at 51.

mvc’s picture

I found it annoying to edit Views with Chosen enabled so I re-rolled (and simplified) this patch.

I renamed the variable because this option controls display on all admin pages and doesn't actually check if we're currently using whatever the current admin theme is (nor should it).

mxwitkowski’s picture

Applied the patch to chosen 7.x-2.0-alpha3 and got a warning: Hunk #1 succeeded at 59 (offset 9 lines). The patch applied fine and all is working fine. @mvc -- nice work, thanks.

mvc’s picture

right, i wrote the patch for the latest dev.

P2790’s picture

Can this be committed to the latest dev?

mvc’s picture

antonyanimator, mxwitkowski: if this patch works for you, please leave a comment saying so, and change the status of this issue to "reviewed & tested by the community" so that the maintainers know it's ready to go.

mxwitkowski’s picture

@mvc - confirmed, patch #6 is working well for me

mvc’s picture

mxwitkowski : glad it worked!

if you think this is ready to be committed to the dev branch, please change the status to RTBC as explained here: https://drupal.org/node/156119

P2790’s picture

Status: Needs review » Reviewed & tested by the community

The patch is working for me too

zilla’s picture

would love to see this in an update - was using something like body:not(.page-admin) but seems clunky and as you may already know, it breaks imagecache (the default chosen settings)

millionleaves’s picture

Patch works for me most of the time, but I've noticed it doesn't catch everything in Panels, e.g. when editing the settings for a Pane. Will note anything else that comes up.

idebr’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Needs review
FileSize
744 bytes
2.12 KB

A path can be an admin path, but does not guarantee the current theme is actually the admin theme for example when a user is not allowed to view it. A common example is user/%user/edit, where administrators has a different theme than the user.

I suggest using a different approach that checks for the actual theme instead of the path.

mvc’s picture

@idebr: that was the approach used in #4, but what if there is no admin theme set, or the admin theme is the same as the default theme? if you prefer to switch based on the theme, you'll have to check for those two cases and fall back to the test i used in #6. also, i think it's a mistake to remove the test for the path system/ajax.

mvc’s picture

Status: Needs review » Needs work

forgot to change status...

Mołot’s picture

I used patch from #6 and it works OK for me.

My suggestion: use the same approach as jQuery Update is now using, to determine admin pages. That way we will be able to keep things consistent.

The code used in #1524944 Allow different version for administrative pages is:

if (!empty($admin_version) && path_is_admin(current_path()))

Please, please stick to it for the consistency! I really don't want to end up with pages that have chosen enabled, but with jQuery version to low for chosen to work.

diamondsea’s picture

Re #14: To make it work with the image styles without a patch, change the default selection string in "Apply Chosen to the following elements" to:

select:visible:not('.image-style-new select')

mvc’s picture

Status: Needs work » Needs review

@Mołot i agree with you that these modules should be consistent, and the test in my patch in #6 is exactly the same as jquery_update, except that here we also avoid loading chosen for system ajax callbacks which i think is the correct thing to do.

setting to 'needs review' again because i think i've answered idebr's objections in #17.

Dave Reid’s picture

Title: Toggle chosen on admin pages » Disable chosen on admin pages

Misleading title

theapi’s picture

Status: Needs review » Reviewed & tested by the community

#6 works for me.
Thank you.

The last submitted patch, 1: chosen-toggle-admin-pages-option-2089987-1.patch, failed testing.

The last submitted patch, 3: chosen-toggle-admin-pages-option-2089987-3.patch, failed testing.

The last submitted patch, 4: chosen-toggle-admin-pages-option-2089987-4.patch, failed testing.

The last submitted patch, 6: chosen-toggle-admin-pages-option-2089987-6.patch, failed testing.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 16: chosen-toggle-admin-pages-option-2089987-16.patch, failed testing.

mike.davis’s picture

Status: Needs work » Needs review
FileSize
1.72 KB

I tried applying patch #16 to 7.x-2.0-beta4 but it failed with:

Hunk #1 FAILED at 181.
1 out of 1 hunk FAILED -- saving rejects to file chosen.module.rej

I have had a look at the bit that failed in chosen.module and I have updated it for this release and this seems to be working fine for me. From the comments, it could do with someone testing it with Panels. Views seems to be fine.

jenlampton’s picture

Assigned: klaasvw » Unassigned
Status: Needs review » Reviewed & tested by the community

This patch works for me with both views and panels. Nice work :)

Dave Reid’s picture

Should this actually be a per-theme setting instead of just admin vs non-admin?

mvc’s picture

I still disagree with the idea of testing based solely on the current theme, as mentioned in comment #17, so here's a patch which does both tests. I'm also proposing to disable this by default on admin pages -- opinions?

@Dave Reid, that would be more work and so far everyone commenting here just seems to want to control admin/non-admin. I suggest starting with this and waiting to see if there's a demand for finer control.

wOOge’s picture

Would it be useful to have an input box that lets you disable Chosen on either specified Drupal paths, or on specified css elements?
That way the module is not making broad decisions for the user, and the user can be very specific or be very general in their configuration.

Thoughts?

ndf’s picture

Status: Needs review » Reviewed & tested by the community

Patch #32 does the job well. Not sure the default setting to disable on admin pages is logic.

@ Dave Reid and wOOge: to me the 'Disable Chosen on the following paths' approach seems most natural. On some admin-pages Chosen can be a great tool, on others (see attached image) it breaks. And yes, that would mean with this patch you first should enable Chosen on admin-pages :)

ndf’s picture

GuyPaddock’s picture

Status: Reviewed & tested by the community » Needs work

This still needs work... We're using Chosen on select lists in user profiles. When the user goes to edit his or her profile, Drupal considers the user edit page to be an "admin page" and therefore this patch causes Chosen not to work on that page unless we enable Chosen for ALL admin pages.

It seems like we do need a way to specify paths or permissions that control when Chosen should be applied. Just basing it on admin vs. non-admin doesn't seem correct. Perhaps it should also be based on whether the user has the permission to use the "admin theme"?

joelpittet’s picture

@GuyPaddock

You can do this to help you out maybe?


/**
 * Implements hook_admin_paths_alter().
 */
function MODULE_admin_paths_alter(&$paths) {
  // Treat all user pages as non-administrative.
  $paths['user/*'] = FALSE;
}
lucsb’s picture

This worked for me:
Place select#edit-selected in the Apply Chosen to the following elements text box in the module config page.

m.lebedev’s picture

Re #32:
current_path() == 'system/ajax'
This check causes problems when the form is updated using Ajax.
Example:

$form['example'] = array(
  '#type' => 'submit',
  '#value' => t('Submit'),
  '#submit' => array('MODULE_submit'),
  '#ajax' => array(
    'callback' => 'MODULE_submit_ajax',
    'wrapper' => 'wrapper',
  ),
);

I propose to refuse this check.

abu-zakham’s picture

Status: Needs work » Needs review
FileSize
1.78 KB

Hello, I have a case, need to disable chosen when admin edit node,
Note: admin theme is the same site theme.
I've rewrite patch #39 to fix it.
Thanks

m.lebedev’s picture

Your a new condition will break all sites. You can disable the chosen in your module, eg adding a hook_form_alter.

m.lebedev’s picture

for new version chosen

Status: Needs review » Needs work

The last submitted patch, 43: chosen-toggle-admin-pages-option-2089987-43.patch, failed testing.

nagy.balint’s picture

Status: Needs work » Closed (duplicate)

Going to mark this as duplicate of #2534756: Enable Chosen on admin page only as that issue also contains this one.