super 0.20.0 → 0.22.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +36 -48
  3. data/app/assets/javascripts/super/application.js +1201 -2092
  4. data/app/assets/stylesheets/super/application.css +54 -6569
  5. data/app/controllers/super/application_controller.rb +52 -47
  6. data/app/controllers/super/foundation_controller.rb +30 -0
  7. data/app/controllers/super/sitewide_controller.rb +36 -0
  8. data/app/controllers/super/substructure_controller.rb +40 -92
  9. data/app/controllers/super/view_controller.rb +59 -0
  10. data/app/views/layouts/super/application.html.erb +3 -3
  11. data/app/views/super/application/_batch_checkbox.csv.erb +1 -1
  12. data/app/views/super/application/_batch_checkbox.html.erb +1 -1
  13. data/app/views/super/application/_collection_header.html.erb +1 -1
  14. data/app/views/super/application/_csv_button.html.erb +1 -1
  15. data/app/views/super/application/_display_actions.html.erb +1 -1
  16. data/app/views/super/application/_display_index.html.erb +8 -2
  17. data/app/views/super/application/_display_rich_text.html.erb +1 -1
  18. data/app/views/super/application/_display_show.html.erb +10 -2
  19. data/app/views/super/application/_filter.html.erb +63 -59
  20. data/app/views/super/application/_form.html.erb +1 -1
  21. data/app/views/super/application/_form_fieldset.html.erb +1 -1
  22. data/app/views/super/application/_form_has_many.html.erb +2 -2
  23. data/app/views/super/application/_form_has_one.html.erb +1 -1
  24. data/app/views/super/application/_layout.html.erb +6 -8
  25. data/app/views/super/application/_link.html.erb +1 -6
  26. data/app/views/super/application/_member_header.html.erb +1 -1
  27. data/app/views/super/application/_panel.html.erb +1 -1
  28. data/app/views/super/application/_query.html.erb +13 -12
  29. data/app/views/super/application/_site_header.html.erb +2 -2
  30. data/app/views/super/application/_sort.html.erb +18 -14
  31. data/app/views/super/application/_sort_expression.html.erb +1 -1
  32. data/app/views/super/application/_view_chain.html.erb +1 -5
  33. data/app/views/super/application/edit.html.erb +1 -1
  34. data/app/views/super/application/index.html.erb +1 -1
  35. data/app/views/super/application/new.html.erb +1 -1
  36. data/app/views/super/application/show.html.erb +1 -1
  37. data/config/locales/en.yml +3 -0
  38. data/frontend/super-frontend/dist/application.css +54 -6569
  39. data/frontend/super-frontend/dist/application.js +1201 -2092
  40. data/lib/super/action_inquirer.rb +28 -8
  41. data/lib/super/assets.rb +2 -2
  42. data/lib/super/badge.rb +8 -23
  43. data/lib/super/cheat.rb +11 -5
  44. data/lib/super/client_error.rb +4 -0
  45. data/lib/super/compatibility.rb +4 -0
  46. data/lib/super/configuration.rb +3 -0
  47. data/lib/super/display/schema_types.rb +50 -71
  48. data/lib/super/display.rb +16 -15
  49. data/lib/super/error.rb +16 -2
  50. data/lib/super/filter/form_object.rb +2 -2
  51. data/lib/super/filter/operator.rb +1 -1
  52. data/lib/super/filter/schema_types.rb +1 -1
  53. data/lib/super/form/field_transcript.rb +4 -0
  54. data/lib/super/form/schema_types.rb +2 -2
  55. data/lib/super/form/strong_params.rb +1 -1
  56. data/lib/super/form_builder/base_methods.rb +3 -9
  57. data/lib/super/form_builder/flatpickr_methods.rb +3 -3
  58. data/lib/super/form_builder.rb +19 -21
  59. data/{app/helpers → lib}/super/form_builder_helper.rb +13 -2
  60. data/lib/super/link.rb +15 -6
  61. data/lib/super/link_builder.rb +4 -4
  62. data/lib/super/navigation.rb +49 -45
  63. data/lib/super/partial.rb +0 -12
  64. data/lib/super/plugin.rb +2 -2
  65. data/lib/super/query.rb +61 -0
  66. data/lib/super/{engine.rb → railtie.rb} +8 -1
  67. data/lib/super/render_helper.rb +31 -0
  68. data/lib/super/reset.rb +7 -5
  69. data/lib/super/schema/guesser.rb +5 -5
  70. data/lib/super/schema.rb +10 -4
  71. data/lib/super/sort.rb +2 -4
  72. data/lib/super/useful/deprecations.rb +16 -0
  73. data/lib/super/useful/enum.rb +1 -1
  74. data/lib/super/useful/i19.rb +1 -1
  75. data/lib/super/version.rb +1 -1
  76. data/lib/super/view_chain.rb +33 -4
  77. data/lib/super.rb +9 -2
  78. metadata +11 -49
  79. data/config/routes.rb +0 -4
  80. data/lib/super/query/form_object.rb +0 -48
