Author: KRavEN
Date: 2010-05-24 20:22:49 +0200 (Mon, 24 May 2010)
New Revision: 29609
Added:
plugins/ExtjsGeneratorPlugin/trunk/data/generator/ExtjsModule/admin/parts/comboAction.php
plugins/ExtjsGeneratorPlugin/trunk/data/generator/ExtjsModule/admin/template/templates/comboSuccess.json.php
Modified:
plugins/ExtjsGeneratorPlugin/trunk/TODO.txt
plugins/ExtjsGeneratorPlugin/trunk/data/generator/ExtjsModule/admin/parts/fieldsConfiguration.php
plugins/ExtjsGeneratorPlugin/trunk/data/generator/ExtjsModule/admin/parts/formpanelAction.php
plugins/ExtjsGeneratorPlugin/trunk/data/generator/ExtjsModule/admin/skeleton/config/generator.yml
plugins/ExtjsGeneratorPlugin/trunk/data/generator/ExtjsModule/admin/template/actions/actions.class.php
plugins/ExtjsGeneratorPlugin/trunk/data/generator/ExtjsModule/admin/template/templates/_formpanel.js.php
plugins/ExtjsGeneratorPlugin/trunk/lib/widget/ExtjsWidgetFormChoice.class.php
plugins/ExtjsGeneratorPlugin/trunk/lib/widget/ExtjsWidgetFormChoiceBase.class.php
plugins/ExtjsGeneratorPlugin/trunk/lib/widget/ExtjsWidgetFormPropelChoice.class.php
plugins/ExtjsGeneratorPlugin/trunk/lib/widget/ExtjsWidgetFormSelect.class.php
Log:
added support for widgetOptions to formPanel. remote combobox loading added
(WIP). added hide config option to filter and form.
Modified: plugins/ExtjsGeneratorPlugin/trunk/TODO.txt
===================================================================
--- plugins/ExtjsGeneratorPlugin/trunk/TODO.txt 2010-05-24 16:39:39 UTC (rev
29608)
+++ plugins/ExtjsGeneratorPlugin/trunk/TODO.txt 2010-05-24 18:22:49 UTC (rev
29609)
@@ -1,3 +1,6 @@
+###routing
+generated route prefix in generator not set correctly
+
### forms
show combobox for related fields (field is not always added)
- this is a problem with the standard generator too
@@ -12,6 +15,7 @@
foreign columns should show __toString() output in list
foreign columns should be clickable to open an adminstration for that foreign
table if one exists
auto add ^object_actions as last column if object_actions are enabled
+need to escape single quotes in labels for columnmodel
### filter
move is_empty checkbox for filter to an Ext.ux extension
@@ -22,7 +26,6 @@
### generic
add time display for datetime fields to list, filter, and edit
find alternate way to do filterpanel without eval, needs it now to get filter
values from user session
-fix widgetOptions for the itemselector for many to many in formpanels
use heredoc in ExtjsGenerator for getStandardPartials,
createStandardConstructorPartial, createStandardInitComponentPartial,
createStandardInitEventsPartial methods
expand generated partials with examples
add support for objects with multiple fields as primary key
@@ -31,13 +34,20 @@
backport changes in sfPropel15Plugin admin15 to forms, filters, widgets, and
routing
+###remote combos (WIP set attributes.mode.remote to test )
+filterpanel support
+displays the value instead of display field when no combo store is loaded
+type ahead filtering not implemented
+no return limit
+support for query_method options not implemented
+non-foreign fields distint or grouping not implemented
+
### defered
add ext components not lazy loaded list to app.yml
add a way to disable bottombar
grid editing
grid row expander
grid grouping
-remote json combos
remote json itemselector
use sfGrid (once it is ready)
Added:
plugins/ExtjsGeneratorPlugin/trunk/data/generator/ExtjsModule/admin/parts/comboAction.php
===================================================================
---
plugins/ExtjsGeneratorPlugin/trunk/data/generator/ExtjsModule/admin/parts/comboAction.php
(rev 0)
+++
plugins/ExtjsGeneratorPlugin/trunk/data/generator/ExtjsModule/admin/parts/comboAction.php
2010-05-24 18:22:49 UTC (rev 29609)
@@ -0,0 +1,28 @@
+ public function executeCombo(sfWebRequest $request)
+ {
+ sfConfig::set('sf_escaping_strategy', false);
+ $request->setRequestFormat('json');
+ $this->forward404Unless($request->getParameter('model'));
+
+ $widget = new ExtjsWidgetFormPropelChoice(array(
+ 'model' => $request->getParameter('model'),
+ 'method' => $request->getParameter('method', '__toString'),
+ 'key_method' => $request->getParameter('key_method', 'getPrimaryKey'),
+ 'order_by' => $request->getParameter('order_by', null),
+ //'query_methods' => json_decode($request->getParameter('query_methods',
array())),
+ //'criteria' => $request->getParameter('criteria', null),
+ //'connection' => $request->getParameter('connection', null),
+ //'multiple' => $request->getParameter('multiple', false),
+ ));
+
+ $options = array();
+ foreach ($widget->getChoices() as $key => $option)
+ {
+ $options[] = array('value' => $key, 'display' => $option);
+ }
+
+ $this->jsonStr = json_encode(array(
+ 'totalCount' => count($options),
+ 'data' => $options
+ ));
+ }
\ No newline at end of file
Modified:
plugins/ExtjsGeneratorPlugin/trunk/data/generator/ExtjsModule/admin/parts/fieldsConfiguration.php
===================================================================
---
plugins/ExtjsGeneratorPlugin/trunk/data/generator/ExtjsModule/admin/parts/fieldsConfiguration.php
2010-05-24 16:39:39 UTC (rev 29608)
+++
plugins/ExtjsGeneratorPlugin/trunk/data/generator/ExtjsModule/admin/parts/fieldsConfiguration.php
2010-05-24 18:22:49 UTC (rev 29609)
@@ -58,19 +58,7 @@
return '<?php echo $this->escapeString($title) ?>';
<?php unset($this->config['new']['title']) ?>
}
-
- public function getFilterDisplay()
- {
- return <?php echo $this->asPhp(isset($this->config['filter']['display']) ?
$this->config['filter']['display'] : array()) ?>;
-<?php unset($this->config['filter']['display']) ?>
- }
-
- public function getFormDisplay()
- {
- return <?php echo $this->asPhp(isset($this->config['form']['display']) ?
$this->config['form']['display'] : array()) ?>;
-<?php unset($this->config['form']['display']) ?>
- }
-
+
public function getEditDisplay()
{
return <?php echo $this->asPhp(isset($this->config['edit']['display']) ?
$this->config['edit']['display'] : array()) ?>;
@@ -83,18 +71,20 @@
<?php unset($this->config['new']['display']) ?>
}
- public function getListDisplay()
+<?php foreach (array('list', 'filter', 'form') as $context): ?>
+ public function get<?php echo ucfirst($context) ?>Display()
{
-<?php if (isset($this->config['list']['display'])): ?>
- return <?php echo $this->asPhp($this->config['list']['display']) ?>;
-<?php elseif (isset($this->config['list']['hide'])): ?>
- return <?php echo $this->asPhp(array_diff($this->getAllFieldNames(false),
$this->config['list']['hide'])) ?>;
+<?php if (isset($this->config[$context]['display'])): ?>
+ return <?php echo $this->asPhp($this->config[$context]['display']) ?>;
+<?php elseif (isset($this->config[$context]['hide'])): ?>
+ return <?php echo $this->asPhp(array_diff($this->getAllFieldNames(false),
$this->config[$context]['hide'])) ?>;
<?php else: ?>
return <?php echo $this->asPhp($this->getAllFieldNames(false)) ?>;
<?php endif; ?>
-<?php unset($this->config['list']['display'], $this->config['list']['hide']) ?>
+<?php unset($this->config[$context]['display'],
$this->config[$context]['hide']) ?>
}
+<?php endforeach; ?>
public function getFieldsDefault()
{
return array(
Modified:
plugins/ExtjsGeneratorPlugin/trunk/data/generator/ExtjsModule/admin/parts/formpanelAction.php
===================================================================
---
plugins/ExtjsGeneratorPlugin/trunk/data/generator/ExtjsModule/admin/parts/formpanelAction.php
2010-05-24 16:39:39 UTC (rev 29608)
+++
plugins/ExtjsGeneratorPlugin/trunk/data/generator/ExtjsModule/admin/parts/formpanelAction.php
2010-05-24 18:22:49 UTC (rev 29609)
@@ -3,4 +3,5 @@
//$this-><?php echo $this->getSingularName() ?> =
$this->getRoute()->getObject($this->configuration->getQueryMethods());
$this->form = $this->configuration->getForm();
sfConfig::set('sf_escaping_strategy', false);
+<?php echo $this->getFormCustomization('form') ?>
}
Modified:
plugins/ExtjsGeneratorPlugin/trunk/data/generator/ExtjsModule/admin/skeleton/config/generator.yml
===================================================================
---
plugins/ExtjsGeneratorPlugin/trunk/data/generator/ExtjsModule/admin/skeleton/config/generator.yml
2010-05-24 16:39:39 UTC (rev 29608)
+++
plugins/ExtjsGeneratorPlugin/trunk/data/generator/ExtjsModule/admin/skeleton/config/generator.yml
2010-05-24 18:22:49 UTC (rev 29609)
@@ -1,5 +1,5 @@
generator:
- class: ExtjsGenerator
+ class: ExtjsGenerator
param:
##CONFIG##
Modified:
plugins/ExtjsGeneratorPlugin/trunk/data/generator/ExtjsModule/admin/template/actions/actions.class.php
===================================================================
---
plugins/ExtjsGeneratorPlugin/trunk/data/generator/ExtjsModule/admin/template/actions/actions.class.php
2010-05-24 16:39:39 UTC (rev 29608)
+++
plugins/ExtjsGeneratorPlugin/trunk/data/generator/ExtjsModule/admin/template/actions/actions.class.php
2010-05-24 18:22:49 UTC (rev 29609)
@@ -26,6 +26,8 @@
$this->helper = new <?php echo $this->getModuleName() ?>GeneratorHelper();
}
+
+<?php include dirname(__FILE__).'/../../parts/comboAction.php' ?>
<?php include dirname(__FILE__).'/../../parts/indexAction.php' ?>
Modified:
plugins/ExtjsGeneratorPlugin/trunk/data/generator/ExtjsModule/admin/template/templates/_formpanel.js.php
===================================================================
---
plugins/ExtjsGeneratorPlugin/trunk/data/generator/ExtjsModule/admin/template/templates/_formpanel.js.php
2010-05-24 16:39:39 UTC (rev 29608)
+++
plugins/ExtjsGeneratorPlugin/trunk/data/generator/ExtjsModule/admin/template/templates/_formpanel.js.php
2010-05-24 18:22:49 UTC (rev 29609)
@@ -43,8 +43,10 @@
$readerFields = array();
$fieldItems = array();
<?php
-$form = $this->configuration->getForm();
+$this->form = $this->configuration->getForm();
+eval($this->getFormCustomization('form'));
+$form = $this->form;
foreach ($this->configuration->getFormFields($form, $form->isNew() ? 'new' :
'edit') as $fieldset => $fields):
$fieldItems = array();
foreach ($fields as $name => $field)
@@ -55,7 +57,10 @@
'help' => $field->getConfig('help'),
'fieldLabel' => $field->getConfig('label',
$form[$name]->getParent()->getWidget()->getFormFormatter()->generateLabelName($name)),
);
- echo $this->addCredentialCondition(sprintf("%s;\n\n",
$form[$name]->render(array_merge($attributes, $field->getConfig('attributes',
array())))), $field->getConfig());
+
+ $fieldAttributes = $field->getConfig('attributes', array());
+ if(isset($fieldAttributes['mode']) && $fieldAttributes['mode'] ==
'remote') $attributes['url'] = $this->getModuleName().'/combo.json';
+ echo $this->addCredentialCondition(sprintf("%s;\n\n",
$form[$name]->render(array_merge($attributes, $fieldAttributes))),
$field->getConfig());
}
if($fieldset == 'NONE'): ?>
Added:
plugins/ExtjsGeneratorPlugin/trunk/data/generator/ExtjsModule/admin/template/templates/comboSuccess.json.php
===================================================================
---
plugins/ExtjsGeneratorPlugin/trunk/data/generator/ExtjsModule/admin/template/templates/comboSuccess.json.php
(rev 0)
+++
plugins/ExtjsGeneratorPlugin/trunk/data/generator/ExtjsModule/admin/template/templates/comboSuccess.json.php
2010-05-24 18:22:49 UTC (rev 29609)
@@ -0,0 +1 @@
+[?php echo $jsonStr; ?]
\ No newline at end of file
Modified:
plugins/ExtjsGeneratorPlugin/trunk/lib/widget/ExtjsWidgetFormChoice.class.php
===================================================================
---
plugins/ExtjsGeneratorPlugin/trunk/lib/widget/ExtjsWidgetFormChoice.class.php
2010-05-24 16:39:39 UTC (rev 29608)
+++
plugins/ExtjsGeneratorPlugin/trunk/lib/widget/ExtjsWidgetFormChoice.class.php
2010-05-24 18:22:49 UTC (rev 29609)
@@ -98,6 +98,12 @@
$class = sprintf('ExtjsWidgetFormSelect%s', ucfirst($type));
}
- return new $class(array_merge(array('defaultValue' =>
$this->getOption('defaultValue'), 'allowClear' =>
$this->getOption('allowClear'), 'context' => $this->getOption('context'),
'choices' => new sfCallable(array($this, 'getChoices'))),
$this->options['renderer_options']), $this->getAttributes());
+ return new $class(array_merge(array(
+ 'defaultValue' => $this->getOption('defaultValue'),
+ 'allowClear' => $this->getOption('allowClear'),
+ 'context' => $this->getOption('context'),
+ 'choices' => new sfCallable(array($this, 'getChoices')),
+ 'baseParams' => new sfCallable(array($this, 'getBaseParams')))
+ , $this->options['renderer_options']), $this->getAttributes());
}
}
Modified:
plugins/ExtjsGeneratorPlugin/trunk/lib/widget/ExtjsWidgetFormChoiceBase.class.php
===================================================================
---
plugins/ExtjsGeneratorPlugin/trunk/lib/widget/ExtjsWidgetFormChoiceBase.class.php
2010-05-24 16:39:39 UTC (rev 29608)
+++
plugins/ExtjsGeneratorPlugin/trunk/lib/widget/ExtjsWidgetFormChoiceBase.class.php
2010-05-24 18:22:49 UTC (rev 29609)
@@ -33,6 +33,7 @@
protected function configure($options = array(), $attributes = array())
{
$this->addRequiredOption('choices');
+ $this->addOption('baseParams');
}
/**
@@ -64,7 +65,17 @@
return $results;
}
+
+ public function getBaseParams()
+ {
+ $baseParams = $this->getOption('baseParams');
+ if ($baseParams instanceof sfCallable)
+ {
+ return $baseParams->call();
+ }
+ }
+
/**
* Clones this object
*/
Modified:
plugins/ExtjsGeneratorPlugin/trunk/lib/widget/ExtjsWidgetFormPropelChoice.class.php
===================================================================
---
plugins/ExtjsGeneratorPlugin/trunk/lib/widget/ExtjsWidgetFormPropelChoice.class.php
2010-05-24 16:39:39 UTC (rev 29608)
+++
plugins/ExtjsGeneratorPlugin/trunk/lib/widget/ExtjsWidgetFormPropelChoice.class.php
2010-05-24 18:22:49 UTC (rev 29609)
@@ -18,13 +18,14 @@
*/
class ExtjsWidgetFormPropelChoice extends ExtjsWidgetFormChoice
{
+
/**
* @see sfWidget
*/
public function __construct($options = array(), $attributes = array())
{
$options['choices'] = array();
-
+
parent::__construct($options, $attributes);
}
@@ -33,18 +34,20 @@
*
* Available options:
*
- * * model: The model class (required)
- * * add_empty: Whether to add a first empty value or not (false by
default)
- * If the option is not a Boolean, the value will be used as
the text value
- * * method: The method to use to display object values (__toString by
default)
- * * key_method: The method to use to display the object keys
(getPrimaryKey by default)
- * * order_by: An array composed of two fields:
- * * The column to order by the results (must be in the
PhpName format)
- * * asc or desc
- * * criteria: A criteria to use when retrieving objects
- * * connection: The Propel connection to use (null by default)
- * * multiple: true if the select tag must allow multiple selections
- * * peer_method: The peer method to use to fetch objects
+ * * model: The model class (required)
+ * * add_empty: Whether to add a first empty value or not (false by
default)
+ * If the option is not a Boolean, the value will be used as the text value
+ * * method: The method to use to display object values (__toString by
default)
+ * * key_method: The method to use to display the object keys
(getPrimaryKey by default)
+ * * order_by: An array composed of two fields:
+ * * The column to order by the results (must be in the PhpName format)
+ * * asc or desc
+ * * query_methods: An array of method names listing the methods to execute
+ * on the model's query object
+ * * criteria: A criteria to use when retrieving objects
+ * * connection: The Propel connection to use (null by default)
+ * * multiple: true if the select tag must allow multiple selections
+ * * peer_method: ignored - only supported for BC purpose
*
* @see sfWidgetFormSelect
*/
@@ -55,14 +58,30 @@
$this->addOption('method', '__toString');
$this->addOption('key_method', 'getPrimaryKey');
$this->addOption('order_by', null);
+ $this->addOption('query_methods', array());
$this->addOption('criteria', null);
$this->addOption('connection', null);
$this->addOption('multiple', false);
+ // not used anymore
$this->addOption('peer_method', 'doSelect');
-
+
parent::configure($options, $attributes);
}
+ public function getBaseParams()
+ {
+ return array(
+ 'model' => $this->getOption('model'),
+ 'method' => $this->getOption('method'),
+ 'key_method' => $this->getOption('key_method'),
+ 'order_by' => $this->getOption('order_by'),
+ 'query_methods' => $this->getOption('query_methods'),
+ 'criteria' => $this->getOption('criteria'),
+ 'connection' => $this->getOption('connection'),
+ 'multiple' => $this->getOption('multiple')
+ );
+ }
+
/**
* Returns the choices associated to the model.
*
@@ -71,38 +90,43 @@
public function getChoices()
{
$choices = array();
- if (false !== $this->getOption('add_empty'))
+ if(false !== $this->getOption('add_empty'))
{
$choices[''] = true === $this->getOption('add_empty') ? '' :
$this->getOption('add_empty');
}
-
- $class = constant($this->getOption('model').'::PEER');
-
- $criteria = null === $this->getOption('criteria') ? new Criteria() : clone
$this->getOption('criteria');
- if ($order = $this->getOption('order_by'))
+
+ $criteria = PropelQuery::from($this->getOption('model'));
+ if($this->getOption('criteria'))
{
- $method = sprintf('add%sOrderByColumn', 0 ===
strpos(strtoupper($order[1]), 'ASC') ? 'Ascending' : 'Descending');
- $criteria->$method(call_user_func(array($class, 'translateFieldName'),
$order[0], BasePeer::TYPE_PHPNAME, BasePeer::TYPE_COLNAME));
+ $criteria->mergeWith($this->getOption('criteria'));
}
- $objects = call_user_func(array($class, $this->getOption('peer_method')),
$criteria, $this->getOption('connection'));
-
+ foreach($this->getOption('query_methods') as $method)
+ {
+ $criteria->$method();
+ }
+ if($order = $this->getOption('order_by'))
+ {
+ $criteria->orderBy($order[0], $order[1]);
+ }
+ $objects = $criteria->find($this->getOption('connection'));
+
$methodKey = $this->getOption('key_method');
- if (!method_exists($this->getOption('model'), $methodKey))
+ if(! method_exists($this->getOption('model'), $methodKey))
{
throw new RuntimeException(sprintf('Class "%s" must implement a "%s"
method to be rendered in a "%s" widget', $this->getOption('model'), $methodKey,
__CLASS__));
}
-
+
$methodValue = $this->getOption('method');
- if (!method_exists($this->getOption('model'), $methodValue))
+ if(! method_exists($this->getOption('model'), $methodValue))
{
throw new RuntimeException(sprintf('Class "%s" must implement a "%s"
method to be rendered in a "%s" widget', $this->getOption('model'),
$methodValue, __CLASS__));
}
-
- foreach ($objects as $object)
+
+ foreach($objects as $object)
{
$choices[$object->$methodKey()] = $object->$methodValue();
}
-
+
return $choices;
}
}
Modified:
plugins/ExtjsGeneratorPlugin/trunk/lib/widget/ExtjsWidgetFormSelect.class.php
===================================================================
---
plugins/ExtjsGeneratorPlugin/trunk/lib/widget/ExtjsWidgetFormSelect.class.php
2010-05-24 16:39:39 UTC (rev 29608)
+++
plugins/ExtjsGeneratorPlugin/trunk/lib/widget/ExtjsWidgetFormSelect.class.php
2010-05-24 18:22:49 UTC (rev 29609)
@@ -89,14 +89,31 @@
}
else
{
+ if(isset($attributes['mode']) && $attributes['mode'] == 'remote')
+ {
+ $store = array(
+ 'xtype' => 'jsonstore',
+ 'fields' => array('value', 'display'),
+ 'root' => 'data',
+ 'url' => $attributes['url'],
+ 'baseParams' => $this->getBaseParams(),
+ );
+ unset($attributes['url']);
+ }
+ else
+ {
+ $attributes['mode'] = 'local';
+ $store = array(
+ 'xtype' => 'arraystore',
+ 'fields' => array('value', 'display'),
+ 'data' => $this->getOptionsForSelect($value, $choices),
+ );
+ }
+
$configArr = array(
'hiddenName' => $name,
'name' => $name,
- 'store' => array(
- 'xtype' => 'arraystore',
- 'fields' => array('value', 'display'),
- 'data' => $this->getOptionsForSelect($value, $choices),
- ),
+ 'store' => $store,
'allowClear' => $this->getOption('allowClear'),
'defaultValue' => $this->getOption('defaultValue'),
'valueField' => 'value',
@@ -105,7 +122,7 @@
'typeAhead' => false,
'value' => (string)$value,
'triggerAction' => 'all',
- 'mode' => 'local',
+ 'mode' => $attributes['mode'],
);
}
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.