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
@@ -1,156 +0,0 @@
1
- module Padrino
2
- module Admin
3
- ##
4
- # Return column config, and store config/data for ExtJS ColumnModel and Store
5
- #
6
- class ColumnStore
7
- attr_reader :data
8
-
9
- def initialize(klass_model, config) #:nodoc
10
- @model = klass_model
11
- table_name = @model.table_name || @model.class.to_s.downcase.pluralize
12
- @data = config["columns"].map do |column|
13
-
14
- # Reformat our config
15
- column["header"] ||= column["method"].to_s
16
- column["dataIndex"] ||= column["method"]
17
- column["sortable"] ||= column["sortable"].nil? ? true : column["sortable"]
18
- column["header"] = @model.human_local_attribute_name(column["header"]) # try to translate with I18n the column name
19
-
20
- # Try to reformat the dataIndex
21
- data_indexes = Array(column["dataIndex"]).collect do |data_index|
22
- if data_index =~ /\./ # if we have some like categories.names we use this
23
- cols = data_index.split(".").collect(&:singularize)
24
- column["name"] ||= cols[0] + "[" + cols[1..-1].join("][") + "]" # accounts.name will be => accounts[name]
25
- else
26
- column["name"] ||= "#{table_name.singularize}[#{data_index}]"
27
- data_index = "#{table_name}.#{data_index}"
28
- end
29
- data_index
30
- end
31
-
32
- # Now we join our data indexes
33
- column["dataIndex"] = data_indexes.compact.uniq.join(",")
34
-
35
- # Reformat mapping like a div id
36
- column["mapping"] ||= column["name"].sub(/\[/,"_").sub(/\]$/, "").sub(/\]\[/,"_")
37
-
38
- # Now is necessary for our columns an ID
39
- #
40
- # TODO: check duplicates here
41
- column["id"] = column["mapping"]
42
-
43
- # Finally we can return our column
44
- column
45
- end
46
- end
47
-
48
- ##
49
- # Return an array config for build an Ext.grid.ColumnModel() config
50
- #
51
- # If +json+ false we return the Hash object, else a JSON pretty printed string
52
- #
53
- def column_fields(json=true)
54
- data = @data.map do |data|
55
- data = data.dup
56
- editor = parse_column_editor(data.delete("editor"))
57
- renderer = parse_column_renderer(data.delete("renderer"))
58
- data.merge!(editor) if editor
59
- data.merge!(renderer) if renderer
60
- data.delete("method")
61
- data.delete("mapping")
62
- data
63
- end
64
- json ? JSON.pretty_generate(data) : data
65
- end
66
-
67
- ##
68
- # Return an array config for build an Ext.data.GroupingStore()
69
- #
70
- # If +json+ false we return the Hash object, else a JSON pretty printed string
71
- #
72
- def store_fields(json=true)
73
- data = @data.map do |data|
74
- type = parse_store_renderer(data["renderer"])
75
- hash = { :name => data["dataIndex"] , :mapping => data["mapping"] }
76
- hash.merge!(type) if type
77
- hash
78
- end
79
- json ? JSON.pretty_generate(data) : data
80
- end
81
-
82
- ##
83
- # Return data for a custom collection for the ExtJS Ext.data.GroupingStore() json
84
- #
85
- def store_data_from(collection)
86
- collection.map do |c|
87
- @data.dup.inject({ "id" => c.id }) do |options, data|
88
- options[data["mapping"]] = (c.instance_eval(data["method"]) rescue I18n.t("admin.labels.not_found"))
89
- options
90
- end
91
- end
92
- end
93
-
94
- ##
95
- # Return a searched and paginated data collection for the ExtJS Ext.data.GroupingStore() json
96
- # You can pass options like:
97
- #
98
- # If options has key +json+ false we return the Hash object, else a JSON string
99
- #
100
- # Examples:
101
- #
102
- # store_data(params, :include => :posts)
103
- #
104
- def store_data(params={}, options={})
105
- # Some can tell me that this method made two identical queries one for count one for paginate.
106
- # We don't use the select count because in some circumstances require much time than select *.
107
- params[:limit] ||= 50
108
- json = params.has_key?(:json) ? params.delete(:json) : true
109
- collection = @model.ext_search(params, options)
110
- result = { :results => store_data_from(collection.records), :count => collection.count }
111
- json ? result.to_json : result
112
- end
113
-
114
- private
115
- def parse_store_renderer(renderer)
116
- case renderer
117
- when "date" then { :type => "date", :dateFormat => "Y-m-d" }
118
- when "datetime" then { :type => "date", :dateFormat => "c" }
119
- when "time_to_date" then { :type => "date", :dateFormat => "c" }
120
- end
121
- end
122
-
123
- def parse_column_editor(editor)
124
- case editor
125
- when "checkbox" then { :checkbox => true }
126
- when "combo" then { :editor => "new Ext.form.ComboBox()".to_l }
127
- when "datefield" then { :editor => "new Ext.form.DateField()".to_l }
128
- when "numberfield" then { :editor => "new Ext.form.NumberField()".to_l }
129
- when "radio" then { :editor => "new Ext.form.Radio()".to_l }
130
- when "textarea" then { :editor => "new Ext.form.TextArea()".to_l }
131
- when "textfield" then { :editor => "new Ext.form.TextField()".to_l }
132
- when "timefield" then { :editor => "new Ext.form.TimeField()".to_l }
133
- when "datetimefield" then { :editor => "new Ext.form.DateTimeField()".to_l }
134
- end
135
- end
136
-
137
- def parse_column_renderer(renderer)
138
- case renderer
139
- when "time_to_date" then { :renderer => "Ext.util.Format.dateRenderer()".to_l }
140
- when "date" then { :renderer => "Ext.util.Format.dateRenderer()".to_l }
141
- when "datetime" then { :renderer => "Ext.util.Format.dateTimeRenderer()".to_l }
142
- when "percentage" then { :renderer => "Ext.util.Format.percentage".to_l }
143
- when "eur_money" then { :renderer => "Ext.util.Format.eurMoney".to_l }
144
- when "us_money" then { :renderer => "Ext.util.Format.usMoney".to_l }
145
- when "boolean" then { :renderer => "Ext.util.Format.boolRenderer".to_l }
146
- when "capitalize" then { :renderer => "Ext.util.Format.capitalize".to_l }
147
- when "file_size" then { :renderer => "Ext.util.Format.fileSize".to_l }
148
- when "downcase" then { :renderer => "Ext.util.Format.lowercase".to_l }
149
- when "trim" then { :renderer => "Ext.util.Format.trim".to_l }
150
- when "undef" then { :renderer => "Ext.util.Format.undef".to_l }
151
- when "upcase" then { :renderer => "Ext.util.Format.uppercase".to_l }
152
- end
153
- end
154
- end # ColumnStore
155
- end # Admin
156
- end # Padrino
@@ -1,36 +0,0 @@
1
- require 'rubygems'
2
- require 'yaml'
3
- require 'erb'
4
- require 'json/pure' unless defined?(JSON) || defined?(JSON::Pure)
5
-
6
- module Padrino
7
- module Admin
8
- module Config
9
-
10
- ##
11
- # This class it's used for JSON variables.
12
- # Normally if we convert this { :function => "alert('Test')" } will be:
13
- #
14
- # { "function": "alert('Test')" }
15
- #
16
- # But if in our javascript we need to "eval" this function is not possible because
17
- # it's a string.
18
- #
19
- # Using Padrino::Config::Variable the result will be:
20
- #
21
- # { "function" : alert('Test') }
22
- #
23
- # Normally an ExtJs Variable can be handled with ExtJs Config like:
24
- #
25
- # function: !js alert('Test')
26
- #
27
- class Variable < String
28
- yaml_as "tag:yaml.org,2002:js"
29
-
30
- def to_json(*a) #:nodoc:
31
- self
32
- end
33
- end # Variable
34
- end # Config
35
- end # Admin
36
- end # Padrino
@@ -1,88 +0,0 @@
1
- module Padrino
2
- module Generators
3
-
4
- class AdminUploader < Thor::Group
5
-
6
- # Add this generator to our padrino-gen
7
- Padrino::Generators.add_generator(:admin_uploader, self)
8
-
9
- # Define the source template root
10
- def self.source_root; File.expand_path(File.dirname(__FILE__)); end
11
- def self.banner; "padrino-gen admin_uploader"; end
12
-
13
- # Include related modules
14
- include Thor::Actions
15
- include Padrino::Generators::Actions
16
- include Padrino::Generators::Admin::Actions
17
-
18
- desc "Description:\n\n\tpadrino-gen admin_uploader Name"
19
- class_option :root, :desc => "The root destination", :aliases => '-r', :type => :string, :default => "."
20
- class_option :destroy, :desc => "Destroy the uploader", :aliases => '-d', :default => false, :type => :boolean
21
-
22
- # Create controller for admin
23
- def create_controller
24
- self.destination_root = options[:root]
25
- if in_app_root?
26
-
27
- unless File.exist?(destination_root("admin"))
28
- say "<= You need to create an admin application first!"
29
- raise SystemExit
30
- end
31
-
32
- self.behavior = :revoke if options[:destroy]
33
-
34
- copy_file "templates/uploader/controller.rb", destination_root("/admin/controllers/uploads.rb")
35
- copy_file "templates/uploader/views/grid.js.erb", destination_root("/admin/views/uploads/grid.js.erb")
36
- copy_file "templates/uploader/views/store.jml", destination_root("/admin/views/uploads/store.jml")
37
- copy_file "templates/uploader/lib/uploader.rb", destination_root("lib", "uploader.rb")
38
-
39
- Padrino::Generators::Model.dup.start([
40
- "upload", "file:string", "created_at:datetime",
41
- "-r=#{options[:root]}", "-s=#{options[:skip_migration]}", "-d=#{options[:destroy]}"
42
- ])
43
-
44
- inject_into_file destination_root("app", "models", "upload.rb"), :before => "end" do
45
- (<<-RUBY).gsub(/ {14}/, ' ')
46
- mount_uploader :file, Uploader
47
-
48
- def size
49
- file.size if file
50
- end
51
-
52
- def content_type
53
- file.content_type if file
54
- end
55
- RUBY
56
- end
57
-
58
- # Add a carrierwave dependency
59
- inject_into_file("Gemfile", "\n# Uploader requirements\n# gem 'mini_magick'\ngem 'carrierwave'\n", :before => "\n# Padrino")
60
-
61
- # Only for datamapper
62
- if orm == :datamapper
63
- inject_into_file destination_root("app", "models", "upload.rb"), :after => "property :file, String" do
64
- ", :auto_validation => false"
65
- end
66
- end
67
-
68
- add_permission("/admin", "role.project_module :uploads, \"/admin/uploads.js\"")
69
-
70
- return if self.behavior == :revoke
71
- say (<<-TEXT).gsub(/ {10}/,'')
72
-
73
- =================================================================
74
- Uploader has been successfully installed, now follow this steps:
75
- =================================================================
76
- 1) Run migrations
77
- 2) That's all!!
78
- =================================================================
79
-
80
- TEXT
81
- else
82
- say "You are not at the root of a Padrino application! (config/boot.rb not found)" and return unless in_app_root?
83
- end
84
- end
85
- end
86
-
87
- end
88
- end
@@ -1,37 +0,0 @@
1
- Admin.controllers :accounts do
2
-
3
- get :index, :respond_to => [:js, :json] do
4
- @store = Account.column_store(options.views, "accounts/store")
5
- case content_type
6
- when :js then render 'accounts/grid.js'
7
- when :json then @store.store_data(params)
8
- end
9
- end
10
-
11
- get :new do
12
- @account = Account.new
13
- render 'accounts/new'
14
- end
15
-
16
- post :create, :respond_to => :js do
17
- @account = Account.create(params[:account])
18
- show_messages_for(@account)
19
- end
20
-
21
- get :edit, :with => :id do
22
- @account = Account.first(:conditions => { :id => params[:id] })
23
- render 'accounts/edit'
24
- end
25
-
26
- put :update, :with => :id, :respond_to => :js do
27
- @account = Account.first(:conditions => { :id => params[:id] })
28
- @account.update_attributes(params[:account])
29
- show_messages_for(@account)
30
- end
31
-
32
- delete :destroy, :respond_to => :json do
33
- accounts = Account.all(:conditions => { :id => params[:ids].split(",") })
34
- errors = accounts.map { |account| I18n.t("admin.general.cantDelete", :record => account.id) unless account.destroy }.compact
35
- render :success => errors.empty?, :msg => errors.join("<br />")
36
- end
37
- end
@@ -1,11 +0,0 @@
1
- Admin.controllers do
2
-
3
- get :index do
4
- render "base/index"
5
- end
6
-
7
- get :dashboard do
8
- render "base/dashboard"
9
- end
10
-
11
- end
@@ -1,10 +0,0 @@
1
- Admin.controllers :javascripts do
2
-
3
- get :admin, :respond_to => :js do
4
- render 'javascripts/admin.js'
5
- end
6
-
7
- get :locale, :respond_to => :js do
8
- render 'javascripts/locale.js'
9
- end
10
- end
@@ -1,24 +0,0 @@
1
- -tab :general do
2
- %table
3
- %tr
4
- %td=f.label :name
5
- %td=f.text_field :name
6
- %tr
7
- %td=f.label :surname
8
- %td=f.text_field :surname
9
- %tr
10
- %td=f.label :role
11
- %td=f.select :role, :options => access_control.roles
12
-
13
- -tab :login do
14
- %table
15
- %tr
16
- %td=f.label :email
17
- %td=f.text_field :email
18
- %tr
19
- %td=f.label :password
20
- %td=f.password_field :password
21
- %tr
22
- %td=f.label :password_confirmation
23
- %td=f.password_field :password_confirmation
24
-
@@ -1,3 +0,0 @@
1
- =title "Edit Account"
2
- -form_for @account, url(:accounts_update, :id => @account, :format => :js), :method => :put, :remote => true do |f|
3
- =partial 'accounts/form', :locals => { :f => f }
@@ -1,9 +0,0 @@
1
- var grid = new Admin.grid({
2
- id: 'grid-accounts',
3
- title: 'List Accounts',
4
- baseUrl: '/admin/accounts',
5
- column_fields: <%= @store.column_fields %>,
6
- store_fields: <%= @store.store_fields %>
7
- });
8
-
9
- Admin.app.addItem(grid);
@@ -1,3 +0,0 @@
1
- =title "New Account"
2
- -form_for @account, url(:accounts_create, :format => :js), :remote => true do |f|
3
- =partial 'accounts/form', :locals => { :f => f }
@@ -1,7 +0,0 @@
1
- columns:
2
- - method: name
3
- - method: surname
4
- - method: email
5
- header: E-mail
6
- sortable: false
7
- - method: role
@@ -1,3 +0,0 @@
1
- =title "Dashboard"
2
- .padding
3
- Welcome to your dashboard
@@ -1,19 +0,0 @@
1
- %html
2
- %head
3
- %title="Welcome to #{options.app_name.titleize}"
4
- =stylesheet_link_tag :ext, :standard, :admin
5
- %body
6
- #loading-mask
7
- #loading
8
- .loading-indicator
9
- =image_tag("admin/logo-loader.png") + "Loading..."
10
- / include everything after the loading indicator
11
- =javascript_include_tag :prototype, :effects, :dragdrop, :controls, :swfupload, :ext, :locale, :admin
12
- #header
13
- #logo=link_to options.app_name.titleize, url(:index)
14
- #logout=link_to "Logout #{current_account.email}", url(:sessions_destroy)
15
-
16
- %iframe{ :id => "ajax-iframe", :name => "ajax-iframe" }
17
- %form{ :id => "history-form", :class => "x-hidden" }
18
- =hidden_field_tag "x-history-field", :id => "x-history-field"
19
- %iframe{ :id => "x-history-frame" }
@@ -1,490 +0,0 @@
1
- Ext.BLANK_IMAGE_URL = '<%= image_path("ext/default/s.gif") %>';
2
- Ext.Updater.defaults.showLoadIndicator = false;
3
- Ext.namespace('Admin');
4
-
5
- // This is our event manager
6
- Admin.events = new Ext.util.Observable();
7
-
8
- // That is the main app
9
- Admin.app = function(){
10
- return {
11
- // Init our app
12
- init: function(){
13
- // Cookie provider
14
- Ext.state.Manager.setProvider(
15
- new Ext.state.CookieProvider({
16
- expires: new Date(new Date().getTime()+(1000*60*60*24*365))
17
- })
18
- );
19
-
20
- // We want save cookies only for grids
21
- Ext.override(Ext.Component, { stateful:false });
22
- // Ext.override(Ext.grid.GridPanel, { stateful:true });
23
- Ext.QuickTips.init();
24
-
25
- // Used for direclty load some specific page
26
- var loadUrl = undefined;
27
- if (window.location.search){
28
- loadUrl = Ext.urlDecode(window.location.search.substring(1)).load;
29
- } else if (window.location.href.split('#')[1]) {
30
- loadUrl = window.location.href.split('#')[1];
31
- }
32
-
33
- // Used for history the browsing
34
- Ext.History.init();
35
- Ext.History.on('change', function(token){ Admin.app.load(token) });
36
-
37
- // Build some events
38
- Admin.events.addEvents('itemAdded', 'contentLoaded');
39
-
40
- // Our header
41
- var header = new Ext.Panel({
42
- contentEl: 'header',
43
- region: 'north',
44
- border: false,
45
- bbar: <%= admin_menu %>
46
- });
47
-
48
- // Our main container
49
- this.contentDynamic = new Ext.Panel({
50
- id:'dynamic',
51
- region:'center',
52
- activeItem: 0,
53
- border:false,
54
- frame: true,
55
- bodyCssClass: 'dynamic',
56
- buttonAlign: 'left',
57
- buttons: [{
58
- id:'back',
59
- text: Admin.locale.buttons.back,
60
- cls: 'x-btn-text-icon back',
61
- handler: this.back
62
- },'->',{
63
- id:'save',
64
- text: Admin.locale.buttons.save,
65
- hidden: true,
66
- cls: 'x-btn-text-icon save'
67
- }],
68
- layout:'card'
69
- });
70
-
71
- // Our viewport
72
- this.viewport = new Ext.Viewport({
73
- layout:'border',
74
- items: [header, this.contentDynamic]
75
- });
76
-
77
- loadUrl ? this.load(loadUrl) : this.loadPage('<%= url(:dashboard) %>');
78
-
79
- setTimeout(function(){
80
- Ext.get('loading').remove();
81
- Ext.get('loading-mask').fadeOut({remove:true});
82
- }, 250);
83
- }, // init
84
-
85
- load: function(url){
86
- var ext = (/[.]/.exec(url)) ? /[^.]+$/.exec(url) : 'html';
87
-
88
- // Now give a reply based on request
89
- if (ext.length == 1 && ext[0].toLowerCase() == 'js') {
90
- // Clean the html and scripts
91
- this.cleanScripts();
92
- this.clean();
93
- Ext.History.add(url, true);
94
- // Enable this for debug errors:
95
- // // We append the js into the head so we can easy inspect errors
96
- // var hd = document.getElementsByTagName("head")[0];
97
- // var s = document.createElement("script");
98
- // s.src = url;
99
- // s.type = 'text/javascript';
100
- // // Now we can append the child.
101
- // hd.appendChild(s);
102
- Admin.app.mask();
103
- Ext.Ajax.request({ url: url, nocache:true, callback:this.unmask, scope:this });
104
- } else if (ext == 'html'){
105
- this.loadWidget(url);
106
- } else {
107
- Admin.showAlert(Admin.locale.messages.alert.message);
108
- }
109
- }, // load
110
-
111
- loadPage: function(url){
112
- // Clean the html and scripts
113
- this.cleanScripts();
114
- this.clean();
115
- this.contentDynamic.load({ url: url, scripts: true, callback:this.inspectContent, scope:this, nocache:true });
116
- }, // loadPage
117
-
118
- loadWidget: function(url, id){
119
- var win = undefined;
120
- if (id) { Ext.WindowMgr.each(function(w) { if (w.id == id) { win = w; return false } }, this) };
121
- if (win){
122
- win.toFront();
123
- } else {
124
- Admin.app.mask();
125
- var win = new Admin.window({ id: id });
126
- win.show(); win.hide();
127
- win.load({
128
- url: url,
129
- scripts: true,
130
- callback: Admin.app.inspectContent,
131
- scope: win,
132
- nocache: true
133
- });
134
- }
135
- },
136
-
137
- back: function(){
138
- Ext.History.back();
139
- }, // back
140
-
141
- update: function(html){
142
- this.cleanScripts();
143
- this.clean();
144
- var el = this.contentDynamic.body.update(html);
145
- this.inspectContent(el, html);
146
- }, // update
147
-
148
- cleanScripts: function(){
149
- Ext.select('head > script').each(function(el){ el.remove(); });
150
- }, // cleanScripts
151
-
152
- clean: function(){
153
- this.saveButtons(false);
154
- this.contentDynamic.items.each(function(item){ item.destroy });
155
- this.contentDynamic.removeAll(true);
156
- this.contentDynamic.body.update('');
157
- }, // clean
158
-
159
- saveButtons: function(show, id){
160
- var btns = this.contentDynamic.fbar.items.map;
161
- if (show){
162
- btns.save.show();
163
- btns.save.handler = function(){ Admin.app.submitForm(id) };
164
- } else {
165
- btns.save.hide();
166
- btns.save.handler = undefined;
167
- }
168
- }, // saveButtons
169
-
170
- addItem: function(item, small){
171
- // If we are loading a small item we don't need to add them to our container
172
- if (small && small!=''){
173
- Admin.events.fireEvent('customItemAdded', item);
174
- } else {
175
- this.contentDynamic.add(item);
176
- this.contentDynamic.layout.setActiveItem(0);
177
- this.contentDynamic.doLayout(true, true);
178
- }
179
- Admin.events.fireEvent('itemAdded', item)
180
- }, // addItem
181
-
182
- submitForm: function(id){
183
- var form = Ext.fly(id);
184
- form.mask(Admin.locale.messages.wait.message);
185
- Ext.Ajax.request({ form: form, callback: function(){ Ext.fly(id).unmask() }, method: form.dom.method });
186
- }, // submitForms
187
-
188
- setTitle: function(title){
189
- this.contentDynamic.setTitle(title);
190
- }, // setTitle
191
-
192
- inspectContent: function(el, success, response){
193
- // Go away if no success
194
- if (!success) return;
195
-
196
- // Reformat ajax forms
197
- el.select('form[data-remote=true]').each(function(form){
198
- var id = Ext.id(form, 'ajax-form-');
199
- form.dom.onsubmit = function(){ Admin.app.submitForm(id); return false };
200
- });
201
-
202
- // Search for tabs in the page
203
- var tabs = el.select('div[tabbed=true]');
204
-
205
- // We select the first form in the dom
206
- var form = el.select('form[data-remote=true]').first();
207
-
208
- // We need to parse our title
209
- var title = el.select('span[title]').first();
210
- if (title) this.setTitle(title.getAttribute("title"));
211
-
212
- // If we have a form we need some save buttons
213
- if (form) this.saveButtons(true, form.id);
214
-
215
- // Build our tab panel if we have a form and tabs
216
- if (tabs.elements.length > 0 && form){
217
- // Build Tabs
218
- var items = []
219
- Ext.each(tabs.elements, function(tab){
220
- tab.id = Ext.id('', tab.id +'-tab-');
221
- items.push({ id: tab.id + '-tab-id-', contentEl: tab.id, title: tab.title });
222
- });
223
-
224
- // We can build the tabPanel
225
- this.tabPanel = new Ext.TabPanel({
226
- applyTo: form,
227
- activeTab: 0,
228
- border:false,
229
- items: items,
230
- layoutOnTabChange: true,
231
- enableTabScroll: true,
232
- defaults: { autoScroll:true, layout:'fit' }
233
- });
234
-
235
- this.addItem(this.tabPanel);
236
- }
237
-
238
- Admin.app.unmask();
239
- this.fireEvent('contentLoaded');
240
- },//inspectContent
241
-
242
- fireEvent: function(event){
243
- Admin.events.fireEvent(event);
244
- }, // fireEvent
245
-
246
- error: function(e){
247
- (typeof console != 'undefined') ? console.error(e) : Admin.showAlert(e)
248
- }, // error
249
-
250
- doLayout: function(){
251
- this.contentDynamic.doLayout(true, true);
252
- }, //doLayout
253
-
254
- mask: function(text){
255
- if (text == null || text.length == 0) { text = Ext.LoadMask.prototype.msg; }
256
- this.contentDynamic.el.mask(text);
257
- }, // mask
258
-
259
- unmask: function(){
260
- this.contentDynamic.el.unmask();
261
- }, // unmask
262
-
263
- collapseBoxes: function(current){
264
- var el = current.up().down('div.x-box-collapsible');
265
- var currentEl = Ext.get(el);
266
- currentEl.isDisplayed() ? currentEl.slideOut('t', {duration:.2, useDisplay:true}) : currentEl.slideIn('t', {duration:.2, useDisplay:true});
267
- Ext.select('div.x-box-collapsible').each(function(el){
268
- if (el.isDisplayed() && el.dom.id!=currentEl.id){ el.slideOut('t', {duration:.2, useDisplay:true}); }
269
- });
270
- } //collapseBoxes
271
- } // return
272
- }();
273
-
274
- Admin.grid = Ext.extend(Ext.grid.GridPanel, {
275
- title: 'Grid',
276
- baseUrl: '',
277
- region: "center",
278
- border: false,
279
- buttons: ['add', 'edit', 'remove'],
280
- search: true,
281
- plugins: [],
282
- column_fields: [],
283
- store_fields: [],
284
- window: undefined,
285
-
286
- initComponent: function(){
287
- // Prepare our View/Cm/Sm
288
- this.view = new Ext.grid.GroupingView({ forceFit: true });
289
- this.selModel = new Ext.grid.CheckboxSelectionModel();
290
- this.column_fields.unshift(this.selModel);
291
- this.colModel = new Ext.grid.ColumnModel({ columns: this.column_fields });
292
- // Toolbar
293
- if (this.buttons.length > 0 || this.search){ this.tbar = new Ext.Toolbar() };
294
- // Add Buttons
295
- Ext.each(this.buttons, function(button){
296
- switch(button){
297
- case 'add':
298
- this.btnAdd = this.tbar.addButton({
299
- handler: this.addRecord,
300
- text: Admin.locale.buttons.add,
301
- disabled: false,
302
- scope: this,
303
- cls: "x-btn-text-icon add",
304
- name: "add"
305
- });
306
- break;
307
- case 'edit':
308
- this.btnEdit = this.tbar.addButton({
309
- handler: this.editRecord,
310
- text: Admin.locale.buttons.edit,
311
- disabled: true,
312
- scope: this,
313
- cls: "x-btn-text-icon edit",
314
- name: "edit"
315
- });
316
- break;
317
- case 'remove':
318
- this.btnRemove = this.tbar.addButton({
319
- handler: this.removeRecord,
320
- text: Admin.locale.buttons.remove,
321
- disabled: true,
322
- scope: this,
323
- cls: "x-btn-text-icon remove",
324
- name: "remove"
325
- });
326
- break;
327
- }
328
- }, this);
329
- this.buttons = undefined; // Remove all bbar buttons, we don't want them in the bottom of grid.
330
- // Add search functions
331
- if (this.search){ this.plugins = [new Ext.grid.Search()] };
332
- // Build our store
333
- this.store = new Ext.data.GroupingStore({
334
- remoteSort: true,
335
- proxy: new Ext.data.HttpProxy({ url: this.baseUrl +'.json' }),
336
- baseParams: {"_method":"GET"},
337
- reader: new Ext.data.JsonReader({
338
- fields: this.store_fields,
339
- root: "results",
340
- totalProperty: "count",
341
- id: "id"
342
- })
343
- });
344
- // Build bbar
345
- this.bbar = new Ext.PagingToolbar({
346
- pageSize: 50,
347
- displayInfo: true,
348
- store: this.store
349
- });
350
- // Call our superclass
351
- Admin.grid.superclass.initComponent.call(this);
352
- // Now we need to add some handlers for activate/deactivate buttons
353
- this.on('render', function(){ this.store.load() }, this);
354
- this.selModel.on('selectionchange', function(){
355
- var n = this.selModel.getSelected();
356
- if(!n){
357
- if (this.btnRemove){ this.btnRemove.disable() };
358
- if (this.btnEdit){ this.btnEdit.disable() };
359
- } else {
360
- if (this.btnRemove){ this.btnRemove.enable() };
361
- if (this.btnEdit){ this.btnEdit.enable() };
362
- }
363
- }, this);
364
- this.on("dblclick", function() {
365
- if (this.btnEdit){ this.editRecord() }
366
- }, this);
367
- this.store.on('beforeload', function(){ this.el.mask(); }, this);
368
- this.store.on('load', function(){ this.el.unmask(); }, this);
369
- }, // initComponent
370
-
371
- addRecord: function(){
372
- Admin.app.loadWidget(this.baseUrl + '/new');
373
- }, // addRecord
374
-
375
- editRecord: function(){
376
- var selections = this.selModel.getSelections();
377
- if (selections.length > 10) {
378
- Admin.showAlert(Admin.locale.messages.alert.tooMany);
379
- } else {
380
- Ext.each(selections, function(selection){
381
- var id = this.baseUrl + '-edit-' + selection.id;
382
- Admin.app.loadWidget(this.baseUrl + '/edit/' + selection.id);
383
- }, this);
384
- }
385
- }, // editRecord
386
-
387
- removeRecord: function(){
388
- Ext.Msg.confirm(Admin.locale.messages.confirm.title, String.format(Admin.locale.messages.confirm.message, this.getSelectionModel().getCount()), function(btn, text){
389
- if (btn == 'yes'){
390
- Admin.app.mask();
391
- var records = this.selModel.getSelections();
392
- var store = this.store;
393
- Ext.Ajax.request({
394
- url: this.baseUrl + '/destroy.json',
395
- params: { ids: records.map(function(r){ return r.id }).join(",") },
396
- method: 'DELETE',
397
- success: function(result, request){
398
- var resultValue = Ext.decode(result.responseText);
399
- Admin.app.unmask();
400
- store.reload();
401
- if (!resultValue.success){
402
- Ext.MessageBox.alert(Admin.locale.messages.alert.title, resultValue.msg);
403
- }
404
- },
405
- failure: function(result, request) {
406
- Admin.app.unmask();
407
- store.reload();
408
- Admin.showAlert(Admin.locale.messages.alert.message);
409
- }
410
- });
411
- }
412
- }, this);
413
- } // removeRecord
414
- }); // Admin.grid
415
-
416
- Admin.window = Ext.extend(Ext.Window, {
417
- width: 700,
418
- layout: 'fit',
419
- maximizable: true,
420
- bodyStyle: 'background-color:#FFF',
421
- grid: undefined,
422
- item: undefined,
423
-
424
- initComponent: function(){
425
- this.addEvents('contentLoaded');
426
- this.index = 0;
427
- Admin.window.superclass.initComponent.call(this);
428
- this.on('contentLoaded', this.center, this);
429
- this.on('contentLoaded', this.show, this);
430
- this.adminWindow = true;
431
- if (this.item || this.grid) this.add(this.item || this.grid);
432
- this.addButton({
433
- text: Admin.locale.buttons.close,
434
- handler: this[this.closeAction].createDelegate(this, [])
435
- });
436
- if (this.grid){
437
- this.addButton({
438
- text: Admin.locale.buttons.select,
439
- handler: this.closeWithSelections.createDelegate(this, [])}
440
- );
441
- }
442
- }, // initComponent
443
-
444
- addItem: function(item){ // this method is for a compatibility with Admin.app.addItem
445
- this.add(item);
446
- this.doLayout(true, true);
447
- },
448
-
449
- saveButtons: function(show, id){
450
- var btns = this.fbar.items.map;
451
- if (show){
452
- this.addButton({
453
- text: Admin.locale.buttons.save,
454
- handler: function(){ Admin.app.submitForm(id) }
455
- });
456
- }
457
- }, // saveButtons
458
-
459
- show: function(){
460
- Ext.WindowMgr.each(function(win) { if (win.adminWindow) this.index++ }, this);
461
- Admin.window.superclass.show.call(this);
462
- }, // show
463
-
464
- center: function(){
465
- var xy = this.el.getAlignToXY(this.container, 'c-c');
466
- this.setPagePosition(xy[0]+(this.index*10), xy[1]+(this.index*10));
467
- return this;
468
- }, // center
469
-
470
- unmask: Ext.emptyFn, // this method is for a compatibility with Admin.app.unmask
471
-
472
- getSelections: function(){
473
- return this.grid.getSelectionModel().getSelections();
474
- }, // getSelections
475
-
476
- closeWithSelections: function(){
477
- if (this.getSelections().length > 0){
478
- this.fireEvent('selected', this, this.getSelections());
479
- this[this.closeAction]();
480
- } else {
481
- Admin.showAlert(Admin.locale.messages.alert.notSelected);
482
- }
483
- } // closeWithSelections
484
- });
485
-
486
- Admin.showAlert = function(msg){
487
- Ext.Msg.alert(Admin.locale.messages.alert.title, msg || Admin.locale.messages.alert.message);
488
- }
489
-
490
- Ext.onReady(Admin.app.init, Admin.app, true);