ransack_advanced_search 0.1.6 → 0.1.7

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
  SHA1:
3
- metadata.gz: e2b4161ad1d0626ca975398592377463b7ba5d17
4
- data.tar.gz: 0054c096955d9202547a73f4ec0dfc1ae129ee41
3
+ metadata.gz: 18acf6ba76b1063a77f370256be06b835f8163b8
4
+ data.tar.gz: 615e325278e36fac5deb9b8d4979d4fe8838a13c
5
5
  SHA512:
6
- metadata.gz: 66ff929f85d40414763e28e257d3c672e03a265f3a946037bbc9909565e9176f830f04f76480a520ee576efbbdb17c029adf1acbadf7b2e3d395e29e0b1f92e6
7
- data.tar.gz: 9f1b340bd88955122a0421cfd6af96252b18a7109b35eccd8fdf07d297262e01cafb0e13bada7101b2a19cc0545b7da2cb4ed3b5c316ef94a01936aec16d5f4e
6
+ metadata.gz: f49634d2bd23a822b0b1334b2047878ed91a12196e0687b51b025803e35be5331cf5be35de847798fc51bf496b86136e5792b936b9e4339052c7582fc5092944
7
+ data.tar.gz: f6d3267818bf9da9882ca01635a995af3db2f50a2b17e83f2780aac08c1e1ca5ba0703cb0a0f89240bbd718dff9b9553e39ca1f85d13a4f0d9c8a2ffe349c2c4
@@ -27,6 +27,22 @@
27
27
  return $(button).before(template.replace(id_regexp, new_id));
28
28
  };
29
29
 
30
+ Search.prototype.convertFieldType = function (fieldType) {
31
+ var fieldTypeToHtmlType = {
32
+ 'default': 'text',
33
+ 'integer': 'number',
34
+ 'date' : 'date',
35
+ 'datetime' : 'date'
36
+ };
37
+ return (fieldTypeToHtmlType[fieldType] || fieldTypeToHtmlType['default']);
38
+ };
39
+
40
+ Search.prototype.changeValueInputsType = function(element, fieldName, search) {
41
+ fieldType = search.fieldsType[fieldName];
42
+ conditionValueInputs = $(element).parents('.ransack-condition-field').find('.ransack-attribute-value');
43
+ conditionValueInputs.attr('type', search.convertFieldType(fieldType));
44
+ };
45
+
30
46
  return Search;
31
47
 
32
48
  })();
@@ -15,3 +15,16 @@
15
15
  .ransack-advanced-search i.remove_fields {
16
16
  cursor: pointer;
17
17
  }