@@ -1,66 +1,70 @@
1
- <h1 class="text-lg">Filter</h1>
2
- <% filter.each_attribute do |attribute_form_object| %>
3
- <div class="mt-4">
4
- <%= form.fields_for(attribute_form_object.field_name, attribute_form_object) do |attribute_form| %>
5
- <% selected_index = 0 %>
6
- <div data-controller="tab-container" data-tab-container-tab-identifier-getter-value="tabIdentifierValue" data-tab-container-tab-controller-name-value="tab">
7
- <div>
8
- <span class="inline-block"><%= attribute_form_object.humanized_attribute_name %></span>
9
- <select data-tab-container-target="control" data-action="tab-container#change" class="super-input super-input-select inline-block">
10
- <% selected = false %>
1
+ <h1 class="text-lg mt-4">Filter</h1>
2
+ <%= super_fields_for(query.namespace_for(filter), filter) do |form| %>
3
+ <% filter.each_attribute do |attribute_form_object| %>
4
+ <div class="mt-4">
5
+ <%= form.fields_for(attribute_form_object.field_name, attribute_form_object) do |attribute_form| %>
6
+ <% selected_index = 0 %>
7
+ <div data-controller="tab-container" data-tab-container-tab-identifier-getter-value="tabIdentifierValue" data-tab-container-tab-controller-name-value="tab">
8
+ <div>
9
+ <span class="inline-block"><%= attribute_form_object.humanized_attribute_name %></span>
10
+ <select data-tab-container-target="control" data-action="tab-container#change" class="super-input super-input-select inline-block">
11
+ <% selected = false %>
12
+ <% attribute_form_object.each_operator.with_index do |operator_form_object, index| %>
13
+ <%
14
+ selected_attribute =
15
+ if !selected && operator_form_object.specified?
16
+ selected = true
17
+ selected_index = index
18
+ %(selected=selected)
19
+ else
20
+ ""
21
+ end
22
+ %>
23
+ <option value="<%= operator_form_object.identifier %>" <%= selected_attribute %>><%= operator_form_object.operator.humanized_operator_name %></option>
24
+ <% end %>
25
+ </select>
26
+ </div>
27
+ <div>
11
28
  <% attribute_form_object.each_operator.with_index do |operator_form_object, index| %>
12
- <%
13
- selected_attribute =
14
- if !selected && operator_form_object.specified?
15
- selected = true
16
- selected_index = index
17
- %(selected=selected)
18
- else
19
- ""
20
- end
21
- %>
22
- <option value="<%= operator_form_object.identifier %>" <%= selected_attribute %>><%= operator_form_object.operator.humanized_operator_name %></option>
23
- <% end %>
24
- </select>
25
- </div>
26
- <div>
27
- <% attribute_form_object.each_operator.with_index do |operator_form_object, index| %>
28
- <div data-controller="tab" data-tab-tab-container-getter-value="tabContainer" data-tab-container-target="tab" data-tab-identifier-value="<%= operator_form_object.identifier %>">
29
- <% form_html = capture do %>
30
- <div data-tab-target="content">
31
- <%= attribute_form.fields_for(operator_form_object.identifier, operator_form_object) do |operator_form| %>
32
- <div class="flex gap-x-2 mt-2">
33
- <% operator_form_object.each_field.with_index do |operator_field_name, index| %>
34
- <div class="flex-1">
35
- <% if operator_field_name == Super::Filter::FormObject::OperatorForm::NULLARY %>
36
- <%= operator_form.super.check_box(operator_field_name, {}, "1", "") %>
37
- <%= operator_form.super.label(operator_field_name, nil, super: { class: "select-none ml-1" }) %>
38
- <% elsif operator_form_object.operator.respond_to?(:field_transcript) && operator_form_object.operator.field_transcript %>
39
- <% field_transcript = operator_form_object.operator.field_transcript %>
40
- <% if field_transcript.super? %>
41
- <%= operator_form.super.public_send(field_transcript.method_name, operator_field_name, *field_transcript.args, **field_transcript.kwargs) %>
29
+ <div data-controller="tab" data-tab-tab-container-getter-value="tabContainer" data-tab-container-target="tab" data-tab-identifier-value="<%= operator_form_object.identifier %>">
30
+ <% form_html = capture do %>
31
+ <div data-tab-target="content">
32
+ <%= attribute_form.fields_for(operator_form_object.identifier, operator_form_object) do |operator_form| %>
33
+ <div class="flex gap-x-2 mt-2">
34
+ <% operator_form_object.each_field.with_index do |operator_field_name, index| %>
35
+ <div class="flex-1">
36
+ <% if operator_field_name == Super::Filter::FormObject::OperatorForm::NULLARY %>
37
+ <%= operator_form.super.check_box(operator_field_name, {}, "1", "") %>
38
+ <%= operator_form.super.label(operator_field_name, nil, super: { class: "select-none ml-1" }) %>
39
+ <% elsif operator_form_object.operator.respond_to?(:field_transcript) && operator_form_object.operator.field_transcript %>
40
+ <% field_transcript = operator_form_object.operator.field_transcript %>
41
+ <% if field_transcript.super? %>
42
+ <%= operator_form.super.public_send(field_transcript.method_name, operator_field_name, *field_transcript.args, **field_transcript.kwargs) %>
43
+ <% else %>
44
+ <%= operator_form.public_send(field_transcript.method_name, operator_field_name, *field_transcript.args, **field_transcript.kwargs) %>
45
+ <% end %>
42
46
  <% else %>
