infold 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +410 -21
- data/Rakefile +0 -5
- data/lib/generators/infold/controller_generator.rb +56 -0
- data/lib/generators/infold/decorator_generator.rb +31 -0
- data/lib/generators/infold/install_generator.rb +98 -0
- data/lib/generators/infold/model_generator.rb +31 -0
- data/lib/generators/infold/resource_generator.rb +12 -0
- data/lib/generators/infold/scaffold_generator.rb +16 -0
- data/lib/generators/infold/search_form_generator.rb +23 -0
- data/lib/generators/infold/templates/controller.rb.tt +70 -0
- data/lib/generators/infold/templates/decorator.rb.tt +6 -0
- data/lib/generators/infold/templates/install/app/components/admin/association_field_component.html.haml +10 -0
- data/lib/generators/infold/templates/install/app/components/admin/association_field_component.rb +25 -0
- data/lib/generators/infold/templates/install/app/components/admin/badge_component.rb +18 -0
- data/lib/generators/infold/templates/install/app/components/admin/checkbox_component.html.haml +4 -0
- data/lib/generators/infold/templates/install/app/components/admin/checkbox_component.rb +22 -0
- data/lib/generators/infold/templates/install/app/components/admin/datetime_component.html.haml +13 -0
- data/lib/generators/infold/templates/install/app/components/admin/datetime_component.rb +10 -0
- data/lib/generators/infold/templates/install/app/components/admin/fieldset_component.html.haml +12 -0
- data/lib/generators/infold/templates/install/app/components/admin/fieldset_component.rb +73 -0
- data/lib/generators/infold/{install/templates/app/components/admin/form → templates/install/app/components/admin}/file_upload_component.html.haml +2 -6
- data/lib/generators/infold/templates/install/app/components/admin/file_upload_component.rb +10 -0
- data/lib/generators/infold/templates/install/app/components/admin/input_group_component.html.haml +6 -0
- data/lib/generators/infold/templates/install/app/components/admin/input_group_component.rb +10 -0
- data/lib/generators/infold/templates/install/app/components/admin/invalid_message_component.rb +17 -0
- data/lib/generators/infold/templates/install/app/components/admin/label_component.rb +16 -0
- data/lib/generators/infold/templates/install/app/components/admin/radio_component.html.haml +4 -0
- data/lib/generators/infold/templates/install/app/components/admin/radio_component.rb +22 -0
- data/lib/generators/infold/{install/templates → templates/install}/app/components/admin/remote_modal_component.html.haml +4 -3
- data/lib/generators/infold/templates/install/app/components/admin/remote_modal_component.rb +14 -0
- data/lib/generators/infold/templates/install/app/components/admin/select_component.rb +26 -0
- data/lib/generators/infold/templates/install/app/components/admin/sortable_component.html.haml +2 -0
- data/lib/generators/infold/templates/install/app/components/admin/sortable_component.rb +35 -0
- data/lib/generators/infold/templates/install/app/components/admin/switch_component.html.haml +3 -0
- data/lib/generators/infold/templates/install/app/components/admin/switch_component.rb +17 -0
- data/lib/generators/infold/templates/install/app/components/admin/text_component.rb +40 -0
- data/lib/generators/infold/{install/templates → templates/install}/app/controllers/admin/admin_users/registrations_controller.rb +0 -0
- data/lib/generators/infold/{install/templates → templates/install}/app/controllers/admin/admin_users/sessions_controller.rb +0 -0
- data/lib/generators/infold/{install/templates → templates/install}/app/controllers/admin/base_controller.rb +3 -3
- data/lib/generators/infold/{install/templates → templates/install}/app/controllers/admin/errors_controller.rb +0 -0
- data/lib/generators/infold/{install/templates → templates/install}/app/controllers/admin/turbo_devise_controller.rb +0 -0
- data/lib/generators/infold/{install/templates → templates/install}/app/controllers/concerns/admin/error_handlers.rb +1 -0
- data/lib/generators/infold/{install/templates/app/forms/admin/search_form_base.rb → templates/install/app/forms/admin/base_search_form.rb} +1 -1
- data/lib/generators/infold/templates/install/app/helpers/admin_helper.rb +23 -0
- data/lib/generators/infold/templates/install/app/javascript/admin/admin.css +188 -0
- data/lib/generators/infold/templates/install/app/javascript/admin/admin.scss +195 -0
- data/{app/javascript → lib/generators/infold/templates/install/app/javascript/admin}/controllers/application.js +0 -0
- data/lib/generators/infold/{install/templates → templates/install/app}/javascript/admin/controllers/datepicker_controller.js +1 -1
- data/{app/javascript → lib/generators/infold/templates/install/app/javascript/admin}/controllers/flash_controller.js +0 -0
- data/lib/generators/infold/{install/templates → templates/install/app}/javascript/admin/controllers/index.js +0 -0
- data/lib/generators/infold/{install/templates → templates/install/app}/javascript/admin/controllers/index_page_controller.js +0 -0
- data/lib/generators/infold/{install/templates → templates/install/app}/javascript/admin/controllers/nested_form_controller.js +0 -0
- data/lib/generators/infold/{install/templates → templates/install/app}/javascript/admin/controllers/relation_search_controller.js +0 -0
- data/lib/generators/infold/{install/templates → templates/install/app}/javascript/admin/controllers/remote_modal_controller.js +7 -7
- data/lib/generators/infold/{install/templates → templates/install/app}/javascript/admin/controllers/timepicker_controller.js +0 -0
- data/lib/generators/infold/templates/install/app/javascript/admin.js +9 -0
- data/lib/generators/infold/{install/templates → templates/install}/app/models/concerns/admin/datetime_field_concern.rb +12 -12
- data/lib/generators/infold/{install/templates → templates/install}/app/views/admin/admin_users/registrations/edit.html.haml +4 -3
- data/lib/generators/infold/{install/templates → templates/install}/app/views/admin/admin_users/sessions/new.html.haml +2 -2
- data/lib/generators/infold/{install/templates → templates/install}/app/views/admin/common/_flash.html.haml +0 -0
- data/lib/generators/infold/templates/install/app/views/admin/common/_header_menu.html.haml +1 -0
- data/lib/generators/infold/{install/templates → templates/install}/app/views/admin/errors/bad_request.html.haml +0 -0
- data/lib/generators/infold/{install/templates → templates/install}/app/views/admin/errors/forbidden.html.haml +0 -0
- data/lib/generators/infold/{install/templates → templates/install}/app/views/admin/errors/internal_server_error.html.haml +0 -0
- data/lib/generators/infold/{install/templates → templates/install}/app/views/admin/errors/not_found.html.haml +0 -0
- data/lib/generators/infold/{install/templates → templates/install}/app/views/admin/kaminari/_first_page.html.haml +0 -0
- data/lib/generators/infold/{install/templates → templates/install}/app/views/admin/kaminari/_gap.html.haml +0 -0
- data/lib/generators/infold/{install/templates → templates/install}/app/views/admin/kaminari/_last_page.html.haml +0 -0
- data/lib/generators/infold/{install/templates → templates/install}/app/views/admin/kaminari/_next_page.html.haml +0 -0
- data/lib/generators/infold/{install/templates → templates/install}/app/views/admin/kaminari/_page.html.haml +0 -0
- data/lib/generators/infold/{install/templates → templates/install}/app/views/admin/kaminari/_paginator.html.haml +0 -0
- data/lib/generators/infold/{install/templates → templates/install}/app/views/admin/kaminari/_prev_page.html.haml +0 -0
- data/lib/generators/infold/{install/templates/app/views/layouts/admin.haml.tt → templates/install/app/views/layouts/admin.html.haml} +8 -12
- data/lib/generators/infold/templates/install/config/infold/admin_user.yml +31 -0
- data/lib/generators/infold/{install/templates → templates/install}/config/locales/infold.en.yml +3 -2
- data/lib/generators/infold/{install/templates → templates/install}/config/locales/infold.ja.yml +1 -0
- data/lib/generators/infold/{install/templates → templates/install}/config/routes/admin.rb +0 -0
- data/lib/generators/infold/templates/model.rb.tt +34 -0
- data/lib/generators/infold/templates/resource.yml.tt +29 -0
- data/lib/generators/infold/templates/search_form.rb.tt +23 -0
- data/lib/generators/infold/templates/views/_form.haml.tt +36 -0
- data/lib/generators/infold/templates/views/_form_association.haml.tt +9 -0
- data/lib/generators/infold/templates/views/_index_row.haml.tt +12 -0
- data/lib/generators/infold/templates/views/_show_content.haml.tt +39 -0
- data/lib/generators/infold/templates/views/_show_wrapper.haml.tt +15 -0
- data/lib/generators/infold/templates/views/edit.html+turbo_frame.haml.tt +15 -0
- data/lib/generators/infold/templates/views/form.turbo_stream.haml.tt +16 -0
- data/lib/generators/infold/templates/views/index.csv.ruby.tt +19 -0
- data/lib/generators/infold/templates/views/index.haml.tt +45 -0
- data/lib/generators/infold/templates/views/index.html+turbo_frame.haml.tt +41 -0
- data/lib/generators/infold/templates/views/new.html+turbo_frame.haml.tt +15 -0
- data/lib/generators/infold/templates/views/show.html+turbo_frame.haml.tt +4 -0
- data/lib/generators/infold/views/form_generator.rb +51 -0
- data/lib/generators/infold/views/index_generator.rb +37 -0
- data/lib/generators/infold/views/show_generator.rb +33 -0
- data/lib/generators/infold/views_generator.rb +13 -0
- data/lib/generators/infold_generator.rb +11 -0
- data/lib/infold/db_schema.rb +28 -0
- data/lib/infold/field.rb +104 -0
- data/lib/infold/field_group.rb +108 -0
- data/lib/infold/property/active_storage.rb +38 -0
- data/lib/infold/property/association.rb +81 -0
- data/lib/infold/property/condition.rb +60 -0
- data/lib/infold/property/decorator.rb +30 -0
- data/lib/infold/property/default_order.rb +14 -0
- data/lib/infold/property/enum.rb +30 -0
- data/lib/infold/property/form_element.rb +56 -0
- data/lib/infold/property/show_element.rb +26 -0
- data/lib/infold/property/validation.rb +38 -0
- data/lib/infold/railtie.rb +4 -0
- data/lib/infold/resource.rb +32 -0
- data/lib/infold/table.rb +25 -0
- data/lib/infold/version.rb +1 -1
- data/lib/infold/writers/base_writer.rb +45 -0
- data/lib/infold/writers/controller_writer.rb +69 -0
- data/lib/infold/writers/decorator_writer.rb +94 -0
- data/lib/infold/writers/model_writer.rb +159 -0
- data/lib/infold/writers/search_form_writer.rb +23 -0
- data/lib/infold/writers/views/base_writer.rb +91 -0
- data/lib/infold/writers/views/form_writer.rb +39 -0
- data/lib/infold/writers/views/index_writer.rb +51 -0
- data/lib/infold/writers/views/show_writer.rb +16 -0
- data/lib/infold/yaml_reader.rb +252 -0
- data/lib/infold.rb +1 -1
- data/lib/tasks/infold_tasks.rake +0 -121
- metadata +246 -405
- data/app/assets/builds/infold.css +0 -17147
- data/app/assets/builds/infold.css.map +0 -7
- data/app/assets/builds/infold.js +0 -17202
- data/app/assets/builds/infold.js.map +0 -7
- data/app/assets/config/infold_manifest.js +0 -0
- data/app/assets/stylesheets/infold.custom.css +0 -76
- data/app/assets/stylesheets/infold.custom.css.map +0 -1
- data/app/components/infold/input_fieldset_component.html.haml +0 -14
- data/app/components/infold/input_fieldset_component.rb +0 -22
- data/app/components/infold/radio_fieldset_component.html.haml +0 -11
- data/app/components/infold/radio_fieldset_component.rb +0 -14
- data/app/components/infold/select_fieldset_component.html.haml +0 -7
- data/app/components/infold/select_fieldset_component.rb +0 -15
- data/app/controllers/infold/app_view_forms_controller.rb +0 -64
- data/app/controllers/infold/app_view_shows_controller.rb +0 -60
- data/app/controllers/infold/application_controller.rb +0 -17
- data/app/controllers/infold/apps_controller.rb +0 -68
- data/app/controllers/infold/attachment_fields_controller.rb +0 -59
- data/app/controllers/infold/builds_controller.rb +0 -21
- data/app/controllers/infold/columns_controller.rb +0 -89
- data/app/controllers/infold/csv_columns_controller.rb +0 -43
- data/app/controllers/infold/form_associations_controller.rb +0 -57
- data/app/controllers/infold/menu_directories_controller.rb +0 -19
- data/app/controllers/infold/menus_controller.rb +0 -35
- data/app/controllers/infold/models_controller.rb +0 -28
- data/app/controllers/infold/pages_controller.rb +0 -8
- data/app/controllers/infold/search_conditions_controller.rb +0 -63
- data/app/controllers/infold/search_result_fields_controller.rb +0 -62
- data/app/controllers/infold/show_associations_controller.rb +0 -54
- data/app/controllers/infold/sync_dbs_controller.rb +0 -13
- data/app/decorators/infold/app_view_form_decorator.rb +0 -56
- data/app/decorators/infold/app_view_index_decorator.rb +0 -53
- data/app/decorators/infold/app_view_modal_decorator.rb +0 -13
- data/app/decorators/infold/app_view_show_decorator.rb +0 -26
- data/app/decorators/infold/attachment_field_decorator.rb +0 -40
- data/app/decorators/infold/build_decorator.rb +0 -15
- data/app/decorators/infold/column_display_decorator.rb +0 -59
- data/app/decorators/infold/csv_column_decorator.rb +0 -5
- data/app/decorators/infold/form_association_column_decorator.rb +0 -5
- data/app/decorators/infold/form_column_decorator.rb +0 -57
- data/app/decorators/infold/model_association_decorator.rb +0 -39
- data/app/decorators/infold/model_column_decorator.rb +0 -201
- data/app/decorators/infold/model_decorator.rb +0 -27
- data/app/decorators/infold/search_condition_decorator.rb +0 -101
- data/app/decorators/infold/search_result_column_decorator.rb +0 -5
- data/app/decorators/infold/show_association_column_decorator.rb +0 -5
- data/app/decorators/infold/show_association_decorator.rb +0 -13
- data/app/decorators/infold/show_field_decorator.rb +0 -5
- data/app/helpers/infold/application_helper.rb +0 -29
- data/app/javascript/admin.scss +0 -5
- data/app/javascript/controllers/attachment_field_controller.js +0 -19
- data/app/javascript/controllers/column_controller.js +0 -20
- data/app/javascript/controllers/index.js +0 -32
- data/app/javascript/controllers/menu_controller.js +0 -26
- data/app/javascript/controllers/menu_directory_controller.js +0 -16
- data/app/javascript/controllers/modal_controller.js +0 -15
- data/app/javascript/controllers/nested_form_controller.js +0 -32
- data/app/javascript/controllers/search_condition_controller.js +0 -41
- data/app/javascript/controllers/sortable_controller.js +0 -19
- data/app/javascript/infold.js +0 -22
- data/app/javascript/infold.scss +0 -68
- data/app/javascript/stylesheets/admin/common.scss +0 -112
- data/app/javascript/stylesheets/admin/form.scss +0 -52
- data/app/javascript/stylesheets/admin/index.scss +0 -93
- data/app/javascript/stylesheets/admin/modal.scss +0 -37
- data/app/javascript/stylesheets/admin/show.scss +0 -16
- data/app/jobs/infold/application_job.rb +0 -4
- data/app/mailers/infold/application_mailer.rb +0 -6
- data/app/models/concerns/infold/app_view_search_concern.rb +0 -72
- data/app/models/concerns/infold/form_column_concern.rb +0 -63
- data/app/models/infold/app.rb +0 -41
- data/app/models/infold/app_view.rb +0 -27
- data/app/models/infold/app_view_form.rb +0 -43
- data/app/models/infold/app_view_index.rb +0 -36
- data/app/models/infold/app_view_modal.rb +0 -21
- data/app/models/infold/app_view_show.rb +0 -47
- data/app/models/infold/application_record.rb +0 -7
- data/app/models/infold/attachment_field.rb +0 -35
- data/app/models/infold/build.rb +0 -35
- data/app/models/infold/csv_column.rb +0 -9
- data/app/models/infold/enum.rb +0 -12
- data/app/models/infold/form_association.rb +0 -41
- data/app/models/infold/form_association_attachment_field.rb +0 -5
- data/app/models/infold/form_association_column.rb +0 -5
- data/app/models/infold/form_association_field.rb +0 -7
- data/app/models/infold/form_attachment_field.rb +0 -5
- data/app/models/infold/form_column.rb +0 -5
- data/app/models/infold/form_field.rb +0 -7
- data/app/models/infold/menu_item.rb +0 -45
- data/app/models/infold/model.rb +0 -40
- data/app/models/infold/model_association.rb +0 -51
- data/app/models/infold/model_column.rb +0 -127
- data/app/models/infold/project.rb +0 -29
- data/app/models/infold/schema_rb.rb +0 -178
- data/app/models/infold/search_condition.rb +0 -62
- data/app/models/infold/search_result_attachment_field.rb +0 -5
- data/app/models/infold/search_result_column.rb +0 -6
- data/app/models/infold/search_result_field.rb +0 -12
- data/app/models/infold/show_association.rb +0 -42
- data/app/models/infold/show_association_attachment_field.rb +0 -5
- data/app/models/infold/show_association_column.rb +0 -5
- data/app/models/infold/show_association_field.rb +0 -8
- data/app/models/infold/show_attachment_field.rb +0 -7
- data/app/models/infold/show_column.rb +0 -7
- data/app/models/infold/show_field.rb +0 -11
- data/app/validators/infold/ruby_code_validator.rb +0 -9
- data/app/views/infold/app_view_forms/_bulk_form.html.haml +0 -16
- data/app/views/infold/app_view_forms/_tab.html.haml +0 -12
- data/app/views/infold/app_view_forms/show.html.haml +0 -7
- data/app/views/infold/app_view_shows/_bulk_form.html.haml +0 -15
- data/app/views/infold/app_view_shows/_tab.html.haml +0 -12
- data/app/views/infold/app_view_shows/show.html.haml +0 -7
- data/app/views/infold/app_view_shows/update.turbo_stream.haml +0 -1
- data/app/views/infold/application/_flash.html.haml +0 -6
- data/app/views/infold/apps/_form.html.haml +0 -30
- data/app/views/infold/apps/_page_header.html.haml +0 -5
- data/app/views/infold/apps/_tab.html.haml +0 -13
- data/app/views/infold/apps/create.turbo_stream.haml +0 -3
- data/app/views/infold/apps/edit.html.haml +0 -6
- data/app/views/infold/apps/new.html.haml +0 -8
- data/app/views/infold/apps/update.turbo_stream.haml +0 -3
- data/app/views/infold/associations/_form.html.haml +0 -18
- data/app/views/infold/associations/edit.html.haml +0 -5
- data/app/views/infold/attachment_fields/_form.html.haml +0 -51
- data/app/views/infold/attachment_fields/edit.html.haml +0 -7
- data/app/views/infold/attachment_fields/form.turbo_stream.haml +0 -4
- data/app/views/infold/attachment_fields/index.html.haml +0 -28
- data/app/views/infold/attachment_fields/new.html.haml +0 -7
- data/app/views/infold/builds/create.turbo_stream.haml +0 -8
- data/app/views/infold/builds/new.html.haml +0 -23
- data/app/views/infold/columns/_bulk_form.html.haml +0 -18
- data/app/views/infold/columns/_row.html.haml +0 -26
- data/app/views/infold/columns/_setting.html.haml +0 -42
- data/app/views/infold/columns/bulk.turbo_stream.haml +0 -3
- data/app/views/infold/columns/edit.html.haml +0 -5
- data/app/views/infold/columns/index.html.haml +0 -9
- data/app/views/infold/columns/update.turbo_stream.haml +0 -8
- data/app/views/infold/csv_columns/_bulk_form.html.haml +0 -14
- data/app/views/infold/csv_columns/_row.html.haml +0 -10
- data/app/views/infold/csv_columns/bulk.turbo_stream.haml +0 -3
- data/app/views/infold/csv_columns/index.html.haml +0 -7
- data/app/views/infold/enums/_form.html.haml +0 -13
- data/app/views/infold/enums/_index.html.haml +0 -27
- data/app/views/infold/enums/index.html.haml +0 -5
- data/app/views/infold/form_association_attachment_fields/_form.html.haml +0 -13
- data/app/views/infold/form_association_columns/_form.html.haml +0 -20
- data/app/views/infold/form_associations/_bulk_form.html.haml +0 -16
- data/app/views/infold/form_associations/_form.html.haml +0 -19
- data/app/views/infold/form_associations/show.html.haml +0 -7
- data/app/views/infold/form_associations/update.turbo_stream.haml +0 -1
- data/app/views/infold/form_attachment_fields/_form.html.haml +0 -14
- data/app/views/infold/form_columns/_form.html.haml +0 -21
- data/app/views/infold/menu_directories/_item.html.haml +0 -20
- data/app/views/infold/menu_directories/create.turbo_stream.haml +0 -2
- data/app/views/infold/menu_directories/destroy.turbo_stream.haml +0 -5
- data/app/views/infold/menus/_app.html.haml +0 -10
- data/app/views/infold/menus/_items.html.haml +0 -7
- data/app/views/infold/menus/edit.html.haml +0 -23
- data/app/views/infold/menus/update.turbo_stream.haml +0 -3
- data/app/views/infold/models/_form.html.haml +0 -12
- data/app/views/infold/models/_tab.html.haml +0 -7
- data/app/views/infold/models/edit.html.haml +0 -9
- data/app/views/infold/models/update.turbo_stream.haml +0 -3
- data/app/views/infold/search_conditions/_bulk_form.html.haml +0 -24
- data/app/views/infold/search_conditions/_column_options.html.haml +0 -3
- data/app/views/infold/search_conditions/_form_kind_options.html.haml +0 -3
- data/app/views/infold/search_conditions/_row.html.haml +0 -31
- data/app/views/infold/search_conditions/_sign_options.html.haml +0 -3
- data/app/views/infold/search_conditions/_tab.html.haml +0 -12
- data/app/views/infold/search_conditions/bulk.turbo_stream.haml +0 -3
- data/app/views/infold/search_conditions/index.html.haml +0 -7
- data/app/views/infold/search_conditions/refresh_columns.turbo_stream.haml +0 -6
- data/app/views/infold/search_conditions/refresh_form_kinds.turbo_stream.haml +0 -4
- data/app/views/infold/search_conditions/refresh_signs.turbo_stream.haml +0 -2
- data/app/views/infold/search_result_attachment_fields/_form.html.haml +0 -12
- data/app/views/infold/search_result_columns/_form.html.haml +0 -12
- data/app/views/infold/search_result_fields/_bulk_form.html.haml +0 -23
- data/app/views/infold/search_result_fields/_row.html.haml +0 -12
- data/app/views/infold/search_result_fields/bulk.turbo_stream.haml +0 -3
- data/app/views/infold/search_result_fields/index.html.haml +0 -7
- data/app/views/infold/show_association_attachment_fields/_form.html.haml +0 -12
- data/app/views/infold/show_association_columns/_form.html.haml +0 -12
- data/app/views/infold/show_associations/_bulk_form.html.haml +0 -15
- data/app/views/infold/show_associations/_form.html.haml +0 -14
- data/app/views/infold/show_associations/show.html.haml +0 -7
- data/app/views/infold/show_associations/update.turbo_stream.haml +0 -1
- data/app/views/infold/show_attachment_fields/_form.html.haml +0 -12
- data/app/views/infold/show_columns/_form.html.haml +0 -12
- data/app/views/infold/sync_dbs/create.turbo_stream.haml +0 -1
- data/app/views/infold/sync_dbs/show.html.haml +0 -11
- data/app/views/layouts/infold/application.html.haml +0 -112
- data/config/database.yml +0 -11
- data/config/initializers/infold_assets.rb +0 -12
- data/config/initializers/infold_locale.rb +0 -1
- data/config/locales/infold/ar/app/en.yml +0 -6
- data/config/locales/infold/ar/app/ja.yml +0 -6
- data/config/locales/infold/ar/app_view/en.yml +0 -4
- data/config/locales/infold/ar/app_view/ja.yml +0 -4
- data/config/locales/infold/ar/app_view_form/en.yml +0 -10
- data/config/locales/infold/ar/app_view_form/ja.yml +0 -10
- data/config/locales/infold/ar/app_view_index/en.yml +0 -12
- data/config/locales/infold/ar/app_view_index/ja.yml +0 -12
- data/config/locales/infold/ar/app_view_modal/en.yml +0 -6
- data/config/locales/infold/ar/app_view_modal/ja.yml +0 -6
- data/config/locales/infold/ar/app_view_show/en.yml +0 -9
- data/config/locales/infold/ar/app_view_show/ja.yml +0 -9
- data/config/locales/infold/ar/csv_column/en.yml +0 -8
- data/config/locales/infold/ar/csv_column/ja.yml +0 -8
- data/config/locales/infold/ar/form_association_column/ja.yml +0 -15
- data/config/locales/infold/ar/form_column/ja.yml +0 -15
- data/config/locales/infold/ar/menu_item/ja.yml +0 -6
- data/config/locales/infold/ar/model/ja.yml +0 -11
- data/config/locales/infold/ar/model_association/en.yml +0 -6
- data/config/locales/infold/ar/model_association/ja.yml +0 -10
- data/config/locales/infold/ar/model_column/en.yml +0 -34
- data/config/locales/infold/ar/model_column/ja.yml +0 -34
- data/config/locales/infold/ar/search_condition/en.yml +0 -30
- data/config/locales/infold/ar/search_condition/ja.yml +0 -30
- data/config/locales/infold/ar/search_result_field/en.yml +0 -9
- data/config/locales/infold/ar/search_result_field/ja.yml +0 -9
- data/config/locales/infold/en.yml +0 -40
- data/config/locales/infold/ja.yml +0 -41
- data/config/routes.rb +0 -40
- data/db/infold_test.sqlite3 +0 -0
- data/db/migrate/20220419050641_create_infold_projects.rb +0 -9
- data/db/migrate/20220419051049_create_infold_models.rb +0 -15
- data/db/migrate/20220419051601_create_infold_columns.rb +0 -23
- data/db/migrate/20220419051718_create_infold_attachment_fields.rb +0 -15
- data/db/migrate/20220419052017_create_infold_model_associations.rb +0 -16
- data/db/migrate/20220419052154_create_infold_apps.rb +0 -10
- data/db/migrate/20220419052320_create_infold_app_views.rb +0 -14
- data/db/migrate/20220419052450_create_infold_search_conditions.rb +0 -14
- data/db/migrate/20220419052707_create_infold_search_result_fields.rb +0 -18
- data/db/migrate/20220419053338_create_infold_show_fields.rb +0 -18
- data/db/migrate/20220419053425_create_infold_show_association_fields.rb +0 -15
- data/db/migrate/20220419060937_create_infold_form_fields.rb +0 -19
- data/db/migrate/20220419061148_create_infold_form_association_fields.rb +0 -16
- data/db/migrate/20220419061725_create_infold_enums.rb +0 -16
- data/db/migrate/20220419062020_create_infold_menu_items.rb +0 -16
- data/db/migrate/20220419062119_create_infold_csv_columns.rb +0 -12
- data/db/schema.rb +0 -260
- data/lib/generators/infold/app/app_generator.rb +0 -134
- data/lib/generators/infold/app/templates/controller.rb.tt +0 -100
- data/lib/generators/infold/app/templates/search_form.rb.tt +0 -31
- data/lib/generators/infold/app/templates/views/_association_fields.haml.tt +0 -16
- data/lib/generators/infold/app/templates/views/_detail.haml.tt +0 -100
- data/lib/generators/infold/app/templates/views/_detail_modal_wrapper.haml.tt +0 -9
- data/lib/generators/infold/app/templates/views/_form.haml.tt +0 -66
- data/lib/generators/infold/app/templates/views/_index_row.haml.tt +0 -17
- data/lib/generators/infold/app/templates/views/_show_operation.haml.tt +0 -5
- data/lib/generators/infold/app/templates/views/edit+turbo_frame.haml.tt +0 -13
- data/lib/generators/infold/app/templates/views/edit.haml.tt +0 -10
- data/lib/generators/infold/app/templates/views/form.turbo_stream.haml.tt +0 -17
- data/lib/generators/infold/app/templates/views/index+turbo_frame.haml.tt +0 -43
- data/lib/generators/infold/app/templates/views/index.csv.ruby.tt +0 -18
- data/lib/generators/infold/app/templates/views/index.haml.tt +0 -49
- data/lib/generators/infold/app/templates/views/new+turbo_frame.haml.tt +0 -14
- data/lib/generators/infold/app/templates/views/new.haml.tt +0 -12
- data/lib/generators/infold/app/templates/views/show+turbo_frame.haml.tt +0 -4
- data/lib/generators/infold/app/templates/views/show.haml.tt +0 -9
- data/lib/generators/infold/install/install_generator.rb +0 -151
- data/lib/generators/infold/install/templates/app/components/admin/enum_badge_component.html.haml +0 -4
- data/lib/generators/infold/install/templates/app/components/admin/enum_badge_component.rb +0 -11
- data/lib/generators/infold/install/templates/app/components/admin/form/checkbox_fieldset_component.html.haml +0 -11
- data/lib/generators/infold/install/templates/app/components/admin/form/checkbox_fieldset_component.rb +0 -15
- data/lib/generators/infold/install/templates/app/components/admin/form/datetime_fieldset_component.html.haml +0 -20
- data/lib/generators/infold/install/templates/app/components/admin/form/datetime_fieldset_component.rb +0 -13
- data/lib/generators/infold/install/templates/app/components/admin/form/file_upload_component.rb +0 -12
- data/lib/generators/infold/install/templates/app/components/admin/form/input_fieldset_component.html.haml +0 -14
- data/lib/generators/infold/install/templates/app/components/admin/form/input_fieldset_component.rb +0 -24
- data/lib/generators/infold/install/templates/app/components/admin/form/radio_fieldset_component.html.haml +0 -11
- data/lib/generators/infold/install/templates/app/components/admin/form/radio_fieldset_component.rb +0 -15
- data/lib/generators/infold/install/templates/app/components/admin/form/relation_fieldset_component.html.haml +0 -17
- data/lib/generators/infold/install/templates/app/components/admin/form/relation_fieldset_component.rb +0 -21
- data/lib/generators/infold/install/templates/app/components/admin/form/select_fieldset_component.html.haml +0 -7
- data/lib/generators/infold/install/templates/app/components/admin/form/select_fieldset_component.rb +0 -16
- data/lib/generators/infold/install/templates/app/components/admin/form/switch_element_component.html.haml +0 -4
- data/lib/generators/infold/install/templates/app/components/admin/form/switch_element_component.rb +0 -12
- data/lib/generators/infold/install/templates/app/components/admin/remote_modal_component.rb +0 -21
- data/lib/generators/infold/install/templates/app/components/admin/sortable_th_component.html.haml +0 -4
- data/lib/generators/infold/install/templates/app/components/admin/sortable_th_component.rb +0 -27
- data/lib/generators/infold/install/templates/app/controllers/admin/admin_users_controller.rb +0 -62
- data/lib/generators/infold/install/templates/app/helpers/admin_helper.rb +0 -37
- data/lib/generators/infold/install/templates/app/views/admin/admin_users/_detail.html.haml +0 -14
- data/lib/generators/infold/install/templates/app/views/admin/admin_users/_form.html.haml +0 -6
- data/lib/generators/infold/install/templates/app/views/admin/admin_users/_index_row.html.haml +0 -9
- data/lib/generators/infold/install/templates/app/views/admin/admin_users/_show_operation.html.haml +0 -4
- data/lib/generators/infold/install/templates/app/views/admin/admin_users/edit.html+turbo_frame.haml +0 -11
- data/lib/generators/infold/install/templates/app/views/admin/admin_users/edit.html.haml +0 -10
- data/lib/generators/infold/install/templates/app/views/admin/admin_users/form.turbo_stream.haml +0 -4
- data/lib/generators/infold/install/templates/app/views/admin/admin_users/index.html.haml +0 -21
- data/lib/generators/infold/install/templates/app/views/admin/admin_users/new.html+turbo_frame.haml +0 -11
- data/lib/generators/infold/install/templates/app/views/admin/admin_users/new.html.haml +0 -10
- data/lib/generators/infold/install/templates/app/views/admin/admin_users/show.html+turbo_frame.haml +0 -11
- data/lib/generators/infold/install/templates/app/views/admin/admin_users/show.html.haml +0 -8
- data/lib/generators/infold/install/templates/app/views/admin/common/_header_menu.html.haml +0 -0
- data/lib/generators/infold/install/templates/javascript/admin/controllers/application.js +0 -9
- data/lib/generators/infold/install/templates/javascript/admin/controllers/flash_controller.js +0 -10
- data/lib/generators/infold/install/templates/javascript/admin/stylesheets/custom.css +0 -290
- data/lib/generators/infold/install/templates/javascript/admin/stylesheets/custom.css.map +0 -1
- data/lib/generators/infold/install/templates/javascript/esbuild/admin.js +0 -10
- data/lib/generators/infold/install/templates/javascript/webpacker/admin.js +0 -9
- data/lib/generators/infold/model/model_generator.rb +0 -50
- data/lib/generators/infold/model/templates/decorator.rb.tt +0 -10
- data/lib/generators/infold/model/templates/model.rb.tt +0 -59
- data/lib/generators/infold/project/project_generator.rb +0 -66
- data/lib/generators/infold/project/templates/_header_menu.haml.tt +0 -17
- data/lib/generators/infold/project/templates/locales/form.yml.tt +0 -11
- data/lib/generators/infold/project/templates/locales/model.yml.tt +0 -43
- data/lib/generators/infold/project/templates/relation_fieldset_component.rb.tt +0 -30
- data/lib/infold/engine.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34854ed0db701ed065426e414a75459e5b65b9925da9ebb3ac61ba9cd39ad5f5
|
4
|
+
data.tar.gz: 5bb21994d45263520774efb5a991613dffddf17f17020a7456917eb6e3f36b7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a65c780a5bd993bc9dd2a081854f514d0c98d902fb0796dbb9d469317ce1f46989f16a8bd6afc3750cacf5ca0de076bdfc1ee6e02469ae18b681d6d251d64b3c
|
7
|
+
data.tar.gz: df9d3d3ff2cc9ab70a783ddac5312ed14475ca9110aa7329a6237775c29bd32986b4ab022fd655e0d0e8a540fa965ec1a9c612ac030c92c52b10106935b94ae8
|
data/README.md
CHANGED
@@ -1,33 +1,422 @@
|
|
1
1
|
# Infold
|
2
|
-
|
2
|
+
Infold provides Scaffolding functionality specifically for Internal tools.
|
3
|
+
CRUD (Create,Read,Update,Delete) applications with an easy-to-use UI can be built instantly.
|
4
|
+
The generated code is highly readable and customizable, allowing for easy additional customization.
|
5
|
+
Supports Rails >= 7.0 and Hotwire.
|
3
6
|
|
4
|
-
##
|
5
|
-
-
|
6
|
-
-
|
7
|
-
-
|
7
|
+
## Purpose
|
8
|
+
- Quickly and easily build Internal tools with all the functionality you need
|
9
|
+
- No need for a designer, just a developer to create a usable UI/UX
|
10
|
+
- Easy customization with YAML and Scaffold instead of DSL development
|
8
11
|
|
9
|
-
##
|
10
|
-
|
12
|
+
## Installation
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
```ruby
|
15
|
+
gem 'indold', require: false
|
16
|
+
```
|
11
17
|
|
12
|
-
|
13
|
-
|
18
|
+
In addition, infold uses the following Gem, add these lines to your Gemfile too.
|
19
|
+
```ruby
|
20
|
+
gem 'devise' # Certification
|
21
|
+
gem 'haml-rails' # HAML
|
22
|
+
gem 'kaminari' # Pagination
|
23
|
+
gem 'view_component' # View Component
|
24
|
+
gem 'active_decorator' # Decoration
|
25
|
+
gem 'enum_help' # Enum Helpers
|
26
|
+
```
|
14
27
|
|
15
|
-
|
16
|
-
<div>After configured, infold will automatically generate source code according to your settings. The code is written in plain Ruby on Rails, so easy-to-customize. Feel free to customize your code to suit your needs.</div>
|
28
|
+
Then run `bundle install`
|
17
29
|
|
18
|
-
|
30
|
+
Next, you need to run the generator:
|
31
|
+
```shell
|
32
|
+
$ rails generate infold:install
|
33
|
+
```
|
19
34
|
|
20
|
-
|
35
|
+
At this point, several common files for CRUD applications are generated.
|
36
|
+
|
37
|
+
### Devise Setup
|
38
|
+
With the above installation, Devise is also installed. Please migrate for Device user's table.
|
39
|
+
```shell
|
40
|
+
$ rails db:migrate
|
41
|
+
```
|
42
|
+
|
43
|
+
Create a test user for Devise from rails console.
|
44
|
+
```shell
|
45
|
+
$ rails console
|
46
|
+
```
|
47
|
+
```ruby
|
48
|
+
AdminUser.create(email: 'user@example.com', password: 'password')
|
49
|
+
```
|
50
|
+
|
51
|
+
## Basic Usage
|
52
|
+
Specify the target model for CRUD and generate code from the generator.
|
53
|
+
The following is an example of a Product model.
|
54
|
+
```shell
|
55
|
+
$ rails generate infold Product
|
56
|
+
```
|
57
|
+
|
58
|
+
This will generate several files, including Controller and View.
|
59
|
+
You can check it by starting rails from `bin/dev` and accessing `http://localhost:3000/admin`.
|
60
|
+
|
61
|
+

