Class: CrudComponents::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/crud_components/install/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#copy_stimulus_controllersObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/generators/crud_components/install/install_generator.rb', line 13

def copy_stimulus_controllers
  copy_file 'crud_filter_controller.js', 'app/javascript/controllers/crud_filter_controller.js'
  copy_file 'crud_multiselect_controller.js', 'app/javascript/controllers/crud_multiselect_controller.js'
  copy_file 'crud_select_controller.js', 'app/javascript/controllers/crud_select_controller.js'
  copy_file 'crud_columns_controller.js', 'app/javascript/controllers/crud_columns_controller.js'
  say <<~NOTE

    Load the gem's stylesheet (it makes the column picker float; everything
    else is plain Bootstrap). Either is fine:
      - layout <head>:           <%= crud_components_styles %>   (works under any
        asset setup — cssbundling/sass, importmap, sprockets, propshaft)
      - or, asset-pipeline hosts: <%= stylesheet_link_tag "crud_components" %>

    The Stimulus controllers are optional — everything works without them.
    - crud-filter: strip empty params on submit + auto-submit inline selects.
    - crud-multiselect: turn a habtm `<select multiple>` into a chips + add picker.
    - crud-select: "select all" / per-group checkboxes + a live count for bulk actions.
    - crud-columns: drag-to-reorder the column picker (ticking columns works without it).
    Register them (stimulus-rails with importmap does this automatically via
    controllers/index.js; otherwise):

      application.register("crud-filter", CrudFilterController)
      application.register("crud-multiselect", CrudMultiselectController)
      application.register("crud-select", CrudSelectController)
      application.register("crud-columns", CrudColumnsController)

  NOTE
end

#create_initializerObject



9
10
11
# File 'lib/generators/crud_components/install/install_generator.rb', line 9

def create_initializer
  copy_file 'initializer.rb', 'config/initializers/crud_components.rb'
end