administrate 0.0.12 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of administrate might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/assets/images/administrate/dropdown.svg +3 -0
- data/app/assets/javascripts/administrate/components/_search.js +2 -1
- data/app/assets/javascripts/administrate/components/has_many_form.js +1 -1
- data/app/assets/stylesheets/administrate/application.scss +0 -1
- data/app/assets/stylesheets/administrate/base/_forms.scss +3 -3
- data/app/assets/stylesheets/administrate/base/_lists.scss +7 -7
- data/app/assets/stylesheets/administrate/base/_variables.scss +3 -0
- data/app/assets/stylesheets/administrate/components/_attributes.scss +13 -0
- data/app/assets/stylesheets/administrate/components/_cells.scss +2 -8
- data/app/assets/stylesheets/administrate/components/_form.scss +32 -25
- data/app/assets/stylesheets/administrate/components/_header.scss +1 -1
- data/app/assets/stylesheets/administrate/components/_search.scss +1 -1
- data/app/assets/stylesheets/administrate/components/_table.scss +4 -0
- data/app/assets/stylesheets/administrate/mixins/_data_label.scss +8 -0
- data/app/assets/stylesheets/administrate/mixins/_mixins.scss +1 -0
- data/app/controllers/administrate/application_controller.rb +35 -38
- data/app/views/administrate/application/{_table.html.erb → _collection.html.erb} +26 -6
- data/app/views/administrate/application/_flashes.html.erb +13 -0
- data/app/views/administrate/application/_form.html.erb +23 -7
- data/app/views/administrate/application/_javascript.html.erb +9 -0
- data/app/views/administrate/application/_sidebar.html.erb +9 -0
- data/app/views/administrate/application/edit.html.erb +22 -3
- data/app/views/administrate/application/index.html.erb +31 -6
- data/app/views/administrate/application/new.html.erb +22 -3
- data/app/views/administrate/application/show.html.erb +24 -4
- data/app/views/fields/belongs_to/_form.html.erb +18 -0
- data/app/views/fields/belongs_to/_index.html.erb +17 -0
- data/app/views/fields/belongs_to/_show.html.erb +17 -0
- data/app/views/fields/boolean/_form.html.erb +17 -0
- data/app/views/fields/boolean/_index.html.erb +19 -1
- data/app/views/fields/boolean/_show.html.erb +19 -1
- data/app/views/fields/date_time/_form.html.erb +18 -0
- data/app/views/fields/date_time/_index.html.erb +18 -0
- data/app/views/fields/date_time/_show.html.erb +18 -0
- data/app/views/fields/email/_form.html.erb +17 -0
- data/app/views/fields/email/_index.html.erb +17 -0
- data/app/views/fields/email/_show.html.erb +17 -0
- data/app/views/fields/has_many/_form.html.erb +21 -0
- data/app/views/fields/has_many/_index.html.erb +18 -0
- data/app/views/fields/has_many/_show.html.erb +33 -3
- data/app/views/fields/has_one/_form.html.erb +21 -1
- data/app/views/fields/has_one/_index.html.erb +17 -0
- data/app/views/fields/has_one/_show.html.erb +17 -0
- data/app/views/fields/image/_form.html.erb +17 -0
- data/app/views/fields/image/_index.html.erb +17 -0
- data/app/views/fields/image/_show.html.erb +17 -0
- data/app/views/fields/number/_form.html.erb +17 -0
- data/app/views/fields/number/_index.html.erb +19 -1
- data/app/views/fields/number/_show.html.erb +19 -1
- data/app/views/fields/polymorphic/_form.html.erb +20 -0
- data/app/views/fields/polymorphic/_index.html.erb +18 -0
- data/app/views/fields/polymorphic/_show.html.erb +18 -0
- data/app/views/fields/string/_form.html.erb +17 -0
- data/app/views/fields/string/_index.html.erb +17 -0
- data/app/views/fields/string/_show.html.erb +17 -0
- data/app/views/fields/text/_form.html.erb +2 -0
- data/app/views/fields/text/_index.html.erb +1 -0
- data/app/views/fields/text/_show.html.erb +1 -0
- data/app/views/layouts/administrate/application.html.erb +15 -1
- data/config/locales/administrate.en.yml +14 -10
- data/lib/administrate/base_dashboard.rb +3 -2
- data/lib/administrate/engine.rb +1 -1
- data/lib/administrate/fields/has_many.rb +7 -3
- data/lib/administrate/fields/text.rb +21 -0
- data/lib/administrate/page/{table.rb → collection.rb} +2 -6
- data/lib/administrate/version.rb +1 -1
- data/lib/administrate/view_generator.rb +27 -0
- data/lib/generators/administrate/dashboard/dashboard_generator.rb +7 -1
- data/lib/generators/administrate/dashboard/templates/dashboard.rb.erb +16 -10
- data/lib/generators/administrate/field/field_generator.rb +31 -0
- data/lib/generators/administrate/field/templates/_form.html.erb +2 -0
- data/lib/generators/administrate/field/templates/_index.html.erb +1 -0
- data/lib/generators/administrate/field/templates/_show.html.erb +1 -0
- data/lib/generators/administrate/field/templates/field_object.rb.erb +7 -0
- data/lib/generators/administrate/views/edit_generator.rb +16 -0
- data/lib/generators/administrate/views/field_generator.rb +36 -0
- data/lib/generators/administrate/views/form_generator.rb +15 -0
- data/lib/generators/administrate/views/index_generator.rb +16 -0
- data/lib/generators/administrate/views/new_generator.rb +16 -0
- data/lib/generators/administrate/views/show_generator.rb +15 -0
- data/lib/generators/administrate/views/views_generator.rb +14 -0
- metadata +33 -15
- data/app/assets/stylesheets/administrate/_show.sass +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a63c6085034ba4b3ee39b90cd213593fbca55347
|
4
|
+
data.tar.gz: 3e4091678fda4953de68374a61c49f45573d843c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 232a793a6aad5135c044d957297f5850078fa4bfbf5e3e100a851a0efc4d3ec5ff0392eb9bcc85a99ea6e1b5480ef8c233ab1454913f95ccccf8271b4dc83902
|
7
|
+
data.tar.gz: e66a04e628f6a1afa97be1784a33deedb3baf782075279efbc2dcecf0a2d71eb3b5f7aed2d72845c4b6c54d6ce571e5838011925fb5bac3d4fd2546a4eb1fce9
|
@@ -7,7 +7,8 @@ $(function() {
|
|
7
7
|
|
8
8
|
$.fn.textWidth = function(text, font) {
|
9
9
|
if (!$.fn.textWidth.fakeEl) {
|
10
|
-
$.fn.textWidth.fakeEl = $(
|
10
|
+
$.fn.textWidth.fakeEl = $('<span style="display: none;">')
|
11
|
+
.appendTo(document.body);
|
11
12
|
}
|
12
13
|
|
13
14
|
var htmlText = text || this.val() || this.text();
|
@@ -36,8 +36,8 @@ select {
|
|
36
36
|
box-sizing: border-box;
|
37
37
|
font-family: $form-font-family;
|
38
38
|
font-size: $form-font-size;
|
39
|
-
margin-bottom: $
|
40
|
-
padding:
|
39
|
+
margin-bottom: $small-spacing;
|
40
|
+
padding: $form-input-padding;
|
41
41
|
transition: border-color;
|
42
42
|
width: 100%;
|
43
43
|
|
@@ -77,6 +77,6 @@ input[type="file"] {
|
|
77
77
|
|
78
78
|
select {
|
79
79
|
appearance: none;
|
80
|
-
background: image-url("dropdown.svg") no-repeat 97% 50% / 10px;
|
80
|
+
background: image-url("administrate/dropdown.svg") no-repeat 97% 50% / 10px;
|
81
81
|
margin-bottom: $base-spacing;
|
82
82
|
}
|
@@ -19,13 +19,13 @@ ol {
|
|
19
19
|
|
20
20
|
dl {
|
21
21
|
margin-bottom: $base-spacing / 2;
|
22
|
+
}
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
dt {
|
25
|
+
font-weight: bold;
|
26
|
+
margin-top: $base-spacing / 2;
|
27
|
+
}
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
}
|
29
|
+
dd {
|
30
|
+
margin: 0;
|
31
31
|
}
|
@@ -28,6 +28,7 @@ $base-border-radius: 3px;
|
|
28
28
|
$base-spacing: $base-line-height * 1em;
|
29
29
|
$base-z-index: 0;
|
30
30
|
$small-spacing: $base-spacing / 2;
|
31
|
+
$table-image-height: 2em;
|
31
32
|
|
32
33
|
// Transitions
|
33
34
|
$base-easing: cubic-bezier(0.215, 0.610, 0.355, 1);
|
@@ -101,3 +102,5 @@ $form-box-shadow: inset 0 1px 3px rgba(black,0.06);
|
|
101
102
|
$form-box-shadow-focus: $form-box-shadow, 0 0 5px rgba(darken($form-border-color-focus, 5), 0.7);
|
102
103
|
$form-font-size: $base-font-size;
|
103
104
|
$form-font-family: $base-font-family;
|
105
|
+
|
106
|
+
$form-input-padding: $base-spacing / 3;
|
@@ -1,3 +1,16 @@
|
|
1
|
+
.attribute-label {
|
2
|
+
@include data-label;
|
3
|
+
@include span-columns(2 of 12);
|
4
|
+
margin-top: 0;
|
5
|
+
text-align: right;
|
6
|
+
}
|
7
|
+
|
1
8
|
.attribute-data--string {
|
2
9
|
white-space: pre;
|
3
10
|
}
|
11
|
+
|
12
|
+
.attribute-data {
|
13
|
+
@include span-columns(10 of 12);
|
14
|
+
@include omega;
|
15
|
+
margin-bottom: $base-spacing;
|
16
|
+
}
|
@@ -1,11 +1,5 @@
|
|
1
|
-
.cell-label
|
2
|
-
|
3
|
-
color: $hint-grey;
|
4
|
-
font-size: $small-font-size;
|
5
|
-
font-weight: $normal-font-weight;
|
6
|
-
letter-spacing: 0.0357em;
|
7
|
-
position: relative;
|
8
|
-
text-transform: uppercase;
|
1
|
+
.cell-label {
|
2
|
+
@include data-label;
|
9
3
|
|
10
4
|
a {
|
11
5
|
@include fill-parent;
|
@@ -1,33 +1,40 @@
|
|
1
|
-
.form {
|
2
|
-
|
3
|
-
|
1
|
+
.form-actions {
|
2
|
+
@include shift(2);
|
3
|
+
}
|
4
|
+
|
5
|
+
.form-field {
|
6
|
+
@include clearfix;
|
7
|
+
@include fill-parent;
|
8
|
+
align-items: baseline;
|
9
|
+
width: 100%;
|
10
|
+
|
11
|
+
label {
|
12
|
+
@include data-label;
|
13
|
+
@include span-columns(2 of 12);
|
14
|
+
padding: $form-input-padding 0;
|
15
|
+
text-align: right;
|
4
16
|
}
|
5
17
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
18
|
+
#{$all-text-inputs},
|
19
|
+
select,
|
20
|
+
textarea,
|
21
|
+
.selectize-control {
|
22
|
+
background-color: $form-field-background-color;
|
23
|
+
margin-bottom: $base-spacing;
|
10
24
|
}
|
11
25
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
width: 100%;
|
26
|
+
input,
|
27
|
+
select,
|
28
|
+
.selectize-control {
|
29
|
+
@include span-columns(4 of 12);
|
30
|
+
}
|
18
31
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
width: 10em;
|
23
|
-
}
|
32
|
+
textarea {
|
33
|
+
@include span-columns(6 of 12);
|
34
|
+
}
|
24
35
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
background-color: $form-field-background-color;
|
29
|
-
max-width: 30em;
|
30
|
-
width: 30em;
|
31
|
-
}
|
36
|
+
[type="checkbox"],
|
37
|
+
[type="radio"] {
|
38
|
+
margin: $small-spacing 0 ($base-spacing + $form-input-padding);
|
32
39
|
}
|
33
40
|
}
|
@@ -1,31 +1,39 @@
|
|
1
1
|
module Administrate
|
2
2
|
class ApplicationController < ActionController::Base
|
3
3
|
def index
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
search_term = params[:search].to_s.strip
|
5
|
+
resources = Administrate::Search.new(resource_resolver, search_term).run
|
6
|
+
resources = order.apply(resources)
|
7
|
+
resources = resources.page(params[:page]).per(records_per_page)
|
8
|
+
page = Administrate::Page::Collection.new(dashboard, order: order)
|
9
|
+
|
10
|
+
render locals: {
|
11
|
+
resources: resources.page(params[:page]).per(records_per_page),
|
12
|
+
search_term: search_term,
|
13
|
+
page: page,
|
14
|
+
}
|
9
15
|
end
|
10
16
|
|
11
17
|
def show
|
12
|
-
|
13
|
-
|
14
|
-
|
18
|
+
render locals: {
|
19
|
+
page: Administrate::Page::Show.new(dashboard, requested_resource),
|
20
|
+
}
|
15
21
|
end
|
16
22
|
|
17
23
|
def new
|
18
|
-
|
24
|
+
render locals: {
|
25
|
+
page: Administrate::Page::Form.new(dashboard, resource_class.new),
|
26
|
+
}
|
19
27
|
end
|
20
28
|
|
21
29
|
def edit
|
22
|
-
|
23
|
-
|
24
|
-
|
30
|
+
render locals: {
|
31
|
+
page: Administrate::Page::Form.new(dashboard, requested_resource),
|
32
|
+
}
|
25
33
|
end
|
26
34
|
|
27
35
|
def create
|
28
|
-
|
36
|
+
resource = resource_class.new(resource_params)
|
29
37
|
|
30
38
|
if resource.save
|
31
39
|
redirect_to(
|
@@ -33,29 +41,27 @@ module Administrate
|
|
33
41
|
notice: translate("create.success"),
|
34
42
|
)
|
35
43
|
else
|
36
|
-
|
37
|
-
|
44
|
+
render :new, locals: {
|
45
|
+
page: Administrate::Page::Form.new(dashboard, resource),
|
46
|
+
}
|
38
47
|
end
|
39
48
|
end
|
40
49
|
|
41
50
|
def update
|
42
|
-
|
43
|
-
|
44
|
-
if resource.update(resource_params)
|
51
|
+
if requested_resource.update(resource_params)
|
45
52
|
redirect_to(
|
46
|
-
[Administrate::NAMESPACE,
|
53
|
+
[Administrate::NAMESPACE, requested_resource],
|
47
54
|
notice: translate("update.success"),
|
48
55
|
)
|
49
56
|
else
|
50
|
-
|
51
|
-
|
57
|
+
render :edit, locals: {
|
58
|
+
page: Administrate::Page::Form.new(dashboard, requested_resource),
|
59
|
+
}
|
52
60
|
end
|
53
61
|
end
|
54
62
|
|
55
63
|
def destroy
|
56
|
-
|
57
|
-
|
58
|
-
resource.destroy
|
64
|
+
requested_resource.destroy
|
59
65
|
flash[:notice] = translate("destroy.success")
|
60
66
|
redirect_to action: :index
|
61
67
|
end
|
@@ -76,26 +82,21 @@ module Administrate
|
|
76
82
|
end
|
77
83
|
|
78
84
|
def order
|
79
|
-
@
|
85
|
+
@_order ||= Administrate::Order.new(params[:order], params[:direction])
|
80
86
|
end
|
81
87
|
|
82
88
|
def dashboard
|
83
|
-
@
|
89
|
+
@_dashboard ||= resource_resolver.dashboard_class.new
|
84
90
|
end
|
85
91
|
|
86
|
-
def
|
87
|
-
|
88
|
-
instance_variable_set(instance_variable, resource)
|
92
|
+
def requested_resource
|
93
|
+
@_requested_resource ||= find_resource(params[:id])
|
89
94
|
end
|
90
95
|
|
91
96
|
def find_resource(param)
|
92
97
|
resource_class.find(param)
|
93
98
|
end
|
94
99
|
|
95
|
-
def resource
|
96
|
-
instance_variable_get(instance_variable)
|
97
|
-
end
|
98
|
-
|
99
100
|
def resource_params
|
100
101
|
params.require(resource_name).permit(*permitted_attributes)
|
101
102
|
end
|
@@ -104,14 +105,10 @@ module Administrate
|
|
104
105
|
dashboard.permitted_attributes
|
105
106
|
end
|
106
107
|
|
107
|
-
def instance_variable
|
108
|
-
"@#{resource_name}"
|
109
|
-
end
|
110
|
-
|
111
108
|
delegate :resource_class, :resource_name, to: :resource_resolver
|
112
109
|
|
113
110
|
def resource_resolver
|
114
|
-
@
|
111
|
+
@_resource_resolver ||=
|
115
112
|
Administrate::ResourceResolver.new(controller_path)
|
116
113
|
end
|
117
114
|
|
@@ -1,17 +1,37 @@
|
|
1
|
+
<%#
|
2
|
+
# Table
|
3
|
+
|
4
|
+
This partial is used on the `index` and `show` pages
|
5
|
+
to display a collection of resources in an HTML table.
|
6
|
+
|
7
|
+
## Local variables:
|
8
|
+
|
9
|
+
- `table_presenter`:
|
10
|
+
An instance of [Administrate::Page::Table][1].
|
11
|
+
The table presenter uses `ResourceDashboard::TABLE_ATTRIBUTES` to determine
|
12
|
+
the columns displayed in the table
|
13
|
+
- `resources`:
|
14
|
+
An ActiveModel::Relation collection of resources to be displayed in the table.
|
15
|
+
By default, the number of resources is limited by pagination
|
16
|
+
or by a hard limit to prevent excessive page load times
|
17
|
+
|
18
|
+
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Table
|
19
|
+
%>
|
20
|
+
|
1
21
|
<table>
|
2
22
|
<thead>
|
3
23
|
<tr>
|
4
|
-
<%
|
24
|
+
<% collection_presenter.attribute_types.each do |attr_name, attr_type| %>
|
5
25
|
<th class="cell-label cell-label--<%= attr_type.html_class %>
|
6
|
-
cell-label--<%=
|
26
|
+
cell-label--<%= collection_presenter.ordered_html_class(attr_name) %>
|
7
27
|
">
|
8
28
|
<%= link_to(params.merge(
|
9
|
-
|
29
|
+
collection_presenter.order_params_for(attr_name)
|
10
30
|
)) do %>
|
11
31
|
<%= attr_name.to_s.titleize %>
|
12
32
|
|
13
|
-
<% if
|
14
|
-
<span class="cell-label__sort-indicator cell-label__sort-indicator--<%=
|
33
|
+
<% if collection_presenter.ordered_by?(attr_name) %>
|
34
|
+
<span class="cell-label__sort-indicator cell-label__sort-indicator--<%= collection_presenter.ordered_html_class(attr_name) %>">
|
15
35
|
<%= inline_svg("administrate/sort_arrow.svg") %>
|
16
36
|
</span>
|
17
37
|
<% end %>
|
@@ -29,7 +49,7 @@
|
|
29
49
|
tabindex="0"
|
30
50
|
data-url="<%= polymorphic_path([Administrate::NAMESPACE, resource]) -%>"
|
31
51
|
>
|
32
|
-
<%
|
52
|
+
<% collection_presenter.attributes_for(resource).each do |attribute| %>
|
33
53
|
<td class="cell-data cell-data--<%= attribute.html_class %>">
|
34
54
|
<%= render_field attribute %>
|
35
55
|
</td>
|
@@ -1,3 +1,16 @@
|
|
1
|
+
<%#
|
2
|
+
# Flash Partial
|
3
|
+
|
4
|
+
This partial renders flash messages on every page.
|
5
|
+
|
6
|
+
## Relevant Helpers:
|
7
|
+
|
8
|
+
- `flash`:
|
9
|
+
Returns a hash,
|
10
|
+
where the keys are the type of flash (alert, error, notice, etc)
|
11
|
+
and the values are the message to be displayed.
|
12
|
+
%>
|
13
|
+
|
1
14
|
<% if flash.any? %>
|
2
15
|
<div id="flashes">
|
3
16
|
<% flash.each do |key, value| -%>
|