bootstrap_admin 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/app/assets/images/jquery.checkbox.png +0 -0
- data/app/assets/stylesheets/bootstrap_admin.css +21 -0
- data/app/helpers/bootstrap_admin_helper.rb +36 -4
- data/app/views/defaults/_form.html.haml +2 -2
- data/app/views/defaults/_index.html.haml +1 -2
- data/app/views/defaults/_search_box.html.haml +1 -1
- data/app/views/defaults/index.html.haml +1 -2
- data/app/views/defaults/show.html.haml +1 -3
- data/lib/bootstrap_admin/actions.rb +12 -4
- data/lib/bootstrap_admin/responder.rb +1 -1
- data/lib/bootstrap_admin/version.rb +1 -1
- metadata +3 -2
data/.gitignore
CHANGED
Binary file
|
@@ -5,8 +5,29 @@
|
|
5
5
|
*= require_self
|
6
6
|
*= require_tree .
|
7
7
|
*/
|
8
|
+
|
8
9
|
form.search{
|
9
10
|
float:right;
|
10
11
|
margin-top: -45px;
|
11
12
|
}
|
13
|
+
|
12
14
|
.clear_both{clear:both;}
|
15
|
+
|
16
|
+
|
17
|
+
.checkbox .icon {
|
18
|
+
display: inline-block;
|
19
|
+
width: 16px;
|
20
|
+
height: 16px;
|
21
|
+
background: url(/assets/jquery.checkbox.png) no-repeat blue;
|
22
|
+
}
|
23
|
+
|
24
|
+
.checkbox {
|
25
|
+
display: inline-block; }
|
26
|
+
.checkbox .icon {
|
27
|
+
display: inline-block;
|
28
|
+
width: 16px;
|
29
|
+
height: 16px;
|
30
|
+
background: url(/assets/jquery.checkbox.png) no-repeat; }
|
31
|
+
.checkbox.checked .icon, .checkbox.true .icon {
|
32
|
+
background-position: -16px 0px; }
|
33
|
+
|
@@ -129,31 +129,63 @@ module BootstrapAdminHelper
|
|
129
129
|
bootstrap_admin_config.available_actions
|
130
130
|
end
|
131
131
|
|
132
|
+
|
133
|
+
def bootstrap_url_for options = {}
|
134
|
+
defaults = {:controller => params[:controller]}.merge options
|
135
|
+
url_for(defaults)
|
136
|
+
end
|
137
|
+
alias_method :bootstrap_url, :bootstrap_url_for
|
138
|
+
|
139
|
+
def bootstrap_form_url item
|
140
|
+
[item, :url => bootstrap_url_for(:action => (item.new_record? ? :create : :update), :id => item.id)]
|
141
|
+
end
|
142
|
+
|
132
143
|
# =============================================================================
|
133
144
|
def index_actions_for item
|
134
145
|
actions = []
|
135
146
|
|
136
147
|
if available_actions.include? :show
|
137
|
-
actions << link_to(:show,
|
148
|
+
actions << link_to(:show, bootstrap_url_for(:action => :show, :id => item.id), class: 'btn')
|
138
149
|
end
|
139
150
|
|
140
151
|
if available_actions.include? :edit
|
141
|
-
actions << link_to(:edit,
|
152
|
+
actions << link_to(:edit, bootstrap_url_for(:action => :edit, :id => item.id), class: 'btn')
|
142
153
|
end
|
143
154
|
|
144
155
|
if available_actions.include? :destroy
|
145
|
-
actions << link_to(:destroy,
|
156
|
+
actions << link_to(:destroy, bootstrap_url_for(:action => :show, :id => item.id), confirm: t(:confirm), method: :delete, class: 'btn btn-danger')
|
146
157
|
end
|
147
158
|
|
148
159
|
actions.join("\n").html_safe
|
149
160
|
end
|
150
161
|
|
162
|
+
# =====
|
163
|
+
def index_default_actions
|
164
|
+
if available_actions.include? :new
|
165
|
+
model_klass = model_for controller
|
166
|
+
link_to([:new, model_klass], bootstrap_url_for(:action => :new), :class => 'btn btn-primary').html_safe
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
def show_default_actions
|
171
|
+
model_instance = model_instance_for controller
|
172
|
+
str = if available_actions.include? :edit
|
173
|
+
link_to :edit, bootstrap_url_for(:action => :edit, :id => model_instance.id), :class => 'btn'
|
174
|
+
end || ""
|
175
|
+
str += link_to :back, bootstrap_url, :class => 'btn'
|
176
|
+
str.html_safe
|
177
|
+
end
|
178
|
+
|
151
179
|
|
152
180
|
# =============================================================================
|
153
181
|
# @param controller [ActionController::Base]
|
154
182
|
# @return [Class] the model class for the current controller
|
155
183
|
def model_for controller
|
156
|
-
|
184
|
+
if bootstrap_admin_config.model_name.blank?
|
185
|
+
collection_name_for(controller).classify.constantize
|
186
|
+
else
|
187
|
+
bootstrap_admin_config.model_name.constantize
|
188
|
+
end
|
157
189
|
end
|
158
190
|
|
159
191
|
# =============================================================================
|
@@ -1,9 +1,9 @@
|
|
1
1
|
- model_instance = model_instance_for(controller)
|
2
|
-
= simple_form_for
|
2
|
+
= simple_form_for *bootstrap_form_url(model_instance) do |f|
|
3
3
|
= f.error_notification
|
4
4
|
|
5
5
|
= render "form_fields", :form => f
|
6
6
|
|
7
7
|
.actions
|
8
8
|
= yield :actions
|
9
|
-
= link_to :back,
|
9
|
+
= link_to :back, bootstrap_url, :class => 'btn'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
= form_tag
|
1
|
+
= form_tag bootstrap_url, :method => :get, :class=>"search bootstrap_admin" do
|
2
2
|
.input-append{:class => params[:q].blank? ? "" : "input-prepend"}
|
3
3
|
- unless params[:q].blank?
|
4
4
|
.add-on.prepend.btn.reset= image_tag "cross.gif"
|
@@ -6,6 +6,4 @@
|
|
6
6
|
= render "show"
|
7
7
|
|
8
8
|
.actions
|
9
|
-
|
10
|
-
= link_to :edit, [:edit, BootstrapAdmin.admin_namespace, model_instance], :class => 'btn'
|
11
|
-
= link_to :back, [BootstrapAdmin.admin_namespace, collection_name], :class => 'btn'
|
9
|
+
= show_default_actions
|
@@ -28,7 +28,7 @@ module BootstrapAdmin
|
|
28
28
|
# =============================================================================
|
29
29
|
# Creates a new item
|
30
30
|
def create
|
31
|
-
instance model_class.
|
31
|
+
instance model_class.new(params[model_name])
|
32
32
|
instance.save
|
33
33
|
namespaced_response instance
|
34
34
|
end
|
@@ -58,14 +58,18 @@ module BootstrapAdmin
|
|
58
58
|
if bootstrap_admin_config.model_name.blank?
|
59
59
|
collection_name.singularize
|
60
60
|
else
|
61
|
-
bootstrap_admin_config.model_name
|
61
|
+
bootstrap_admin_config.model_name.underscore.gsub("/","_")
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
65
|
# =============================================================================
|
66
66
|
# @return [ActiveRecord::Base] model class based on the controller's name
|
67
67
|
def model_class
|
68
|
-
model_name.
|
68
|
+
if bootstrap_admin_config.model_name.blank?
|
69
|
+
collection_name.singularize.classify.constantize
|
70
|
+
else
|
71
|
+
bootstrap_admin_config.model_name.constantize
|
72
|
+
end
|
69
73
|
end
|
70
74
|
|
71
75
|
# =============================================================================
|
@@ -75,7 +79,11 @@ module BootstrapAdmin
|
|
75
79
|
instance_variable_set "@#{collection_name.singularize}", instance_var
|
76
80
|
else
|
77
81
|
unless ivar = instance_variable_get("@#{collection_name.singularize}")
|
78
|
-
ivar =
|
82
|
+
ivar = if ["new", "create"].include? params[:action]
|
83
|
+
model_class.new
|
84
|
+
else
|
85
|
+
model_class.find params[:id]
|
86
|
+
end
|
79
87
|
instance_variable_set "@#{collection_name.singularize}", ivar
|
80
88
|
end
|
81
89
|
ivar
|
@@ -29,7 +29,7 @@ module BootstrapAdmin
|
|
29
29
|
'helpers.messages.update.success'
|
30
30
|
end
|
31
31
|
controller.flash[:success] = I18n.t(message, :model => resource.class.model_name.human)
|
32
|
-
redirect_to
|
32
|
+
redirect_to :controller => controller.controller_name, :action => :show, :id => resource.id
|
33
33
|
|
34
34
|
else
|
35
35
|
if delete?
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootstrap_admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-05-
|
13
|
+
date: 2013-05-20 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -106,6 +106,7 @@ files:
|
|
106
106
|
- README.md
|
107
107
|
- Rakefile
|
108
108
|
- app/assets/images/cross.gif
|
109
|
+
- app/assets/images/jquery.checkbox.png
|
109
110
|
- app/assets/images/search_btn.png
|
110
111
|
- app/assets/javascripts/bootstrap_admin.js
|
111
112
|
- app/assets/javascripts/bootstrap_admin/bootstrap_admin.js.coffee
|