tramway-admin 1.9.0.3 → 1.10
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 +4 -4
- data/app/controllers/tramway/admin/records_controller.rb +4 -1
- data/app/helpers/tramway/admin/records_helper.rb +2 -2
- data/app/views/tramway/admin/records/_search.html.haml +5 -3
- data/app/views/tramway/admin/records/index.html.haml +8 -5
- data/lib/tramway/admin/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3e963fa22f305797034b5f98cbc556d0cb53ab21d09ee9314a59e6828e0ef2f
|
4
|
+
data.tar.gz: d089bf2d73c27ec5dd35efe2e8b6f7a1a3feaa846c7af2f64afe6270bbdfa97d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b282fccc48f302754ccc6fcbb844d214f6a88c7b0d0713ad825278cc000b95a380a5e9ea50a48ebc6594d435cc9d7c41da67a10a4849d292c3221aed2f546c9
|
7
|
+
data.tar.gz: 074ec3863ed4acd2081ab54ee5104672ab16c858a0d026972329c5eb2ceaa1d4578ef019f759d607dc931a34a3a604f70500f95cd51609a8277d658912bc452a
|
@@ -1,7 +1,10 @@
|
|
1
1
|
module Tramway::Admin
|
2
2
|
class RecordsController < ApplicationController
|
3
3
|
def index
|
4
|
-
|
4
|
+
scope = params[:scope].present? ? params[:scope] : :all
|
5
|
+
records = model_class.active.order(id: :desc).send scope
|
6
|
+
records = records.search params[:search] if params[:search]
|
7
|
+
@records = decorator_class.decorate records.page params[:page]
|
5
8
|
end
|
6
9
|
|
7
10
|
def show
|
@@ -34,11 +34,11 @@ module Tramway::Admin
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def search_tab_title(count)
|
37
|
-
"#{t("helpers.found")} / #{count}"
|
37
|
+
"#{t("helpers.scope.found")} / #{count}"
|
38
38
|
end
|
39
39
|
|
40
40
|
def searchable_model?(model_class)
|
41
|
-
model_class.methods.include?
|
41
|
+
model_class.methods.include? :search
|
42
42
|
end
|
43
43
|
|
44
44
|
def admin_index_path_of_model(model_class, tab = nil)
|
@@ -1,9 +1,11 @@
|
|
1
1
|
- if searchable_model?(model_class)
|
2
2
|
.col-md-6
|
3
3
|
.search
|
4
|
-
= form_tag
|
4
|
+
= form_tag records_path, method: :get do |f|
|
5
5
|
.form-group.text
|
6
6
|
.input-group
|
7
7
|
= text_field_tag :search, params[:search], class: 'text form-control'
|
8
|
-
|
9
|
-
|
8
|
+
= hidden_field_tag :model, params[:model]
|
9
|
+
= hidden_field_tag :scope, params[:scope]
|
10
|
+
.input-group-append
|
11
|
+
= submit_tag t('helpers.actions.search'), class: 'btn btn-primary'
|
@@ -13,11 +13,14 @@
|
|
13
13
|
%hr
|
14
14
|
%ul.nav.nav-tabs
|
15
15
|
- if params[:search]
|
16
|
-
%li.active.nav-item
|
17
|
-
= link_to search_tab_title(items.total_count), '#', class: 'nav-link'
|
18
|
-
- tabs.each_with_index do |tab, index|
|
19
16
|
%li.nav-item
|
20
|
-
= link_to
|
21
|
-
|
17
|
+
= link_to search_tab_title(@records.total_count), '#', class: 'nav-link active'
|
18
|
+
%li.nav-item
|
19
|
+
= link_to t('helpers.actions.reset'), records_path(model: params[:model]), class: 'nav-link'
|
20
|
+
- else
|
21
|
+
- tabs.each_with_index do |tab, index|
|
22
|
+
%li.nav-item
|
23
|
+
= link_to admin_index_path_of_model(model_class, tab), class: "#{active_tab(tab, index)} nav-link" do
|
24
|
+
!= tab_title(model_class, tab, @counts[tab], state_method)
|
22
25
|
%div{ id: (params[:search] ? :search : params[:scope]) }
|
23
26
|
= render 'list'
|