You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The idea came up in #1149 to give the developers the ability to create their own custom field partials. They could then subsequently run the command whenever they want to create said new partial.
# 🚅 super scaffolding will insert new fields above this line.
]
end
For instance, we could make a hash like this to which we would add the custom field:
defvalid_partial_types{canvas_field: "canvas_field"# 🚅 super scaffolding will insert new fields above this line.}end
Then we could check for custom partial fields before hitting the conditional:
defpartial_namereturnoptions[:attribute]ifoptions[:attribute]returnvalid_field_partials[type.to_sym]ifvalid_field_partials[type.to_sym]
...
end
Updating the Transformer
Concerning the Transformer, I think most of the logic should be okay because most things are handled with an attribute object (for example, the partial name here).
I don't want to go out of the way to override the Transformer as well, so we could just add a new method to Attribute and, again, override it in the starter repository. We would then call that method in the Transformer to cover any extra custom scaffolding that we need for the partial.
The text was updated successfully, but these errors were encountered:
The idea came up in #1149 to give the developers the ability to create their own custom field partials. They could then subsequently run the command whenever they want to create said new partial.
cc/ @jagthedrummer @kaspth @pascallaliberte @andrewculver
An example from @jagthedrummer:
What we'll need to do:
rails g super_scaffold:field_type
)tangible_things
so we have a hook to catch when creating the new partial from a template)valid_partial_types
to Attribute class and other necessary filesvalid_partial_types
We will need a list of
valid_partial_types
or something similar to handle the conditional we have in the Attributes class inpartial_name
.https://github.com/bullet-train-co/bullet_train-core/blob/509c34602cfde35c7aa0fd583e459d24f982058b/bullet_train-super_scaffolding/lib/scaffolding/attribute.rb#L126-L129
I'm thinking we can override
partial_name
in the starter repository, similar to what we do in the teams controller, etc.bullet_train/app/controllers/account/teams_controller.rb
Lines 6 to 10 in 0211217
For instance, we could make a hash like this to which we would add the custom field:
Then we could check for custom partial fields before hitting the conditional:
Updating the Transformer
Concerning the Transformer, I think most of the logic should be okay because most things are handled with an
attribute
object (for example, the partial name here).https://github.com/bullet-train-co/bullet_train-core/blob/509c34602cfde35c7aa0fd583e459d24f982058b/bullet_train-super_scaffolding/lib/scaffolding/transformer.rb#L822-L824
There might be some things that we aren't catching though, so we'll just have to proceed with caution.
There are also some minor partial-based discrepancies like this:
https://github.com/bullet-train-co/bullet_train-core/blob/509c34602cfde35c7aa0fd583e459d24f982058b/bullet_train-super_scaffolding/lib/scaffolding/transformer.rb#L826-L828
I don't want to go out of the way to override the Transformer as well, so we could just add a new method to
Attribute
and, again, override it in the starter repository. We would then call that method in the Transformer to cover any extra custom scaffolding that we need for the partial.The text was updated successfully, but these errors were encountered: