rails_dash 0.0.4 → 0.0.5
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/app/controllers/rails_dash/base_controller.rb +3 -17
- data/app/controllers/rails_dash/crud_controller.rb +2 -2
- data/app/helpers/rails_dash/application_helper.rb +13 -0
- data/{lib/generators/dash/templates/filter.erb → app/views/rails_dash/shared/_options.html.haml} +3 -2
- data/lib/generators/dash/install_generator.rb +0 -2
- data/lib/generators/dash/resource_generator.rb +2 -2
- data/lib/generators/dash/templates/form.erb +1 -1
- data/lib/generators/dash/templates/index.erb +6 -4
- data/lib/generators/dash/templates/layout.erb +1 -1
- data/lib/rails_dash/version.rb +1 -1
- data/test/dummy/app/controllers/statics_controller.rb +6 -0
- data/test/dummy/app/models/photo.rb +1 -9
- data/test/dummy/app/views/dash/photos/form.html.haml +3 -1
- data/test/dummy/app/views/dash/photos/index.html.haml +10 -4
- data/test/dummy/app/views/layouts/dash.html.haml +2 -2
- data/test/dummy/app/views/statics/home.html.haml +4 -0
- data/test/dummy/app/views/statics/other.html.haml +4 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/log/development.log +11472 -8141
- data/test/dummy/tmp/cache/assets/BFB/7E0/sprockets%2F9320085d33b800555194fe929982762b +0 -0
- data/test/dummy/tmp/cache/assets/C8B/270/sprockets%2F7a0602acfe998896b0d470e151625588 +0 -0
- data/test/dummy/tmp/cache/assets/C99/E60/sprockets%2F064aac0041190c605c1728b86db5e660 +0 -0
- data/test/dummy/tmp/cache/assets/C9D/5C0/sprockets%2Fa3870a84599f2900e899d917239fee70 +0 -0
- data/test/dummy/tmp/cache/assets/CA3/D40/sprockets%2Fd0c463ae779d0510a7d2a39201475f80 +0 -0
- data/test/dummy/tmp/cache/assets/CB0/680/sprockets%2Fa545b40f4926503219dee13976ba83c7 +0 -0
- data/test/dummy/tmp/cache/assets/CB0/DB0/sprockets%2F3b03d1b258e45bf0488808687a3c019f +0 -0
- data/test/dummy/tmp/cache/assets/CCB/C40/sprockets%2F6c2c30b00feda0096c1523c4721e8647 +0 -0
- data/test/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/CE0/1D0/sprockets%2F95cf9361ed4c73f7736bb1065003c27d +0 -0
- data/test/dummy/tmp/cache/assets/CE5/C90/sprockets%2F0e2f9731d66610f311f7d93ee472be92 +0 -0
- data/test/dummy/tmp/cache/assets/CF8/E40/sprockets%2F97e76837bd2bd4d792b34582df74a747 +0 -0
- data/test/dummy/tmp/cache/assets/CFD/B30/sprockets%2F0e7126250acecd256a22173a6c69f33c +0 -0
- data/test/dummy/tmp/cache/assets/D03/FF0/sprockets%2F6159334a6b4a6011f9e4aca85713deb2 +0 -0
- data/test/dummy/tmp/cache/assets/D0C/6D0/sprockets%2F066b73503006b11fe0ca9cf979818bcf +0 -0
- data/test/dummy/tmp/cache/assets/D0C/D50/sprockets%2F1e1fb266cbd216d68ad5f460542f8507 +0 -0
- data/test/dummy/tmp/cache/assets/D13/380/sprockets%2F45ea51d9524b0d78eb92ba6f205e3957 +0 -0
- data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/D3A/720/sprockets%2Fd2e3289732e11cf54d74e8ea51acd125 +0 -0
- data/test/dummy/tmp/cache/assets/D3C/F40/sprockets%2Ff0f0ade9590889033e221c7e60c73afa +0 -0
- data/test/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/dummy/tmp/cache/assets/D55/110/sprockets%2F18e497baefd6939772d9cc267d3416ea +0 -0
- data/test/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/D5F/8A0/sprockets%2F0412cd81c0aa11e2ccef0d9e479e7146 +0 -0
- data/test/dummy/tmp/cache/assets/D77/080/sprockets%2Fd231e66bef5f5ccb5a92272f714786dd +0 -0
- data/test/dummy/tmp/cache/assets/D79/0C0/sprockets%2Fffa7fbddfd8a63f466156a14f4471753 +0 -0
- data/test/dummy/tmp/cache/assets/D9B/E00/sprockets%2Fb66a75bd10bef6da5f16f4fa9113926c +0 -0
- data/test/dummy/tmp/cache/assets/DAC/650/sprockets%2Ff8ec2e25f819797cb9a491d0af22ae9b +0 -0
- data/test/dummy/tmp/cache/assets/DBA/780/sprockets%2Fe231e0256cb57ae5feac27411bb8cab5 +0 -0
- data/test/dummy/tmp/cache/assets/DCD/B00/sprockets%2Fc39efce3c924fd1aa2c0898e0b3e194b +0 -0
- data/test/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/DEF/100/sprockets%2F8b9d88bfa8f8eed7910469ef2ab8a8c7 +0 -0
- data/test/dummy/tmp/cache/assets/DF1/BA0/sprockets%2Ff2aaadaa5f593082c04c59cde41ecc37 +0 -0
- data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/E05/400/sprockets%2F6df59ebc6ab9ec4b3c24516d6efd3b47 +0 -0
- data/test/dummy/tmp/cache/assets/E29/AA0/sprockets%2F6eaab4ab4dbae1b8b5a6f9286aa966d4 +0 -0
- data/test/dummy/tmp/cache/assets/E5D/4B0/sprockets%2Fba31b9d7aabcf86ec3c48fcd7db830e5 +0 -0
- data/test/dummy/tmp/cache/assets/E67/970/sprockets%2F39d69c6bafd9cebefdea7015bd7d0a87 +0 -0
- data/test/dummy/tmp/cache/assets/E93/600/sprockets%2F2daf7d5f74f8c9ac8be0bedcfae6009c +0 -0
- metadata +15 -100
- data/lib/generators/dash/templates/pager.erb +0 -26
- data/test/dummy/app/views/dash/shared/_filter.html.haml +0 -5
- data/test/dummy/log/test.log +0 -3
- data/test/dummy/tmp/cache/assets/C58/890/sprockets%2F2d7971158b18b431d02989a96e33e812 +0 -0
- data/test/dummy/tmp/cache/assets/C5B/F90/sprockets%2F8c7a3bc5548168137aa7392b86284906 +0 -0
- data/test/dummy/tmp/cache/assets/C6D/C60/sprockets%2F62a541364d6d42f11830c3426f841a3a +0 -0
- data/test/dummy/tmp/cache/assets/C79/E70/sprockets%2F179bde618f75a5099991956a966f6861 +0 -0
- data/test/dummy/tmp/cache/assets/C8F/D20/sprockets%2F2d66fda9c7d8645910e0754749f11544 +0 -0
- data/test/dummy/tmp/cache/assets/CA6/DD0/sprockets%2F41c60b85ca6aa885732e007b88c05343 +0 -0
- data/test/dummy/tmp/cache/assets/CAB/660/sprockets%2F0c2455743e4d9189dd1f0ef250c11394 +0 -0
- data/test/dummy/tmp/cache/assets/CBD/760/sprockets%2Fcd6bf3159c52152955549982d634f4bc +0 -0
- data/test/dummy/tmp/cache/assets/CD2/BD0/sprockets%2F68d29301abf7b7892ca072ad232341f2 +0 -0
- data/test/dummy/tmp/cache/assets/CEB/150/sprockets%2F21cd9639cd9b6925f1a127192c2959fb +0 -0
- data/test/dummy/tmp/cache/assets/D0F/AF0/sprockets%2Fcee92070637e21e6c3b0ae89b5604b96 +0 -0
- data/test/dummy/tmp/cache/assets/D15/8D0/sprockets%2F576fdac742aaf620938b5586e3e261e3 +0 -0
- data/test/dummy/tmp/cache/assets/D15/B80/sprockets%2Fc6e382a83453937ad9d0988e2c12c6aa +0 -0
- data/test/dummy/tmp/cache/assets/D1A/0E0/sprockets%2Ffa6065deb98c82544e6bf8960f31801c +0 -0
- data/test/dummy/tmp/cache/assets/D22/130/sprockets%2F710e497370aad44a1ad04addbd256204 +0 -0
- data/test/dummy/tmp/cache/assets/D2A/A60/sprockets%2F1d0eea7f3b7d8e691998d5a97568514c +0 -0
- data/test/dummy/tmp/cache/assets/D35/120/sprockets%2F0b2424217f6c72fc05df4183dcd169ea +0 -0
- data/test/dummy/tmp/cache/assets/D37/950/sprockets%2F60859b54ca0d1dfca7049028bedf2903 +0 -0
- data/test/dummy/tmp/cache/assets/D3D/F70/sprockets%2Fd09ae614e12f07187afd3458c57a6a4d +0 -0
- data/test/dummy/tmp/cache/assets/D3F/DC0/sprockets%2F9bd1780aa8721f46e01a84e7db0e6e56 +0 -0
- data/test/dummy/tmp/cache/assets/D41/670/sprockets%2F19274a17da516d46b58baf55fd1c3f58 +0 -0
- data/test/dummy/tmp/cache/assets/D45/340/sprockets%2Fd417be808603d0e3a7cb829d55f5a68e +0 -0
- data/test/dummy/tmp/cache/assets/D4D/640/sprockets%2Ffea346129509ff08d5d5d8b77ba98b24 +0 -0
- data/test/dummy/tmp/cache/assets/D69/4F0/sprockets%2Fb9d37dc41f5268332346adebac1379bb +0 -0
- data/test/dummy/tmp/cache/assets/D6A/400/sprockets%2F630afb0339b0ce630663983b8dd2efec +0 -0
- data/test/dummy/tmp/cache/assets/D78/090/sprockets%2F14e4a77f7da894213732ad97befdd4d4 +0 -0
- data/test/dummy/tmp/cache/assets/D9C/9F0/sprockets%2F7c6e5cc58a73cac2d1c900d4a0c589d8 +0 -0
- data/test/dummy/tmp/cache/assets/DA2/E80/sprockets%2Fb9b99eb30a9731cc4abcdf42ff951247 +0 -0
- data/test/dummy/tmp/cache/assets/DC0/F90/sprockets%2Fea7b247b3a394fd0a87b9b3f300a1cfd +0 -0
- data/test/dummy/tmp/cache/assets/DC6/790/sprockets%2F223d40d7aed38d4da4e2cad0d555ff39 +0 -0
- data/test/dummy/tmp/cache/assets/DCD/AB0/sprockets%2Fd7094ece7c1b47b62d4b280aea7e80ef +0 -0
- data/test/dummy/tmp/cache/assets/E02/5F0/sprockets%2Fc099f7cc09acdb9f0c28860edd9a0ba7 +0 -0
- data/test/dummy/tmp/cache/assets/EEE/360/sprockets%2Ff7b473abfbca6ef0bd2bdfdfda3939ee +0 -0
- data/test/dummy/tmp/cache/sass/e22804675e303f28a5c33209e40bad6d47fd67a4/autocomplete.sassc +0 -0
- data/test/dummy/tmp/cache/sass/e22804675e303f28a5c33209e40bad6d47fd67a4/content.sassc +0 -0
- data/test/dummy/tmp/cache/sass/e22804675e303f28a5c33209e40bad6d47fd67a4/flash.sassc +0 -0
- data/test/dummy/tmp/cache/sass/e22804675e303f28a5c33209e40bad6d47fd67a4/footer.sassc +0 -0
- data/test/dummy/tmp/cache/sass/e22804675e303f28a5c33209e40bad6d47fd67a4/forms.sassc +0 -0
- data/test/dummy/tmp/cache/sass/e22804675e303f28a5c33209e40bad6d47fd67a4/grid.sassc +0 -0
- data/test/dummy/tmp/cache/sass/e22804675e303f28a5c33209e40bad6d47fd67a4/header.sassc +0 -0
- data/test/dummy/tmp/cache/sass/e22804675e303f28a5c33209e40bad6d47fd67a4/intro.sassc +0 -0
- data/test/dummy/tmp/cache/sass/e22804675e303f28a5c33209e40bad6d47fd67a4/navigation.sassc +0 -0
- data/test/dummy/tmp/cache/sass/e22804675e303f28a5c33209e40bad6d47fd67a4/page.sassc +0 -0
- data/test/dummy/tmp/cache/sass/e22804675e303f28a5c33209e40bad6d47fd67a4/pager.sassc +0 -0
- data/test/dummy/tmp/cache/sass/e22804675e303f28a5c33209e40bad6d47fd67a4/style.sassc +0 -0
- /data/{test/dummy/app/views/dash → app/views/rails_dash}/shared/_pager.html.haml +0 -0
@@ -1,21 +1,7 @@
|
|
1
1
|
module RailsDash
|
2
|
-
class BaseController <
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
protected
|
7
|
-
|
8
|
-
def year
|
9
|
-
@year = Time.now.year
|
10
|
-
end
|
11
|
-
|
12
|
-
def page
|
13
|
-
params[:p].present? ? params[:p].to_i : 1
|
14
|
-
end
|
15
|
-
|
16
|
-
def filter
|
17
|
-
params[:q]
|
18
|
-
end
|
2
|
+
class BaseController < ::ApplicationController
|
3
|
+
|
4
|
+
helper RailsDash::ApplicationHelper
|
19
5
|
|
20
6
|
end
|
21
7
|
end
|
@@ -5,7 +5,7 @@ module RailsDash
|
|
5
5
|
|
6
6
|
def index
|
7
7
|
@meta_title = @title = "#{@model.model_name.human :count => 2}"
|
8
|
-
@records = @model.filter(
|
8
|
+
@records = @model.filter(params[:q]).page(params[:p].present? ? params[:p].to_i : 1).per(15)
|
9
9
|
end
|
10
10
|
|
11
11
|
def new
|
@@ -54,7 +54,7 @@ module RailsDash
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def index_path
|
57
|
-
|
57
|
+
main_app.url_for(:controller => "dash/#{@model.name.tableize}", :action => 'index')
|
58
58
|
end
|
59
59
|
|
60
60
|
def param
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module RailsDash
|
2
|
+
module ApplicationHelper
|
3
|
+
|
4
|
+
def options(add_button=true)
|
5
|
+
render :partial => 'rails_dash/shared/options', :locals => { :add_button => add_button }
|
6
|
+
end
|
7
|
+
|
8
|
+
def pager(collection)
|
9
|
+
render :partial => 'rails_dash/shared/pager', :locals => { :collection => collection }
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
data/{lib/generators/dash/templates/filter.erb → app/views/rails_dash/shared/_options.html.haml}
RENAMED
@@ -1,5 +1,6 @@
|
|
1
1
|
#options
|
2
2
|
= form_tag request.fullpath, :method => 'get', :id => 'search' do
|
3
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
|
-
|
5
|
-
|
4
|
+
- if add_button
|
5
|
+
%a.button.action{ :href => main_app.url_for([:new, :dash, @model.name.underscore.to_sym]) }
|
6
|
+
= t('dash.grid.add')
|
@@ -8,8 +8,6 @@ module Dash
|
|
8
8
|
route "namespace :dash do\n\n end"
|
9
9
|
template 'dash.erb', 'app/controllers/dash_controller.rb'
|
10
10
|
template 'layout.erb', 'app/views/layouts/dash.html.haml'
|
11
|
-
template 'filter.erb', 'app/views/dash/shared/_filter.html.haml'
|
12
|
-
template 'pager.erb', 'app/views/dash/shared/_pager.html.haml'
|
13
11
|
end
|
14
12
|
|
15
13
|
end
|
@@ -11,14 +11,14 @@ module Dash
|
|
11
11
|
|
12
12
|
def add_scope
|
13
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}%\") }"
|
14
|
+
"\n\n scope :filter, lambda { |filter| where('', :filter => \"%\#{filter.present? ? filter.downcase : ''}%\") }"
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
def add_menu
|
19
19
|
insert_into_file 'app/views/layouts/dash.html.haml', :before => /(.*)#session(.*)/ do
|
20
20
|
"#{' ' * 16}%li\n" +
|
21
|
-
"#{' ' * 18}%a{ :href => url_for(
|
21
|
+
"#{' ' * 18}%a{ :href => main_app.url_for(:controller => 'dash/#{table_name}', :action => 'index'), :title => #{singular_name.camelize}.model_name.human(:count => 2) }\n" +
|
22
22
|
"#{' ' * 20}= #{singular_name.camelize}.model_name.human(:count => 2)\n"
|
23
23
|
end
|
24
24
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
=
|
1
|
+
= options(true)
|
2
2
|
%table{ :cellpadding => '0', :cellspacing => '0' }
|
3
3
|
%tr
|
4
4
|
%th
|
@@ -14,6 +14,8 @@
|
|
14
14
|
%td
|
15
15
|
= l(record.created_at)
|
16
16
|
%td.actions
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
%a{ :href => main_app.url_for([:dash, record]) }
|
18
|
+
= t('dash.grid.edit')
|
19
|
+
%a{ :href => main_app.url_for([:dash, record]), :'data-method' => 'delete' }
|
20
|
+
= t('dash.grid.destroy')
|
21
|
+
= pager(@records)
|
data/lib/rails_dash/version.rb
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
class Photo < ActiveRecord::Base
|
2
2
|
|
3
|
-
scope :filter, lambda { |filter| where('', :filter => "%#{filter}%") }
|
3
|
+
scope :filter, lambda { |filter| where('LOWER(name) LIKE :filter', :filter => "%#{filter.present? ? filter.downcase : ''}%") }
|
4
4
|
|
5
5
|
attr_accessible :name
|
6
6
|
|
7
|
-
class << self
|
8
|
-
|
9
|
-
def list(page, filter)
|
10
|
-
where('LOWER(name) LIKE :filter', :filter => "%#{filter}%").page(page)
|
11
|
-
end
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
7
|
end
|
@@ -1,8 +1,10 @@
|
|
1
|
-
=
|
1
|
+
= options(true)
|
2
2
|
%table{ :cellpadding => '0', :cellspacing => '0' }
|
3
3
|
%tr
|
4
4
|
%th
|
5
5
|
= '#'
|
6
|
+
%th
|
7
|
+
= @model.human_attribute_name('name')
|
6
8
|
%th
|
7
9
|
= @model.human_attribute_name('created_at')
|
8
10
|
%th.actions
|
@@ -11,9 +13,13 @@
|
|
11
13
|
%tr
|
12
14
|
%td
|
13
15
|
= record.id
|
16
|
+
%td
|
17
|
+
= record.name
|
14
18
|
%td
|
15
19
|
= l(record.created_at)
|
16
20
|
%td.actions
|
17
|
-
|
18
|
-
|
19
|
-
|
21
|
+
%a{ :href => main_app.url_for([:dash, record]) }
|
22
|
+
= t('dash.grid.edit')
|
23
|
+
%a{ :href => main_app.url_for([:dash, record]), :'data-method' => 'delete' }
|
24
|
+
= t('dash.grid.destroy')
|
25
|
+
= pager(@records)
|
@@ -15,7 +15,7 @@
|
|
15
15
|
%a{ :href => rails_dash.root_path, :title => t('dash.menu.home') }
|
16
16
|
= t('dash.menu.home')
|
17
17
|
%li
|
18
|
-
%a{ :href => url_for(
|
18
|
+
%a{ :href => main_app.url_for(:controller => 'dash/photos', :action => 'index'), :title => Photo.model_name.human(:count => 2) }
|
19
19
|
= Photo.model_name.human(:count => 2)
|
20
20
|
#session
|
21
21
|
%a.button{ :href => '#', :title => t('dash.session.logout') }
|
@@ -40,4 +40,4 @@
|
|
40
40
|
#footer
|
41
41
|
.holder
|
42
42
|
%p#copyright
|
43
|
-
= t('dash.footer.copyright', :year =>
|
43
|
+
= t('dash.footer.copyright', :year => Time.now.year)
|
data/test/dummy/config/routes.rb
CHANGED
Binary file
|