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.
Files changed (353) hide show
  1. data/README.rdoc +40 -84
  2. data/VERSION +1 -1
  3. data/lib/padrino-admin.rb +3 -20
  4. data/lib/padrino-admin/access_control.rb +78 -326
  5. data/lib/padrino-admin/generators/actions.rb +6 -26
  6. data/lib/padrino-admin/generators/admin_app.rb +40 -11
  7. data/lib/padrino-admin/generators/admin_page.rb +11 -17
  8. data/lib/padrino-admin/generators/orm.rb +85 -0
  9. data/lib/padrino-admin/generators/templates/account/activerecord.rb.tt +43 -0
  10. data/lib/padrino-admin/generators/templates/account/datamapper.rb.tt +54 -0
  11. data/lib/padrino-admin/generators/templates/{page/db → account}/seeds.rb.tt +5 -6
  12. data/lib/padrino-admin/generators/{app/app.rb.tt → templates/app/app.rb} +2 -10
  13. data/lib/padrino-admin/generators/templates/app/controllers/base.rb +7 -0
  14. data/lib/padrino-admin/generators/{app → templates/app}/controllers/sessions.rb +6 -6
  15. data/lib/padrino-admin/generators/templates/assets/stylesheets/base.css +370 -0
  16. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/amro/style.css +364 -0
  17. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/bec-green/style.css +290 -0
  18. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/bec/style.css +301 -0
  19. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/blue/style.css +287 -0
  20. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/default/style.css +373 -0
  21. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/djime-cerulean/style.css +305 -0
  22. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/kathleene/style.css +279 -0
  23. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/olive/style.css +345 -0
  24. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/orange/style.css +269 -0
  25. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/reidb-greenish/style.css +302 -0
  26. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/ruby/style.css +281 -0
  27. data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/warehouse/style.css +391 -0
  28. data/lib/padrino-admin/generators/templates/erb/app/base/_sidebar.erb.tt +13 -0
  29. data/lib/padrino-admin/generators/templates/erb/app/base/index.erb.tt +17 -0
  30. data/lib/padrino-admin/generators/templates/erb/app/layouts/application.erb.tt +44 -0
  31. data/lib/padrino-admin/generators/templates/erb/app/sessions/new.erb.tt +46 -0
  32. data/lib/padrino-admin/generators/templates/erb/page/_form.erb.tt +11 -0
  33. data/lib/padrino-admin/generators/templates/erb/page/edit.erb.tt +18 -0
  34. data/lib/padrino-admin/generators/templates/erb/page/index.erb.tt +36 -0
  35. data/lib/padrino-admin/generators/templates/erb/page/new.erb.tt +17 -0
  36. data/lib/padrino-admin/generators/templates/page/controller.rb.tt +32 -22
  37. data/lib/padrino-admin/helpers/authentication_helpers.rb +8 -9
  38. data/lib/padrino-admin/helpers/view_helpers.rb +20 -338
  39. data/lib/padrino-admin/locale/admin/de.yml +15 -49
  40. data/lib/padrino-admin/locale/admin/en.yml +12 -50
  41. data/lib/padrino-admin/locale/admin/it.yml +15 -50
  42. data/padrino-admin.gemspec +40 -321
  43. data/test/fixtures/data_mapper.rb +56 -7
  44. data/test/generators/test_admin_app_generator.rb +17 -16
  45. data/test/generators/test_admin_page_generator.rb +12 -16
  46. data/test/test_admin_application.rb +193 -12
  47. metadata +33 -314
  48. data/lib/padrino-admin/column_store.rb +0 -156
  49. data/lib/padrino-admin/config.rb +0 -36
  50. data/lib/padrino-admin/generators/admin_uploader.rb +0 -88
  51. data/lib/padrino-admin/generators/app/controllers/accounts.rb +0 -37
  52. data/lib/padrino-admin/generators/app/controllers/base.rb +0 -11
  53. data/lib/padrino-admin/generators/app/controllers/javascripts.rb +0 -10
  54. data/lib/padrino-admin/generators/app/views/accounts/_form.haml +0 -24
  55. data/lib/padrino-admin/generators/app/views/accounts/edit.haml +0 -3
  56. data/lib/padrino-admin/generators/app/views/accounts/grid.js.erb +0 -9
  57. data/lib/padrino-admin/generators/app/views/accounts/new.haml +0 -3
  58. data/lib/padrino-admin/generators/app/views/accounts/store.jml +0 -7
  59. data/lib/padrino-admin/generators/app/views/base/dashboard.haml +0 -3
  60. data/lib/padrino-admin/generators/app/views/base/index.haml +0 -19
  61. data/lib/padrino-admin/generators/app/views/javascripts/admin.js.erb +0 -490
  62. data/lib/padrino-admin/generators/app/views/javascripts/locale.js.erb +0 -135
  63. data/lib/padrino-admin/generators/app/views/sessions/new.haml +0 -26
  64. data/lib/padrino-admin/generators/assets/flash/charts.swf +0 -0
  65. data/lib/padrino-admin/generators/assets/flash/clippy.swf +0 -0
  66. data/lib/padrino-admin/generators/assets/flash/expressinstall.swf +0 -0
  67. data/lib/padrino-admin/generators/assets/flash/swfupload.swf +0 -0
  68. data/lib/padrino-admin/generators/assets/images/admin/back.gif +0 -0
  69. data/lib/padrino-admin/generators/assets/images/admin/background.png +0 -0
  70. data/lib/padrino-admin/generators/assets/images/admin/bg-content.png +0 -0
  71. data/lib/padrino-admin/generators/assets/images/admin/bg-hd-slate.png +0 -0
  72. data/lib/padrino-admin/generators/assets/images/admin/bg-hd.png +0 -0
  73. data/lib/padrino-admin/generators/assets/images/admin/bg-intro.png +0 -0
  74. data/lib/padrino-admin/generators/assets/images/admin/bg-login.png +0 -0
  75. data/lib/padrino-admin/generators/assets/images/admin/bg-menu-slate.png +0 -0
  76. data/lib/padrino-admin/generators/assets/images/admin/bg-menu.png +0 -0
  77. data/lib/padrino-admin/generators/assets/images/admin/bg.png +0 -0
  78. data/lib/padrino-admin/generators/assets/images/admin/btn-login.png +0 -0
  79. data/lib/padrino-admin/generators/assets/images/admin/cancel.gif +0 -0
  80. data/lib/padrino-admin/generators/assets/images/admin/categories.gif +0 -0
  81. data/lib/padrino-admin/generators/assets/images/admin/close.gif +0 -0
  82. data/lib/padrino-admin/generators/assets/images/admin/close.png +0 -0
  83. data/lib/padrino-admin/generators/assets/images/admin/delete.gif +0 -0
  84. data/lib/padrino-admin/generators/assets/images/admin/download.gif +0 -0
  85. data/lib/padrino-admin/generators/assets/images/admin/duplicate.gif +0 -0
  86. data/lib/padrino-admin/generators/assets/images/admin/edit.gif +0 -0
  87. data/lib/padrino-admin/generators/assets/images/admin/export.gif +0 -0
  88. data/lib/padrino-admin/generators/assets/images/admin/hd-bg.gif +0 -0
  89. data/lib/padrino-admin/generators/assets/images/admin/image.gif +0 -0
  90. data/lib/padrino-admin/generators/assets/images/admin/loader.gif +0 -0
  91. data/lib/padrino-admin/generators/assets/images/admin/logo-loader.png +0 -0
  92. data/lib/padrino-admin/generators/assets/images/admin/logo-small.png +0 -0
  93. data/lib/padrino-admin/generators/assets/images/admin/new.gif +0 -0
  94. data/lib/padrino-admin/generators/assets/images/admin/no-image.png +0 -0
  95. data/lib/padrino-admin/generators/assets/images/admin/preview.gif +0 -0
  96. data/lib/padrino-admin/generators/assets/images/admin/print.gif +0 -0
  97. data/lib/padrino-admin/generators/assets/images/admin/save.gif +0 -0
  98. data/lib/padrino-admin/generators/assets/images/admin/support.gif +0 -0
  99. data/lib/padrino-admin/generators/assets/images/admin/up.gif +0 -0
  100. data/lib/padrino-admin/generators/assets/images/ext/default/box/corners-blue.gif +0 -0
  101. data/lib/padrino-admin/generators/assets/images/ext/default/box/corners.gif +0 -0
  102. data/lib/padrino-admin/generators/assets/images/ext/default/box/l-blue.gif +0 -0
  103. data/lib/padrino-admin/generators/assets/images/ext/default/box/l.gif +0 -0
  104. data/lib/padrino-admin/generators/assets/images/ext/default/box/r-blue.gif +0 -0
  105. data/lib/padrino-admin/generators/assets/images/ext/default/box/r.gif +0 -0
  106. data/lib/padrino-admin/generators/assets/images/ext/default/box/tb-blue.gif +0 -0
  107. data/lib/padrino-admin/generators/assets/images/ext/default/box/tb.gif +0 -0
  108. data/lib/padrino-admin/generators/assets/images/ext/default/button/arrow.gif +0 -0
  109. data/lib/padrino-admin/generators/assets/images/ext/default/button/btn.gif +0 -0
  110. data/lib/padrino-admin/generators/assets/images/ext/default/button/group-cs.gif +0 -0
  111. data/lib/padrino-admin/generators/assets/images/ext/default/button/group-lr.gif +0 -0
  112. data/lib/padrino-admin/generators/assets/images/ext/default/button/group-tb.gif +0 -0
  113. data/lib/padrino-admin/generators/assets/images/ext/default/button/s-arrow-b-noline.gif +0 -0
  114. data/lib/padrino-admin/generators/assets/images/ext/default/button/s-arrow-b.gif +0 -0
  115. data/lib/padrino-admin/generators/assets/images/ext/default/button/s-arrow-bo.gif +0 -0
  116. data/lib/padrino-admin/generators/assets/images/ext/default/button/s-arrow-noline.gif +0 -0
  117. data/lib/padrino-admin/generators/assets/images/ext/default/button/s-arrow-o.gif +0 -0
  118. data/lib/padrino-admin/generators/assets/images/ext/default/button/s-arrow.gif +0 -0
  119. data/lib/padrino-admin/generators/assets/images/ext/default/dd/drop-add.gif +0 -0
  120. data/lib/padrino-admin/generators/assets/images/ext/default/dd/drop-no.gif +0 -0
  121. data/lib/padrino-admin/generators/assets/images/ext/default/dd/drop-yes.gif +0 -0
  122. data/lib/padrino-admin/generators/assets/images/ext/default/editor/tb-sprite.gif +0 -0
  123. data/lib/padrino-admin/generators/assets/images/ext/default/form/checkbox.gif +0 -0
  124. data/lib/padrino-admin/generators/assets/images/ext/default/form/clear-trigger.gif +0 -0
  125. data/lib/padrino-admin/generators/assets/images/ext/default/form/clear-trigger.psd +0 -0
  126. data/lib/padrino-admin/generators/assets/images/ext/default/form/date-trigger.gif +0 -0
  127. data/lib/padrino-admin/generators/assets/images/ext/default/form/date-trigger.psd +0 -0
  128. data/lib/padrino-admin/generators/assets/images/ext/default/form/error-tip-corners.gif +0 -0
  129. data/lib/padrino-admin/generators/assets/images/ext/default/form/exclamation.gif +0 -0
  130. data/lib/padrino-admin/generators/assets/images/ext/default/form/radio.gif +0 -0
  131. data/lib/padrino-admin/generators/assets/images/ext/default/form/search-trigger.gif +0 -0
  132. data/lib/padrino-admin/generators/assets/images/ext/default/form/search-trigger.psd +0 -0
  133. data/lib/padrino-admin/generators/assets/images/ext/default/form/text-bg.gif +0 -0
  134. data/lib/padrino-admin/generators/assets/images/ext/default/form/trigger-tpl.gif +0 -0
  135. data/lib/padrino-admin/generators/assets/images/ext/default/form/trigger.gif +0 -0
  136. data/lib/padrino-admin/generators/assets/images/ext/default/form/trigger.psd +0 -0
  137. data/lib/padrino-admin/generators/assets/images/ext/default/gradient-bg.gif +0 -0
  138. data/lib/padrino-admin/generators/assets/images/ext/default/grid/Thumbs.db +0 -0
  139. data/lib/padrino-admin/generators/assets/images/ext/default/grid/arrow-left-white.gif +0 -0
  140. data/lib/padrino-admin/generators/assets/images/ext/default/grid/arrow-right-white.gif +0 -0
  141. data/lib/padrino-admin/generators/assets/images/ext/default/grid/col-move-bottom.gif +0 -0
  142. data/lib/padrino-admin/generators/assets/images/ext/default/grid/col-move-top.gif +0 -0
  143. data/lib/padrino-admin/generators/assets/images/ext/default/grid/columns.gif +0 -0
  144. data/lib/padrino-admin/generators/assets/images/ext/default/grid/dirty.gif +0 -0
  145. data/lib/padrino-admin/generators/assets/images/ext/default/grid/done.gif +0 -0
  146. data/lib/padrino-admin/generators/assets/images/ext/default/grid/drop-no.gif +0 -0
  147. data/lib/padrino-admin/generators/assets/images/ext/default/grid/drop-yes.gif +0 -0
  148. data/lib/padrino-admin/generators/assets/images/ext/default/grid/footer-bg.gif +0 -0
  149. data/lib/padrino-admin/generators/assets/images/ext/default/grid/grid-blue-hd.gif +0 -0
  150. data/lib/padrino-admin/generators/assets/images/ext/default/grid/grid-blue-split.gif +0 -0
  151. data/lib/padrino-admin/generators/assets/images/ext/default/grid/grid-hrow.gif +0 -0
  152. data/lib/padrino-admin/generators/assets/images/ext/default/grid/grid-loading.gif +0 -0
  153. data/lib/padrino-admin/generators/assets/images/ext/default/grid/grid-split.gif +0 -0
  154. data/lib/padrino-admin/generators/assets/images/ext/default/grid/grid-vista-hd.gif +0 -0
  155. data/lib/padrino-admin/generators/assets/images/ext/default/grid/grid3-hd-btn.gif +0 -0
  156. data/lib/padrino-admin/generators/assets/images/ext/default/grid/grid3-hrow-over.gif +0 -0
  157. data/lib/padrino-admin/generators/assets/images/ext/default/grid/grid3-hrow.gif +0 -0
  158. data/lib/padrino-admin/generators/assets/images/ext/default/grid/grid3-special-col-bg.gif +0 -0
  159. data/lib/padrino-admin/generators/assets/images/ext/default/grid/grid3-special-col-sel-bg.gif +0 -0
  160. data/lib/padrino-admin/generators/assets/images/ext/default/grid/group-by.gif +0 -0
  161. data/lib/padrino-admin/generators/assets/images/ext/default/grid/group-expand-sprite.gif +0 -0
  162. data/lib/padrino-admin/generators/assets/images/ext/default/grid/hd-pop.gif +0 -0
  163. data/lib/padrino-admin/generators/assets/images/ext/default/grid/hmenu-asc.gif +0 -0
  164. data/lib/padrino-admin/generators/assets/images/ext/default/grid/hmenu-desc.gif +0 -0
  165. data/lib/padrino-admin/generators/assets/images/ext/default/grid/hmenu-lock.gif +0 -0
  166. data/lib/padrino-admin/generators/assets/images/ext/default/grid/hmenu-lock.png +0 -0
  167. data/lib/padrino-admin/generators/assets/images/ext/default/grid/hmenu-unlock.gif +0 -0
  168. data/lib/padrino-admin/generators/assets/images/ext/default/grid/hmenu-unlock.png +0 -0
  169. data/lib/padrino-admin/generators/assets/images/ext/default/grid/invalid_line.gif +0 -0
  170. data/lib/padrino-admin/generators/assets/images/ext/default/grid/loading.gif +0 -0
  171. data/lib/padrino-admin/generators/assets/images/ext/default/grid/mso-hd.gif +0 -0
  172. data/lib/padrino-admin/generators/assets/images/ext/default/grid/nowait.gif +0 -0
  173. data/lib/padrino-admin/generators/assets/images/ext/default/grid/page-first-disabled.gif +0 -0
  174. data/lib/padrino-admin/generators/assets/images/ext/default/grid/page-first.gif +0 -0
  175. data/lib/padrino-admin/generators/assets/images/ext/default/grid/page-last-disabled.gif +0 -0
  176. data/lib/padrino-admin/generators/assets/images/ext/default/grid/page-last.gif +0 -0
  177. data/lib/padrino-admin/generators/assets/images/ext/default/grid/page-next-disabled.gif +0 -0
  178. data/lib/padrino-admin/generators/assets/images/ext/default/grid/page-next.gif +0 -0
  179. data/lib/padrino-admin/generators/assets/images/ext/default/grid/page-prev-disabled.gif +0 -0
  180. data/lib/padrino-admin/generators/assets/images/ext/default/grid/page-prev.gif +0 -0
  181. data/lib/padrino-admin/generators/assets/images/ext/default/grid/pick-button.gif +0 -0
  182. data/lib/padrino-admin/generators/assets/images/ext/default/grid/refresh.gif +0 -0
  183. data/lib/padrino-admin/generators/assets/images/ext/default/grid/row-check-sprite.gif +0 -0
  184. data/lib/padrino-admin/generators/assets/images/ext/default/grid/row-expand-sprite.gif +0 -0
  185. data/lib/padrino-admin/generators/assets/images/ext/default/grid/row-over.gif +0 -0
  186. data/lib/padrino-admin/generators/assets/images/ext/default/grid/row-sel.gif +0 -0
  187. data/lib/padrino-admin/generators/assets/images/ext/default/grid/sort-hd.gif +0 -0
  188. data/lib/padrino-admin/generators/assets/images/ext/default/grid/sort_asc.gif +0 -0
  189. data/lib/padrino-admin/generators/assets/images/ext/default/grid/sort_desc.gif +0 -0
  190. data/lib/padrino-admin/generators/assets/images/ext/default/grid/wait.gif +0 -0
  191. data/lib/padrino-admin/generators/assets/images/ext/default/layout/collapse.gif +0 -0
  192. data/lib/padrino-admin/generators/assets/images/ext/default/layout/expand.gif +0 -0
  193. data/lib/padrino-admin/generators/assets/images/ext/default/layout/gradient-bg.gif +0 -0
  194. data/lib/padrino-admin/generators/assets/images/ext/default/layout/mini-bottom.gif +0 -0
  195. data/lib/padrino-admin/generators/assets/images/ext/default/layout/mini-left.gif +0 -0
  196. data/lib/padrino-admin/generators/assets/images/ext/default/layout/mini-right.gif +0 -0
  197. data/lib/padrino-admin/generators/assets/images/ext/default/layout/mini-top.gif +0 -0
  198. data/lib/padrino-admin/generators/assets/images/ext/default/layout/ns-collapse.gif +0 -0
  199. data/lib/padrino-admin/generators/assets/images/ext/default/layout/ns-expand.gif +0 -0
  200. data/lib/padrino-admin/generators/assets/images/ext/default/layout/panel-close.gif +0 -0
  201. data/lib/padrino-admin/generators/assets/images/ext/default/layout/panel-title-bg.gif +0 -0
  202. data/lib/padrino-admin/generators/assets/images/ext/default/layout/panel-title-light-bg.gif +0 -0
  203. data/lib/padrino-admin/generators/assets/images/ext/default/layout/stick.gif +0 -0
  204. data/lib/padrino-admin/generators/assets/images/ext/default/layout/stuck.gif +0 -0
  205. data/lib/padrino-admin/generators/assets/images/ext/default/layout/tab-close-on.gif +0 -0
  206. data/lib/padrino-admin/generators/assets/images/ext/default/layout/tab-close.gif +0 -0
  207. data/lib/padrino-admin/generators/assets/images/ext/default/menu/checked.gif +0 -0
  208. data/lib/padrino-admin/generators/assets/images/ext/default/menu/group-checked.gif +0 -0
  209. data/lib/padrino-admin/generators/assets/images/ext/default/menu/item-over.gif +0 -0
  210. data/lib/padrino-admin/generators/assets/images/ext/default/menu/menu-parent.gif +0 -0
  211. data/lib/padrino-admin/generators/assets/images/ext/default/menu/menu.gif +0 -0
  212. data/lib/padrino-admin/generators/assets/images/ext/default/menu/unchecked.gif +0 -0
  213. data/lib/padrino-admin/generators/assets/images/ext/default/panel/corners-sprite.gif +0 -0
  214. data/lib/padrino-admin/generators/assets/images/ext/default/panel/left-right.gif +0 -0
  215. data/lib/padrino-admin/generators/assets/images/ext/default/panel/light-hd.gif +0 -0
  216. data/lib/padrino-admin/generators/assets/images/ext/default/panel/tool-sprite-tpl.gif +0 -0
  217. data/lib/padrino-admin/generators/assets/images/ext/default/panel/tool-sprites.gif +0 -0
  218. data/lib/padrino-admin/generators/assets/images/ext/default/panel/tools-sprites-trans.gif +0 -0
  219. data/lib/padrino-admin/generators/assets/images/ext/default/panel/top-bottom.gif +0 -0
  220. data/lib/padrino-admin/generators/assets/images/ext/default/panel/top-bottom.png +0 -0
  221. data/lib/padrino-admin/generators/assets/images/ext/default/panel/white-corners-sprite.gif +0 -0
  222. data/lib/padrino-admin/generators/assets/images/ext/default/panel/white-left-right.gif +0 -0
  223. data/lib/padrino-admin/generators/assets/images/ext/default/panel/white-top-bottom.gif +0 -0
  224. data/lib/padrino-admin/generators/assets/images/ext/default/progress/progress-bg.gif +0 -0
  225. data/lib/padrino-admin/generators/assets/images/ext/default/qtip/bg.gif +0 -0
  226. data/lib/padrino-admin/generators/assets/images/ext/default/qtip/close.gif +0 -0
  227. data/lib/padrino-admin/generators/assets/images/ext/default/qtip/tip-anchor-sprite.gif +0 -0
  228. data/lib/padrino-admin/generators/assets/images/ext/default/qtip/tip-sprite.gif +0 -0
  229. data/lib/padrino-admin/generators/assets/images/ext/default/s.gif +0 -0
  230. data/lib/padrino-admin/generators/assets/images/ext/default/shadow-c.png +0 -0
  231. data/lib/padrino-admin/generators/assets/images/ext/default/shadow-lr.png +0 -0
  232. data/lib/padrino-admin/generators/assets/images/ext/default/shadow.png +0 -0
  233. data/lib/padrino-admin/generators/assets/images/ext/default/shared/blue-loading.gif +0 -0
  234. data/lib/padrino-admin/generators/assets/images/ext/default/shared/calendar.gif +0 -0
  235. data/lib/padrino-admin/generators/assets/images/ext/default/shared/glass-bg.gif +0 -0
  236. data/lib/padrino-admin/generators/assets/images/ext/default/shared/hd-sprite.gif +0 -0
  237. data/lib/padrino-admin/generators/assets/images/ext/default/shared/large-loading.gif +0 -0
  238. data/lib/padrino-admin/generators/assets/images/ext/default/shared/left-btn.gif +0 -0
  239. data/lib/padrino-admin/generators/assets/images/ext/default/shared/loading-balls.gif +0 -0
  240. data/lib/padrino-admin/generators/assets/images/ext/default/shared/right-btn.gif +0 -0
  241. data/lib/padrino-admin/generators/assets/images/ext/default/shared/warning.gif +0 -0
  242. data/lib/padrino-admin/generators/assets/images/ext/default/sizer/e-handle-dark.gif +0 -0
  243. data/lib/padrino-admin/generators/assets/images/ext/default/sizer/e-handle.gif +0 -0
  244. data/lib/padrino-admin/generators/assets/images/ext/default/sizer/ne-handle-dark.gif +0 -0
  245. data/lib/padrino-admin/generators/assets/images/ext/default/sizer/ne-handle.gif +0 -0
  246. data/lib/padrino-admin/generators/assets/images/ext/default/sizer/nw-handle-dark.gif +0 -0
  247. data/lib/padrino-admin/generators/assets/images/ext/default/sizer/nw-handle.gif +0 -0
  248. data/lib/padrino-admin/generators/assets/images/ext/default/sizer/s-handle-dark.gif +0 -0
  249. data/lib/padrino-admin/generators/assets/images/ext/default/sizer/s-handle.gif +0 -0
  250. data/lib/padrino-admin/generators/assets/images/ext/default/sizer/se-handle-dark.gif +0 -0
  251. data/lib/padrino-admin/generators/assets/images/ext/default/sizer/se-handle.gif +0 -0
  252. data/lib/padrino-admin/generators/assets/images/ext/default/sizer/square.gif +0 -0
  253. data/lib/padrino-admin/generators/assets/images/ext/default/sizer/sw-handle-dark.gif +0 -0
  254. data/lib/padrino-admin/generators/assets/images/ext/default/sizer/sw-handle.gif +0 -0
  255. data/lib/padrino-admin/generators/assets/images/ext/default/slider/slider-bg.png +0 -0
  256. data/lib/padrino-admin/generators/assets/images/ext/default/slider/slider-thumb.png +0 -0
  257. data/lib/padrino-admin/generators/assets/images/ext/default/slider/slider-v-bg.png +0 -0
  258. data/lib/padrino-admin/generators/assets/images/ext/default/slider/slider-v-thumb.png +0 -0
  259. data/lib/padrino-admin/generators/assets/images/ext/default/tabs/scroll-left.gif +0 -0
  260. data/lib/padrino-admin/generators/assets/images/ext/default/tabs/scroll-right.gif +0 -0
  261. data/lib/padrino-admin/generators/assets/images/ext/default/tabs/scroller-bg.gif +0 -0
  262. data/lib/padrino-admin/generators/assets/images/ext/default/tabs/tab-btm-inactive-left-bg.gif +0 -0
  263. data/lib/padrino-admin/generators/assets/images/ext/default/tabs/tab-btm-inactive-right-bg.gif +0 -0
  264. data/lib/padrino-admin/generators/assets/images/ext/default/tabs/tab-btm-left-bg.gif +0 -0
  265. data/lib/padrino-admin/generators/assets/images/ext/default/tabs/tab-btm-right-bg.gif +0 -0
  266. data/lib/padrino-admin/generators/assets/images/ext/default/tabs/tab-close.gif +0 -0
  267. data/lib/padrino-admin/generators/assets/images/ext/default/tabs/tab-strip-bg.gif +0 -0
  268. data/lib/padrino-admin/generators/assets/images/ext/default/tabs/tab-strip-bg.png +0 -0
  269. data/lib/padrino-admin/generators/assets/images/ext/default/tabs/tab-strip-btm-bg.gif +0 -0
  270. data/lib/padrino-admin/generators/assets/images/ext/default/tabs/tabs-sprite.gif +0 -0
  271. data/lib/padrino-admin/generators/assets/images/ext/default/toolbar/bg.gif +0 -0
  272. data/lib/padrino-admin/generators/assets/images/ext/default/toolbar/btn-arrow-light.gif +0 -0
  273. data/lib/padrino-admin/generators/assets/images/ext/default/toolbar/btn-arrow.gif +0 -0
  274. data/lib/padrino-admin/generators/assets/images/ext/default/toolbar/btn-over-bg.gif +0 -0
  275. data/lib/padrino-admin/generators/assets/images/ext/default/toolbar/gray-bg.gif +0 -0
  276. data/lib/padrino-admin/generators/assets/images/ext/default/toolbar/more.gif +0 -0
  277. data/lib/padrino-admin/generators/assets/images/ext/default/toolbar/tb-bg.gif +0 -0
  278. data/lib/padrino-admin/generators/assets/images/ext/default/toolbar/tb-btn-sprite.gif +0 -0
  279. data/lib/padrino-admin/generators/assets/images/ext/default/toolbar/tb-xl-btn-sprite.gif +0 -0
  280. data/lib/padrino-admin/generators/assets/images/ext/default/toolbar/tb-xl-sep.gif +0 -0
  281. data/lib/padrino-admin/generators/assets/images/ext/default/tree/arrows.gif +0 -0
  282. data/lib/padrino-admin/generators/assets/images/ext/default/tree/drop-add.gif +0 -0
  283. data/lib/padrino-admin/generators/assets/images/ext/default/tree/drop-between.gif +0 -0
  284. data/lib/padrino-admin/generators/assets/images/ext/default/tree/drop-no.gif +0 -0
  285. data/lib/padrino-admin/generators/assets/images/ext/default/tree/drop-over.gif +0 -0
  286. data/lib/padrino-admin/generators/assets/images/ext/default/tree/drop-under.gif +0 -0
  287. data/lib/padrino-admin/generators/assets/images/ext/default/tree/drop-yes.gif +0 -0
  288. data/lib/padrino-admin/generators/assets/images/ext/default/tree/elbow-end-minus-nl.gif +0 -0
  289. data/lib/padrino-admin/generators/assets/images/ext/default/tree/elbow-end-minus.gif +0 -0
  290. data/lib/padrino-admin/generators/assets/images/ext/default/tree/elbow-end-plus-nl.gif +0 -0
  291. data/lib/padrino-admin/generators/assets/images/ext/default/tree/elbow-end-plus.gif +0 -0
  292. data/lib/padrino-admin/generators/assets/images/ext/default/tree/elbow-end.gif +0 -0
  293. data/lib/padrino-admin/generators/assets/images/ext/default/tree/elbow-line.gif +0 -0
  294. data/lib/padrino-admin/generators/assets/images/ext/default/tree/elbow-minus-nl.gif +0 -0
  295. data/lib/padrino-admin/generators/assets/images/ext/default/tree/elbow-minus.gif +0 -0
  296. data/lib/padrino-admin/generators/assets/images/ext/default/tree/elbow-plus-nl.gif +0 -0
  297. data/lib/padrino-admin/generators/assets/images/ext/default/tree/elbow-plus.gif +0 -0
  298. data/lib/padrino-admin/generators/assets/images/ext/default/tree/elbow.gif +0 -0
  299. data/lib/padrino-admin/generators/assets/images/ext/default/tree/folder-open.gif +0 -0
  300. data/lib/padrino-admin/generators/assets/images/ext/default/tree/folder.gif +0 -0
  301. data/lib/padrino-admin/generators/assets/images/ext/default/tree/leaf.gif +0 -0
  302. data/lib/padrino-admin/generators/assets/images/ext/default/tree/loading.gif +0 -0
  303. data/lib/padrino-admin/generators/assets/images/ext/default/tree/s.gif +0 -0
  304. data/lib/padrino-admin/generators/assets/images/ext/default/window/icon-error.gif +0 -0
  305. data/lib/padrino-admin/generators/assets/images/ext/default/window/icon-info.gif +0 -0
  306. data/lib/padrino-admin/generators/assets/images/ext/default/window/icon-question.gif +0 -0
  307. data/lib/padrino-admin/generators/assets/images/ext/default/window/icon-warning.gif +0 -0
  308. data/lib/padrino-admin/generators/assets/images/ext/default/window/left-corners.png +0 -0
  309. data/lib/padrino-admin/generators/assets/images/ext/default/window/left-corners.psd +0 -0
  310. data/lib/padrino-admin/generators/assets/images/ext/default/window/left-right.png +0 -0
  311. data/lib/padrino-admin/generators/assets/images/ext/default/window/left-right.psd +0 -0
  312. data/lib/padrino-admin/generators/assets/images/ext/default/window/right-corners.png +0 -0
  313. data/lib/padrino-admin/generators/assets/images/ext/default/window/right-corners.psd +0 -0
  314. data/lib/padrino-admin/generators/assets/images/ext/default/window/top-bottom.png +0 -0
  315. data/lib/padrino-admin/generators/assets/images/ext/default/window/top-bottom.psd +0 -0
  316. data/lib/padrino-admin/generators/assets/javascripts/controls.js +0 -3
  317. data/lib/padrino-admin/generators/assets/javascripts/dragdrop.js +0 -3
  318. data/lib/padrino-admin/generators/assets/javascripts/effects.js +0 -4
  319. data/lib/padrino-admin/generators/assets/javascripts/ext.js +0 -29
  320. data/lib/padrino-admin/generators/assets/javascripts/prototype.js +0 -14
  321. data/lib/padrino-admin/generators/assets/javascripts/swfupload.js +0 -4
  322. data/lib/padrino-admin/generators/assets/stylesheets/admin.css +0 -60
  323. data/lib/padrino-admin/generators/assets/stylesheets/ext.css +0 -1543
  324. data/lib/padrino-admin/generators/assets/stylesheets/login.css +0 -17
  325. data/lib/padrino-admin/generators/assets/stylesheets/standard.css +0 -62
  326. data/lib/padrino-admin/generators/templates/page/views/_form.haml.tt +0 -9
  327. data/lib/padrino-admin/generators/templates/page/views/edit.haml.tt +0 -3
  328. data/lib/padrino-admin/generators/templates/page/views/grid.js.erb.tt +0 -9
  329. data/lib/padrino-admin/generators/templates/page/views/new.haml.tt +0 -3
  330. data/lib/padrino-admin/generators/templates/page/views/store.jml.tt +0 -6
  331. data/lib/padrino-admin/generators/templates/uploader/controller.rb +0 -24
  332. data/lib/padrino-admin/generators/templates/uploader/lib/uploader.rb +0 -66
  333. data/lib/padrino-admin/generators/templates/uploader/views/grid.js.erb +0 -57
  334. data/lib/padrino-admin/generators/templates/uploader/views/store.jml +0 -10
  335. data/lib/padrino-admin/locale/extjs/de.yml +0 -147
  336. data/lib/padrino-admin/locale/extjs/en.yml +0 -147
  337. data/lib/padrino-admin/locale/extjs/it.yml +0 -147
  338. data/lib/padrino-admin/orm.rb +0 -48
  339. data/lib/padrino-admin/orm/abstract.rb +0 -95
  340. data/lib/padrino-admin/orm/activerecord.rb +0 -144
  341. data/lib/padrino-admin/orm/datamapper.rb +0 -229
  342. data/lib/padrino-admin/orm/mongomapper.rb +0 -65
  343. data/lib/padrino-admin/utils/literal.rb +0 -13
  344. data/test/fixtures/active_record.rb +0 -29
  345. data/test/fixtures/mongo_mapper.rb +0 -12
  346. data/test/fixtures/test_column_store.jml +0 -11
  347. data/test/generators/test_admin_uploader_generator.rb +0 -56
  348. data/test/test_access_control.rb +0 -99
  349. data/test/test_active_record.rb +0 -96
  350. data/test/test_column_store.rb +0 -87
  351. data/test/test_config.rb +0 -13
  352. data/test/test_data_mapper.rb +0 -114
  353. 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">&nbsp;</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 :<%= @model_plural %> do