43
- <%= operator_form.public_send(field_transcript.method_name, operator_field_name, *field_transcript.args, **field_transcript.kwargs) %>
47
+ <%= operator_form.super.text_field(operator_field_name) %>
44
48
  <% end %>
45
- <% else %>
46
- <%= operator_form.super.text_field(operator_field_name) %>
47
- <% end %>
48
- </div>
49
- <% end %>
50
- </div>
51
- <% end %>
52
- </div>
53
- <% end %>
49
+ </div>
50
+ <% end %>
51
+ </div>
52
+ <% end %>
53
+ </div>
54
+ <% end %>
54
55
 
55
- <%= form_html if index == selected_index %>
56
+ <%= form_html if index == selected_index %>
56
57
 
57
- <template data-tab-target="pocket">
58
- <%= form_html %>
59
- </template>
60
- </div>
61
- <% end %>
58
+ <template data-tab-target="pocket">
59
+ <%= form_html %>
60
+ </template>
61
+ </div>
62
+ <% end %>
63
+ </div>
62
64
  </div>
63
- </div>
64
- <% end %>
65
- </div>
65
+ <% end %>
66
+ </div>
67
+ <% end %>
66
68
  <% end %>
69
+
70
+ <%= yield if block_given? %>
@@ -1,7 +1,7 @@
1
1
  <%= super_form_for(form_record(@record), url: form_action(@record)) do |f| %>
2
2
  <div class="max-w-3xl">
3
3
  <% form.each_attribute do |field, type| %>
