alchemy-ajax-form 1.1.3 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 910f913d3c80d97fb9bace371c5ce32f9cd04da6188780d4e892987738d18df6
4
- data.tar.gz: 61ea54945f97308d90b85bf6ae862f4ccbe080b558329b92414990bd79ff6eb5
3
+ metadata.gz: 36a4acac3687f6041a55b8efc1c4d445ca213185a2fe6ed368d0fa887d8b8f98
4
+ data.tar.gz: 2ef67b1ec3ca05197248fbfb2ee2e236dd9a133e0105cbf67dafef8a3c6be9be
5
5
  SHA512:
6
- metadata.gz: 469cfa607c4827e86eee7d47d6ffa113169b16f8dc4a497a00cd00b1b3aff63f426b433e885df130129aa817e7de466e964fcd13eff3479c9ea1accb6270108b
7
- data.tar.gz: 8b6fdc6336a27a75ffcab37ce2b92917d580726df65fd4022ee572db38bdd06f5ba07bca67a2724763450f24a8e145d3067e9d02667d708d34b5c175159e6c1a
6
+ metadata.gz: d5b4509ac463fa1a0f0262870b5f41bf8219c6fb1836296a57c4dab68020f472e83c59c97dba7f6dfed379a12087789ff1e82b48fd5f38be244a963ff11c1a3e
7
+ data.tar.gz: 23a6006f76f29528cd5583d4ae09acefbd81640fa049cef3a3f6b8ebe640ab44a84dc7ab525929b1a0213ec7062e831ee6cec90ff9beae12b8b353c7711a5155
@@ -1,5 +1,7 @@
1
1
  (function ($) {
2
2
 
3
+ $.getScript("//www.google.com/recaptcha/api.js?onload=load_invisible_recaptcha&render=explicit")
4
+
3
5
  var recaptha_disabled =
4
6
  <%= Recaptcha.configuration.skip_verify_env.include?(Rails.env.to_s ) %>
5
7
 
@@ -27,7 +29,7 @@
27
29
 
28
30
  $.each(errors, function (name, value) {
29
31
 
30
- var input = $(form).find("*:not([type='hidden'])[name*='" + name + "']")
32
+ var input = $(form).find("*:not([type='hidden'])[name*='[" + name + "]']")
31
33
 
32
34
 
33
35
  $(input).addClass("invalid");
@@ -137,7 +139,7 @@
137
139
 
138
140
  var widget_id = grecaptcha.render(container_div[0], {
139
141
  'sitekey': '<%= Recaptcha.configuration.site_key! %>',
140
- 'badge': 'inline',
142
+ 'badge': '<%= Alchemy::Ajax::Form.recaptcha_badge %>',
141
143
  'size': 'invisible',
142
144
  'callback': function () {
143
145
  submit_function(form, method, action);
@@ -179,7 +181,6 @@
179
181
 
180
182
  });
181
183
  };
182
- $.getScript("//www.google.com/recaptcha/api.js?onload=load_invisible_recaptcha&render=explicit")
183
184
 
184
185
 
185
186
  })(jQuery);
@@ -18,4 +18,84 @@
18
18
 
19
19
  }
20
20
  }
21
+ }
22
+
23
+ .resources-table-wrapper {
24
+ .search_panel {
25
+ position: fixed;
26
+ top: 127px;
27
+ background-color: #f7f7f7;
28
+ z-index: 2;
29
+ width: 100%;
30
+ padding: 15px 0px;
31
+ width: calc(100% - 159px);
32
+ padding: 15px;
33
+
34
+ }
35
+
36
+ .search_fields_group {
37
+ width: 100%;
38
+ box-sizing: border-box;
39
+
40
+ div.input {
41
+ width: 50%;
42
+ float: left;
43
+ padding: 0 15px;
44
+ margin: 2px 0;
45
+
46
+ &.full-width {
47
+ width: 100%;
48
+
49
+ input[type="url"],
50
+ input[type="text"],
51
+ input[type="email"],
52
+ input[type="password"],
53
+ textarea,
54
+ .select2-container,
55
+ .mce-tinymce,
56
+ .with-hint{
57
+ width: 100%;
58
+ }
59
+ }
60
+
61
+ input[type="url"],
62
+ input[type="text"],
63
+ input[type="email"],
64
+ input[type="password"],
65
+ textarea,
66
+ .select2-container,
67
+ .mce-tinymce,
68
+ .with-hint{
69
+ width: 100%;
70
+ }
71
+ .tinymce_container {
72
+ width: 100%;
73
+ float: left;
74
+ }
75
+
76
+ label {
77
+ width: 100%;
78
+ float: none;
79
+ text-align: left;
80
+ }
81
+ }
82
+
83
+ &:after {
84
+ content: "";
85
+ clear: both;
86
+ visibility: hidden;
87
+ display: block;
88
+ height: 0;
89
+ }
90
+
91
+
92
+ }
93
+
94
+ .action_buttons {
95
+
96
+
97
+ text-align: center;
98
+ margin-top: 15px;
99
+ }
100
+
21
101
  }
