coolsam726/jetstream-inertia-generator

Modification of boilerplate

asbator opened this issue · 5 comments

How can I adjust myself auto generated code for field titles?
To make changes that will suite my needs inside
views, repository dtColumns() and api controller index()?

I ask because i have 300 columns table
To make it more manageable i thought about making own helper class that will accept field name and return title. That way it will be possible to change things centrally for many places in app.

It would be something like this in php:

Column::make('field_name')->title(report_title('field_name'))

Or in Vue form

<jet-label for="field_name" :value="fields.field_name.title" />

I'm actually thinking about long and short titles (forms and data tables) and more, like types of values for stats, advanced filters.

Maybe regex replacing of generate code will be easier...

I think it might be a bit of an overkill because for the Datatables such a helper already exists. I don't know how convenient it would be to create your helper as compared to refactoring. The generator does not create such an abstraction but it would be fun to explore if you have time! Please do a PR in case you proceed with the idea.

I already have arrays with 'attr_name' => 'title', both short and long titles. Id rather write helpers, instead copy paste it at least 5x300 times. I had that experience before on old system. In case of creating new lists/stats view, having centralized data properties (like title) can save lots of time. Not nearly as good as JIG, but helpful too.

Im just considering is it easier to customize generators code before generation or make regex replace customization after generation.

Alas during generation order of fields was changed.
Now i have to put 300 fields back to order on 3 views :(

@asbator I think the rule of the thumb is that after generation of a module, if you have modified some files you can skip their generation in case you want to re-run code generation. You can achieve this by NOT specifying the --force param.

During code generation, the following are generated for each table:

  1. Model
  2. Policy
  3. Repository
  4. Factory
  5. FormRequests (Folder = app/Http/Requests/ModuleName)
  6. API Controller in app/Http/Controllers/API
  7. Admin Controller in app/Http/Controllers/Admin
  8. js views (Folder = resources/js/Pages/ModuleName)
    The following appends are also made:
  9. Api Routes in routes/api.php
  10. Admin Routes in routes/jig.php

If you have modified any of the above generated code sections and would like to re-run generation of some sections and leave others, the best option would be to delete all the sections that you would like to re-generate and leave the ones you would like to remain intact, then run jig:generate without -f