Open phgrey opened 10 months ago
Nicely written thank you 👏
From my experience with mix phx.gen
, I'm not a big fan of using generators, since upgrading the code is super difficult after anyone done any changes and to be honest sometimes even without making any customizations. I know the idea of templates is to definitely avoid customization. But even so, it feels bad not to provide any safe escape hatches.
Have you guys considered a similar approach to LiveAdmin ?
The API is super simple and looks like this:
defmodule MyApp.Admin.Accounts do
use LiveAdmin.Resource, schema: MyApp.Accounts.User
# callbacks here for escape hatches, like:
# - `delete_with`, an atom or MFA function to delete a record (set to false to disable deletes)
# - `actions`, list of atoms or MFAs that identify a function that operates on a record
end
....
# router.ex
live_admin "/admin" do
admin_resource "/accounts", MyApp.Admin.Accounts
end
Pros
moon
as a dependecy could easily add a backoffice without adding lots of frontend code to their repo think of same DX as LiveDashboard, fast plug-n-playCons
Hey, very nice document!
There was any alternative taken in consideration? I believe that in when decisions like that are being documented it's vital to document also the alternatives taken into consideration, what would be the pros and cons for this alternatives and why the selected approach is preferable.
I can see the overral discussion been shaped around how much customization we want to provide to the user. Do we have this clearly defined already? If so would be interesting to document it also.
The generated table will have sortable and filterable columns, aligned with the fields in the original struct.
We have some examples of tables in balanced that only make sense together with their associations, like invoices and invoice rows, for instance, the data on the this 2 tables are complementary. The invoice_row table only appears inside the invoices show page, so managing this 2 entities on separate pages would provide us no value, even in a back office scenario. Were this use case taken into consideration? Do you believe this is relevant for other teams?
@gfrancischelli I would greatly appreciate having both of these options. In my opinion, both of them will require the same functionality under the hood - building forms, tables, and more based on the given datatype.
Furthermore, I see several additional advantages in having generated code, especially considering my numerous negative experiences with customer feedback for the auto-updates provided by the Moon library.
@ViniciusGaiaValente point by point:
What are the several advantages besides putting 1 more command between a potentially explosive upgrade and the user?
Furthermore, I see several additional advantages in having generated code, especially considering my numerous negative experiences with customer feedback for the auto-updates provided by the Moon library.
I don't think a design systems are difficult to upgrade by nature.
Would be more worth to explore what makes Moon upgrades so difficult in the first place and work to fix it
WDYT?
Let's consider both approaches: using a generator and a single CRUD component (as proposed by @gfrancischelli). Initially, both methods will appear identical as the generator will create several components, while the single CRUD component will generate the same interface.
Suppose we need to modify the behavior for all *_icon
fields. In the provided example, we will introduce the Table.IconColumn
component and utilize it to render all *_icon
fields instead of the Table.Column
component.
Both the generator and single CRUD component need to be updated. However, after updating the Moon library, users of the single CRUD component will immediately receive the update. On the other hand, generator users will need to execute a mix command for each table individually to apply the update. And thanks to CVS, generator users can selectively choose which update to apply to each column in each table.
The same for form, filters, ...
By following this approach, the MoonDS team can avoid encountering many issues regarding accidentally updated components in consuming projects.
Everybody who needs immediate updates is supposed to use a single CRUD component and can easily get the latest updates.
version 0.4
Purpose of the Proposal
The aim of this proposal is to streamline the frontend development process for common CRUD (Create, Read, Update, Delete) operations in the BO Templates area. This will be achieved by implementing a
mix
generator task that facilitates instant prototyping. The intention is to minimize the occurrence of breaking changes while adhering to the development standards of Phoenix.Workflow of the Proposal
The proposal should:
Subject of the Proposal
The proposal involves the creation of a generator task like
mix moon.scaffold <Your.Data.Type.Module>
, which closely resembles the Phoenix'smix phx.gen...
tasks.