padrino-admin 0.8.5 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +40 -84
- data/VERSION +1 -1
- data/lib/padrino-admin.rb +3 -20
- data/lib/padrino-admin/access_control.rb +78 -326
- data/lib/padrino-admin/generators/actions.rb +6 -26
- data/lib/padrino-admin/generators/admin_app.rb +40 -11
- data/lib/padrino-admin/generators/admin_page.rb +11 -17
- data/lib/padrino-admin/generators/orm.rb +85 -0
- data/lib/padrino-admin/generators/templates/account/activerecord.rb.tt +43 -0
- data/lib/padrino-admin/generators/templates/account/datamapper.rb.tt +54 -0
- data/lib/padrino-admin/generators/templates/{page/db → account}/seeds.rb.tt +5 -6
- data/lib/padrino-admin/generators/{app/app.rb.tt → templates/app/app.rb} +2 -10
- data/lib/padrino-admin/generators/templates/app/controllers/base.rb +7 -0
- data/lib/padrino-admin/generators/{app → templates/app}/controllers/sessions.rb +6 -6
- data/lib/padrino-admin/generators/templates/assets/stylesheets/base.css +370 -0
- data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/amro/style.css +364 -0
- data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/bec-green/style.css +290 -0
- data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/bec/style.css +301 -0
- data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/blue/style.css +287 -0
- data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/default/style.css +373 -0
- data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/djime-cerulean/style.css +305 -0
- data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/kathleene/style.css +279 -0
- data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/olive/style.css +345 -0
- data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/orange/style.css +269 -0
- data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/reidb-greenish/style.css +302 -0
- data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/ruby/style.css +281 -0
- data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/warehouse/style.css +391 -0
- data/lib/padrino-admin/generators/templates/erb/app/base/_sidebar.erb.tt +13 -0
- data/lib/padrino-admin/generators/templates/erb/app/base/index.erb.tt +17 -0
- data/lib/padrino-admin/generators/templates/erb/app/layouts/application.erb.tt +44 -0
- data/lib/padrino-admin/generators/templates/erb/app/sessions/new.erb.tt +46 -0
- data/lib/padrino-admin/generators/templates/erb/page/_form.erb.tt +11 -0
- data/lib/padrino-admin/generators/templates/erb/page/edit.erb.tt +18 -0
- data/lib/padrino-admin/generators/templates/erb/page/index.erb.tt +36 -0
- data/lib/padrino-admin/generators/templates/erb/page/new.erb.tt +17 -0
- data/lib/padrino-admin/generators/templates/page/controller.rb.tt +32 -22
- data/lib/padrino-admin/helpers/authentication_helpers.rb +8 -9
- data/lib/padrino-admin/helpers/view_helpers.rb +20 -338
- data/lib/padrino-admin/locale/admin/de.yml +15 -49
- data/lib/padrino-admin/locale/admin/en.yml +12 -50
- data/lib/padrino-admin/locale/admin/it.yml +15 -50
- data/padrino-admin.gemspec +40 -321
- data/test/fixtures/data_mapper.rb +56 -7
- data/test/generators/test_admin_app_generator.rb +17 -16
- data/test/generators/test_admin_page_generator.rb +12 -16
- data/test/test_admin_application.rb +193 -12
- metadata +33 -314
- data/lib/padrino-admin/column_store.rb +0 -156
- data/lib/padrino-admin/config.rb +0 -36
- data/lib/padrino-admin/generators/admin_uploader.rb +0 -88
- data/lib/padrino-admin/generators/app/controllers/accounts.rb +0 -37
- data/lib/padrino-admin/generators/app/controllers/base.rb +0 -11
- data/lib/padrino-admin/generators/app/controllers/javascripts.rb +0 -10
- data/lib/padrino-admin/generators/app/views/accounts/_form.haml +0 -24
- data/lib/padrino-admin/generators/app/views/accounts/edit.haml +0 -3
- data/lib/padrino-admin/generators/app/views/accounts/grid.js.erb +0 -9
- data/lib/padrino-admin/generators/app/views/accounts/new.haml +0 -3
- data/lib/padrino-admin/generators/app/views/accounts/store.jml +0 -7
- data/lib/padrino-admin/generators/app/views/base/dashboard.haml +0 -3
- data/lib/padrino-admin/generators/app/views/base/index.haml +0 -19
- data/lib/padrino-admin/generators/app/views/javascripts/admin.js.erb +0 -490
- data/lib/padrino-admin/generators/app/views/javascripts/locale.js.erb +0 -135
- data/lib/padrino-admin/generators/app/views/sessions/new.haml +0 -26
- data/lib/padrino-admin/generators/assets/flash/charts.swf +0 -0
- data/lib/padrino-admin/generators/assets/flash/clippy.swf +0 -0
- data/lib/padrino-admin/generators/assets/flash/expressinstall.swf +0 -0
- data/lib/padrino-admin/generators/assets/flash/swfupload.swf +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/back.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/background.png +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/bg-content.png +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/bg-hd-slate.png +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/bg-hd.png +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/bg-intro.png +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/bg-login.png +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/bg-menu-slate.png +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/bg-menu.png +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/bg.png +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/btn-login.png +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/cancel.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/categories.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/close.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/close.png +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/delete.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/download.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/duplicate.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/edit.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/export.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/hd-bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/image.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/loader.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/logo-loader.png +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/logo-small.png +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/new.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/no-image.png +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/preview.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/print.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/save.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/support.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/up.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/box/corners-blue.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/box/corners.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/box/l-blue.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/box/l.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/box/r-blue.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/box/r.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/box/tb-blue.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/box/tb.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/button/arrow.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/button/btn.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/button/group-cs.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/button/group-lr.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/button/group-tb.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/button/s-arrow-b-noline.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/button/s-arrow-b.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/button/s-arrow-bo.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/button/s-arrow-noline.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/button/s-arrow-o.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/button/s-arrow.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/dd/drop-add.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/dd/drop-no.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/dd/drop-yes.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/editor/tb-sprite.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/form/checkbox.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/form/clear-trigger.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/form/clear-trigger.psd +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/form/date-trigger.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/form/date-trigger.psd +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/form/error-tip-corners.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/form/exclamation.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/form/radio.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/form/search-trigger.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/form/search-trigger.psd +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/form/text-bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/form/trigger-tpl.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/form/trigger.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/form/trigger.psd +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/gradient-bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/Thumbs.db +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/arrow-left-white.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/arrow-right-white.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/col-move-bottom.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/col-move-top.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/columns.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/dirty.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/done.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/drop-no.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/drop-yes.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/footer-bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/grid-blue-hd.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/grid-blue-split.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/grid-hrow.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/grid-loading.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/grid-split.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/grid-vista-hd.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/grid3-hd-btn.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/grid3-hrow-over.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/grid3-hrow.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/grid3-special-col-bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/grid3-special-col-sel-bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/group-by.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/group-expand-sprite.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/hd-pop.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/hmenu-asc.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/hmenu-desc.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/hmenu-lock.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/hmenu-lock.png +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/hmenu-unlock.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/hmenu-unlock.png +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/invalid_line.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/loading.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/mso-hd.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/nowait.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/page-first-disabled.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/page-first.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/page-last-disabled.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/page-last.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/page-next-disabled.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/page-next.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/page-prev-disabled.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/page-prev.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/pick-button.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/refresh.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/row-check-sprite.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/row-expand-sprite.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/row-over.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/row-sel.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/sort-hd.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/sort_asc.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/sort_desc.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/wait.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/layout/collapse.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/layout/expand.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/layout/gradient-bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/layout/mini-bottom.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/layout/mini-left.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/layout/mini-right.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/layout/mini-top.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/layout/ns-collapse.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/layout/ns-expand.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/layout/panel-close.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/layout/panel-title-bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/layout/panel-title-light-bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/layout/stick.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/layout/stuck.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/layout/tab-close-on.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/layout/tab-close.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/menu/checked.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/menu/group-checked.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/menu/item-over.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/menu/menu-parent.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/menu/menu.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/menu/unchecked.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/panel/corners-sprite.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/panel/left-right.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/panel/light-hd.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/panel/tool-sprite-tpl.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/panel/tool-sprites.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/panel/tools-sprites-trans.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/panel/top-bottom.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/panel/top-bottom.png +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/panel/white-corners-sprite.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/panel/white-left-right.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/panel/white-top-bottom.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/progress/progress-bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/qtip/bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/qtip/close.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/qtip/tip-anchor-sprite.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/qtip/tip-sprite.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/s.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/shadow-c.png +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/shadow-lr.png +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/shadow.png +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/shared/blue-loading.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/shared/calendar.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/shared/glass-bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/shared/hd-sprite.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/shared/large-loading.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/shared/left-btn.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/shared/loading-balls.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/shared/right-btn.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/shared/warning.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/sizer/e-handle-dark.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/sizer/e-handle.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/sizer/ne-handle-dark.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/sizer/ne-handle.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/sizer/nw-handle-dark.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/sizer/nw-handle.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/sizer/s-handle-dark.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/sizer/s-handle.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/sizer/se-handle-dark.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/sizer/se-handle.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/sizer/square.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/sizer/sw-handle-dark.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/sizer/sw-handle.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/slider/slider-bg.png +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/slider/slider-thumb.png +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/slider/slider-v-bg.png +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/slider/slider-v-thumb.png +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tabs/scroll-left.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tabs/scroll-right.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tabs/scroller-bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tabs/tab-btm-inactive-left-bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tabs/tab-btm-inactive-right-bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tabs/tab-btm-left-bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tabs/tab-btm-right-bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tabs/tab-close.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tabs/tab-strip-bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tabs/tab-strip-bg.png +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tabs/tab-strip-btm-bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tabs/tabs-sprite.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/toolbar/bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/toolbar/btn-arrow-light.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/toolbar/btn-arrow.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/toolbar/btn-over-bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/toolbar/gray-bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/toolbar/more.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/toolbar/tb-bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/toolbar/tb-btn-sprite.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/toolbar/tb-xl-btn-sprite.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/toolbar/tb-xl-sep.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/arrows.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/drop-add.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/drop-between.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/drop-no.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/drop-over.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/drop-under.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/drop-yes.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/elbow-end-minus-nl.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/elbow-end-minus.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/elbow-end-plus-nl.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/elbow-end-plus.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/elbow-end.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/elbow-line.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/elbow-minus-nl.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/elbow-minus.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/elbow-plus-nl.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/elbow-plus.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/elbow.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/folder-open.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/folder.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/leaf.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/loading.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/s.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/window/icon-error.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/window/icon-info.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/window/icon-question.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/window/icon-warning.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/window/left-corners.png +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/window/left-corners.psd +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/window/left-right.png +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/window/left-right.psd +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/window/right-corners.png +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/window/right-corners.psd +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/window/top-bottom.png +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/window/top-bottom.psd +0 -0
- data/lib/padrino-admin/generators/assets/javascripts/controls.js +0 -3
- data/lib/padrino-admin/generators/assets/javascripts/dragdrop.js +0 -3
- data/lib/padrino-admin/generators/assets/javascripts/effects.js +0 -4
- data/lib/padrino-admin/generators/assets/javascripts/ext.js +0 -29
- data/lib/padrino-admin/generators/assets/javascripts/prototype.js +0 -14
- data/lib/padrino-admin/generators/assets/javascripts/swfupload.js +0 -4
- data/lib/padrino-admin/generators/assets/stylesheets/admin.css +0 -60
- data/lib/padrino-admin/generators/assets/stylesheets/ext.css +0 -1543
- data/lib/padrino-admin/generators/assets/stylesheets/login.css +0 -17
- data/lib/padrino-admin/generators/assets/stylesheets/standard.css +0 -62
- data/lib/padrino-admin/generators/templates/page/views/_form.haml.tt +0 -9
- data/lib/padrino-admin/generators/templates/page/views/edit.haml.tt +0 -3
- data/lib/padrino-admin/generators/templates/page/views/grid.js.erb.tt +0 -9
- data/lib/padrino-admin/generators/templates/page/views/new.haml.tt +0 -3
- data/lib/padrino-admin/generators/templates/page/views/store.jml.tt +0 -6
- data/lib/padrino-admin/generators/templates/uploader/controller.rb +0 -24
- data/lib/padrino-admin/generators/templates/uploader/lib/uploader.rb +0 -66
- data/lib/padrino-admin/generators/templates/uploader/views/grid.js.erb +0 -57
- data/lib/padrino-admin/generators/templates/uploader/views/store.jml +0 -10
- data/lib/padrino-admin/locale/extjs/de.yml +0 -147
- data/lib/padrino-admin/locale/extjs/en.yml +0 -147
- data/lib/padrino-admin/locale/extjs/it.yml +0 -147
- data/lib/padrino-admin/orm.rb +0 -48
- data/lib/padrino-admin/orm/abstract.rb +0 -95
- data/lib/padrino-admin/orm/activerecord.rb +0 -144
- data/lib/padrino-admin/orm/datamapper.rb +0 -229
- data/lib/padrino-admin/orm/mongomapper.rb +0 -65
- data/lib/padrino-admin/utils/literal.rb +0 -13
- data/test/fixtures/active_record.rb +0 -29
- data/test/fixtures/mongo_mapper.rb +0 -12
- data/test/fixtures/test_column_store.jml +0 -11
- data/test/generators/test_admin_uploader_generator.rb +0 -56
- data/test/test_access_control.rb +0 -99
- data/test/test_active_record.rb +0 -96
- data/test/test_column_store.rb +0 -87
- data/test/test_config.rb +0 -13
- data/test/test_data_mapper.rb +0 -114
- data/test/test_mongo_mapper.rb +0 -30
@@ -0,0 +1,46 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
2
|
+
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
|
3
|
+
<head>
|
4
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
5
|
+
<title><%= options[:name] %></title>
|
6
|
+
<%%= stylesheet_link_tag :base, :override, "themes/<%= options[:theme] %>/style" %>
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
<div id="container">
|
10
|
+
<div id="box">
|
11
|
+
<h1><%= options[:name] %></h1>
|
12
|
+
<div class="block" id="block-login">
|
13
|
+
<h2>Login Box</h2>
|
14
|
+
<div class="content login">
|
15
|
+
<div class="flash">
|
16
|
+
<%%= [:error, :warning, :notice].map { |type| flash_tag(type, :class => "message #{type}") }.join %>
|
17
|
+
</div>
|
18
|
+
<%% form_tag(url(:sessions, :create), :class => 'form login') do %>
|
19
|
+
<div class="group wat-cf">
|
20
|
+
<div class="left">
|
21
|
+
<label class="label right">Login</label>
|
22
|
+
</div>
|
23
|
+
<div class="right">
|
24
|
+
<%%= text_field_tag :email, :value => params[:email], :class => 'text_field' %>
|
25
|
+
</div>
|
26
|
+
</div>
|
27
|
+
<div class="group wat-cf">
|
28
|
+
<div class="left">
|
29
|
+
<label class="label right">Password</label>
|
30
|
+
</div>
|
31
|
+
<div class="right">
|
32
|
+
<%%= password_field_tag :password, :value => params[:password], :class => 'text_field' %>
|
33
|
+
</div>
|
34
|
+
</div>
|
35
|
+
<div class="group navform wat-cf">
|
36
|
+
<div class="right">
|
37
|
+
<input type="submit" class="button" value="Sign in" />
|
38
|
+
</div>
|
39
|
+
</div>
|
40
|
+
<%% end %>
|
41
|
+
</div>
|
42
|
+
</div>
|
43
|
+
</div>
|
44
|
+
</div>
|
45
|
+
</body>
|
46
|
+
</html>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<% @orm.column_fields.each do |column| -%>
|
2
|
+
<div class="group">
|
3
|
+
<%%= f.label :<%= column[:name] %> %><%%= f.error_message_on :<%= column[:name] %> %>
|
4
|
+
<%%= f.<%= column[:field_type] %> :<%= column[:name] %>, :class => :<%= column[:field_type] %> %>
|
5
|
+
<span class="description">Ex: a simple text</span>
|
6
|
+
</div>
|
7
|
+
<% end %>
|
8
|
+
<div class="group navform wat-cf">
|
9
|
+
<%%= f.submit pat(:save), :class => :button %>
|
10
|
+
<%%= f.submit pat(:cancel), :onclick => "window.location='#{url(:accounts, :index)}';return false", :class => :button %>
|
11
|
+
</div>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<div class="block">
|
2
|
+
<div class="secondary-navigation">
|
3
|
+
<ul class="wat-cf">
|
4
|
+
<li class="first"><%%= link_to pat(:list), url(:<%= @orm.name_plural %>, :index) %></li>
|
5
|
+
<li><%%= link_to pat(:new), url(:<%= @orm.name_plural %>, :new) %></li>
|
6
|
+
<li class="active"><%%= link_to pat(:edit), url(:<%= @orm.name_plural %>, :edit, :id => @<%= @orm.name_singular %>.id) %></li>
|
7
|
+
</ul>
|
8
|
+
</div>
|
9
|
+
<div class="content">
|
10
|
+
<h2 class="title"><%%= pat(:edit) %> <%% mt(:<%= @orm.name_singular %>) %></h2>
|
11
|
+
<div class="inner">
|
12
|
+
<%% form_for :<%= @orm.name_singular %>, url(:<%= @orm.name_plural %>, :update, :id => @<%= @orm.name_singular %>.id), :method => :put, :class => :form do |f| %>
|
13
|
+
<%%= partial "<%= @orm.name_plural %>/form", :locals => { :f => f } %>
|
14
|
+
<%% end %>
|
15
|
+
</div>
|
16
|
+
</div>
|
17
|
+
</div>
|
18
|
+
<%% content_for :sidebar, partial("base/sidebar") %>
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<div class="block">
|
2
|
+
<div class="secondary-navigation">
|
3
|
+
<ul class="wat-cf">
|
4
|
+
<li class="first active"><%%= link_to pat(:list), url(:<%= @orm.name_plural %>, :index) %></li>
|
5
|
+
<li><%%= link_to pat(:new), url(:<%= @orm.name_plural %>, :new) %></li>
|
6
|
+
</ul>
|
7
|
+
</div>
|
8
|
+
<div class="content">
|
9
|
+
<h2 class="title"><%%= pat(:all) %> <%% mt(:<%= @orm.name_singular %>) %></h2>
|
10
|
+
<div class="inner">
|
11
|
+
<table class="table">
|
12
|
+
<tr>
|
13
|
+
<%- @orm.columns.each_with_index do |column, i| -%>
|
14
|
+
<th<%= " class=\"first\"" if i==0 %>><%%= mat(:<%= @orm.name_singular %>, :<%= column.name %>) %></th>
|
15
|
+
<%- end -%>
|
16
|
+
<th class="last"> </th>
|
17
|
+
</tr>
|
18
|
+
<%% @<%= @orm.name_plural %>.each do |<%= @orm.name_singular %>| %>
|
19
|
+
<tr>
|
20
|
+
<%- @orm.columns.each_with_index do |column, i| -%>
|
21
|
+
<td<%= " class=\"first\"" if i==0 %>><%%= link_to <%= @orm.name_singular %>.<%= column.name %>, url(:<%= @orm.name_plural %>, :edit, :id => <%= @orm.name_singular %>.id) %></td>
|
22
|
+
<%- end -%>
|
23
|
+
<td class="last">
|
24
|
+
<%%= button_to pat(:edit), url(:<%= @orm.name_plural %>, :edit, :id => <%= @orm.name_singular %>.id), :method => :get, :class => :button_to %> |
|
25
|
+
<%%= button_to pat(:delete), url(:<%= @orm.name_plural %>, :destroy, :id => <%= @orm.name_singular %>.id), :method => :delete, :class => :button_to %>
|
26
|
+
</td>
|
27
|
+
</tr>
|
28
|
+
<%% end %>
|
29
|
+
</table>
|
30
|
+
<div class="actions-bar wat-cf">
|
31
|
+
<div class="actions"></div>
|
32
|
+
</div>
|
33
|
+
</div>
|
34
|
+
</div>
|
35
|
+
</div>
|
36
|
+
<%% content_for :sidebar, partial("base/sidebar") %>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<div class="block">
|
2
|
+
<div class="secondary-navigation">
|
3
|
+
<ul class="wat-cf">
|
4
|
+
<li class="first"><%%= link_to pat(:list), url(:<%= @orm.name_plural %>, :index) %></li>
|
5
|
+
<li class="active"><%%= link_to pat(:new), url(:<%= @orm.name_plural %>, :new) %></li>
|
6
|
+
</ul>
|
7
|
+
</div>
|
8
|
+
<div class="content">
|
9
|
+
<h2 class="title"><%%= pat(:new) %> <%% mt(:<%= @orm.name_singular %>) %></h2>
|
10
|
+
<div class="inner">
|
11
|
+
<%% form_for :<%= @orm.name_singular %>, url(:<%= @orm.name_plural %>, :create), :class => :form do |f| %>
|
12
|
+
<%%= partial "<%= @orm.name_plural %>/form", :locals => { :f => f } %>
|
13
|
+
<%% end %>
|
14
|
+
</div>
|
15
|
+
</div>
|
16
|
+
</div>
|
17
|
+
<%% content_for :sidebar, partial("base/sidebar") %>
|
@@ -1,37 +1,47 @@
|
|
1
|
-
Admin.controllers :<%= @
|
1
|
+
Admin.controllers :<%= @orm.name_plural %> do
|
2
2
|
|
3
|
-
get :index
|
4
|
-
@
|
5
|
-
|
6
|
-
when :js then render '<%= @model_plural %>/grid.js'
|
7
|
-
when :json then @store.store_data(params)
|
8
|
-
end
|
3
|
+
get :index do
|
4
|
+
@<%= @orm.name_plural %> = <%= @orm.all %>
|
5
|
+
render '<%= @orm.name_plural %>/index'
|
9
6
|
end
|
10
7
|
|
11
8
|
get :new do
|
12
|
-
@<%= @
|
13
|
-
render '<%= @
|
9
|
+
@<%= @orm.name_singular %> = <%= @orm.build %>
|
10
|
+
render '<%= @orm.name_plural %>/new'
|
14
11
|
end
|
15
12
|
|
16
|
-
post :create
|
17
|
-
@<%= @
|
18
|
-
|
13
|
+
post :create do
|
14
|
+
@<%= @orm.name_singular %> = <%= @orm.build("params[:#{@orm.name_singular}]") %>
|
15
|
+
if @<%= @orm.save %>
|
16
|
+
flash[:notice] = '<%= @orm.klass_name %> was successfully created.'
|
17
|
+
redirect url(:<%= @orm.name_plural %>, :edit, :id => @<%= @orm.name_singular%>.id)
|
18
|
+
else
|
19
|
+
render '<%= @orm.name_plural %>/new'
|
20
|
+
end
|
19
21
|
end
|
20
22
|
|
21
23
|
get :edit, :with => :id do
|
22
|
-
@<%= @
|
23
|
-
render '<%= @
|
24
|
+
@<%= @orm.name_singular %> = <%= @orm.find("params[:id]") %>
|
25
|
+
render '<%= @orm.name_plural %>/edit'
|
24
26
|
end
|
25
27
|
|
26
|
-
put :update, :with => :id
|
27
|
-
@<%= @
|
28
|
-
@<%= @
|
29
|
-
|
28
|
+
put :update, :with => :id do
|
29
|
+
@<%= @orm.name_singular %> = <%= @orm.find("params[:id]") %>
|
30
|
+
if @<%= @orm.update_attributes("params[:#{@orm.name_singular}]") %>
|
31
|
+
flash[:notice] = '<%= @orm.klass_name %> was successfully updated.'
|
32
|
+
redirect url(:<%= @orm.name_plural %>, :edit, :id => @<%= @orm.name_singular %>.id)
|
33
|
+
else
|
34
|
+
render '<%= @orm.name_plural %>/edit'
|
35
|
+
end
|
30
36
|
end
|
31
37
|
|
32
|
-
delete :destroy, :
|
33
|
-
<%= @
|
34
|
-
|
35
|
-
|
38
|
+
delete :destroy, :with => :id do
|
39
|
+
<%= @orm.name_singular %> = <%= @orm.find("params[:id]") %>
|
40
|
+
if <%= @orm.destroy %>
|
41
|
+
flash[:notice] = '<%= @orm.klass_name %> was successfully destroyed.'
|
42
|
+
else
|
43
|
+
flash[:error] = 'Impossible destroy <%= @orm.klass_name %>!'
|
44
|
+
end
|
45
|
+
redirect url(:<%= @orm.name_plural %>, :index)
|
36
46
|
end
|
37
47
|
end
|
@@ -16,14 +16,6 @@ module Padrino
|
|
16
16
|
@current_account ||= login_from_session
|
17
17
|
end
|
18
18
|
|
19
|
-
##
|
20
|
-
# Return the admin menu
|
21
|
-
#
|
22
|
-
def admin_menu
|
23
|
-
return "[]" unless current_account
|
24
|
-
access_control.auths(current_account).project_modules.collect(&:config).to_json
|
25
|
-
end
|
26
|
-
|
27
19
|
##
|
28
20
|
# Ovverride the current_account, you must provide an instance of Account Model
|
29
21
|
#
|
@@ -42,7 +34,14 @@ module Padrino
|
|
42
34
|
# For configure this role please refer to: +Padrino::Admin::AccessControl::Base+
|
43
35
|
#
|
44
36
|
def allowed?
|
45
|
-
access_control.
|
37
|
+
access_control.allowed?(current_account, request.path_info)
|
38
|
+
end
|
39
|
+
|
40
|
+
##
|
41
|
+
# Returns project modules for the current account
|
42
|
+
#
|
43
|
+
def project_modules
|
44
|
+
access_control.project_modules(current_account)
|
46
45
|
end
|
47
46
|
|
48
47
|
##
|
@@ -3,364 +3,46 @@ module Padrino
|
|
3
3
|
module Helpers
|
4
4
|
module ViewHelpers
|
5
5
|
##
|
6
|
-
#
|
7
|
-
#
|
8
|
-
# An interesting thing wose that this helper
|
9
|
-
# try to translate itself to your current locale ex:
|
10
|
-
#
|
11
|
-
# ==== Examples
|
12
|
-
#
|
13
|
-
# # Look for: I18n.t("admin.titles.welcome_here", :default => "Welcome Here")
|
14
|
-
# title :welcome_here
|
15
|
-
# # In this case we provide a +String+ so we don't try to translate them.
|
16
|
-
# title "This is my page title"
|
17
|
-
#
|
18
|
-
def title(title)
|
19
|
-
title = I18n.t("admin.titles.#{title}", :default => title.to_s) if title.is_a?(Symbol)
|
20
|
-
tag(:span, :title => title)
|
21
|
-
end
|
22
|
-
|
23
|
-
##
|
24
|
-
# This method work like error_message_for but use an Ext.Message.show({..}).
|
25
|
-
#
|
26
|
-
# It can return a list of errors like error_messages_for do but also (if no errors occours)
|
27
|
-
# a great message box that indicate the success of the action.
|
28
|
-
#
|
29
|
-
# ==== Options
|
30
|
-
#
|
31
|
-
# :url:: Used for change the <form.action>
|
32
|
-
# :method:: Used for change the <form.method>
|
33
|
-
# :header_tag:: Used for the header of the error div (default: "h2").
|
34
|
-
# :id:: The id of the error div (default: "errorExplanation").
|
35
|
-
# :class:: The class of the error div (default: "errorExplanation").
|
36
|
-
# :object:: The object (or array of objects) for which to display errors,
|
37
|
-
# if you need to escape the instance variable convention.
|
38
|
-
# :object_name:: The object name to use in the header, or any text that you prefer.
|
39
|
-
# If +:object_name+ is not set, the name of the first object will be used.
|
40
|
-
# :header_message:: The message in the header of the error div. Pass +nil+
|
41
|
-
# or an empty string to avoid the header message altogether. (Default: "X errors
|
42
|
-
# prohibited this object from being saved").
|
43
|
-
# :message:: The explanation message after the header message and before
|
44
|
-
# the error list. Pass +nil+ or an empty string to avoid the explanation message
|
45
|
-
# altogether. (Default: "There were problems with the following fields:").
|
6
|
+
# Translate a given word for padrino admin
|
46
7
|
#
|
47
8
|
# ==== Examples
|
48
9
|
#
|
49
|
-
# #
|
50
|
-
#
|
51
|
-
# show_messages_for :account
|
10
|
+
# # => t("padrino.admin.profile", :default => "Profile")
|
11
|
+
# pat(:profile)
|
52
12
|
#
|
53
|
-
# #
|
54
|
-
#
|
55
|
-
# show_messages_for :account, :url => url(:accounts_create), :method => :create
|
13
|
+
# # => t("padrino.admin.profile", :default => "My Profile")
|
14
|
+
# pat(:profile, "My Profile")
|
56
15
|
#
|
57
|
-
def
|
58
|
-
|
59
|
-
count = object.errors.count
|
60
|
-
error_cleaner = object.class.properties.map { |field|
|
61
|
-
(<<-JAVASCRIPT).gsub(/ {12}/, '')
|
62
|
-
parent.body.select('*[id=#{object.class.name.underscore}_#{field.name}]').each(function(field){
|
63
|
-
field.removeClass('x-form-invalid');
|
64
|
-
});
|
65
|
-
JAVASCRIPT
|
66
|
-
}.join("\n")
|
67
|
-
|
68
|
-
unless count.zero?
|
69
|
-
html = {}
|
70
|
-
options[:object_name] ||= object.class
|
71
|
-
|
72
|
-
I18n.with_options :locale => options[:locale], :scope => [:models, :errors, :template] do |locale|
|
73
|
-
header_message = if options.include?(:header_message)
|
74
|
-
escape_javascript(options[:header_message])
|
75
|
-
else
|
76
|
-
object_name = options[:object_name].to_s.gsub('_', ' ')
|
77
|
-
object_name = I18n.t(object_name, :default => object_name, :scope => [:models], :count => 1)
|
78
|
-
escape_javascript(locale.t :header, :count => count, :model => object_name)
|
79
|
-
end
|
80
|
-
message = escape_javascript(options.include?(:message) ? options[:message] : locale.t(:body))
|
81
|
-
error_messages = object.errors.full_messages.map { |msg| content_tag(:li, escape_javascript(msg)) }.join
|
82
|
-
error_highlighter = object.errors_keys.map { |column|
|
83
|
-
(<<-JAVASCRIPT).gsub(/ {16}/, '')
|
84
|
-
parent.body.select('*[id=#{object.class.name.underscore}_#{column}]').each(function(field){
|
85
|
-
field.addClass('x-form-invalid');
|
86
|
-
});
|
87
|
-
JAVASCRIPT
|
88
|
-
}.join("\n")
|
89
|
-
contents = ''
|
90
|
-
contents << content_tag(:p, message) if message.present?
|
91
|
-
contents << content_tag(:ul, error_messages, :class => :list)
|
92
|
-
|
93
|
-
(<<-JAVASCRIPT).gsub(/ {14}/, '')
|
94
|
-
var parent = Ext.WindowMgr.getActive();
|
95
|
-
#{error_cleaner}
|
96
|
-
Ext.Msg.show({
|
97
|
-
title: '#{header_message}',
|
98
|
-
msg: '#{contents}',
|
99
|
-
buttons: Ext.Msg.OK,
|
100
|
-
minWidth: 400
|
101
|
-
});
|
102
|
-
#{error_highlighter}
|
103
|
-
JAVASCRIPT
|
104
|
-
end
|
105
|
-
else
|
106
|
-
options[:url] ||= url("#{object.class.name.underscore.pluralize}_update".to_sym, :id => object.id, :format => :js)
|
107
|
-
options[:method] ||= "put"
|
108
|
-
(<<-JAVASCRIPT).gsub(/ {12}/, '')
|
109
|
-
var parent = Ext.WindowMgr.getActive();
|
110
|
-
var form = parent.body.select('form').first().dom;
|
111
|
-
form.action = '#{options[:url]}';
|
112
|
-
form.method = '#{options[:method]}';
|
113
|
-
#{error_cleaner}
|
114
|
-
Ext.Msg.alert(Admin.locale.messages.compliments.title, Admin.locale.messages.compliments.message);
|
115
|
-
JAVASCRIPT
|
116
|
-
end
|
16
|
+
def padrino_admin_translate(word, default=nil)
|
17
|
+
t("padrino.admin.#{word}", :default => (default || word.to_s.humanize))
|
117
18
|
end
|
19
|
+
alias :pat :padrino_admin_translate
|
118
20
|
|
119
21
|
##
|
120
|
-
#
|
121
|
-
#
|
122
|
-
# First argument is the name and title of the tab, an interesting thing wose that this helper
|
123
|
-
# try to translate itself to your current locale ex:
|
124
|
-
#
|
125
|
-
# === Examples
|
126
|
-
#
|
127
|
-
# # Look for: I18n.t("admin.tabs.settings", :default => "Settings")
|
128
|
-
# tab :settings do
|
129
|
-
# ...
|
130
|
-
# # In this case we provide a +String+ so we don't try to translate them.
|
131
|
-
# tab "This is my tab title"
|
132
|
-
#
|
133
|
-
def tab(name, options={}, &block)
|
134
|
-
options[:id] ||= name.to_s.downcase.gsub(/[^a-z0-9]+/, '_').gsub(/-+$/, '').gsub(/^-+$/, '')
|
135
|
-
options[:style] = "padding:10px;#{options[:style]}"
|
136
|
-
options[:title] = name.is_a?(Symbol) ? I18n.t("admin.tabs.#{name.to_s.downcase}", :default => name.to_s.humanize) : name
|
137
|
-
options[:tabbed] = true
|
138
|
-
options[:class] = "x-hide-display"
|
139
|
-
container = content_tag(:div, capture_html(&block), :class => :full) # Is necessary for IE6+
|
140
|
-
concat_content content_tag(:div, container, options)
|
141
|
-
end
|
142
|
-
|
143
|
-
##
|
144
|
-
# This method generates a new ExtJs BoxComponent.
|
145
|
-
#
|
146
|
-
# Our box can be collapsible so you can minimize them.
|
147
|
-
# When you click on a box it will be expanded while others will be minimized (if all are collapsible)
|
148
|
-
#
|
149
|
-
# ==== Options
|
150
|
-
#
|
151
|
-
# :collapsible:: Indicate if the box can be minimized (clicking on the header). Default +false+
|
152
|
-
# :start:: Indicate if the box on rendering is minimized or expanded. Can be: +open+ or +close+. Default +open+.
|
153
|
-
# :style:: Stylesheet of the box container.
|
154
|
-
# :class:: CSS Class of the box container.
|
22
|
+
# Translate attribute name for the given model
|
155
23
|
#
|
156
24
|
# ==== Examples
|
157
25
|
#
|
158
|
-
# #
|
159
|
-
#
|
160
|
-
# my content
|
26
|
+
# # => t("models.account.email", :default => "Email")
|
27
|
+
# mat(:account, :email)
|
161
28
|
#
|
162
|
-
|
163
|
-
|
164
|
-
# my content
|
165
|
-
#
|
166
|
-
# # Create a minimized box that is collapsible.
|
167
|
-
# -box "My Box 3", "My Subtitle", :collapsible => true, :start => :close do
|
168
|
-
# my content
|
169
|
-
#
|
170
|
-
# In this example when you click on "My Box 3", "My Box 2" will be minimized and nothing will happen on "My Box 1".
|
171
|
-
# When you click on "My Box 2" it will be expanded and "My Box 3" will be minimized and nothing will happen on "My Box 1"
|
172
|
-
#
|
173
|
-
# Also box title can be translated if you provide a +Symbol+ so if you create a box like:
|
174
|
-
#
|
175
|
-
# # Look for: I18n.t("admin.boxs.foo_bar", :default => "Foo Bar")
|
176
|
-
# -box :foo_bar do
|
177
|
-
# ...
|
178
|
-
#
|
179
|
-
def box(title=nil, options={}, &block)
|
180
|
-
title = I18n.t("admin.boxes.#{title}", :default => title.to_s.humanize) if title.is_a?(Symbol)
|
181
|
-
subtitle = options.delete(:subtitle)
|
182
|
-
options[:style] ||= "width:100%;"
|
183
|
-
options[:start] ||= :open
|
184
|
-
concat_content (<<-HTML).gsub(/ {10}/, '')
|
185
|
-
<div class="#{options[:class]}" style="#{options[:style]}">
|
186
|
-
<div class="x-box">
|
187
|
-
<div class="x-box-tl">
|
188
|
-
<div class="x-box-tr">
|
189
|
-
<div class="x-box-tc"> </div>
|
190
|
-
</div>
|
191
|
-
</div>
|
192
|
-
<div class="x-box-ml">
|
193
|
-
<div class="x-box-mr">
|
194
|
-
<div class="x-box-mc">
|
195
|
-
<div id="x-body-title" style="#{"cursor:pointer" if options[:collapsible]}" onclick="#{"Admin.app.collapseBoxes(this);" if options[:collapsible]}">
|
196
|
-
#{"<h3 style=\"margin-bottom:0px;padding-bottom:0px;float:left;\">"+title+"</h3>" if title.present?}
|
197
|
-
#{"<div style=\"float:right\"><em>"+subtitle+"</em></div>" if subtitle.present?}
|
198
|
-
#{"<br class=\"clear\" />" if title.present? || subtitle.present?}
|
199
|
-
#{"<div style=\"font-size:0px\"> </div>" if title.present? || subtitle.present?}
|
200
|
-
</div>
|
201
|
-
<div class="#{"x-box-collapsible" if options[:collapsible]}" style="width:99%;#{"display:none" if options[:collapsible] && options[:start] == :close}">
|
202
|
-
#{"<div style=\"font-size:10px\"> </div>" if title.present? || subtitle.present?}
|
203
|
-
#{capture_html(&block)}
|
204
|
-
</div>
|
205
|
-
</div>
|
206
|
-
</div>
|
207
|
-
</div>
|
208
|
-
<div class="x-box-bl">
|
209
|
-
<div class="x-box-br">
|
210
|
-
<div class="x-box-bc"> </div>
|
211
|
-
</div>
|
212
|
-
</div>
|
213
|
-
</div>
|
214
|
-
</div>
|
215
|
-
HTML
|
29
|
+
def model_attribute_translate(model, attribute)
|
30
|
+
t("models.#{model}.#{attribute}", :default => attribute.to_s.humanize)
|
216
31
|
end
|
32
|
+
alias :mat :model_attribute_translate
|
217
33
|
|
218
34
|
##
|
219
|
-
#
|
220
|
-
#
|
221
|
-
# ==== Options
|
222
|
-
#
|
223
|
-
# :with:: name of the association. Ex: :images.
|
224
|
-
# :url:: the url of the gird, by default we autogenerate them using +:with+ ex: url(:images_index, :format => :js)
|
225
|
-
# :controller:: the name of the controller that contains the gird, by default is +:with+
|
226
|
-
# :show:: value to display, if it's a symbol we tranform them using +with+ ex: :name, will be: data["images.name"]
|
227
|
-
# :get:: value to store in our db, Default: +:id+
|
228
|
-
# :grid:: the name of the var of Admin.grid. Default :grid
|
229
|
-
# :item:: the name of container. This necessary in cases where our grid it's in another container.
|
230
|
-
# :update:: javascript function to handle when the user close grid with some selections. Default autogenerated.
|
231
|
-
# :prompt:: text or html tag to prompt. Default is autogenerated.
|
232
|
-
# :prompt_destroy:: text or html tag to prompt for clear current selections. Default is autogenerated.
|
233
|
-
# :function:: name of the function. Default is autogenerated.
|
234
|
-
# :multiple:: if true returns a collections of +:value+. Default false.
|
35
|
+
# Translate model name
|
235
36
|
#
|
236
37
|
# ==== Examples
|
237
38
|
#
|
238
|
-
# #
|
239
|
-
#
|
240
|
-
# # function showAccountImages(){
|
241
|
-
# # Ext.Ajax.request({
|
242
|
-
# # url: '/admin/images.js',
|
243
|
-
# # scripts: false,
|
244
|
-
# # success: function(response){
|
245
|
-
# # try { eval(response.responseText) } catch(e) { Admin.app.error(e) };
|
246
|
-
# # var win = new Admin.window({ grid: grid, width: 800, height: 600 });
|
247
|
-
# # win.on('selected', function(win, selections){ ... });
|
248
|
-
# # win.show();
|
249
|
-
# # }
|
250
|
-
# # });
|
251
|
-
# # }
|
252
|
-
# # </script>
|
253
|
-
# # <ul id="account_images">
|
254
|
-
# # <li>
|
255
|
-
# # <span id="display">Foo</span>
|
256
|
-
# # <input type="hidden" name="account[image_ids][]" value = "1" />
|
257
|
-
# # <a href="#" onclick="this.up('li').destroy(); return false">Remove</a>
|
258
|
-
# # </li>
|
259
|
-
# # <li>
|
260
|
-
# # <span id="display">Bar</span>
|
261
|
-
# # <input type="hidden" name="account[image_ids][]" value = "2" />
|
262
|
-
# # <a href="#" onclick="this.up('li').destroy(); return false">Remove</a>
|
263
|
-
# # </li>
|
264
|
-
# # </ul>
|
265
|
-
# # <a href="#" onclick="showAccountImages(); return false">Show Images</a>
|
266
|
-
# open_grid :account, :image_ids, :with => :images, :show => :name, :get => :id, :multiple => true
|
39
|
+
# # => t("models.account.name", :default => "Account")
|
40
|
+
# mt(:account)
|
267
41
|
#
|
268
|
-
def
|
269
|
-
|
270
|
-
# We need plural version of our association
|
271
|
-
options[:controller] ||= options[:with]
|
272
|
-
controller = options[:multiple] ? options[:controller] : "#{options[:controller].to_s.pluralize}".to_sym
|
273
|
-
|
274
|
-
# Now we need our association
|
275
|
-
association = instance_variable_get("@#{object_name}").send(options[:with])
|
276
|
-
|
277
|
-
# Parsing not mandatory options
|
278
|
-
options[:url] ||= url("#{controller}_index".to_sym, :format => :js, :small => true)
|
279
|
-
options[:grid] ||= :grid
|
280
|
-
options[:item] ||= :undefined
|
281
|
-
options[:get] ||= :id
|
282
|
-
options[:prompt] ||= image_tag("admin/new.gif", :style => "vertical-align:bottom;padding:2px")
|
283
|
-
options[:function] ||= "show#{object_name.to_s.capitalize}#{options[:with].to_s.capitalize}"
|
284
|
-
|
285
|
-
# Here we build our html template
|
286
|
-
input_name = "#{object_name}[#{method}]"
|
287
|
-
input_name += "[]" if options[:multiple]
|
288
|
-
|
289
|
-
# We need always some defaults values
|
290
|
-
defaults = hidden_field_tag(input_name)
|
291
|
-
|
292
|
-
# Now a reusable (also from extjs) template
|
293
|
-
template = (<<-HTML).gsub(/ {10}/, "")
|
294
|
-
<li>
|
295
|
-
<span class="display">{0}</span>
|
296
|
-
<input type="hidden" name="#{input_name}" value="{1}">
|
297
|
-
<a href="#" onclick="this.up(\\'li\\').remove(); return false" class="closebutton"> </a>
|
298
|
-
</li>
|
299
|
-
HTML
|
300
|
-
|
301
|
-
# We create a collection of <li>
|
302
|
-
collection = Array(association).map do |item|
|
303
|
-
template.gsub("{0}", item.send(options[:show]).to_s).
|
304
|
-
gsub("{1}", item.send(options[:get]).to_s)
|
305
|
-
end
|
306
|
-
|
307
|
-
# And we add our link for add new records
|
308
|
-
li_link = content_tag(:li, link_to(options[:prompt], "#", :onclick => "#{options[:function]}(); return false;"), :class => :clean)
|
309
|
-
collection << li_link
|
310
|
-
|
311
|
-
# Now we have the final container
|
312
|
-
container = content_tag(:ul, defaults + collection.join.gsub("\\",""), :id => "#{object_name}_#{method}", :class => "open-window-grid")
|
313
|
-
|
314
|
-
# We need to refactor some values
|
315
|
-
show = "data['#{controller}.#{options[:show]}']" if options[:show].is_a?(Symbol)
|
316
|
-
get = options[:get].is_a?(Symbol) && options[:get] != :id ? "data['#{controller}.#{options[:get]}']" : options[:get]
|
317
|
-
|
318
|
-
# Updater handler
|
319
|
-
update_function = if options[:multiple]
|
320
|
-
(<<-JAVASCRIPT).gsub(/ {12}/, "")
|
321
|
-
var parent = win.parent.body.select("*[id=#{object_name}_#{method}]").first();
|
322
|
-
Ext.each(selections, function(selection){
|
323
|
-
var template = String.format('#{template.gsub(/\n/,"")}', selection.#{show}, selection.#{get});
|
324
|
-
parent.insertHtml('afterBegin', template);
|
325
|
-
});
|
326
|
-
JAVASCRIPT
|
327
|
-
else
|
328
|
-
(<<-JAVASCRIPT).gsub(/ {12}/, "")
|
329
|
-
var selection = selections.first();
|
330
|
-
var template = String.format('#{template.gsub(/\n/,"")}', selection.#{show}, selection.#{get}) + '#{li_link}';
|
331
|
-
win.parent.body.select("*[id=#{object_name}_#{method}]").first().update(template);
|
332
|
-
JAVASCRIPT
|
333
|
-
end
|
334
|
-
|
335
|
-
# Now we build the update function (if not present)
|
336
|
-
javascript = (<<-JAVASCRIPT).gsub(/ {10}/, '')
|
337
|
-
function #{options[:function]}(){
|
338
|
-
var me = Ext.WindowMgr.getActive();
|
339
|
-
Ext.Ajax.request({
|
340
|
-
url: '#{options[:url]}',
|
341
|
-
scripts: false,
|
342
|
-
success: function(response){
|
343
|
-
try { eval(response.responseText) } catch(e) { Admin.app.error(e) };
|
344
|
-
var win = new Admin.window({ grid: #{options[:grid]}, item: #{options[:item]}, width: 800, height:600, modal: true, parent:me });
|
345
|
-
win.on('selected', function(win, selections){
|
346
|
-
#{update_function}
|
347
|
-
});
|
348
|
-
win.show();
|
349
|
-
}
|
350
|
-
});
|
351
|
-
}
|
352
|
-
JAVASCRIPT
|
353
|
-
|
354
|
-
# Now we return our html code
|
355
|
-
[content_tag(:script, javascript, :type => 'text/javascript'), container, tag(:div, :class => :clear)].join("\n")
|
356
|
-
end
|
357
|
-
|
358
|
-
module AbstractFormBuilder #:nodoc:
|
359
|
-
# f.open_window_grid :upload_ids, :brand_ids, :with => :brands, :get => :id, :show => :name
|
360
|
-
def open_window_grid(field, options={})
|
361
|
-
@template.open_window_grid object_name, field, options
|
362
|
-
end
|
42
|
+
def model_translate(model)
|
43
|
+
t("models.#{model}.name", :default => model.to_s.humanize)
|
363
44
|
end
|
45
|
+
alias :mt :model_translate
|
364
46
|
end # ViewHelpers
|
365
47
|
end # Helpers
|
366
48
|
end # Admin
|