ransack_advanced_search 0.1.4 → 0.1.5

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: 709e75317b253464253e2227e66d97ae1120ead2
4
- data.tar.gz: 85ec334b704763e7f559041cfbc392ec703513b0
3
+ metadata.gz: e195555aa30993c5a09c75ce2b317f2ae204ee09
4
+ data.tar.gz: a322011e4765d3182d11a911e0db6270b7e1fa6d
5
5
  SHA512:
6
- metadata.gz: 667d4d911afe7cffdc24dc46777adfb5e0ef7114c35abac12c43dabdbf69b888c1368739db65ad7e46df0bd55b4ccc0719f4db4659d41681cdd0e02a024db798
7
- data.tar.gz: 47400c50f9d161176080e4d0fd74a02ab5a323313de1370495e49fd1e881b6e7846b053eba9ef86c615aa7928d18bb766668acc80f0717695aabdaf76594a651
6
+ metadata.gz: 464cad2535aba50d399a3f48137e57efb5dc81e91fcfd0a68b8cac3f9f8b39cc04c4fee18279c72270194af0a18a0eb683bc04feda5fb83ed7dc2f05473c6557
7
+ data.tar.gz: 6d00c7e61f22b8df27f2c0f6c9f6cba2b44382700e925f35ae05273dc705f66cea6c37784e21f650836b0b85a2be203470dfc5fb1017968b91203f5e9bbf37b4
data/README.md CHANGED
@@ -122,7 +122,7 @@ Or, the following for quick_search:
122
122
  }
123
123
  %>
124
124
  ```
125
-
125
+ IMPORTANT: If you are using saved searches and you want to change from quick search to advanced search views or vice versa, you must provide a new context for this saved searches or delete all saved search for that context before changing the view.
126
126
 
127
127
  All done! Enjoy the search!
128
128
 
@@ -0,0 +1,20 @@
1
+ class SavedSearchesController < ApplicationController
2
+ before_action :set_saved_search, only: [:destroy]
3
+
4
+ # DELETE /saved_search/1
5
+ # DELETE /saved_search/1.json
6
+ def destroy
7
+ @saved_search.destroy
8
+ respond_to do |format|
9
+ redirect_path = params[:redirect_to] || root_path
10
+ format.html { redirect_to redirect_path, notice: t('ransack.saved_search.delete.success') }
11
+ format.json { head :no_content }
12
+ end
13
+ end
14
+
15
+ private
16
+ # Use callbacks to share common setup or constraints between actions.
17
+ def set_saved_search
18
+ @saved_search = SavedSearch.find(params[:id])
19
+ end
20
+ end
@@ -44,14 +44,24 @@
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
- <div class="form-group">
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' %>
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>
52
63
  <% end %>
53
- <%= link_to t('ransack.advanced_search.form.clear_search_text'), redirect_path, class: 'btn btn-default' %>
54
- </div>
64
+ <% end %>
55
65
  <% end %>
56
66
  </div>
57
67
  </div>
@@ -40,14 +40,25 @@
40
40
  </div>
41
41
 
42
42
  <div class="clearfix"></div>
43
- <div class="form-group">
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' %>
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
+ <%binding.pry%>
51
+ <% if @saved_search.present? && @saved_search.persisted? %>
52
+ <div class="pull-right">
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>
48
60
  <% end %>
49
- <%= link_to t('ransack.advanced_search.form.clear_search_text'), redirect_path, class: 'btn btn-default' %>
50
- </div>
61
+ <% end %>
51
62
  <% end %>
52
63
  </div>
53
64
  </div>
@@ -9,6 +9,8 @@ en:
9
9
  save_submit_text: Save and Search
10
10
  save_new_submit_text: Save as new and Search
11
11
  clear_search_text: Reset
12
+ delete_saved_search: Delete this saved search
13
+ delete_saved_search_confirm: Confirm deletion of this saved search?
12
14
  sort:
13
15
  title: Sort
14
16
  label_title: Sort by
@@ -28,6 +30,8 @@ en:
28
30
  save:
29
31
  success: Search saved successfully.
30
32
  error: Error while saving the search. You must enter a description of the search and at least one filter.
33
+ delete:
34
+ success: Search successfully destroyed.
31
35
  search: "search"
32
36
  predicate: "predicate"
33
37
  and: "and"
@@ -9,6 +9,8 @@ pt-BR:
9
9
  save_submit_text: Salvar e Pesquisar
10
10
  save_new_submit_text: Salvar nova e Pesquisar
11
11
  clear_search_text: Limpar
12
+ delete_saved_search: Excluir esta busca salva
13
+ delete_saved_search_confirm: Confirma a exclusão desta busca salva?
12
14
  sort:
13
15
  title: Ordenação
14
16
  add: Adicionar ordenação
@@ -27,6 +29,8 @@ pt-BR:
27
29
  save:
28
30
  success: Busca salva com sucesso.
29
31
  error: Erro ao salvar a busca. Você precisa informar a descrição da busca e pelo menos um filtro.
32
+ delete:
33
+ success: Busca excluída com sucesso.
30
34
  search: "pesquisar"
31
35
  predicate: "predicado"
32
36
  and: "e"
data/config/routes.rb CHANGED
@@ -1,2 +1,3 @@
1
- RansackAdvancedSearch::Engine.routes.draw do
1
+ Rails.application.routes.draw do
2
+ resources :saved_search, only: [:destroy]
2
3
  end
@@ -1,3 +1,3 @@
1
1
  module RansackAdvancedSearch
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ransack_advanced_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Brusius
@@ -79,6 +79,7 @@ files:
79
79
  - app/assets/stylesheets/ransack_advanced_search/application.css
80
80
  - app/controllers/concerns/ransack_advanced_search/saved_search_utils.rb
81
81
  - app/controllers/ransack_advanced_search/application_controller.rb
82
+ - app/controllers/saved_searches_controller.rb
82
83
  - app/helpers/ransack_advanced_search_helper.rb
83
84
  - app/models/saved_search.rb
84
85
  - app/views/ransack_advanced_search/_advanced_search.html.erb