script_core 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (219) hide show
  1. checksums.yaml +4 -4
  2. data/.gitattributes +1 -1
  3. data/.gitignore +15 -1
  4. data/.rubocop.yml +10 -2
  5. data/.ruby-version +1 -1
  6. data/.travis.yml +6 -0
  7. data/Gemfile +32 -0
  8. data/README.md +169 -6
  9. data/Rakefile +11 -0
  10. data/Vagrantfile +1 -1
  11. data/bin/rails +25 -0
  12. data/bootstrap.sh +2 -3
  13. data/dev.yml +4 -4
  14. data/ext/enterprise_script_service/Rakefile +5 -4
  15. data/ext/enterprise_script_service/mruby_config.rb +1 -0
  16. data/lib/script_core.rb +17 -15
  17. data/lib/script_core/engine.rb +1 -0
  18. data/lib/script_core/executable.rb +1 -1
  19. data/lib/script_core/railtie.rb +8 -0
  20. data/lib/script_core/spawner.rb +1 -0
  21. data/lib/script_core/version.rb +1 -1
  22. data/lib/tasks/mruby/engine.gembox.example +19 -0
  23. data/lib/tasks/mruby/lib/.keep +0 -0
  24. data/lib/tasks/script_core.rake +111 -0
  25. data/script/regression +7 -5
  26. data/script_core.gemspec +2 -2
  27. data/spec/dummy/Rakefile +8 -0
  28. data/spec/dummy/app/assets/config/manifest.js +3 -0
  29. data/spec/dummy/app/assets/images/.keep +0 -0
  30. data/spec/dummy/app/assets/javascripts/application.es6 +56 -0
  31. data/spec/dummy/app/assets/stylesheets/application.scss +65 -0
  32. data/spec/dummy/app/controllers/application_controller.rb +4 -0
  33. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  34. data/spec/dummy/app/controllers/fields/application_controller.rb +25 -0
  35. data/spec/dummy/app/controllers/fields/options_controller.rb +26 -0
  36. data/spec/dummy/app/controllers/fields/validations_controller.rb +26 -0
  37. data/spec/dummy/app/controllers/forms/application_controller.rb +14 -0
  38. data/spec/dummy/app/controllers/forms/fields_controller.rb +56 -0
  39. data/spec/dummy/app/controllers/forms/formulas/application_controller.rb +19 -0
  40. data/spec/dummy/app/controllers/forms/formulas/playgrounds_controller.rb +29 -0
  41. data/spec/dummy/app/controllers/forms/formulas_controller.rb +56 -0
  42. data/spec/dummy/app/controllers/forms_controller.rb +58 -0
  43. data/spec/dummy/app/controllers/home_controller.rb +7 -0
  44. data/spec/dummy/app/controllers/nested_forms/application_controller.rb +12 -0
  45. data/spec/dummy/app/controllers/nested_forms/fields_controller.rb +50 -0
  46. data/spec/dummy/app/controllers/playgrounds_controller.rb +29 -0
  47. data/spec/dummy/app/decorators/.keep +0 -0
  48. data/spec/dummy/app/helpers/application_helper.rb +21 -0
  49. data/spec/dummy/app/helpers/fields_helper.rb +32 -0
  50. data/spec/dummy/app/helpers/forms_helper.rb +14 -0
  51. data/spec/dummy/app/jobs/application_job.rb +4 -0
  52. data/spec/dummy/app/lib/script_engine.rb +22 -0
  53. data/spec/dummy/app/models/application_record.rb +8 -0
  54. data/spec/dummy/app/models/concerns/.keep +0 -0
  55. data/spec/dummy/app/models/concerns/acts_as_default_value.rb +152 -0
  56. data/spec/dummy/app/models/concerns/enum_attribute_localizable.rb +32 -0
  57. data/spec/dummy/app/models/concerns/fields/validations/acceptance.rb +18 -0
  58. data/spec/dummy/app/models/concerns/fields/validations/confirmation.rb +18 -0
  59. data/spec/dummy/app/models/concerns/fields/validations/exclusion.rb +35 -0
  60. data/spec/dummy/app/models/concerns/fields/validations/format.rb +45 -0
  61. data/spec/dummy/app/models/concerns/fields/validations/inclusion.rb +35 -0
  62. data/spec/dummy/app/models/concerns/fields/validations/length.rb +59 -0
  63. data/spec/dummy/app/models/concerns/fields/validations/numericality.rb +56 -0
  64. data/spec/dummy/app/models/concerns/fields/validations/presence.rb +18 -0
  65. data/spec/dummy/app/models/concerns/form_core/acts_as_default_value.rb +143 -0
  66. data/spec/dummy/app/models/field.rb +67 -0
  67. data/spec/dummy/app/models/field_options.rb +90 -0
  68. data/spec/dummy/app/models/fields.rb +10 -0
  69. data/spec/dummy/app/models/fields/boolean_field.rb +12 -0
  70. data/spec/dummy/app/models/fields/decimal_field.rb +12 -0
  71. data/spec/dummy/app/models/fields/integer_field.rb +20 -0
  72. data/spec/dummy/app/models/fields/multiple_nested_form_field.rb +35 -0
  73. data/spec/dummy/app/models/fields/nested_form_field.rb +37 -0
  74. data/spec/dummy/app/models/fields/options/boolean_field.rb +6 -0
  75. data/spec/dummy/app/models/fields/options/decimal_field.rb +12 -0
  76. data/spec/dummy/app/models/fields/options/integer_field.rb +13 -0
  77. data/spec/dummy/app/models/fields/options/multiple_nested_form_field.rb +6 -0
  78. data/spec/dummy/app/models/fields/options/nested_form_field.rb +6 -0
  79. data/spec/dummy/app/models/fields/options/text_field.rb +7 -0
  80. data/spec/dummy/app/models/fields/text_field.rb +12 -0
  81. data/spec/dummy/app/models/fields/validations/boolean_field.rb +7 -0
  82. data/spec/dummy/app/models/fields/validations/decimal_field.rb +8 -0
  83. data/spec/dummy/app/models/fields/validations/integer_field.rb +8 -0
  84. data/spec/dummy/app/models/fields/validations/multiple_nested_form_field.rb +8 -0
  85. data/spec/dummy/app/models/fields/validations/nested_form_field.rb +7 -0
  86. data/spec/dummy/app/models/fields/validations/text_field.rb +9 -0
  87. data/spec/dummy/app/models/form.rb +8 -0
  88. data/spec/dummy/app/models/formula.rb +8 -0
  89. data/spec/dummy/app/models/metal_form.rb +9 -0
  90. data/spec/dummy/app/models/nested_form.rb +5 -0
  91. data/spec/dummy/app/models/virtual_model.rb +23 -0
  92. data/spec/dummy/app/presenters/application_presenter.rb +11 -0
  93. data/spec/dummy/app/presenters/concerns/fields/presenter_for_number_field.rb +36 -0
  94. data/spec/dummy/app/presenters/fields/boolean_field_presenter.rb +13 -0
  95. data/spec/dummy/app/presenters/fields/composite_field_presenter.rb +13 -0
  96. data/spec/dummy/app/presenters/fields/decimal_field_presenter.rb +7 -0
  97. data/spec/dummy/app/presenters/fields/field_presenter.rb +44 -0
  98. data/spec/dummy/app/presenters/fields/integer_field_presenter.rb +11 -0
  99. data/spec/dummy/app/presenters/fields/multiple_nested_form_field_presenter.rb +9 -0
  100. data/spec/dummy/app/presenters/fields/nested_form_field_presenter.rb +9 -0
  101. data/spec/dummy/app/presenters/fields/text_field_presenter.rb +10 -0
  102. data/spec/dummy/app/views/_form_core/field_options/_decimal_field.html.erb +9 -0
  103. data/spec/dummy/app/views/_form_core/field_options/_integer_field.html.erb +10 -0
  104. data/spec/dummy/app/views/_form_core/field_options/_text_field.html.erb +12 -0
  105. data/spec/dummy/app/views/_form_core/fields/_boolean_field.html.erb +11 -0
  106. data/spec/dummy/app/views/_form_core/fields/_decimal_field.html.erb +9 -0
  107. data/spec/dummy/app/views/_form_core/fields/_integer_field.html.erb +9 -0
  108. data/spec/dummy/app/views/_form_core/fields/_multiple_nested_form_field.html.erb +23 -0
  109. data/spec/dummy/app/views/_form_core/fields/_nested_form.html.erb +37 -0
  110. data/spec/dummy/app/views/_form_core/fields/_nested_form_field.html.erb +42 -0
  111. data/spec/dummy/app/views/_form_core/fields/_text_field.html.erb +13 -0
  112. data/spec/dummy/app/views/_form_core/preview/_form.html.erb +17 -0
  113. data/spec/dummy/app/views/_form_core/preview/_nested_form.html.erb +22 -0
  114. data/spec/dummy/app/views/_form_core/render/_form.html.erb +39 -0
  115. data/spec/dummy/app/views/_form_core/validations/_acceptance.html.erb +12 -0
  116. data/spec/dummy/app/views/_form_core/validations/_confirmation.html.erb +12 -0
  117. data/spec/dummy/app/views/_form_core/validations/_exclusion.html.erb +2 -0
  118. data/spec/dummy/app/views/_form_core/validations/_format.html.erb +37 -0
  119. data/spec/dummy/app/views/_form_core/validations/_inclusion.html.erb +2 -0
  120. data/spec/dummy/app/views/_form_core/validations/_length.html.erb +44 -0
  121. data/spec/dummy/app/views/_form_core/validations/_numericality.html.erb +45 -0
  122. data/spec/dummy/app/views/_form_core/validations/_presence.html.erb +12 -0
  123. data/spec/dummy/app/views/fields/options/_form.html.erb +29 -0
  124. data/spec/dummy/app/views/fields/options/edit.html.erb +6 -0
  125. data/spec/dummy/app/views/fields/validations/_form.html.erb +34 -0
  126. data/spec/dummy/app/views/fields/validations/edit.html.erb +6 -0
  127. data/spec/dummy/app/views/forms/_form.html.erb +41 -0
  128. data/spec/dummy/app/views/forms/edit.html.erb +6 -0
  129. data/spec/dummy/app/views/forms/fields/_form.html.erb +71 -0
  130. data/spec/dummy/app/views/forms/fields/edit.html.erb +6 -0
  131. data/spec/dummy/app/views/forms/fields/index.html.erb +42 -0
  132. data/spec/dummy/app/views/forms/fields/new.html.erb +6 -0
  133. data/spec/dummy/app/views/forms/formulas/_form.html.erb +41 -0
  134. data/spec/dummy/app/views/forms/formulas/edit.html.erb +6 -0
  135. data/spec/dummy/app/views/forms/formulas/index.html.erb +28 -0
  136. data/spec/dummy/app/views/forms/formulas/new.html.erb +6 -0
  137. data/spec/dummy/app/views/forms/formulas/playgrounds/create.html.erb +48 -0
  138. data/spec/dummy/app/views/forms/formulas/playgrounds/show.html.erb +14 -0
  139. data/spec/dummy/app/views/forms/index.html.erb +31 -0
  140. data/spec/dummy/app/views/forms/new.html.erb +6 -0
  141. data/spec/dummy/app/views/home/index.html.erb +5 -0
  142. data/spec/dummy/app/views/layouts/_alert.html.erb +4 -0
  143. data/spec/dummy/app/views/layouts/_footer.html.erb +13 -0
  144. data/spec/dummy/app/views/layouts/_nav.html.erb +11 -0
  145. data/spec/dummy/app/views/layouts/_notice.html.erb +4 -0
  146. data/spec/dummy/app/views/layouts/application.html.erb +25 -0
  147. data/spec/dummy/app/views/layouts/forms.html.erb +33 -0
  148. data/spec/dummy/app/views/nested_forms/fields/_form.html.erb +68 -0
  149. data/spec/dummy/app/views/nested_forms/fields/edit.html.erb +6 -0
  150. data/spec/dummy/app/views/nested_forms/fields/index.html.erb +39 -0
  151. data/spec/dummy/app/views/nested_forms/fields/new.html.erb +6 -0
  152. data/spec/dummy/app/views/playgrounds/_form.html.erb +13 -0
  153. data/spec/dummy/app/views/playgrounds/create.html.erb +51 -0
  154. data/spec/dummy/app/views/playgrounds/show.html.erb +7 -0
  155. data/spec/dummy/bin/bundle +5 -0
  156. data/spec/dummy/bin/rails +6 -0
  157. data/spec/dummy/bin/rake +6 -0
  158. data/spec/dummy/bin/setup +40 -0
  159. data/spec/dummy/bin/update +35 -0
  160. data/spec/dummy/bin/yarn +13 -0
  161. data/spec/dummy/config.ru +7 -0
  162. data/spec/dummy/config/application.rb +35 -0
  163. data/spec/dummy/config/boot.rb +7 -0
  164. data/spec/dummy/config/database.yml +25 -0
  165. data/spec/dummy/config/environment.rb +7 -0
  166. data/spec/dummy/config/environments/development.rb +58 -0
  167. data/spec/dummy/config/environments/production.rb +85 -0
  168. data/spec/dummy/config/environments/test.rb +41 -0
  169. data/spec/dummy/config/initializers/application_controller_renderer.rb +10 -0
  170. data/spec/dummy/config/initializers/assets.rb +16 -0
  171. data/spec/dummy/config/initializers/backtrace_silencers.rb +9 -0
  172. data/spec/dummy/config/initializers/content_security_policy.rb +27 -0
  173. data/spec/dummy/config/initializers/cookies_serializer.rb +7 -0
  174. data/spec/dummy/config/initializers/filter_parameter_logging.rb +6 -0
  175. data/spec/dummy/config/initializers/form_core.rb +4 -0
  176. data/spec/dummy/config/initializers/inflections.rb +18 -0
  177. data/spec/dummy/config/initializers/mime_types.rb +6 -0
  178. data/spec/dummy/config/initializers/wrap_parameters.rb +16 -0
  179. data/spec/dummy/config/locales/en.yml +33 -0
  180. data/spec/dummy/config/puma.rb +36 -0
  181. data/spec/dummy/config/routes.rb +31 -0
  182. data/spec/dummy/config/spring.rb +8 -0
  183. data/spec/dummy/config/storage.yml +34 -0
  184. data/spec/dummy/db/migrate/20180916202025_create_forms.form_core.rb +12 -0
  185. data/spec/dummy/db/migrate/20180916202026_add_columns_to_forms.rb +10 -0
  186. data/spec/dummy/db/migrate/20180916202027_add_attachable_to_forms.rb +9 -0
  187. data/spec/dummy/db/migrate/20180916202030_create_fields.form_core.rb +17 -0
  188. data/spec/dummy/db/migrate/20180916202121_add_columns_to_fields.rb +10 -0
  189. data/spec/dummy/db/migrate/20180916202124_add_position_to_fields.rb +9 -0
  190. data/spec/dummy/db/migrate/20181111111412_create_formulas.rb +13 -0
  191. data/spec/dummy/db/schema.rb +52 -0
  192. data/spec/dummy/lib/assets/.keep +0 -0
  193. data/spec/dummy/lib/monkey_patches/active_support.rb +3 -0
  194. data/spec/dummy/lib/monkey_patches/active_support/concern+prependable.rb +28 -0
  195. data/spec/dummy/lib/monkey_patches/big_decimal.rb +8 -0
  196. data/spec/dummy/log/.keep +0 -0
  197. data/spec/dummy/mruby/engine.gembox +19 -0
  198. data/spec/dummy/mruby/lib/.keep +0 -0
  199. data/spec/dummy/mruby/lib/core_ext.rb +62 -0
  200. data/spec/dummy/mruby/lib/harden.rb +1 -0
  201. data/spec/dummy/mruby/lib/input.rb +20 -0
  202. data/spec/dummy/mruby/lib/io.rb +19 -0
  203. data/spec/dummy/mruby/lib/output.rb +35 -0
  204. data/spec/dummy/mruby/lib/script_kernel.rb +12 -0
  205. data/spec/dummy/package.json +5 -0
  206. data/spec/dummy/public/404.html +67 -0
  207. data/spec/dummy/public/422.html +67 -0
  208. data/spec/dummy/public/500.html +66 -0
  209. data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
  210. data/spec/dummy/public/apple-touch-icon.png +0 -0
  211. data/spec/dummy/public/favicon.ico +0 -0
  212. data/spec/dummy/storage/.keep +0 -0
  213. data/spec/dummy/test/controllers/.keep +0 -0
  214. data/spec/dummy/test/fixtures/.keep +0 -0
  215. data/spec/dummy/test/models/.keep +0 -0
  216. data/spec/script_core_spec.rb +2 -2
  217. data/spec/spec_helper.rb +2 -2
  218. metadata +199 -5
  219. data/circle.yml +0 -9
