Changeset 15204

Show
Ignore:
Timestamp:
02/23/08 00:17:16 (8 months ago)
Author:
flack
Message:

make chooser creation mode work correctly if there is more than one chooser widget in the current form

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/MidCOM_2_8/midcom.helper.datamanager2/widget/chooser.php

    r14720 r15204  
    204204    /** 
    205205     * These options are always visible 
    206      *  
     206     * 
    207207     * @var array 
    208208     */ 
     
    284284    /** 
    285285     * The group of widgets items as QuickForm elements 
    286      *  
     286     * 
    287287     * @var array 
    288288     */ 
    289289    var $widget_elements = array(); 
    290      
     290 
    291291    var $_static_items_html = ""; 
    292292    var $_added_static_items = array(); 
    293      
     293 
    294294    var $allow_multiple = true; 
    295295    var $require_corresponding_option = true; 
     
    10941094            $dialog_id = $this->_element_id . '_creation_dialog'; 
    10951095 
    1096             $dialog_js = '<script type="text/javascript">'; 
    1097             $dialog_js .= "function close_dialog(){jQuery('#{$dialog_id}').hide();};"; 
    1098             $dialog_js .= "function add_item(data){jQuery('#{$this->_element_id}_search_input').midcom_helper_datamanager2_widget_chooser_add_result_item(data);};"; 
    1099             $dialog_js .= '</script>'; 
    1100  
    11011096            $dialog_html = '<div class="chooser_widget_creation_dialog" id="' . $dialog_id . '">'; 
    11021097            $dialog_html .= '<div class="chooser_widget_creation_dialog_content_holder">'; 
    1103             $dialog_html .= $dialog_js; 
    11041098            $dialog_html .= '</div>'; 
    11051099            $dialog_html .= '</div>'; 
     
    11511145        // debug_pop(); 
    11521146 
    1153         // $this->_static_items_html = "<noscript>\n";         
     1147        // $this->_static_items_html = "<noscript>\n"; 
    11541148        $this->_static_items_html .= "<table class=\"widget_chooser_static_items_table\">\n<thead><tr>\n"; 
    1155          
     1149 
    11561150        if (   !empty($this->reflector_key) 
    11571151            && !$this->result_headers) 
     
    11651159            { 
    11661160                $this->_static_items_html .= "    <th class=\"{$header_item['name']}\">{$header_item['title']}&nbsp;</th>\n"; 
    1167             }             
    1168         } 
    1169          
     1161            } 
     1162        } 
     1163 
    11701164        $title = $_MIDCOM->i18n->get_string('Selected', 'midcom.helper.datamanager2'); 
    11711165        $this->_static_items_html .= "    <th class=\"selected\">{$title}&nbsp;</th>\n"; 
    1172          
     1166 
    11731167        $this->_static_items_html .= "</tr></thead>\n<tbody>\n"; 
    1174          
     1168 
    11751169        $ee_script = ''; 
    11761170        if ($this->_renderer_callback) 
     
    12071201            } 
    12081202        } 
    1209          
     1203 
    12101204        $this->_jscript .= $ee_script; 
    12111205 
     
    12261220            $this->_jscript 
    12271221        ); 
    1228          
     1222 
    12291223        $this->widget_elements[] =& HTML_QuickForm::createElement 
    12301224        ( 
     
    12371231        $group =& $this->_form->addGroup($this->widget_elements, $this->name, $this->_translate($this->_field['title']), '', array('class' => 'midcom_helper_datamanager2_widget_chooser')); 
    12381232    } 
    1239      
     1233 
    12401234    function _add_existing_item_as_static($key) 
    12411235    { 
     
    12431237        $id_field = $this->id_field; 
    12441238        $item_id = @$object->$id_field; 
    1245          
     1239 
    12461240        if (   empty($item_id) 
    12471241            || isset($this->_added_static_items[$item_id])) 
     
    12491243            return; 
    12501244        } 
    1251          
     1245 
    12521246        $this->_static_items_html .= "<tr id=\"{$this->_element_id}_existing_item_{$item_id}_row\" class=\"chooser_widget_existing_item_static_row\">\n"; 
    1253          
     1247 
    12541248        if (   !empty($this->reflector_key) 
    12551249            && !$this->result_headers) 
     
    12691263                // $value = rawurlencode(utf8_decode($value)); 
    12701264                // debug_add("adding header item: name={$item_name} value={$value}"); 
    1271         //          
     1265        // 
    12721266                $this->_static_items_html .= "<td class=\"{$item_name}\">{$value}&nbsp;</td>"; 
    12731267            } 
    12741268        } 
    1275          
     1269 
    12761270        $this->_static_items_html .= "<td>\n"; 
    12771271        $this->_static_items_html .= "<input type=\"checkbox\" name=\"{$this->_element_id}_selections[{$item_id}]\" id=\"{$this->_element_id}_existing_item_{$item_id}_value\" class=\"chooser_widget_existing_item_static_input\" checked=\"checked\"/>\n"; 
    12781272        $this->_static_items_html .= "</td>\n"; 
    1279          
     1273 
    12801274        $this->_static_items_html .= "</tr>\n"; 
    1281          
     1275 
    12821276        $this->_added_static_items[$item_id] = true; 
    12831277    } 
     
    13901384                return $this->_callback->resolve_object_name($key); 
    13911385            } 
    1392                          
     1386 
    13931387            $results = $this->_callback->get_key_data($key); 
    13941388 
     
    14521446 
    14531447        $_MIDCOM->auth->drop_sudo(); 
    1454          
     1448 
    14551449        // debug_pop(); 
    14561450        if ($return_object) 
  • branches/MidCOM_2_8/midgard.admin.asgard/style/midgard_admin_asgard_object_create_after.php

    r13651 r15204  
    11<script type="text/javascript"> 
     2   /* 
     3    * we need to determine the correct widget_id prefix here, loading from the parent 
     4    * frame breaks when multiple choosers with creation support exist 
     5    */ 
     6   var widget_id = window.parent.jQuery("iframe[src^=" + window.location.pathname + "]").attr("id"); 
     7   widget_id = widget_id.replace('chooser_widget_creation_dialog_content',''); 
     8 
     9 
     10   function close_dialog(){window.parent.jQuery('#' + widget_id + '_creation_dialog').hide();}; 
     11   function add_item(data){window.parent.jQuery('#' + widget_id + '_search_input').midcom_helper_datamanager2_widget_chooser_add_result_item(data);}; 
    212    <?php 
    313    if (! isset($data['cancelled'])) 
    414    { 
    5         echo "window.parent.add_item({$data['jsdata']});"; 
     15 
     16        echo "add_item({$data['jsdata']});"; 
    617    } 
    718    ?> 
    8     window.parent.close_dialog(); 
     19    close_dialog(); 
    920</script>