sferik-merb-admin 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +2 -4
- data/Rakefile +1 -1
- data/app/controllers/forms.rb +18 -2
- data/app/helpers/application_helper.rb +0 -2
- data/app/helpers/forms_helper.rb +2 -0
- data/app/views/forms/delete.html.erb +1 -1
- data/app/views/forms/edit.html.erb +6 -2
- data/app/views/forms/index.html.erb +12 -4
- data/app/views/forms/list.html.erb +39 -3
- data/app/views/layout/dashboard.html.erb +1 -1
- data/app/views/layout/form.html.erb +3 -3
- data/app/views/layout/list.html.erb +2 -2
- data/lib/merb-admin.rb +1 -1
- metadata +2 -2
data/README.markdown
CHANGED
@@ -8,15 +8,13 @@ It currently offers the features listed [here](http://sferik.tadalist.com/lists/
|
|
8
8
|
|
9
9
|
At the command prompt, type:
|
10
10
|
|
11
|
-
|
12
|
-
cd merb-admin
|
13
|
-
sudo rake install
|
11
|
+
sudo gem install sferik-merb-admin -s http://gems.github.com
|
14
12
|
|
15
13
|
## Install it
|
16
14
|
|
17
15
|
In your app, add the following dependency to `config/dependencies.rb`:
|
18
16
|
|
19
|
-
dependency "merb-admin", "0.1.
|
17
|
+
dependency "sferik-merb-admin", "0.1.8", :require_as => "merb-admin"
|
20
18
|
|
21
19
|
Add the following route to `config/router.rb`:
|
22
20
|
|
data/Rakefile
CHANGED
@@ -12,7 +12,7 @@ AUTHOR = "Erik Michaels-Ober"
|
|
12
12
|
EMAIL = "sferik@gmail.com"
|
13
13
|
HOMEPAGE = "http://twitter.com/sferik"
|
14
14
|
SUMMARY = "MerbAdmin is a merb slice that provides an easy-to-use interface for managing your data."
|
15
|
-
GEM_VERSION = "0.1.
|
15
|
+
GEM_VERSION = "0.1.8"
|
16
16
|
|
17
17
|
spec = Gem::Specification.new do |s|
|
18
18
|
s.rubyforge_project = "merb"
|
data/app/controllers/forms.rb
CHANGED
@@ -9,13 +9,29 @@ class MerbAdmin::Forms < MerbAdmin::Application
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def list
|
12
|
+
options = {}
|
13
|
+
filters = params[:filter] || {}
|
14
|
+
filters.each_pair do |key, value|
|
15
|
+
if @model.properties[key].primitive.to_s == "TrueClass"
|
16
|
+
options.merge!(key.to_sym => (value == "true" ? true : false))
|
17
|
+
elsif @model.properties[key].primitive.to_s == "Integer" && @model.properties[key].type.respond_to?(:flag_map)
|
18
|
+
options.merge!(key.to_sym => value.to_sym)
|
19
|
+
end
|
20
|
+
end
|
12
21
|
if params[:all]
|
13
|
-
|
22
|
+
options = {
|
23
|
+
:limit => 200,
|
24
|
+
}.merge(options)
|
25
|
+
@instances = @model.all(options).reverse
|
14
26
|
else
|
15
27
|
# monkey patch pagination
|
16
28
|
@model.class_eval("is_paginated") unless @model.respond_to?(:paginated)
|
17
29
|
@current_page = (params[:page] || 1).to_i
|
18
|
-
|
30
|
+
options = {
|
31
|
+
:page => @current_page,
|
32
|
+
:per_page => 100,
|
33
|
+
}.merge(options)
|
34
|
+
@page_count, @instances = @model.paginated(options)
|
19
35
|
end
|
20
36
|
render(:layout => "list")
|
21
37
|
end
|
data/app/helpers/forms_helper.rb
CHANGED
@@ -2,6 +2,7 @@ require 'builder'
|
|
2
2
|
module Merb
|
3
3
|
module MerbAdmin
|
4
4
|
module FormsHelper
|
5
|
+
|
5
6
|
# Given a page count and the current page, we generate a set of pagination
|
6
7
|
# links.
|
7
8
|
#
|
@@ -107,6 +108,7 @@ module Merb
|
|
107
108
|
def infinity
|
108
109
|
1.0 / 0
|
109
110
|
end
|
111
|
+
|
110
112
|
end
|
111
113
|
end
|
112
114
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<p>Are you sure you want to delete the <%= @model_name.snake_case.gsub('_', ' ') %>? All of the following related items will be deleted:</p>
|
2
2
|
<ul>
|
3
3
|
<li>
|
4
|
-
|
4
|
+
<%= link_to(@model_name, slice_url(:admin_edit, :model_name => @model_name.snake_case, :id => @instance.id))%>
|
5
5
|
</li>
|
6
6
|
</ul>
|
7
7
|
<%= form_for(@instance, :action => slice_url(:admin_destroy, :model_name => @model_name.snake_case, :id => @instance.id), :method => :delete) do %>
|
@@ -1,6 +1,8 @@
|
|
1
1
|
<div id="content-main">
|
2
2
|
<ul class="object-tools">
|
3
|
-
<li
|
3
|
+
<li>
|
4
|
+
<%= link_to("View on site", "/#{@model_name.snake_case}/#{@instance.id}", :target => "_blank", :class => "viewsitelink") %>
|
5
|
+
</li>
|
4
6
|
</ul>
|
5
7
|
<%= form_for(@instance, :action => slice_url(:admin_update, :model_name => @model_name.snake_case, :id => @instance.id)) do %>
|
6
8
|
<div>
|
@@ -13,7 +15,9 @@
|
|
13
15
|
</fieldset>
|
14
16
|
<div class="submit-row" >
|
15
17
|
<%= submit "Save", :class => "default", :name => "_save" %>
|
16
|
-
<p class="deletelink-box"
|
18
|
+
<p class="deletelink-box">
|
19
|
+
<%= link_to("Delete", slice_url(:admin_delete, :model_name => @model_name.snake_case, :id => @instance.id), :class => "deletelink") %>
|
20
|
+
</p>
|
17
21
|
<%= submit "Save and add another", :name => "_add_another" %>
|
18
22
|
<%= submit "Save and continue editing", :name => "_continue" %>
|
19
23
|
</div>
|
@@ -1,12 +1,20 @@
|
|
1
1
|
<div id="content-main">
|
2
2
|
<div class="module">
|
3
3
|
<table summary="Models available in the application.">
|
4
|
-
<caption
|
4
|
+
<caption>
|
5
|
+
<%= link_to("Models", slice_url(:admin_dashboard), :class => "section") %>
|
6
|
+
</caption>
|
5
7
|
<% @models.map{|m| m.to_s}.each do |model_name| %>
|
6
8
|
<tr>
|
7
|
-
<th scope="row"
|
8
|
-
|
9
|
-
|
9
|
+
<th scope="row">
|
10
|
+
<%= link_to(model_name.pluralize, slice_url(:admin_list, :model_name => model_name.snake_case)) %>
|
11
|
+
</th>
|
12
|
+
<td>
|
13
|
+
<%= link_to("Add", slice_url(:admin_new, :model_name => model_name.snake_case), :class => "addlink") %>
|
14
|
+
</td>
|
15
|
+
<td>
|
16
|
+
<%= link_to("Edit", slice_url(:admin_list, :model_name => model_name.snake_case), :class => "changelink") %>
|
17
|
+
</td>
|
10
18
|
</tr>
|
11
19
|
<% end %>
|
12
20
|
</table>
|
@@ -1,10 +1,42 @@
|
|
1
1
|
<div id="content-main">
|
2
2
|
<ul class="object-tools">
|
3
3
|
<li>
|
4
|
-
|
4
|
+
<%= link_to("Add #{@model_name.snake_case.gsub('_', ' ')}", slice_url(:admin_new, :model_name => @model_name.snake_case), :class => "addlink") %>
|
5
5
|
</li>
|
6
6
|
</ul>
|
7
7
|
<div class="module filtered" id="changelist">
|
8
|
+
<div id="changelist-filter">
|
9
|
+
<h2>Filter</h2>
|
10
|
+
<% params = request.params.except(:action, :controller, :model_name) %>
|
11
|
+
<% @properties.each do |property| %>
|
12
|
+
<% if property.primitive.to_s == "TrueClass" %>
|
13
|
+
<h3>By <%= property.field.gsub('_', ' ') %></h3>
|
14
|
+
<ul>
|
15
|
+
<li<%= params[:filter].nil? || params[:filter][property.name].blank? ? ' class="selected"' : nil %>>
|
16
|
+
<a href="?<%= Merb::Parse.params_to_query_string(params.merge(:filter => (params[:filter] || {}).reject{|key, value| key.to_sym == property.name})) %>">All</a>
|
17
|
+
</li>
|
18
|
+
<li<%= params[:filter] && params[:filter][property.name] == "true" ? ' class="selected"' : nil %>>
|
19
|
+
<a href="?<%= Merb::Parse.params_to_query_string(params.merge(:filter => (params[:filter] || {}).merge({property.name => true}))) %>">Yes</a>
|
20
|
+
</li>
|
21
|
+
<li<%= params[:filter] && params[:filter][property.name] == "false" ? ' class="selected"' : nil %>>
|
22
|
+
<a href="?<%= Merb::Parse.params_to_query_string(params.merge(:filter => (params[:filter] || {}).merge({property.name => false}))) %>">No</a>
|
23
|
+
</li>
|
24
|
+
</ul>
|
25
|
+
<% elsif property.primitive.to_s == "Integer" && property.type.respond_to?(:flag_map) %>
|
26
|
+
<h3>By <%= property.field.gsub('_', ' ') %></h3>
|
27
|
+
<ul>
|
28
|
+
<li<%= params[:filter].nil? || params[:filter][property.name].blank? ? ' class="selected"' : nil %>>
|
29
|
+
<a href="?<%= Merb::Parse.params_to_query_string(params.merge(:filter => (params[:filter] || {}).reject{|key, value| key.to_sym == property.name})) %>">All</a>
|
30
|
+
</li>
|
31
|
+
<% property.type.flag_map.each do |value, name| %>
|
32
|
+
<li<%= params[:filter] && params[:filter][property.name] == name.to_s ? ' class="selected"' : nil %>>
|
33
|
+
<a href="?<%= Merb::Parse.params_to_query_string(params.merge(:filter => (params[:filter] || {}).merge({property.name => name}))) %>"><%= name.to_s.capitalize.gsub('_', ' ')%></a>
|
34
|
+
</li>
|
35
|
+
<% end %>
|
36
|
+
</ul>
|
37
|
+
<% end %>
|
38
|
+
<% end %>
|
39
|
+
</div>
|
8
40
|
<table cellspacing="0">
|
9
41
|
<thead>
|
10
42
|
<tr>
|
@@ -55,9 +87,13 @@
|
|
55
87
|
</tbody>
|
56
88
|
</table>
|
57
89
|
<p class="paginator">
|
58
|
-
|
90
|
+
<% if @page_count.to_i > 1 %>
|
91
|
+
<%= paginate(@current_page, @page_count, :url => slice_url(:admin_list, :model_name => @model_name.snake_case)) %>
|
92
|
+
<% end %>
|
59
93
|
<%= @model.count %> <%= @model.count == 1 ? @model_name.snake_case.gsub('_', ' ') : @model_name.snake_case.gsub('_', ' ').pluralize %>
|
60
|
-
|
94
|
+
<% if @page_count.to_i == 2 %>
|
95
|
+
<%= link_to("Show all", slice_url(:admin_list, :model_name => @model_name.snake_case, :all => true), :class => "showall") %>
|
96
|
+
<% end %>
|
61
97
|
</p>
|
62
98
|
</div>
|
63
99
|
</div>
|
@@ -30,12 +30,12 @@
|
|
30
30
|
</h1>
|
31
31
|
</div>
|
32
32
|
<div id="user-tools">
|
33
|
-
Welcome, <strong
|
33
|
+
<!-- Welcome, <strong></strong>. <a href="">Log out</a> -->
|
34
34
|
</div>
|
35
35
|
</div>
|
36
36
|
<div class="breadcrumbs">
|
37
|
-
|
38
|
-
|
37
|
+
<%= link_to("Home", url(:admin_dashboard)) %> ›
|
38
|
+
<%= link_to(@model_name.pluralize, url(:admin_list, :model_name => @model_name.snake_case)) %> ›
|
39
39
|
<%= page_name %>
|
40
40
|
</div>
|
41
41
|
<%= partial 'layout/message' -%>
|
@@ -25,11 +25,11 @@
|
|
25
25
|
</h1>
|
26
26
|
</div>
|
27
27
|
<div id="user-tools">
|
28
|
-
Welcome, <strong
|
28
|
+
<!-- Welcome, <strong></strong>. <a href="">Log out</a> -->
|
29
29
|
</div>
|
30
30
|
</div>
|
31
31
|
<div class="breadcrumbs">
|
32
|
-
|
32
|
+
<%= link_to("Home", url(:admin_dashboard)) %> ›
|
33
33
|
<%=h @model_name.pluralize %>
|
34
34
|
</div>
|
35
35
|
<%= partial 'layout/message' -%>
|
data/lib/merb-admin.rb
CHANGED
@@ -22,7 +22,7 @@ if defined?(Merb::Plugins)
|
|
22
22
|
|
23
23
|
# Slice metadata
|
24
24
|
self.description = "MerbAdmin is a merb slice that uses your DataMapper models to provide an easy-to-use, Django-style interface for content managers."
|
25
|
-
self.version = "0.1.
|
25
|
+
self.version = "0.1.8"
|
26
26
|
self.author = "Erik Michaels-Ober"
|
27
27
|
|
28
28
|
# Stub classes loaded hook - runs before LoadClasses BootLoader
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sferik-merb-admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erik Michaels-Ober
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-08-
|
12
|
+
date: 2009-08-08 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|