Class: Terrazzo::Generators::FieldGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Terrazzo::Generators::FieldGenerator
- Defined in:
- lib/generators/terrazzo/field/field_generator.rb
Instance Method Summary collapse
Instance Method Details
#create_field_class ⇒ Object
11 12 13 14 |
# File 'lib/generators/terrazzo/field/field_generator.rb', line 11 def create_field_class template "field.rb.erb", "app/fields/#{file_name}_field.rb" end |
#create_jsx_components ⇒ Object
16 17 18 19 20 21 |
# File 'lib/generators/terrazzo/field/field_generator.rb', line 16 def create_jsx_components %w[IndexField ShowField FormField].each do |component| template "#{component}.jsx.erb", "app/views/#{namespace_name}/fields/#{file_name}/#{component}.jsx" end end |
#register_in_barrel ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/generators/terrazzo/field/field_generator.rb', line 23 def = File.join(destination_root, "app/views/#{namespace_name}/fields/index.js") return unless File.exist?() registration = <<~JS // #{class_name} - custom field export { IndexField as #{class_name}IndexField } from "./#{file_name}/IndexField"; export { ShowField as #{class_name}ShowField } from "./#{file_name}/ShowField"; export { FormField as #{class_name}FormField } from "./#{file_name}/FormField"; JS append_to_file "app/views/#{namespace_name}/fields/index.js", registration say "\nCustom field '#{file_name}' registered in fields/index.js.", :green say "Use it in your dashboard:" say " #{file_name}: Terrazzo::Field::#{class_name}," end |