infold 0.1.1 → 0.2.1

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.
Files changed (438) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +418 -20
  3. data/Rakefile +0 -5
  4. data/lib/generators/infold/controller_generator.rb +52 -0
  5. data/lib/generators/infold/decorator_generator.rb +32 -0
  6. data/lib/generators/infold/install_generator.rb +98 -0
  7. data/lib/generators/infold/model_generator.rb +33 -0
  8. data/lib/generators/infold/resource_generator.rb +12 -0
  9. data/lib/generators/infold/scaffold_generator.rb +16 -0
  10. data/lib/generators/infold/search_form_generator.rb +24 -0
  11. data/lib/generators/infold/templates/controller.rb.tt +70 -0
  12. data/lib/generators/infold/templates/decorator.rb.tt +6 -0
  13. data/lib/generators/infold/templates/install/app/components/admin/association_field_component.html.haml +10 -0
  14. data/lib/generators/infold/templates/install/app/components/admin/association_field_component.rb +25 -0
  15. data/lib/generators/infold/templates/install/app/components/admin/badge_component.rb +18 -0
  16. data/lib/generators/infold/templates/install/app/components/admin/checkbox_component.html.haml +4 -0
  17. data/lib/generators/infold/templates/install/app/components/admin/checkbox_component.rb +22 -0
  18. data/lib/generators/infold/templates/install/app/components/admin/datetime_component.html.haml +13 -0
  19. data/lib/generators/infold/templates/install/app/components/admin/datetime_component.rb +10 -0
  20. data/lib/generators/infold/templates/install/app/components/admin/fieldset_component.html.haml +12 -0
  21. data/lib/generators/infold/templates/install/app/components/admin/fieldset_component.rb +73 -0
  22. data/lib/generators/infold/{install/templates/app/components/admin/form → templates/install/app/components/admin}/file_upload_component.html.haml +2 -6
  23. data/lib/generators/infold/templates/install/app/components/admin/file_upload_component.rb +10 -0
  24. data/lib/generators/infold/templates/install/app/components/admin/input_group_component.html.haml +6 -0
  25. data/lib/generators/infold/templates/install/app/components/admin/input_group_component.rb +10 -0
  26. data/lib/generators/infold/templates/install/app/components/admin/invalid_message_component.rb +17 -0
  27. data/lib/generators/infold/templates/install/app/components/admin/label_component.rb +16 -0
  28. data/lib/generators/infold/templates/install/app/components/admin/radio_component.html.haml +4 -0
  29. data/lib/generators/infold/templates/install/app/components/admin/radio_component.rb +22 -0
  30. data/lib/generators/infold/{install/templates → templates/install}/app/components/admin/remote_modal_component.html.haml +4 -3
  31. data/lib/generators/infold/templates/install/app/components/admin/remote_modal_component.rb +14 -0
  32. data/lib/generators/infold/templates/install/app/components/admin/select_component.rb +26 -0
  33. data/lib/generators/infold/templates/install/app/components/admin/sortable_component.html.haml +2 -0
  34. data/lib/generators/infold/templates/install/app/components/admin/sortable_component.rb +35 -0
  35. data/lib/generators/infold/templates/install/app/components/admin/switch_component.html.haml +3 -0
  36. data/lib/generators/infold/templates/install/app/components/admin/switch_component.rb +17 -0
  37. data/lib/generators/infold/templates/install/app/components/admin/text_component.rb +40 -0
  38. data/lib/generators/infold/{install/templates → templates/install}/app/controllers/admin/admin_users/registrations_controller.rb +0 -0
  39. data/lib/generators/infold/{install/templates → templates/install}/app/controllers/admin/admin_users/sessions_controller.rb +0 -0
  40. data/lib/generators/infold/{install/templates → templates/install}/app/controllers/admin/base_controller.rb +3 -3
  41. data/lib/generators/infold/{install/templates → templates/install}/app/controllers/admin/errors_controller.rb +0 -0
  42. data/lib/generators/infold/{install/templates → templates/install}/app/controllers/admin/turbo_devise_controller.rb +0 -0
  43. data/lib/generators/infold/{install/templates → templates/install}/app/controllers/concerns/admin/error_handlers.rb +1 -0
  44. data/lib/generators/infold/{install/templates/app/forms/admin/search_form_base.rb → templates/install/app/forms/admin/base_search_form.rb} +1 -1
  45. data/lib/generators/infold/templates/install/app/helpers/admin_helper.rb +23 -0
  46. data/lib/generators/infold/templates/install/app/javascript/admin/admin.css +188 -0
  47. data/lib/generators/infold/templates/install/app/javascript/admin/admin.scss +195 -0
  48. data/{app/javascript → lib/generators/infold/templates/install/app/javascript/admin}/controllers/application.js +0 -0
  49. data/lib/generators/infold/{install/templates → templates/install/app}/javascript/admin/controllers/datepicker_controller.js +1 -1
  50. data/{app/javascript → lib/generators/infold/templates/install/app/javascript/admin}/controllers/flash_controller.js +0 -0
  51. data/lib/generators/infold/{install/templates → templates/install/app}/javascript/admin/controllers/index.js +0 -0
  52. data/lib/generators/infold/{install/templates → templates/install/app}/javascript/admin/controllers/index_page_controller.js +0 -0
  53. data/lib/generators/infold/{install/templates → templates/install/app}/javascript/admin/controllers/nested_form_controller.js +0 -0
  54. data/lib/generators/infold/{install/templates → templates/install/app}/javascript/admin/controllers/relation_search_controller.js +0 -0
  55. data/lib/generators/infold/{install/templates → templates/install/app}/javascript/admin/controllers/remote_modal_controller.js +7 -7
  56. data/lib/generators/infold/{install/templates → templates/install/app}/javascript/admin/controllers/timepicker_controller.js +0 -0
  57. data/lib/generators/infold/templates/install/app/javascript/admin.js +9 -0
  58. data/lib/generators/infold/{install/templates → templates/install}/app/models/concerns/admin/datetime_field_concern.rb +12 -12
  59. data/lib/generators/infold/{install/templates → templates/install}/app/views/admin/admin_users/registrations/edit.html.haml +4 -3
  60. data/lib/generators/infold/{install/templates → templates/install}/app/views/admin/admin_users/sessions/new.html.haml +2 -2
  61. data/lib/generators/infold/{install/templates → templates/install}/app/views/admin/common/_flash.html.haml +0 -0
  62. data/lib/generators/infold/templates/install/app/views/admin/common/_header_menu.html.haml +1 -0
  63. data/lib/generators/infold/{install/templates → templates/install}/app/views/admin/errors/bad_request.html.haml +0 -0
  64. data/lib/generators/infold/{install/templates → templates/install}/app/views/admin/errors/forbidden.html.haml +0 -0
  65. data/lib/generators/infold/{install/templates → templates/install}/app/views/admin/errors/internal_server_error.html.haml +0 -0
  66. data/lib/generators/infold/{install/templates → templates/install}/app/views/admin/errors/not_found.html.haml +0 -0
  67. data/lib/generators/infold/{install/templates → templates/install}/app/views/admin/kaminari/_first_page.html.haml +0 -0
  68. data/lib/generators/infold/{install/templates → templates/install}/app/views/admin/kaminari/_gap.html.haml +0 -0
  69. data/lib/generators/infold/{install/templates → templates/install}/app/views/admin/kaminari/_last_page.html.haml +0 -0
  70. data/lib/generators/infold/{install/templates → templates/install}/app/views/admin/kaminari/_next_page.html.haml +0 -0
  71. data/lib/generators/infold/{install/templates → templates/install}/app/views/admin/kaminari/_page.html.haml +0 -0
  72. data/lib/generators/infold/{install/templates → templates/install}/app/views/admin/kaminari/_paginator.html.haml +0 -0
  73. data/lib/generators/infold/{install/templates → templates/install}/app/views/admin/kaminari/_prev_page.html.haml +0 -0
  74. data/lib/generators/infold/{install/templates/app/views/layouts/admin.haml.tt → templates/install/app/views/layouts/admin.html.haml} +8 -12
  75. data/lib/generators/infold/templates/install/config/infold/admin_user.yml +31 -0
  76. data/lib/generators/infold/{install/templates → templates/install}/config/locales/infold.en.yml +4 -3
  77. data/lib/generators/infold/{install/templates → templates/install}/config/locales/infold.ja.yml +1 -0
  78. data/lib/generators/infold/{install/templates → templates/install}/config/routes/admin.rb +1 -0
  79. data/lib/generators/infold/templates/model.rb.tt +34 -0
  80. data/lib/generators/infold/templates/resource.yml.tt +94 -0
  81. data/lib/generators/infold/templates/search_form.rb.tt +23 -0
  82. data/lib/generators/infold/templates/views/_form.haml.tt +36 -0
  83. data/lib/generators/infold/templates/views/_form_association.haml.tt +9 -0
  84. data/lib/generators/infold/templates/views/_index_row.haml.tt +12 -0
  85. data/lib/generators/infold/templates/views/_show_content.haml.tt +39 -0
  86. data/lib/generators/infold/templates/views/_show_wrapper.haml.tt +15 -0
  87. data/lib/generators/infold/templates/views/edit.html+turbo_frame.haml.tt +15 -0
  88. data/lib/generators/infold/templates/views/form.turbo_stream.haml.tt +16 -0
  89. data/lib/generators/infold/templates/views/index.csv.ruby.tt +19 -0
  90. data/lib/generators/infold/templates/views/index.haml.tt +45 -0
  91. data/lib/generators/infold/templates/views/index.html+turbo_frame.haml.tt +41 -0
  92. data/lib/generators/infold/templates/views/new.html+turbo_frame.haml.tt +15 -0
  93. data/lib/generators/infold/templates/views/show.html+turbo_frame.haml.tt +4 -0
  94. data/lib/generators/infold/views/form_generator.rb +52 -0
  95. data/lib/generators/infold/views/index_generator.rb +38 -0
  96. data/lib/generators/infold/views/show_generator.rb +34 -0
  97. data/lib/generators/infold/views_generator.rb +13 -0
  98. data/lib/generators/infold_generator.rb +11 -0
  99. data/lib/infold/db_schema.rb +29 -0
  100. data/lib/infold/field.rb +104 -0
  101. data/lib/infold/field_group.rb +118 -0
  102. data/lib/infold/property/active_storage.rb +38 -0
  103. data/lib/infold/property/association.rb +85 -0
  104. data/lib/infold/property/condition.rb +60 -0
  105. data/lib/infold/property/decorator.rb +30 -0
  106. data/lib/infold/property/default_order.rb +14 -0
  107. data/lib/infold/property/enum.rb +30 -0
  108. data/lib/infold/property/form_element.rb +62 -0
  109. data/lib/infold/property/show_element.rb +26 -0
  110. data/lib/infold/property/validation.rb +38 -0
  111. data/lib/infold/railtie.rb +4 -0
  112. data/lib/infold/resource.rb +32 -0
  113. data/lib/infold/table.rb +25 -0
  114. data/lib/infold/version.rb +1 -1
  115. data/lib/infold/writers/base_writer.rb +45 -0
  116. data/lib/infold/writers/controller_writer.rb +69 -0
  117. data/lib/infold/writers/decorator_writer.rb +94 -0
  118. data/lib/infold/writers/model_writer.rb +159 -0
  119. data/lib/infold/writers/search_form_writer.rb +23 -0
  120. data/lib/infold/writers/views/base_writer.rb +91 -0
  121. data/lib/infold/writers/views/form_writer.rb +39 -0
  122. data/lib/infold/writers/views/index_writer.rb +51 -0
  123. data/lib/infold/writers/views/show_writer.rb +16 -0
  124. data/lib/infold/yaml_reader.rb +253 -0
  125. data/lib/infold.rb +1 -1
  126. data/lib/tasks/infold_tasks.rake +0 -121
  127. metadata +246 -405
  128. data/app/assets/builds/infold.css +0 -17147
  129. data/app/assets/builds/infold.css.map +0 -7
  130. data/app/assets/builds/infold.js +0 -17202
  131. data/app/assets/builds/infold.js.map +0 -7
  132. data/app/assets/config/infold_manifest.js +0 -0
  133. data/app/assets/stylesheets/infold.custom.css +0 -76
  134. data/app/assets/stylesheets/infold.custom.css.map +0 -1
  135. data/app/components/infold/input_fieldset_component.html.haml +0 -14
  136. data/app/components/infold/input_fieldset_component.rb +0 -22
  137. data/app/components/infold/radio_fieldset_component.html.haml +0 -11
  138. data/app/components/infold/radio_fieldset_component.rb +0 -14
  139. data/app/components/infold/select_fieldset_component.html.haml +0 -7
  140. data/app/components/infold/select_fieldset_component.rb +0 -15
  141. data/app/controllers/infold/app_view_forms_controller.rb +0 -64
  142. data/app/controllers/infold/app_view_shows_controller.rb +0 -60
  143. data/app/controllers/infold/application_controller.rb +0 -17
  144. data/app/controllers/infold/apps_controller.rb +0 -68
  145. data/app/controllers/infold/attachment_fields_controller.rb +0 -59
  146. data/app/controllers/infold/builds_controller.rb +0 -21
  147. data/app/controllers/infold/columns_controller.rb +0 -89
  148. data/app/controllers/infold/csv_columns_controller.rb +0 -43
  149. data/app/controllers/infold/form_associations_controller.rb +0 -57
  150. data/app/controllers/infold/menu_directories_controller.rb +0 -19
  151. data/app/controllers/infold/menus_controller.rb +0 -35
  152. data/app/controllers/infold/models_controller.rb +0 -28
  153. data/app/controllers/infold/pages_controller.rb +0 -8
  154. data/app/controllers/infold/search_conditions_controller.rb +0 -63
  155. data/app/controllers/infold/search_result_fields_controller.rb +0 -62
  156. data/app/controllers/infold/show_associations_controller.rb +0 -54
  157. data/app/controllers/infold/sync_dbs_controller.rb +0 -13
  158. data/app/decorators/infold/app_view_form_decorator.rb +0 -56
  159. data/app/decorators/infold/app_view_index_decorator.rb +0 -53
  160. data/app/decorators/infold/app_view_modal_decorator.rb +0 -13
  161. data/app/decorators/infold/app_view_show_decorator.rb +0 -26
  162. data/app/decorators/infold/attachment_field_decorator.rb +0 -40
  163. data/app/decorators/infold/build_decorator.rb +0 -15
  164. data/app/decorators/infold/column_display_decorator.rb +0 -59
  165. data/app/decorators/infold/csv_column_decorator.rb +0 -5
  166. data/app/decorators/infold/form_association_column_decorator.rb +0 -5
  167. data/app/decorators/infold/form_column_decorator.rb +0 -57
  168. data/app/decorators/infold/model_association_decorator.rb +0 -39
  169. data/app/decorators/infold/model_column_decorator.rb +0 -201
  170. data/app/decorators/infold/model_decorator.rb +0 -27
  171. data/app/decorators/infold/search_condition_decorator.rb +0 -101
  172. data/app/decorators/infold/search_result_column_decorator.rb +0 -5
  173. data/app/decorators/infold/show_association_column_decorator.rb +0 -5
  174. data/app/decorators/infold/show_association_decorator.rb +0 -13
  175. data/app/decorators/infold/show_field_decorator.rb +0 -5
  176. data/app/helpers/infold/application_helper.rb +0 -29
  177. data/app/javascript/admin.scss +0 -5
  178. data/app/javascript/controllers/attachment_field_controller.js +0 -19
  179. data/app/javascript/controllers/column_controller.js +0 -20
  180. data/app/javascript/controllers/index.js +0 -32
  181. data/app/javascript/controllers/menu_controller.js +0 -26
  182. data/app/javascript/controllers/menu_directory_controller.js +0 -16
  183. data/app/javascript/controllers/modal_controller.js +0 -15
  184. data/app/javascript/controllers/nested_form_controller.js +0 -32
  185. data/app/javascript/controllers/search_condition_controller.js +0 -41
  186. data/app/javascript/controllers/sortable_controller.js +0 -19
  187. data/app/javascript/infold.js +0 -22
  188. data/app/javascript/infold.scss +0 -68
  189. data/app/javascript/stylesheets/admin/common.scss +0 -112
  190. data/app/javascript/stylesheets/admin/form.scss +0 -52
  191. data/app/javascript/stylesheets/admin/index.scss +0 -93
  192. data/app/javascript/stylesheets/admin/modal.scss +0 -37
  193. data/app/javascript/stylesheets/admin/show.scss +0 -16
  194. data/app/jobs/infold/application_job.rb +0 -4
  195. data/app/mailers/infold/application_mailer.rb +0 -6
  196. data/app/models/concerns/infold/app_view_search_concern.rb +0 -72
  197. data/app/models/concerns/infold/form_column_concern.rb +0 -63
  198. data/app/models/infold/app.rb +0 -41
  199. data/app/models/infold/app_view.rb +0 -27
  200. data/app/models/infold/app_view_form.rb +0 -43
  201. data/app/models/infold/app_view_index.rb +0 -36
  202. data/app/models/infold/app_view_modal.rb +0 -21
  203. data/app/models/infold/app_view_show.rb +0 -47
  204. data/app/models/infold/application_record.rb +0 -7
  205. data/app/models/infold/attachment_field.rb +0 -35
  206. data/app/models/infold/build.rb +0 -35
  207. data/app/models/infold/csv_column.rb +0 -9
  208. data/app/models/infold/enum.rb +0 -12
  209. data/app/models/infold/form_association.rb +0 -41
  210. data/app/models/infold/form_association_attachment_field.rb +0 -5
  211. data/app/models/infold/form_association_column.rb +0 -5
  212. data/app/models/infold/form_association_field.rb +0 -7
  213. data/app/models/infold/form_attachment_field.rb +0 -5
  214. data/app/models/infold/form_column.rb +0 -5
  215. data/app/models/infold/form_field.rb +0 -7
  216. data/app/models/infold/menu_item.rb +0 -45
  217. data/app/models/infold/model.rb +0 -40
  218. data/app/models/infold/model_association.rb +0 -51
  219. data/app/models/infold/model_column.rb +0 -127
  220. data/app/models/infold/project.rb +0 -29
  221. data/app/models/infold/schema_rb.rb +0 -178
  222. data/app/models/infold/search_condition.rb +0 -62
  223. data/app/models/infold/search_result_attachment_field.rb +0 -5
  224. data/app/models/infold/search_result_column.rb +0 -6
  225. data/app/models/infold/search_result_field.rb +0 -12
  226. data/app/models/infold/show_association.rb +0 -42
  227. data/app/models/infold/show_association_attachment_field.rb +0 -5
  228. data/app/models/infold/show_association_column.rb +0 -5
  229. data/app/models/infold/show_association_field.rb +0 -8
  230. data/app/models/infold/show_attachment_field.rb +0 -7
  231. data/app/models/infold/show_column.rb +0 -7
  232. data/app/models/infold/show_field.rb +0 -11
  233. data/app/validators/infold/ruby_code_validator.rb +0 -9
  234. data/app/views/infold/app_view_forms/_bulk_form.html.haml +0 -16
  235. data/app/views/infold/app_view_forms/_tab.html.haml +0 -12
  236. data/app/views/infold/app_view_forms/show.html.haml +0 -7
  237. data/app/views/infold/app_view_shows/_bulk_form.html.haml +0 -15
  238. data/app/views/infold/app_view_shows/_tab.html.haml +0 -12
  239. data/app/views/infold/app_view_shows/show.html.haml +0 -7
  240. data/app/views/infold/app_view_shows/update.turbo_stream.haml +0 -1
  241. data/app/views/infold/application/_flash.html.haml +0 -6
  242. data/app/views/infold/apps/_form.html.haml +0 -30
  243. data/app/views/infold/apps/_page_header.html.haml +0 -5
  244. data/app/views/infold/apps/_tab.html.haml +0 -13
  245. data/app/views/infold/apps/create.turbo_stream.haml +0 -3
  246. data/app/views/infold/apps/edit.html.haml +0 -6
  247. data/app/views/infold/apps/new.html.haml +0 -8
  248. data/app/views/infold/apps/update.turbo_stream.haml +0 -3
  249. data/app/views/infold/associations/_form.html.haml +0 -18
  250. data/app/views/infold/associations/edit.html.haml +0 -5
  251. data/app/views/infold/attachment_fields/_form.html.haml +0 -51
  252. data/app/views/infold/attachment_fields/edit.html.haml +0 -7
  253. data/app/views/infold/attachment_fields/form.turbo_stream.haml +0 -4
  254. data/app/views/infold/attachment_fields/index.html.haml +0 -28
  255. data/app/views/infold/attachment_fields/new.html.haml +0 -7
  256. data/app/views/infold/builds/create.turbo_stream.haml +0 -8
  257. data/app/views/infold/builds/new.html.haml +0 -23
  258. data/app/views/infold/columns/_bulk_form.html.haml +0 -18
  259. data/app/views/infold/columns/_row.html.haml +0 -26
  260. data/app/views/infold/columns/_setting.html.haml +0 -42
  261. data/app/views/infold/columns/bulk.turbo_stream.haml +0 -3
  262. data/app/views/infold/columns/edit.html.haml +0 -5
  263. data/app/views/infold/columns/index.html.haml +0 -9
  264. data/app/views/infold/columns/update.turbo_stream.haml +0 -8
  265. data/app/views/infold/csv_columns/_bulk_form.html.haml +0 -14
  266. data/app/views/infold/csv_columns/_row.html.haml +0 -10
  267. data/app/views/infold/csv_columns/bulk.turbo_stream.haml +0 -3
  268. data/app/views/infold/csv_columns/index.html.haml +0 -7
  269. data/app/views/infold/enums/_form.html.haml +0 -13
  270. data/app/views/infold/enums/_index.html.haml +0 -27
  271. data/app/views/infold/enums/index.html.haml +0 -5
  272. data/app/views/infold/form_association_attachment_fields/_form.html.haml +0 -13
  273. data/app/views/infold/form_association_columns/_form.html.haml +0 -20
  274. data/app/views/infold/form_associations/_bulk_form.html.haml +0 -16
  275. data/app/views/infold/form_associations/_form.html.haml +0 -19
  276. data/app/views/infold/form_associations/show.html.haml +0 -7
  277. data/app/views/infold/form_associations/update.turbo_stream.haml +0 -1
  278. data/app/views/infold/form_attachment_fields/_form.html.haml +0 -14
  279. data/app/views/infold/form_columns/_form.html.haml +0 -21
  280. data/app/views/infold/menu_directories/_item.html.haml +0 -20
  281. data/app/views/infold/menu_directories/create.turbo_stream.haml +0 -2
  282. data/app/views/infold/menu_directories/destroy.turbo_stream.haml +0 -5
  283. data/app/views/infold/menus/_app.html.haml +0 -10
  284. data/app/views/infold/menus/_items.html.haml +0 -7
  285. data/app/views/infold/menus/edit.html.haml +0 -23
  286. data/app/views/infold/menus/update.turbo_stream.haml +0 -3
  287. data/app/views/infold/models/_form.html.haml +0 -12
  288. data/app/views/infold/models/_tab.html.haml +0 -7
  289. data/app/views/infold/models/edit.html.haml +0 -9
  290. data/app/views/infold/models/update.turbo_stream.haml +0 -3
  291. data/app/views/infold/search_conditions/_bulk_form.html.haml +0 -24
  292. data/app/views/infold/search_conditions/_column_options.html.haml +0 -3
  293. data/app/views/infold/search_conditions/_form_kind_options.html.haml +0 -3
  294. data/app/views/infold/search_conditions/_row.html.haml +0 -31
  295. data/app/views/infold/search_conditions/_sign_options.html.haml +0 -3
  296. data/app/views/infold/search_conditions/_tab.html.haml +0 -12
  297. data/app/views/infold/search_conditions/bulk.turbo_stream.haml +0 -3
  298. data/app/views/infold/search_conditions/index.html.haml +0 -7
  299. data/app/views/infold/search_conditions/refresh_columns.turbo_stream.haml +0 -6
  300. data/app/views/infold/search_conditions/refresh_form_kinds.turbo_stream.haml +0 -4
  301. data/app/views/infold/search_conditions/refresh_signs.turbo_stream.haml +0 -2
  302. data/app/views/infold/search_result_attachment_fields/_form.html.haml +0 -12
  303. data/app/views/infold/search_result_columns/_form.html.haml +0 -12
  304. data/app/views/infold/search_result_fields/_bulk_form.html.haml +0 -23
  305. data/app/views/infold/search_result_fields/_row.html.haml +0 -12
  306. data/app/views/infold/search_result_fields/bulk.turbo_stream.haml +0 -3
  307. data/app/views/infold/search_result_fields/index.html.haml +0 -7
  308. data/app/views/infold/show_association_attachment_fields/_form.html.haml +0 -12
  309. data/app/views/infold/show_association_columns/_form.html.haml +0 -12
  310. data/app/views/infold/show_associations/_bulk_form.html.haml +0 -15
  311. data/app/views/infold/show_associations/_form.html.haml +0 -14
  312. data/app/views/infold/show_associations/show.html.haml +0 -7
  313. data/app/views/infold/show_associations/update.turbo_stream.haml +0 -1
  314. data/app/views/infold/show_attachment_fields/_form.html.haml +0 -12
  315. data/app/views/infold/show_columns/_form.html.haml +0 -12
  316. data/app/views/infold/sync_dbs/create.turbo_stream.haml +0 -1
  317. data/app/views/infold/sync_dbs/show.html.haml +0 -11
  318. data/app/views/layouts/infold/application.html.haml +0 -112
  319. data/config/database.yml +0 -11
  320. data/config/initializers/infold_assets.rb +0 -12
  321. data/config/initializers/infold_locale.rb +0 -1
  322. data/config/locales/infold/ar/app/en.yml +0 -6
  323. data/config/locales/infold/ar/app/ja.yml +0 -6
  324. data/config/locales/infold/ar/app_view/en.yml +0 -4
  325. data/config/locales/infold/ar/app_view/ja.yml +0 -4
  326. data/config/locales/infold/ar/app_view_form/en.yml +0 -10
  327. data/config/locales/infold/ar/app_view_form/ja.yml +0 -10
  328. data/config/locales/infold/ar/app_view_index/en.yml +0 -12
  329. data/config/locales/infold/ar/app_view_index/ja.yml +0 -12
  330. data/config/locales/infold/ar/app_view_modal/en.yml +0 -6
  331. data/config/locales/infold/ar/app_view_modal/ja.yml +0 -6
  332. data/config/locales/infold/ar/app_view_show/en.yml +0 -9
  333. data/config/locales/infold/ar/app_view_show/ja.yml +0 -9
  334. data/config/locales/infold/ar/csv_column/en.yml +0 -8
  335. data/config/locales/infold/ar/csv_column/ja.yml +0 -8
  336. data/config/locales/infold/ar/form_association_column/ja.yml +0 -15
  337. data/config/locales/infold/ar/form_column/ja.yml +0 -15
  338. data/config/locales/infold/ar/menu_item/ja.yml +0 -6
  339. data/config/locales/infold/ar/model/ja.yml +0 -11
  340. data/config/locales/infold/ar/model_association/en.yml +0 -6
  341. data/config/locales/infold/ar/model_association/ja.yml +0 -10
  342. data/config/locales/infold/ar/model_column/en.yml +0 -34
  343. data/config/locales/infold/ar/model_column/ja.yml +0 -34
  344. data/config/locales/infold/ar/search_condition/en.yml +0 -30
  345. data/config/locales/infold/ar/search_condition/ja.yml +0 -30
  346. data/config/locales/infold/ar/search_result_field/en.yml +0 -9
  347. data/config/locales/infold/ar/search_result_field/ja.yml +0 -9
  348. data/config/locales/infold/en.yml +0 -40
  349. data/config/locales/infold/ja.yml +0 -41
  350. data/config/routes.rb +0 -40
  351. data/db/infold_test.sqlite3 +0 -0
  352. data/db/migrate/20220419050641_create_infold_projects.rb +0 -9
  353. data/db/migrate/20220419051049_create_infold_models.rb +0 -15
  354. data/db/migrate/20220419051601_create_infold_columns.rb +0 -23
  355. data/db/migrate/20220419051718_create_infold_attachment_fields.rb +0 -15
  356. data/db/migrate/20220419052017_create_infold_model_associations.rb +0 -16
  357. data/db/migrate/20220419052154_create_infold_apps.rb +0 -10
  358. data/db/migrate/20220419052320_create_infold_app_views.rb +0 -14
  359. data/db/migrate/20220419052450_create_infold_search_conditions.rb +0 -14
  360. data/db/migrate/20220419052707_create_infold_search_result_fields.rb +0 -18
  361. data/db/migrate/20220419053338_create_infold_show_fields.rb +0 -18
  362. data/db/migrate/20220419053425_create_infold_show_association_fields.rb +0 -15
  363. data/db/migrate/20220419060937_create_infold_form_fields.rb +0 -19
  364. data/db/migrate/20220419061148_create_infold_form_association_fields.rb +0 -16
  365. data/db/migrate/20220419061725_create_infold_enums.rb +0 -16
  366. data/db/migrate/20220419062020_create_infold_menu_items.rb +0 -16
  367. data/db/migrate/20220419062119_create_infold_csv_columns.rb +0 -12
  368. data/db/schema.rb +0 -260
  369. data/lib/generators/infold/app/app_generator.rb +0 -134
  370. data/lib/generators/infold/app/templates/controller.rb.tt +0 -100
  371. data/lib/generators/infold/app/templates/search_form.rb.tt +0 -31
  372. data/lib/generators/infold/app/templates/views/_association_fields.haml.tt +0 -16
  373. data/lib/generators/infold/app/templates/views/_detail.haml.tt +0 -100
  374. data/lib/generators/infold/app/templates/views/_detail_modal_wrapper.haml.tt +0 -9
  375. data/lib/generators/infold/app/templates/views/_form.haml.tt +0 -66
  376. data/lib/generators/infold/app/templates/views/_index_row.haml.tt +0 -17
  377. data/lib/generators/infold/app/templates/views/_show_operation.haml.tt +0 -5
  378. data/lib/generators/infold/app/templates/views/edit+turbo_frame.haml.tt +0 -13
  379. data/lib/generators/infold/app/templates/views/edit.haml.tt +0 -10
  380. data/lib/generators/infold/app/templates/views/form.turbo_stream.haml.tt +0 -17
  381. data/lib/generators/infold/app/templates/views/index+turbo_frame.haml.tt +0 -43
  382. data/lib/generators/infold/app/templates/views/index.csv.ruby.tt +0 -18
  383. data/lib/generators/infold/app/templates/views/index.haml.tt +0 -49
  384. data/lib/generators/infold/app/templates/views/new+turbo_frame.haml.tt +0 -14
  385. data/lib/generators/infold/app/templates/views/new.haml.tt +0 -12
  386. data/lib/generators/infold/app/templates/views/show+turbo_frame.haml.tt +0 -4
  387. data/lib/generators/infold/app/templates/views/show.haml.tt +0 -9
  388. data/lib/generators/infold/install/install_generator.rb +0 -151
  389. data/lib/generators/infold/install/templates/app/components/admin/enum_badge_component.html.haml +0 -4
  390. data/lib/generators/infold/install/templates/app/components/admin/enum_badge_component.rb +0 -11
  391. data/lib/generators/infold/install/templates/app/components/admin/form/checkbox_fieldset_component.html.haml +0 -11
  392. data/lib/generators/infold/install/templates/app/components/admin/form/checkbox_fieldset_component.rb +0 -15
  393. data/lib/generators/infold/install/templates/app/components/admin/form/datetime_fieldset_component.html.haml +0 -20
  394. data/lib/generators/infold/install/templates/app/components/admin/form/datetime_fieldset_component.rb +0 -13
  395. data/lib/generators/infold/install/templates/app/components/admin/form/file_upload_component.rb +0 -12
  396. data/lib/generators/infold/install/templates/app/components/admin/form/input_fieldset_component.html.haml +0 -14
  397. data/lib/generators/infold/install/templates/app/components/admin/form/input_fieldset_component.rb +0 -24
  398. data/lib/generators/infold/install/templates/app/components/admin/form/radio_fieldset_component.html.haml +0 -11
  399. data/lib/generators/infold/install/templates/app/components/admin/form/radio_fieldset_component.rb +0 -15
  400. data/lib/generators/infold/install/templates/app/components/admin/form/relation_fieldset_component.html.haml +0 -17
  401. data/lib/generators/infold/install/templates/app/components/admin/form/relation_fieldset_component.rb +0 -21
  402. data/lib/generators/infold/install/templates/app/components/admin/form/select_fieldset_component.html.haml +0 -7
  403. data/lib/generators/infold/install/templates/app/components/admin/form/select_fieldset_component.rb +0 -16
  404. data/lib/generators/infold/install/templates/app/components/admin/form/switch_element_component.html.haml +0 -4
  405. data/lib/generators/infold/install/templates/app/components/admin/form/switch_element_component.rb +0 -12
  406. data/lib/generators/infold/install/templates/app/components/admin/remote_modal_component.rb +0 -21
  407. data/lib/generators/infold/install/templates/app/components/admin/sortable_th_component.html.haml +0 -4
  408. data/lib/generators/infold/install/templates/app/components/admin/sortable_th_component.rb +0 -27
  409. data/lib/generators/infold/install/templates/app/controllers/admin/admin_users_controller.rb +0 -62
  410. data/lib/generators/infold/install/templates/app/helpers/admin_helper.rb +0 -37
  411. data/lib/generators/infold/install/templates/app/views/admin/admin_users/_detail.html.haml +0 -14
  412. data/lib/generators/infold/install/templates/app/views/admin/admin_users/_form.html.haml +0 -6
  413. data/lib/generators/infold/install/templates/app/views/admin/admin_users/_index_row.html.haml +0 -9
  414. data/lib/generators/infold/install/templates/app/views/admin/admin_users/_show_operation.html.haml +0 -4
  415. data/lib/generators/infold/install/templates/app/views/admin/admin_users/edit.html+turbo_frame.haml +0 -11
  416. data/lib/generators/infold/install/templates/app/views/admin/admin_users/edit.html.haml +0 -10
  417. data/lib/generators/infold/install/templates/app/views/admin/admin_users/form.turbo_stream.haml +0 -4
  418. data/lib/generators/infold/install/templates/app/views/admin/admin_users/index.html.haml +0 -21
  419. data/lib/generators/infold/install/templates/app/views/admin/admin_users/new.html+turbo_frame.haml +0 -11
  420. data/lib/generators/infold/install/templates/app/views/admin/admin_users/new.html.haml +0 -10
  421. data/lib/generators/infold/install/templates/app/views/admin/admin_users/show.html+turbo_frame.haml +0 -11
  422. data/lib/generators/infold/install/templates/app/views/admin/admin_users/show.html.haml +0 -8
  423. data/lib/generators/infold/install/templates/app/views/admin/common/_header_menu.html.haml +0 -0
  424. data/lib/generators/infold/install/templates/javascript/admin/controllers/application.js +0 -9
  425. data/lib/generators/infold/install/templates/javascript/admin/controllers/flash_controller.js +0 -10
  426. data/lib/generators/infold/install/templates/javascript/admin/stylesheets/custom.css +0 -290
  427. data/lib/generators/infold/install/templates/javascript/admin/stylesheets/custom.css.map +0 -1
  428. data/lib/generators/infold/install/templates/javascript/esbuild/admin.js +0 -10
  429. data/lib/generators/infold/install/templates/javascript/webpacker/admin.js +0 -9
  430. data/lib/generators/infold/model/model_generator.rb +0 -50
  431. data/lib/generators/infold/model/templates/decorator.rb.tt +0 -10
  432. data/lib/generators/infold/model/templates/model.rb.tt +0 -59
  433. data/lib/generators/infold/project/project_generator.rb +0 -66
  434. data/lib/generators/infold/project/templates/_header_menu.haml.tt +0 -17
  435. data/lib/generators/infold/project/templates/locales/form.yml.tt +0 -11
  436. data/lib/generators/infold/project/templates/locales/model.yml.tt +0 -43
  437. data/lib/generators/infold/project/templates/relation_fieldset_component.rb.tt +0 -30
  438. data/lib/infold/engine.rb +0 -15
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 22d0d58a49eeff5ad6dc7308cdafbe979c97ea38753f3e28b5fc136957b5bd6c
4
- data.tar.gz: 02cc7042a7182e2e8dcd744057e64fcd828720011ae4108972ba2b6c5b5a8169
3
+ metadata.gz: a965cd1508d39abde6e77ad66a19dec7a088159b3562d795576dc70a3a36332a
4
+ data.tar.gz: 40163f510b91241b30fe97c56dfe9114e679f5de014c2f451b3a00de0e42650b
5
5
  SHA512:
