avo 2.5.2.pre.2 → 2.5.2.pre.3

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 (75) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +0 -2
  3. data/Gemfile.lock +1 -4
  4. data/app/assets/builds/avo.css +222 -812
  5. data/app/assets/builds/avo.js +123 -212
  6. data/app/assets/builds/avo.js.map +3 -3
  7. data/app/assets/stylesheets/avo.css +33 -3
  8. data/app/assets/stylesheets/css/search.css +1 -1
  9. data/app/assets/svgs/heroicons/solid/user-remove.svg +1 -1
  10. data/app/components/avo/actions_component.html.erb +2 -1
  11. data/app/components/avo/alert_component.html.erb +1 -1
  12. data/app/components/avo/alert_component.rb +24 -5
  13. data/app/components/avo/button_component.rb +2 -0
  14. data/app/components/avo/filters_component.html.erb +1 -1
  15. data/app/components/avo/index/field_wrapper_component.html.erb +1 -1
  16. data/app/components/avo/index/grid_cover_empty_state_component.html.erb +1 -1
  17. data/app/components/avo/index/resource_table_component.html.erb +1 -1
  18. data/app/components/avo/panel_component.html.erb +3 -3
  19. data/app/components/avo/panel_component.rb +1 -1
  20. data/app/components/avo/resource_component.rb +50 -0
  21. data/app/components/avo/sidebar/heading_component.html.erb +1 -1
  22. data/app/components/avo/sidebar/link_component.rb +1 -1
  23. data/app/components/avo/sidebar_component.html.erb +5 -13
  24. data/app/components/avo/sidebar_profile_component.html.erb +1 -1
  25. data/app/components/avo/views/resource_edit_component.html.erb +28 -3
  26. data/app/components/avo/views/resource_edit_component.rb +4 -6
  27. data/app/components/avo/views/resource_index_component.html.erb +15 -7
  28. data/app/components/avo/views/resource_new_component.html.erb +8 -2
  29. data/app/components/avo/views/resource_show_component.html.erb +15 -5
  30. data/app/components/avo/views/resource_show_component.rb +0 -45
  31. data/app/controllers/avo/actions_controller.rb +23 -8
  32. data/app/controllers/avo/associations_controller.rb +1 -1
  33. data/app/controllers/avo/base_controller.rb +25 -16
  34. data/app/helpers/avo/application_helper.rb +1 -1
  35. data/app/javascript/js/application.js +1 -1
  36. data/app/javascript/js/controllers/fields/key_value_controller.js +1 -1
  37. data/app/javascript/js/controllers/filter_controller.js +4 -1
  38. data/app/javascript/js/controllers.js +0 -4
  39. data/app/views/avo/actions/show.html.erb +5 -2
  40. data/app/views/avo/partials/_logo.html.erb +1 -1
  41. data/app/views/avo/partials/_navbar.html.erb +12 -6
  42. data/app/views/avo/private/_links_and_buttons.html.erb +1 -1
  43. data/app/views/layouts/avo/application.html.erb +47 -53
  44. data/db/factories.rb +0 -2
  45. data/lib/avo/base_action.rb +24 -6
  46. data/lib/avo/base_resource.rb +0 -6
  47. data/lib/avo/engine.rb +1 -1
  48. data/lib/avo/fields/base_field.rb +1 -2
  49. data/lib/avo/fields/has_and_belongs_to_many_field.rb +2 -2
  50. data/lib/avo/fields/has_many_field.rb +2 -2
  51. data/lib/avo/fields/has_one_field.rb +2 -2
  52. data/lib/avo/licensing/pro_license.rb +1 -2
  53. data/lib/avo/version.rb +1 -1
  54. data/lib/generators/avo/templates/locales/avo.en.yml +0 -4
  55. data/public/avo-assets/avo.css +214 -812
  56. data/public/avo-assets/avo.js +123 -212
  57. data/public/avo-assets/avo.js.map +3 -3
  58. metadata +2 -19
  59. data/app/assets/stylesheets/css/alerts.css +0 -35
  60. data/app/assets/stylesheets/css/tags.css +0 -16
  61. data/app/components/avo/fields/tags_field/edit_component.html.erb +0 -27
  62. data/app/components/avo/fields/tags_field/edit_component.rb +0 -4
  63. data/app/components/avo/fields/tags_field/index_component.html.erb +0 -14
  64. data/app/components/avo/fields/tags_field/index_component.rb +0 -7
  65. data/app/components/avo/fields/tags_field/show_component.html.erb +0 -7
  66. data/app/components/avo/fields/tags_field/show_component.rb +0 -11
  67. data/app/components/avo/fields/tags_field/tag_component.html.erb +0 -9
  68. data/app/components/avo/fields/tags_field/tag_component.rb +0 -11
  69. data/app/javascript/js/controllers/alerts_controller.js +0 -26
  70. data/app/javascript/js/controllers/base_controller.js +0 -22
  71. data/app/javascript/js/controllers/fields/tags_field_controller.js +0 -86
  72. data/app/javascript/js/controllers/fields/tags_field_helpers.js +0 -47
  73. data/lib/avo/concerns/handles_field_args.rb +0 -36
  74. data/lib/avo/fields/tags_field.rb +0 -82
  75. data/lib/avo/hosts/record_host.rb +0 -7
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.5.2.pre.2
4
+ version: 2.5.2.pre.3
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-05-03 00:00:00.000000000 Z
12
+ date: 2022-05-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -254,7 +254,6 @@ files:
254
254
  - app/assets/config/avo_manifest.js