|
62
|
+
|
63
|
+
By executing the above command, each directory such as controllers, models, and views automatically generates code to run the internal tools.
|
64
|
+
This is a mechanism similar to that of Rails' Scaffold, and it is possible to implement additional necessary functions based on this.
|
65
|
+
|
66
|
+
However, **this is not the only functionality that can be generated from Infold**.
|
67
|
+
Let's customize YAML and automatically generate the necessary functions by referring to the following contents.
|
68
|
+
|
69
|
+
## More Customization
|
70
|
+
infold can be customized more by configuring YAML. YAML is generated in the `config/infold` directory.
|
71
|
+
After setting up YAML, the code is regenerated by executing the following command.
|
72
|
+
```shell
|
73
|
+
$ rails generate infold:scaffold Product
|
74
|
+
```
|
75
|
+
|
76
|
+
### Validation
|
77
|
+
In `model`.`validate`, you can define validation for each field.
|
78
|
+
#### Example
|
79
|
+
The following example shows the `title` and `price` fields with required validation and the `price` field with numeric (and greater than or equal to 0) validation.
|
80
|
+
```yaml
|
81
|
+
model:
|
82
|
+
validate:
|
83
|
+
title:
|
84
|
+
- presence
|
85
|
+
price:
|
86
|
+
- presence
|
87
|
+
- numericality:
|
88
|
+
greater_than_or_equal_to: 0
|
89
|
+
```
|
90
|
+
Then validation is activated on the form screen.
|
91
|
+
|
92
|
+

