rails_dash 0.0.2 → 0.0.3
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.
- data/README.rdoc +4 -1
- data/app/controllers/rails_dash/base_controller.rb +0 -2
- data/app/controllers/rails_dash/crud_controller.rb +8 -8
- data/config/locales/en.yml +24 -0
- data/config/locales/es.yml +24 -0
- data/lib/generators/dash/resource_generator.rb +16 -2
- data/lib/generators/dash/templates/filter.erb +2 -2
- data/lib/generators/dash/templates/index.erb +3 -3
- data/lib/generators/dash/templates/layout.erb +6 -6
- data/lib/generators/dash/templates/pager.erb +4 -4
- data/lib/rails_dash/version.rb +1 -1
- data/test/dummy/app/models/photo.rb +2 -0
- data/test/dummy/app/views/dash/photos/index.html.haml +3 -3
- data/test/dummy/app/views/dash/shared/_filter.html.haml +2 -2
- data/test/dummy/app/views/dash/shared/_pager.html.haml +4 -4
- data/test/dummy/app/views/layouts/dash.html.haml +8 -5
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/log/development.log +2448 -0
- metadata +3 -1
data/README.rdoc
CHANGED
@@ -23,7 +23,7 @@ To generate a resource do:
|
|
23
23
|
= Customize
|
24
24
|
|
25
25
|
To protect the dash directory edit authorize filter in:
|
26
|
-
app/
|
26
|
+
app/controllers/dash_controller.rb
|
27
27
|
|
28
28
|
To change the behavior of a resource:
|
29
29
|
app/controllers/dash/model_controller.rb
|
@@ -36,3 +36,6 @@ To change the resource form edit:
|
|
36
36
|
|
37
37
|
To change the resource grid edit:
|
38
38
|
app/views/dash/model/index.html.html
|
39
|
+
|
40
|
+
To change the records in the grid and the filter behavior edit the filter scope in your resource model:
|
41
|
+
app/models/model.rb
|
@@ -5,20 +5,20 @@ module RailsDash
|
|
5
5
|
|
6
6
|
def index
|
7
7
|
@meta_title = @title = "#{@model.model_name.human :count => 2}"
|
8
|
-
@records = @model.
|
8
|
+
@records = @model.filter(filter).page(page)
|
9
9
|
end
|
10
10
|
|
11
11
|
def new
|
12
|
-
@meta_title = @title = "#{t('
|
12
|
+
@meta_title = @title = "#{t('dash.grid.add')} #{@model.model_name.human}"
|
13
13
|
@record = @model.new
|
14
14
|
render :form
|
15
15
|
end
|
16
16
|
|
17
17
|
def create
|
18
|
-
@meta_title = @title = "#{t('
|
18
|
+
@meta_title = @title = "#{t('dash.grid.add')} #{@model.model_name.human}"
|
19
19
|
@record = @model.new(params[param])
|
20
20
|
if @record.save
|
21
|
-
redirect_with_flash(index_path, :success, t('flash.success.add'), params)
|
21
|
+
redirect_with_flash(index_path, :success, t('dash.flash.success.add'), params)
|
22
22
|
else
|
23
23
|
flash_errors @record
|
24
24
|
render :form
|
@@ -26,16 +26,16 @@ module RailsDash
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def show
|
29
|
-
@meta_title = @title = "#{t('
|
29
|
+
@meta_title = @title = "#{t('dash.grid.edit')} #{@model.model_name.human}"
|
30
30
|
@record = @model.find(params[:id])
|
31
31
|
render :form
|
32
32
|
end
|
33
33
|
|
34
34
|
def update
|
35
|
-
@meta_title = @title = "#{t('
|
35
|
+
@meta_title = @title = "#{t('dash.grid.edit')} #{@model.model_name.human}"
|
36
36
|
@record = @model.find(params[:id])
|
37
37
|
if @record.update_attributes(params[param])
|
38
|
-
redirect_with_flash index_path, :success, t('flash.success.edit'), params
|
38
|
+
redirect_with_flash index_path, :success, t('dash.flash.success.edit'), params
|
39
39
|
else
|
40
40
|
flash_errors @record
|
41
41
|
render :form
|
@@ -44,7 +44,7 @@ module RailsDash
|
|
44
44
|
|
45
45
|
def destroy
|
46
46
|
@model.destroy params[:id]
|
47
|
-
redirect_with_flash index_path, :success, t('flash.success.
|
47
|
+
redirect_with_flash index_path, :success, t('dash.flash.success.destroy')
|
48
48
|
end
|
49
49
|
|
50
50
|
protected
|
@@ -0,0 +1,24 @@
|
|
1
|
+
en:
|
2
|
+
dash:
|
3
|
+
flash:
|
4
|
+
success:
|
5
|
+
add: "Record added successfully."
|
6
|
+
edit: "Record edited successfully."
|
7
|
+
destroy: "Record destroyed successfully."
|
8
|
+
menu:
|
9
|
+
home: "Home"
|
10
|
+
session:
|
11
|
+
logout: "Logout"
|
12
|
+
footer:
|
13
|
+
copyright: "Dash © %{year}"
|
14
|
+
grid:
|
15
|
+
filter: "Filter"
|
16
|
+
actions: "Actions"
|
17
|
+
add: "Add"
|
18
|
+
edit: "Edit"
|
19
|
+
destroy: "Destroy"
|
20
|
+
pager:
|
21
|
+
first: "First"
|
22
|
+
previous: "Previous"
|
23
|
+
next: "Next"
|
24
|
+
last: "Last"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
es:
|
2
|
+
dash:
|
3
|
+
flash:
|
4
|
+
success:
|
5
|
+
add: "Registro agregado correctamente."
|
6
|
+
edit: "Registro editado correctamente."
|
7
|
+
destroy: "Registro eliminiado correctamente."
|
8
|
+
menu:
|
9
|
+
home: "Inicio"
|
10
|
+
session:
|
11
|
+
logout: "Salir"
|
12
|
+
footer:
|
13
|
+
copyright: "Panel © %{year}"
|
14
|
+
grid:
|
15
|
+
filter: "Filtrar"
|
16
|
+
actions: "Acciones"
|
17
|
+
add: "Agregar"
|
18
|
+
edit: "Editar"
|
19
|
+
destroy: "Eliminar"
|
20
|
+
pager:
|
21
|
+
first: "Primero"
|
22
|
+
previous: "Anterior"
|
23
|
+
next: "Siguiente"
|
24
|
+
last: "Último"
|
@@ -4,8 +4,22 @@ module Dash
|
|
4
4
|
source_root File.expand_path('../templates', __FILE__)
|
5
5
|
|
6
6
|
def add_route
|
7
|
-
|
8
|
-
"
|
7
|
+
insert_into_file 'config/routes.rb', :after => /namespace :dash(.*)/ do
|
8
|
+
"\n\n resources :#{table_name}"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def add_scope
|
13
|
+
insert_into_file "app/models/#{singular_name}.rb", :after => /class #{singular_name.camelize}(.*)/ do
|
14
|
+
"\n\n scope :filter, lambda { |filter| where('', :filter => \"%\#{filter}%\") }"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def add_menu
|
19
|
+
insert_into_file 'app/views/layouts/dash.html.haml', :before => /(.*)#session(.*)/ do
|
20
|
+
"#{' ' * 16}%li\n" +
|
21
|
+
"#{' ' * 18}%a{ :href => url_for([:dash, :#{table_name}]), :title => #{singular_name.camelize}.model_name.human(:count => 2) }\n" +
|
22
|
+
"#{' ' * 20}= #{singular_name.camelize}.model_name.human(:count => 2)\n"
|
9
23
|
end
|
10
24
|
end
|
11
25
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#options
|
2
2
|
= form_tag request.fullpath, :method => 'get', :id => 'search' do
|
3
|
-
= text_field_tag :q, (params[:q].present? ? params[:q] : t('
|
3
|
+
= text_field_tag :q, (params[:q].present? ? params[:q] : t('dash.grid.filter')), :onblur => "if (this.value == '') {this.value = '#{t('dash.grid.filter')}';}", :onfocus => "if (this.value == '#{t('dash.grid.filter')}') {this.value = '';}"
|
4
4
|
%a.button.action{ :href => url_for([:new, :dash, @model.name.underscore.to_sym]) }
|
5
|
-
= t('
|
5
|
+
= t('dash.grid.add')
|
@@ -6,7 +6,7 @@
|
|
6
6
|
%th
|
7
7
|
= @model.human_attribute_name('created_at')
|
8
8
|
%th.actions
|
9
|
-
= t('
|
9
|
+
= t('dash.grid.actions')
|
10
10
|
- @records.each do |record|
|
11
11
|
%tr
|
12
12
|
%td
|
@@ -14,6 +14,6 @@
|
|
14
14
|
%td
|
15
15
|
= l(record.created_at)
|
16
16
|
%td.actions
|
17
|
-
= link_to(t('
|
18
|
-
= link_to(t('
|
17
|
+
= link_to(t('dash.grid.edit'), [:dash, record])
|
18
|
+
= link_to(t('dash.grid.destroy'), [:dash, record], :method => :delete)
|
19
19
|
= render :partial => 'dash/shared/pager', :locals => { :collection => @records }
|
@@ -2,7 +2,7 @@
|
|
2
2
|
%html{:xmlns => 'http://www.w3.org/1999/xhtml', :'xml:lang' => I18n.locale, :lang => I18n.locale}
|
3
3
|
%head
|
4
4
|
%title= @meta_title
|
5
|
-
= stylesheet_link_tag '
|
5
|
+
= stylesheet_link_tag 'railsdash/application', :media => 'all'
|
6
6
|
= javascript_include_tag 'application'
|
7
7
|
= csrf_meta_tags
|
8
8
|
%body
|
@@ -12,11 +12,11 @@
|
|
12
12
|
#menu
|
13
13
|
%ul
|
14
14
|
%li
|
15
|
-
%a{ :href => rails_dash.root_path, :title => t('
|
16
|
-
= t('
|
15
|
+
%a{ :href => rails_dash.root_path, :title => t('dash.menu.home') }
|
16
|
+
= t('dash.menu.home')
|
17
17
|
#session
|
18
|
-
%a.button{ :href => '#', :title => t('
|
19
|
-
= t('
|
18
|
+
%a.button{ :href => '#', :title => t('dash.session.logout') }
|
19
|
+
= t('dash.session.logout')
|
20
20
|
- if @title
|
21
21
|
#header
|
22
22
|
.holder
|
@@ -37,4 +37,4 @@
|
|
37
37
|
#footer
|
38
38
|
.holder
|
39
39
|
%p#copyright
|
40
|
-
= t('
|
40
|
+
= t('dash.footer.copyright', :year => @year)
|
@@ -3,10 +3,10 @@
|
|
3
3
|
#pager
|
4
4
|
- if pager.has_first_page?
|
5
5
|
%a.first{ :href => pager.first_page_path }
|
6
|
-
= t('
|
6
|
+
= t('dash.pager.first')
|
7
7
|
- if pager.has_previous_page?
|
8
8
|
%a.previous{ :href => pager.previous_page_path }
|
9
|
-
= t('
|
9
|
+
= t('dash.pager.previous')
|
10
10
|
- if pager.navigation.has_less_pages?
|
11
11
|
%span.ellipsis ...
|
12
12
|
- for page in pager.navigation.pages
|
@@ -20,7 +20,7 @@
|
|
20
20
|
%span.ellipsis ...
|
21
21
|
- if pager.has_next_page?
|
22
22
|
%a.next{ :href => pager.next_page_path }
|
23
|
-
= t('
|
23
|
+
= t('dash.pager.next')
|
24
24
|
- if pager.has_last_page?
|
25
25
|
%a.last{ :href => pager.last_page_path }
|
26
|
-
= t('
|
26
|
+
= t('dash.pager.last')
|
data/lib/rails_dash/version.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
%th
|
7
7
|
= @model.human_attribute_name('created_at')
|
8
8
|
%th.actions
|
9
|
-
= t('
|
9
|
+
= t('dash.grid.actions')
|
10
10
|
- @records.each do |record|
|
11
11
|
%tr
|
12
12
|
%td
|
@@ -14,6 +14,6 @@
|
|
14
14
|
%td
|
15
15
|
= l(record.created_at)
|
16
16
|
%td.actions
|
17
|
-
= link_to(t('
|
18
|
-
= link_to(t('
|
17
|
+
= link_to(t('dash.grid.edit'), [:dash, record])
|
18
|
+
= link_to(t('dash.grid.destroy'), [:dash, record], :method => :delete)
|
19
19
|
= render :partial => 'dash/shared/pager', :locals => { :collection => @records }
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#options
|
2
2
|
= form_tag request.fullpath, :method => 'get', :id => 'search' do
|
3
|
-
= text_field_tag :q, (params[:q].present? ? params[:q] : t('
|
3
|
+
= text_field_tag :q, (params[:q].present? ? params[:q] : t('dash.grid.filter')), :onblur => "if (this.value == '') {this.value = '#{t('dash.grid.filter')}';}", :onfocus => "if (this.value == '#{t('dash.grid.filter')}') {this.value = '';}"
|
4
4
|
%a.button.action{ :href => url_for([:new, :dash, @model.name.underscore.to_sym]) }
|
5
|
-
= t('
|
5
|
+
= t('dash.grid.add')
|
@@ -3,10 +3,10 @@
|
|
3
3
|
#pager
|
4
4
|
- if pager.has_first_page?
|
5
5
|
%a.first{ :href => pager.first_page_path }
|
6
|
-
= t('
|
6
|
+
= t('dash.pager.first')
|
7
7
|
- if pager.has_previous_page?
|
8
8
|
%a.previous{ :href => pager.previous_page_path }
|
9
|
-
= t('
|
9
|
+
= t('dash.pager.previous')
|
10
10
|
- if pager.navigation.has_less_pages?
|
11
11
|
%span.ellipsis ...
|
12
12
|
- for page in pager.navigation.pages
|
@@ -20,7 +20,7 @@
|
|
20
20
|
%span.ellipsis ...
|
21
21
|
- if pager.has_next_page?
|
22
22
|
%a.next{ :href => pager.next_page_path }
|
23
|
-
= t('
|
23
|
+
= t('dash.pager.next')
|
24
24
|
- if pager.has_last_page?
|
25
25
|
%a.last{ :href => pager.last_page_path }
|
26
|
-
= t('
|
26
|
+
= t('dash.pager.last')
|
@@ -12,11 +12,14 @@
|
|
12
12
|
#menu
|
13
13
|
%ul
|
14
14
|
%li
|
15
|
-
%a{ :href => rails_dash.root_path, :title => t('
|
16
|
-
= t('
|
15
|
+
%a{ :href => rails_dash.root_path, :title => t('dash.menu.home') }
|
16
|
+
= t('dash.menu.home')
|
17
|
+
%li
|
18
|
+
%a{ :href => url_for([:dash, :photos]), :title => Photo.model_name.human(:count => 2) }
|
19
|
+
= Photo.model_name.human(:count => 2)
|
17
20
|
#session
|
18
|
-
%a.button{ :href => '#', :title => t('
|
19
|
-
= t('
|
21
|
+
%a.button{ :href => '#', :title => t('dash.session.logout') }
|
22
|
+
= t('dash.session.logout')
|
20
23
|
- if @title
|
21
24
|
#header
|
22
25
|
.holder
|
@@ -37,4 +40,4 @@
|
|
37
40
|
#footer
|
38
41
|
.holder
|
39
42
|
%p#copyright
|
40
|
-
= t('
|
43
|
+
= t('dash.footer.copyright', :year => @year)
|
Binary file
|