Home » support » General discussion » Building Own Generator ( ) 7 Vote(s)
| | | | | |
| Re: Building Own Generator [message #55437 is a reply to message #24107 ] |
Thu, 03 July 2008 19:25   |
saganxis Messages: 24 Registered: February 2008 Location: Argentina |
Junior Member |
|
|
Hi to all. This post maybe is more realted with the Extjs2Plugin than Extjs2ThemePlugin, but i know you know about how to use this plugin.
I'm using sF 1.1 so i installed the Extjs2Plugin(i don't know how to make Extjs2ThemePlugin to work in 1.1). I did some chages to
the code in this post: http://www.symfony-project.org/forum/index.php/t/12399/.
I wanted to add the TreePanel control, so i modified the /plugins/sfExtjs2Plugin/config/config.php file and add some lines in the
"mapping plugin method against class" section.
I added this lines:
'KeyMap' => 'Ext.KeyMap',
'TreePanel' => 'Ext.tree.TreePanel',
'Observable' => 'Ext.util.Observable',
'TreeLoader' => 'Ext.tree.TreeLoader',
'Node' => 'Ext.data.Node',
'TreeNode' => 'Ext.tree.TreeNode',
'AsyncTreeNode' => 'Ext.tree.AsyncTreeNode'
and then the "sfConfig::set" for each class.
Well, in the layout.php i added this Panel:
$sfExtjs2Plugin->Panel(array
(
'id'=>'tonyWp',
'region'=>'west',
'title'=>'Menú Principal',
'margins'=>'0 0 0 5',
'cmargins'=>'0 0 0 0',
'width'=>'200',
'minSize'=>'100',
'maxSize'=>'300',
'split'=>'true',
'collapsible'=>'true',
'items' => array(
$sfExtjs2Plugin->TreePanel(array(
'id'=> 'tree-panel',
'title'=> 'Sample Layouts',
'region'=>'north',
'split'=> true,
'height'=> 300,
'root'=> $sfExtjs2Plugin->TreeNode(array(
'draggable'=>false,
'text'=>'the root',
'expanded'=> true,
))
))
)
))
So the root element appear. But i don't know how to build the tree childrens...
I probed adding:
'loader' => $sfExtjs2Plugin->TreeLoader(array(
'dataUrl'=> 'tree-data.json', //this is the url that will return the JSON string
'requestMethod'=> 'GET' //you can configure POST as well, depends on your script that is waiting on the above url
))
to the previous TreePanel and i put the tree-data.json file in the web dir.
I want something sinilar to this:
http://extjs.com/deploy/dev/examples/layout-browser/layout-b rowser.html
i tryed this too:
http://cappelleh-java.blogspot.com/2008/06/exttreetreepanel- examples-explained.html
Do you know how can i make this work??????
|
|
| |
| Re: Building Own Generator [message #55443 is a reply to message #24107 ] |
Thu, 03 July 2008 21:03   |
saganxis Messages: 24 Registered: February 2008 Location: Argentina |
Junior Member |
|
|
Thanks for the response!!
I tested again but with some changes. the final code in the layout is:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<?php include_http_metas() ?>
<?php include_metas() ?>
<?php include_title() ?>
<link rel="shortcut icon" href="/favicon.ico" />
</head>
<body>
<?php
$tab1info = "test";
$help = "Alguna ayuda";
$sfExtjs2Plugin = new sfExtjs2Plugin(array('theme'=>'aero'));
$sfExtjs2Plugin->load();
$sfExtjs2Plugin->begin();
// **************************************
// Application
// **************************************
/*'loader' => $sfExtjs2Plugin->TreeLoader(array(
'dataUrl'=>'http://uvqapp11.dev/js/tree-data.json',
'requestMethod' => 'GET'
))*/
$sfExtjs2Plugin_App_viewport = $sfExtjs2Plugin->Viewport(array
(
'layout' => 'border', 'items' => array
(
$sfExtjs2Plugin->Panel(array
(
'id'=>'tonyNp',
'region'=>'north',
'height'=>'auto',
'title'=>' ',
'html'=> image_tag('logouvq'),
'split'=>'true',
'collapsible'=>'true'
)),
$sfExtjs2Plugin->Panel(array
(
'id'=>'tonyWp',
'region'=>'west',
'title'=>'Menú Principal',
'margins'=>'0 0 0 5',
'cmargins'=>'0 0 0 0',
'width'=>'200',
'minSize'=>'100',
'maxSize'=>'300',
'split'=>'true',
'collapsible'=>'true',
'items' => array(
$sfExtjs2Plugin->TreePanel(array(
'id'=> 'tree-panel',
'title'=> 'Sample Layouts',
'region'=>'north',
'split'=> true,
'height'=> 300,
'rootVisible'=> false,
'loader' => $sfExtjs2Plugin->TreeLoader(array(
'dataUrl'=> 'http://uvqapp11.dev/tree-data.json', //this is the url that will return the JSON string
'requestMethod'=> 'GET' //you can configure POST as well, depends on your script that is waiting on the above url
)),
'root'=> $sfExtjs2Plugin->AsyncTreeNode(array())
))
)
)),
$sfExtjs2Plugin->TabPanel(array
(
'id'=>'tonyCp',
'region'=>'center',
'margins'=>'0 5 0 0',
'items'=>array(
$sfExtjs2Plugin->Panel(array(
'title'=>'Página Principal',
'contentEl' => 'center'
)),
$sfExtjs2Plugin->Panel(array(
'title'=>'Ayuda',
'html'=>$help
))
)
))
)
));
$sfExtjs2Plugin->beginApplication(array
(
'name' => 'App',
'public' => array(
'init' => $sfExtjs2Plugin->asMethod("$sfExtjs2Plugin_App_viewport;"
)
)
));
$sfExtjs2Plugin->endApplication();
$sfExtjs2Plugin->end('Ext.onReady(App.init, App);');
?>
<div id="center" style="padding-left: 20px; padding-top: 20px;">
<?php echo $sf_content ?>
</div>
</body>
</html>
I have to fix the dataUrl param, but this is just a test.
Here is an screenshot of what i wanted to do. Is is simple by now.
Attachment: symfony.png
(Size: 203.06KB, Downloaded 173 time(s))
|
|
|
| Re: Building Own Generator [message #55447 is a reply to message #55443 ] |
Fri, 04 July 2008 00:53   |
 |
lvanderree Messages: 652 Registered: June 2007 Location: Netherlands |
Faithful Member |
|
|
Sorry think I misunderstood your problem. The problem isn't the sfExtjs2Plugin, but the construction of the json-data isn't it?
As said I haven't used the tree-panel myself yet, but the example you gave shows your should construct something like this:
[{
id: 1,
text: 'A leaf Node',
leaf: true
},{
id: 2,
text: 'A folder Node',
children: [{
id: 3,
text: 'A child Node',
leaf: true
}]
}]
I assume you know what you want to construct, but not how to create a json itself.
It probably is the easiest to create an array, and export this as json.
You can see how I do it manually in my actions.class.php for my menu here:
public function executeGetOverview()
{
$filter = $this->getRequestParameter('filter');
$c = new Criteria();
$c->addDescendingOrderByColumn(VoyagePeer::CREATED_AT);
$c->addAscendingOrderByColumn(AssignmentPeer::SUBJECT);
$c->addAscendingOrderByColumn(AssignmentParcelPeer::SUBJECT);
$words = explode(' ', $filter);
//filter on words from search-field
foreach($words as $word)
{
if (strlen($word) > 2)
{
$c1 = $c->getNewCriterion(AssignmentPeer::SUBJECT, '%'.$word.'%', Criteria::LIKE);
$c2 = $c->getNewCriterion(AssignmentParcelPeer::SUBJECT, '%'.$word.'%', Criteria::LIKE);
$c3 = $c->getNewCriterion(ClientCompanyPeer::NAME, '%'.$word.'%', Criteria::LIKE);
$c4 = $c->getNewCriterion(BerthPeer::NAME, '%'.$word.'%', Criteria::LIKE);
$c5 = $c->getNewCriterion(VesselPeer::NAME, '%'.$word.'%', Criteria::LIKE);
$c6 = $c->getNewCriterion(CityPeer::NAME, '%'.$word.'%', Criteria::LIKE);
$c1->addOr($c2);
$c1->addOr($c3);
$c1->addOr($c4);
$c1->addOr($c5);
$c1->addOr($c6);
$c->add($c1);
}
}
$this->overview = AssignmentParcelPeer::doSelectLeftJoinAssignment($c);
$results = array();
foreach ($this->overview as $result)
{
$assignment = $result->getAssignment();
$voyage = $assignment->getVoyage();
$results[] = array(
'voyage_id' => $voyage->getVoyageId(),
'voyage_title' => $voyage->getTitle(),
'assignment_id' => $assignment->getAssignmentId(),
'assignment_subject' => $assignment->getSubject(),
'assignment_parcel_id' => $result->getAssignmentParcelId(),
'assignment_parcel_subject' => $result->getSubject(),
);
}
// $this->getResponse()->setHttpHeader('X-JSON');
sfConfig::set('sf_web_debug', false);
return $this->renderText(json_encode($results));
}
I fill an array called $results, and transform this into json with json_encode.
Hope this can help.
Leon
|
|
| | | | | |
| Re: Building Own Generator [message #55704 is a reply to message #24107 ] |
Tue, 08 July 2008 10:14   |
snk00sj Messages: 71 Registered: July 2006 |
Member |
|
|
thx for the tip about clearing cookies for sorting columns, i'll make sure to add that to the wiki 'troubleshooting' part.
I am looking for the best way to integrate the extjs grid in my application. I don't want the grid to show 100% (taking up the entire page) but i'd like it fit in in my current layout.php
What would be the best approach to reach this goal ?
Digital Base Webagency
|
|
|
| Re: Building Own Generator [message #55707 is a reply to message #55704 ] |
Tue, 08 July 2008 10:54   |
 |
lvanderree Messages: 652 Registered: June 2007 Location: Netherlands |
Faithful Member |
|
|
The grid is placed in a panel, so all you have to do is use the panel as an item in your layout.
I use a grid as a formField, which requires setting some more config-options, but looks pretty similar, all you have to do is:
items = [
// a normal field
{
name: 'voyage[eta_text]',
fieldLabel: 'Overrule with text',
labelSeparator: ':',
qtip: 'text here will override latest ETA',
width: 200,
xtype: 'textfield',
allowBlank: true
},
// a grid as a field
{
name: 'voyage[voyage_id]',
fieldLabel: 'Latest ETA\'s',
xtype: 'listetagridpanel',
filter: 'voyage-voyage_id',
filter_key: this.key,
// hideHeaders: false,
enableColumnResize: false,
enableColumnHide: false,
enableColumnMove: false,
enableDragDrop: false,
enableHdMenu: false,
width: 150,
isFormField : true,
border: true,
bodyBorder: true,
fieldClass : "x-form-field"
},
]
For the result see http://tejohnston.dynora.eu/index.php/voyage/edit/voyage_id/ 1 (admin:admin, after login: reload to get the requested page) See tab-page ETA.
Also I prefer to use xtypes, instead of its direct constructor, but thats up to you, you can also call new ListModuleGridPanel({..options here..});
for an example of my layout.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<?php sfContext::getInstance()->getResponse()->addJavascript('/sfExtjsThemePlugin/js/tiny_mce/tiny_mce', 'first'); ?>
<?php include_partial('global/extIncludePartial') ?>
<?php include_http_metas() ?>
<?php include_metas() ?>
<?php include_title() ?>
<link rel="shortcut icon" href="/favicon.ico" />
</head>
<body>
<?php
$sfExtjs2Plugin = new sfExtjs2Plugin(array('adapter'=>'ext'));
// init login-window
$sfExtjs2Plugin->begin();
?>
// preload login-window
Ext.onReady(function() {Login.init('<?php echo $this->getContext()->getRequest()->getScriptName() ?>');}, Login);
<?php
$sfExtjs2Plugin->end();
// content
echo $sf_data->getRaw('sf_content');
//init app
$sfExtjs2Plugin->begin();
?>
Ext.onReady(function() {App.init('<?php echo $this->getContext()->getRequest()->getScriptName() ?>');}, App);
// not authorized exception
var A = Ext.lib.Ajax;
A.request = A.request.createInterceptor(function(method, uri, cb, data, options) {
if (!A._locked) {
// save the last request arguments
A._lastRequest = Array.prototype.slice.call(arguments, 0);
} else if (options.scope.options && options.scope.options.loggingIn) {
return true; // allow your login only
}
return !A._locked; // cancel all future requests during lockout
}, A);
var sessionTimeoutHandler = function(statusCode, transaction, response, callback, isAbort) {
A._locked = true;
//repeat last query
var withCallBack = function() {
A._locked = false;
A._lastRequest ? A.request.apply(A, A._lastRequest) : null;
A._lastRequest = null;
};
Login.show(withCallBack);
};
A.onStatus([401], sessionTimeoutHandler);
<?php
$sfExtjs2Plugin->end();
?>
<div id="header">
<div id="header_title_div">
<img style="float:left;margin-left:10px;margin-right:10px;" src="/images/logos/tej.gif" alt="T.E. Johnston & Co. Holland b.v." />
<div class="title">T.E. Johnston & Co. (Holland) b.v. Support System</div>
</div>
<div id="header_content"></div>
<div id="menu">
<div id="menu_opened_docs" class="opened docs"></div>
</div>
</div>
</body>
</html>
and the _extIncludePartial
<?php
$js = sfConfig::get('extjs_default_javascripts', array());
$js[] = '/js/app.js';
$js[] = '/js/login.js';
$js[] = '/js/Ext.ux.ContentPanel.js';
$js[] = '/js/Ext.ux.MainMenu.js';
$js[] = '/js/Ext.ux.OverviewPanel.js';
$js[] = '/js/Ext.ux.VoyageEtaPanel.js';
$js[] = '/sfExtjsThemePlugin/js/ext.ux.tinymce/Ext.ux.TinyMCE.min.js';
$sfExtjs2Plugin = new sfExtjs2Plugin(array('theme'=>'gray'),
array('css' => array('/sfExtjsThemePlugin/css/symfony-extjs.css',
'/sfExtjsThemePlugin/css/collapsing-disabled',
'/css/parcel_overview'
),
'js' => $js
));
$sfExtjs2Plugin->load();
all these js includes can be found at:
http://tejohnston.dynora.eu/js/app.js
Leon
|
|
|
| Re: Building Own Generator [message #55732 is a reply to message #55707 ] |
Tue, 08 July 2008 14:27   |
snk00sj Messages: 71 Registered: July 2006 |
Member |
|
|
leon,
tnx for the fast reply.
i have no knowledge at all about ext, so typex/panels are not my cup of tea.
i am using a default admin generated module (list action) with the custom adminexttheme. Now all the sites content is in a wrapping div see : http://www.pastebin.be/12667
I added 'CONTENT SHOULD BE HERE' string
So the default symfony admin generator nicely puts its content where i put
<div class="center">
<?php echo $sf_data->getRaw('sf_content') ?>
</div>
Whenever i use the ext admin theme, it gets replaced by the javascript functionality, causing the js grid to be loaded full page (without respecting my css/div.center guidelines.
So if you could add some info to your previous posts, which file, where to put, i would be happy to try it out, and eventually document it afterwards. I can't find a partial (in the cache) named : extIncludePartial
And i would like not to touch my existing layout php (only if needed). Any thoughts ?
Digital Base Webagency
|
|
| |
| Re: Building Own Generator [message #56025 is a reply to message #55758 ] |
Sat, 12 July 2008 17:37   |
 |
lvanderree Messages: 652 Registered: June 2007 Location: Netherlands |
Faithful Member |
|
|
Partials for the grid are implemented.
It now requires some significant partial code to make things work, this can probably made easier in the future, but for now it works!
First a Demo?
check this out:
http://tejohnston.dynora.eu/voyage/edit/voyage_id/1 (admin:admin)
Refresh the page after login so you see a voyage-edit panel with two tabs. Tab2 contains and ETA-list(grid from the ETA-module, while you are in the edit action of the voyage module), with actions to delete the ETAs. The eta-list filters: showing only eta related to this voyage!
I am aware this demo actually is a form-action, but I implemented it as a partial so you can have the control about in which column you want the partial. In the future I can also implement list.objectactions to make things (a little) backwards compatible.
To see only the eta list you can go this url: http://tejohnston.dynora.eu/eta
which simplifies things a little probably (adding will not work, since the required foreign key voyage_id will be missing this way)
I think you can see this list is highly modified, so please don't be scared because of the number of gridpanel and render partials I also use).
its complete generator is:
generator:
class: sfExtjsPropelAdminGenerator
param:
model_class: Eta
theme: extjs
peer_method: doSelectJoinRelatedForTitle
peer_count_method: doCount
fields:
eta:
params:
menuDisabled: true
editable: false
sortable: false
fixed: true
width: 175
renderer: this.renderDateAdded
gridpanel:
variable:
partials: _gridpanel_headerTpl #partial containing the header to add items
method:
partials: [_gridpanel_syncFields, _gridpanel_addEta, _gridpanel_deleteButton_mouseEvents] #partials containing syncFields (to align the add Eta field), the addEtaField itself and the events to handle mouseEvents for the DeleteButton
renderer:
method:
partials: _renderer_mouseover #partial containing the mouseover tip renderer (above the eta-text)
list:
params:
header: false
bbar: false
tbar: false
display: [eta, _delete, +created_at, +created_by/username]
actions: false
For the delete action I have the list.display[_delete] partial and a gridpanel.method.partial to handle its mouseEvents
The _delete partial contains the layout for the column,
_gridcolumn_delete.php:
<?php
// partials for a delete column :O
?>
new Ext.ux.DeleteColumn()
The Ext.ux.DeleteColumn() is defined in a javascript file:
// namespace: Ext.ux
Ext.namespace('Ext.ux');
Ext.ux.DeleteColumn = function(){
Ext.apply(this, {
width: 22,
header: '<div class="delete-col-hd"></div>',
menuDisabled:true,
fixed: true,
tooltip: 'Click to delete this ETA',
renderer: function(){
return '<div class="delete-td"></div>';
}
});
};
You also need CSS and images to make this work.
And to make the button behave like a button I've added event-handlers like this,
_gridpanel_deleteButton_mouseEvents.php:
<?php
// auto-generated by sfPropelAdmin
// date: 2008/06/11 12:11:36
?>
<?php ob_start() ?>
var index = this.getView().findRowIndex(t);
return this.store.getAt(index);
<?php
$source = ob_get_clean();
// onRender
$configArr = array(
'parameters' => 't',
'source' => $source
);
$gridpanel->attributes['getRecord'] = $sfExtjs2Plugin->asMethod($configArr);
ob_start()
?>
if((e.button==0) && Ext.fly(t).hasClass('delete-td')){
e.stopEvent();
Ext.fly(t).addClass('delete-td-down');
this.activeButtonPressed = t;
}
<?php
$source = ob_get_clean();
// onRender
$configArr = array(
'parameters' => 'e, t',
'source' => $source
);
$gridpanel->attributes['onMouseDown'] = $sfExtjs2Plugin->asMethod($configArr);
ob_start()
?>
if(Ext.fly(t).hasClass('delete-td') && (this.activeButtonPressed == t)){
e.stopEvent();
Ext.fly(t).removeClass('delete-td-down');
var record = this.getRecord(t);
Ext.Msg.confirm('Confirm','Are you sure you want to delete this ETA?',function(btn,text){
if(btn == 'yes'){
var selectArr = [];
Ext.Ajax.request({
url: '<?php echo sfContext::getInstance()->getController()->genUrl('eta'.'/ajaxDelete') ?>',
method: 'POST',
params: {id: Ext.encode(record.data['eta_id'])},
scope: this,
success: function(response){
try { var json_response = Ext.util.JSON.decode(response.responseText); } catch (e) {};
this.store.reload();
//TODO: throw event!
},
failure: function(response){
try { var json_response = Ext.util.JSON.decode(response.responseText); } catch (e) {};
Ext.Msg.alert('Error while deleting', json_response.message);
}
});
}
},this);
}
this.activeButtonPressed = null; // TODO: this should be done globally, if you release the button anywhere, the button is not pressed anymore...
<?php
$source = ob_get_clean();
// onRender
$configArr = array(
'parameters' => 'e, t',
'source' => $source
);
$gridpanel->attributes['onMouseUp'] = $sfExtjs2Plugin->asMethod($configArr);
ob_start()
?>
if(Ext.fly(t).hasClass('delete-td')){
if (this.activeButtonPressed == t) Ext.fly(t).addClass('delete-td-down');
Ext.fly(t.parentNode).addClass('delete-back-over');
}
<?php
$source = ob_get_clean();
// onRender
$configArr = array(
'parameters' => 'e, t',
'source' => $source
);
$gridpanel->attributes['onMouseOver'] = $sfExtjs2Plugin->asMethod($configArr);
ob_start()
?>
if(Ext.fly(t).hasClass('delete-td')){
Ext.fly(t).removeClass('delete-td-down');
Ext.fly(t.parentNode).removeClass('delete-back-over');
}
<?php
$source = ob_get_clean();
// onRender
$configArr = array(
'parameters' => 'e, t',
'source' => $source
);
$gridpanel->attributes['onMouseOut'] = $sfExtjs2Plugin->asMethod($configArr);
?>
Especially those event-handlers should be made easier, but as as proof of concept I am very happy with the result!
Leon
|
|
|
| Re: Building Own Generator [message #56031 is a reply to message #56025 ] |
Sat, 12 July 2008 19:50   |
 |
lvanderree Messages: 652 Registered: June 2007 Location: Netherlands |
Faithful Member |
|
|
this post os about improving the Editable ComboBoxes
At the moment the comboBoxes still aren't working really well, they force you to stay in the box as long as they contain invalid (unknown) data, which can be very annoying. Besides they sometimes have some strange errors where they don't seem to be aware they contain valid data, or visa versa.
With the code I currently have (Ext.ux.ComboBoxAutoLoad.js),
an implementation seen at http://extjs.com/forum/showthread.php?t=37781&page=2 from durlabh
and some new code, I would like to improve this.
The general problem with comboboxes has already been explained by me at http://extjs.com/forum/showthread.php?t=37781
In short:
ComboStores should always contain the display-value from the grid/form (solved, but can be improved by the post at page2).
Besides this, I would like to be able to add new values for the combo directly with it.
My idea about this second part (the adding/manipulation of the selected item) is the following:
improving the combo
A combo can be in 4 states (I think)
- Empty (the text-value = "")
- Valid (the text-value matches an item in the related table)
- New (the text-value does not match and needs to be added)
- Searching (the store is being queried to find if the value exists)
My first solution to improve the combos is to show the state of the combo with the help of an icon.
1. If the combo is empty, no icon is necessary,
2. When valid we can show an OK-icon Or Edit icon (to allow you to manipulate the item in a pop-up-window)
3. When it contains a new item, there should be an Add-icon.
4. when querying, the user sees an animated icon which shows it is searching.
Instead of keeping the user locked in the combofield, the user can now see (with the help of the icon) if the combo contains a valid value. If the combo contains an invalid field we can disable the submit-button of the form (or show a message which tells to enter a valid value in the combo else saving is not possible).
Any ideas/improvements/questions are again appreciated
Leon
|
|
|
| Re: Building Own Generator [message #56051 is a reply to message #56031 ] |
Sun, 13 July 2008 17:59   |
 |
lvanderree Messages: 652 Registered: June 2007 Location: Netherlands |
Faithful Member |
|
|
The backwards compatibility bug is fixed (your generator.yml won't require list.display or edit.display anymore, it will show all fields in those cases)
I also implemented partials for edit/form-panel
edit-form-partials won't automatically get a fieldname anymore. Yyou need to set the field.name EXPLICITELY for edit-partials if you want to give one (with field.params.name), this field-name corresponds with the json-item-name it should show. If no name is set, the field will not be committed, nor loaded (which is a good thing)
This opens possibilities to show related items, E.G. when editing an assignment, you can show the related invoices (1 to many relation, where assignments won't have a foreign-key to invoices, but invoices do have a fk to assignment)
Ps. At the moment (list/edit)partials are NOT backwards compatible. I think in best case, we should try to return different results for ajax and non-ajax request from a partial (which has already been proposed a long time a go, don't know by who anymore, but like this):
<?php
switch($type) {
case 'edit':
echo "Edit";
break;
case 'ajax_edit':
// use_helper('sfExtjsAppPasswordField');
// echo generate_extjs_password_fields( $fieldLabel, $name );
use_helper('Extjs');
echo extjs_form_combobox(array());
break;
case 'list':
echo 'partial in list-view';
break;
default:
echo $type;
}
?>
I don't use this at the moment, and I haven't tested if this syntax is still working...
To keep normal symfony-partials and ExtJsThemePartials resemble each other as good as possible, it is important to do all data manipulation in the lib/model-objects (so don't define for instance $fullname = $first_name.' '.$last_name in your partial, but in your lib/model/user.php-object.
Partials should be used to define the field-type or other representation styles.
[Updated on: Sun, 13 July 2008 18:03] Leon
|
|
|
| Re: Building Own Generator [message #56120 is a reply to message #56031 ] |
Mon, 14 July 2008 14:54   |
lukas Messages: 28 Registered: November 2007 Location: Switzerland |
Junior Member |
|
|
| lvanderree wrote on Sat, 12 July 2008 19:50 |
At the moment the comboBoxes still aren't working really well, they force you to stay in the box as long as they contain invalid (unknown) data, which can be very annoying. Besides they sometimes have some strange errors where they don't seem to be aware they contain valid data, or visa versa.
|
I think we all made these observations, and can agree that it's a good idea to improve combo's.
| Quote: |
ComboStores should always contain the display-value from the grid/form (solved, but can be improved by the post at page2).
Besides this, I would like to be able to add new values for the combo directly with it.
|
the "add new values" part should be configurable. I don't always want to make the user able to add new values. (e.g. on course registration: imagine a user could add a new course we don't have)
| Quote: |
improving the combo
A combo can be in 4 states (I think)
- Empty (the text-value = "")
- Valid (the text-value matches an item in the related table)
- New (the text-value does not match and needs to be added)
- Searching (the store is being queried to find if the value exists)
|
concerning "Valid": An emptied option should be available to (as configurable behaivour) on fields that are not required (we talked about that). (e.g. PC Appliance sales: Some appliances boot from stick (eg firewalls), but you CAN have a hd for logs. It wouldn't be nice If I had to add a product "none" in my product table...)
concerning "New": Shouldn't be allowed in every case too (see add values above)
| Quote: |
My first solution to improve the combos is to show the state of the combo with the help of an icon.
1. If the combo is empty, no icon is necessary,
2. When valid we can show an OK-icon Or Edit icon (to allow you to manipulate the item in a pop-up-window)
3. When it contains a new item, there should be an Add-icon.
4. when querying, the user sees an animated icon which shows it is searching.
Instead of keeping the user locked in the combofield, the user can now see (with the help of the icon) if the combo contains a valid value. If the combo contains an invalid field we can disable the submit-button of the form (or show a message which tells to enter a valid value in the combo else saving is not possible).
Any ideas/improvements/questions are again appreciated
|
This solution should last for a while. With the appropriate server configuration you could even be faster than many company xy's serverbased ERP (eg the SAP / R3 insts) can build combos...
As long as it shows the sandclock-like thingie, the user will eat it
carpe diem
lukas
|
|
| | | |
| Re: Building Own Generator [message #56522 is a reply to message #56202 ] |
Sat, 19 July 2008 19:25   |
 |
lvanderree Messages: 652 Registered: June 2007 Location: Netherlands |
Faithful Member |
|
|
Pure magic has been implemented!
'Using' has been replaced with Ext-BaseX 3.0 from Doug Hendricks, this together with an idea from KRavEN and some changes to ExtJs itself makes it possible to automagically show your modules edit and grid-panels!
all you have to do is write something like:
var editWindow = new Ext.Window({
items : [
{
xtype : ('Edit' + this.relatedModuleName + 'FormPanel').toLowerCase()
}
]
});
editWindow.show();
And Extjs automatically loads the Object from the server when it has (automatically) found out that the xtype isn't registered yet! After that the instantiation of the panel for the window has been made, et Voila you have a edit-window for this module, without the need to include any (p)js-script!
There is one downside at the moment, I cannot make it work with script-injection into your documents header. So you won't be able to debug your javascript with firebug. BaseX3.0 is capable of injecting scripts into the header, but the instantiation of the object(panel) is done too fast, even though your browser has loaded the (pjs)script it didn't had time to evaluate its content while the browser already tries to create the panel... I haven't found out yet how to get around this, making it wait for an on-ready event or something, before continuing.
The advantage of this is that when you request a pjs-script while you are logged-out the script is being re-requested without a problem after successful login.
The only thing you have to do to make this work is update the svn for the sfExtjs2Plugin (which contains a hacked ExtJS (feature request is done at ExtJs)) and sfExtjsThemePlugin.
After that you should add the module which sfExtjTheme now has in your settings.yml enabled_modules
enabled_modules: [default, ajaxWebdebug, sfExtjsThemePluginXtypeManager]
This module makes it possible to automatically resolve the correct module/action for a given xtype.
A demo can again be found at http://tejohnston.dynora.eu/ (admin admin)
Leon
|
|
|
| Re: Building Own Generator [message #56780 is a reply to message #24107 ] |
Wed, 23 July 2008 01:14   |
 |
lvanderree Messages: 652 Registered: June 2007 Location: Netherlands |
Faithful Member |
|
|
Here a screenshot of what can be accomplished from the generator.yml config:

you see
- fields (among which custom xtypes)
- fieldsets
- tabpages (recursive)
- panels below each other (overrule the default tabpanel-xtype)
- column-layouts
the code to accomplish this:
edit:
params:
width: fill
newtitle: "New parcel"
title: "Parcel: <b>%%subject%%</b>"
content_xtype: contentpanel
content_config:
activeItem: 0
display: [subject, instructions_made, +assignment_id]
pages: # tabpages
general:
title: <img src="/images/barrel.png"/> General
params:
xtype: panel # this panel will contain other panels, by default pages will be shown in tabpanels, but you can overrule the contain's xtype, this way you get pages below each other...
pages:
general_top:
params:
layout: column
header: false
display:
"Product": [product_id/name, country_id/name, quantity, stowage]
"Survey": [installation, ex_tank, contract]
"params_Product":
columnWidth: 0.5
style: "margin:5px;"
"params_Survey":
columnWidth: 0.5
style: "margin:5px;"
general_bottom:
params:
header: false
display:
"Analysis": [_todo]
bl:
title: <img src="/sfExtjsThemePlugin/images/silk_icons/icons/folder_page.png"/> Bill of Lading
display:
"Bill of Lading": [number_of_bls, _bls, bl_to_agent]
Leon
|
|
| | | | |
| Re: Building Own Generator [message #56922 is a reply to message #24107 ] |
Thu, 24 July 2008 11:12   |
 |
lvanderree Messages: 652 Registered: June 2007 Location: Netherlands |
Faithful Member |
|
|
This plugin isn still Symfony 1.0 depended, don't know if I will make it 1.1 compatible since 1.2 is already on its way. The problem is that I can't seem to get in contact with Fabien and discuss his plans and make the plugin match the roadmap for 1.2
Fortunately 1.0 is still a great framework, but it would be nicer to keep the plugin compatible with the latest Symfony version. (It is not that I cannot do that without Fabien, but I think some of the work made for this plugin, can be put right back into the core generator.)
About the City-Country plugin, I will take a look at that and post a new version on the wiki. I post a new message after I've done that.
Last night I've came to a pretty cool conclusion, you can write Ext-code in the generator.yml files, since json and yml are very much a like! So you can use the Ext-Api directly in the generator.
An example, this would setup a tbar in Json:
new Ext.Panel({
tbar : [
{text: 'OK', handler: okHandler, scope: this}
]
});
And this is how it is done in Yml:
edit:
newtitle: "New Item"
title: "Edit: <b>%%name%%</b>"
params:
tbar:
- {text: 'Do something', cls: 'x-btn-text-icon btn_create', handler: this.doSomething, scope: this}
- {text: 'Or something', cls: 'x-btn-text-icon btn_mail', handler: "function(){alert('Easy');}", scope: 'this'}
bbar: [{text: 'this is also valid'},{text: 'looks more similar but less easy to read'}]
display:
General: [name, other, fields]
Thanks to the brilliance of the sfExtjs2plugin with its quote except function it doesn't matter if you place ' around your values (like this for the scope).
Leon
|
|
| | | | | | | |
Goto Forum:
|