|
93
|
+
|
94
|
+
### Enum
|
95
|
+
In `model`.`enum`, you can define enum field.
|
96
|
+
#### Example
|
97
|
+
The following example defines an enum in the `status` field and sets the elements to `ordered`(value: 1), `charged`(value: 2), and `delivered`(value: 3).
|
98
|
+
```yaml
|
99
|
+
model:
|
100
|
+
enum:
|
101
|
+
status:
|
102
|
+
ordered: 1
|
103
|
+
charged: 2
|
104
|
+
delivered: 3
|
105
|
+
```
|
106
|
+
|
107
|
+
Then the screen displays the Name of the Enum.
|
108
|
+
|
109
|
+

|
110
|
+
|
111
|
+
#### Colored Enum
|
112
|
+
Enum also allows you to specify a color for each element. The available colors are `blue` `azure` `indigo` `purple` `pink` `red` `orange` `yellow` `lime` `green` `teal` `cyan`.
|
113
|
+
#### Example
|
114
|
+
```yaml
|
115
|
+
model:
|
116
|
+
enum:
|
117
|
+
status:
|
118
|
+
ordered:
|
119
|
+
value: 1
|
120
|
+
color: blue
|
121
|
+
charged:
|
122
|
+
value: 2
|
123
|
+
color: pink
|
124
|
+
delivered:
|
125
|
+
value: 3
|
126
|
+
color: green
|
127
|
+
```
|
128
|
+
|
129
|
+
It will then be displayed with a colored badge for easy identification.
|
130
|
+
|
131
|
+