255
255
  - app/assets/stylesheets/avo.css
256
256
  - app/assets/stylesheets/css/active-storage.css
257
- - app/assets/stylesheets/css/alerts.css
258
257
  - app/assets/stylesheets/css/breadcrumbs.css
259
258
  - app/assets/stylesheets/css/buttons.css
260
259
  - app/assets/stylesheets/css/components/code.css
@@ -265,7 +264,6 @@ files:
265
264
  - app/assets/stylesheets/css/pagination.css
266
265
  - app/assets/stylesheets/css/search.css
267
266
  - app/assets/stylesheets/css/spinner.css
268
- - app/assets/stylesheets/css/tags.css
269
267
  - app/assets/stylesheets/css/tailwindcss/base.css
270
268
  - app/assets/stylesheets/css/tailwindcss/components.css
271
269
  - app/assets/stylesheets/css/tailwindcss/utilities.css
@@ -954,14 +952,6 @@ files:
954
952
  - app/components/avo/fields/status_field/index_component.rb
955
953
  - app/components/avo/fields/status_field/show_component.html.erb
956
954
  - app/components/avo/fields/status_field/show_component.rb
957
- - app/components/avo/fields/tags_field/edit_component.html.erb
958
- - app/components/avo/fields/tags_field/edit_component.rb
959
- - app/components/avo/fields/tags_field/index_component.html.erb
960
- - app/components/avo/fields/tags_field/index_component.rb
961
- - app/components/avo/fields/tags_field/show_component.html.erb
962
- - app/components/avo/fields/tags_field/show_component.rb
963
- - app/components/avo/fields/tags_field/tag_component.html.erb
964
- - app/components/avo/fields/tags_field/tag_component.rb
965
955
  - app/components/avo/fields/text_field/edit_component.html.erb
966
956
  - app/components/avo/fields/text_field/edit_component.rb
967
957
  - app/components/avo/fields/text_field/index_component.html.erb
@@ -1061,9 +1051,7 @@ files:
1061
1051
  - app/javascript/js/controllers.js
1062
1052
  - app/javascript/js/controllers/action_controller.js
1063
1053
  - app/javascript/js/controllers/actions_picker_controller.js
1064
- - app/javascript/js/controllers/alerts_controller.js
1065
1054
  - app/javascript/js/controllers/attachments_controller.js
1066
- - app/javascript/js/controllers/base_controller.js
1067
1055
  - app/javascript/js/controllers/boolean_filter_controller.js
1068
1056
  - app/javascript/js/controllers/copy_to_clipboard_controller.js
1069
1057
  - app/javascript/js/controllers/dashboard_card_controller.js
