Class: Administrate::Generators::DashboardGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Administrate::Generators::DashboardGenerator
- Defined in:
- lib/generators/administrate/dashboard/dashboard_generator.rb
Constant Summary collapse
- ATTRIBUTE_TYPE_MAPPING =
{ boolean: "Field::Boolean", date: "Field::Date", datetime: "Field::DateTime", enum: "Field::Select", float: "Field::Number", integer: "Field::Number", time: "Field::Time", text: "Field::Text", string: "Field::String", uuid: "Field::String" }
- ATTRIBUTE_OPTIONS_MAPPING =
{ # procs must be defined in one line! enum: {searchable: false, collection: ->(field) { field.resource.class.send(field.attribute.to_s.pluralize).keys }}, float: {decimals: 2} }
- DEFAULT_FIELD_TYPE =
"Field::String.with_options(searchable: false)"
- COLLECTION_ATTRIBUTE_LIMIT =
4
- READ_ONLY_ATTRIBUTES =
%w[id created_at updated_at]
Instance Method Summary collapse
Instance Method Details
#create_dashboard_definition ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/generators/administrate/dashboard/dashboard_generator.rb', line 39 def create_dashboard_definition scope = regular_class_path.join("/") template( "dashboard.rb.erb", Rails.root.join("app/dashboards/#{scope}/#{file_name}_dashboard.rb") ) end |
#create_resource_controller ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/generators/administrate/dashboard/dashboard_generator.rb', line 48 def create_resource_controller scope = "#{namespace}/#{regular_class_path.join("/")}" destination = Rails.root.join( "app/controllers/#{scope}/#{file_name.pluralize}_controller.rb" ) template("controller.rb.erb", destination) end |