|
132
|
+
|
133
|
+
### Decorator
|
134
|
+
In `model`.`decorator`, you can define simple decorations such as comma-separated numbers and units.
|
135
|
+
#### Example
|
136
|
+
In the following example, the `price` field displays a comma-separated number and "$" as the unit of measure in the front, and the `weight` field displays "Kg" in the back.
|
137
|
+
```yaml
|
138
|
+
model:
|
139
|
+
decorator:
|
140
|
+
price:
|
141
|
+
prepend: $
|
142
|
+
digit: true
|
143
|
+
weight:
|
144
|
+
append: Kg
|
145
|
+
```
|
146
|
+
|
147
|
+
Price is displayed as comma-separated and with units.
|
148
|
+
|
149
|
+

|
150
|
+
|
151
|
+
### ActiveStorage
|
152
|
+
Infold supports ActiveStorage. If you want to store files such as images or PDFs, define them in `model`. `active_storage`.
|
153
|
+
|
154
|
+
**As a prerequisite, ActiveStorage must be installed in the project.**
|
155
|
+
#### Example
|
156
|
+
In the following example, define the use of ActiveStorage with the name `photo` and specify "image" as kind (for PDF, etc., specify "file" as kind).
|
157
|
+
```yaml
|
158
|
+
model:
|
159
|
+
active_storage:
|
160
|
+
photo:
|
161
|
+
kind: image
|
162
|
+
```
|
163
|
+
|
164
|
+
Then images stored in ActiveStorage can be displayed.
|
165
|
+
|
166
|
+