18
+
19
+ .ransack-advanced-search .ransack-condition-field {
20
+ margin-bottom: 5px;
21
+ margin-top: 5px;
22
+ }
23
+
24
+ .ransack-advanced-search .ransack-action-buttons {
25
+ margin-top: 10px;
26
+ }
27
+
28
+ .ransack-advanced-search .ransack-saved-search-delete {
29
+ margin: 7px;
30
+ }
@@ -7,31 +7,21 @@ module RansackAdvancedSearchHelper
7
7
  content_for :ransack_setup, %Q{
8
8
  var search = new Search({grouping: "#{escape_javascript(fields)}"});
9
9
  search.fieldsType = #{get_fields_data_type(search_object).to_json.html_safe}
10
- search.convertFieldType = function (fieldType) {
11
- var fieldTypeToHtmlType = {
12
- 'default': 'text',
13
- 'integer': 'number',
14
- 'date' : 'date',
15
- 'datetime' : 'date'
16
- }
17
- return (fieldTypeToHtmlType[fieldType] || fieldTypeToHtmlType['default']);
18
- }
19
- search.changeValueInputsType = function(element, fieldName) {
20
- fieldType = search.fieldsType[fieldName];
21
- conditionValueInputs = $(element).parents('.ransack-condition-field').find('.ransack-attribute-value');
22
- conditionValueInputs.attr('type', search.convertFieldType(fieldType));
23
- }
10
+ $('select.ransack-attribute-select').each(function(e) {
11
+ fieldName = $(this).find('option:selected')[0].value;
12
+ search.changeValueInputsType(this, fieldName, search);
13
+ });
24
14
  $(document).on("click", "button.add_fields", function() {
25
15
  search.add_fields(this, $(this).data('fieldType'), $(this).data('content'));
26
16
  if($(this).hasClass('ransack-add-attribute')) {
27
17
  fieldName = $(this).parents('.ransack-condition-field').find('select.ransack-attribute-select').find('option:selected')[0].value;
28
- search.changeValueInputsType(this, fieldName)
18
+ search.changeValueInputsType(this, fieldName, search);
29
19
  }
30
20
  return false;
31
21
  });
32
22
  $(document).on('change', 'select.ransack-attribute-select', function(e) {
33
23
  fieldName = $(this).find('option:selected')[0].value;
34
- search.changeValueInputsType(this, fieldName)
24
+ search.changeValueInputsType(this, fieldName, search);
35
25
  });
36
26
  $(document).on("click", "i.remove_fields", function() {
37
27
  search.remove_fields(this);
@@ -44,24 +44,26 @@
44
44
  <!-- <%= label_tag :distinct, 'Return distinct records?' %> -->
45
45
  <!-- <%= check_box_tag :distinct, '1', params[:distinct].to_i == 1 %> -->
46
46
  <div class="clearfix"></div>
47
- <%= f.submit t('ransack.advanced_search.form.submit_text'), class: 'btn btn-primary' %>
48
- <% if RansackAdvancedSearch.enable_saved_searches %>
49
- <%= f.submit t('ransack.advanced_search.form.save_submit_text'), name: 'save_search', class: 'btn btn-primary' %>
50
- <%= f.submit t('ransack.advanced_search.form.save_new_submit_text'), name: 'save_new_search', class: 'btn btn-primary' %>
51
- <% end %>
52
- <%= link_to t('ransack.advanced_search.form.clear_search_text'), redirect_path, class: 'btn btn-default' %>
53
- <% if RansackAdvancedSearch.enable_saved_searches %>
54
- <% if @saved_search.present? && @saved_search.persisted? %>
55
- <div class="pull-right">
56
- <%= link_to saved_search_path(id: @saved_search.id, redirect_to: redirect_path),
57
- { method: :delete, title: t('ransack.advanced_search.form.delete_saved_search'),
58
- data: { confirm: t('ransack.advanced_search.form.delete_saved_search_confirm'),
59
- toggle: 'tooltip', placement: 'bottom' } } do %>
60
- <icon class="glyphicon glyphicon-trash text-danger"></i>
61
- <% end %>
62
- </div>
47
+ <div class="ransack-action-buttons">
48
+ <%= f.submit t('ransack.advanced_search.form.submit_text'), class: 'btn btn-primary' %>
49
+ <% if RansackAdvancedSearch.enable_saved_searches %>
50
+ <%= f.submit t('ransack.advanced_search.form.save_submit_text'), name: 'save_search', class: 'btn btn-primary' %>
51
+ <%= f.submit t('ransack.advanced_search.form.save_new_submit_text'), name: 'save_new_search', class: 'btn btn-primary' %>
63
52
  <% end %>
64
- <% end %>
53
+ <%= link_to t('ransack.advanced_search.form.clear_search_text'), redirect_path, class: 'btn btn-default' %>
54
+ <% if RansackAdvancedSearch.enable_saved_searches %>
55
+ <% if @saved_search.present? && @saved_search.persisted? %>
56
+ <div class="pull-right ransack-saved-search-delete">
57
+ <%= link_to saved_search_path(id: @saved_search.id, redirect_to: redirect_path),
58
+ { method: :delete, title: t('ransack.advanced_search.form.delete_saved_search'),
59
+ data: { confirm: t('ransack.advanced_search.form.delete_saved_search_confirm'),
60
+ toggle: 'tooltip', placement: 'bottom' } } do %>
61
+ <icon class="glyphicon glyphicon-trash text-danger"></i>
62
+ <% end %>
63
+ </div>
64
+ <% end %>
65
+ <% end %>
66
+ </div>
65
67
  <% end %>
66
68
  </div>
67
69
  </div>
@@ -40,24 +40,26 @@
40
40
  </div>
41
41
 
42
42
  <div class="clearfix"></div>
43
- <%= f.submit t('ransack.advanced_search.form.submit_text'), class: 'btn btn-primary' %>
44
- <% if RansackAdvancedSearch.enable_saved_searches %>
45
- <%= f.submit t('ransack.advanced_search.form.save_submit_text'), name: 'save_search', class: 'btn btn-primary' %>
46
- <%= f.submit t('ransack.advanced_search.form.save_new_submit_text'), name: 'save_new_search', class: 'btn btn-primary' %>
47
- <% end %>
48
- <%= link_to t('ransack.advanced_search.form.clear_search_text'), redirect_path, class: 'btn btn-default' %>
49
- <% if RansackAdvancedSearch.enable_saved_searches %>
50
- <% if @saved_search.present? && @saved_search.persisted? %>
51
- <div class="pull-right">
52
- <%= link_to saved_search_path(id: @saved_search.id, redirect_to: redirect_path),
53
- { method: :delete, title: t('ransack.advanced_search.form.delete_saved_search'),
54
- data: { confirm: t('ransack.advanced_search.form.delete_saved_search_confirm'),
55
- toggle: 'tooltip', placement: 'bottom' } } do %>
56
- <icon class="glyphicon glyphicon-trash text-danger"></i>
57
- <% end %>
58
- </div>
43
+ <div class="ransack-action-buttons">
44
+ <%= f.submit t('ransack.advanced_search.form.submit_text'), class: 'btn btn-primary' %>
45
+ <% if RansackAdvancedSearch.enable_saved_searches %>
46
+ <%= f.submit t('ransack.advanced_search.form.save_submit_text'), name: 'save_search', class: 'btn btn-primary' %>
47
+ <%= f.submit t('ransack.advanced_search.form.save_new_submit_text'), name: 'save_new_search', class: 'btn btn-primary' %>
59
48
  <% end %>
60
- <% end %>
49
+ <%= link_to t('ransack.advanced_search.form.clear_search_text'), redirect_path, class: 'btn btn-default' %>
50
+ <% if RansackAdvancedSearch.enable_saved_searches %>
51
+ <% if @saved_search.present? && @saved_search.persisted? %>
52
+ <div class="pull-right ransack-saved-search-delete">
53
+ <%= link_to saved_search_path(id: @saved_search.id, redirect_to: redirect_path),
54
+ { method: :delete, title: t('ransack.advanced_search.form.delete_saved_search'),
55
+ data: { confirm: t('ransack.advanced_search.form.delete_saved_search_confirm'),
56
+ toggle: 'tooltip', placement: 'bottom' } } do %>
57
+ <icon class="glyphicon glyphicon-trash text-danger"></i>
58
+ <% end %>
59
+ </div>
60
+ <% end %>
61
+ <% end %>
62
+ </div>
61
63
  <% end %>
62
64
  </div>
63
65
  </div>
@@ -1,3 +1,3 @@
1
1
  module RansackAdvancedSearch
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ransack_advanced_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Brusius
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-29 00:00:00.000000000 Z
11
+ date: 2016-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails