avo 2.8.0 → 2.9.1.pre2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of avo might be problematic. Click here for more details.

Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +2 -2
  3. data/README.md +11 -0
  4. data/app/assets/builds/action_cable.js +2 -0
  5. data/app/assets/builds/action_cable.js.map +7 -0
  6. data/app/assets/builds/application.js +2 -0
  7. data/app/assets/builds/application.js.map +7 -0
  8. data/app/assets/builds/avo.css +9028 -0
  9. data/app/assets/builds/avo.js +512 -0
  10. data/app/assets/builds/avo.js.map +7 -0
  11. data/app/assets/builds/avo_custom.js +6 -0
  12. data/app/assets/builds/avo_custom.js.map +7 -0
  13. data/app/assets/stylesheets/avo.css +4 -4
  14. data/app/assets/stylesheets/css/{components → fields}/code.css +0 -0
  15. data/app/assets/stylesheets/css/{components → fields}/progress.css +0 -0
  16. data/app/assets/stylesheets/css/{components → fields}/status.css +0 -0
  17. data/app/assets/stylesheets/css/fields/trix.css +17 -0
  18. data/app/components/avo/actions_component.html.erb +5 -13
  19. data/app/components/avo/actions_component.rb +39 -1
  20. data/app/components/avo/common_field_wrapper_component.html.erb +1 -1
  21. data/app/components/avo/fields/belongs_to_field/edit_component.rb +1 -1
  22. data/app/components/avo/fields/trix_field/edit_component.html.erb +1 -0
  23. data/app/components/avo/fields/trix_field/show_component.html.erb +1 -1
  24. data/app/components/avo/sidebar/item_switcher_component.html.erb +2 -2
  25. data/app/components/avo/views/resource_edit_component.html.erb +6 -4
  26. data/app/components/avo/views/resource_edit_component.rb +32 -4
  27. data/app/components/avo/views/resource_index_component.html.erb +1 -1
  28. data/app/components/avo/views/resource_show_component.html.erb +2 -2
  29. data/app/controllers/avo/base_controller.rb +11 -6
  30. data/app/helpers/avo/url_helpers.rb +8 -9
  31. data/app/javascript/js/controllers.js +0 -2
  32. data/app/views/avo/base/edit.html.erb +2 -1
  33. data/app/views/avo/base/new.html.erb +1 -1
  34. data/app/views/avo/partials/_custom_tools_alert.html.erb +21 -7
  35. data/app/views/avo/partials/_table_header.html.erb +9 -1
  36. data/bin/test +1 -0
  37. data/lib/avo/app.rb +18 -1
  38. data/lib/avo/base_action.rb +7 -2
  39. data/lib/avo/base_resource.rb +7 -2
  40. data/lib/avo/concerns/fetches_things.rb +19 -12
  41. data/lib/avo/concerns/has_model.rb +11 -0
  42. data/lib/avo/concerns/model_class_constantized.rb +23 -0
  43. data/lib/avo/dynamic_router.rb +1 -1
  44. data/lib/avo/engine.rb +1 -3
  45. data/lib/avo/fields/base_field.rb +1 -0
  46. data/lib/avo/fields/concerns/is_required.rb +17 -0
  47. data/lib/avo/hosts/view_record_host.rb +7 -0
  48. data/lib/avo/menu/base_item.rb +4 -0
  49. data/lib/avo/menu/dashboard.rb +5 -0
  50. data/lib/avo/menu/resource.rb +5 -0
  51. data/lib/avo/version.rb +1 -1
  52. data/lib/avo.rb +1 -0
  53. data/lib/generators/avo/install_generator.rb +1 -4
  54. data/public/avo-assets/avo.css +467 -1069
  55. data/public/avo-assets/avo.js +70 -70
  56. data/public/avo-assets/avo.js.map +3 -3
  57. metadata +21 -10
  58. data/app/components/avo/views/resource_new_component.html.erb +0 -60
  59. data/app/components/avo/views/resource_new_component.rb +0 -39
  60. data/app/javascript/js/controllers/custom/course_resource_controller.js +0 -102
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.0
4
+ version: 2.9.1.pre2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Marin
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-06-08 00:00:00.000000000 Z
12
+ date: 2022-06-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -248,14 +248,24 @@ files:
248
248
  - Gemfile.lock