|
167
|
+
|
168
|
+
### Association
|
169
|
+
Infold supports association with other models such as `has_many` and `belongs_to`. By defining `model`.`association`, it is possible to bulk register and reference related models.
|
170
|
+
### belongs_to
|
171
|
+
For example, the relation `purchase` belongs_to `customer` is defined as follows:
|
172
|
+
```yaml
|
173
|
+
model:
|
174
|
+
association:
|
175
|
+
customer:
|
176
|
+
kind: belongs_to
|
177
|
+
```
|
178
|
+
#### Naming field
|
179
|
+
In the case of `belongs_to`, The field representing the record name of the referenced parent model, if any, is defined in `name_filed`.
|
180
|
+
The `customer.name` associated with the `customer_id` is displayed. The `customer` is also displayed as a link, which can be clicked to view the details of the `customer`.
|
181
|
+
```yaml
|
182
|
+
model:
|
183
|
+
association:
|
184
|
+
customer:
|
185
|
+
kind: belongs_to
|
186
|
+
name_field: name
|
187
|
+
```
|
188
|
+
|
189
|
+

|
190
|
+
|
191
|
+
### has_many, has_one
|
192
|
+
For example, the relation `order` has_many `order_details` is defined as follows:
|
193
|
+
```yaml
|
194
|
+
model:
|
195
|
+
association:
|
196
|
+
order_details:
|
197
|
+
kind: has_many
|
198
|
+
dependent: destroy
|
199
|
+
```
|
200
|
+
|
201
|
+
The `app.show.fields` settings described below will enable batch registration and referencing of has_many.
|
202
|
+
|
203
|
+
#### Batch reference in detail view
|
204
|
+