4
- <%= render(
4
+ <%= super_render(
5
5
  type,
6
6
  form: f,
7
7
  column: field
@@ -3,6 +3,6 @@
3
3
  <legend class="bg-white p-1 -mx-1"><%= form_fieldset.label %></legend>
4
4
  <% end %>
5
5
  <% form_fieldset.nested_fields.each do |field, type| %>
6
- <%= render(type, form: form, column: field) %>
6
+ <%= super_render(type, form: form, column: field) %>
7
7
  <% end %>
8
8
  </fieldset>
@@ -1,6 +1,6 @@
1
1
  <div data-controller="apply-template">
2
2
  <%= form.fields_for(form_has_many.reader) do |ff| %>
3
- <%= render "form_fieldset", form_fieldset: form_has_many, form: ff %>
3
+ <%= super_render "form_fieldset", form_fieldset: form_has_many, form: ff %>
4
4
  <% end %>
5
5
 
6
6
  <%=
@@ -11,7 +11,7 @@
11
11
  ) do |ff|
12
12
  %>
13
13
  <template data-apply-template-target="template">
14
- <%= render "form_fieldset", form_fieldset: form_has_many, form: ff %>
14
+ <%= super_render "form_fieldset", form_fieldset: form_has_many, form: ff %>
15
15
  </template>
16
16
  <% end %>
17
17
 
@@ -6,6 +6,6 @@
6
6
  %>
7
7
 
8
8
  <%= form.fields_for(form_has_one.reader) do |ff| %>
9
- <%= render "form_fieldset", form_fieldset: form_has_one, form: ff %>
9
+ <%= super_render "form_fieldset", form_fieldset: form_has_one, form: ff %>
10
10
  <% end %>
11
11
  </div>
@@ -1,28 +1,26 @@
1
- <%# <% layout.resolve(self) %1> %>
2
-
3
1
  <% if layout.header %>
4
- <%= render layout.header %>
2
+ <%= super_render layout.header %>
5
3
  <% end %>
6
4
 
7
5
  <% if layout.aside %>
8
6
  <div class="flow-root -mx-2">
9
7
  <div class="md:float-left md:w-9/12 px-2">
10
8
  <% if layout.main %>
11
- <%= render layout.main %>
9
+ <%= super_render layout.main %>
12
10
  <% end %>
13
11
  </div>
14
12
 
15
13
  <div class="md:float-right md:w-3/12 px-2">
16
- <%= render layout.aside %>
14
+ <%= super_render layout.aside %>
17
15
  </div>
18
16
  </div>
19
17
  <% else %>
20
18
  <% if layout.main %>
21
- <%= render layout.main %>
19
+ <%= super_render layout.main %>
22
20
  <% end %>
23
21
  <% end %>
24
22
 
25
23
  <% if layout.footer %>
26
- <%= render layout.footer %>
27
- <%= Super::Partial.render(partial, template: self) %>
24
+ <%= super_render layout.footer %>
25
+ <%= super_render(partial) %>
28
26
  <% end %>
@@ -1,8 +1,3 @@
1
1
  <%=
2
- default_options ||= {}
3
- link_to(
4
- link.text,
5
- link.href,
6
- default_options.deep_merge(link.options)
7
- )
2
+ link.to_link(self, local_assigns)
8
3
  %>
@@ -4,7 +4,7 @@
4
4
  </h1>
5
5
  <div class="flex gap-2">
6
6
  <% resolved_member_actions(@record).each do |link| %>
7
- <%= render(
7
+ <%= super_render(
8
8
  link,
9
9
  default_options: {
10
10
  class: "super-button super-button--border-blue super-button-sm inline-block"
@@ -1,7 +1,7 @@
1
1
  <% if panel.resolve(self, block_given? ? Proc.new { yield } : nil).resolved_parts.any? %>
2
2
  <div class="border rounded shadow border-gray-400 bg-white px-5 pt-4 pb-8 mt-6">
3
3
  <% panel.resolved_parts.each do |partial| %>
4
- <%= Super::Partial.render(partial, template: self) %>
4
+ <%= super_render(partial) %>
5
5
  <% end %>
6
6
  </div>
7
7
  <% end %>
@@ -1,18 +1,19 @@
1
- <%= render(Super::Panel.new) do %>
1
+ <% if filters_enabled? || sort_enabled? %>
2
2
  <h1 class="text-xl">Query</h1>
3
- <%= super_form_for(
4
- query,
5
- url: query.path,
6
- method: :get,
7
- as: query.namespace,
8
- html: { class: "mt-4" },
9
- data: { controller: "clean-filter-params", action: "submit->clean-filter-params#call" }) do |form| %>
10
- <% query.addons.each do |namespace, addon| %>
11
- <%= form.fields_for namespace do |addon_form| %>
12
- <%= render(addon, form: addon_form) %>
3
+
4
+ <%= form_tag(query.path, method: :get, data: { controller: "clean-filter-params", action: "submit->clean-filter-params#call" }) do %>
5
+ <% if filters_enabled? %>
6
+ <%= super_render @filter_form %>
7
+ <% end %>
8
+ <% if sort_enabled? %>
9
+ <% if filters_enabled? %>
10
+ <div class="mt-6"></div>
13
11
  <% end %>
12
+ <%= super_render @sort_form %>
14
13
  <% end %>
15
14
 
16
- <%= form.super.submit "Apply", class: "super-button--border-gray mt-6" %>
15
+ <%= submit_tag("Apply", class: "super-button super-button--border-gray mt-6") %>
17
16
  <% end %>
18
17
  <% end %>
18
+
19
+ <%= yield if block_given? %>
@@ -2,13 +2,13 @@
2
2
  <h1 class="text-lg font-bold mr-6 mb-1"><%= site_title %></h1>
3
3
  <% site_navigation.definition.each do |link_or_menu| %>
4
4
  <% if link_or_menu.is_a?(Super::Link) %>
5
- <%= render(link_or_menu, default_options: { class: "inline-block mr-6" }) %>
5
+ <%= super_render(link_or_menu, default_options: { class: "inline-block mr-6" }) %>
6
6
  <% else %>
7
7
  <details class="details-reset details-backdrop-transparent select-none inline-block mr-6">
8
8
  <summary class="text-blue-700"><%= link_or_menu.title %></summary>
9
9
  <ul class="absolute bg-white shadow-md px-4 py-3 z-20">
10
10
  <% link_or_menu.links.each do |link| %>
11
- <li><%= render(link, default_options: { class: "" }) %></li>
11
+ <li><%= super_render(link, default_options: { class: "" }) %></li>
12
12
  <% end %>
13
13
  </ul>
14
14
  </details>
@@ -1,18 +1,22 @@
1
1
  <h1 class="text-lg mt-6">Sort</h1>
2
- <div data-controller="apply-template">
3
- <% sort.exprs.each.with_index do |expr, index| %>
4
- <%= form.fields_for("exprs[]", expr.with_index(index)) do |expr_fields| %>
5
- <%= render "sort_expression", expr_fields: expr_fields, sort: sort %>
2
+ <%= super_fields_for(query.namespace_for(sort), sort) do |form| %>
3
+ <div data-controller="apply-template">
4
+ <% sort.exprs.each.with_index do |expr, index| %>
5
+ <%= form.fields_for("exprs[]", expr.with_index(index)) do |expr_fields| %>
6
+ <%= super_render "sort_expression", expr_fields: expr_fields, sort: sort %>
7
+ <% end %>
6
8
  <% end %>
7
- <% end %>
8
9
 
9
- <%= form.fields_for("exprs[]", sort.new_expr.with_index("TEMPLATEINDEX")) do |expr_fields| %>
10
- <template data-apply-template-target="template">
11
- <%= render "sort_expression", expr_fields: expr_fields, sort: sort %>
12
- </template>
13
- <% end %>
10
+ <%= form.fields_for("exprs[]", sort.new_expr.with_index("TEMPLATEINDEX")) do |expr_fields| %>
11
+ <template data-apply-template-target="template">
12
+ <%= super_render "sort_expression", expr_fields: expr_fields, sort: sort %>
13
+ </template>
14
+ <% end %>
15
+
16
+ <a href="#" data-action="apply-template#call" class="block mt-2 text-sm">
17
+ Add
18
+ </a>
19
+ </div>
20
+ <% end %>
14
21
 
15
- <a href="#" data-action="apply-template#call" class="block mt-2 text-sm">
16
- Add
17
- </a>
18
- </div>
22
+ <%= yield if block_given? %>
@@ -19,7 +19,7 @@
19
19
  ) %>
20
20
  </div>
21
21
  <div class="flex-none pl-2">
22
- <a href="#" data-action="delete#call" class="block text-black hover:text-red-600 h-4 w-4"><%= render("super/feather/x") %></a>
22
+ <a href="#" data-action="delete#call" class="block text-black hover:text-red-600 h-4 w-4"><%= super_render("super/feather/x") %></a>
23
23
  </div>
24
24
  </div>
25
25
  </div>
@@ -1,5 +1 @@
1
- <% current = view_chain.chain.shift %>
2
- <% current = instance_variable_get(current) if current.kind_of?(Symbol) %>
3
- <%= render(current) do %>
4
- <%= render(view_chain) %>
5
- <% end %>
1
+ <%= view_chain.handle_super_render(self, local_assigns) %>
@@ -1,2 +1,2 @@
1
1
  <% raise Super::Error::NothingToRender, "edit" if @view.nil? %>
2
- <%= render(@view) %>
2
+ <%= super_render(@view) %>
@@ -1,2 +1,2 @@
1
1
  <% raise Super::Error::NothingToRender, "index" if @view.nil? %>
2
- <%= render(@view) %>
2
+ <%= super_render(@view) %>
@@ -1,2 +1,2 @@
1
1
  <% raise Super::Error::NothingToRender, "new" if @view.nil? %>
2
- <%= render(@view) %>
2
+ <%= super_render(@view) %>
@@ -1,2 +1,2 @@
1
1
  <% raise Super::Error::NothingToRender, "show" if @view.nil? %>
2
- <%= render(@view) %>
2
+ <%= super_render(@view) %>
@@ -17,3 +17,6 @@ en:
17
17
  layout:
18
18
  powered_by_html: "%{env} environment. Powered by Super %{version}. <a href='https://superadministration.github.io/v%{version}/'>Developer docs.</a>"
19
19
  mismatching_package_json_gemfile_versions: "The version of Super specified in your package.json file does not match the version specified in your Gemfile.lock."
20
+ destroy_error:
21
+ invalid_foreign_key: Couldn't delete record because other records still refer to this one
22
+ generic: Couldn't delete record