@@ -1072,8 +1060,6 @@ files:
1072
1060
  - app/javascript/js/controllers/fields/date_field_controller.js
1073
1061
  - app/javascript/js/controllers/fields/key_value_controller.js
1074
1062
  - app/javascript/js/controllers/fields/simple_mde_controller.js
1075
- - app/javascript/js/controllers/fields/tags_field_controller.js
1076
- - app/javascript/js/controllers/fields/tags_field_helpers.js
1077
1063
  - app/javascript/js/controllers/fields/trix_field_controller.js
1078
1064
  - app/javascript/js/controllers/filter_controller.js
1079
1065
  - app/javascript/js/controllers/hidden_input_controller.js
@@ -1164,7 +1150,6 @@ files:
1164
1150
  - lib/avo/base_card.rb
1165
1151
  - lib/avo/base_resource.rb
1166
1152
  - lib/avo/concerns/fetches_things.rb
1167
- - lib/avo/concerns/handles_field_args.rb
1168
1153
  - lib/avo/configuration.rb
1169
1154
  - lib/avo/dashboards/base_dashboard.rb
1170
1155
  - lib/avo/dashboards/base_divider.rb
@@ -1204,7 +1189,6 @@ files:
1204
1189
  - lib/avo/fields/progress_bar_field.rb
1205
1190
  - lib/avo/fields/select_field.rb
1206
1191
  - lib/avo/fields/status_field.rb
1207
- - lib/avo/fields/tags_field.rb
1208
1192
  - lib/avo/fields/text_field.rb
1209
1193
  - lib/avo/fields/textarea_field.rb
1210
1194
  - lib/avo/fields/trix_field.rb
@@ -1225,7 +1209,6 @@ files:
1225
1209
  - lib/avo/hosts/dashboard_card.rb
1226
1210
  - lib/avo/hosts/dashboard_visibility.rb
1227
1211
  - lib/avo/hosts/ordering.rb
1228
- - lib/avo/hosts/record_host.rb
1229
1212
  - lib/avo/licensing/community_license.rb
1230
1213
  - lib/avo/licensing/h_q.rb
1231
1214
  - lib/avo/licensing/license.rb