|
205
|
+
|
206
|
+
#### Advanced configuration of the referenced model in `has_many`.
|
207
|
+
For example, in a `has_many` association such as `order` and `order details`, you may want to register multiple `order details` at once when registering `order`.
|
208
|
+
In this case, by defining `model` in the association model, Validation, Enum, etc. can be defined in the same way as above.
|
209
|
+
#### Example
|
210
|
+
In the example below, there is a `has_many order_details` association.
|
211
|
+
For this `order_details`, define a required validation for the `product_id` field, and a decorator for the `amount` field. It also defines an `association`.`belongs_to` for the `product` model that the `order_detail` is associated with.
|
212
|
+
```yaml
|
213
|
+
model:
|
214
|
+
association:
|
215
|
+
order_details:
|
216
|
+
kind: has_many
|
217
|
+
model:
|
218
|
+
validate:
|
219
|
+
product_id:
|
220
|
+
- presence
|
221
|
+
decorator:
|
222
|
+
amount:
|
223
|
+
digit: true
|
224
|
+
association:
|
225
|
+
product:
|
226
|
+
kind: belongs_to
|
227
|
+
name_field: title
|
228
|
+
```
|
229
|
+
|
230
|
+
#### Bulk Registration Form
|
231
|
+

|
232
|
+
|
233
|
+
## View Customization
|
234
|
+
### Index (list) view
|
235
|
+
#### Search conditions
|
236
|
+
In `app`.`index`.`conditions`, you can define search condition for the resource.
|
237
|
+
The condition specifies `sign` and `form_kind`.
|
238
|
+
|
239
|
+
sign can be specified as follows:
|
240
|
+
- eq (equal)
|
241
|
+
- lteq (less than equal)
|
242
|
+
- gteq (gather than equal)
|
243
|
+
- full_like (like %...%)
|
244
|
+
- start_with (like ...%)
|
245
|
+
- any (Used to specify multiple elements of Enum with "or")
|
246
|
+
|
247
|
+
form_kind can be specified as follows:
|
248
|
+
- text
|
249
|
+
- number (input type="number")
|
250
|
+
- select
|
251
|
+
- switch (Used with the boolean type)
|
252
|
+
- association_search (For association columns in belongs_to, `association_search` allows you to search and specify the related tables from the child screen)
|
253
|
+
|
254
|
+
#### Example
|
255
|
+
For example, equal search for id, association search for customer_id, multiple checkboxes for status, is defined as follows:
|
256
|
+
```yaml
|
257
|
+
app:
|
258
|
+
index:
|
259
|
+
conditions:
|
260
|
+
- id:
|
261
|
+
sign: eq
|
262
|
+
- customer_id:
|
263
|
+
sign: eq
|
264
|
+
form_kind: association_search
|
265
|
+
- status:
|
266
|
+
sign: any
|
267
|
+
form_kind: checkbox
|
268
|
+
```
|
269
|
+
|
270
|
+

|
271
|
+
|
272
|
+
#### List
|
273
|
+
In `app`.`index`.`list`, you can define which items are displayed in the list and the default sort order (you can change the sort order by clicking on the header cell of the list).
|
274
|
+
If you specify an association name in the list field, the name_field of the associated destination will be displayed in link format.
|
275
|
+
#### Example
|
276
|
+
```yaml
|
277
|
+
app:
|
278
|
+
index:
|
279
|
+
list:
|
280
|
+
fields:
|
281
|
+
- id
|
282
|
+
- customer
|
283
|
+
- status
|
284
|
+
- total_price
|
285
|
+
- delivered_at
|
286
|
+
default_order:
|
287
|
+
field: id
|
288
|
+
kind: desc
|
289
|
+
```
|
290
|
+
|
291
|
+