@@ -7,7 +7,7 @@ module Alchemy
7
7
  end
8
8
 
9
9
  def index
10
- @query = resource_handler.model.ransack(search_filter_params[:q])
10
+ @query = resource_handler.model.joins(language: :site).ransack(search_filter_params[:q])
11
11
  items = @query.result
12
12
  items = items.order(created_at: :desc)
13
13
 
@@ -25,7 +25,7 @@ module Alchemy
25
25
 
26
26
  respond_to do |format|
27
27
  format.html {
28
- items = items.page(params[:page] || 1).per(per_page_value_for_screen_size)
28
+ items = items.page(params[:page] || 1).per(items_per_page)
29
29
  instance_variable_set("@#{resource_handler.resources_name}", items)
30
30
  }
31
31
  format.csv {
@@ -43,13 +43,17 @@ module Alchemy
43
43
  [
44
44
  # contrary to Rails' documentation passing an empty hash to permit all keys does not work
45
45
  {options: options_from_params.keys},
46
- {q: [resource_handler.search_field_name, :s]},
46
+ {q: [resource_handler.search_field_name, :s].push(*permitted_ransack_attributes)},
47
47
  :tagged_with,
48
48
  :filter,
49
49
  :page
50
50
  ].freeze
51
51
  end
52
52
 
53
+ def permitted_ransack_attributes
54
+ [:language_id_eq, :language_site_id_eq]
55
+ end
56
+
53
57
  def load_resource
54
58
  @resource = resource_handler.model.find(params[:id])
55
59
  instance_variable_set("@#{resource_handler.resource_name}", @resource)
@@ -4,14 +4,52 @@ module Alchemy
4
4
 
5
5
  def alchemy_body_class
6
6
  [
7
- "ajax_forms",
8
- controller_name,
9
- action_name,
10
- content_for(:main_menu_style),
11
- content_for(:alchemy_body_class)
7
+ "ajax_forms",
8
+ controller_name,
9
+ action_name,
10
+ content_for(:main_menu_style),
11
+ content_for(:alchemy_body_class)
12
12
  ].compact
13
13
  end
14
14
 
15
+ def search_panel(options = {}, &block)
16
+ submit_button = options.fetch(:enable_submit, true)
17
+ klass = options.delete(:class) || []
18
+ content_tag(:div, class: "search_panel #{klass.join(" ")}", ** options) do
19
+ if @query
20
+ simple_form_for(@query, url: polymorphic_path([:admin, @query.klass]), method: :get) do |f|
21
+ sb = ActiveSupport::SafeBuffer.new
22
+
23
+ sb << content_tag(:div, class: "search_fields_group") do
24
+ search_fields = ActiveSupport::SafeBuffer.new
25
+ search_fields << f.input(resource_handler.search_field_name,
26
+ label: false,
27
+ input_html: {
28
+ class: 'search_input_field',
29
+ placeholder: Alchemy.t(:search)
30
+ },
31
+ wrapper_html: {
32
+ class: "full-width"
33
+ }
34
+
35
+ )
36
+
37
+ search_fields << capture do
38
+ block.call(f)
39
+ end
40
+ search_fields
41
+ end
42
+ if submit_button
43
+ sb << content_tag(:div, class: "action_buttons") do
44
+ f.submit(::I18n.t('alchemy_ajax_form.submit_search'))
45
+ end
46
+ end
47
+ sb
48
+ end
49
+ end
50
+ end
51
+ end
52
+
15
53
  end
16
54
  end
17
55
  end
@@ -0,0 +1,55 @@
1
+ <% label_title = Alchemy.t("Create #{resource_name}", default: Alchemy.t('Create')) %>
2
+
3
+ <% toolbar(
4
+ buttons: [
5
+ {
6
+ icon: :plus,
7
+ label: label_title,
8
+ url: new_resource_path,
9
+ title: label_title,
10
+ hotkey: 'alt+n',
11
+ dialog_options: {
12
+ title: label_title,
13
+ size: resource_window_size
14
+ },
15
+ if_permitted_to: [:create, resource_model]
16
+ },
17
+ {
18
+ icon: 'download',
19
+ url: resource_url_proxy.url_for(action: 'index', format: 'csv', q: search_filter_params[:q], sort: params[:sort]),
20
+ label: Alchemy.t(:download_csv),
21
+ title: Alchemy.t(:download_csv),
22
+ dialog: false,
23
+ if_permitted_to: [:index, resource_model]
24
+ }
25
+ ],
26
+ search: !lookup_context.any?("search_panel", lookup_context.prefixes, true)
27
+ ) %>
28
+
29
+ <div id="archive_all" class="resources-table-wrapper<%= ' with_tag_filter' if resource_has_tags || resource_has_filters %>">
30
+
31
+ <%= render 'alchemy/admin/resources/table_header' %>
32
+ <% if lookup_context.any? "search_panel", lookup_context.prefixes, true %>
33
+ <%= render partial: "search_panel" %>
34
+ <% end %>
35
+ <%= render 'table' %>
36
+
37
+ <% if resource_has_tags || resource_has_filters %>
38
+ <div id="library_sidebar">
39
+ <% if resource_has_filters %>
40
+ <%= render 'filter_bar' %>
41
+ <% end %>
42
+
43
+ <% if resource_has_tags %>
44
+ <%= render 'tag_list' %>
45
+ <% end %>
46
+ </div>
47
+ <% end %>
48
+ </div>
49
+
50
+
51
+ <script type="text/javascript">
52
+ if ($(".search_panel").length > 0) {
53
+ $("#main_content table.list").css("padding-top", $(".search_panel").height() + 52 + "px")
54
+ }
55
+ </script>
@@ -51,6 +51,8 @@ it:
51
51
  submit: "Invia"
52
52
  form_sended_succesfully: "Inviato con successo"
53
53
  show: Visualizza
54
+ alchemy_ajax_form:
55
+ submit_search: "Cerca..."
54
56
 
55
57
 
56
58
 
@@ -1,7 +1,7 @@
1
1
  module Alchemy
2
2
  module Ajax
3
3
  module Form
4
- VERSION = '1.1.3'
4
+ VERSION = '1.2.1'
5
5
  end
6
6
  end
7
7
  end
@@ -10,8 +10,10 @@ module Alchemy
10
10
  module Ajax
11
11
  module Form
12
12
  # Your code goes here...
13
- mattr_accessor :enable_mjml
13
+ mattr_accessor :enable_mjml, :recaptcha_badge
14
14
  @@enable_mjml = true
15
+ @@recaptcha_badge = 'inline'
16
+
15
17
 
16
18
  end
17
19
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alchemy-ajax-form
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alessandro Baccanelli
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-15 00:00:00.000000000 Z
11
+ date: 2022-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -132,6 +132,7 @@ files:
132
132
  - app/models/alchemy/ajax_form_ability.rb
133
133
  - app/views/alchemy/admin/ajax_forms/_resource.html.erb
134
134
  - app/views/alchemy/admin/ajax_forms/_table.html.erb
135
+ - app/views/alchemy/admin/ajax_forms/index.html.erb
135
136
  - app/views/alchemy/admin/ajax_forms/show.html.erb
136
137
  - app/views/alchemy/ajax_forms/create.json.jbuilder
137
138
  - app/views/alchemy/ajax_forms_mailer/mjml_notify_message.mjml.erb
@@ -179,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
179
180
  - !ruby/object:Gem::Version
180
181
  version: '0'
181
182
  requirements: []
182
- rubygems_version: 3.0.3
183
+ rubygems_version: 3.0.8
183
184
  signing_key:
184
185
  specification_version: 4
185
186
  summary: Structure to implement the forms using ajax and management in the backend