Home » support » General discussion » Building Own Generator ( ) 7 Vote(s)
|
| Re: Building Own Generator [message #37647 is a reply to message #37630 ] |
Thu, 18 October 2007 03:10   |
DrCore Messages: 59 Registered: August 2007 |
Member |
|
|
I have been struggling with the problem of foreign columns also. Currently I implemented for lists a function which allows you to specify a foreign field like this:
list:
display: [ field, submodel/field, submodel/submodel/field, submodel/ ]
To make this work, I overloaded the getColumnGetter function of the admin generator. However this does not provide a full solution for filters and edits. My preference would be to add submodel functionality to the sfAdminColumn class and make all theme related files aware on how to deal with foreign classes.
To use submodel fields it is often best to use a peer_method/peer_count_method in the list section for performance.
The documentation in this latest release does not cover the submodel functionality yet. If I'm able to finish my deadline I will write some.
Cheers,
Andre
|
|
|
| Re: Building Own Generator [message #37681 is a reply to message #24107 ] |
Thu, 18 October 2007 12:04   |
gouiggou Messages: 44 Registered: October 2005 Location: Paris |
Member |
|
|
Great results, this is an excellent consideration to improve generator!
I discover ExtJS 1.1 thanks to another project and the second version of the ext seems to be very complete release.
I need to develop an internal management application. I've done my choice for symfony (of course...) and ext 2.0.
I would like to give some helpers to use usealy ext features.
I've seen your integration of grids into the generator of symfony, it's look very good.
I can help you lvanderree, but I don't know what youe ar expecting to do concerned your work.
I propose begin the writing of helpers. It would be nice if it could be bundle with what you have done before.
Regards.
Jérôme M.
|
|
|
| Re: Building Own Generator [message #37684 is a reply to message #37681 ] |
Thu, 18 October 2007 12:57   |
 |
lvanderree Messages: 652 Registered: June 2007 Location: Netherlands |
Faithful Member |
|
|
Hello and welcome gouiggou.
Any help is appreciated. I uploaded my code to the svn so everyone can collaborate, but maybe some 'guideliness' or initial ideas are in place.
Maybe we together can define the functionality which is desired and create an overview of what is done and what is still needed to be done.
My ideas for now are:
Lists:
- should be backwards compatible (in the generator.yml file)
- should be editable (but this can be disabled)
- filtering should work
- fields with foreign-keys should show up as an (autocomplete) drop-down combobox
DONE:
- It is possible to sort on foreign-data fields and combined data-fields (for example full-name (=firstname+lastname)).
- Data can be send as JSON-data, with respect to credentials
- (editable)(grouping)grid is generated
PROBLEM:
- master-detail pages (for example categories, with 0 or more products) are represented in a groupable-grid. Problem is to get a good detail-class instantiation. At the moment foreignkey-fields of detail-classes cannot be detected.
TODO:
- Extjs does not support multi-column sorting. This functionality can be extended. The symfony code is already prepared for this. Andre to use subclass/field for this)
- Mixing master-columns and detail-columns. (I like the idea of
- refreshing the data. You don't want to refresh the entire page to see if there is new data. A refresh button on top of the grid would be nice, which reloads the data from the grid, and all the drop-down-combo-boxes and other extra datastores. Maybe even nicer is to poll or even push these requests from the server. (pushing can be done I think by keeping a data-stream open, which is closed by the server as soon as data is changed for which the client is listening. The client can make a new connection and get all new data as soon as the open data-stream is disconnected).
Edit:
- should be backwards compatible (in the generator.yml file)
- forms should be constructed with extjs-methods
- required fields should show hints when not filled
- regexps can be added to check input
- drag-drop can be added, for example for admin_double_lists
DONE:
PROBLEM:
- first have to have editable grids working
TODO:
- A lot
- Helpers can be of good use here, so you can use them in edit as well as in lists.
layout.php:
- an example for a layout.php can be given, which shows how to cache your pages.
DONE:
- I've got this working. What I do is load every page in a tab-page. I check with the help of the URL if the page is not already loaded, if it is I show that tab-page. I hide the tab-page-headers with CSS so the user does not see a thing.
PROBLEM:
- Whenever there is a javascript error, no new javascript is executed anymore, so no new pages will be loaded. (The grids are rendered by javascript).
TODO:
- Maybe make javascript-code more robust, so it can handle errors.
There is a lot more which needs to be done, this are some of my initial ideas.
I will setup a wiki page, so everyone can add his ideas over there.
Leon
|
|
| |
| Re: Building Own Generator [message #37691 is a reply to message #37685 ] |
Thu, 18 October 2007 14:19   |
gouiggou Messages: 44 Registered: October 2005 Location: Paris |
Member |
|
|
Ok good, I already have a trac account.
I will look more in detail extjx code and your generator code.
I will certainly have some questions concerned your ideas.
Jérôme M.
|
|
| |
| Re: Building Own Generator [message #37822 is a reply to message #37692 ] |
Sun, 21 October 2007 15:03   |
 |
plan-r Messages: 42 Registered: October 2007 Location: Cologne (Köln) |
Member |
|
|
Hi Leon,
this plugins looks really great to me.
Where can I get the latest version of it, if I don't have a trac/svn account to check it out from there?
[Updated on: Sun, 21 October 2007 15:07] Ralf
|
|
| | |
| Re: Building Own Generator [message #37864 is a reply to message #37829 ] |
Mon, 22 October 2007 14:38   |
gouiggou Messages: 44 Registered: October 2005 Location: Paris |
Member |
|
|
I work hard in the plugin.
I'm writing small helper and using them in template and actions of generator.
I'm testing the mixing of master-class and detail-class, I will tell you more soon.
Jérôme M.
|
|
| |
| Re: Building Own Generator [message #37871 is a reply to message #24107 ] |
Mon, 22 October 2007 15:58   |
 |
lvanderree Messages: 652 Registered: June 2007 Location: Netherlands |
Faithful Member |
|
|
I've put online a small and simple online-demo:
http://fun4me.demon.nl/test/test_dev.php/item
It shows a problem I've posted on the Extjs forum about sorting. (when you change the item-sorting the group-sorting gets changed as well, which is not supposed to happen).
the generator for this (list-class) is:
generator:
class: sfPropelAdminGenerator
param:
model_class: Item
theme: extjs
list:
title: Items in a group
multisort: false
display: [ groep_id, =name ]
grouping:
field: groep_id
plugins: summary
multisort: true
sort: [ [groep_id, desc], [name, desc] ]
fields:
groep_id:
join_fields: [ItemPeer::GROEP_ID, GroepPeer::ID]
sort_column: GroepPeer::NAME
As you can see, this is not a master-detail (in that case you would have seen empty group-2 as well).
There is something wrong with this stylesheet, but haven't tried to figure out what.
because I have defined groep_id instead of groep, I don't need a Groep->__toString() method. In this case the extjs library does an other call to the server asking for a groep-JSON-data-list, so the translation form id to name can be done client sided (which makes it possible to have drop-down combo-boxes).
Because of this, you are required to have set the theme of the groep in its generator.yml to extjs as well (otherwise there would not be an action called jsonList). For now the json-list of group is required to have a field called 'name', I think I will add an optional option to set a show_field (which can also handle partials).
With the fields: part I tell my plugin on which column to sort, when groep_id is called (sort on group:name instead of its ID).
The sort: part is an array in array, which defines the default sorting, for multiple columns.
(Ps. groep is group in Dutch I could not use group, because symfony does not put a ` around the table-name in the sql query, and group is not a good table name in sql).
Leon
|
|
|
| Re: Building Own Generator [message #37890 is a reply to message #24107 ] |
Mon, 22 October 2007 18:54   |
 |
plan-r Messages: 42 Registered: October 2007 Location: Cologne (Köln) |
Member |
|
|
hi there,
I am just testing the plugin and I am having a problem I don't understand:
I have created an admin-backend with the plugin from a model with 1 db-table which has 25 fields.
The db-tables content are ca. 7000 records.
I just started with a generator file like that:
generator:
class: sfPropelAdminGenerator
param:
model_class: products
theme: extjs
#ajax: false
list:
title: Produkt-Liste
The result is an empty grid in the module, with all fieldsnames as column headers.
When I add the following to the generator I get a filled grid, and it sorts ascending to the column "id" as it should:
list:
title: Produkt-Liste
multisort: true
sort: [[id, asc]]
display: [id, name]
Then, if I add one or more fields to display in the generator (e.g. db-fields "description", "price" and so on) the result extjs grid is empty again.
When I then click on the column header "id" (in the result grid) to sort it descending, the grid will be filled - but sorted descending, and the grid-paging does not work.
Here is my simple generator:
generator:
class: sfPropelAdminGenerator
param:
model_class: products
theme: extjs
#ajax: false
list:
title: Produkt-Liste
multisort: true
sort: [[id, asc]]
display: [id, name, description, price]
(I always cleared the SF cache between each step)
Is there something I've forgotten while generating the admin-backend and editing the generator?
My symfony-version is 1.0.7
Thanks in advance for a hint...
Ralf
|
|
| | | |
| Re: Building Own Generator [message #37899 is a reply to message #37897 ] |
Mon, 22 October 2007 20:39   |
 |
lvanderree Messages: 652 Registered: June 2007 Location: Netherlands |
Faithful Member |
|
|
If the problem is because of your data, maybe a nice solution could be to write a partial field, which transforms the data to a valid output.
But on the otherhand, you should be able to have line-breaks in your data. So I guess that it would be nicer to have this done by the plugin as well.
[Updated on: Mon, 22 October 2007 20:47] Leon
|
|
| | |
| Re: Building Own Generator [message #37904 is a reply to message #37902 ] |
Mon, 22 October 2007 21:17   |
 |
lvanderree Messages: 652 Registered: June 2007 Location: Netherlands |
Faithful Member |
|
|
yes I know why this happens.
when you set multisort to true, you can sort on multiple columns at the same time. But there is a BUT and an Ahhh
Lets begin with the Ahhh,
If you sort on [id, name, price], you sort on
id, name AND price.
So it begins with sorting on all ids, then it sorts on all names, and then it sorts on all prices. Because the ids are all different, you cannot notice the sorting on names, nor prices.
And because you mentioned ids first, you also won't notice it when you change sorting of the other fields to descending, only sorting on ids will work.
The multisort functionality is usefull if you have for example product-groups and product-names, or products with the same name, but with a different price. You can then first sort on product-group (or product-name) and then on product-name (or product-price, or all three of them if you like). But you have to leave the ids out!
the array of fields after sort: do not tell you on which fields you are allowed to sort, maybe that is a nice addition one day.
So I hope that this is clear, and you probably want to disable multisort, to have the default behaviour.
Now for the 'BUT'.
Multisorting isn't working with ajax set to true, because at the moment extjs cannot handle sorting on mulitple columns. It can only sort one column at a time. If you disable ajax (ajax: false) you can see how it should work. Someone first has to extend extjs with this functionality before this is possible. I very much like the implementation done with jquery: http://tablesorter.com/docs/ (holding the shift-key while pressing the column headers to sort on multiple columns)
It should be possible to extend extjs with this functionality, but it is not there (yet). At the moment I haven't got time for this yet. And to make it work like the jquery example, there should also be some extention for my plugin, to make the multi-sort reset when you don't hold shift.
You probably want to do add a sort-column to a sort-array when the user holds shift, and when the user does not hold shift, you call an other action which first resets the sort-array, and than adds one column to the empty sort-array.
Leon
|
|
| | | | | |
| Re: Building Own Generator [message #37924 is a reply to message #37916 ] |
Tue, 23 October 2007 08:39   |
elrems Messages: 5 Registered: October 2007 |
Junior Member |
|
|
Hi,
can you give your "schema.yml" for the "city" project?
and i've a lot of
"Notice: Undefined offset: 1 in C:\symfony_sandbox\cache\frontend\dev\modules\autoAssignment \actions\actions.class.php on line 229"
is that ok?
Elrems
[Updated on: Tue, 23 October 2007 08:51]
|
|
|
| Re: Building Own Generator [message #37931 is a reply to message #37924 ] |
Tue, 23 October 2007 10:07   |
 |
lvanderree Messages: 652 Registered: June 2007 Location: Netherlands |
Faithful Member |
|
|
The undefined offsets should not be there. Could you post the code around line 229 (something like 220 to 240, from C:\symfony_sandbox\cache\frontend\dev\modules\autoAssignment \actions\actions.class.php )
my schema.yml file contains the following data:
// countries
country:
countryid:
type: INTEGER
required: true
autoIncrement: true
primaryKey: true
name:
type: VARCHAR
size: 150
required: true
abbreviation: {type: varchar(4), required: false}
// cities
city:
cityid:
type: INTEGER
required: true
autoIncrement: true
primaryKey: true
countryid:
type: INTEGER
required: true
index: true
foreignTable: country
foreignReference: countryid
onDelete: RESTRICT
onUpdate: CASCADE
name: {type: varchar(150), required: true}
Unfortunately I cannot use the camel-case convention in my project so, no country_id or city_id.
If you have got a list of cities, and use countryid in the display field of your city-list, your country should have a field called name, or otherwise the drop-down combobox cannot be filled. (there will be an option which you can set later on).
Ps. the plugin has no problems with the camel-case convention, and actually I prefer to use it myself as well. When you use camel-case convention the schema.yml would be much simpler:
// countries
country:
id:
name: {type: varchar(150), required: true}
abbreviation: {type: varchar(4), required: false}
// cities
city:
id:
country_id:
name: {type: varchar(150), required: true}
of course you have to insert some underscores in the generator.yml file in that case.
[Updated on: Tue, 23 October 2007 12:58] Leon
|
|
|
| Re: Building Own Generator [message #38028 is a reply to message #37897 ] |
Wed, 24 October 2007 12:01   |
 |
plan-r Messages: 42 Registered: October 2007 Location: Cologne (Köln) |
Member |
|
|
hi again.
i am still doing some tests with my db-tables and the extjs-Theme / grid.
but i guess i have a big name confusion now.
i'll try to explain it.
i have 2 db-tables in the model:
"products" and "folder" (folder means the product category)
table "products" has a FK in field "pid" which refers to the field "id" in the foreign table "folder".
i build the model, and the class files "Products.php", "ProductsPeer.php" and "Folder.php" and "FolderPeer.php" (and the mapping class files) have been created properly.
i then created a backend app and created/initiated the admin-backend-modules.
what i want to do is to show the field NAME (not the id) of the "folder" table as a column in the "products" admin list (therefore i added a _toSTring()-Method to the "Folder.php" which returns the NAME-field of the FOLDER-table instead of the ID).
with the default admin theme that works fine.
after having that wokring i tried to do that with the extjs theme.
i altered the generator.yml as described at the plugins wiki-page:
generator:
class: sfPropelAdminGenerator
param:
model_class: Products
theme: extjs
list:
title: Produkte
multisort: false
# sort: [id]
display: [folder, name, description, price]
fields:
pillefolder:
join_fields: [ProductsPeer::ID, FolderPeer::PID]
sort_column: FolderPeer::NAME
name: {name: Bezeichnung}
description: {name: Beschreibung deutsch}
The result is an empty extjs-grid.
Firebug notifies me twice at the firebug-console as follows:
POST : The requested URL /backend_dev.php/folder/jsonList/filter/query was not found on this server
and the response json-arrays, viewed at Firebug's console, look all the same:
(from: /backend_dev.php/Productex/jsonList?limit=20&start=0)
{totalCount:"98", data:[
{"folder":"<br />
<b>Notice</b>: Object of class Folder to string conversion in <b>/cache/backend/dev/modules/autoProductex/templates/_json_list_td.php</b> on line <b>6</b><br />
Object","name":"Arriflex 16 ST","description":"Grundausstattung mit: Selbstregelmotor 24/25 B/s, 2 Kassetten 120m, 2 Akkus","price":"80","id":"1"}
The table "products" has the fields "id", "pid", "name" etc.
The table "folder" has also fields with names "id", "name" etc.
Do I have a name confusion with the field names when displaying foreign fields as columns in the grid?
I just want to have a (sortable and later on groupable) column in the extjs-grid "products" which shows the "name" field of the foreign-table "folder".
As I am new to symfony - please be patient with me
Thanx a lot in advance!
Ralf
|
|
| | |
| Re: Building Own Generator [message #38050 is a reply to message #24107 ] |
Wed, 24 October 2007 17:04   |
gouiggou Messages: 44 Registered: October 2005 Location: Paris |
Member |
|
|
Hi Leon,
For mixing master and detail-class I use the DrCore's solution (overloaded the getColumnGetter for display value) and I modify functions addSortCriteria and addFilterCriteria of action.
Currently I'm playing with the extjs for display the combobox and doing more and more refactoring!
I've extended the sfPropelAdminGenerator to add getColumnGetter and include insinde this new class your getAjaxButtonToToolbarAction.
I've also added a function name getAjaxLinkToAction which add actions defined in object_actions of generator.yml into a RowContextMenu.
This rowContextMenu is building into a new partial called _list_ajax_td_actions and included at the bottom _lit_ajax_layout.
To finish, I add in the columnModel of extjs the possibility to modify boolean with the checkBox editor.
That's all for the moment, I attempt to give you a functionnal version of the plugin and it will be great we discuss about my work.
Jérôme M.
|
|
| | | | | | | | |
Goto Forum:
|