|
292
|
+
|
293
|
+
#### CSV output
|
294
|
+
infold also allows CSV output of search results. Define the target columns in `app`.`index`.`csv`.`fields`. If empty, all fields will be output.
|
295
|
+
|
296
|
+
#### Example
|
297
|
+
```yaml
|
298
|
+
app:
|
299
|
+
index:
|
300
|
+
csv:
|
301
|
+
fields:
|
302
|
+
- id
|
303
|
+
- title
|
304
|
+
- price
|
305
|
+
- created_at
|
306
|
+
- updated_at
|
307
|
+
```
|
308
|
+
|
309
|
+
### Show (detail) view
|
310
|
+
In `app`.`show`.`fields`, you can specify the fields and the order in which they are displayed on the detail screen.
|
311
|
+
If you include has_many / has_one associations in the field, you can also specify fields for the associated destination model.
|
312
|
+
|
313
|
+
#### Example
|
314
|
+
- The following example shows fields such as `id` and `status` to be displayed.
|
315
|
+
- It also displays the `customer.name_field` by including `customer` in the `belongs_to` association.
|
316
|
+
- In addition, the has_many association `order_details` is included. The `product`, `amount`, `unit_price` of this `order_details` is specified as the display field.
|
317
|
+
```yaml
|
318
|
+
app:
|
319
|
+
show:
|
320
|
+
fields:
|
321
|
+
- id
|
322
|
+
- customer
|
323
|
+
- status
|
324
|
+
- order_details:
|
325
|
+
fields:
|
326
|
+
- product
|
327
|
+
- amount
|
328
|
+
- unit_price
|
329
|
+
- created_at
|
330
|
+
```
|
331
|
+
|
332
|
+

|
333
|
+
|
334
|
+
### Form (Registration and Edit) view
|
335
|
+
In `app`.`form`.`fields`, you can define fields for registration and update forms.
|
336
|
+
|
337
|
+
Specify the form type from `kind`, `kind` can be specified as follows:
|
338
|
+
- text (default)
|
339
|
+
- number (input type="number")
|
340
|
+
- email (input type="email")
|
341
|
+
- password (input type="password")
|
342
|
+
- text_area
|
343
|
+
- radio
|
344
|
+
- select
|
345
|
+
- switch (boolean)
|
346
|
+
- file (defined in ActiveStorage)
|
347
|
+
- association_search (For association columns in belongs_to, `association_search` allows you to search and specify the related tables from the child screen)
|
348
|
+
|
349
|
+
If has_many/has_one of association is specified in the field, batch registration of related models is enabled.
|
350
|
+
|
351
|
+
#### Example
|
352
|
+
- Able to search and specify the related customer from a child screen (related to `order belongs_to customer`)
|
353
|
+
- `status` allows radio button selection of Enum elements
|
354
|
+
- Decorator's append($) set to `total_price` is displayed on the form
|
355
|
+
- Enable batch registration of related data, including `order_details`, which are related to has_many.
|
356
|
+
- Display `product_id`, `amount`, `unit_price` from related `order_details` on the form
|
357
|
+
- In relation to `order_detail belongs_to product`, and the related product can be searched from the child screen.
|
358
|
+
- ADD button to add rows.
|
359
|
+
```yaml
|
360
|
+
app:
|
361
|
+
form:
|
362
|
+
fields:
|
363
|
+
- customer:
|
364
|
+
kind: association_search
|
365
|
+
- status:
|
366
|
+
kind: radio
|
367
|
+
- total_price:
|
368
|
+
kind: number
|
369
|
+
- order_details:
|
370
|
+
kind: association
|
371
|
+
fields:
|
372
|
+
- product_id:
|
373
|
+
kind: association_search
|
374
|
+
- amount
|
375
|
+
- unit_price
|
376
|
+
```
|
377
|
+
|
378
|
+

|
379
|
+
|
380
|
+
### Association search view
|
381
|
+
Fields that are related to `belongs_to` can be searched and selected from the child screens for data in the related model.
|
382
|
+
|
383
|
+
**Note: Child screen searches should be defined in the resource (YAML) of the caller. For example, in the case of `order belongs_to customer`, define the association_search in the YAML of the `customer`, not in the `order`.**
|
384
|
+
|
385
|
+
The configuration is the same as for `app`.`index`. Define the necessary fields for `conditions` and `list`.
|
386
|
+
#### Example
|
387
|
+
- Use `name` and `email` as search criteria
|
388
|
+
- list `id`, `name` and `email`.
|
389
|
+
```yaml
|
390
|
+
app:
|
391
|
+
association_search:
|
392
|
+
conditions:
|
393
|
+
- name:
|
394
|
+
sign: full_like
|
395
|
+
- email:
|
396
|
+
sign: start_with
|
397
|
+
list:
|
398
|
+
fields:
|
399
|
+
- id
|
400
|
+
- name
|
401
|
+
- email
|
402
|
+
```
|
403
|
+
If a customer is defined as kind=association_search on the Order form, the customer can be searched and selected from the child screens.
|
404
|
+
|
405
|
+

