DROP Task: Alter flexifilter administration interface to use tabledrag API.

arhip - January 11, 2008 - 02:14
Project:Flexifilter
Version:6.x-1.1-rc1
Component:User interface - Admin pages
Category:feature request
Priority:normal
Assigned:Unassigned
Status:patch (code needs work)
Description

Hi.

I think Edit flexifilter form is too crowded when there are many components, especially for nested components. I suggest to use tabledrag instead of fieldsets, to improve user friendliness.

#1

cwgordon7 - January 18, 2008 - 01:25

Good idea; the administration pages will likely see reworking in the 1.2 version if not the 1.1 version. As always, patches are welcome :) .

#2

cwgordon7 - January 29, 2008 - 00:41
Title:Tabledrag vs. Fieldset» Drop #1: Alter flexifilter administration interface to use tabledrag API.
Version:6.x-1.0-beta2» 6.x-1.1-rc1

This is now a DROP task.

#3

cwgordon7 - January 29, 2008 - 00:46
Title:Drop #1: Alter flexifilter administration interface to use tabledrag API.» Drop Task: Alter flexifilter administration interface to use tabledrag API.

(Forgot about the no-numbering rule)

#4

dmitrig01 - January 29, 2008 - 01:05

Inital patch... doesn't add Drag 'n Drop.

AttachmentSize
flexifilter_ui.patch11.47 KB

#5

dmitrig01 - January 29, 2008 - 05:32

Another update... has lots of code that doesn't yet work

AttachmentSize
flexifilter_ui.patch27.26 KB

#6

dmitrig01 - February 2, 2008 - 05:42

Now with awesomeness out of the box

AttachmentSize
flexifilter_ui.patch37.62 KB

#7

dmitrig01 - February 2, 2008 - 19:57

Latest update

AttachmentSize
flexifilter_ui.patch44.9 KB

#8

corsix - February 2, 2008 - 21:50

Getting this:

Warning: Call-time pass-by-reference has been deprecated - argument passed by value; If you would like to pass it by reference, modify the declaration of form_get_cache(). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file. However, future versions may not support this any longer. in E:\HTML\Apache\users\drupal60_dev_clean\modules\flexifilter\flexifilter.admin.inc on line 762
after enabling flexifilter. Apparently the line in question needs to be changed from
<?php
   $form
= form_get_cache($form_build_id, &$form_state);
?>
to
<?php
   $form
= form_get_cache($form_build_id, $form_state);
?>

#9

corsix - February 2, 2008 - 21:58
Status:active» patch (code needs work)

Firstly, I cannot edit things using Firefox2. I can rearrange components, but clicking on one doesn't yield a way to edit it.

Secondly, saving a flexifilter gives a bunch of PHP notices:

    * notice: Undefined index: id_prefix in E:\HTML\Apache\users\drupal60_dev_clean\modules\flexifilter\flexifilter.admin.inc on line 212.
    * notice: Undefined index: id_prefix in E:\HTML\Apache\users\drupal60_dev_clean\modules\flexifilter\flexifilter.admin.inc on line 212.
    * notice: Undefined index: id_prefix in E:\HTML\Apache\users\drupal60_dev_clean\modules\flexifilter\flexifilter.admin.inc on line 212.
    * notice: Undefined index: id_prefix in E:\HTML\Apache\users\drupal60_dev_clean\modules\flexifilter\flexifilter.admin.inc on line 212.
    * notice: Undefined index: id_prefix in E:\HTML\Apache\users\drupal60_dev_clean\modules\flexifilter\flexifilter.admin.inc on line 212.
    * notice: Undefined index: id_prefix in E:\HTML\Apache\users\drupal60_dev_clean\modules\flexifilter\flexifilter.admin.inc on line 212.
    * notice: Undefined index: id_prefix in E:\HTML\Apache\users\drupal60_dev_clean\modules\flexifilter\flexifilter.admin.inc on line 212.
    * notice: Undefined index: id_prefix in E:\HTML\Apache\users\drupal60_dev_clean\modules\flexifilter\flexifilter.admin.inc on line 212.
    * notice: Undefined index: id_prefix in E:\HTML\Apache\users\drupal60_dev_clean\modules\flexifilter\flexifilter.admin.inc on line 219.
    * notice: Undefined index: class in E:\HTML\Apache\users\drupal60_dev_clean\modules\flexifilter\flexifilter.admin.inc on line 220.
    * notice: Undefined index: in E:\HTML\Apache\users\drupal60_dev_clean\modules\flexifilter\flexifilter.admin.inc on line 220.
    * notice: Undefined index: id_prefix in E:\HTML\Apache\users\drupal60_dev_clean\modules\flexifilter\flexifilter.admin.inc on line 219.
    * notice: Undefined index: class in E:\HTML\Apache\users\drupal60_dev_clean\modules\flexifilter\flexifilter.admin.inc on line 220.
    * notice: Undefined index: in E:\HTML\Apache\users\drupal60_dev_clean\modules\flexifilter\flexifilter.admin.inc on line 220.
    * notice: Undefined index: id_prefix in E:\HTML\Apache\users\drupal60_dev_clean\modules\flexifilter\flexifilter.admin.inc on line 219.
    * notice: Undefined index: class in E:\HTML\Apache\users\drupal60_dev_clean\modules\flexifilter\flexifilter.admin.inc on line 220.
    * notice: Undefined index: in E:\HTML\Apache\users\drupal60_dev_clean\modules\flexifilter\flexifilter.admin.inc on line 220.
    * notice: Undefined index: id_prefix in E:\HTML\Apache\users\drupal60_dev_clean\modules\flexifilter\flexifilter.admin.inc on line 219.
    * notice: Undefined index: class in E:\HTML\Apache\users\drupal60_dev_clean\modules\flexifilter\flexifilter.admin.inc on line 220.
    * notice: Undefined index: in E:\HTML\Apache\users\drupal60_dev_clean\modules\flexifilter\flexifilter.admin.inc on line 220.
    * notice: Undefined index: id_prefix in E:\HTML\Apache\users\drupal60_dev_clean\modules\flexifilter\flexifilter.admin.inc on line 186.
    * notice: Undefined index: id_next in E:\HTML\Apache\users\drupal60_dev_clean\modules\flexifilter\flexifilter.admin.inc on line 187.

