alchemy-ajax-form 1.1.5 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2e25d83694739bb010bcd6ca0bdd447a6a77f048fee6e609a88a1cf78f20517e
4
- data.tar.gz: ee26e7caeb40cafd1b6a47b6550e16c48e759615b4333b795ab2e5d38d1e1bd7
3
+ metadata.gz: ab4f8170326efc5737373e3c71789cd388572e4dc700f81350cf4b5aa98b388c
4
+ data.tar.gz: d4c3306b11ad49214b189e5faf06b6dee0aabb92073d4d926a6760fcdbf430ae
5
5
  SHA512:
6
- metadata.gz: de9cd90aa04c6d9196932f14dd2334dcf46fb4123ce45e640c131973e21ce40e4ca811a547e332bfbf9406707e08611c5b93726ee8f4f234292e10d2b94c2e95
7
- data.tar.gz: 99d0f9c3987d1dbf1f9b83c67e8238652d9c8a5d8fecf7d2b01dd8d2bb2e65b7b896c58e446962a1e60da6b8211d7452d3a363b0a661dc81523fbf93b3a187b6
6
+ metadata.gz: 872039ce8ef52c630b460bcb4b04ff3c2143f1e80b189491343bbc1d488df8c3ba7884fb97fa2c7926b315f48462703e80aece69fc42a15c0cc936a31488a36d
7
+ data.tar.gz: 1aac09b7d730c12112ab35e27a68fdf20976e7c3e004a06e5cc57c0024a5947736e54f318d0a5079c6eb5c000de4b510e86b796cea1a77abf938611ba11cc0ec
@@ -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.5'
4
+ VERSION = '1.2.0'
5
5
  end
6
6
  end
7
7
  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.5
4
+ version: 1.2.0
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-20 00:00:00.000000000 Z
11
+ date: 2020-06-26 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