|
21
406
|
|
22
407
|
## Dependencies
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
408
|
+
Infold is built with other open source projects:
|
409
|
+
|
410
|
+
| TOOL | DESCRIPTION |
|
411
|
+
|------------------------------------------------------------------|----------------------------------------------------------------------------|
|
412
|
+
| [tabler](https://github.com/tabler/tabler) | HTML Dashboard UI Kit built on Bootstrap |
|
413
|
+
| [devise](https://github.com/heartcombo/devise) | Flexible authentication solution for Rails with Warden. |
|
414
|
+
| [kaminari](https://github.com/kaminari/kaminari) | Clean, powerful, customizable and sophisticated paginator |
|
415
|
+
| [enum_help](https://github.com/zmbacker/enum_help) | Help ActiveRecord::Enum feature to work fine with I18n |
|
416
|
+
| [view_component](https://github.com/github/view_component) | A framework for building reusable, testable & encapsulated view components |
|
417
|
+
| [active_decorator](https://github.com/amatsuda/active_decorator) | A simple and Rubyish view helper for Rails |
|
418
|
+
| [haml-rails](https://github.com/haml/haml-rails) | A templating engine for HTML |
|
419
|
+
|
31
420
|
|
32
421
|
## License
|
33
422
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
CHANGED
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'rails/generators/base'
|
2
|
+
require 'infold/writers/controller_writer'
|
3
|
+
require 'infold/resource'
|
4
|
+
require 'infold/db_schema'
|
5
|
+
require 'infold/yaml_reader'
|
6
|
+
|
7
|
+
module Infold
|
8
|
+
class ControllerGenerator < Rails::Generators::NamedBase
|
9
|
+
source_root File.expand_path('templates', __dir__)
|
10
|
+
|
11
|
+
def setup
|
12
|
+
resource_name = name.camelize.singularize
|
13
|
+
db_schema = DbSchema.new(File.read(Rails.root.join('db/schema.rb')))
|
14
|
+
yaml = YAML.load_file(Rails.root.join("config/infold/#{resource_name.underscore}.yml"))
|
15
|
+
resource = YamlReader.generate_resource(resource_name, yaml, db_schema)
|
16
|
+
@writer = ControllerWriter.new(resource)
|
17
|
+
end
|
18
|
+
|
19
|
+
def create_controller_file
|
20
|
+
template "controller.rb", Rails.root.join("app/controllers/admin/#{name.pluralize.underscore}_controller.rb"), force: true
|
21
|
+
end
|
22
|
+
|
23
|
+
def add_routes
|
24
|
+
file = Rails.root.join('config/routes/admin.rb')
|
25
|
+
route = "resources :#{name.pluralize.underscore}"
|
26
|
+
return unless File.exist?(file)
|
27
|
+
in_file = File.readlines(file).grep(/^\s+#{route}$/)
|
28
|
+
if in_file.blank?
|
29
|
+
inject_into_file file, after: "namespace 'admin' do" do
|
30
|
+
"\n #{route}"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
return if name.pluralize.underscore == 'admin_users'
|
35
|
+
in_file = File.readlines(file).grep(/^\s+authenticated :admin_user do root/)
|
36
|
+
if in_file.blank?
|
37
|
+
inject_into_file file, after: "resources :admin_users" do
|
38
|
+
"\n authenticated :admin_user do root :to => '#{name.pluralize.underscore}#index', as: :root end"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def add_menu
|
44
|
+
return if name.pluralize.underscore == 'admin_users'
|
45
|
+
file = Rails.root.join('app/views/admin/common/_header_menu.html.haml')
|
46
|
+
return unless File.exist?(file)
|
47
|
+
menu = "\n %li.nav-item\n = link_to '#{@writer.resource.app_title}', #{@writer.index_path}, class: 'nav-link'"
|
48
|
+
in_file = File.readlines(file).grep(/, #{@writer.index_path},/)
|
49
|
+
if in_file.blank?
|
50
|
+
append_to_file file do
|
51
|
+
menu
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'rails/generators/base'
|
2
|
+
require 'infold/writers/decorator_writer'
|
3
|
+
require 'infold/resource'
|
4
|
+
require 'infold/db_schema'
|
5
|
+
require 'infold/yaml_reader'
|
6
|
+
|
7
|
+
module Infold
|
8
|
+
class DecoratorGenerator < Rails::Generators::NamedBase
|
9
|
+
source_root File.expand_path('templates', __dir__)
|
10
|
+
|
11
|
+
def setup
|
12
|
+
resource_name = name.camelize.singularize
|
13
|
+
db_schema = DbSchema.new(File.read(Rails.root.join('db/schema.rb')))
|
14
|
+
yaml = YAML.load_file(Rails.root.join("config/infold/#{resource_name.underscore}.yml"))
|
15
|
+
@resource = YamlReader.generate_resource(resource_name, yaml, db_schema)
|
16
|
+
end
|
17
|
+
|
18
|
+
def create_model_file
|
19
|
+
@writer = DecoratorWriter.new(@resource)
|
20
|
+
template "decorator.rb", Rails.root.join("app/decorators/admin/#{name.underscore.singularize}_decorator.rb"), force: true
|
21
|
+
end
|
22
|
+
|
23
|
+
def create_association_model_file
|
24
|
+
@resource.associations&.
|
25
|
+
select { |as| !as.belongs_to? && as.field_group.has_association_model? }&.each do |association|
|
26
|
+
@writer = DecoratorWriter.new(association)
|
27
|
+
template "decorator.rb", Rails.root.join("app/decorators/admin/#{association.model_name(:snake)}_decorator.rb"), force: true
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'rails/generators/base'
|
2
|
+
|
3
|
+
module Infold
|
4
|
+
class InstallGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path('templates/install', __dir__)
|
6
|
+
|
7
|
+
def check_devise_installed
|
8
|
+
initializer_file =
|
9
|
+
File.join(Rails.root, "config", "initializers", "devise.rb")
|
10
|
+
@devise_installed = File.exist?(initializer_file)
|
11
|
+
end
|
12
|
+
|
13
|
+
def install_devise
|
14
|
+
require "devise"
|
15
|
+
|
16
|
+
if @devise_installed
|
17
|
+
log :generate, "No need to install devise, already done."
|
18
|
+
else
|
19
|
+
log :generate, "devise:install"
|
20
|
+
invoke "devise:install"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def create_devise_user
|
25
|
+
invoke "devise", ["admin_User"]
|
26
|
+
end
|
27
|
+
|
28
|
+
def delete_devise_routes
|
29
|
+
routes_file = File.join(destination_root, "config", "routes.rb")
|
30
|
+
gsub_file routes_file, /devise_for :admin_users.*$/, ""
|
31
|
+
end
|
32
|
+
|
33
|
+
def edit_devise_config
|
34
|
+
config_file = File.join(destination_root, "config", "initializers", "devise.rb")
|
35
|
+
gsub_file config_file, /# config.scoped_views = false$/, "config.scoped_views = true"
|
36
|
+
unless @devise_installed
|
37
|
+
gsub_file config_file, /# config.parent_controller = 'DeviseController'$/, "config.parent_controller = 'Admin::TurboDeviseController'"
|
38
|
+
gsub_file config_file, "# config.navigational_formats = ['*/*', :html]", "config.navigational_formats = ['*/*', :html, :turbo_stream]"
|
39
|
+
gsub_file config_file, "# config.warden do |manager|", "config.warden do |manager|\n manager.failure_app = TurboFailureApp\n end"
|
40
|
+
code = <<-CODE.gsub(/^\s+/, '')
|
41
|
+
# Turbo doesn't work with devise by default.
|
42
|
+
# Keep tabs on https://github.com/heartcombo/devise/issues/5446 for a possible fix
|
43
|
+
# Fix from https://gorails.com/episodes/devise-hotwire-turbo
|
44
|
+
class TurboFailureApp < Devise::FailureApp
|
45
|
+
[TAB]def respond
|
46
|
+
[TAB][TAB]if request_format == :turbo_stream
|
47
|
+
[TAB][TAB][TAB]redirect
|
48
|
+
[TAB][TAB]else
|
49
|
+
[TAB][TAB][TAB]super
|
50
|
+
[TAB][TAB]end
|
51
|
+
[TAB]end
|
52
|
+
|
53
|
+
[TAB]def skip_format?
|
54
|
+
[TAB][TAB]%w(html turbo_stream */*).include? request_format.to_s
|
55
|
+
[TAB]end
|
56
|
+
end
|
57
|
+
CODE
|
58
|
+
inject_into_file(config_file, before: "Devise.setup do |config|") { code.gsub('[TAB]', ' ') }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def copy_app_files
|
63
|
+
template_path = File.expand_path("templates/install", __dir__)
|
64
|
+
Dir.glob("#{template_path}/app/**/*").each do |item|
|
65
|
+
next if FileTest.directory?(item) || item.end_with?('admin.scss')
|
66
|
+
dist_path = item.to_s.gsub(template_path.to_s, Rails.root.to_s)
|
67
|
+
template item, dist_path, encoding: :utf8, ask: true
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def edit_routes_file
|
72
|
+
template "config/routes/admin.rb", "config/routes/admin.rb", ask: true
|
73
|
+
route "draw(:admin)"
|
74
|
+
end
|
75
|
+
|
76
|
+
def copy_locale_files
|
77
|
+
template_path = File.expand_path("templates/install/config/locales", __dir__)
|
78
|
+
Dir.glob("#{template_path}/*") do |item|
|
79
|
+
dist_path = Rails.root.join("config/locales", item.split('/').last)
|
80
|
+
template item, dist_path, encoding: :utf8, ask: true
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def install_admin_users
|
85
|
+
template "config/infold/admin_user.yml", "config/infold/admin_user.yml", ask: true
|
86
|
+
generate 'infold:scaffold', 'admin_user'
|
87
|
+
|
88
|
+
route_file = Rails.root.join('config/routes/admin.rb')
|
89
|
+
route = "resources :admin_users"
|
90
|
+
in_file = File.readlines(route_file).grep(/^\s+#{route}$/)
|
91
|
+
if in_file.blank?
|
92
|
+
inject_into_file route_file, after: "namespace 'admin' do" do
|
93
|
+
"\n #{route}"
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'rails/generators/base'
|
2
|
+
require 'infold/writers/model_writer'
|
3
|
+
require 'infold/resource'
|
4
|
+
require 'infold/db_schema'
|
5
|
+
require 'infold/yaml_reader'
|
6
|
+
|
7
|
+
module Infold
|
8
|
+
class ModelGenerator < Rails::Generators::NamedBase
|
9
|
+
source_root File.expand_path('templates', __dir__)
|
10
|
+
|
11
|
+
def setup
|
12
|
+
resource_name = name.camelize.singularize
|
13
|
+
db_schema = DbSchema.new(File.read(Rails.root.join('db/schema.rb')))
|
14
|
+
yaml = YAML.load_file(Rails.root.join("config/infold/#{resource_name.underscore}.yml"))
|
15
|
+
@resource = YamlReader.generate_resource(resource_name, yaml, db_schema)
|
16
|
+
end
|
17
|
+
|
18
|
+
def create_model_file
|
19
|
+
@writer = ModelWriter.new(@resource)
|
20
|
+
template "model.rb", Rails.root.join("app/models/admin", "#{name.underscore.singularize}.rb"), force: true
|
21
|
+
end
|
22
|
+
|
23
|
+
def create_association_model_file
|
24
|
+
@resource.associations&.
|
25
|
+
select { |as| !as.belongs_to? && as.field_group.has_association_model? }&.each do |association|
|
26
|
+
@writer = ModelWriter.new(association)
|
27
|
+
template "model.rb", Rails.root.join("app/models/admin", "#{association.model_name(:snake)}.rb"), force: true
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|