249
249
  - README.md
250
250
  - Rakefile
251
+ - app/assets/builds/action_cable.js
252
+ - app/assets/builds/action_cable.js.map
253
+ - app/assets/builds/application.js
254
+ - app/assets/builds/application.js.map
255
+ - app/assets/builds/avo.css
256
+ - app/assets/builds/avo.js
257
+ - app/assets/builds/avo.js.map
258
+ - app/assets/builds/avo_custom.js
259
+ - app/assets/builds/avo_custom.js.map
251
260
  - app/assets/config/avo_manifest.js
252
261
  - app/assets/stylesheets/avo.css
253
262
  - app/assets/stylesheets/css/active-storage.css
254
263
  - app/assets/stylesheets/css/breadcrumbs.css
255
264
  - app/assets/stylesheets/css/buttons.css
256
- - app/assets/stylesheets/css/components/code.css
257
- - app/assets/stylesheets/css/components/progress.css
258
- - app/assets/stylesheets/css/components/status.css
265
+ - app/assets/stylesheets/css/fields/code.css
266
+ - app/assets/stylesheets/css/fields/progress.css
267
+ - app/assets/stylesheets/css/fields/status.css
268
+ - app/assets/stylesheets/css/fields/trix.css
259
269
  - app/assets/stylesheets/css/fonts.css
260
270
  - app/assets/stylesheets/css/loader.css
261
271
  - app/assets/stylesheets/css/pagination.css
@@ -1032,8 +1042,6 @@ files:
1032
1042
  - app/components/avo/views/resource_edit_component.rb
1033
1043
  - app/components/avo/views/resource_index_component.html.erb
1034
1044
  - app/components/avo/views/resource_index_component.rb
1035
- - app/components/avo/views/resource_new_component.html.erb
1036
- - app/components/avo/views/resource_new_component.rb
1037
1045
  - app/components/avo/views/resource_show_component.html.erb
1038
1046
  - app/components/avo/views/resource_show_component.rb
1039
1047
  - app/controllers/avo/actions_controller.rb
@@ -1063,7 +1071,6 @@ files:
1063
1071
  - app/javascript/js/controllers/base_controller.js
1064
1072
  - app/javascript/js/controllers/boolean_filter_controller.js
1065
1073
  - app/javascript/js/controllers/copy_to_clipboard_controller.js
1066
- - app/javascript/js/controllers/custom/course_resource_controller.js
1067
1074
  - app/javascript/js/controllers/dashboard_card_controller.js
1068
1075
  - app/javascript/js/controllers/fields/belongs_to_field_controller.js
1069
1076
  - app/javascript/js/controllers/fields/code_field_controller.js
@@ -1169,8 +1176,10 @@ files:
1169
1176
  - lib/avo/concerns/handles_field_args.rb
1170
1177
  - lib/avo/concerns/has_fields.rb
1171
1178
  - lib/avo/concerns/has_html_attributes.rb
1179
+ - lib/avo/concerns/has_model.rb
1172
1180
  - lib/avo/concerns/has_stimulus_controllers.rb
1173
1181
  - lib/avo/concerns/has_tools.rb
1182
+ - lib/avo/concerns/model_class_constantized.rb
1174
1183
  - lib/avo/configuration.rb
1175
1184
  - lib/avo/dashboards/base_dashboard.rb
1176
1185
  - lib/avo/dashboards/base_divider.rb
@@ -1186,6 +1195,7 @@ files:
1186
1195
  - lib/avo/fields/boolean_field.rb
1187
1196
  - lib/avo/fields/boolean_group_field.rb
1188
1197
  - lib/avo/fields/code_field.rb
1198
+ - lib/avo/fields/concerns/is_required.rb
1189
1199
  - lib/avo/fields/country_field.rb
1190
1200
  - lib/avo/fields/currency_field.rb
