Make Execute PHP Block Collapsible

jeffschuler - October 19, 2009 - 17:50
Project:Devel
Version:6.x-1.x-dev
Component:devel
Category:feature request
Priority:normal
Assigned:Unassigned
Status:reviewed & tested by the community
Description

Could the Execute PHP block be [javascript'ly] collapsible?
I like to keep it around while developing, but it takes up screen/mind real estate.

Ideal solution might be an AJAX-y overlay -- a sort of combination of the Execute PHP menu item & block -- but the ability to collapse the block would be a nice step in the non-obtrusive-but-available direction.

#1

jeffschuler - October 19, 2009 - 18:02

Another justification for doing this:
I typically keep the Execute PHP block in the Content Bottom region on sites where there's no room in the footer...
So, the Execute button becomes the bottom button on forms, instead of the Form's Submit, facilitating some minor mixups and hesitation~inefficiencies...

#2

salvis - October 24, 2009 - 15:56

I like the idea (but moshe calls the shots). Collapse it by default if the textarea is empty and expand it if it isn't.

Care to submit a patch?

#3

jeffschuler - October 27, 2009 - 06:37
Status:active» needs review

Thanks for liking the idea!
Here's a patch.

I removed the block title and use the fieldset title, as that space is there just asking to be used, and it makes things a little more compact.

Not sure if there's something better than $_POST to figure out if the code block has text...

Thanks for any feedback.

AttachmentSize
608734-collapsible_1.patch 1.31 KB

#4

salvis - October 27, 2009 - 18:49
Status:needs review» needs work

Didn't you want to put the button into the fieldset?

We'll need a patch for D7, too...

#5

jeffschuler - October 28, 2009 - 04:01
Status:needs work» needs review

Thanks for checking this out.
Good point... Here's an updated D6 patch with the button inside the fieldset.

AttachmentSize
608734-collapsible_2.patch 1.45 KB

#6

jeffschuler - October 28, 2009 - 04:41

Here's a D7 version, (though I haven't changed the version on this Issue.)

Changed ==NULL to isset(). I'll make the same change in the D6 version...

Looks like the code inside the Execute textfield isn't preserved after a form submit, but that happens regardless of whether this patch is applied.

AttachmentSize
608734-collapsible-d7_1.patch 1.41 KB

#7

jeffschuler - October 28, 2009 - 04:50

D6 version using isset()...

AttachmentSize
608734-collapsible-d6_3.patch 1.45 KB

#8

salvis - October 28, 2009 - 15:56
Status:needs review» reviewed & tested by the community

Both versions look and work fine. Thanks.

We'll address the losing of the code in D7 after this is committed.

#9

salvis - November 26, 2009 - 20:27
Priority:minor» normal
Status:reviewed & tested by the community» needs work

I've been using this for a while now and it's nice, except on devel/php: the fieldset should never be collapsed there.

Something like $_GET['q'] != 'devel/php' should help...

Let's raise the priority a little and hope we'll eventually catch moshe's interest...

#10

jeffschuler - November 27, 2009 - 07:20

Another good point ~ thanks salvis.

The attached patch does uses the fieldset only when not on the devel/php page, though it maintains $form['execute']['code'] (instead of the old $form['code']) for the sake of code simplicity. Let me know if this is a bad idea.

It also sets default settings for the Execute PHP block -- preventing duplication by not displaying it on the Execute PHP page.

AttachmentSize
608734-collapsible-d6_7.patch 1.91 KB

#11

jeffschuler - November 27, 2009 - 07:21
Status:needs work» needs review

#12

salvis - November 27, 2009 - 20:55
Status:needs review» reviewed & tested by the community

RTBC for D6. The patch doesn't apply to D7.

The code to avoid duplication on devel/php only works during first-time installation of Devel, but that's already an improvement over what we have now. Admins who have the block enabled are unlikely to go there anyway.

My complaint in #9 is fully addressed, thanks!

 
 

Drupal is a registered trademark of Dries Buytaert.