avo 1.19.1.pre.1 → 1.19.1.pre.5
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.
- checksums.yaml +4 -4
- data/Gemfile +3 -7
- data/Gemfile.lock +31 -51
- data/README.md +3 -0
- data/app/assets/builds/avo.css +8590 -0
- data/app/assets/builds/avo.js +87755 -0
- data/app/assets/builds/avo.js.map +7 -0
- data/app/assets/config/avo_manifest.js +2 -1
- data/app/{packs/images → assets/images/avo}/logo.png +0 -0
- data/app/{packs/entrypoints/application.css → assets/stylesheets/avo.css} +31 -24
- data/app/{packs/stylesheets → assets/stylesheets/css}/active-storage.css +0 -0
- data/app/{packs/stylesheets → assets/stylesheets/css}/alerts.css +0 -0
- data/app/{packs/stylesheets → assets/stylesheets/css}/breadcrumbs.css +0 -0
- data/app/{packs/stylesheets → assets/stylesheets/css}/components/code.css +0 -0
- data/app/{packs/stylesheets → assets/stylesheets/css}/components/progress.css +0 -0
- data/app/{packs/stylesheets → assets/stylesheets/css}/components/status.css +0 -0
- data/app/assets/stylesheets/css/fonts.css +26 -0
- data/app/{packs/stylesheets → assets/stylesheets/css}/loader.css +0 -0
- data/app/{packs/stylesheets → assets/stylesheets/css}/pagination.css +0 -0
- data/app/{packs/stylesheets → assets/stylesheets/css}/search.css +1 -1
- data/app/{packs/stylesheets → assets/stylesheets/css}/spinner.css +0 -0
- data/app/{packs/stylesheets → assets/stylesheets/css}/tailwindcss/base.css +0 -0
- data/app/{packs/stylesheets → assets/stylesheets/css}/tailwindcss/components.css +0 -0
- data/app/{packs/stylesheets → assets/stylesheets/css}/tailwindcss/utilities.css +0 -0
- data/app/{packs/stylesheets → assets/stylesheets/css}/tooltips.css +0 -0
- data/app/{packs/stylesheets → assets/stylesheets/css}/typography.css +0 -0
- data/app/{packs → assets}/svgs/arrow-circle-right.svg +0 -0
- data/app/{packs → assets}/svgs/arrow-left.svg +0 -0
- data/app/{packs → assets}/svgs/avocado.svg +0 -0
- data/app/{packs → assets}/svgs/badge-check-sm.svg +0 -0
- data/app/{packs → assets}/svgs/check-circle-sm.svg +0 -0
- data/app/{packs → assets}/svgs/check-circle.svg +0 -0
- data/app/{packs → assets}/svgs/chevron-down.svg +0 -0
- data/app/{packs → assets}/svgs/chevron-right.svg +0 -0
- data/app/{packs → assets}/svgs/chevron-up.svg +0 -0
- data/app/{packs → assets}/svgs/code.svg +0 -0
- data/app/{packs → assets}/svgs/color-swatch.svg +0 -0
- data/app/{packs → assets}/svgs/document-text.svg +0 -0
- data/app/{packs → assets}/svgs/download.svg +0 -0
- data/app/{packs → assets}/svgs/edit.svg +0 -0
- data/app/{packs → assets}/svgs/exclamation-circle-sm.svg +0 -0
- data/app/{packs → assets}/svgs/exclamation-sm.svg +0 -0
- data/app/{packs → assets}/svgs/exclamation.svg +0 -0
- data/app/{packs → assets}/svgs/eye.svg +0 -0
- data/app/{packs → assets}/svgs/filter.svg +0 -0
- data/app/{packs → assets}/svgs/fire.svg +0 -0
- data/app/{packs → assets}/svgs/game-board.svg +0 -0
- data/app/{packs → assets}/svgs/globe.svg +0 -0
- data/app/{packs → assets}/svgs/information-circle-sm.svg +0 -0
- data/app/{packs → assets}/svgs/information-circle.svg +0 -0
- data/app/{packs → assets}/svgs/library.svg +0 -0
- data/app/{packs → assets}/svgs/photograph.svg +0 -0
- data/app/{packs → assets}/svgs/play.svg +0 -0
- data/app/{packs → assets}/svgs/plus-circle.svg +0 -0
- data/app/{packs → assets}/svgs/plus.svg +0 -0
- data/app/{packs → assets}/svgs/question-mark-circle.svg +0 -0
- data/app/{packs → assets}/svgs/save.svg +0 -0
- data/app/{packs → assets}/svgs/selector.svg +0 -0
- data/app/{packs → assets}/svgs/sort-ascending.svg +0 -0
- data/app/{packs → assets}/svgs/sort-descending.svg +0 -0
- data/app/{packs → assets}/svgs/switch-horizontal.svg +0 -0
- data/app/{packs → assets}/svgs/thumbs-down.svg +0 -0
- data/app/{packs → assets}/svgs/thumbs-up.svg +0 -0
- data/app/{packs → assets}/svgs/times.svg +0 -0
- data/app/{packs → assets}/svgs/trash-sm.svg +0 -0
- data/app/{packs → assets}/svgs/trash.svg +0 -0
- data/app/{packs → assets}/svgs/view-grid-add.svg +0 -0
- data/app/{packs → assets}/svgs/view-grid.svg +0 -0
- data/app/{packs → assets}/svgs/view-list.svg +0 -0
- data/app/{packs → assets}/svgs/x-circle-sm.svg +0 -0
- data/app/{packs → assets}/svgs/x-circle.svg +0 -0
- data/app/components/avo/edit/field_wrapper_component.html.erb +1 -1
- data/app/components/avo/fields/common/files_list_viewer_component.html.erb +1 -1
- data/app/components/avo/fields/common/heading_component.html.erb +1 -1
- data/app/components/avo/index/field_wrapper_component.html.erb +1 -1
- data/app/components/avo/index/table_row_component.html.erb +1 -1
- data/app/components/avo/resource_component.rb +0 -4
- data/app/components/avo/show/field_wrapper_component.html.erb +1 -1
- data/app/components/avo/views/resource_edit_component.html.erb +1 -1
- data/app/components/avo/views/resource_edit_component.rb +6 -0
- data/app/components/avo/views/resource_index_component.html.erb +1 -1
- data/app/components/avo/views/resource_index_component.rb +21 -9
- data/app/components/avo/views/resource_new_component.html.erb +6 -4
- data/app/components/avo/views/resource_new_component.rb +6 -0
- data/app/components/avo/views/resource_show_component.html.erb +2 -2
- data/app/components/avo/views/resource_show_component.rb +9 -1
- data/app/controllers/avo/application_controller.rb +15 -0
- data/app/controllers/avo/base_controller.rb +40 -12
- data/app/helpers/avo/application_helper.rb +3 -14
- data/app/{packs/entrypoints/application.js → javascript/avo.js} +15 -18
- data/{public/avo-packs/media/images/dadf2db36589607d107d.png → app/javascript/images/logo.png} +0 -0
- data/app/{packs → javascript}/js/active-storage.js +0 -0
- data/app/javascript/js/application.js +9 -0
- data/app/{packs → javascript}/js/controllers/action_controller.js +1 -1
- data/app/{packs → javascript}/js/controllers/actions_picker_controller.js +0 -0
- data/app/{packs → javascript}/js/controllers/alerts_controller.js +0 -0
- data/app/{packs → javascript}/js/controllers/attachments_controller.js +0 -0
- data/app/{packs → javascript}/js/controllers/boolean_filter_controller.js +0 -0
- data/app/{packs → javascript}/js/controllers/fields/belongs_to_field_controller.js +0 -0
- data/app/{packs → javascript}/js/controllers/fields/code_field_controller.js +2 -1
- data/app/{packs → javascript}/js/controllers/fields/date_field_controller.js +1 -1
- data/app/{packs → javascript}/js/controllers/fields/key_value_controller.js +1 -1
- data/app/{packs → javascript}/js/controllers/fields/simple_mde_controller.js +0 -0
- data/app/{packs → javascript}/js/controllers/fields/trix_field_controller.js +1 -1
- data/app/{packs → javascript}/js/controllers/filter_controller.js +0 -0
- data/app/{packs → javascript}/js/controllers/hidden_input_controller.js +0 -0
- data/app/{packs → javascript}/js/controllers/item_select_all_controller.js +0 -0
- data/app/{packs → javascript}/js/controllers/item_selector_controller.js +0 -0
- data/app/{packs → javascript}/js/controllers/loading_button_controller.js +0 -0
- data/app/{packs → javascript}/js/controllers/modal_controller.js +0 -0
- data/app/{packs → javascript}/js/controllers/multiple_select_filter_controller.js +0 -0
- data/app/{packs → javascript}/js/controllers/per_page_controller.js +0 -0
- data/app/{packs → javascript}/js/controllers/search_controller.js +1 -1
- data/app/{packs → javascript}/js/controllers/select_filter_controller.js +0 -0
- data/app/{packs → javascript}/js/controllers/text_filter_controller.js +0 -0
- data/app/{packs → javascript}/js/controllers/tippy_controller.js +0 -0
- data/app/{packs → javascript}/js/controllers/toggle_panel_controller.js +0 -0
- data/app/javascript/js/controllers.js +53 -0
- data/app/{packs → javascript}/js/helpers/cast_boolean.js +0 -0
- data/app/{packs → javascript}/js/helpers/debounce_promise.js +0 -0
- data/app/{packs → javascript}/js/toastr.js +0 -0
- data/app/views/avo/actions/show.html.erb +1 -1
- data/app/views/avo/base/_actions.html.erb +1 -1
- data/app/views/avo/base/_filters.html.erb +3 -3
- data/app/views/avo/home/_actions.html.erb +1 -1
- data/app/views/avo/home/_filters.html.erb +1 -1
- data/app/views/avo/home/_resources.html.erb +2 -2
- data/app/views/avo/partials/_footer.html.erb +1 -1
- data/app/views/avo/partials/_global_search.html.erb +4 -1
- data/app/views/avo/partials/_logo.html.erb +1 -1
- data/app/views/avo/partials/_paginator.html.erb +3 -3
- data/app/views/avo/partials/_table_header.html.erb +2 -2
- data/app/views/layouts/avo/application.html.erb +9 -4
- data/avo.gemspec +1 -2
- data/bin/dev +9 -0
- data/bin/test +2 -1
- data/lib/avo/base_resource.rb +4 -3
- data/lib/avo/configuration.rb +6 -0
- data/lib/avo/engine.rb +2 -16
- data/lib/avo/version.rb +1 -1
- data/lib/avo.rb +0 -18
- data/lib/generators/avo/filter_generator.rb +2 -0
- data/lib/generators/avo/templates/filters/text_filter.tt +8 -0
- data/public/avo-assets/avo.css +8590 -0
- data/public/avo-assets/avo.js +87755 -0
- data/public/avo-assets/avo.js.map +7 -0
- data/{app/packs → public/avo-assets}/fonts/nunito-v16-latin-700.eot +0 -0
- data/{app/packs → public/avo-assets}/fonts/nunito-v16-latin-700.svg +0 -0
- data/{app/packs → public/avo-assets}/fonts/nunito-v16-latin-700.ttf +0 -0
- data/{app/packs → public/avo-assets}/fonts/nunito-v16-latin-700.woff +0 -0
- data/{app/packs → public/avo-assets}/fonts/nunito-v16-latin-700.woff2 +0 -0
- data/{app/packs → public/avo-assets}/fonts/nunito-v16-latin-regular.eot +0 -0
- data/{app/packs → public/avo-assets}/fonts/nunito-v16-latin-regular.svg +0 -0
- data/{app/packs → public/avo-assets}/fonts/nunito-v16-latin-regular.ttf +0 -0
- data/{app/packs → public/avo-assets}/fonts/nunito-v16-latin-regular.woff +0 -0
- data/{app/packs → public/avo-assets}/fonts/nunito-v16-latin-regular.woff2 +0 -0
- metadata +116 -168
- data/app/assets/stylesheets/avo/application.css +0 -15
- data/app/packs/importmap.json.erb +0 -5
- data/app/packs/stylesheets/fonts.css +0 -26
- data/bin/webpack +0 -20
- data/bin/webpack-dev-server +0 -18
- data/config/webpack/aliases.js +0 -10
- data/config/webpack/base.js +0 -14
- data/config/webpack/development.js +0 -5
- data/config/webpack/production.js +0 -5
- data/config/webpack/test.js +0 -5
- data/config/webpacker.yml +0 -79
- data/public/avo-packs/css/application-c3b50b28.css +0 -6329
- data/public/avo-packs/css/application-c3b50b28.css.br +0 -0
- data/public/avo-packs/css/application-c3b50b28.css.gz +0 -0
- data/public/avo-packs/css/application-c3b50b28.css.map +0 -1
- data/public/avo-packs/css/application-c3b50b28.css.map.br +0 -0
- data/public/avo-packs/css/application-c3b50b28.css.map.gz +0 -0
- data/public/avo-packs/js/actioncable-7119dbc1a908641fb263.chunk.js +0 -2
- data/public/avo-packs/js/actioncable-7119dbc1a908641fb263.chunk.js.br +0 -0
- data/public/avo-packs/js/actioncable-7119dbc1a908641fb263.chunk.js.gz +0 -0
- data/public/avo-packs/js/actioncable-7119dbc1a908641fb263.chunk.js.map +0 -1
- data/public/avo-packs/js/actioncable-7119dbc1a908641fb263.chunk.js.map.br +0 -0
- data/public/avo-packs/js/actioncable-7119dbc1a908641fb263.chunk.js.map.gz +0 -0
- data/public/avo-packs/js/application-6fc968cfa52976c4582b.js +0 -26
- data/public/avo-packs/js/application-6fc968cfa52976c4582b.js.LICENSE.txt +0 -77
- data/public/avo-packs/js/application-6fc968cfa52976c4582b.js.br +0 -0
- data/public/avo-packs/js/application-6fc968cfa52976c4582b.js.gz +0 -0
- data/public/avo-packs/js/application-6fc968cfa52976c4582b.js.map +0 -1
- data/public/avo-packs/js/application-6fc968cfa52976c4582b.js.map.br +0 -0
- data/public/avo-packs/js/application-6fc968cfa52976c4582b.js.map.gz +0 -0
- data/public/avo-packs/manifest.json +0 -52
- data/public/avo-packs/media/images/13ae283c0d7cc04efe7e.svg +0 -380
- data/public/avo-packs/media/images/13ae283c0d7cc04efe7e.svg.br +0 -0
- data/public/avo-packs/media/images/13ae283c0d7cc04efe7e.svg.gz +0 -0
- data/public/avo-packs/media/images/195026a50008c53526ef.svg +0 -388
- data/public/avo-packs/media/images/195026a50008c53526ef.svg.br +0 -0
- data/public/avo-packs/media/images/195026a50008c53526ef.svg.gz +0 -0
- data/public/avo-packs/media/images/1f30e08faa7c60d1f7ac.woff +0 -0
- data/public/avo-packs/media/images/1fd17dabf6b7d2b15348.ttf +0 -0
- data/public/avo-packs/media/images/1fd17dabf6b7d2b15348.ttf.br +0 -0
- data/public/avo-packs/media/images/1fd17dabf6b7d2b15348.ttf.gz +0 -0
- data/public/avo-packs/media/images/39a18f443d434999b89b.woff2 +0 -0
- data/public/avo-packs/media/images/4ad349571e28bb59c5a5.woff2 +0 -0
- data/public/avo-packs/media/images/57a5470848663767abbf.eot +0 -0
- data/public/avo-packs/media/images/b2e4cf0fab6c8ca66b7f.ttf +0 -0
- data/public/avo-packs/media/images/b2e4cf0fab6c8ca66b7f.ttf.br +0 -0
- data/public/avo-packs/media/images/b2e4cf0fab6c8ca66b7f.ttf.gz +0 -0
- data/public/avo-packs/media/images/b78d61ab7e046de8c156.eot +0 -0
- data/public/avo-packs/media/images/c9ab29becb76ddab01d0.woff +0 -0
@@ -1 +1,2 @@
|
|
1
|
-
//= link_directory ../
|
1
|
+
//= link_directory ../images/avo
|
2
|
+
//= link_tree ../builds
|
File without changes
|
@@ -6,25 +6,26 @@
|
|
6
6
|
@import './../../../node_modules/flatpickr/dist/flatpickr.css';
|
7
7
|
@import './../../../node_modules/@algolia/autocomplete-theme-classic/dist/theme.css';
|
8
8
|
|
9
|
-
@import '
|
10
|
-
|
11
|
-
@import '
|
12
|
-
@import '
|
13
|
-
@import '
|
14
|
-
@import '
|
15
|
-
@import '
|
16
|
-
@import '
|
17
|
-
@import '
|
18
|
-
@import '
|
19
|
-
@import '
|
20
|
-
@import '
|
21
|
-
|
22
|
-
@import '
|
23
|
-
@import '
|
24
|
-
@import '
|
25
|
-
|
26
|
-
|
27
|
-
|
9
|
+
@import 'tailwindcss/base';
|
10
|
+
|
11
|
+
@import './css/fonts.css';
|
12
|
+
@import './css/typography.css';
|
13
|
+
@import './css/tooltips.css';
|
14
|
+
@import './css/alerts.css';
|
15
|
+
@import './css/loader.css';
|
16
|
+
@import './css/pagination.css';
|
17
|
+
@import './css/breadcrumbs.css';
|
18
|
+
@import './css/search.css';
|
19
|
+
@import './css/active-storage.css';
|
20
|
+
@import './css/spinner.css';
|
21
|
+
|
22
|
+
@import './css/components/status.css';
|
23
|
+
@import './css/components/code.css';
|
24
|
+
@import './css/components/progress.css';
|
25
|
+
|
26
|
+
@import 'tailwindcss/components';
|
27
|
+
|
28
|
+
@import 'tailwindcss/utilities';
|
28
29
|
|
29
30
|
html,
|
30
31
|
body {
|
@@ -67,13 +68,19 @@ body {
|
|
67
68
|
@apply opacity-0 translate-y-1;
|
68
69
|
}
|
69
70
|
|
70
|
-
.application-sidebar
|
71
|
-
|
72
|
-
|
73
|
-
@apply bg-gray-200;
|
74
|
-
}
|
71
|
+
.application-sidebar .active:hover,
|
72
|
+
.application-sidebar .active {
|
73
|
+
@apply bg-gray-200;
|
75
74
|
}
|
76
75
|
|
77
76
|
.turbo-progress-bar {
|
78
77
|
@apply bg-green-500;
|
79
78
|
}
|
79
|
+
|
80
|
+
body.os-mac .mac\:hidden {
|
81
|
+
display: none;
|
82
|
+
}
|
83
|
+
|
84
|
+
body.os-pc .pc\:hidden {
|
85
|
+
display: none;
|
86
|
+
}
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,26 @@
|
|
1
|
+
/* nunito-regular - latin */
|
2
|
+
@font-face {
|
3
|
+
font-family: 'Nunito';
|
4
|
+
font-style: normal;
|
5
|
+
font-weight: 400;
|
6
|
+
src: url('/avo-assets/fonts/nunito-v16-latin-regular.eot'); /* IE9 Compat Modes */
|
7
|
+
src: local(''),
|
8
|
+
url('/avo-assets/fonts/nunito-v16-latin-regular.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
|
9
|
+
url('/avo-assets/fonts/nunito-v16-latin-regular.woff2') format('woff2'), /* Super Modern Browsers */
|
10
|
+
url('/avo-assets/fonts/nunito-v16-latin-regular.woff') format('woff'), /* Modern Browsers */
|
11
|
+
url('/avo-assets/fonts/nunito-v16-latin-regular.ttf') format('truetype'), /* Safari, Android, iOS */
|
12
|
+
url('/avo-assets/fonts/nunito-v16-latin-regular.svg#Nunito') format('svg'); /* Legacy iOS */
|
13
|
+
}
|
14
|
+
/* nunito-700 - latin */
|
15
|
+
@font-face {
|
16
|
+
font-family: 'Nunito';
|
17
|
+
font-style: normal;
|
18
|
+
font-weight: 700;
|
19
|
+
src: url('/avo-assets/fonts/nunito-v16-latin-700.eot'); /* IE9 Compat Modes */
|
20
|
+
src: local(''),
|
21
|
+
url('/avo-assets/fonts/nunito-v16-latin-700.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
|
22
|
+
url('/avo-assets/fonts/nunito-v16-latin-700.woff2') format('woff2'), /* Super Modern Browsers */
|
23
|
+
url('/avo-assets/fonts/nunito-v16-latin-700.woff') format('woff'), /* Modern Browsers */
|
24
|
+
url('/avo-assets/fonts/nunito-v16-latin-700.ttf') format('truetype'), /* Safari, Android, iOS */
|
25
|
+
url('/avo-assets/fonts/nunito-v16-latin-700.svg#Nunito') format('svg'); /* Legacy iOS */
|
26
|
+
}
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<div class="flex items-center py-0 leading-tight <%= @classes %> min-h-16" data-field-id="<%= @field.id %>" data-field-type="<%= @field.type %>">
|
2
|
-
<div class="h-16 flex self-start items-center text-
|
2
|
+
<div class="h-16 flex self-start items-center text-slate-800">
|
3
3
|
<div class="<% if @displayed_in_modal %> md:w-48 <% else %> md:w-64 <% end %> w-48 px-8 flex" data-slot="label">
|
4
4
|
<%= @form.label @field.id, label %> <% if @field.required %> <span class="text-red-600">*</span> <% end %>
|
5
5
|
</div>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<div class="relative p-3 bg-
|
1
|
+
<div class="relative p-3 bg-slate-200 grid grid-cols-3 xl:grid-cols-4 gap-3 rounded-xl">
|
2
2
|
<% @field.value.attachments.each do |file| %>
|
3
3
|
<%= render Avo::Fields::Common::MultipleFileViewerComponent.new id: @field.id, file: file, is_image: @field.is_image, button_size: :xs, resource: @resource %>
|
4
4
|
<% end %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<div class="flex items-start py-1 leading-tight border-t bg-
|
1
|
+
<div class="flex items-start py-1 leading-tight border-t bg-slate-600 text-white text-xs">
|
2
2
|
<div class="p-3 pl-6 h-full w-full">
|
3
3
|
<% if @value.present? %>
|
4
4
|
<% if @as_html %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<td class="px-4 py-2 leading-tight whitespace-nowrap h-12 text-
|
1
|
+
<td class="px-4 py-2 leading-tight whitespace-nowrap h-12 text-slate-800 <%= @classes %>" data-field-id="<%= @field.id %>" data-field-type="<%= @field.type %>">
|
2
2
|
<% if @field.value.blank? && @dash_if_blank %>
|
3
3
|
—
|
4
4
|
<% else %>
|
@@ -25,10 +25,6 @@ class Avo::ResourceComponent < ViewComponent::Base
|
|
25
25
|
|
26
26
|
private
|
27
27
|
|
28
|
-
def simple_relation?
|
29
|
-
@reflection.is_a? ::ActiveRecord::Reflection::HasManyReflection
|
30
|
-
end
|
31
|
-
|
32
28
|
def relation_resource
|
33
29
|
::Avo::App.get_resource_by_model_name params[:via_resource_class].safe_constantize
|
34
30
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<div class="flex items-start leading-tight <%= @classes %> min-h-16" data-field-id="<%= @field.id %>" data-field-type="<%= @field.type %>">
|
2
|
-
<div class="h-16 flex self-start items-center text-
|
2
|
+
<div class="h-16 flex self-start items-center text-slate-800">
|
3
3
|
<div class="w-48 md:w-64 px-8" data-slot="label">
|
4
4
|
<%= @field.name %> <% if @field.required %> <span class="text-red-600">*</span> <% end %>
|
5
5
|
</div>
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<%= helpers.svg 'arrow-left' %> <%= t('avo.cancel').capitalize %>
|
11
11
|
<% end %>
|
12
12
|
|
13
|
-
<% if
|
13
|
+
<% if can_see_the_save_button? %>
|
14
14
|
<%= a_button color: 'green', variant: 'outlined', spinner: true, type: :submit do %>
|
15
15
|
<%= helpers.svg 'save' %> <%= t('avo.save').capitalize %>
|
16
16
|
<% end %>
|
@@ -16,6 +16,12 @@ class Avo::Views::ResourceEditComponent < Avo::ResourceComponent
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
+
# The save button is dependent on the edit? policy method.
|
20
|
+
# The update? method should be called only when the user clicks the Save button so the developer gets access to the params from the form.
|
21
|
+
def can_see_the_save_button?
|
22
|
+
@resource.authorization.authorize_action :edit, raise_exception: false
|
23
|
+
end
|
24
|
+
|
19
25
|
private
|
20
26
|
|
21
27
|
def via_resource?
|
@@ -44,8 +44,10 @@ class Avo::Views::ResourceIndexComponent < Avo::ResourceComponent
|
|
44
44
|
@index_params[:available_view_types]
|
45
45
|
end
|
46
46
|
|
47
|
-
|
48
|
-
|
47
|
+
# The Create button is dependent on the new? policy method.
|
48
|
+
# The create? should be called only when the user clicks the Save button so the developers gets access to the params from the form.
|
49
|
+
def can_see_the_create_button?
|
50
|
+
@resource.authorization.authorize_action(:new, raise_exception: false) && !has_reflection_and_is_read_only
|
49
51
|
end
|
50
52
|
|
51
53
|
def can_attach?
|
@@ -58,7 +60,7 @@ class Avo::Views::ResourceIndexComponent < Avo::ResourceComponent
|
|
58
60
|
def has_reflection_and_is_read_only
|
59
61
|
if @reflection.present? && @reflection.active_record.name && @reflection.name
|
60
62
|
fields = ::Avo::App.get_resource_by_model_name(@reflection.active_record.name).get_field_definitions
|
61
|
-
filtered_fields = fields.filter{ |f| f.id == @reflection.name}
|
63
|
+
filtered_fields = fields.filter { |f| f.id == @reflection.name }
|
62
64
|
else
|
63
65
|
return false
|
64
66
|
end
|
@@ -75,10 +77,22 @@ class Avo::Views::ResourceIndexComponent < Avo::ResourceComponent
|
|
75
77
|
|
76
78
|
if @reflection.present?
|
77
79
|
args = {
|
78
|
-
via_relation_class:
|
79
|
-
via_resource_id: @parent_model.id
|
80
|
+
via_relation_class: reflection_model_class,
|
81
|
+
via_resource_id: @parent_model.id,
|
80
82
|
}
|
81
83
|
|
84
|
+
if @reflection.is_a? ActiveRecord::Reflection::ThroughReflection
|
85
|
+
args[:via_relation] = params[:resource_name]
|
86
|
+
end
|
87
|
+
|
88
|
+
if @reflection.is_a? ActiveRecord::Reflection::HasManyReflection
|
89
|
+
args[:via_relation] = @reflection.name
|
90
|
+
end
|
91
|
+
|
92
|
+
if @reflection.parent_reflection.present? && @reflection.parent_reflection.inverse_of.present?
|
93
|
+
args[:via_relation] = @reflection.parent_reflection.inverse_of.name
|
94
|
+
end
|
95
|
+
|
82
96
|
if @reflection.inverse_of.present?
|
83
97
|
args[:via_relation] = @reflection.inverse_of.name
|
84
98
|
end
|
@@ -101,9 +115,7 @@ class Avo::Views::ResourceIndexComponent < Avo::ResourceComponent
|
|
101
115
|
|
102
116
|
private
|
103
117
|
|
104
|
-
def
|
105
|
-
|
106
|
-
|
107
|
-
true
|
118
|
+
def reflection_model_class
|
119
|
+
@reflection.active_record.to_s
|
108
120
|
end
|
109
121
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<div>
|
2
2
|
<% @resource.panels.each do |resource_panel| %>
|
3
|
-
<%= form_with model: @resource.model, url: helpers.resources_path(resource: @resource, via_relation_class: params[:via_relation_class], via_resource_id: params[:via_resource_id]), local: true, multipart: true do |form| %>
|
3
|
+
<%= form_with model: @resource.model, url: helpers.resources_path(resource: @resource, via_relation_class: params[:via_relation_class], via_relation: params[:via_relation], via_resource_id: params[:via_resource_id]), local: true, multipart: true do |form| %>
|
4
4
|
<%= render Avo::PanelComponent.new(title: resource_panel[:name], display_breadcrumbs: true) do |c| %>
|
5
5
|
<% c.tools do %>
|
6
6
|
<div class="flex justify-end space-x-2">
|
@@ -8,9 +8,11 @@
|
|
8
8
|
<%= svg 'arrow-left' %> <%= t('avo.cancel').capitalize %>
|
9
9
|
<% end %>
|
10
10
|
|
11
|
-
|
12
|
-
<%=
|
13
|
-
|
11
|
+
<% if can_see_the_save_button? %>
|
12
|
+
<%= a_button color: 'green', spinner: true, type: :submit do %>
|
13
|
+
<%= svg 'save' %> <%= t('avo.save').capitalize %>
|
14
|
+
<% end %>
|
15
|
+
<% end %>
|
14
16
|
</div>
|
15
17
|
<% end %>
|
16
18
|
|
@@ -20,6 +20,12 @@ class Avo::Views::ResourceNewComponent < ViewComponent::Base
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
# The create button is dependent on the new? policy method.
|
24
|
+
# The create? should be called only when the user clicks the Save button so the developers gets access to the params from the form.
|
25
|
+
def can_see_the_save_button?
|
26
|
+
@resource.authorization.authorize_action :new, raise_exception: false
|
27
|
+
end
|
28
|
+
|
23
29
|
private
|
24
30
|
|
25
31
|
def via_resource?
|
@@ -14,7 +14,7 @@
|
|
14
14
|
<%= svg 'trash' %> <%= t('avo.detach_item', item: @reflection.name.to_s).capitalize %>
|
15
15
|
<% end %>
|
16
16
|
<% end %>
|
17
|
-
<% if
|
17
|
+
<% if can_see_the_edit_button? %>
|
18
18
|
<%= a_link edit_path, color: 'indigo' do %>
|
19
19
|
<%= svg 'edit' %> <%= t('avo.edit').capitalize %>
|
20
20
|
<% end %>
|
@@ -24,7 +24,7 @@
|
|
24
24
|
<%= svg 'arrow-left' %> <%= t('avo.go_back') %>
|
25
25
|
<% end %>
|
26
26
|
|
27
|
-
<% if
|
27
|
+
<% if can_see_the_destroy_button? %>
|
28
28
|
<%= form_with url: helpers.resource_path(model: @resource.model, resource: @resource), method: :delete, html: { 'data-turbo-frame': params[:turbo_frame] } do |form| %>
|
29
29
|
<%= a_button title: t('avo.delete_item', item: @resource.model.model_name.name.downcase).capitalize,
|
30
30
|
spinner: true,
|
@@ -43,7 +43,15 @@ class Avo::Views::ResourceShowComponent < Avo::ResourceComponent
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def can_detach?
|
46
|
-
authorize_association_for(
|
46
|
+
authorize_association_for("detach")
|
47
|
+
end
|
48
|
+
|
49
|
+
def can_see_the_edit_button?
|
50
|
+
@resource.authorization.authorize_action(:edit, raise_exception: false)
|
51
|
+
end
|
52
|
+
|
53
|
+
def can_see_the_destroy_button?
|
54
|
+
@resource.authorization.authorize_action(:destroy, raise_exception: false)
|
47
55
|
end
|
48
56
|
|
49
57
|
private
|
@@ -12,6 +12,8 @@ module Avo
|
|
12
12
|
before_action :_authenticate!
|
13
13
|
before_action :set_container_classes
|
14
14
|
before_action :add_initial_breadcrumbs
|
15
|
+
before_action :set_view
|
16
|
+
before_action :set_model_to_fill
|
15
17
|
|
16
18
|
rescue_from Pundit::NotAuthorizedError, with: :render_unauthorized
|
17
19
|
rescue_from ActiveRecord::RecordInvalid, with: :exception_logger
|
@@ -99,6 +101,19 @@ module Avo
|
|
99
101
|
@related_model = eager_load_files(@related_resource, @related_resource.class.find_scope).find params[:related_id]
|
100
102
|
end
|
101
103
|
|
104
|
+
def set_view
|
105
|
+
@view = action_name.to_sym
|
106
|
+
end
|
107
|
+
|
108
|
+
def set_model_to_fill
|
109
|
+
@model_to_fill = @resource.model_class.new if @view == :create
|
110
|
+
@model_to_fill = @model if @view == :update
|
111
|
+
end
|
112
|
+
|
113
|
+
def fill_model
|
114
|
+
@model = @resource.fill_model(@model_to_fill, cast_nullable(model_params))
|
115
|
+
end
|
116
|
+
|
102
117
|
def hydrate_resource
|
103
118
|
@resource.hydrate(view: action_name.to_sym, user: _current_user)
|
104
119
|
end
|