1191
1201
  - lib/avo/fields/date_field.rb
@@ -1231,6 +1241,7 @@ files:
1231
1241
  - lib/avo/hosts/dashboard_visibility.rb
1232
1242
  - lib/avo/hosts/ordering.rb
1233
1243
  - lib/avo/hosts/record_host.rb
1244
+ - lib/avo/hosts/view_record_host.rb
1234
1245
  - lib/avo/html/builder.rb
1235
1246
  - lib/avo/licensing/community_license.rb
1236
1247
  - lib/avo/licensing/h_q.rb
@@ -1348,9 +1359,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
1348
1359
  version: 2.4.0
1349
1360
  required_rubygems_version: !ruby/object:Gem::Requirement
1350
1361
  requirements:
1351
- - - ">="
1362
+ - - ">"
1352
1363
  - !ruby/object:Gem::Version
1353
- version: '0'
1364
+ version: 1.3.1
1354
1365
  requirements: []
1355
1366
  rubygems_version: 3.3.3
1356
1367
  signing_key:
@@ -1,60 +0,0 @@
1
- <%= content_tag :div,
2
- class: "space-y-12",
3
- data: {
4
- 'model-id': @resource.model.id,
5
- **@resource.stimulus_data_attributes
6
- } do %>
7
- <% @resource.panels.each do |resource_panel| %>
8
- <%= form_with model: @resource.model,
9
- scope: @resource.form_scope,
10
- url: helpers.resources_path(
11
- resource: @resource,
12
- via_relation_class: params[:via_relation_class],
13
- via_relation: params[:via_relation],
14
- via_resource_id: params[:via_resource_id]
15
- ),
16
- local: true,
17
- multipart: true do |form| %>
18
- <%= render Avo::ReferrerParamsComponent.new back_path: back_path %>
19
- <%= render Avo::PanelComponent.new(title: resource_panel[:name], description: @resource.resource_description, display_breadcrumbs: true) do |c| %>
20
- <% c.tools do %>
21
- <div class="flex justify-end space-x-2">
22
- <%= a_link back_path,
23
- style: :text,
24
- icon: 'arrow-left' do %>
25
- <%= t('avo.cancel').capitalize %>
26
- <% end %>
27
- <% if can_see_the_save_button? %>
28
- <%= a_button color: :primary,
29
- style: :primary,
30
- loading: true,
31
- type: :submit,
32
- icon: 'save' do %>
33
- <%= t('avo.save').capitalize %>
34
- <% end %>
35
- <% end %>
36
- </div>
37
- <% end %>
38
- <% if Avo.configuration.buttons_on_form_footers %>
39
- <% c.footer_tools do %>
40
- <%= a_link back_path, icon: 'arrow-left' do %>
41
- <%= t('avo.cancel').capitalize %>
42
- <% end %>
43
- <% if can_see_the_save_button? %>
44
- <%= a_button color: :green, loading: true, type: :submit, icon: 'save' do %>
45
- <%= t('avo.save').capitalize %>
46
- <% end %>
47
- <% end %>
48
- <% end %>
49
- <% end %>
50
- <% c.body do %>
51
- <div class="divide-y">
52
- <% @resource.get_fields.each_with_index do |field, index| %>
53
- <%= render field.component_for_view(:edit).new(field: field, resource: @resource, index: index, form: form) unless field.computed %>
54
- <% end %>
55
- </div>
56
- <% end %>
57
- <% end %>
58
- <% end %>
59
- <% end %>
60
- <% end %>
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Avo::Views::ResourceNewComponent < Avo::ResourceComponent
4
- include Avo::ResourcesHelper
5
- include Avo::ApplicationHelper
6
-
7
- def initialize(
8
- resource: nil,
9
- model: nil
10
- )
11
- @resource = resource
12
- @model = model
13
- @view = :new
14
- end
15
-
16
- def back_path
17
- if via_resource?
18
- helpers.resource_path(model: params[:via_relation_class].safe_constantize, resource: relation_resource, resource_id: params[:via_resource_id])
19
- else
20
- helpers.resources_path(resource: @resource)
21
- end
22
- end
23
-
24
- # The create button is dependent on the new? policy method.
25
- # The create? should be called only when the user clicks the Save button so the developers gets access to the params from the form.
26
- def can_see_the_save_button?
27
- @resource.authorization.authorize_action :new, raise_exception: false
28
- end
29
-
30
- private
31
-
32
- def via_resource?
33
- params[:via_relation_class].present? && params[:via_resource_id].present?
34
- end
35
-
36
- def relation_resource
37
- ::Avo::App.get_resource_by_model_name params[:via_relation_class].safe_constantize
38
- end
39
- end
@@ -1,102 +0,0 @@
1
- import { Controller } from '@hotwired/stimulus'
2
-
3
- const LOADER_CLASSES = 'absolute bg-gray-100 opacity-10 w-full h-full'
4
-
5
- export default class extends Controller {
6
- static targets = ['countrySelectInput', 'citySelectInput', 'citySelectWrapper'];
7
-
8
- static values = {
9
- view: String,
10
- }
11
-
12
- // Te fields initial value
13
- static initialValue
14
-
15
- get placeholder() {
16
- return this.citySelectInputTarget.ariaPlaceholder
17
- }
18
-
19
- set loading(isLoading) {
20
- if (isLoading) {
21
- // create a loader overlay
22
- const loadingDiv = document.createElement('div')
23
- loadingDiv.className = LOADER_CLASSES
24
- loadingDiv.dataset.target = 'city-loader'
25
-
26
- // add the loader overlay
27
- this.citySelectWrapperTarget.prepend(loadingDiv)
28
- this.citySelectWrapperTarget.classList.add('opacity-50')
29
- } else {
30
- // remove the loader overlay
31
- this.citySelectWrapperTarget.querySelector('[data-target="city-loader"]').remove()
32
- this.citySelectWrapperTarget.classList.remove('opacity-50')
33
- }
34
- }
35
-
36
- async connect() {
37
- // Add the controller functionality only on forms
38
- if (['edit', 'new'].includes(this.viewValue)) {
39
- this.captureTheInitialValue()
40
-
41
- // Trigger the change on load
42
- await this.onCountryChange()
43
- }
44
- }
45
-
46
- // Read the country select.
47
- // If there's any value selected show the cities and prefill them.
48
- async onCountryChange() {
49
- if (this.hasCountrySelectInputTarget && this.countrySelectInputTarget) {
50
- // Get the country
51
- const country = this.countrySelectInputTarget.value
52
- // Dynamically fetch the cities for this country
53
- const cities = await this.fetchCitiesForCountry(country)
54
-
55
- // Clear the select of options
56
- Object.keys(this.citySelectInputTarget.options).forEach(() => {
57
- this.citySelectInputTarget.options.remove(0)
58
- })
59
-
60
- // Add blank option
61
- this.citySelectInputTarget.add(new Option(this.placeholder))
62
-
63
- // Add the new cities
64
- cities.forEach((city) => {
65
- this.citySelectInputTarget.add(new Option(city, city))
66
- })
67
-
68
- // Check if the initial value is present in the cities array and select it.
69
- // If not, select the first item
70
- const currentOptions = Array.from(this.citySelectInputTarget.options).map((item) => item.value)
71
- if (currentOptions.includes(this.initialValue)) {
72
- this.citySelectInputTarget.value = this.initialValue
73
- } else {
74
- // Select the first item
75
- this.citySelectInputTarget.value = this.citySelectInputTarget.options[0].value
76
- }
77
- }
78
- }
79
-
80
- // Private
81
-
82
- captureTheInitialValue() {
83
- this.initialValue = this.citySelectInputTarget.value
84
- }
85
-
86
- async fetchCitiesForCountry(country) {
87
- if (!country) {
88
- return []
89
- }
90
-
91
- this.loading = true
92
-
93
- const response = await fetch(
94
- `${window.Avo.configuration.root_path}/resources/courses/cities?country=${country}`,
95
- )
96
- const data = await response.json()
97
-
98
- this.loading = false
99
-
100
- return data
101
- }
102
- }