Home » support » General discussion » Building Own Generator ( ) 7 Vote(s)
| Re: Building Own Generator [message #50270 is a reply to message #50240 ] |
Fri, 18 April 2008 13:30   |
KRavEN Messages: 213 Registered: May 2007 |
Faithful Member |
|
|
| lvanderree wrote on Thu, 17 April 2008 18:49 | My idea about the dynamic loading of scripts is like this:
imaging you have a list (grid) of cities, and you want to add a city. I will write down the pseudo-javascript/actions for it.
Click add-city button from toolbar
- javascript checks if var CityEditor has been defined
- if not defined, load module City action Create.pjs (as seen in http://blogs.byte-force.com/xor/archive/2008/04/16/1758.aspx )
- this would load the layout-only
- now the layout is loaded and set in the var CityEditor a callback function will perform the rendering of the CityEditor-Panel (just like is done in http://backoffice.kaffill.de/ext2/ext2 when pressing the window button )
When we want to save this new city, we click the save button (delete should not be there for a new object)
Click Save
- save the form
- A callback function will set the key (which this new item gets and returns in the succes:json-result) for this form/panel/window
= the delete button should now appear
When we now also want to edit a item from the (same) list, we click on one of the items
Click on a item
- Check if var CityEditor has been defined (which now is, because of the clicking on add city from before, and since action create and action edit should return the same layout (except for the delete-button somehow) this is fine)
- Open a new windows/panel with this layout (see kaffill again)
- get the content with a query and load the json-data.
hardcoding the ids of the panels/forms/windows should be obsolete I think, you can find elements by querying them on properties.
This would be ideal I think, but requires significant rewriting of current code and I haven't got an idea about how to make a difference between create and edit (with the delete button). This difference should be made client-sided, by checking for example if the PrimaryKey is set as some property, but no idea how to write this javascript yet, since everything is defined by javascript-config style.
Please tell me what you people think about this.
|
I implemented something similar when I added the upload panel action.
Check out ajaxUploadJsSuccess.pjs and ajaxUploadSuccess.php along with the executeAjaxUpload** actions. The action is defined in the upload case in the getAjaxButtonToToolbarAction method.
I use the same sort of method whenever I have a tabpanel to load the content for the tabs.
|
|
| | | | | |
| Re: Building Own Generator [message #50291 is a reply to message #50289 ] |
Fri, 18 April 2008 15:10   |
 |
lvanderree Messages: 652 Registered: June 2007 Location: Netherlands |
Faithful Member |
|
|
I guess it is probably because I use a associative array somewhere, and since the names of the seperators are the same, only one will remain...
Had this same issue with fields, and resolved it by using a normal array. I will take a look at it later on.
Is everything still working for you, after I changed the edit-pages, and submit-buttons?
I am really thinking about rewriting the edit-pages even further, so they are implemented as described in the previous posts. This will probably will introduce new problems, but hopefully solve more of them 
I think there should also be an event-manager introduced, on which lists can announce themselves, and to which edit-pages can tell they have just saved/deleted an item (so the lists who are subscribed for that item-type can automatically reload themselves). We now both use hardcoded moduleList.getDataStore.reload(), but imagine you have list of cities (with the county they are in) and you fix a typo in the naming of a country, you want the city-list to be reloaded, so the naming of the countries gets fixed... (there are of course more examples of where this works)
Leon
|
|
| | | | | | | |
| Re: Building Own Generator [message #50312 is a reply to message #50309 ] |
Fri, 18 April 2008 17:00   |
clad Messages: 23 Registered: April 2008 |
Junior Member |
|
|
yes sorry i didn't see it.Without it works fine. i'll update my previous post
for question2: The parcel list display now the name of assignment and not the id. (i'm not sure it's what's you were talking about?)
[Updated on: Fri, 18 April 2008 17:37]
|
|
| | | | | |
| Re: Building Own Generator [message #50633 is a reply to message #50628 ] |
Tue, 22 April 2008 17:54   |
clad Messages: 23 Registered: April 2008 |
Junior Member |
|
|
Sorry if i'm not clear.In fact i think i make a lot of confusion between sfExtjs2Plugin and sfExtjsTheme plugin. I don't know how using both correctly.For example. I know how create a grid with sfExtjsThemePlugin but not with sfExtjs2Plugin .
I know http://fun4me.demon.nl/test/test_dev.php/city is your website and it is pretty cool. It is precisely what i try to do.You have a panel and in the panel(not a tabpanel) a grid.
In fact in my layout i have :
<body>
<div id="content">
<?php echo $sf_data->getRaw('sf_content') ?>
</div>
<div id="content2">test</div>
<div id="content3"></div>
<?php
$sfExtjs2Plugin = new sfExtjs2Plugin(array('theme'=>'gray'));
$sfExtjs2Plugin->load();
$sfExtjs2Plugin->begin();
$sfExtjs2Plugin_App_viewport = $sfExtjs2Plugin->Viewport(array
(
'layout' => 'border',
'items' => array
(
$sfExtjs2Plugin->Panel(array
(
'region' => 'west',
'border' => true,
'title' => 'menu',
'width' => 200,
'collapsible' => true,
'collapseMode' => 'mini',
'split' => true
)),
$sfExtjs2Plugin->Panel(array
(
'region' => 'center',
'border' => true,
'plain' => true,
'collapsible' => true,
//'layout' => 'fit',
'items' => array(
$sfExtjs2Plugin->Panel(array(
'region' => 'center',
'title' => 'Content',
'contentEl' => 'content',
'titleCollapse' => true,
'collapsible' => true,
'collapseMode' => 'mini',
'autoScroll' => true
)),
$sfExtjs2Plugin->Panel(array(
'region' => 'center',
'title' => 'Content2',
'contentEl' => 'content2',
'collapsible' => true,
'autoScroll' => true
)),
$sfExtjs2Plugin->Panel(array(
'region' => 'center',
'title' => 'Content3',
'contentEl' => 'content3',
'collapsible' => true,
'autoScroll' => true,
'items' => array(
$sfExtjs2Plugin->TabPanel(array(
'region' => 'south',
'title' => 'info',
'titleCollapse' => true,
'items' => array(
$sfExtjs2Plugin->Panel(array(
'contentEl' => 'Onglet 1',
'title' => 'Onglet 1',
'autoScroll' => true
)),
$sfExtjs2Plugin->Panel(array(
'contentEl' => 'Onglet 2',
'title' => 'Onglet 2',
'autoScroll' => true
)),
$sfExtjs2Plugin->Panel(array(
'title' => 'Onglet 3',
'contentEl' => 'Onglet 3',
'autoScroll' => true
))
)
))
)
))
)
))
)
));
$sfExtjs2Plugin->beginApplication(array
(
'name' => 'App',
'public' => array
(
'init' => $sfExtjs2Plugin->asMethod(
"
Ext.QuickTips.init();
$sfExtjs2Plugin_App_viewport;
")
)
));
$sfExtjs2Plugin->endApplication();
$sfExtjs2Plugin->end('Ext.onReady(App.init, App);');
?>
</body>
But in content div , i Have a grid but there are a border with the title defined in my parcel generator list for exemple. i put the title to false and i have always the border (the border seems to be like border in combobox). i don't want to see this border.
In your website there is no border...Perahps it's simply a problem in my CSS ...
I have a lot of anothers questions about this very interressant plugin.In fact i have read all doc but with all changes, i'm not sure about what we can really do with it.
thanks a lot leon
|
|
| |
| Re: Building Own Generator [message #50677 is a reply to message #50670 ] |
Wed, 23 April 2008 13:46   |
 |
lvanderree Messages: 652 Registered: June 2007 Location: Netherlands |
Faithful Member |
|
|
I had already upgraded the sfExtjs2Plugin to Ext2.1 earlier this week, so if you do an svn-update you should have the new Extjs2.1 Please be aware of the changed license of Extjs2.1 (changed from lgpl to GPLv3: http://www.extjs.com/products/license.php )
About the differences between sfExtjs2Plugin and sfExtjsThemePlugin.
sfExtjs2Plugin: is the wrapper-plugin arround ExtJS 2(.1) You can write php which results in extjs-javascript code. The idea behind it is that you don't have to change your php-code if you want to use another javascript-library, you simply can replace it with an other wrapper. (although I don't know how this will work-out since all arguments in the php-code are specific to the extjs api...)
the sfExtjsThemePlugin is a theme/generator for symfony which replaces the default static html (with tables for lists and forms for edit-pages) which is generate by the default symfony-generator by extjs-powered html/js-scripts using extjs. So grids and extjs-forms with their datastores are setup to present you your data.
The sfExtjsThemePlugin depends on the the sfExtjs2Plugin for generating the extjs-javascript code.
In my new version of the sfExtjsThemePlugin, which I will commit soon, I will make more use of the sfExtjs2Plugin. The sfExtjs2Plugin uses arrays as an argument, but in contradiction to most javascript-engines, php has no problem with extra comma's in you array-content, which makes things easier to read in the generator.
I've also choosen to let the php-generator script generate php-template-scripts which contain the calls to the sfExtjs2Plugin. This means that at run-time when a person browses your application, the php-templates call the sfExtjs2Plugin-functions to generate javascript. I could already do this during generation, but this would make it harder to change and override the templates by/with custom php-code.
THe only thing I want to implement before committing is the implementation of showing the new edit-panels (when you click the add-button or on a link of one of your items in the grid).
What will not be implemented yet is the connection to the datastores. So your edit-pages will for the moment stay empty and cannot store anything either. So if you want to keep editing and your items, you should not update the sfExtjsTheme plugin, if you want to help me you can update and test/expand the new code. The old version will be obsolete, it was compatible with Extjs1.0 (someday) and now everything will be written in the much nicer way of extjs2 which is extendible and is only required to be loaded once (instead of for every item you want to edit you had to load the complete layout).
Leon
|
|
| |
| Re: Building Own Generator [message #50709 is a reply to message #50679 ] |
Thu, 24 April 2008 03:18   |
 |
lvanderree Messages: 652 Registered: June 2007 Location: Netherlands |
Faithful Member |
|
|
OK People,
it has been done! I have committed.
Before updating your svn, please be-aware that this will brake functionality!
TODO's:
- setup datastore/datareaders to make loading/saving of form-content possible
= setting PK in form-field
- Add ability to set some fields with predefined values.
- clean-up old code & old php-files (I improved naming)
I changed default settings, so more things should work out of the box. (this is especially for KRavEN, if these settings don't work for you it probably is best to overrule them in your application, but maybe I set some silly defaults, in that case please tell me of course)
For a Live demo of current capabilities, please check: http://fun4me.demon.nl/test/test_dev.php
Things you can test: click on Add City (add country does not work yet, since I don't set the correct url to load yet)
Click on an existing city (will not show the city, but it does load).
The code of these edit-pages is much much cleaner. Extjs2-style and best of all: The layout is now lazy loaded (only once and only when you need it). I do it differently than you KRavEN, not with an head where I include the javascript, but with a library which can lazy load ) So only the first time you want to see an edit-page it will be somewhat slower, after that it will be fast.
The sfExtjsTheme plugin now depends on another plugin: sfPJSPlugin (which you should install yourself). This plugin adds the ability to return prue javascript files (with a javascript header).
I tried to made the generated-code for the templates to be mostly php (so not javascript), which should make it easier to override/extend it per template.
I included the source of the demo (which should work almost out of the box, just set your database/propel settings and include sfExtjsTheme and sfExtjs2 plugins). Most important things are the layout.php file of the application and the setup of the pjs-plugin.
There is probably a lot I did not mention yet, but it is time for bed right now
Attachment: test.zip
(Size: 155.83KB, Downloaded 152 time(s))
Leon
|
|
| | |
| Re: Building Own Generator [message #50740 is a reply to message #50738 ] |
Thu, 24 April 2008 11:19   |
clad Messages: 23 Registered: April 2008 |
Junior Member |
|
|
Hi all,
the update looking good.
But i have also javascript error in firebug and i have no grid display:
my errors:
Ext.ux.TabCloseMenu is not a constructor (like the last time ???) (city line 674)
using is not defined (city line 144)
using is not defined (city line 115)
I think i installed sfPJS plugin correclty.
Any idea about what i'm doing wrong?
thanks
[Updated on: Thu, 24 April 2008 11:26]
|
|
| | | |
| Re: Building Own Generator [message #50759 is a reply to message #50757 ] |
Thu, 24 April 2008 14:43   |
clad Messages: 23 Registered: April 2008 |
Junior Member |
|
|
| lvanderree wrote on Thu, 24 April 2008 14:26 | Is your sfExtjsThemePlugin/web-folder linked(or copied) to your projects-web-folder, so it is accessible by your browser? So can you go to: http://fun4me.demon.nl/test/sfExtjsThemePlugin/js (where fun4me.demon.nl/test is the url of your webserver/project
|
Thanks that's was it. i had the wrong url.I had /sfExtjsThemePlugin/web/js instead of /sfExtjsThemePlugin/js.
In your example you have a border with the title "city list".I know that we can change the title in generator file but i'm wondering if it is possible to have only the grid and not this border?(we can put the title to default to have no title but there are still the border).
And last question, can we move the toolbar in wich there are action (like create,print) to put it in an other location in the page ?
[Updated on: Thu, 24 April 2008 14:44]
|
|
|
| Re: Building Own Generator [message #50763 is a reply to message #50759 ] |
Thu, 24 April 2008 15:02   |
 |
lvanderree Messages: 652 Registered: June 2007 Location: Netherlands |
Faithful Member |
|
|
Yes you can switch of the border,
but because everything is work in progress, and because you probably have tons of more questions wants you are up-and-running, it might be better not to give you the direct-answer, but show you how you can find out.
Everything the generator creates is described in the php-generator-scripts (which generated php-templates, which result in html/javascript). These php-generator-scripts can be found at the sfExtjsThemePlugin/data/generator/sfPropelAdmin/extjs/templa te/templates folder. You start with the files without an underscore in front of them (so most importantly listAjaxSucess.php and editAjaxSuccess.php) these files include all kind of templates (which start with an underscore) (there are also some files with double underscores (__) these are special php-generator-templates which are recursively included or exported to different file-names.
All files which we use for the Extjs-Theme should have the following naming <action>AjaxSuccess.php or for templates <action>_ajax_<description>.php
Now when you want to find out where the border is defined, you know it is about grids, so you look at the listAjaxSucess.php file And somewhere near the bottom you see
<?php if ($this->getParameterValue('border_panel', sfConfig::get('app_sf_extjs_theme_plugin_border_panel', true))): ?>
which says if in the generator.yml file border_panel is set as a parameter, look at its value, else use as default value the result of the app.yml-config file (preferably you define this in your application, and do not override the app.yml file of the plugin, but you can take a look at it as an example) and look if all:sf_extjs_theme_plugin:border_panel is set, else use as default true.
so what you probably want is set in your application, the following app.yml-file in its config folder:
all:
sf_extjs_theme_plugin:
border_panel: false
I don't know where you want to place the toolbar, but now you know that you can take a look at _list_ajax_layout.php (use a file-search if you don't know where to start looking, and look for toolbar) and look if you can find a way to change the location of the toolbar.
Now you can look for a way to add make it better configurable (by adding new config-options) so it can be included by a patch to the plugin, or if you have an exception which will only show up once, overrule the generated template by copying it from the cache and place it in your module/template folder and alter it overthere.
I hope I made some sense and if you could make a/update the howto for other people from this, please post it.
Leon
|
|
| | | | |
| Re: Building Own Generator [message #50820 is a reply to message #50787 ] |
Fri, 25 April 2008 10:10   |
clad Messages: 23 Registered: April 2008 |
Junior Member |
|
|
Hi all,
Yesterday Plugin was working correctly.
Today when i load pages of test code i have a symfony exception.
Sort column "partial" not found
stack trace
* at ()
in SF_ROOT_DIR\cache\test\dev\modules\autoCity\actions\actions. class.php line 660 ...
657.
658. if (!$found)
659. {
660. throw new Exception('Sort column "'.$sort_column.'" not found');
661. }
662.
663. try
I saw in this thread that in the past, there was the same problem but i don't find a solution.
Does Anyone have the same problem ?
I put in comment line
if (!$found)
{
throw new Exception('Sort column "'.$sort_column.'" not found');
}
and it work until i clear cache. Is it a bug of generator or am i doing something wrong?
Thanks
[Updated on: Fri, 25 April 2008 10:49]
|
|
| | |
Goto Forum:
|