6
- metadata.gz: 34f264655f92b14dea2e74e99185e6bd75daf41e7ccb2c013d5118465cab7e08b61ebaa7362f7f341b2f300b529c24e978705e3e367e7027bdd4d882edbe7130
7
- data.tar.gz: 1c5efe138795d184cf946dc2af5871ec3989ca903ebf47e8495aebacbca77b5849dd77859e933fd5467d295f64db87590dc155e23882102d9c946206eac0f71c
6
+ metadata.gz: 8c24112c452a48c2fcb3ca34b6cf8ea6a49edf18ecfe61ffd8ca35a972f484449af54cac939c2adfb1cfdd27cb635cbd5f59a4bced5e6a4248a0b647e5c5c4a7
7
+ data.tar.gz: 6bce2862588f717f633d09f1af464d9668f2a10a7de36f8c72610ab0141e76ec90d57e35b877b4b4ebe9c2789ad389d4efe1340fd523fe19f1e1fc311bb50140
data/README.md CHANGED
@@ -1,33 +1,431 @@
1
1
  # Infold
2
- [infold](https://infold.dev) (**in**ternal tool + scaf**fold**) is a Ruby Gem that creates admin system like [ActiveAdmin](https://github.com/activeadmin/activeadmin). However, no need to use DSL. Configure from GUI, and it'll automatically generate the code like Scaffold. This code is written in plain Ruby on Rails, easy readable and customizable.
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.
6
+
7
+ ## Goals
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
3
11
 
4
12
  ## Getting started
5
- - Check out [the docs](https://docs.infold.dev).
6
- - Try the [live demo](https://demo.infold.dev).
7
- - [Website](https://infold.dev)
13
+ - Try the [live demo](https://demo.infold.dev/admin).
14
+ - Check the [website](https://infold.dev).
15
+
16
+ ## Installation
17
+ Add this line to your application's Gemfile:
18
+ ```ruby
19
+ gem 'infold', require: false
20
+ ```
21
+
22
+ In addition, infold uses the following Gem, add these lines to your Gemfile too.
23
+ ```ruby
24
+ gem 'devise' # Certification
25
+ gem 'haml-rails' # HAML
26
+ gem 'kaminari' # Pagination
27
+ gem 'view_component' # View Component
28
+ gem 'active_decorator' # Decoration
29
+ gem 'enum_help' # Enum Helpers
30
+ ```
31
+
32
+ Then run `bundle install`
33
+
34
+ Next, you need to run the generator:
35
+ ```shell
36
+ $ rails generate infold:install
37
+ ```
38
+
39
+ At this point, several common files for CRUD applications are generated.
40
+
41
+ ### Devise Setup
42
+ With the above installation, Devise is also installed. Please migrate for Device user's table.
43
+ ```shell
44
+ $ rails db:migrate
45
+ ```
46
+
47
+ Create a test user for Devise from rails console.
48
+ ```shell
49
+ $ rails console
50
+ ```
51
+ ```ruby
52
+ AdminUser.create(email: 'user@example.com', password: 'password')
53
+ ```
54
+
55
+ ## Basic Usage
56
+ Specify the target model for CRUD and generate code from the generator.
57
+ The following is an example of a Product model.
58
+ ```shell
59
+ $ rails generate infold Product
60
+ ```
61
+
62
+ The above commands will generate several files, including Controller and View.
63
+ You can check it by starting rails from `bin/dev` and accessing `http://localhost:3000/admin`.
64
+
65
+ ![basic](./readme/basic.png)
66
+
67
+ By executing the above command, each directory, such as controllers, models, and views, automatically generates code to run the internal tools.
68
+ This mechanism is similar to Rails' Scaffold, and it is possible to implement additional necessary functions based on this.
69
+
70
+ However, **this is not the only functionality that can generate from Infold**.
71
+ Let's customize YAML and automatically generate the necessary functions by referring to the following contents.
72
+
73
+ ## More Customization
74
+ Infold can be customized more by configuring YAML. YAML is generated in the `config/infold` directory.
75
+ After setting up YAML, the code is regenerated by executing the following command.
76
+ ```shell
77
+ $ rails generate infold:scaffold ResourceName (eg: Product)
78
+ ```
79
+
80
+ ### YAML for demo apps
81
+ The YAML file for the [demo apps](https://demo.infold.dev/admin) can be referenced [here](https://github.com/yamataka22/infold/tree/main/test/dummy/config/infold). Please refer to it.
82
+
83
+ ### Validation
84
+ In `model`.`validate`, you can define validation for each field.
85
+ #### Example
86
+ 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.
87
+ ```yaml
88
+ model:
89
+ validate:
90
+ title: presence
91
+ price:
92
+ - presence
93
+ - numericality:
94
+ greater_than_or_equal_to: 0
95
+ ```
96
+ Then validation is activated on the form screen.
97
+
98
+ ![validate](./readme/validate.png)
99
+
100
+ ### Enum
101
+ In `model`.`enum`, you can define enum field.
102
+ #### Example
103
+ 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).
104
+ ```yaml
105
+ model:
106
+ enum:
107
+ status:
108
+ ordered: 1
109
+ charged: 2
110
+ delivered: 3
111
+ ```
112
+
113
+ Then the screen displays the Name of the Enum.
114
+
115
+ ![enum](./readme/enum.png)
116
+
117
+ #### Colored Enum
118
+ Enum also allows you to specify a color for each element.
119
+ The available colors are `blue`, `azure`, `indigo`, `purple`, `pink`, `red`, `orange`, `yellow`, `lime`, `green`, `teal` and `cyan`.
120
+ #### Example
121
+ ```yaml
122
+ model:
123
+ enum:
124
+ status:
125
+ ordered:
126
+ value: 1
127
+ color: blue
128
+ charged:
129
+ value: 2
130
+ color: pink
131
+ delivered:
132
+ value: 3
133
+ color: green
134
+ ```
135
+
136
+ It will then be displayed with a colored badge for easy identification.
137
+
138
+ ![colored_enum](./readme/colored_enum.png)
139
+
140
+ ### Decorator
141
+ In `model`.`decorator`, you can define simple decorations such as comma-separated numbers and units.
142
+ #### Example
143
+ In the following example, the `price` field indicates a comma-separated number and "$" as the unit of measure in the front, and the `weight` field indicates "Kg" in the back.
144
+ ```yaml
145
+ model:
146
+ decorator:
147
+ price:
148
+ prepend: $
149
+ digit: true
150
+ weight:
151
+ append: Kg
152
+ ```
153
+
154
+ Price indicated as comma-separated and with units.
155
+
156
+ ![decorator](./readme/decorator.png)
157
+
158
+ ### ActiveStorage
159
+ Infold supports ActiveStorage. If you want to store files such as images or PDFs, define them in the `model`. `active_storage`.
160
+
161
+ **As a prerequisite, ActiveStorage must installed in the project.**
162
+ #### Example
163
+ In the following example, define the use of ActiveStorage with the name `photo` and select "image" as kind (for PDF, etc., select "file" as kind).
164
+ ```yaml
165
+ model:
166
+ active_storage:
167
+ photo:
168
+ kind: image
169
+ ```
8
170
 
9
- ## How it works
10
- infold consists of two main steps:
171
+ Then images stored in ActiveStorage can be displayed.
11
172
 
12
- 1. Configure your admin system on the browser.
13
- <div>After installing infold, access http://localhost:3000/infold, you will be able to configure admin system on your browser.</div>
173
+ ![active_storage_image](./readme/active_storage_image.png)
14
174
 
15
- 2. Generate source code automatically and customize.
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>
175
+ ### Association
176
+ Infold supports an 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.
177
+ ### belongs_to
178
+ For example, the relation `purchase` belongs_to `customer` is defined as follows:
179
+ ```yaml
180
+ model:
181
+ association:
182
+ customer:
183
+ kind: belongs_to
184
+ ```
185
+ #### Naming field
186
+ In the case of `belongs_to`, the field representing the record name of the referenced parent model, if any, is defined in `name_filed`.
187
+ 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`.
188
+ ```yaml
189
+ model:
190
+ association:
191
+ customer:
192
+ kind: belongs_to
193
+ name_field: name
194
+ ```
17
195
 
18
- ## Documentation
196
+ ![belongs_to](./readme/belongs_to.png)
19
197
 
20
- See [docs.infold.dev](https://docs.infold.dev/) for documentation.
198
+ ### has_many, has_one
199
+ For example, the relation `order` has_many `order_details` is defined as follows:
200
+ ```yaml
201
+ model:
202
+ association:
203
+ order_details:
204
+ kind: has_many
205
+ dependent: destroy
206
+ ```
207
+
208
+ The `app.show.fields` settings described below will enable batch registration and referencing of has_many.
209
+
210
+ #### Batch reference in detail view
211
+ ![has_many_show](./readme/has_many_show.png)
212
+
213
+ #### Advanced configuration of the referenced model in `has_many`.
214
+ 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`.
215
+ In this case, by defining the `model` in the association model, Validation, Enum, etc., can be defined in the same way as above.
216
+ #### Example
217
+ In the example below, there is a `has_many order_details` association.
218
+ 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` with which the `order_detail` is associated with.
219
+ ```yaml
220
+ model:
221
+ association:
222
+ order_details:
223
+ kind: has_many
224
+ model:
225
+ validate:
226
+ product: presence
227
+ decorator:
228
+ amount:
229
+ digit: true
230
+ association:
231
+ product:
232
+ kind: belongs_to
233
+ name_field: title
234
+ ```
235
+
236
+ #### Bulk Registration Form
237
+ In the following example, multiple lines of OrderDetails can be registered at once.
238
+ You can add rows from the ADD button and delete records with the trash icon.
239
+
240
+ ![has_many_form](./readme/has_many_form.png)
241
+
242
+ ## View Customization
243
+ ### Index (list) view
244
+ #### Search conditions
245
+ In `app`.`index`.`conditions`, you can define search condition for the resource.
246
+ The condition specifies `sign` and `form_kind`.
247
+
248
+ sign can be specified as follows:
249
+ - eq (equal)
250
+ - lteq (less than equal)
251
+ - gteq (gather than equal)
252
+ - full_like (like %...%)
253
+ - start_with (like ...%)
254
+ - any (Used to specify multiple elements of Enum with "or")
255
+
256
+ form_kind can be specified as follows:
257
+ - text
258
+ - number (input type="number")
259
+ - select
260
+ - switch (Used with the boolean type)
261
+ - association_search (For association columns in belongs_to, `association_search` allows you to search and specify the related tables from the child screen.)
262
+
263
+ #### Example
264
+ For example, equal search for id, association search for customer_id, and multiple checkboxes for status are defined as follows:
265
+ ```yaml
266
+ app:
267
+ index:
268
+ conditions:
269
+ - id:
270
+ sign: eq
271
+ - customer_id:
272
+ sign: eq
273
+ form_kind: association_search
274
+ - status:
275
+ sign: any
276
+ form_kind: checkbox
277
+ ```
278
+
279
+ ![index_condition](./readme/index_condition.png)
280
+
281
+ #### List
282
+ 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).
283
+ If you specify an association name in the list field, the name_field of the associated destination will be displayed in link format.
284
+ #### Example
285
+ ```yaml
286
+ app:
287
+ index:
288
+ list:
289
+ fields:
290
+ - id
291
+ - customer
292
+ - status
293
+ - total_price
294
+ - delivered_at
295
+ default_order:
296
+ field: id
297
+ kind: desc
298
+ ```
299
+
300
+ ![index_view](./readme/index_view.png)
301
+
302
+ #### CSV output
303
+ Infold also allows CSV output of search results. Define the target columns in `app`.`index`.`csv`.`fields`. If empty, all fields will be output.
304
+
305
+ #### Example
306
+ ```yaml
307
+ app:
308
+ index:
309
+ csv:
310
+ fields:
311
+ - id
312
+ - title
313
+ - price
314
+ - created_at
315
+ - updated_at
316
+ ```
317
+
318
+ ### Show (detail) view
319
+ In `app`.`show`.`fields`, you can specify the fields and the order in which they are displayed on the detail screen.
320
+ If you include has_many / has_one associations in the field, you can also specify fields for the associated destination model.
321
+
322
+ #### Example
323
+ - The following example shows fields such as `id` and `status` to be displayed.
324
+ - It also displays the `customer.name_field` by including the `customer` in the `belongs_to` association.
325
+ - In addition, the has_many association `order_details` is included. The `product`, `amount` and `unit_price` of this `order_details` are specified as the display field.
326
+ ```yaml
327
+ app:
328
+ show:
329
+ fields:
330
+ - id
331
+ - customer
332
+ - status
333
+ - order_details:
334
+ fields:
335
+ - product
336
+ - amount
337
+ - unit_price
338
+ - created_at
339
+ ```
340
+
341
+ ![has_many_show](./readme/has_many_show.png)
342
+
343
+ ### Form (Registration and Edit) view
344
+ In `app`.`form`.`fields`, you can define fields for registration and update forms.
345
+
346
+ Specify the form type from `kind`, `kind` can be specified as follows:
347
+ - text (default)
348
+ - number (input type="number")
349
+ - email (input type="email")
350
+ - password (input type="password")
351
+ - text_area
352
+ - radio
353
+ - select
354
+ - switch (boolean)
355
+ - file (defined in ActiveStorage)
356
+ - association_search (For association columns in belongs_to, `association_search` allows you to search and specify the related tables from the child screen.)
357
+
358
+ If has_many/has_one of association is specified in the field, batch registration of related models is enabled.
359
+
360
+ #### Example
361
+ - Able to search and specify the related customer from a child screen (related to `order belongs_to customer`)
362
+ - The `status` allows radio button selection of Enum elements
363
+ - The decorator's append($) set to `total_price` is displayed on the form
364
+ - Enable batch registration of related data, including `order_details`, which are related to has_many.
365
+ - Display `product_id`, `amount`, `unit_price` from related `order_details` on the form
366
+ - In relation to `order_detail belongs_to product`, the related product can be searched from the child screen.
367
+ - ADD button to add rows.
368
+ ```yaml
369
+ app:
370
+ form:
371
+ fields:
372
+ - customer:
373
+ kind: association_search
374
+ - status:
375
+ kind: radio
376
+ - total_price:
377
+ kind: number
378
+ - order_details:
379
+ kind: association
380
+ fields:
381
+ - product_id:
382
+ kind: association_search
383
+ - amount
384
+ - unit_price
385
+ ```
386
+
387
+ ![form](./readme/form.png)
388
+
389
+ ### Association search view
390
+ Fields related to `belongs_to` can be searched and selected from the child screens for data in the related model.
391
+
392
+ **Note: Child screen should be defined in the caller's resource (YAML). For example, in the case of `order belongs_to customer`, define the association_search in the YAML of the `customer`, not in the `order`.**
393
+
394
+ The configuration is the same as for `app`.`index`. Define the necessary fields for `conditions` and `list`.
395
+ #### Example
396
+ - Use `name` and `email` as search criteria
397
+ - list `id`, `name` and `email`.
398
+ ```yaml
399
+ app:
400
+ association_search:
401
+ conditions:
402
+ - name:
403
+ sign: full_like
404
+ - email:
405
+ sign: start_with
406
+ list:
407
+ fields:
408
+ - id
409
+ - name
410
+ - email
411
+ ```
412
+ If a customer is defined as kind=association_search on the Order form, the customer can be searched and selected from the child screens.
413
+
414
+ ![association_search](./readme/association_search.gif)
21
415
 
22
416
  ## Dependencies
23
- infold is built with other open source projects:
24
- - [tabler](https://github.com/tabler/tabler)
25
- - [devise](https://github.com/heartcombo/devise)
26
- - [kaminari](https://github.com/kaminari/kaminari)
27
- - [enum_help](https://github.com/zmbacker/enum_help)
28
- - [view_component](https://github.com/github/view_component)
29
- - [active_decorator](https://github.com/amatsuda/active_decorator)
30
- - [haml-rails](https://github.com/haml/haml-rails)
417
+ Infold is built with other open source projects:
418
+
419
+ | TOOL | DESCRIPTION |
420
+ |------------------------------------------------------------------|----------------------------------------------------------------------------|
421
+ | [tabler](https://github.com/tabler/tabler) | HTML Dashboard UI Kit built on Bootstrap |
422
+ | [devise](https://github.com/heartcombo/devise) | Flexible authentication solution for Rails with Warden. |
423
+ | [kaminari](https://github.com/kaminari/kaminari) | Clean, powerful, customizable and sophisticated paginator |
424
+ | [enum_help](https://github.com/zmbacker/enum_help) | Help ActiveRecord::Enum feature to work fine with I18n |
425
+ | [view_component](https://github.com/github/view_component) | A framework for building reusable, testable & encapsulated view components |
426
+ | [active_decorator](https://github.com/amatsuda/active_decorator) | A simple and Rubyish view helper for Rails |
427
+ | [haml-rails](https://github.com/haml/haml-rails) | A templating engine for HTML |
428
+
31
429
 
32
430
  ## License
33
431
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile CHANGED
@@ -1,8 +1,3 @@
1
1
  require "bundler/setup"
2
2
 
3
- APP_RAKEFILE = File.expand_path("spec/dummy_app/Rakefile", __dir__)
4
- load "rails/tasks/engine.rake"
5
-
6
- load "rails/tasks/statistics.rake"
7
-
8
3
  require "bundler/gem_tasks"
@@ -0,0 +1,52 @@
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_file = Rails.root.join('db/schema.rb')
14
+ db_schema = DbSchema.new(File.exist?(db_schema_file) ? File.read(db_schema_file) : nil)
15
+ yaml = YAML.load_file(Rails.root.join("config/infold/#{resource_name.underscore}.yml"))
16
+ resource = YamlReader.generate_resource(resource_name, yaml, db_schema)
17
+ @writer = ControllerWriter.new(resource)
18
+ end
19
+
20
+ def create_controller_file
21
+ template "controller.rb", Rails.root.join("app/controllers/admin/#{name.pluralize.underscore}_controller.rb"), force: true
22
+ end
23
+
24
+ def add_routes
25
+ file = Rails.root.join('config/routes/admin.rb')
26
+ route = "resources :#{name.pluralize.underscore}"
27
+ return unless File.exist?(file)
28
+ in_file = File.readlines(file).grep(/^\s+#{route}$/)
29
+ if in_file.blank?
30
+ inject_into_file file, after: "namespace 'admin' do" do
31
+ "\n #{route}"
32
+ end
33
+ end
34
+
35
+ gsub_file file, "root :to => 'admin_users#index'",
36
+ "root :to => '#{name.pluralize.underscore}#index'"
37
+ end
38
+
39
+ def add_menu
40
+ return if name.pluralize.underscore == 'admin_users'
41
+ file = Rails.root.join('app/views/admin/common/_header_menu.html.haml')
42
+ return unless File.exist?(file)
43
+ menu = "\n %li.nav-item\n = link_to '#{@writer.resource.app_title}', #{@writer.index_path}, class: 'nav-link'"
44
+ in_file = File.readlines(file).grep(/, #{@writer.index_path},/)
45
+ if in_file.blank?
46
+ append_to_file file do
47
+ menu
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,32 @@
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_file = Rails.root.join('db/schema.rb')
14
+ db_schema = DbSchema.new(File.exist?(db_schema_file) ? File.read(db_schema_file) : nil)
15
+ yaml = YAML.load_file(Rails.root.join("config/infold/#{resource_name.underscore}.yml"))
16
+ @resource = YamlReader.generate_resource(resource_name, yaml, db_schema)
17
+ end
18
+
19
+ def create_model_file
20
+ @writer = DecoratorWriter.new(@resource)
21
+ template "decorator.rb", Rails.root.join("app/decorators/admin/#{name.underscore.singularize}_decorator.rb"), force: true
22
+ end
23
+
24
+ def create_association_model_file
25
+ @resource.associations&.
26
+ select { |as| !as.belongs_to? && as.field_group.has_association_model? }&.each do |association|
27
+ @writer = DecoratorWriter.new(association)
28
+ template "decorator.rb", Rails.root.join("app/decorators/admin/#{association.model_name(:snake)}_decorator.rb"), force: true
29
+ end
30
+ end
31
+ end
32
+ 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