Development

Changeset 5728

You must first sign up to be able to contribute.

Changeset 5728

Show
Ignore:
Timestamp:
10/29/07 00:41:12 (1 year ago)
Author:
Leon.van.der.Ree
Message:

First fix for new foreign-key drop-down-list style.

You can now define foreign-key-value list in your generator.yml file as:

display: [ =name, country/name ]


or


display: [ =name, country/abbreviation ]


TODO: get the JSON-Data from the main-list (which removes the dependency on the generator of the list-class)

display: [ =name, country_id ] now gets obsolete (although it for now still works...)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfExtjsThemePlugin/data/generator/sfPropelAdmin/extjs/template/templates/_json_list_td.php

    r5717 r5728  
    77$pk = $pks[0]->getPhpName(); 
    88 
     9//iterate through all columns of all class 
     10$completeColumns= $this->getColumnsGroup($pk); 
    911 
    1012$hs = $this->getParameterValue('list.hide', array()); 
     
    3739  else 
    3840  { 
    39     $value = $this->getColumnListTag($column); 
     41    // set value 
     42    if (false !== strpos($column->getName(), '/')) 
     43    { 
     44      list($relatedClassName, $relatedColumn) = explode('/', $column->getName()); 
     45      $value = $this->getColumnListTag($completeColumns['related'][$relatedClassName]['pk']); 
     46    } 
     47    else 
     48    { 
     49      $value = $this->getColumnListTag($column); 
     50    } 
    4051  } 
    41   echo "\"".$column->getName()."\": \"[?php echo str_replace('\"', '\\\"', ".$value.") ?]\""; 
     52 
     53  //set name 
     54  if (false !== strpos($column->getName(), '/')) 
     55  { 
     56    list($relatedClassName, $relatedColumn) = explode('/', $column->getName()); 
     57    $name = $completeColumns['related'][$relatedClassName]['pk']->getName(); 
     58  } 
     59  else 
     60  { 
     61    $name = $column->getName(); 
     62  } 
     63 
     64  echo "\"".$name."\": \"[?php echo str_replace('\"', '\\\"', ".$value.") ?]\""; 
    4265 
    4366  $i++; 
  • plugins/sfExtjsThemePlugin/data/generator/sfPropelAdmin/extjs/template/templates/_list_ajax_layout.php

    r5717 r5728  
    3232$pk = $pks[0]->getPhpName(); 
    3333$pkn = $this->getAdminColumnForField($pk)->getName(); 
    34 $prefix = ""
     34$prefix = ""
    3535 
    3636$columns['pk'] = $this->getAdminColumnForField($pk); 
     
    7171      // create the Data Store 
    7272<?php 
     73        // TODO: parts of this should be moved to the actions.class one day 
    7374        $store = ''; 
    7475        $jsCode = ''; 
     
    7778        $i = 1; $listDisplay = array(); 
    7879 
     80        // Alwasy add primary key 
    7981        $listDisplay[0] = array('name' => $prefix.$columns['pk']->getName(), 
    8082                                'mapping' => $prefix.$columns['pk']->getName(), 
     
    9092            $i++; 
    9193 
    92             foreach ($relatedClasses['columns'] as $relatedColumn => $col) 
    93             { 
    94               $listDisplay[$i] = array('name' => $class.'/'.$relatedColumn, 
    95                                        'mapping' => $class.'/'.$relatedColumn, 
    96                                        'type' => extjs_convert_propel_type($col->getType())); 
    97               $i++; 
    98             } 
     94            // TODO: enable this when it is implemented in the JSON-output! NICE!!! 
     95//            foreach ($relatedClasses['columns'] as $relatedColumn => $col) 
     96//            { 
     97//              $listDisplay[$i] = array('name' => $class.'/'.$relatedColumn, 
     98//                                       'mapping' => $class.'/'.$relatedColumn, 
     99//                                       'type' => extjs_convert_propel_type($col->getType())); 
     100//              $i++; 
     101//            } 
    99102          } 
    100103        } 
     
    192195      $listDisplay = array(array('name' => $pk, 'mapping' => $pk), 
    193196                           array('name' => $relatedColumn, 'mapping' => $relatedColumn)); 
    194       $options = array('id' => $column->getName()
     197      $options = array('id' => $pk
    195198                       'root' => 'data', 
    196199                       'totalProperty' => 'totalCount'); 
     
    291294        // http://extjs.com/forum/showthread.php?t=13268 
    292295        if (value) { 
    293           return <?= strtolower($relatedClassName) ?>_ds.getById(value).get('name'); 
     296<?php 
     297  //set name 
     298  if (false !== strpos($column->getName(), '/')) 
     299  { 
     300    $name = $relatedColumn; 
     301  } 
     302  else 
     303  { 
     304    $name = $column->getName(); 
     305  } 
     306?> 
     307          return <?php echo strtolower($relatedClassName) ?>_ds.getById(value).get('<?php echo $name ?>'); 
    294308        } 
    295309      } 
     
    317331  $header = str_replace("'", "\\'", $this->getParameterValue('list.fields.'.$column->getName().'.name')); 
    318332  list($header) = explode('/', $header); 
    319   $dataIndex = $column->getName(); 
     333 
     334  if (false !== strpos($column->getName(), '/')) 
     335  { 
     336    list($relatedClassName, $relatedColumn) = explode('/', $column->getName()); 
     337    $dataIndex = $completeColumns['related'][$relatedClassName]['pk']->getName(); 
     338  } 
     339  else 
     340  { 
     341    $dataIndex = $column->getName(); 
     342  } 
     343 
    320344?> 
    321345<?php