admini 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/admini/default.css +25 -1
- data/app/controllers/concerns/admini/resources.rb +29 -4
- data/app/views/admini/layouts/_nav.html.erb +4 -1
- data/app/views/admini/layouts/_search.html.erb +7 -0
- data/config/locales/admini.en.yml +1 -0
- data/config/locales/admini.ja.yml +1 -0
- data/lib/admini/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2951544c110448fa3e238ec1d2e06df1d3c22ca1
|
4
|
+
data.tar.gz: 726e830aa6a0e8b7bcf64f28fe9c78c33830f0be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe48c9b92753655f75b136593ce5a38cec6b8a6026f130ebbef1f2fecb4be111511e31ecdcbb49cc606d4179dddb6038bc320a126df2a8e8a9ea1c1e166c5d9f
|
7
|
+
data.tar.gz: 915b6a16f2266be298a44e5d1fa3ad933bccbdb147a9f0f8e6a5e020c37ecac74fda88f36bb4fbde36d562b78cb3d4ae5a04cb7b2b28ceebb823b10db2ecb2e7
|
@@ -21,6 +21,17 @@ a {
|
|
21
21
|
float: right;
|
22
22
|
}
|
23
23
|
|
24
|
+
.clearfix:before {
|
25
|
+
display: table;
|
26
|
+
content: '';
|
27
|
+
}
|
28
|
+
|
29
|
+
.clearfix:after {
|
30
|
+
clear: both;
|
31
|
+
display: table;
|
32
|
+
content: '';
|
33
|
+
}
|
34
|
+
|
24
35
|
.header {
|
25
36
|
margin-bottom: 20px;
|
26
37
|
padding-top: 20px;
|
@@ -73,9 +84,22 @@ textarea {
|
|
73
84
|
padding: 8px;
|
74
85
|
width: 50%;
|
75
86
|
min-width: 480px;
|
76
|
-
border: 1px solid #
|
87
|
+
border: 1px solid #ddd;
|
88
|
+
border-radius: 2px;
|
89
|
+
vertical-align: middle;
|
90
|
+
}
|
91
|
+
|
92
|
+
input[type=search] {
|
93
|
+
padding: 2px;
|
94
|
+
border: 1px solid #ddd;
|
95
|
+
border-radius: 2px;
|
96
|
+
vertical-align: middle;
|
77
97
|
}
|
78
98
|
|
79
99
|
textarea {
|
80
100
|
height: 160px;
|
81
101
|
}
|
102
|
+
|
103
|
+
select {
|
104
|
+
vertical-align: middle;
|
105
|
+
}
|
@@ -4,10 +4,13 @@ module Admini
|
|
4
4
|
module Resources
|
5
5
|
extend ActiveSupport::Concern
|
6
6
|
|
7
|
+
include ActionView::Helpers::FormOptionsHelper
|
8
|
+
|
7
9
|
included do
|
8
10
|
before_action :load_resources, only: :index
|
9
11
|
before_action :load_resource, only: [:edit, :update, :show, :destroy]
|
10
12
|
before_action :build_resource, only: [:new, :create]
|
13
|
+
before_action :search_resources, only: :index
|
11
14
|
before_action :authorize
|
12
15
|
|
13
16
|
helper_method :resource_name,
|
@@ -15,6 +18,7 @@ module Admini
|
|
15
18
|
:new_attributes,
|
16
19
|
:edit_attributes,
|
17
20
|
:show_attributes,
|
21
|
+
:search_attributes,
|
18
22
|
:enum_attributes,
|
19
23
|
:can_create?,
|
20
24
|
:can_read?,
|
@@ -22,12 +26,16 @@ module Admini
|
|
22
26
|
:can_delete?,
|
23
27
|
:enable_action?,
|
24
28
|
:render_attribute,
|
25
|
-
:resource_object
|
29
|
+
:resource_object,
|
30
|
+
:search_options
|
26
31
|
|
27
32
|
layout 'admini/layouts/application'
|
28
33
|
end
|
29
34
|
|
30
35
|
def index
|
36
|
+
@resources = @resources.order(id: :desc)
|
37
|
+
.page(params[:page])
|
38
|
+
.per(paginates_per)
|
31
39
|
end
|
32
40
|
|
33
41
|
def new
|
@@ -71,9 +79,7 @@ module Admini
|
|
71
79
|
end
|
72
80
|
|
73
81
|
def resources
|
74
|
-
@resources ||= resource_class.
|
75
|
-
.page(params[:page])
|
76
|
-
.per(paginates_per)
|
82
|
+
@resources ||= resource_class.all
|
77
83
|
end
|
78
84
|
alias_method :load_resources, :resources
|
79
85
|
|
@@ -101,6 +107,13 @@ module Admini
|
|
101
107
|
params.require(resource_name).permit(attributes)
|
102
108
|
end
|
103
109
|
|
110
|
+
def search_resources
|
111
|
+
unless search_attributes.include?(params[:attribute].try(:to_sym))
|
112
|
+
return
|
113
|
+
end
|
114
|
+
@resources = @resources.where("#{params[:attribute]} LIKE ?", "%#{params[:value]}%")
|
115
|
+
end
|
116
|
+
|
104
117
|
def index_attributes
|
105
118
|
%i(id created_at updated_at)
|
106
119
|
end
|
@@ -117,6 +130,10 @@ module Admini
|
|
117
130
|
new_attributes
|
118
131
|
end
|
119
132
|
|
133
|
+
def search_attributes
|
134
|
+
%i()
|
135
|
+
end
|
136
|
+
|
120
137
|
def enum_attributes
|
121
138
|
%i()
|
122
139
|
end
|
@@ -188,6 +205,14 @@ module Admini
|
|
188
205
|
end
|
189
206
|
end
|
190
207
|
|
208
|
+
def search_options
|
209
|
+
options = []
|
210
|
+
search_attributes.each do |attribute|
|
211
|
+
options << [t("activerecord.attributes.#{resource_name}.#{attribute}"), attribute]
|
212
|
+
end
|
213
|
+
options_for_select(options)
|
214
|
+
end
|
215
|
+
|
191
216
|
def paginates_per
|
192
217
|
defined?(super) ? super : 25
|
193
218
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<div class="nav">
|
2
|
-
<div class="container">
|
2
|
+
<div class="container clearfix">
|
3
3
|
<%= render 'admini/shared/links/index' %>
|
4
4
|
<%= render 'admini/shared/links/new' %>
|
5
5
|
<% if action_name.in?(%w(show edit update)) %>
|
@@ -7,5 +7,8 @@
|
|
7
7
|
<%= render partial: 'admini/shared/links/edit', locals: { resource: @resource } %>
|
8
8
|
<%= render partial: 'admini/shared/links/delete', locals: { resource: @resource } %>
|
9
9
|
<% end %>
|
10
|
+
<div class="right">
|
11
|
+
<%= render 'admini/layouts/search' %>
|
12
|
+
</div>
|
10
13
|
</div>
|
11
14
|
</div>
|
data/lib/admini/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: admini
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kami
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -97,6 +97,7 @@ files:
|
|
97
97
|
- app/controllers/concerns/admini/resources.rb
|
98
98
|
- app/views/admini/layouts/_header.html.erb
|
99
99
|
- app/views/admini/layouts/_nav.html.erb
|
100
|
+
- app/views/admini/layouts/_search.html.erb
|
100
101
|
- app/views/admini/layouts/application.html.erb
|
101
102
|
- app/views/admini/resources/_form.html.erb
|
102
103
|
- app/views/admini/resources/edit.html.erb
|