cambium 1.1.6 → 1.2.0
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/README.md +5 -0
- data/app/assets/javascripts/cambium/admin/application.js.coffee +1 -1
- data/app/assets/stylesheets/cambium/admin/partials/components.scss +2 -1
- data/app/assets/stylesheets/cambium/admin/partials/forms.scss +6 -0
- data/app/assets/stylesheets/cambium/admin/partials/page_title.scss +6 -2
- data/app/controllers/cambium/admin_controller.rb +17 -4
- data/app/helpers/cambium/cambium_helper.rb +26 -2
- data/app/presenters/cambium/admin_presenter.rb +1 -0
- data/lib/cambium/version.rb +1 -1
- data/lib/generators/templates/config/admin/controller.yml.erb +2 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc213f76b0bfb1bc7f89557007412022d32f0c37
|
4
|
+
data.tar.gz: a02c79d2cbf1b519942703e3a57d246ca97f7cb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28daeea78d3becc708ed681e5e933fa6729980382df60d73a51c0d95ce0de5f18f88a42581e4be2fb55a877e42607abbffbca2d6a4dc1c76ce2a176a694cbc53
|
7
|
+
data.tar.gz: 431257c6a35b8f5c630c717697af2fc168f139c0215e0bd9d1db2c4a6d669253630c7c4ac4b04ac641d0fb441e03711ca57138ef6241728a866921c5969aac80
|
data/README.md
CHANGED
@@ -224,6 +224,8 @@ export:
|
|
224
224
|
email:
|
225
225
|
label: Email
|
226
226
|
form:
|
227
|
+
buttons:
|
228
|
+
delete: Delete User
|
227
229
|
new: &new
|
228
230
|
title: New User
|
229
231
|
fields:
|
@@ -265,6 +267,9 @@ Every setting plays a role. Let's step through each one.
|
|
265
267
|
* `export:columns:[column]:output`: An optional method you can pass to each
|
266
268
|
object to help with display.
|
267
269
|
* `form`: Settings for the form.
|
270
|
+
* `form:buttons:delete`: Label for the delete button. If you remove `delete`
|
271
|
+
entirely, then no delete button will exist (though you'd have to manually
|
272
|
+
remove the route from your routes file).
|
268
273
|
* `form:[new/edit]`: New is the defaut, and most of the time Edit will inherit
|
269
274
|
from new (the `<<: *new` is what handles that). But you can optionally
|
270
275
|
override new values for your edit form.
|
@@ -38,7 +38,7 @@ div.status{
|
|
38
38
|
}
|
39
39
|
|
40
40
|
a {
|
41
|
-
&.new, &.export, &.file {
|
41
|
+
&.new, &.export, &.file, &.delete {
|
42
42
|
&:before {
|
43
43
|
font-family: 'icomoon';
|
44
44
|
font-size: inherit;
|
@@ -48,6 +48,7 @@ a {
|
|
48
48
|
}
|
49
49
|
&.new:before { content: "\e702"; }
|
50
50
|
&.export:before { content: "\e65e"; }
|
51
|
+
&.delete:before { content: "\e6a7"; }
|
51
52
|
&.file:before { content: "\e622"; }
|
52
53
|
}
|
53
54
|
|
@@ -24,7 +24,7 @@
|
|
24
24
|
font-weight: 400;
|
25
25
|
color: $color-dark;
|
26
26
|
vertical-align: top;
|
27
|
-
&.new, &.export {
|
27
|
+
&.new, &.export, &.delete {
|
28
28
|
margin: 12px 0 0 10px;
|
29
29
|
padding: 3px 8px;
|
30
30
|
font-size: 13px;
|
@@ -35,7 +35,11 @@
|
|
35
35
|
&.new {
|
36
36
|
background: $color-2;
|
37
37
|
}
|
38
|
-
&.
|
38
|
+
&.delete {
|
39
|
+
background: $color-danger;
|
40
|
+
color: $color-light;
|
41
|
+
}
|
42
|
+
&.export, &.delete {
|
39
43
|
float: right;
|
40
44
|
}
|
41
45
|
}
|
@@ -9,12 +9,19 @@ class Cambium::AdminController < Cambium::BaseController
|
|
9
9
|
|
10
10
|
def index
|
11
11
|
respond_to do |format|
|
12
|
-
|
12
|
+
scope = admin_table.scope
|
13
|
+
if scope.split('.').size > 1
|
14
|
+
@collection = admin_model
|
15
|
+
scope.split('.').each do |s|
|
16
|
+
@collection = @collection.send(s)
|
17
|
+
end
|
18
|
+
else
|
13
19
|
@collection = admin_model.send(admin_table.scope)
|
14
|
-
|
20
|
+
end
|
21
|
+
format.html do
|
22
|
+
@collection = @collection.page(params[:page] || 1).per(15)
|
15
23
|
end
|
16
24
|
format.csv do
|
17
|
-
@collection = admin_model.send(admin_table.scope)
|
18
25
|
send_data admin.to_csv(@collection)
|
19
26
|
end
|
20
27
|
end
|
@@ -30,7 +37,6 @@ class Cambium::AdminController < Cambium::BaseController
|
|
30
37
|
end
|
31
38
|
|
32
39
|
def create
|
33
|
-
set_object
|
34
40
|
@object = admin_model.new(create_params)
|
35
41
|
if @object.save
|
36
42
|
redirect_to(admin_routes.index, :notice => "#{admin_model.to_s} created!")
|
@@ -52,6 +58,12 @@ class Cambium::AdminController < Cambium::BaseController
|
|
52
58
|
end
|
53
59
|
end
|
54
60
|
|
61
|
+
def destroy
|
62
|
+
set_object
|
63
|
+
@object.destroy
|
64
|
+
redirect_to(admin_routes.index, :notice => "#{admin_model.to_s} deleted!")
|
65
|
+
end
|
66
|
+
|
55
67
|
private
|
56
68
|
|
57
69
|
def set_object
|
@@ -62,6 +74,7 @@ class Cambium::AdminController < Cambium::BaseController
|
|
62
74
|
id = params[:"#{admin_model.to_s.underscore}_id"] || params[:id]
|
63
75
|
@object = admin_model.find_by_id(id.to_i)
|
64
76
|
end
|
77
|
+
not_found if @object.nil?
|
65
78
|
@obj = @object
|
66
79
|
end
|
67
80
|
|
@@ -60,6 +60,15 @@ module Cambium
|
|
60
60
|
:class => 'button export'
|
61
61
|
)
|
62
62
|
end
|
63
|
+
if is_edit? && can_delete?
|
64
|
+
o += link_to(
|
65
|
+
admin_view.form.buttons.delete,
|
66
|
+
admin_routes.delete,
|
67
|
+
:class => 'button delete',
|
68
|
+
:method => :delete,
|
69
|
+
:data => { :confirm => 'Are you sure?' }
|
70
|
+
)
|
71
|
+
end
|
63
72
|
o.html_safe
|
64
73
|
end
|
65
74
|
end
|
@@ -131,10 +140,16 @@ module Cambium
|
|
131
140
|
if options.type == 'heading'
|
132
141
|
o += content_tag(:h2, options.label || attr.titleize)
|
133
142
|
elsif ['select','check_boxes','radio_buttons'].include?(options.type)
|
143
|
+
parts = options.options.split('.')
|
144
|
+
if parts.size > 1
|
145
|
+
collection = parts[0].constantize.send(parts[1])
|
146
|
+
else
|
147
|
+
collection = options.options
|
148
|
+
end
|
134
149
|
o += f.input(
|
135
150
|
attr.to_sym,
|
136
151
|
:as => options.type,
|
137
|
-
:collection =>
|
152
|
+
:collection => collection,
|
138
153
|
:label => label,
|
139
154
|
:readonly => readonly
|
140
155
|
)
|
@@ -189,7 +204,7 @@ module Cambium
|
|
189
204
|
end
|
190
205
|
elsif options.type == 'markdown'
|
191
206
|
o += content_tag(:div, :class => "input text optional #{attr}") do
|
192
|
-
o2 = content_tag(:label,
|
207
|
+
o2 = content_tag(:label, label, :for => attr)
|
193
208
|
o2 += content_tag(
|
194
209
|
:div,
|
195
210
|
f.markdown(attr.to_sym),
|
@@ -250,9 +265,18 @@ module Cambium
|
|
250
265
|
action_name == 'index'
|
251
266
|
end
|
252
267
|
|
268
|
+
def is_edit?
|
269
|
+
['edit','update'].include?(action_name)
|
270
|
+
end
|
271
|
+
|
253
272
|
def has_new_form?
|
254
273
|
admin_view.form.present? && admin_view.form.new.present?
|
255
274
|
end
|
256
275
|
|
276
|
+
def can_delete?
|
277
|
+
admin_view.form.present? && admin_view.form.buttons.present? &&
|
278
|
+
admin_view.form.buttons.delete.present?
|
279
|
+
end
|
280
|
+
|
257
281
|
end
|
258
282
|
end
|
data/lib/cambium/version.rb
CHANGED