# |
Jun 27th 2017, 09:00 |
slackebot |
__('All') => 'all', __('Missing Maintainer') => 'missingMaintainer', __('Uncategorized') => 'uncategorized', __('No version set') => 'unversioned', ]); if (in_array($this->request->query('finder'), ['missingMaintainer', 'uncategorized', 'unversioned'])) { $this->Crud->action()->config('findMethod', $this->request->query('finder')); } |
# |
Jun 27th 2017, 09:00 |
savant |
``` public function index() { $fields = [ 'id', 'maintainer_id', 'name', 'repository_url', 'tags', 'category_id' ]; if ($this->request->getParam('_ext') === 'csv') { $this->set('_serialize', ['packages']); $this->set('_extract', $fields); } $this->Crud->action()->config('scaffold.index_finder_scopes', |
# |
Jun 27th 2017, 09:00 |
savant |
here is the code for that particular index action |
# |
Jun 27th 2017, 09:00 |
savant |
can link actions etc, have scoped filters |
# |
Jun 27th 2017, 09:00 |
savant |
i get csv/json/xml export support |
# |
Jun 27th 2017, 09:00 |
savant |
https://cl.ly/2G3G133C2Q3z |
# |
Jun 27th 2017, 09:00 |
savant |
anyhow, re: crud, this is the sort of thing I’m doing |
# |
Jun 27th 2017, 08:59 |
savant |
you pass in your table and deal with just the wrapper class |
# |
Jun 27th 2017, 08:59 |
savant |
that is basically your data provider |
# |
Jun 27th 2017, 08:59 |
savant |
that or build a wrapper class |
# |
Jun 27th 2017, 08:59 |
savant |
then you have strong cohesion |
# |
Jun 27th 2017, 08:59 |
savant |
I think if you want to treat a specific table as a “type” of thing, you should build an interface and attach it where necessary |
# |
Jun 27th 2017, 08:58 |
savant |
I’ve been leaning heavily on crud-view recently - @dakota mentioned it above - and it helps build out administrative patterns |
# |
Jun 27th 2017, 08:58 |
savant |
I dont really use that sort of approach per-se |
# |
Jun 27th 2017, 08:56 |
rudy1976s |
I found that approach very useful for displaying data |
# |
Jun 27th 2017, 08:56 |
rudy1976s |
http://www.yiiframework.com/doc-2.0/guide-output-data-providers.html |
# |
Jun 27th 2017, 08:56 |
rudy1976s |
exactly |
# |
Jun 27th 2017, 08:55 |
savant |
but automatically without needing to rebake things, is that correct? |
# |
Jun 27th 2017, 08:55 |
savant |
sort of like bake? |
# |
Jun 27th 2017, 08:55 |
rudy1976s |
Yii2 uses the dataprovider which is able to receive a query and display in a widget with the according fields result of the query with its label in a list or grid fashion |
# |
Jun 27th 2017, 08:54 |
rudy1976s |
I am thinking of this because of my recent Yii2 experience, which was really complicated for me coming from cake way of thinking ( which I still prefer) but the dataprovider concept was very useful ) |
# |
Jun 27th 2017, 08:53 |
savant |
im guessing you’re trying to automatically generate admin panels? |
# |
Jun 27th 2017, 08:53 |
savant |
can you point me to where yii2 has this “label” functionality? |
# |
Jun 27th 2017, 08:52 |
savant |
rudy1976s: your question has me interested enough to stay awake to ask a few questions |
# |
Jun 27th 2017, 08:52 |
rudy1976s |
and build a helper where I can pass the query and then render it in grid or list, with correct field name for every field in the query automatically |
# |
Jun 27th 2017, 08:51 |
neon1024 |
Perhaps it adds a ‘meta’ association to the returned entities |
# |
Jun 27th 2017, 08:51 |
neon1024 |
A lookup table could be accessed neatly through a behaviour which does the lookup when you use the table |
# |
Jun 27th 2017, 08:48 |
rudy1976s |
My target intent is to have something like a dataprovider |
# |
Jun 27th 2017, 08:48 |
dereuromark |
I 2nd that |
# |
Jun 27th 2017, 08:48 |
neon1024 |
I guess you could make a table, which stores the table, column and label fields and look the stuff up |
# |
Jun 27th 2017, 08:47 |
neon1024 |
When I did this, I ended up just writing configuration for it |
# |
Jun 27th 2017, 08:47 |
neon1024 |
What’s wrong with the column name? |
# |
Jun 27th 2017, 08:46 |
rudy1976s |
@neon a column, I need a label because I need to generate the code for gri/list view prgramatically and with translations in mind |
# |
Jun 27th 2017, 08:45 |
neon1024 |
My first thought about putting presentation logic into the database is that it’s dirty |
# |
Jun 27th 2017, 08:45 |
dakota |
sounds like a job for CrudView :) |
# |
Jun 27th 2017, 08:45 |
neon1024 |
When you say a field of a table, do you mean a column or a specific row cell? |
# |
Jun 27th 2017, 08:43 |
slackebot |
views, perhaps with a helper. have you some idea to achieve such result ? |
# |
Jun 27th 2017, 08:43 |
rudy1976s |
I have a question that I have already asked some time ago relating to table: I would need to be able to assign a "label" to every field of a table: actually cake does not provide a native method to do such thing, like for example Yii2 does ( iI am working on both so I can check against each other features ) . This would be useful to create a class for generating listViews and gridViews automatically , without the need to write the full mark |
# |
Jun 27th 2017, 08:27 |
Antoniossss |
sleep well |
# |
Jun 27th 2017, 08:27 |
Antoniossss |
thank you very much! |
# |
Jun 27th 2017, 08:27 |
savant |
night |