Changeset 5854
- Timestamp:
- 11/04/07 17:35:57 (1 year ago)
- Files:
-
- plugins/sfExtjsThemePlugin/data/generator/sfPropelAdmin/extjs/template/templates/_json_list_td.php (modified) (2 diffs)
- plugins/sfExtjsThemePlugin/data/generator/sfPropelAdmin/extjs/template/templates/_list_ajax_layout.php (modified) (17 diffs)
- plugins/sfExtjsThemePlugin/lib/helper/ExtjsHelper.php (modified) (2 diffs)
- plugins/sfExtjsThemePlugin/lib/sfExtjsPropelAdminGenerator.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/sfExtjsThemePlugin/data/generator/sfPropelAdmin/extjs/template/templates/_json_list_td.php
r5793 r5854 9 9 $hs = $this->getParameterValue('list.hide', array()); 10 10 $columns = $this->getColumns('list.display'); 11 //add PrimaryKey of class12 $columns[] = $this->getAdminColumnForField($pk);13 11 14 12 // iterate through all columns of all class (inc. related) 15 13 $completeColumns= $this->getColumnsGroup($pk); 16 14 15 //add PrimaryKey of class 16 $columns[] = $this->getAdminColumnForField($pk); 17 17 18 //iterate through all columns of current class 18 19 //add PrimaryKeys of foreign-classes 20 foreach ($columns as $column) 21 { 22 if ($foreign = (false !== strpos($column->getName(), '/'))) 23 { 24 // construct foreign-id name 25 list($relatedClassName, $relatedColumn) = explode('/', $column->getName()); 26 $columnPk = $completeColumns['related'][$relatedClassName]['pk']; 27 $columnName = $relatedClassName."/".$columnPk->getName(); 28 29 // add column if not already in list 30 if (!in_array($columnName, $hs)) { 31 $columns[] = $this->getAdminColumnForField($columnName); 32 } 33 } 34 } 35 36 37 38 //iterate through all columns 19 39 $i = 0; 20 40 foreach ($columns as $column) : 21 41 22 // set name42 // set name 23 43 $columnName = $column->getName(); 24 if (false !== strpos($column->getName(), '/')) 44 // add classname to json data for fields of current class 45 if (!$foreign = (false !== strpos($column->getName(), '/'))) 25 46 { 26 list($relatedClassName, $relatedColumn) = explode('/', $column->getName()); 27 $columnName = $completeColumns['related'][$relatedClassName]['pk']->getName(); 47 $columnName = strtolower($this->getClassName())."/".$column->getName(); 28 48 } 29 49 30 50 if (in_array($column->getName(), $hs)) continue; 31 51 32 $credentials = $this->getParameterValue('list.fields.'.$column->getName().'.credentials');52 $credentials = $this->getParameterValue('list.fields.'.$column->getName().'.credentials'); 33 53 34 54 ?> … … 43 63 } 44 64 45 // set value 46 if ($column->getCreoleType() == CreoleTypes::BOOLEAN) 47 { 48 $value = $this->getColumnGetter($column, true); 49 } 50 else 51 { 52 if (false !== strpos($column->getName(), '/')) 53 { 54 list($relatedClassName, $relatedColumn) = explode('/', $column->getName()); 55 $value = $this->getColumnListTag($completeColumns['related'][$relatedClassName]['pk']); 56 } 57 else 58 { 59 $value = $this->getColumnListTag($column); 60 } 61 } 65 // // set value 66 // if ($column->getCreoleType() == CreoleTypes::BOOLEAN) 67 // { 68 // $value = $this->getColumnGetter($column, true); 69 // } 70 71 // value data, unfortunately we cannot use the '/' to distinquish the class and the field, because the name is used as variable in _list_ajax_layout.php 72 echo "\"".str_replace('/','_',$columnName)."\": \"[?php echo str_replace('\"', '\\\"', ".$this->getColumnListTag($column).") ?]\""; 62 73 63 if (!in_array($columnName, $hs)) { 64 echo "\"".$columnName."\": \"[?php echo str_replace('\"', '\\\"', ".$value.") ?]\""; 65 66 //don't add it twice 67 $hs[] = $columnName; 68 69 if ($columnName != $column->getName()) echo ", "; 70 } 71 if ($columnName != $column->getName()) { 72 // value data 73 echo "\"".$column->getName()."\": \"[?php echo str_replace('\"', '\\\"', ".$this->getColumnListTag($column).") ?]\""; 74 75 //don't add it twice 76 $hs[] = $column->getName(); 77 } 74 //don't add it twice 75 $hs[] = $column->getName(); 78 76 79 77 $i++; plugins/sfExtjsThemePlugin/data/generator/sfPropelAdmin/extjs/template/templates/_list_ajax_layout.php
r5798 r5854 32 32 $pk = $pks[0]->getPhpName(); 33 33 $pkn = $this->getAdminColumnForField($pk)->getName(); 34 $prefix = "";34 $prefix = strtolower($this->getClassName()); 35 35 36 36 $columns['pk'] = $this->getAdminColumnForField($pk); … … 41 41 42 42 $group_field = $this->getParameterValue('list.grouping.field', null); 43 $group_field = $group_field ? $prefix. $group_field : null;43 $group_field = $group_field ? $prefix."_".$group_field : null; 44 44 45 45 ?> … … 83 83 84 84 // Always add the primary key 85 $listDisplay[0] = array('name' => $prefix. $columns['pk']->getName(),86 'mapping' => $prefix. $columns['pk']->getName(),85 $listDisplay[0] = array('name' => $prefix."_".$columns['pk']->getName(), 86 'mapping' => $prefix."_".$columns['pk']->getName(), 87 87 'type' => extjs_convert_propel_type($columns['pk']->getType())); 88 88 … … 93 93 { 94 94 // Add id 95 $listDisplay[$i] = array('name' => $ relatedClasses['pk']->getName(), // removed $class.'_'.96 'mapping' => $ relatedClasses['pk']->getName(), // removed $class.'_'.95 $listDisplay[$i] = array('name' => $class."_".$relatedClasses['pk']->getName(), 96 'mapping' => $class."_".$relatedClasses['pk']->getName(), 97 97 'type' => extjs_convert_propel_type($relatedClasses['pk']->getType())); 98 98 $i++; … … 100 100 foreach ($relatedClasses['columns'] as $relatedColumn => $col) 101 101 { 102 $listDisplay[$i] = array('name' => $class.' /'.$relatedColumn,103 'mapping' => $class.' /'.$relatedColumn,102 $listDisplay[$i] = array('name' => $class.'_'.$relatedColumn, 103 'mapping' => $class.'_'.$relatedColumn, 104 104 'type' => extjs_convert_propel_type($col->getType())); 105 105 $i++; … … 111 111 foreach ($columns['column'] as $column) 112 112 { 113 $listDisplay[$i] = array('name' => $prefix. $column->getName(),114 'mapping' => $prefix. $column->getName(),113 $listDisplay[$i] = array('name' => $prefix."_".$column->getName(), 114 'mapping' => $prefix."_".$column->getName(), 115 115 'type' => extjs_convert_propel_type($column->getType())); 116 116 … … 118 118 } 119 119 120 $options = array('id' => $prefix. $pkn,120 $options = array('id' => $prefix."_".$pkn, 121 121 'root' => 'data', 122 122 'totalProperty' => 'totalCount'); … … 169 169 <?php 170 170 171 //$hs = $this->getParameterValue('list.hide', array());171 $hs = $this->getParameterValue('list.hide', array()); 172 172 // $columns = $this->getColumns('list.display'); 173 173 … … 178 178 179 179 $pk = $relatedClasses['pk']->getName(); 180 $listDisplay = array(array('name' => $ pk, 'mapping' =>$pk));180 $listDisplay = array(array('name' => $class.'_'.$pk, 'mapping' => $class.'_'.$pk)); 181 181 182 182 // iterate through all requested columns of current class … … 191 191 <?php 192 192 // add colum to array 193 $listDisplay[] = array('name' => $c olumnName, 'mapping' =>$columnName);193 $listDisplay[] = array('name' => $class.'_'.$columnName, 'mapping' => $class.'_'.$columnName); 194 194 ?> 195 195 <?php … … 202 202 <?php endforeach; ?> 203 203 <?php 204 $options = array('id' => $ pk,204 $options = array('id' => $class.'_'.$pk, 205 205 'root' => 'data', 206 206 'totalProperty' => 'totalCount'); … … 214 214 $options = array('url' => $url, 215 215 'reader' => $jsReader, 216 'sortInfo' => array('field' => $c olumnName, 'direction' => 'asc'),216 'sortInfo' => array('field' => $class.'_'.$columnName, 'direction' => 'asc'), 217 217 'remoteSort' => 'true'); 218 218 $jsDataStore = extjs_data_store($options); … … 221 221 // disabled 222 222 // <?php echo strtolower($class) ?>_ds.load({params:{start:0, limit:10000}}); // TODO: do I need to say more, this is a hack to preload everything, which probably isn't desired... (but when something isn't there, but it is requested by the renderer with its ID javascript breaks. Requesting the id would be ideal, but because it runs in a seperate thread I don't know how yet... 223 224 function <?php echo strtolower($class) ?>_ds_add_preloaded_from_index(index, value) { 225 <?php 226 $fields = $listDisplay; 227 ?> 228 229 var Record = Ext.data.Record.create(<?php echo _extjs_property_encode($fields) ?>); 230 231 var r = new Record({ 232 <?php echo $class.'_'.$pk ?>: value 233 <?php 234 $hs = $this->getParameterValue('list.hide', array()); 235 236 // iterate through all requested columns of current class 237 foreach ($relatedClasses['columns'] as $relatedColumn => $column): 238 $columnName = $column->getName(); 239 240 $credentials = $this->getParameterValue('list.fields.'.$columnName.'.credentials'); 241 ?> 242 <?php if ($credentials): $credentials = str_replace("\n", ' ', var_export($credentials, true)) ?> 243 [?php if ($sf_user->hasCredential(<?php echo $credentials ?>)): ?] 244 <?php endif; ?> 245 <?php echo ", ".$class.'_'.$columnName ?>: ds.getAt(index).get('<?php echo $class.'_'.$columnName ?>') 246 <?php 247 //don't add it twice 248 $hs[] = $column->getName(); 249 ?> 250 <?php if ($credentials): ?> 251 [?php endif; ?] 252 <?php endif; ?> 253 <?php endforeach; ?> 254 }); 255 256 <?php echo strtolower($class) ?>_ds.add(r); 257 } 258 259 223 260 224 261 <?php endforeach; ?> … … 288 325 if ($column->isPrimaryKey()) continue; 289 326 if ($column->isForeignKey()) continue; 290 // OBSOLETE, ForeignKeyIDs 291 // if ($column->isForeignKey()) 292 // { 293 // $relatedClassName = $this->getRelatedClassName($column); 294 // $relatedColumn = 'name'; // TODO: This can be a default, but you should be able to set it. 295 // $name = $column->getName(); 296 // } 327 297 328 // or are we looking for it? Columns defined as 'table/field' 298 329 if (false !== strpos($column->getName(), '/')) 299 330 { 300 331 list($relatedClassName, $relatedColumn) = explode('/', $column->getName()); 301 $key = $ completeColumns['related'][$relatedClassName]['pk']->getName(); // removed $relatedClassName.'_'.332 $key = $relatedClassName."_".$completeColumns['related'][$relatedClassName]['pk']->getName(); // removed $relatedClassName.'_'. 302 333 } 303 334 else … … 323 354 // if value in foreign datastore, return this value 324 355 if (<?php echo $foreign_ds ?>.getById(value)) { 325 return <?php echo $foreign_ds ?>.getById(value).get('<?php echo $ name ?>');356 return <?php echo $foreign_ds ?>.getById(value).get('<?php echo $relatedClassName."_".$name ?>'); 326 357 // if not in foreign datastore, test if it is preloaded (this can be out-dated therefor do it after checking datastore) 327 358 } else if ((index = ds.find('<?php echo $key ?>', value)) != -1) { 328 // foreign-ID not known in foreign-store yet, add preloaded data to the main-store 329 // TODO: this should be done in a new function which is called when onLoad of the main-store is fired, for all foreign-columns (currently it works for only the first column of the foreign-table 330 var Record = Ext.data.Record.create([ 331 {name: '<?php echo $key ?>', mapping: 1}, 332 {name: '<?php echo $name ?>', mapping: 2} 333 ]); 334 335 var r = new Record({ 336 <?php echo $key ?>: value, 337 <?php echo $name ?>: ds.getAt(index).get('<?php echo $column->getName() ?>') 338 }); 339 340 <?php echo $foreign_ds ?>.add(r); 341 342 return ds.getAt(index).get('<?php echo $column->getName() ?>'); 359 // foreign-ID not known in foreign-store yet, add preloaded data from the main-store 360 <?php echo $foreign_ds ?>_add_preloaded_from_index(index, value); 361 362 return ds.getAt(index).get('<?php echo $relatedClassName.'_'.$name ?>'); 343 363 } else { 344 364 //TODO if value still not found the foreign-data-store should get it from the server! (but I don't think this will be necesarry occur) … … 374 394 { 375 395 list($relatedClassName, $relatedColumn) = explode('/', $column->getName()); 376 $dataIndex = $ completeColumns['related'][$relatedClassName]['pk']->getName();396 $dataIndex = $relatedClassName."_".$completeColumns['related'][$relatedClassName]['pk']->getName(); 377 397 } 378 398 else 379 399 { 380 $dataIndex = $column->getName();400 $dataIndex = strtolower($this->getClassName())."_".$column->getName(); 381 401 } 382 402 … … 451 471 list($relatedClassName, $relatedColumn) = explode('/', $column->getName()); 452 472 453 $valueField = $ completeColumns['related'][$relatedClassName]['pk']->getName();473 $valueField = $relatedClassName."_".$completeColumns['related'][$relatedClassName]['pk']->getName(); 454 474 $options = array('valueField' => $valueField); 455 475 } plugins/sfExtjsThemePlugin/lib/helper/ExtjsHelper.php
r5783 r5854 37 37 function extjs_form_combobox($options) 38 38 { 39 $defaultOptions = array('displayField' => ' name',39 $defaultOptions = array('displayField' => 'REQUIRED', 40 40 'triggerAction' => 'all', 41 41 'typeAhead' => true, … … 44 44 'pageSize' => 15, 45 45 'lazyRender' => true, 46 'queryParam' => 'filters[ name]',46 'queryParam' => 'filters[REQUIRED]', 47 47 'listClass' => 'x-combo-list-small'); 48 48 plugins/sfExtjsThemePlugin/lib/sfExtjsPropelAdminGenerator.php
r5793 r5854 189 189 return $getter; 190 190 } 191 191 192 192 /** 193 193 * Process the column name to check for foreign model peer classes … … 318 318 'name' => strtolower($relatedClassPhpName).'_'.$relatedColumn.'_combo', 319 319 'valueField' => $options['valueField'], 320 'displayField' => $relatedC olumn,321 'queryParam' => 'filters['.$relatedC olumn.']',320 'displayField' => $relatedClassName."_".$relatedColumn, 321 'queryParam' => 'filters['.$relatedClassName."_".$relatedColumn.']', 322 322 'store' => strtolower($relatedClassPhpName).'_ds' 323 323 );