@@ -1,35 +0,0 @@
1
- #toast-container > div {
2
- box-shadow: none;
3
- background-size: 1.5rem;
4
- background-position: 0.8rem 0.8rem;
5
- width: 500px;
6
-
7
- @apply shadow-md opacity-100 border border-gray-200 rounded-md pt-3 pr-3 pb-3 bg-white;
8
-
9
- &:hover {
10
- @apply shadow-xl;
11
- }
12
-
13
- .toast-title {
14
- @apply text-gray-800;
15
- }
16
- .toast-message {
17
- @apply text-gray-800;
18
- }
19
-
20
- &.toast-success {
21
- background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyMCAyMCIgZmlsbD0iIzM4YTE2OSI+CiAgPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNi4yNjcgMy40NTVhMy4wNjYgMy4wNjYgMCAwMDEuNzQ1LS43MjMgMy4wNjYgMy4wNjYgMCAwMTMuOTc2IDAgMy4wNjYgMy4wNjYgMCAwMDEuNzQ1LjcyMyAzLjA2NiAzLjA2NiAwIDAxMi44MTIgMi44MTJjLjA1MS42NDMuMzA0IDEuMjU0LjcyMyAxLjc0NWEzLjA2NiAzLjA2NiAwIDAxMCAzLjk3NiAzLjA2NiAzLjA2NiAwIDAwLS43MjMgMS43NDUgMy4wNjYgMy4wNjYgMCAwMS0yLjgxMiAyLjgxMiAzLjA2NiAzLjA2NiAwIDAwLTEuNzQ1LjcyMyAzLjA2NiAzLjA2NiAwIDAxLTMuOTc2IDAgMy4wNjYgMy4wNjYgMCAwMC0xLjc0NS0uNzIzIDMuMDY2IDMuMDY2IDAgMDEtMi44MTItMi44MTIgMy4wNjYgMy4wNjYgMCAwMC0uNzIzLTEuNzQ1IDMuMDY2IDMuMDY2IDAgMDEwLTMuOTc2IDMuMDY2IDMuMDY2IDAgMDAuNzIzLTEuNzQ1IDMuMDY2IDMuMDY2IDAgMDEyLjgxMi0yLjgxMnptNy40NCA1LjI1MmExIDEgMCAwMC0xLjQxNC0xLjQxNEw5IDEwLjU4NiA3LjcwNyA5LjI5M2ExIDEgMCAwMC0xLjQxNCAxLjQxNGwyIDJhMSAxIDAgMDAxLjQxNCAwbDQtNHoiIGNsaXAtcnVsZT0iZXZlbm9kZCIgLz4KPC9zdmc+Cg==) !important;
22
- }
23
-
24
- &.toast-warning {
25
- background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyMCAyMCIgZmlsbD0icmdiYSgyMTcsIDExOSwgNiwgMSkiPgogIDxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgZD0iTTguMjU3IDMuMDk5Yy43NjUtMS4zNiAyLjcyMi0xLjM2IDMuNDg2IDBsNS41OCA5LjkyYy43NSAxLjMzNC0uMjEzIDIuOTgtMS43NDIgMi45OEg0LjQyYy0xLjUzIDAtMi40OTMtMS42NDYtMS43NDMtMi45OGw1LjU4LTkuOTJ6TTExIDEzYTEgMSAwIDExLTIgMCAxIDEgMCAwMTIgMHptLTEtOGExIDEgMCAwMC0xIDF2M2ExIDEgMCAwMDIgMFY2YTEgMSAwIDAwLTEtMXoiIGNsaXAtcnVsZT0iZXZlbm9kZCIgLz4KPC9zdmc+Cg==) !important;
26
- }
27
-
28
- &.toast-info {
29
- background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyMCAyMCIgZmlsbD0icmdiYSgzNywgOTksIDIzNSwgMSkiPgogIDxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgZD0iTTE4IDEwYTggOCAwIDExLTE2IDAgOCA4IDAgMDExNiAwem0tNy00YTEgMSAwIDExLTIgMCAxIDEgMCAwMTIgMHpNOSA5YTEgMSAwIDAwMCAydjNhMSAxIDAgMDAxIDFoMWExIDEgMCAxMDAtMnYtM2ExIDEgMCAwMC0xLTFIOXoiIGNsaXAtcnVsZT0iZXZlbm9kZCIgLz4KPC9zdmc+Cg==) !important;
30
- }
31
-
32
- &.toast-error {
33
- background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyMCAyMCIgZmlsbD0icmdiYSgyMjAsIDM4LCAzOCwgMSkiPgogIDxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgZD0iTTE4IDEwYTggOCAwIDExLTE2IDAgOCA4IDAgMDExNiAwem0tNyA0YTEgMSAwIDExLTIgMCAxIDEgMCAwMTIgMHptLTEtOWExIDEgMCAwMC0xIDF2NGExIDEgMCAxMDIgMFY2YTEgMSAwIDAwLTEtMXoiIGNsaXAtcnVsZT0iZXZlbm9kZCIgLz4KPC9zdmc+Cg==) !important;
34
- }
35
- }
@@ -1,16 +0,0 @@
1
- tags.tagify {
2
- --tag-inset-shadow-size: 3em;
3
- }
4
-
5
- tags.tagify {
6
- @apply !p-0;
7
-
8
- span.tagify__input {
9
- @apply my-1;
10
- }
11
- }
12
-
13
- tag.tagify__tag {
14
- @apply text-sm my-1 mb-0;
15
- }
16
-
@@ -1,27 +0,0 @@
1
- <%= edit_field_wrapper field: @field, index: @index, form: @form, resource: @resource, displayed_in_modal: @displayed_in_modal do %>
2
- <div data-controller="tags-field">
3
- <%# dummy field %>
4
- <%= text_field_tag "#{@field.id}-dummy", '',
5
- class: helpers.input_classes('w-full', has_error: @field.model_errors.include?(@field.id)),
6
- placeholder: @field.placeholder,
7
- disabled: @field.readonly,
8
- value: '',
9
- data: {
10
- 'tags-field-target': 'fakeInput',
11
- } %>
12
- <%# real field %>
13
- <%= @form.text_field @field.id,
14
- class: helpers.input_classes('hidden w-full', has_error: @field.model_errors.include?(@field.id)),
15
- placeholder: @field.placeholder,
16
- disabled: @field.readonly,
17
- value: @field.field_value.to_json,
18
- data: {
19
- 'tags-field-target': 'input',
20
- 'whitelist-items': @field.suggestions.to_json,
21
- 'blacklist-items': @field.blacklist.to_json,
22
- 'enforce-suggestions': @field.enforce_suggestions ? 1 : 0,
23
- 'delimiters': @field.delimiters,
24
- 'close-on-select': @field.close_on_select ? 1 : 0,
25
- } %>
26
- </div>
27
- <% end %>
@@ -1,4 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Avo::Fields::TagsField::EditComponent < Avo::Fields::EditComponent
4
- end
@@ -1,14 +0,0 @@
1
- <%= index_field_wrapper field: @field do %>
2
- <div class="flex gap-1 items-center flex-nowrap">
3
- <% value.take(3).each do |item| %>
4
- <% if @field.acts_as_taggable_on.present? %>
5
- <%= render Avo::Fields::TagsField::TagComponent.new(label: item['value']) %>
6
- <% else %>
7
- <%= render Avo::Fields::TagsField::TagComponent.new(label: item) %>
8
- <% end %>
9
- <% end %>
10
- <% if value.count > 3 %>
11
- <%= render Avo::Fields::TagsField::TagComponent.new(label: '...', title: I18n.t('avo.x_items_more', count: value.count - 3)) %>
12
- <% end %>
13
- </div>
14
- <% end %>
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Avo::Fields::TagsField::IndexComponent < Avo::Fields::IndexComponent
4
- def value
5
- @field.field_value
6
- end
7
- end
@@ -1,7 +0,0 @@
1
- <%= show_field_wrapper field: @field, index: @index do %>
2
- <div class="flex gap-1 items-center flex-wrap">
3
- <% @field.field_value.each do |item| %>
4
- <%= render Avo::Fields::TagsField::TagComponent.new(label: label_from_item(item)) %>
5
- <% end %>
6
- </div>
7
- <% end %>
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Avo::Fields::TagsField::ShowComponent < Avo::Fields::ShowComponent
4
- def label_from_item(item)
5
- if @field.acts_as_taggable_on.present?
6
- item['value']
7
- else
8
- item
9
- end
10
- end
11
- end
@@ -1,9 +0,0 @@
1
- <div class="flex px-2 py-1 rounded bg-gray-200 text-sm text-gray-800 font-normal flex-shrink-0"
2
- <% if title.present? %>
3
- data-tippy="tooltip"
4
- title="<%= title %>"
5
- <% end %>
6
- data-target="tag-component"
7
- >
8
- <%= label %>
9
- </div>
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Avo::Fields::TagsField::TagComponent < ViewComponent::Base
4
- attr_reader :label
5
- attr_reader :title
6
-
7
- def initialize(label: nil, title: nil)
8
- @label = label
9
- @title = title
10
- end
11
- end
@@ -1,26 +0,0 @@
1
- import { Controller } from '@hotwired/stimulus'
2
-
3
- export default class extends Controller {
4
- static targets = ['container']
5
-
6
- connect() {
7
- window.toastr[this.type](this.message)
8
- }
9
-
10
- get type() {
11
- const typeMap = {
12
- info: 'info',
13
- warning: 'warning',
14
- success: 'success',
15
- error: 'error',
16
- notice: 'info',
17
- alert: 'error',
18
- }
19
-
20
- return typeMap[this.containerTarget.dataset.alertType]
21
- }
22
-
23
- get message() {
24
- return this.containerTarget.innerHTML
25
- }
26
- }
@@ -1,22 +0,0 @@
1
- import { Controller } from '@hotwired/stimulus'
2
-
3
- export default class extends Controller {
4
- /**
5
- * Helper that parses the data attribute value to JSON
6
- */
7
- getJsonAttribute(target, attribute, defaultValue = []) {
8
- let result = defaultValue
9
- try {
10
- result = JSON.parse(target.getAttribute(attribute))
11
- } catch (error) {}
12
-
13
- return result
14
- }
15
-
16
- /**
17
- * Parses the attribute to boolean
18
- */
19
- getBooleanAttribute(target, attribute) {
20
- return target.getAttribute(attribute) === '1'
21
- }
22
- }
@@ -1,86 +0,0 @@
1
- import { first, isObject, merge } from 'lodash'
2
- import Tagify from '@yaireo/tagify'
3
-
4
- import BaseController from '../base_controller'
5
-
6
- import { suggestionItemTemplate, tagTemplate } from './tags_field_helpers'
7
-
8
- export default class extends BaseController {
9
- static targets = ['input', 'fakeInput'];
10
-
11
- tagify = null;
12
-
13
- get whitelistItems() {
14
- return this.getJsonAttribute(this.inputTarget, 'data-whitelist-items', [])
15
- }
16
-
17
- get blacklistItems() {
18
- return this.getJsonAttribute(this.inputTarget, 'data-blacklist-items', [])
19
- }
20
-
21
- get enforceSuggestions() {
22
- return this.getBooleanAttribute(this.inputTarget, 'data-enforce-suggestions')
23
- }
24
-
25
- get closeOnSelect() {
26
- return this.getBooleanAttribute(this.inputTarget, 'data-close-on-select')
27
- }
28
-
29
- get delimiters() {
30
- return this.getJsonAttribute(this.inputTarget, 'data-delimiters', [])
31
- }
32
-
33
- get suggestionsAreObjects() {
34
- return isObject(first(this.whitelistItems))
35
- }
36
-
37
- get tagifyOptions() {
38
- let options = {
39
- whitelist: this.whitelistItems,
40
- blacklist: this.blacklistItems,
41
- enforceWhitelist: this.enforceSuggestions,
42
- delimiters: this.delimiters.join('|'),
43
- maxTags: 10,
44
- dropdown: {
45
- maxItems: 20,
46
- enabled: 0,
47
- closeOnSelect: this.closeOnSelect,
48
- },
49
- }
50
-
51
- if (this.suggestionsAreObjects) {
52
- options = merge(options, {
53
- tagTextProp: 'label',
54
- dropdown: {
55
- searchKeys: ['label'],
56
- },
57
- templates: {
58
- tag: tagTemplate,
59
- dropdownItem: suggestionItemTemplate,
60
- },
61
- })
62
- }
63
-
64
- return options
65
- }
66
-
67
- connect() {
68
- if (this.hasInputTarget) {
69
- this.hideFakeInput()
70
- this.showRealInput()
71
- this.initTagify()
72
- }
73
- }
74
-
75
- initTagify() {
76
- this.tagify = new Tagify(this.inputTarget, this.tagifyOptions)
77
- }
78
-
79
- hideFakeInput() {
80
- this.fakeInputTarget.classList.add('hidden')
81
- }
82
-
83
- showRealInput() {
84
- this.inputTarget.classList.remove('hidden')
85
- }
86
- }
@@ -1,47 +0,0 @@
1
- export function tagTemplate(tagData) {
2
- const suggestions = this.settings.whitelist || []
3
-
4
- const possibleSuggestion = suggestions.find(
5
- // eslint-disable-next-line eqeqeq
6
- (item) => item.value == tagData.value,
7
- )
8
- const possibleLabel = possibleSuggestion
9
- ? possibleSuggestion.label
10
- : tagData.value
11
-
12
- return `
13
- <tag title="${tagData.value}"
14
- contenteditable='false'
15
- spellcheck='false'
16
- tabIndex="-1"
17
- class="tagify__tag ${tagData.class ? tagData.class : ''}"
18
- ${this.getAttributes(tagData)}
19
- >
20
- <x title='' class='tagify__tag__removeBtn' role='button' aria-label='remove tag'></x>
21
- <div>
22
- <span class='tagify__tag-text'>${possibleLabel}</span>
23
- </div>
24
- </tag>
25
- `
26
- }
27
-
28
- export function suggestionItemTemplate(tagData) {
29
- return `
30
- <div ${this.getAttributes(tagData)}
31
- class='tagify__dropdown__item flex items-center ${
32
- tagData.class ? tagData.class : ''
33
- }'
34
- tabindex="0"
35
- role="option">
36
- ${
37
- tagData.avatar
38
- ? `
39
- <div class='rounded w-8 h-8 block mr-2'>
40
- <img onerror="this.style.visibility='hidden'" class="w-full" src="${tagData.avatar}">
41
- </div>`
42
- : ''
43
- }
44
- <span>${tagData.label}</span>
45
- </div>
46
- `
47
- }
@@ -1,36 +0,0 @@
1
- module Avo
2
- module Concerns
3
- module HandlesFieldArgs
4
- extend ActiveSupport::Concern
5
-
6
- private
7
-
8
- # Add an instance variable from args
9
- # That may be a string, boolean, or array
10
- # Each args should also have a default value
11
- def add_prop_from_args(args = {}, name: nil, type: :string, default: nil)
12
- value = default
13
-
14
- if type == :boolean
15
- value = args[name.to_sym] == true
16
- else
17
- value = args[name.to_sym] unless args.dig(name.to_sym).nil?
18
- end
19
-
20
- instance_variable_set(:"@#{name}", value)
21
- end
22
-
23
- def add_boolean_prop(args, name, default = false)
24
- add_prop_from_args args, name: name, default: default, type: :boolean
25
- end
26
-
27
- def add_array_prop(args, name, default = [])
28
- add_prop_from_args args, name: name, default: default, type: :array
29
- end
30
-
31
- def add_string_prop(args, name, default = [])
32
- add_prop_from_args args, name: name, default: default, type: :string
33
- end
34
- end
35
- end
36
- end
@@ -1,82 +0,0 @@
1
- module Avo
2
- module Fields
3
- class TagsField < BaseField
4
- attr_reader :acts_as_taggable_on
5
- attr_reader :close_on_select
6
- attr_reader :delimiters
7
- attr_reader :enforce_suggestions
8
-
9
- def initialize(id, **args, &block)
10
- super(id, **args, &block)
11
-
12
- add_boolean_prop args, :close_on_select
13
- add_boolean_prop args, :enforce_suggestions
14
- add_string_prop args, :acts_as_taggable_on
15
- add_array_prop args, :blacklist
16
- add_array_prop args, :delimiters, [","]
17
- add_array_prop args, :suggestions
18
- end
19
-
20
- def field_value
21
- return json_value if acts_as_taggable_on.present?
22
-
23
- value || []
24
- end
25
-
26
- def json_value
27
- value.map do |item|
28
- {
29
- value: item.name
30
- }
31
- end.as_json
32
- end
33
-
34
- def fill_field(model, key, value, params)
35
- if acts_as_taggable_on.present?
36
- model.send(act_as_taggable_attribute(key), parsed_value(value))
37
- else
38
- model.send("#{key}=", parsed_value(value))
39
- end
40
-
41
- model
42
- end
43
-
44
- def suggestions
45
- return @suggestions if @suggestions.is_a? Array
46
-
47
- if @suggestions.respond_to? :call
48
- return Avo::Hosts::RecordHost.new(block: @suggestions, record: model).handle
49
- end
50
-
51
- []
52
- end
53
-
54
- def blacklist
55
- return @blacklist if @blacklist.is_a? Array
56
-
57
- if @blacklist.respond_to? :call
58
- return Avo::Hosts::RecordHost.new(block: @blacklist, record: model).handle
59
- end
60
-
61
- []
62
- end
63
-
64
- private
65
-
66
- def act_as_taggable_attribute(key)
67
- "#{key.singularize}_list="
68
- end
69
-
70
- def parsed_value(value)
71
- JSON.parse(value).pluck("value")
72
- rescue
73
- []
74
- end
75
-
76
- private
77
-
78
- def parse_suggestions_from_args(args)
79
- end
80
- end
81
- end
82
- end
@@ -1,7 +0,0 @@
1
- module Avo
2
- module Hosts
3
- class RecordHost < BaseHost
4
- option :record
5
- end
6
- end
7
- end