1
+ Admin.controllers :<%= @orm.name_plural %> do
2
2
 
3
- get :index, :respond_to => [:js, :json] do
4
- @store = <%= @model_name %>.column_store(options.views, "<%= @model_plural %>/store")
5
- case content_type
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
- @<%= @model_singular %> = <%= @model_name %>.new
13
- render '<%= @model_plural %>/new'
9
+ @<%= @orm.name_singular %> = <%= @orm.build %>
10
+ render '<%= @orm.name_plural %>/new'
14
11
  end
15
12
 
16
- post :create, :respond_to => :js do
17
- @<%= @model_singular %> = <%= @model_name %>.create(params[:<%= @model_singular %>])
18
- show_messages_for(@<%= @model_singular %>)
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
- @<%= @model_singular %> = <%= @model_name %>.first(:conditions => { :id => params[:id] })
23
- render '<%= @model_plural %>/edit'
24
+ @<%= @orm.name_singular %> = <%= @orm.find("params[:id]") %>
25
+ render '<%= @orm.name_plural %>/edit'
24
26
  end
25
27
 
26
- put :update, :with => :id, :respond_to => :js do
27
- @<%= @model_singular %> = <%= @model_name %>.first(:conditions => { :id => params[:id] })
28
- @<%= @model_singular %>.update_attributes(params[:<%= @model_singular %>])
29
- show_messages_for(@<%= @model_singular %>)
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, :respond_to => :json do
33
- <%= @model_plural %> = <%= @model_name %>.all(:conditions => { :id => params[:ids].split(",") })
34
- errors = <%= @model_plural %>.map { |<%= @model_singular %>| I18n.t("admin.general.cantDelete", :record => <%= @model_singular %>.id) unless <%= @model_singular %>.destroy }.compact
35
- render :success => errors.empty?, :msg => errors.join("<br />")
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.auths(current_account).can?(request.path_info)
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
- # Set the title of the page.
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
- # # Show an window with errors or "congratulations" and point form.action to:
50
- # # <form action="/admin/accounts/update/123.js" method="put">
51
- # show_messages_for :account
10
+ # # => t("padrino.admin.profile", :default => "Profile")
11
+ # pat(:profile)
52
12
  #
53
- # # Show an window with errors or "congratulations" and point form.action to:
54
- # # <form action="/admin/accounts/create.js" method="create">
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 show_messages_for(object, options={})
58
- object = object.is_a?(Symbol) ? instance_variable_get("@#{object}") : object
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
- # This method add tab for in your view.
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
- # # Create an expanded box that is not collapsible.
159
- # -box "My Box 1", "My Subtitle" do
160
- # my content
26
+ # # => t("models.account.email", :default => "Email")
27
+ # mat(:account, :email)
161
28
  #
162
- # # Create an expanded box that is collapsible.
163
- # -box "My Box 2", "My Subtitle", :collapsible => true do
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">&nbsp;</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\">&nbsp;</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\">&nbsp;</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">&nbsp;</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
- # Open a Standard window that can contain a grid. Works like a select_tag.
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
- # # Generate:
239
- # # <script type="text/javascript">
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 open_window_grid(object_name, method, options={})
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">&nbsp;</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