#10

kourge - February 24, 2008 - 01:07

I have concerns with the JavaScript file in this patch. The JS code is conveniently reproduced below due to the lack of the actual existence of the file as of now, because the JS file is still part of the patch.

(function($) {
  $(function() {
    $('#flexifilter-components tbody tr').each(function() {
      $(this).find('td:first').bind('click', function() {
        component_id = $(this).parent().find('td:last .flexifilter-cid').val();
        $('#flexifilter-components tbody tr').removeClass('flexifilter-component-highlighted');
        $.scrollTo($('#flexifilter-component-settings').offset().top - 10, 'slow');
        $('#flexifilter-component-settings').load(Drupal.settings.basePath +'admin/build/flexifilters/js/component_edit/'+ Drupal.settings.flexifilterFid +'/'+ component_id, function() {
          Drupal.attachBehaviors($(this));
          $(this).css('background-color', '#FCFF97');
          $(this).animate({ 'background-color': '#ffffff' }, 'slow');
        });
        return false;
      });
    });
  });
  // This is only when flexifilter.inc is included
  Drupal.theme.prototype.tableDragChangedWarning = function() {};
})(jQuery);

Let's start with line 2. $(function() {/*...*/}) is certainly a very compact way to state $(document).ready(function() {/*...*/}), but it does not offer as much clarity. It's not a severe problem, though.

The biggest problem is this:
component_id = $(this).parent().find('td:last .flexifilter-cid').val();
It should be this:
var componentId = $(this).parent().find('td:last .flexifilter-cid').val();
The reason to use var is because in JavaScript if you don't, and if a global variable has the same name, it would be overwritten. Using var would indicate that it's intended to be local. Not only that, you should never leave out var for declaring local variables because it's costly. It's an expensive operation since the JavaScript engine would have to go through the trouble of looking for a variable with the same name. (A more technically correct way to put it is that it would search up the whole scoping chain until it hits the global namespace if there aren't any variables with the same name.)
So never leave out var unless it's intended. I suggested componentId instead of component_id because in JavaScript, camelCasing is the practice, rather than underscore_separation.

Lastly, it would be best to consolidate the following two lines:

$(this).css('background-color', '#FCFF97');
$(this).animate({ 'background-color': '#ffffff' }, 'slow');

Into one line:
$(this).css('background-color', '#FCFF97').animate({ 'background-color': '#ffffff' }, 'slow');
Not only would this save space and eliminate visual redundancy, it would also avoid calling $(this) twice, speeding up the performance (a tiny bit).

I'm happy to see the (function($) {/*...*/})(jQuery); wrapping. This ensures library compatibility.

#11

birdmanx35 - February 23, 2008 - 02:41

Word on the street says dmitrig01 is still working on this locally.

#12

birdmanx35 - February 24, 2008 - 01:05
Title:Drop Task: Alter flexifilter administration interface to use tabledrag API.» DROP Task: Alter flexifilter administration interface to use tabledrag API.

#13

Amitaibu - March 17, 2008 - 13:38

subscribe

#14

wolfflow - June 11, 2008 - 03:12

Subscribe

 
 

Drupal is a registered trademark of Dries Buytaert.