rails_com 1.2.5 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +20 -165
- data/README.md +45 -22
- data/Rakefile +2 -1
- data/app/apis/ali_dns.rb +66 -0
- data/app/assets/images/avatar.png +0 -0
- data/app/channels/com/session_channel.rb +16 -0
- data/app/channels/rails_com/connection.rb +31 -0
- data/app/controllers/admin_controller.rb +4 -0
- data/app/controllers/application_controller.rb +7 -0
- data/app/controllers/base_controller.rb +2 -0
- data/app/controllers/board/base_controller.rb +3 -0
- data/app/controllers/board/home_controller.rb +6 -0
- data/app/controllers/board_controller.rb +3 -0
- data/app/controllers/com/audios_controller.rb +27 -0
- data/app/controllers/com/base_controller.rb +4 -0
- data/app/controllers/com/common_controller.rb +69 -0
- data/app/controllers/com/controller/admin.rb +114 -0
- data/app/controllers/com/controller/err_handler.rb +13 -0
- data/app/controllers/com/direct_uploads_controller.rb +11 -0
- data/app/controllers/com/log_controller.rb +30 -0
- data/app/controllers/com/nodes_controller.rb +22 -0
- data/app/controllers/com/panel/acme_accounts_controller.rb +12 -0
- data/app/controllers/com/panel/acme_identifiers_controller.rb +31 -0
- data/app/controllers/com/panel/acme_orders_controller.rb +64 -0
- data/app/controllers/com/panel/attachments_controller.rb +31 -0
- data/app/controllers/com/panel/base_controller.rb +5 -0
- data/app/controllers/com/panel/blob_defaults_controller.rb +13 -0
- data/app/controllers/com/panel/blobs_controller.rb +52 -0
- data/app/controllers/com/panel/cache_lists_controller.rb +5 -0
- data/app/controllers/com/panel/csps_controller.rb +18 -0
- data/app/controllers/com/panel/errs_controller.rb +18 -0
- data/app/controllers/com/panel/inbound_emails_controller.rb +15 -0
- data/app/controllers/com/panel/infos_controller.rb +9 -0
- data/app/controllers/com/panel/meta_actions_controller.rb +46 -0
- data/app/controllers/com/panel/meta_businesses_controller.rb +21 -0
- data/app/controllers/com/panel/meta_columns_controller.rb +47 -0
- data/app/controllers/com/panel/meta_controllers_controller.rb +46 -0
- data/app/controllers/com/panel/meta_models_controller.rb +32 -0
- data/app/controllers/com/panel/meta_namespaces_controller.rb +29 -0
- data/app/controllers/com/pdfs_controller.rb +37 -0
- data/app/controllers/com/videos_controller.rb +28 -0
- data/app/controllers/home_controller.rb +6 -0
- data/app/controllers/my/base_controller.rb +4 -0
- data/app/controllers/my/home_controller.rb +8 -0
- data/app/controllers/my_controller.rb +3 -0
- data/app/controllers/panel/base_controller.rb +4 -0
- data/app/controllers/panel/home_controller.rb +8 -0
- data/app/controllers/panel_controller.rb +5 -0
- data/app/controllers/rails_com/application.rb +113 -0
- data/app/helpers/rails_com/active_helper.rb +35 -39
- data/app/helpers/rails_com/form_helper.rb +21 -0
- data/app/helpers/rails_com/format_helper.rb +13 -0
- data/app/helpers/rails_com/frame_helper.rb +13 -0
- data/app/helpers/rails_com/kaminari_helper.rb +9 -0
- data/app/helpers/rails_com/time_helper.rb +23 -0
- data/app/helpers/rails_com/url_helper.rb +12 -0
- data/app/jobs/active_storage/identify_job.rb +9 -0
- data/app/jobs/application_job.rb +2 -0
- data/app/jobs/com/acme_job.rb +9 -0
- data/app/jobs/com/err_job.rb +10 -0
- data/app/mailboxes/application_mailbox.rb +2 -0
- data/app/mailers/application_mailer.rb +3 -0
- data/app/models/com/acme_account.rb +5 -0
- data/app/models/com/acme_identifier.rb +5 -0
- data/app/models/com/acme_order.rb +5 -0
- data/app/models/com/application_record.rb +5 -0
- data/app/models/com/blob_default.rb +5 -0
- data/app/models/com/cache_list.rb +5 -0
- data/app/models/com/csp.rb +5 -0
- data/app/models/com/err.rb +5 -0
- data/app/models/com/ext/debug.rb +71 -0
- data/app/models/com/ext/extra.rb +20 -0
- data/app/models/com/ext/parameter.rb +19 -0
- data/app/models/com/ext/sequence.rb +36 -0
- data/app/models/com/ext/state_machine.rb +82 -0
- data/app/models/com/ext/taxon.rb +81 -0
- data/app/models/com/ext/taxon_prepend.rb +21 -0
- data/app/models/com/info.rb +5 -0
- data/app/models/com/meta_action.rb +5 -0
- data/app/models/com/meta_business.rb +5 -0
- data/app/models/com/meta_column.rb +5 -0
- data/app/models/com/meta_controller.rb +5 -0
- data/app/models/com/meta_model.rb +5 -0
- data/app/models/com/meta_namespace.rb +5 -0
- data/app/models/com/meta_operation.rb +5 -0
- data/app/models/com/meta_route.rb +5 -0
- data/app/models/com/model/acme_account.rb +70 -0
- data/app/models/com/model/acme_identifier.rb +132 -0
- data/app/models/com/model/acme_order.rb +139 -0
- data/app/models/com/model/blob_default.rb +36 -0
- data/app/models/com/model/cache_list.rb +15 -0
- data/app/models/com/model/csp.rb +23 -0
- data/app/models/com/model/err.rb +108 -0
- data/app/models/com/model/info.rb +31 -0
- data/app/models/com/model/meta_action.rb +70 -0
- data/app/models/com/model/meta_business.rb +66 -0
- data/app/models/com/model/meta_column.rb +36 -0
- data/app/models/com/model/meta_controller.rb +115 -0
- data/app/models/com/model/meta_model.rb +58 -0
- data/app/models/com/model/meta_namespace.rb +61 -0
- data/app/models/com/model/meta_operation.rb +18 -0
- data/app/models/com/model/meta_permission.rb +10 -0
- data/app/models/com/model/meta_relation.rb +6 -0
- data/app/models/com/model/meta_route.rb +10 -0
- data/app/models/com.rb +11 -0
- data/app/models/concerns/feishu_bot.rb +15 -0
- data/app/models/concerns/log_record_bot.rb +40 -0
- data/app/models/concerns/work_wechat_bot.rb +18 -0
- data/app/stores/com/env_yaml.rb +96 -0
- data/app/stores/com/yaml.rb +89 -0
- data/app/views/admin/_breadcrumb.html.erb +5 -0
- data/app/views/application/_actionsheet.html.erb +20 -0
- data/app/views/application/_alert.html+phone.erb +6 -0
- data/app/views/application/_alert.html.erb +9 -0
- data/app/views/application/_auth_navbar.html.erb +18 -0
- data/app/views/application/_breadcrumb.html.erb +0 -0
- data/app/views/application/_button.html+phone.erb +3 -0
- data/app/views/application/_button.html.erb +3 -0
- data/app/views/application/_edit_form.html+phone.erb +10 -0
- data/app/views/application/_edit_form.html.erb +4 -0
- data/app/views/application/_error_messages.html.erb +11 -0
- data/app/views/application/_filter_form.html+phone.erb +14 -0
- data/app/views/application/_filter_form.html.erb +9 -0
- data/app/views/application/_filter_table.html.erb +0 -0
- data/app/views/application/_footer.html.erb +8 -0
- data/app/views/application/_form.html.erb +4 -0
- data/app/views/application/_index_sortable_table.html.erb +22 -0
- data/app/views/application/_index_table.html+phone.erb +13 -0
- data/app/views/application/_index_table.html.erb +22 -0
- data/app/views/application/_index_tbody.html.erb +3 -0
- data/app/views/application/_index_thead.html.erb +4 -0
- data/app/views/application/_index_tr.html+phone.erb +4 -0
- data/app/views/application/_index_tr.html.erb +16 -0
- data/app/views/application/_index_tree_table.html.erb +18 -0
- data/app/views/application/_locales.html.erb +11 -0
- data/app/views/application/_modal.html+phone.erb +14 -0
- data/app/views/application/_modal.html.erb +14 -0
- data/app/views/application/_nav.html.erb +0 -0
- data/app/views/application/_nav_bar.html+phone.erb +0 -0
- data/app/views/application/_nav_bar.html.erb +25 -0
- data/app/views/application/_nav_brand.html.erb +3 -0
- data/app/views/application/_nav_with_login.html.erb +0 -0
- data/app/views/application/_nav_without_login.html.erb +0 -0
- data/app/views/application/_new_form.html+phone.erb +10 -0
- data/app/views/application/_new_form.html.erb +4 -0
- data/app/views/application/_pagination.json.jbuilder +7 -0
- data/app/views/application/_show.html+phone.erb +20 -0
- data/app/views/application/_show.html.erb +13 -0
- data/app/views/application/_show_table.html.erb +0 -0
- data/app/views/application/_tab_bar.html.erb +3 -0
- data/app/views/application/_tab_bar_item.erb +4 -0
- data/app/views/application/alert.turbo_stream.erb +1 -0
- data/app/views/application/controller_not_found.json.jbuilder +4 -0
- data/app/views/application/create.json.jbuilder +1 -0
- data/app/views/application/create.turbo_stream.erb +3 -0
- data/app/views/application/destroy.json.jbuilder +0 -0
- data/app/views/application/destroy.turbo_stream.erb +3 -0
- data/app/views/application/edit.html.erb +7 -0
- data/app/views/application/edit.json.jbuilder +2 -0
- data/app/views/{shared/_error_messages.html.erb → application/err.turbo_stream.erb} +4 -4
- data/app/views/application/index.html.erb +5 -0
- data/app/views/application/index.json.jbuilder +1 -0
- data/app/views/application/move_higher.turbo_stream.erb +3 -0
- data/app/views/application/move_lower.turbo_stream.erb +3 -0
- data/app/views/application/new.html.erb +7 -0
- data/app/views/application/new.json.jbuilder +2 -0
- data/app/views/application/show.html.erb +3 -0
- data/app/views/application/show.json.jbuilder +1 -0
- data/app/views/application/update.json.jbuilder +1 -0
- data/app/views/application/update.turbo_stream.erb +3 -0
- data/app/views/board/home/index.html.erb +0 -0
- data/app/views/com/attachments/_file_upload.html.erb +19 -0
- data/app/views/com/attachments/_image_preview.html.erb +9 -0
- data/app/views/com/attachments/_list.html.erb +31 -0
- data/app/views/com/attachments/_list_edit.html.erb +28 -0
- data/app/views/com/attachments/_list_field.html.erb +6 -0
- data/app/views/com/attachments/_list_many.html.erb +17 -0
- data/app/views/com/attachments/_video_item.html.erb +6 -0
- data/app/views/com/audios/show.html.erb +3 -0
- data/app/views/com/common/deploy.html.erb +0 -0
- data/app/views/com/common/info.json.jbuilder +1 -0
- data/app/views/com/extra/_extra_form.html.erb +5 -0
- data/app/views/com/extra/_item.html.erb +15 -0
- data/app/views/com/nodes/_children_options.html.erb +4 -0
- data/app/views/com/nodes/_children_select.html.erb +15 -0
- data/app/views/com/nodes/_outer_children_options.html.erb +4 -0
- data/app/views/com/nodes/_outer_options.html+phone.erb +2 -0
- data/app/views/com/nodes/_outer_options.html.erb +4 -0
- data/app/views/com/nodes/_outer_select.html.erb +12 -0
- data/app/views/com/nodes/_self_and_siblings_options.html.erb +4 -0
- data/app/views/com/nodes/_siblings_options.html.erb +4 -0
- data/app/views/com/nodes/_siblings_select.html.erb +14 -0
- data/app/views/com/nodes/children.turbo_stream.erb +3 -0
- data/app/views/com/nodes/outer.turbo_stream.erb +3 -0
- data/app/views/com/panel/acme_accounts/_filter_form.html.erb +9 -0
- data/app/views/com/panel/acme_accounts/_index_tbody.html.erb +7 -0
- data/app/views/com/panel/acme_accounts/_index_thead.html.erb +4 -0
- data/app/views/com/panel/acme_accounts/_index_tr.html.erb +16 -0
- data/app/views/com/panel/acme_identifiers/_breadcrumb.html.erb +7 -0
- data/app/views/com/panel/acme_identifiers/_button.html.erb +0 -0
- data/app/views/com/panel/acme_identifiers/_filter_form.html.erb +9 -0
- data/app/views/com/panel/acme_identifiers/_form.html.erb +2 -0
- data/app/views/com/panel/acme_identifiers/_index_tbody.html.erb +16 -0
- data/app/views/com/panel/acme_identifiers/_index_thead.html.erb +17 -0
- data/app/views/com/panel/acme_identifiers/_show_table.html.erb +24 -0
- data/app/views/com/panel/acme_identifiers/index.html.erb +3 -0
- data/app/views/com/panel/acme_orders/_breadcrumb.html.erb +6 -0
- data/app/views/com/panel/acme_orders/_filter_form.html.erb +9 -0
- data/app/views/com/panel/acme_orders/_form.html.erb +4 -0
- data/app/views/com/panel/acme_orders/_index_tbody.html.erb +11 -0
- data/app/views/com/panel/acme_orders/_index_thead.html.erb +8 -0
- data/app/views/com/panel/acme_orders/_index_tr.html.erb +25 -0
- data/app/views/com/panel/acme_orders/_item_form.html.erb +14 -0
- data/app/views/com/panel/acme_orders/_new_form.html.erb +7 -0
- data/app/views/com/panel/acme_orders/_show_table.html.erb +4 -0
- data/app/views/com/panel/attachments/_breadcrumb.html.erb +10 -0
- data/app/views/com/panel/attachments/_button.html.erb +0 -0
- data/app/views/com/panel/attachments/_filter_form.html.erb +13 -0
- data/app/views/com/panel/attachments/_index_tbody.html.erb +6 -0
- data/app/views/com/panel/attachments/_index_thead.html.erb +7 -0
- data/app/views/com/panel/attachments/_index_tr.html.erb +10 -0
- data/app/views/com/panel/attachments/index.html.erb +5 -0
- data/app/views/com/panel/base/_index_meta_action.html.erb +14 -0
- data/app/views/com/panel/base/_nav.html.erb +3 -0
- data/app/views/com/panel/blob_defaults/_add_form.html.erb +7 -0
- data/app/views/com/panel/blob_defaults/_filter_form.html.erb +10 -0
- data/app/views/com/panel/blob_defaults/_form.html.erb +4 -0
- data/app/views/com/panel/blob_defaults/_index_tbody.html.erb +7 -0
- data/app/views/com/panel/blob_defaults/_index_thead.html.erb +5 -0
- data/app/views/com/panel/blob_defaults/_index_tr.html.erb +13 -0
- data/app/views/com/panel/blob_defaults/add.turbo_stream.erb +1 -0
- data/app/views/com/panel/blobs/_breadcrumb.html.erb +6 -0
- data/app/views/com/panel/blobs/_filter_form.html.erb +13 -0
- data/app/views/com/panel/blobs/_index_tbody.html.erb +22 -0
- data/app/views/com/panel/blobs/_index_thead.html.erb +12 -0
- data/app/views/com/panel/blobs/_index_tr.html.erb +13 -0
- data/app/views/com/panel/blobs/_new_form.html.erb +5 -0
- data/app/views/com/panel/blobs/index.html.erb +5 -0
- data/app/views/com/panel/cache_lists/_index_tbody.html.erb +4 -0
- data/app/views/com/panel/cache_lists/_index_thead.html.erb +5 -0
- data/app/views/com/panel/cache_lists/_show_table.html.erb +8 -0
- data/app/views/com/panel/csps/_button.html.erb +0 -0
- data/app/views/com/panel/csps/_filter_form.html.erb +8 -0
- data/app/views/com/panel/csps/_index_tbody.html.erb +11 -0
- data/app/views/com/panel/csps/_index_thead.html.erb +12 -0
- data/app/views/com/panel/csps/_index_tr.html.erb +13 -0
- data/app/views/com/panel/csps/_show/_breadcrumb.html.erb +6 -0
- data/app/views/com/panel/csps/_show_table.html.erb +48 -0
- data/app/views/com/panel/csps/show.html.erb +7 -0
- data/app/views/com/panel/errs/_button.html.erb +0 -0
- data/app/views/com/panel/errs/_filter_form.html.erb +11 -0
- data/app/views/com/panel/errs/_index_tbody.html.erb +16 -0
- data/app/views/com/panel/errs/_index_thead.html.erb +11 -0
- data/app/views/com/panel/errs/_index_tr.html.erb +13 -0
- data/app/views/com/panel/errs/_show/_breadcrumb.html.erb +6 -0
- data/app/views/com/panel/errs/_show_table.html.erb +44 -0
- data/app/views/com/panel/errs/show.html.erb +7 -0
- data/app/views/com/panel/inbound_emails/_button.html.erb +0 -0
- data/app/views/com/panel/inbound_emails/_filter_form.html.erb +9 -0
- data/app/views/com/panel/inbound_emails/_index_tbody.html.erb +5 -0
- data/app/views/com/panel/inbound_emails/_index_thead.html.erb +6 -0
- data/app/views/com/panel/inbound_emails/_show_table.html.erb +10 -0
- data/app/views/com/panel/inbound_emails/index.html.erb +5 -0
- data/app/views/com/panel/infos/_filter_form.html.erb +9 -0
- data/app/views/com/panel/infos/_index_tbody.html.erb +4 -0
- data/app/views/com/panel/infos/_index_thead.html.erb +5 -0
- data/app/views/com/panel/infos/index.json.jbuilder +1 -0
- data/app/views/com/panel/meta_actions/_breadcrumb.html.erb +6 -0
- data/app/views/com/panel/meta_actions/_form.html.erb +1 -0
- data/app/views/com/panel/meta_actions/_index_tbody.html.erb +4 -0
- data/app/views/com/panel/meta_actions/_index_thead.html.erb +5 -0
- data/app/views/com/panel/meta_actions/_roles.html.erb +9 -0
- data/app/views/com/panel/meta_actions/index.html.erb +3 -0
- data/app/views/com/panel/meta_actions/roles.js.erb +6 -0
- data/app/views/com/panel/meta_actions/update.turbo_stream.erb +1 -0
- data/app/views/com/panel/meta_businesses/_breadcrumb.html.erb +10 -0
- data/app/views/com/panel/meta_businesses/_button.html.erb +3 -0
- data/app/views/com/panel/meta_businesses/_form.html.erb +3 -0
- data/app/views/com/panel/meta_businesses/_index_tbody.html.erb +12 -0
- data/app/views/com/panel/meta_businesses/_index_thead.html.erb +2 -0
- data/app/views/com/panel/meta_businesses/_index_tr.html.erb +16 -0
- data/app/views/com/panel/meta_businesses/_show_table.html.erb +8 -0
- data/app/views/com/panel/meta_businesses/sync.turbo_stream.erb +3 -0
- data/app/views/com/panel/meta_columns/_breadcrumb.html.erb +6 -0
- data/app/views/com/panel/meta_columns/_form.html.erb +6 -0
- data/app/views/com/panel/meta_columns/_index_tbody.html.erb +20 -0
- data/app/views/com/panel/meta_columns/_index_thead.html.erb +12 -0
- data/app/views/com/panel/meta_columns/_index_tr.html.erb +22 -0
- data/app/views/com/panel/meta_columns/_show_table.html.erb +20 -0
- data/app/views/com/panel/meta_columns/sync.turbo_stream.erb +3 -0
- data/app/views/com/panel/meta_columns/test.turbo_stream.erb +3 -0
- data/app/views/com/panel/meta_controllers/_button.html.erb +3 -0
- data/app/views/com/panel/meta_controllers/_filter_form.html.erb +8 -0
- data/app/views/com/panel/meta_controllers/_filter_tablex.html.erb +8 -0
- data/app/views/com/panel/meta_controllers/_form.html.erb +2 -0
- data/app/views/com/panel/meta_controllers/_index_meta_business.html.erb +10 -0
- data/app/views/com/panel/meta_controllers/_index_meta_controller.html.erb +15 -0
- data/app/views/com/panel/meta_controllers/_index_meta_namespace.html.erb +12 -0
- data/app/views/com/panel/meta_controllers/_index_tbody.html.erb +28 -0
- data/app/views/com/panel/meta_controllers/_index_thead.html.erb +2 -0
- data/app/views/com/panel/meta_controllers/index.html.erb +3 -0
- data/app/views/com/panel/meta_controllers/meta_actions.turbo_stream.erb +1 -0
- data/app/views/com/panel/meta_controllers/meta_controllers.turbo_stream.erb +1 -0
- data/app/views/com/panel/meta_controllers/meta_namespaces.turbo_stream.erb +1 -0
- data/app/views/com/panel/meta_controllers/sync.turbo_stream.erb +3 -0
- data/app/views/com/panel/meta_models/_button.html.erb +6 -0
- data/app/views/com/panel/meta_models/_form.html.erb +4 -0
- data/app/views/com/panel/meta_models/_index_tbody.html.erb +3 -0
- data/app/views/com/panel/meta_models/_index_thead.html.erb +4 -0
- data/app/views/com/panel/meta_models/_index_tr.html.erb +19 -0
- data/app/views/com/panel/meta_models/_show_table.html.erb +12 -0
- data/app/views/com/panel/meta_models/sync.turbo_stream.erb +3 -0
- data/app/views/com/panel/meta_namespaces/_breadcrumb.html.erb +10 -0
- data/app/views/com/panel/meta_namespaces/_button.html.erb +3 -0
- data/app/views/com/panel/meta_namespaces/_form.html.erb +5 -0
- data/app/views/com/panel/meta_namespaces/_index_tbody.html.erb +20 -0
- data/app/views/com/panel/meta_namespaces/_index_thead.html.erb +6 -0
- data/app/views/com/panel/meta_namespaces/_show_table.html.erb +20 -0
- data/app/views/com/panel/meta_namespaces/sync.turbo_stream.erb +3 -0
- data/app/views/com/videos/show.html.erb +9 -0
- data/app/{assets/javascripts/controllers/active_storage_ext/videos/show.ready.js → views/com/videos/show.js} +0 -0
- data/app/views/default_form/_date_field.html.erb +1 -0
- data/app/views/default_form/_datetime_field.html.erb +1 -0
- data/app/views/default_form/_number_field.html.erb +1 -0
- data/app/views/default_form/_outer_select.html.erb +14 -0
- data/app/views/default_form/_select_enum.html.erb +1 -0
- data/app/views/default_form/_text_field.html.erb +1 -0
- data/app/views/default_form/_time_field.html.erb +1 -0
- data/app/views/extra_form/_number_field.html.erb +1 -0
- data/app/views/extra_form/_outer_select.html.erb +14 -0
- data/app/views/extra_form/_text_field.html.erb +1 -0
- data/app/views/home/index.html.erb +0 -0
- data/app/views/kaminari/com/_first_page.html.erb +3 -0
- data/app/views/kaminari/{_gap.html.erb → com/_gap.html.erb} +1 -1
- data/app/views/kaminari/com/_last_page.html.erb +3 -0
- data/app/views/kaminari/com/_next_page.html.erb +3 -0
- data/app/views/kaminari/com/_page.html.erb +1 -0
- data/app/views/kaminari/{_paginator.html.erb → com/_paginator.html+phone.erb} +3 -3
- data/app/views/kaminari/com/_paginator.html.erb +17 -0
- data/app/views/kaminari/com/_prev_page.html.erb +3 -0
- data/app/views/layouts/_admin_head.html.erb +22 -0
- data/app/views/layouts/_application_head.html.erb +26 -0
- data/app/views/layouts/_phone_head.html.erb +28 -0
- data/app/views/layouts/admin.html.erb +12 -0
- data/app/views/layouts/application.html+phone.erb +12 -0
- data/app/views/layouts/application.html.erb +11 -0
- data/app/views/layouts/application.json.jbuilder +2 -0
- data/app/views/layouts/board.html+phone.erb +10 -0
- data/app/views/layouts/board.html.erb +12 -0
- data/app/views/layouts/mailer.html.erb +14 -0
- data/app/views/layouts/mailer.text.erb +1 -0
- data/app/views/layouts/my.html+phone.erb +11 -0
- data/app/views/layouts/my.html.erb +13 -0
- data/app/views/layouts/panel.html.erb +12 -0
- data/app/views/my/home/index.html.erb +0 -0
- data/app/views/panel/_breadcrumb.html.erb +0 -0
- data/app/views/panel/_com_nav.html.erb +19 -0
- data/app/views/panel/_nav.html.erb +6 -0
- data/app/views/panel/_nav_without_login.html.erb +3 -0
- data/app/views/panel/destroy.turbo_stream.erb +1 -0
- data/app/views/panel/home/index.html.erb +0 -0
- data/config/default_form.yml +74 -0
- data/config/locales/en.controller.yml +46 -0
- data/config/locales/en.yml +2 -2
- data/config/locales/zh.attributes.yml +9 -0
- data/config/locales/zh.controller.yml +65 -0
- data/config/locales/zh.enum.yml +11 -0
- data/config/locales/zh.helper.yml +10 -0
- data/config/locales/zh.rb +34 -0
- data/config/locales/zh.yml +66 -10
- data/config/routes.rb +140 -8
- data/lib/active_storage/service/disc_service.rb +41 -0
- data/lib/default_form/active_record/extend.rb +38 -0
- data/lib/default_form/builder/default.rb +88 -0
- data/lib/default_form/builder/helper.rb +212 -0
- data/lib/default_form/builder/wrap.rb +58 -0
- data/lib/default_form/config.rb +50 -0
- data/lib/default_form/controller_helper.rb +14 -0
- data/lib/default_form/form_builder.rb +61 -0
- data/lib/default_form/override/action_view/helpers/tags/collection_check_boxes.rb +23 -0
- data/lib/default_form/override/action_view/helpers/tags/collection_radio_buttons.rb +23 -0
- data/lib/default_form/view_helper.rb +39 -0
- data/lib/generators/jbuilder_generator.rb +22 -0
- data/lib/generators/scaffold_generator.rb +27 -0
- data/lib/generators/templates/jbuilder/_show.json.jbuilder.tt +1 -0
- data/lib/generators/templates/jbuilder/index.json.jbuilder.tt +1 -0
- data/lib/generators/templates/jbuilder/partial.json.jbuilder.tt +17 -0
- data/lib/generators/templates/scaffold_erb/_edit_form.html.erb.tt +4 -0
- data/lib/generators/templates/scaffold_erb/_filter_form.html.erb.tt +9 -0
- data/lib/generators/templates/scaffold_erb/_form.html.erb.tt +4 -0
- data/lib/generators/templates/scaffold_erb/_index_tbody.html.erb.tt +3 -0
- data/lib/generators/templates/scaffold_erb/_index_thead.html.erb.tt +4 -0
- data/lib/generators/templates/scaffold_erb/_new_form.html.erb.tt +4 -0
- data/lib/generators/templates/scaffold_erb/_show_table.html.erb.tt +6 -0
- data/lib/generators/templates/scaffold_erb/index.html.erb.tt +5 -0
- data/lib/rails_com/action_controller/errors.rb +11 -0
- data/lib/rails_com/action_controller/extend.rb +20 -0
- data/lib/rails_com/action_controller/include.rb +31 -0
- data/lib/rails_com/action_controller/parameters.rb +19 -0
- data/lib/rails_com/action_controller/public_exceptions.rb +31 -0
- data/lib/rails_com/action_controller/subscriber.rb +32 -0
- data/lib/rails_com/action_controller.rb +9 -0
- data/lib/rails_com/action_mailbox/inbound_email.rb +23 -0
- data/lib/rails_com/action_mailbox/mail_ext.rb +34 -0
- data/lib/rails_com/action_mailbox.rb +4 -0
- data/lib/rails_com/action_text/rich_text.rb +16 -0
- data/lib/rails_com/action_text.rb +3 -0
- data/lib/rails_com/action_view/partial_renderer.rb +22 -0
- data/lib/rails_com/action_view/template_renderer.rb +41 -0
- data/lib/rails_com/action_view/translation_helper.rb +23 -0
- data/lib/rails_com/action_view.rb +5 -0
- data/lib/rails_com/{rails_ext → active_storage}/activestorage_attached.rb +7 -3
- data/lib/rails_com/active_storage/attached_macros.rb +32 -0
- data/lib/rails_com/active_storage/attachment_prepend.rb +14 -0
- data/lib/rails_com/{rails_ext → active_storage}/attachment_transfer.rb +15 -6
- data/lib/rails_com/{rails_ext → active_storage}/video_response.rb +6 -1
- data/lib/rails_com/active_storage.rb +9 -0
- data/lib/rails_com/all.rb +23 -0
- data/lib/rails_com/api.rb +24 -0
- data/lib/rails_com/config.rb +22 -14
- data/lib/rails_com/engine.rb +42 -21
- data/lib/rails_com/utils/hex_helper.rb +12 -0
- data/lib/rails_com/utils/jobber.rb +3 -1
- data/lib/rails_com/utils/num_helper.rb +7 -5
- data/lib/rails_com/utils/qrcode_helper.rb +35 -0
- data/lib/rails_com/utils/setting.rb +5 -5
- data/lib/rails_com/utils/time_helper.rb +2 -0
- data/lib/rails_com/utils/uid_helper.rb +22 -13
- data/lib/rails_com.rb +31 -29
- data/lib/templates/rails/scaffold_controller/api_controller.rb.tt +20 -19
- data/lib/templates/rails/scaffold_controller/controller.rb.tt +1 -52
- data/lib/templates/test_unit/scaffold/functional_test.rb.tt +64 -0
- metadata +558 -108
- data/app/assets/config/rails_com_manifest.js +0 -6
- data/app/assets/images/image-square.png +0 -0
- data/app/assets/images/verification.jpg +0 -0
- data/app/assets/javascripts/rails_com/application.js +0 -45
- data/app/assets/javascripts/rails_com/attachment.js +0 -416
- data/app/assets/javascripts/rails_com/checkbox.js +0 -59
- data/app/assets/javascripts/rails_com/fetch_xhr_script.js +0 -20
- data/app/assets/javascripts/rails_com/footer.js +0 -3
- data/app/assets/javascripts/rails_com/picture.js +0 -17
- data/app/assets/javascripts/rails_com/sidebar.js +0 -40
- data/app/assets/stylesheets/controllers/active_storage_ext/videos/show.css +0 -7
- data/app/assets/stylesheets/controllers/active_storage_ext/videos/transfer.css +0 -4
- data/app/assets/stylesheets/rails_com/application.css +0 -3
- data/app/controllers/active_storage_ext/admin/attachments_controller.rb +0 -13
- data/app/controllers/active_storage_ext/admin/base_controller.rb +0 -4
- data/app/controllers/active_storage_ext/admin/blob_defaults_controller.rb +0 -54
- data/app/controllers/active_storage_ext/admin/blobs_controller.rb +0 -48
- data/app/controllers/active_storage_ext/audios_controller.rb +0 -24
- data/app/controllers/active_storage_ext/videos_controller.rb +0 -25
- data/app/controllers/concerns/rails_common_api.rb +0 -50
- data/app/controllers/concerns/rails_common_xhr.rb +0 -15
- data/app/helpers/rails_com/assets_helper.rb +0 -91
- data/app/models/active_storage/blob_default.rb +0 -5
- data/app/models/concerns/state_machine.rb +0 -79
- data/app/views/active_storage_ext/admin/attachments/destroy.js.erb +0 -1
- data/app/views/active_storage_ext/admin/blob_defaults/_form.html.erb +0 -7
- data/app/views/active_storage_ext/admin/blob_defaults/_search_form.html.erb +0 -7
- data/app/views/active_storage_ext/admin/blob_defaults/edit.html.erb +0 -9
- data/app/views/active_storage_ext/admin/blob_defaults/index.html.erb +0 -48
- data/app/views/active_storage_ext/admin/blob_defaults/new.html.erb +0 -9
- data/app/views/active_storage_ext/admin/blob_defaults/show.html.erb +0 -10
- data/app/views/active_storage_ext/admin/blobs/_search_form.html.erb +0 -9
- data/app/views/active_storage_ext/admin/blobs/destroy.js.erb +0 -1
- data/app/views/active_storage_ext/admin/blobs/index.html.erb +0 -51
- data/app/views/active_storage_ext/admin/blobs/new.html.erb +0 -13
- data/app/views/active_storage_ext/admin/blobs/show.html.erb +0 -10
- data/app/views/active_storage_ext/attachments/_default_image_item.html.erb +0 -6
- data/app/views/active_storage_ext/attachments/_image_item.html.erb +0 -6
- data/app/views/active_storage_ext/attachments/_list.html.erb +0 -25
- data/app/views/active_storage_ext/attachments/_list_edit.html.erb +0 -25
- data/app/views/active_storage_ext/attachments/_list_form.html.erb +0 -28
- data/app/views/active_storage_ext/attachments/_video_item.html.erb +0 -6
- data/app/views/active_storage_ext/audios/show.html.erb +0 -5
- data/app/views/active_storage_ext/videos/show.html.erb +0 -6
- data/app/views/kaminari/_first_page.html.erb +0 -3
- data/app/views/kaminari/_last_page.html.erb +0 -3
- data/app/views/kaminari/_next_page.html.erb +0 -3
- data/app/views/kaminari/_page.html.erb +0 -1
- data/app/views/kaminari/_prev_page.html.erb +0 -3
- data/app/views/layouts/rails_com/application.html.erb +0 -17
- data/app/views/shared/_alert.html.erb +0 -8
- data/app/views/shared/_locales.html.erb +0 -8
- data/config/locales/zh.datetime.yml +0 -44
- data/db/migrate/20181012025833_rails_com_init.rb +0 -13
- data/lib/generators/doc_model_generator.rb +0 -37
- data/lib/generators/doc_models_generator.rb +0 -11
- data/lib/generators/templates/model.erb +0 -6
- data/lib/mina/git2.rb +0 -59
- data/lib/mina/puma.rb +0 -64
- data/lib/mina/sidekiq.rb +0 -67
- data/lib/mina/whenever.rb +0 -27
- data/lib/rails_com/core_ext/array.rb +0 -72
- data/lib/rails_com/core_ext/date.rb +0 -25
- data/lib/rails_com/core_ext/hash.rb +0 -38
- data/lib/rails_com/core_ext/nil.rb +0 -7
- data/lib/rails_com/core_ext/numeric.rb +0 -11
- data/lib/rails_com/core_ext/string.rb +0 -15
- data/lib/rails_com/helpers/controller_helper.rb +0 -30
- data/lib/rails_com/helpers/model_helper.rb +0 -107
- data/lib/rails_com/meta/controllers.rb +0 -8
- data/lib/rails_com/meta/models.rb +0 -21
- data/lib/rails_com/meta/routes.rb +0 -53
- data/lib/rails_com/rails_ext/attached_macros.rb +0 -21
- data/lib/rails_com/rails_ext/errors.rb +0 -4
- data/lib/rails_com/rails_ext/named_base.rb +0 -9
- data/lib/rails_com/rails_ext/persistence_sneakily.rb +0 -11
- data/lib/rails_com/rails_ext/scaffold_generator.rb +0 -15
- data/lib/rails_com/rails_ext/template_renderer.rb +0 -54
- data/lib/rails_com/rails_ext/translation_helper.rb +0 -18
- data/lib/rails_com/sprockets/non_digest_assets.rb +0 -16
- data/lib/rails_com/utils/babel.rb +0 -38
- data/lib/rails_com/version.rb +0 -3
- data/lib/tasks/rails_com_tasks.rake +0 -4
- data/lib/templates/erb/scaffold/_form.html.erb.tt +0 -12
- data/lib/templates/erb/scaffold/_search_form.html.erb.tt +0 -7
- data/lib/templates/erb/scaffold/edit.html.erb.tt +0 -9
- data/lib/templates/erb/scaffold/index.html.erb.tt +0 -47
- data/lib/templates/erb/scaffold/new.html.erb.tt +0 -9
- data/lib/templates/erb/scaffold/show.html.erb.tt +0 -16
data/config/routes.rb
CHANGED
@@ -1,20 +1,152 @@
|
|
1
1
|
Rails.application.routes.draw do
|
2
2
|
|
3
|
-
scope
|
3
|
+
scope 'rails/active_storage', module: :com, defaults: { business: 'com' } do
|
4
|
+
resources :direct_uploads, only: [:create]
|
5
|
+
end
|
6
|
+
|
7
|
+
controller :home do
|
8
|
+
get :index
|
9
|
+
end
|
10
|
+
|
11
|
+
namespace :panel, defaults: { namespace: 'panel' } do
|
12
|
+
controller :home do
|
13
|
+
get :index
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
scope :rails, module: 'com', as: :rails_ext, defaults: { business: 'com' } do
|
4
18
|
resources :videos, only: [:show] do
|
5
|
-
|
19
|
+
member do
|
20
|
+
put :transfer
|
21
|
+
end
|
6
22
|
end
|
7
23
|
resources :audios, only: [:show] do
|
8
|
-
|
24
|
+
member do
|
25
|
+
put :transfer
|
26
|
+
end
|
27
|
+
end
|
28
|
+
resources :pdfs, only: [:show] do
|
29
|
+
member do
|
30
|
+
get :png
|
31
|
+
get :jpg
|
32
|
+
end
|
9
33
|
end
|
10
34
|
end
|
11
35
|
|
12
|
-
scope
|
13
|
-
|
14
|
-
|
15
|
-
get :
|
36
|
+
scope module: 'com', defaults: { business: 'com' } do
|
37
|
+
controller :common do
|
38
|
+
get :infos
|
39
|
+
get :cache_list
|
40
|
+
get :enum_list
|
41
|
+
get :qrcode
|
42
|
+
get :test_raise
|
43
|
+
get :cancel
|
44
|
+
match :deploy, via: [:get, :post]
|
45
|
+
end
|
46
|
+
controller :log do
|
47
|
+
get '/not_founds' => :index
|
48
|
+
post '/csp_violation_report' => :csp
|
49
|
+
end
|
50
|
+
resources :nodes, only: [] do
|
51
|
+
collection do
|
52
|
+
get :children
|
53
|
+
get :outer
|
54
|
+
get :outer_search
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
namespace :com, defaults: { business: 'com' } do
|
60
|
+
namespace :panel, defaults: { namespace: 'panel' } do
|
61
|
+
resources :errs, only: [:index, :show, :destroy]
|
62
|
+
resources :csps, only: [:index, :show, :destroy]
|
63
|
+
resources :meta_namespaces do
|
64
|
+
collection do
|
65
|
+
post :sync
|
66
|
+
end
|
67
|
+
member do
|
68
|
+
patch :move_lower
|
69
|
+
patch :move_higher
|
70
|
+
end
|
71
|
+
end
|
72
|
+
resources :meta_businesses do
|
73
|
+
collection do
|
74
|
+
post :sync
|
75
|
+
end
|
76
|
+
member do
|
77
|
+
patch :move_lower
|
78
|
+
patch :move_higher
|
79
|
+
end
|
80
|
+
end
|
81
|
+
resources :meta_controllers, only: [:index] do
|
82
|
+
collection do
|
83
|
+
post :sync
|
84
|
+
post :meta_namespaces
|
85
|
+
post :meta_controllers
|
86
|
+
post :meta_actions
|
87
|
+
end
|
88
|
+
member do
|
89
|
+
patch :move_lower
|
90
|
+
patch :move_higher
|
91
|
+
end
|
92
|
+
resources :meta_actions do
|
93
|
+
member do
|
94
|
+
patch :move_lower
|
95
|
+
patch :move_higher
|
96
|
+
get :roles
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
resources :meta_models do
|
101
|
+
collection do
|
102
|
+
post :sync
|
103
|
+
end
|
104
|
+
resources :meta_columns do
|
105
|
+
member do
|
106
|
+
patch :sync
|
107
|
+
patch :test
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
resources :infos
|
112
|
+
resources :cache_lists
|
113
|
+
resources :inbound_emails
|
114
|
+
resources :attachments, only: [:index, :destroy] do
|
115
|
+
collection do
|
116
|
+
get :garbled
|
117
|
+
end
|
118
|
+
member do
|
119
|
+
delete :delete
|
120
|
+
end
|
121
|
+
end
|
122
|
+
resources :blobs, only: [:index, :show, :new, :create, :destroy] do
|
123
|
+
collection do
|
124
|
+
get :unattached
|
125
|
+
end
|
126
|
+
end
|
127
|
+
resources :blob_defaults do
|
128
|
+
collection do
|
129
|
+
get :add
|
130
|
+
end
|
131
|
+
end
|
132
|
+
resources :acme_accounts do
|
133
|
+
resources :acme_orders do
|
134
|
+
member do
|
135
|
+
patch :order
|
136
|
+
patch :verify
|
137
|
+
patch :cert
|
138
|
+
end
|
139
|
+
end
|
140
|
+
resources :acme_orders, only: [] do
|
141
|
+
resources :acme_identifiers, only: [:index, :new, :create]
|
142
|
+
resources :acme_identifiers, only: [:show, :edit, :update, :destroy]
|
143
|
+
end
|
144
|
+
end
|
16
145
|
end
|
17
|
-
resources :blob_defaults
|
18
146
|
end
|
19
147
|
|
20
148
|
end
|
149
|
+
|
150
|
+
Rails.application.routes.append do
|
151
|
+
match '*path' => 'com/log#not_found', via: :all
|
152
|
+
end if RailsCom.config.intercept_not_found
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'active_storage/service/disk_service'
|
2
|
+
module ActiveStorage
|
3
|
+
class Service
|
4
|
+
class DiscService < DiskService
|
5
|
+
|
6
|
+
def upload(key, io, checksum: nil, filename: nil, **)
|
7
|
+
path = filename.to_s
|
8
|
+
|
9
|
+
instrument :upload, key: key, checksum: checksum do
|
10
|
+
IO.copy_stream(io, make_path_for(path)) if path.present?
|
11
|
+
ensure_integrity_of(path, checksum) if checksum
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def download(key, &block)
|
16
|
+
path = ActiveStorage::Blob.find_by(key: key)&.filename.to_s
|
17
|
+
|
18
|
+
if block_given?
|
19
|
+
instrument :streaming_download, key: key do
|
20
|
+
stream path, &block
|
21
|
+
end
|
22
|
+
else
|
23
|
+
instrument :download, key: key do
|
24
|
+
File.binread path_for(path)
|
25
|
+
rescue Errno::ENOENT
|
26
|
+
raise ActiveStorage::FileNotFoundError
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def make_path_for(path)
|
32
|
+
path_for(path).tap { |p| FileUtils.mkdir_p File.dirname(p) }
|
33
|
+
end
|
34
|
+
|
35
|
+
def path_for(path)
|
36
|
+
File.join root, path
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module DefaultForm::ActiveRecord
|
2
|
+
module Extend
|
3
|
+
|
4
|
+
def input_attributes_by_model
|
5
|
+
cols = {}
|
6
|
+
|
7
|
+
attributes_by_model.each do |name, column|
|
8
|
+
r = {}
|
9
|
+
r.merge! column.slice(:type, :subtype, :outer)
|
10
|
+
r.merge! input_type: column[:raw_type]
|
11
|
+
|
12
|
+
if r[:type].respond_to? :input_type
|
13
|
+
r.merge! input_type: r[:type].input_type
|
14
|
+
end
|
15
|
+
|
16
|
+
case r[:type].class.name
|
17
|
+
when 'ActiveRecord::Enum::EnumType'
|
18
|
+
r.merge! input_type: :enum
|
19
|
+
r.merge! mapping: r[:type].send(:mapping)
|
20
|
+
end
|
21
|
+
|
22
|
+
if inheritance_column.to_s == name
|
23
|
+
r.merge! input_type: :enum
|
24
|
+
end
|
25
|
+
r.merge! DefaultForm.config.mapping.fetch(r[:input_type], {})
|
26
|
+
|
27
|
+
cols.merge! name => r
|
28
|
+
end
|
29
|
+
|
30
|
+
cols
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
ActiveSupport.on_load :active_record do
|
37
|
+
extend DefaultForm::ActiveRecord::Extend
|
38
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DefaultForm::Builder
|
4
|
+
module Default
|
5
|
+
VALIDATIONS = [
|
6
|
+
:required,
|
7
|
+
:pattern,
|
8
|
+
:min, :max, :step,
|
9
|
+
:maxlength
|
10
|
+
].freeze
|
11
|
+
|
12
|
+
def default_label(method)
|
13
|
+
if object.is_a?(ActiveRecord::Base)
|
14
|
+
object.class.human_attribute_name(method)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def default_help(method)
|
19
|
+
if object.is_a?(ActiveRecord::Base)
|
20
|
+
object.class.help_i18n(method)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def default_value(method)
|
25
|
+
if object.is_a?(ActiveRecord::Base)
|
26
|
+
r = object.respond_to?(method) && object.send(method)
|
27
|
+
return r if r
|
28
|
+
end
|
29
|
+
|
30
|
+
if object_name.present?
|
31
|
+
params.dig(object_name, method)
|
32
|
+
else
|
33
|
+
params[method]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def default_step(method)
|
38
|
+
if object.is_a?(ActiveRecord::Base)
|
39
|
+
col = object.class.column_for_attribute(method)
|
40
|
+
|
41
|
+
if col.type == :decimal
|
42
|
+
0.01
|
43
|
+
else
|
44
|
+
1
|
45
|
+
end
|
46
|
+
#scale = col.scale || col.limit
|
47
|
+
#0.1.to_d.power(scale.to_i)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def default_options(method = nil, options = {})
|
52
|
+
# search 应返回默认 params 中对应的 value
|
53
|
+
on = options.slice(:label, :placeholder, :autocomplete, :autofilter)
|
54
|
+
on.reverse_merge! on_options
|
55
|
+
if on[:autofilter] && !(options.key?(:value) || on[:autocomplete])
|
56
|
+
options[:value] = default_value(method)
|
57
|
+
end
|
58
|
+
|
59
|
+
if on[:placeholder] && !options.key?(:placeholder)
|
60
|
+
options[:placeholder] = default_label(method)
|
61
|
+
end
|
62
|
+
|
63
|
+
if on[:label] && !options.key?(:label)
|
64
|
+
options[:label] = default_label(method)
|
65
|
+
end
|
66
|
+
|
67
|
+
valid_key = options.keys.map(&:to_sym) & VALIDATIONS
|
68
|
+
if valid_key.present?
|
69
|
+
action_str = 'default_valid#clear blur->default_valid#check invalid->default_valid#notice'
|
70
|
+
options[:data] ||= {}
|
71
|
+
if options[:data][:action].present?
|
72
|
+
options[:data][:action] += " #{action_str}"
|
73
|
+
else
|
74
|
+
options[:data][:action] = action_str
|
75
|
+
end unless options[:data].key?(:valid)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def default_without_method(options = {})
|
80
|
+
origin = (options.delete(:origin) || {}).with_defaults!(origin_css)
|
81
|
+
wrap = (options.delete(:wrap) || {}).with_defaults!(wrap_css)
|
82
|
+
error = (options.delete(:error) || {}).with_defaults!(error_css)
|
83
|
+
|
84
|
+
[origin, wrap, error]
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,212 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DefaultForm::Builder
|
4
|
+
module Helper
|
5
|
+
include Wrap
|
6
|
+
include Default
|
7
|
+
|
8
|
+
INPUT_FIELDS = [
|
9
|
+
:text_field,
|
10
|
+
:password_field,
|
11
|
+
:color_field,
|
12
|
+
:search_field,
|
13
|
+
:telephone_field,
|
14
|
+
:phone_field,
|
15
|
+
:time_field,
|
16
|
+
:datetime_field,
|
17
|
+
:datetime_local_field,
|
18
|
+
:month_field,
|
19
|
+
:week_field,
|
20
|
+
:url_field,
|
21
|
+
:email_field,
|
22
|
+
:range_field,
|
23
|
+
:file_field,
|
24
|
+
:date_select
|
25
|
+
].freeze
|
26
|
+
|
27
|
+
def fields(scope = nil, model: nil, **options, &block)
|
28
|
+
options[:theme] ||= theme
|
29
|
+
super
|
30
|
+
end
|
31
|
+
|
32
|
+
def label(method, text = nil, options = {}, &block)
|
33
|
+
origin = (options.delete(:origin) || {}).with_defaults!(origin_css)
|
34
|
+
wrap = (options.delete(:wrap) || {}).with_defaults!(wrap_css)
|
35
|
+
options[:class] = origin[:label] unless options.key?(:class)
|
36
|
+
|
37
|
+
wrapping(:label, super, wrap: wrap)
|
38
|
+
end
|
39
|
+
|
40
|
+
def submit(value = nil, options = {})
|
41
|
+
wrap_all_with(nil, options) do |css|
|
42
|
+
options[:class] = css.dig(:origin, :submit) unless options.key?(:class)
|
43
|
+
css[:wrap][:all] = css.dig(:wrap, :all_submit)
|
44
|
+
|
45
|
+
submit_content = wrapping(:submit, super, wrap: css[:wrap])
|
46
|
+
offset(css.dig(:offset, :submit)) + submit_content
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def check_box(method, options = {}, checked_value = '1', unchecked_value = '0')
|
51
|
+
wrap_all_with(method, options) do |css|
|
52
|
+
default_options(method, options)
|
53
|
+
options[:class] = css.dig(:origin, :checkbox) unless options.key?(:class)
|
54
|
+
r = options.delete(:label)
|
55
|
+
if r.present?
|
56
|
+
label_text = content_tag(:span, r)
|
57
|
+
else
|
58
|
+
label_text = ''
|
59
|
+
end
|
60
|
+
checkbox_content = wrapping(:checkbox, super + label_text, wrap: css[:wrap], tag: 'label')
|
61
|
+
|
62
|
+
offset(css.dig(:offset, :submit)) + checkbox_content
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def collection_check_boxes(method, collection, value_method, text_method, options = {}, html_options = {}, &block)
|
67
|
+
wrap_with(method, options) do |css|
|
68
|
+
wrapping(:checkboxes, super, wrap: css[:wrap])
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def radio_button(method, tag_value, options = {})
|
73
|
+
wrap_with(method, options) do |css|
|
74
|
+
options[:class] = css.dig(:origin, :radio) unless options.key?(:class)
|
75
|
+
value_content = label(method, tag_value, class: nil)
|
76
|
+
wrapping(:radio, super + value_content, wrap: css[:wrap])
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def collection_radio_buttons(method, collection, value_method, text_method, options = {}, html_options = {}, &block)
|
81
|
+
wrap_with(method, options) do |css|
|
82
|
+
wrapping(:radios, super, wrap: css[:wrap])
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def select(method, choices = nil, options = {}, html_options = {}, &block)
|
87
|
+
wrap_with(method, options) do |css|
|
88
|
+
options[:selected] ||= default_value(method)
|
89
|
+
if html_options[:multiple]
|
90
|
+
html_options[:class] = css.dig(:origin, :multi_select)
|
91
|
+
else
|
92
|
+
html_options[:class] = css.dig(:origin, :select)
|
93
|
+
end unless html_options.key?(:class)
|
94
|
+
options[:include_blank] = I18n.t('helpers.select.prompt') if options[:include_blank] == true
|
95
|
+
|
96
|
+
wrapping(:select, super, wrap: css[:wrap])
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def collection_select(method, collection, value_method, text_method, options = {}, html_options = {})
|
101
|
+
wrap_with(method, options) do |css|
|
102
|
+
html_options[:class] = if html_options[:multiple]
|
103
|
+
css.dig(:origin, :multi_select)
|
104
|
+
else
|
105
|
+
css.dig(:origin, :select)
|
106
|
+
end unless html_options.key?(:class)
|
107
|
+
options[:include_blank] = I18n.t('helpers.select.prompt') if options[:include_blank] == true
|
108
|
+
|
109
|
+
wrapping(:select, super, wrap: css[:wrap])
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def time_zone_select(method, priority_zones = nil, options = {}, html_options = {})
|
114
|
+
wrap_with(method, options) do |css|
|
115
|
+
html_options[:class] = if html_options[:multiple]
|
116
|
+
css.dig(:origin, :multi_select)
|
117
|
+
else
|
118
|
+
css.dig(:origin, :select)
|
119
|
+
end unless html_options.key?(:class)
|
120
|
+
|
121
|
+
wrapping(:select, super, wrap: css[:wrap])
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
def time_select(method, options = {}, html_options = {})
|
126
|
+
wrap_with(method, options) do |css|
|
127
|
+
html_options[:class] = css.dig(:origin, :select) unless html_options.key?(:class)
|
128
|
+
wrapping(:select, super, wrap: css[:wrap])
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def hidden_field(method, options = {})
|
133
|
+
options[:autocomplete] = on_options[:autocomplete] unless options.key?(:autocomplete)
|
134
|
+
super
|
135
|
+
end
|
136
|
+
|
137
|
+
def date_field(method, options = {})
|
138
|
+
wrap_with(method, options) do |css|
|
139
|
+
options[:class] = css.dig(:origin, :input) unless options.key?(:class)
|
140
|
+
if method.end_with?('(date)')
|
141
|
+
real_method = method.to_s.sub('(date)', '')
|
142
|
+
options[:data] = {}
|
143
|
+
options[:data].merge! controller: 'datetime', action: 'datetime#default' if object.column_for_attribute(real_method).type == :datetime
|
144
|
+
options[:value] = object.read_attribute(real_method)&.to_date
|
145
|
+
end
|
146
|
+
|
147
|
+
wrapping(:input, super, wrap: css[:wrap])
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
def number_field(method, options = {})
|
152
|
+
wrap_with(method, options) do |css|
|
153
|
+
options[:class] = css.dig(:origin, :input) unless options.key?(:class)
|
154
|
+
options[:step] = default_step(method) unless options.key?(:step)
|
155
|
+
wrapping(:input, super, wrap: css[:wrap])
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
def text_area(method, options = {})
|
160
|
+
wrap_with(method, options) do |css|
|
161
|
+
options[:class] = css.dig(:origin, :textarea) unless options.key?(:class)
|
162
|
+
wrapping(:input, super, wrap: css[:wrap])
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
# block 应返回 input with wrapper 的内容
|
167
|
+
def wrap_with(method, options = {})
|
168
|
+
wrap_all_with(method, options) do |css|
|
169
|
+
default_options(method, options)
|
170
|
+
if options[:label]
|
171
|
+
label_content = label method, options.delete(:label), options.slice(:origin, :wrap)
|
172
|
+
else
|
173
|
+
options.delete(:label)
|
174
|
+
label_content = ''.html_safe
|
175
|
+
end
|
176
|
+
input_content = yield css
|
177
|
+
|
178
|
+
label_content + input_content
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
# block 应返回 label_content + input_content 的内容
|
183
|
+
def wrap_all_with(method, options)
|
184
|
+
css = {}
|
185
|
+
css[:origin] = origin_css.merge options.delete(:origin) || {}
|
186
|
+
css[:wrap] = wrap_css.merge options.delete(:wrap) || {}
|
187
|
+
css[:error] = error_css.merge options.delete(:error) || {}
|
188
|
+
css[:offset] = offset_css.merge options.delete(:offset) || {}
|
189
|
+
inner_content = yield css
|
190
|
+
|
191
|
+
wrapping_all inner_content, method, wrap: css[:wrap], required: options[:required]
|
192
|
+
end
|
193
|
+
|
194
|
+
INPUT_FIELDS.each do |selector|
|
195
|
+
class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
|
196
|
+
def #{selector}(method, options = {})
|
197
|
+
wrap_with(method, options) do |css|
|
198
|
+
unless options.key?(:class)
|
199
|
+
if object_has_errors?(method)
|
200
|
+
options[:class] = css.dig(:error, :input)
|
201
|
+
else
|
202
|
+
options[:class] = css.dig(:origin, :input)
|
203
|
+
end
|
204
|
+
end
|
205
|
+
wrapping(:input, super, wrap: css[:wrap])
|
206
|
+
end
|
207
|
+
end
|
208
|
+
RUBY_EVAL
|
209
|
+
end
|
210
|
+
|
211
|
+
end
|
212
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DefaultForm::Builder
|
4
|
+
module Wrap
|
5
|
+
|
6
|
+
def wrapping(type, inner, tag: 'div', wrap: {})
|
7
|
+
if wrap[type].present?
|
8
|
+
css_ary = wrap[type].split(' > ')
|
9
|
+
css_ary.reverse_each.with_index do |css, index|
|
10
|
+
if index == 0
|
11
|
+
inner = content_tag(tag, inner, class: css)
|
12
|
+
else
|
13
|
+
inner = content_tag('div', inner, class: css)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
inner
|
19
|
+
end
|
20
|
+
|
21
|
+
def wrapping_all(inner, method = nil, wrap: {}, required: false)
|
22
|
+
if method && object_has_errors?(method)
|
23
|
+
final_css = wrap[:all_error]
|
24
|
+
elsif required
|
25
|
+
final_css = wrap[:all_required]
|
26
|
+
else
|
27
|
+
final_css = wrap[:all]
|
28
|
+
end
|
29
|
+
|
30
|
+
if final_css
|
31
|
+
if method
|
32
|
+
help_text = default_help(method)
|
33
|
+
inner += help_tag(help_text) if help_text
|
34
|
+
end
|
35
|
+
content_tag(:div, inner, class: final_css)
|
36
|
+
else
|
37
|
+
inner
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def offset(css)
|
42
|
+
if css.present?
|
43
|
+
content_tag(:div, '', class: css)
|
44
|
+
else
|
45
|
+
''.html_safe
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def help_tag(text)
|
50
|
+
DefaultForm.config.help_tag.call(self, text)
|
51
|
+
end
|
52
|
+
|
53
|
+
def object_has_errors?(method)
|
54
|
+
object.respond_to?(:errors) && object.errors.respond_to?(:[]) && object.errors[method].present?
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/configurable'
|
4
|
+
|
5
|
+
module DefaultForm
|
6
|
+
include ActiveSupport::Configurable
|
7
|
+
|
8
|
+
configure do |config|
|
9
|
+
config.theme = 'default'
|
10
|
+
config.help_tag = ->(app, text) {
|
11
|
+
app.content_tag(:span, aria: { label: text }) do
|
12
|
+
app.content_tag(:i, nil, class: 'fas fa-question-circle')
|
13
|
+
end
|
14
|
+
}
|
15
|
+
config.mapping = ActiveSupport::OrderedOptions.new
|
16
|
+
config.mapping.date = {
|
17
|
+
input: 'date_field',
|
18
|
+
output: 'to_date'
|
19
|
+
}
|
20
|
+
config.mapping.integer = {
|
21
|
+
input: 'number_field',
|
22
|
+
options: { step: 1 },
|
23
|
+
output: 'to_i'
|
24
|
+
}
|
25
|
+
config.mapping.decimal = {
|
26
|
+
input: 'number_field',
|
27
|
+
options: { step: 0.01 }
|
28
|
+
}
|
29
|
+
config.mapping.string = {
|
30
|
+
input: 'text_field',
|
31
|
+
output: 'to_s'
|
32
|
+
}
|
33
|
+
config.mapping.text = {
|
34
|
+
input: 'text_area',
|
35
|
+
output: 'to_s'
|
36
|
+
}
|
37
|
+
config.mapping.array = {
|
38
|
+
input: 'text_field',
|
39
|
+
options: { multiple: true },
|
40
|
+
output: 'to_s'
|
41
|
+
}
|
42
|
+
config.mapping.taxon = {
|
43
|
+
input: 'outer_select'
|
44
|
+
}
|
45
|
+
config.mapping.enum = {
|
46
|
+
input: 'select_enum'
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'default_form/form_builder'
|
2
|
+
|
3
|
+
module DefaultForm::ControllerHelper
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
default_form_builder DefaultForm::FormBuilder
|
8
|
+
end
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
ActiveSupport.on_load :action_controller_base do
|
13
|
+
include DefaultForm::ControllerHelper
|
14
|
+
end
|