@@ -0,0 +1,11 @@
1
+ <div class="field">
2
+ <div class="control">
3
+ <label class="checkbox">
4
+ <%= f.check_box field.name, id: field.id, required: field.required, disabled: field.access_readonly? %>
5
+ <%= field.label %>
6
+ </label>
7
+ </div>
8
+ <% if field.hint.present? %>
9
+ <p class="help"><%= field.hint %></p>
10
+ <% end %>
11
+ </div>
@@ -0,0 +1,9 @@
1
+ <div class="field">
2
+ <%= f.label field.name, field.label, class: 'label' %>
3
+ <div class="control">
4
+ <%= f.number_field field.name, class: 'input', id: field.id, required: field.required, disabled: field.access_readonly?, **field.to_builder_options %>
5
+ </div>
6
+ <% if field.hint.present? %>
7
+ <p class="help"><%= field.hint %></p>
8
+ <% end %>
9
+ </div>
@@ -0,0 +1,9 @@
1
+ <div class="field">
2
+ <%= f.label field.name, field.label, class: 'label' %>
3
+ <div class="control">
4
+ <%= f.number_field field.name, class: 'input', id: field.id, required: field.required, disabled: field.access_readonly?, **field.to_builder_options %>
5
+ </div>
6
+ <% if field.hint.present? %>
7
+ <p class="help"><%= field.hint %></p>
8
+ <% end %>
9
+ </div>
@@ -0,0 +1,23 @@
1
+ <div class="field nested_form_field">
2
+ <h2 class="label"><%= field.label %></h2>
3
+
4
+ <%= tag.div id: field.name, class: "collection" do %>
5
+ <%= f.fields_for field.name do |ff| %>
6
+ <%= render "_form_core/fields/nested_form", f: ff, field: field, form: field.nested_form %>
7
+ <% end %>
8
+
9
+ <div class="links">
10
+ <% if field.access_read_and_write? %>
11
+ <%= link_to_add_association "Add", f, field.name,
12
+ class: "button is-small",
13
+ partial: "_form_core/fields/nested_form",
14
+ render_options: {
15
+ locals: {field: field, form: field.nested_form}
16
+ } %>
17
+ <% end %>
18
+ <% if field.hint.present? %>
19
+ <p class="help"><%= field.hint %></p>
20
+ <% end %>
21
+ </div>
22
+ <% end %>
23
+ </div>
@@ -0,0 +1,37 @@
1
+ <div class="nested_form">
2
+ <% if f.object.errors.any? %>
3
+ <article class="message is-danger">
4
+ <div class="message-header">
5
+ <p>
6
+ <%= pluralize(f.object.errors.count, "error") %> prohibited this form from being submitted:
7
+ </p>
8
+ </div>
9
+ <div class="message-body content">
10
+ <ul>
11
+ <% f.object.errors.messages.each do |name, messages| %>
12
+ <% messages.each do |message| %>
13
+ <li>
14
+ <%= "#{form.fields.select { |field| field.name == name}.first&.label } #{message}" %>
15
+ </li>
16
+ <% end %>
17
+ <% end %>
18
+ </ul>
19
+ </div>
20
+ </article>
21
+ <% end %>
22
+
23
+ <% form.fields.each do |field| %>
24
+ <% field = present(field, target: f.object) %>
25
+ <% unless field.access_hidden? %>
26
+ <%= render "_form_core/fields/#{field.type_key}", f: f, field: field %>
27
+ <% end %>
28
+ <% end %>
29
+
30
+ <% if field.access_read_and_write? %>
31
+ <div class="field is-grouped">
32
+ <div class="control">
33
+ <%= link_to_remove_association "Remove", f, class: "button is-small is-danger", wrapper_class: "nested_form" %>
34
+ </div>
35
+ </div>
36
+ <% end %>
37
+ </div>
@@ -0,0 +1,42 @@
1
+ <div class="field nested_form_field">
2
+ <h2 class="label"><%= field.label %></h2>
3
+
4
+ <%= tag.div id: field.name, class: "collection" do %>
5
+ <%= f.fields_for field.name do |ff| %>
6
+ <%= render "_form_core/fields/nested_form", f: ff, field: field, form: field.nested_form %>
7
+ <% end %>
8
+
9
+ <div class="links">
10
+ <% if field.access_read_and_write? %>
11
+ <%= link_to_add_association "Add", f, field.name,
12
+ force_non_association_create: true,
13
+ class: "button is-small",
14
+ partial: "_form_core/fields/nested_form",
15
+ render_options: {
16
+ locals: {field: field, form: field.nested_form}
17
+ } %>
18
+ <% end %>
19
+ <% if field.hint.present? %>
20
+ <p class="help"><%= field.hint %></p>
21
+ <% end %>
22
+ </div>
23
+ <% end %>
24
+ </div>
25
+
26
+ <% if field.access_read_and_write? %>
27
+ <script>
28
+ document.addEventListener("turbolinks:load", function() {
29
+ if($('<%= "##{field.name}" %> > .nested_form').length > 0) {
30
+ $('<%= "##{field.name}" %> .links a.add_fields').hide();
31
+ }
32
+
33
+ $('<%= "##{field.name}" %>')
34
+ .on('cocoon:before-insert', function() {
35
+ $('<%= "##{field.name}" %> .links a.add_fields').hide();
36
+ })
37
+ .on("cocoon:before-remove", function() {
38
+ $('<%= "##{field.name}" %> .links a.add_fields').show();
39
+ });
40
+ });
41
+ </script>
42
+ <% end %>
@@ -0,0 +1,13 @@
1
+ <div class="field">
2
+ <%= f.label field.name, field.label, class: 'label' %>
3
+ <div class="control">
4
+ <% if field.options.multiline %>
5
+ <%= f.text_area field.name, class: 'textarea', id: field.id, required: field.required, disabled: field.access_readonly? %>
6
+ <% else %>
7
+ <%= f.text_field field.name, class: 'input', id: field.id, required: field.required, disabled: field.access_readonly? %>
8
+ <% end %>
9
+ </div>
10
+ <% if field.hint.present? %>
11
+ <p class="help"><%= field.hint %></p>
12
+ <% end %>
13
+ </div>
@@ -0,0 +1,17 @@
1
+ <% form.fields.map { |field| present(field, target: instance) }.each do |field| %>
2
+ <% if field.nested_form_field? %>
3
+ <% next unless field.value_for_preview %>
4
+
5
+ <p><%= field.label %>:</p>
6
+ <%= render "_form_core/preview/nested_form", form: field.nested_form, instance: field.value_for_preview %>
7
+ <% elsif field.multiple_nested_form? %>
8
+ <% next if field.value_for_preview.empty? %>
9
+
10
+ <p><%= field.label %>:</p>
11
+ <%= field.value_for_preview.map do |nested_instance| %>
12
+ <% render "_form_core/preview/nested_form", form: field.nested_form, instance: nested_instance %>
13
+ <% end.join("<hr>").html_safe %>
14
+ <% else %>
15
+ <p><%= field.label %>: <%= field.value_for_preview %></p>
16
+ <% end %>
17
+ <% end %>
@@ -0,0 +1,22 @@
1
+ <% fields = form.fields.map { |field| present(field, target: instance) }.reject(&:access_hidden?) %>
2
+ <% return if fields.empty? %>
3
+
4
+ <div class="nested-content">
5
+ <% fields.each do |field| %>
6
+ <% if field.nested_form_field? %>
7
+ <% next unless field.value_for_preview %>
8
+
9
+ <p><%= field.label %>:</p>
10
+ <%= render "_form_core/preview/nested_form", form: field.nested_form, instance: field.value_for_preview %>
11
+ <% elsif field.multiple_nested_form? %>
12
+ <% next if field.value_for_preview.empty? %>
13
+
14
+ <p><%= field.label %>:</p>
15
+ <%= field.value_for_preview.map do |nested_instance| %>
16
+ <% render "_form_core/preview/nested_form", form: field.nested_form, instance: nested_instance %>
17
+ <% end.join("<hr>").html_safe %>
18
+ <% else %>
19
+ <p><%= field.label %>: <%= field.value_for_preview %></p>
20
+ <% end %>
21
+ <% end %>
22
+ </div>
@@ -0,0 +1,39 @@
1
+ <% options ||= {} %>
2
+ <% back_url ||= url_for(:back) %>
3
+
4
+ <%= form_with(model: instance, **options) do |f| %>
5
+ <% if instance.errors.any? %>
6
+ <article class="message is-danger">
7
+ <div class="message-header">
8
+ <p>
9
+ <%= pluralize(instance.errors.count, "error") %> prohibited this form from being submitted:
10
+ </p>
11
+ </div>
12
+ <div class="message-body content">
13
+ <ul>
14
+ <% instance.errors.messages.each do |name, messages| %>
15
+ <% messages.each do |message| %>
16
+ <li><%= "#{field_label(form, field_name: name)} #{message}" %></li>
17
+ <% end %>
18
+ <% end %>
19
+ </ul>
20
+ </div>
21
+ </article>
22
+ <% end %>
23
+
24
+ <% form.fields.each do |field| %>
25
+ <% field = present(field, target: instance) %>
26
+ <% next if field.access_hidden? %>
27
+
28
+ <%= render "_form_core/fields/#{field.type_key}", f: f, field: field %>
29
+ <% end %>
30
+
31
+ <div class="field is-grouped">
32
+ <div class="control">
33
+ <%= f.submit "Submit", class: "button is-primary" %>
34
+ </div>
35
+ <div class="control">
36
+ <%= link_to "Back", back_url, class: "button is-link" %>
37
+ </div>
38
+ </div>
39
+ <% end %>
@@ -0,0 +1,12 @@
1
+ <h3 class="title">Acceptance</h3>
2
+
3
+ <div class="field">
4
+ <div class="control">
5
+ <label class="checkbox">
6
+ <%= f.check_box :acceptance %>
7
+ The field must be checked
8
+ </label>
9
+ </div>
10
+ </div>
11
+
12
+ <hr>
@@ -0,0 +1,12 @@
1
+ <h3 class="title">Confirmation</h3>
2
+
3
+ <div class="field">
4
+ <div class="control">
5
+ <label class="checkbox">
6
+ <%= f.check_box :confirmation %>
7
+ The field must be repeated in confirmation field
8
+ </label>
9
+ </div>
10
+ </div>
11
+
12
+ <hr>
@@ -0,0 +1,2 @@
1
+ <h3 class="title">Exclusion</h3>
2
+ <hr>
@@ -0,0 +1,37 @@
1
+ <% validations.build_format unless validations.format %>
2
+ <% format = validations.format %>
3
+
4
+ <h3 class="title">Format</h3>
5
+
6
+ <%= f.fields_for :format, format do |ff| %>
7
+ <% if format.errors.any? %>
8
+ <article class="message is-danger">
9
+ <div class="message-header">
10
+ <p>
11
+ <%= pluralize(format.errors.count, "error") %> prohibited this form from being saved:
12
+ </p>
13
+ </div>
14
+ <div class="message-body">
15
+ <% format.errors.full_messages.each do |message| %>
16
+ <li><%= message %></li>
17
+ <% end %>
18
+ </div>
19
+ </article>
20
+ <% end %>
21
+
22
+ <div class="field">
23
+ <%= ff.label :with %>
24
+ <div class="control">
25
+ <%= ff.text_field :with, class: "input" %>
26
+ </div>
27
+ </div>
28
+
29
+ <div class="field">
30
+ <%= ff.label :message %>
31
+ <div class="control">
32
+ <%= ff.text_field :message, class: "input" %>
33
+ </div>
34
+ </div>
35
+ <% end %>
36
+
37
+ <hr>
@@ -0,0 +1,2 @@
1
+ <h3 class="title">Inclusion</h3>
2
+ <hr>
@@ -0,0 +1,44 @@
1
+ <% validations.build_length unless validations.length %>
2
+ <% length = validations.length %>
3
+
4
+ <h3 class="title">Length</h3>
5
+
6
+ <%= f.fields_for :length, length do |ff| %>
7
+ <% if length.errors.any? %>
8
+ <article class="message is-danger">
9
+ <div class="message-header">
10
+ <p>
11
+ <%= pluralize(length.errors.count, "error") %> prohibited this form from being saved:
12
+ </p>
13
+ </div>
14
+ <div class="message-body">
15
+ <% length.errors.full_messages.each do |message| %>
16
+ <li><%= message %></li>
17
+ <% end %>
18
+ </div>
19
+ </article>
20
+ <% end %>
21
+
22
+ <div class="field">
23
+ <%= ff.label :minimum %>
24
+ <div class="control">
25
+ <%= ff.number_field :minimum, min: 0, step: 1, class: 'input' %>
26
+ </div>
27
+ </div>
28
+
29
+ <div class="field">
30
+ <%= ff.label :maximum %>
31
+ <div class="control">
32
+ <%= ff.number_field :maximum, min: 0, step: 1, class: 'input' %>
33
+ </div>
34
+ </div>
35
+
36
+ <div class="field">
37
+ <%= ff.label :is %>
38
+ <div class="control">
39
+ <%= ff.number_field :is, min: 0, step: 1, class: 'input' %>
40
+ </div>
41
+ </div>
42
+ <% end %>
43
+
44
+ <hr>
@@ -0,0 +1,45 @@
1
+ <% validations.build_numericality unless validations.numericality %>
2
+ <% numericality = validations.numericality %>
3
+
4
+ <h3 class="title">Numericality</h3>
5
+
6
+ <%= f.fields_for :numericality, numericality do |ff| %>
7
+ <% if numericality.errors.any? %>
8
+ <article class="message is-danger">
9
+ <div class="message-header">
10
+ <p>
11
+ <%= pluralize(numericality.errors.count, "error") %> prohibited this form from being saved:
12
+ </p>
13
+ </div>
14
+ <div class="message-body">
15
+ <% numericality.errors.full_messages.each do |message| %>
16
+ <li><%= message %></li>
17
+ <% end %>
18
+ </div>
19
+ </article>
20
+ <% end %>
21
+
22
+ <div class="field has-addons">
23
+ <div class="control">
24
+ <span class="select">
25
+ <%= ff.select :lower_bound_check, options_for_enum_select(numericality.class, :lower_bound_check, numericality.lower_bound_check), {}, class: "select" %>
26
+ </span>
27
+ </div>
28
+ <div class="control">
29
+ <%= ff.number_field :lower_bound_value, step: 0.01, class: "input" %>
30
+ </div>
31
+ </div>
32
+
33
+ <div class="field has-addons">
34
+ <div class="control">
35
+ <span class="select">
36
+ <%= ff.select :upper_bound_check, options_for_enum_select(numericality.class, :upper_bound_check, numericality.upper_bound_check), {}, class: "select" %>
37
+ </span>
38
+ </div>
39
+ <div class="control">
40
+ <%= ff.number_field :upper_bound_value, step: 0.01, class: "input" %>
41
+ </div>
42
+ </div>
43
+ <% end %>
44
+
45
+ <hr>
@@ -0,0 +1,12 @@
1
+ <h3 class="title">Presence</h3>
2
+
3
+ <div class="field">
4
+ <div class="control">
5
+ <label class="checkbox">
6
+ <%= f.check_box :presence %>
7
+ The field must not empty
8
+ </label>
9
+ </div>
10
+ </div>
11
+
12
+ <hr>
@@ -0,0 +1,29 @@
1
+ <%= form_with(model: options, scope: :options, url: field_options_path(field), method: :patch, local: true) do |f| %>
2
+ <% if options.errors.any? %>
3
+ <article class="message is-danger">
4
+ <div class="message-header">
5
+ <p>
6
+ <%= pluralize(options.errors.count, "error") %> prohibited this form from being saved:
7
+ </p>
8
+ </div>
9
+ <div class="message-body content">
10
+ <ul>
11
+ <% options.errors.full_messages.each do |message| %>
12
+ <li><%= message %></li>
13
+ <% end %>
14
+ </ul>
15
+ </div>
16
+ </article>
17
+ <% end %>
18
+
19
+ <%= render "_form_core/field_options/#{field.type_key}", f: f, options: options %>
20
+
21
+ <div class="field is-grouped">
22
+ <div class="control">
23
+ <%= f.submit "Update", class: 'button is-primary' %>
24
+ </div>
25
+ <div class="control">
26
+ <%= link_to 'Back', url_for(:back), class: 'button is-link' %>
27
+ </div>
28
+ </div>
29
+ <% end %>