releaf 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (201) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +15 -12
  3. data/Rakefile +8 -0
  4. data/app/assets/javascripts/releaf/controllers/base.js +0 -40
  5. data/app/assets/javascripts/releaf/include/field.type_date_or_datetime_or_time.js +43 -0
  6. data/app/assets/javascripts/releaf/include/nested_fields.js +58 -65
  7. data/app/assets/javascripts/releaf/include/sortable.js +19 -17
  8. data/app/assets/stylesheets/releaf/controllers/releaf/content.css.erb +6 -0
  9. data/app/assets/stylesheets/releaf/include/field.css.erb +37 -13
  10. data/app/controllers/releaf/admins_controller.rb +13 -6
  11. data/app/controllers/releaf/base_application_controller.rb +4 -1
  12. data/app/controllers/releaf/base_controller.rb +415 -154
  13. data/app/controllers/releaf/content_controller.rb +62 -45
  14. data/app/controllers/releaf/roles_controller.rb +11 -9
  15. data/app/controllers/releaf/sessions_controller.rb +23 -1
  16. data/app/controllers/releaf/translations_controller.rb +21 -25
  17. data/app/helpers/releaf/admin_helper.rb +0 -20
  18. data/app/models/releaf/admin.rb +9 -0
  19. data/app/models/releaf/blank_node_base.rb +29 -0
  20. data/app/models/releaf/node.rb +6 -5
  21. data/app/models/releaf/node_base.rb +9 -3
  22. data/app/models/releaf/role.rb +9 -2
  23. data/app/views/layouts/releaf/admin.html.haml +12 -6
  24. data/app/views/layouts/releaf/devise.html.haml +32 -0
  25. data/app/views/releaf/aliases/{_edit.body.haml → _edit.body.html.haml} +0 -0
  26. data/app/views/releaf/aliases/{_edit.header.haml → _edit.header.html.haml} +1 -1
  27. data/app/views/releaf/aliases/_index.row.html.haml +5 -0
  28. data/app/views/releaf/aliases/{_secondary_panel.haml → _secondary_panel.html.haml} +0 -0
  29. data/app/views/releaf/base/_edit.body.html.haml +11 -0
  30. data/app/views/releaf/base/_edit.field.html.haml +23 -0
  31. data/app/views/releaf/base/{_edit.field.type_autocomplete.haml → _edit.field_type_autocomplete.html.haml} +1 -1
  32. data/app/views/releaf/base/{_edit.field.type_checkbox.haml → _edit.field_type_boolean.html.haml} +1 -1
  33. data/app/views/releaf/base/{_edit.field.type_date.haml → _edit.field_type_date.html.haml} +0 -0
  34. data/app/views/releaf/base/{_edit.field.type_datetime.haml → _edit.field_type_datetime.html.haml} +0 -0
  35. data/app/views/releaf/base/{_edit.field.type_delete_nested.haml → _edit.field_type_delete_nested.html.haml} +0 -0
  36. data/app/views/releaf/base/{_edit.field.type_file.haml → _edit.field_type_file.html.haml} +0 -0
  37. data/app/views/releaf/base/_edit.field_type_image.html.haml +12 -0
  38. data/app/views/releaf/base/_edit.field_type_item.html.haml +31 -0
  39. data/app/views/releaf/base/{_edit.field.type_link.haml → _edit.field_type_link.html.haml} +0 -0
  40. data/app/views/releaf/base/_edit.field_type_link_i18n.html.haml +26 -0
  41. data/app/views/releaf/base/{_edit.field.type_password.haml → _edit.field_type_password.html.haml} +0 -0
  42. data/app/views/releaf/base/{_edit.field.type_richtext.haml → _edit.field_type_richtext.html.haml} +0 -0
  43. data/app/views/releaf/base/{_edit.field.type_richtext_i18n.haml → _edit.field_type_richtext_i18n.html.haml} +0 -0
  44. data/app/views/releaf/base/{_edit.field.type_text.haml → _edit.field_type_text.html.haml} +0 -0
  45. data/app/views/releaf/base/{_edit.field.type_text_i18n.haml → _edit.field_type_text_i18n.html.haml} +0 -0
  46. data/app/views/releaf/base/{_edit.field.type_textarea.haml → _edit.field_type_textarea.html.haml} +0 -0
  47. data/app/views/releaf/base/{_edit.field.type_textarea_i18n.haml → _edit.field_type_textarea_i18n.html.haml} +0 -0
  48. data/app/views/releaf/base/{_edit.field.type_time.haml → _edit.field_type_time.html.haml} +0 -0
  49. data/app/views/releaf/base/_edit.fields.association.html.haml +48 -0
  50. data/app/views/releaf/base/_edit.fields.has_many_template.html.haml +15 -0
  51. data/app/views/releaf/base/_edit.fields.html.haml +20 -0
  52. data/app/views/releaf/base/{_edit.footer.haml → _edit.footer.html.haml} +2 -2
  53. data/app/views/releaf/base/_edit.form.html.haml +4 -0
  54. data/app/views/releaf/base/_edit.header.html.haml +3 -0
  55. data/app/views/releaf/base/{_index.body.haml → _index.body.html.haml} +2 -2
  56. data/app/views/releaf/base/_index.cell.html.haml +20 -0
  57. data/app/views/releaf/base/_index.footer.html.haml +28 -0
  58. data/app/views/releaf/base/_index.header.html.haml +4 -0
  59. data/app/views/releaf/base/_index.row.html.haml +6 -0
  60. data/app/views/releaf/base/_index.search.html.haml +5 -0
  61. data/app/views/releaf/base/_index.table.html.haml +24 -0
  62. data/app/views/releaf/base/_secondary_panel.html.haml +10 -0
  63. data/app/views/releaf/base/_show.body.html.haml +3 -0
  64. data/app/views/releaf/base/_show.field.html.haml +20 -0
  65. data/app/views/releaf/base/_show.field_type_date.html.haml +9 -0
  66. data/app/views/releaf/base/_show.field_type_date_time.html.haml +9 -0
  67. data/app/views/releaf/base/_show.field_type_email.html.haml +6 -0
  68. data/app/views/releaf/base/_show.field_type_file.html.haml +7 -0
  69. data/app/views/releaf/base/_show.field_type_image.html.haml +10 -0
  70. data/app/views/releaf/base/_show.field_type_item.html.haml +11 -0
  71. data/app/views/releaf/base/_show.field_type_link.html.haml +14 -0
  72. data/app/views/releaf/base/_show.field_type_password.html.haml +6 -0
  73. data/app/views/releaf/base/_show.field_type_richtext.html.haml +6 -0
  74. data/app/views/releaf/base/_show.field_type_text.html.haml +6 -0
  75. data/app/views/releaf/base/_show.field_type_textarea.html.haml +6 -0
  76. data/app/views/releaf/base/_show.field_type_time.html.haml +9 -0
  77. data/app/views/releaf/base/_show.field_type_url.html.haml +7 -0
  78. data/app/views/releaf/base/_show.fields.association.html.haml +36 -0
  79. data/app/views/releaf/base/_show.fields.has_many_template.html.haml +12 -0
  80. data/app/views/releaf/base/_show.fields.html.haml +17 -0
  81. data/app/views/releaf/base/{_show.footer.haml → _show.footer.html.haml} +6 -4
  82. data/app/views/releaf/base/_show.header.html.haml +3 -0
  83. data/app/views/releaf/base/confirm_destroy.html.haml +17 -0
  84. data/app/views/releaf/base/edit.html.haml +1 -0
  85. data/app/views/releaf/base/index.html.haml +3 -0
  86. data/app/views/releaf/base/new.html.haml +1 -0
  87. data/app/views/releaf/base/show.html.haml +3 -0
  88. data/app/views/releaf/content/{_edit.body.haml → _edit.body.html.haml} +7 -6
  89. data/app/views/releaf/content/_edit.content_fields.html.haml +11 -0
  90. data/app/views/releaf/content/_edit.fields.html.haml +17 -0
  91. data/app/views/releaf/content/{_edit.slug.haml → _edit.slug.html.haml} +0 -0
  92. data/app/views/releaf/content/{_get_content_form.haml → _get_content_form.html.haml} +2 -2
  93. data/app/views/releaf/content/{_secondary_panel.haml → _secondary_panel.html.haml} +0 -0
  94. data/app/views/releaf/content/{_tree_level.haml → _tree_level.html.haml} +0 -0
  95. data/app/views/releaf/content/{ajax.new.haml → ajax.new.html.haml} +0 -0
  96. data/app/views/releaf/content/{index.haml → index.html.haml} +0 -0
  97. data/app/views/releaf/roles/_edit.field.permissions.html.haml +5 -0
  98. data/app/views/releaf/roles/{_show.field.default.haml → _show.field.default.html.haml} +1 -1
  99. data/app/views/releaf/roles/{_show.field.permissions.haml → _show.field.permissions.html.haml} +2 -2
  100. data/app/views/releaf/translations/{_edit.body.haml → _edit.body.html.haml} +0 -0
  101. data/app/views/releaf/translations/{_edit.header.haml → _edit.header.html.haml} +1 -1
  102. data/app/views/releaf/translations/_index.row.html.haml +5 -0
  103. data/app/views/releaf/translations/{_secondary_panel.haml → _secondary_panel.html.haml} +0 -0
  104. data/lib/generators/releaf/templates/initializers/releaf.rb +0 -39
  105. data/lib/generators/releaf/templates/initializers/releaf_i18n.rb +17 -0
  106. data/lib/generators/releaf/templates/javascripts/3rd_party/jquery.jcarousel.js +1058 -0
  107. data/lib/generators/releaf/templates/javascripts/lib/init_jcarousel.js +40 -0
  108. data/lib/generators/releaf/templates/migrations/create_releaf_roles.rb +1 -0
  109. data/lib/generators/releaf/templates/migrations/create_releaf_tinymce_assets.rb +1 -0
  110. data/lib/generators/releaf/templates/models/admin_ability.rb +1 -1
  111. data/lib/i18n/backend/releaf.rb +5 -4
  112. data/lib/i18n/backend/releaf/translation.rb +5 -0
  113. data/lib/i18n/backend/releaf/translation_data.rb +7 -0
  114. data/lib/i18n/backend/releaf/translation_group.rb +4 -0
  115. data/lib/releaf.rb +4 -0
  116. data/lib/releaf/boolean_at.rb +77 -0
  117. data/lib/releaf/globalize3/fallbacks.rb +19 -0
  118. data/lib/releaf/resources.rb +101 -0
  119. data/lib/releaf/slug.rb +99 -60
  120. data/lib/releaf/version.rb +1 -1
  121. data/spec/spec_helper.rb +6 -0
  122. data/templates/releaf/installer.rb +15 -4
  123. metadata +275 -329
  124. data/app/views/releaf/aliases/_index.row.haml +0 -5
  125. data/app/views/releaf/base/_edit.body.haml +0 -19
  126. data/app/views/releaf/base/_edit.field.haml +0 -96
  127. data/app/views/releaf/base/_edit.field.type_image.haml +0 -14
  128. data/app/views/releaf/base/_edit.field.type_select.haml +0 -11
  129. data/app/views/releaf/base/_edit.form.haml +0 -4
  130. data/app/views/releaf/base/_edit.has_many_associations.haml +0 -45
  131. data/app/views/releaf/base/_edit.header.haml +0 -3
  132. data/app/views/releaf/base/_index.cell.haml +0 -19
  133. data/app/views/releaf/base/_index.footer.haml +0 -22
  134. data/app/views/releaf/base/_index.header.haml +0 -4
  135. data/app/views/releaf/base/_index.row.haml +0 -6
  136. data/app/views/releaf/base/_index.search.haml +0 -5
  137. data/app/views/releaf/base/_index.table.haml +0 -8
  138. data/app/views/releaf/base/_secondary_panel.haml +0 -9
  139. data/app/views/releaf/base/_show.body.haml +0 -7
  140. data/app/views/releaf/base/_show.field.haml +0 -78
  141. data/app/views/releaf/base/_show.field.type_html.haml +0 -1
  142. data/app/views/releaf/base/_show.header.haml +0 -3
  143. data/app/views/releaf/base/confirm_destroy.haml +0 -10
  144. data/app/views/releaf/base/edit.haml +0 -1
  145. data/app/views/releaf/base/index.haml +0 -3
  146. data/app/views/releaf/base/new.haml +0 -1
  147. data/app/views/releaf/base/show.haml +0 -3
  148. data/app/views/releaf/content/_edit.content_fields.haml +0 -19
  149. data/app/views/releaf/content/_show.field.content.haml +0 -11
  150. data/app/views/releaf/roles/_edit.field.admins.haml +0 -0
  151. data/app/views/releaf/roles/_edit.field.permissions.haml +0 -5
  152. data/app/views/releaf/translations/_index.row.haml +0 -5
  153. data/spec/dummy/README.rdoc +0 -261
  154. data/spec/dummy/Rakefile +0 -7
  155. data/spec/dummy/app/assets/images/rails.png +0 -0
  156. data/spec/dummy/app/assets/javascripts/application.js +0 -15
  157. data/spec/dummy/app/assets/stylesheets/application.css +0 -13
  158. data/spec/dummy/app/controllers/application_controller.rb +0 -3
  159. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  160. data/spec/dummy/app/models/admin_ability.rb +0 -51
  161. data/spec/dummy/app/models/settings.rb +0 -2
  162. data/spec/dummy/app/views/layouts/application.html.haml +0 -10
  163. data/spec/dummy/config.ru +0 -4
  164. data/spec/dummy/config/application.rb +0 -68
  165. data/spec/dummy/config/boot.rb +0 -6
  166. data/spec/dummy/config/common_fields.yml.example +0 -17
  167. data/spec/dummy/config/database.yml +0 -42
  168. data/spec/dummy/config/environment.rb +0 -5
  169. data/spec/dummy/config/environments/development.rb +0 -37
  170. data/spec/dummy/config/environments/production.rb +0 -67
  171. data/spec/dummy/config/environments/test.rb +0 -37
  172. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  173. data/spec/dummy/config/initializers/devise.rb +0 -232
  174. data/spec/dummy/config/initializers/dragonfly.rb +0 -1
  175. data/spec/dummy/config/initializers/inflections.rb +0 -15
  176. data/spec/dummy/config/initializers/mime_types.rb +0 -5
  177. data/spec/dummy/config/initializers/releaf.rb +0 -59
  178. data/spec/dummy/config/initializers/releaf_i18n.rb +0 -8
  179. data/spec/dummy/config/initializers/releaf_store_current_template.rb +0 -25
  180. data/spec/dummy/config/initializers/secret_token.rb +0 -7
  181. data/spec/dummy/config/initializers/session_store.rb +0 -8
  182. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
  183. data/spec/dummy/config/locales/devise.en.yml +0 -58
  184. data/spec/dummy/config/locales/en.yml +0 -5
  185. data/spec/dummy/config/routes.rb +0 -11
  186. data/spec/dummy/db/migrate/20130204164516_create_settings.rb +0 -17
  187. data/spec/dummy/db/migrate/20130204164523_create_releaf_nodes.rb +0 -25
  188. data/spec/dummy/db/migrate/20130204164524_create_releaf_roles.rb +0 -11
  189. data/spec/dummy/db/migrate/20130204164525_create_releaf_translations.rb +0 -31
  190. data/spec/dummy/db/migrate/20130204164526_create_releaf_admins.rb +0 -53
  191. data/spec/dummy/db/schema.rb +0 -112
  192. data/spec/dummy/db/seeds.rb +0 -64
  193. data/spec/dummy/doc/README_FOR_APP +0 -2
  194. data/spec/dummy/log/development.log +0 -74
  195. data/spec/dummy/log/test.log +0 -129
  196. data/spec/dummy/public/404.html +0 -26
  197. data/spec/dummy/public/422.html +0 -26
  198. data/spec/dummy/public/500.html +0 -25
  199. data/spec/dummy/public/favicon.ico +0 -0
  200. data/spec/dummy/script/rails +0 -6
  201. data/spec/dummy/tmp/cache/9C5/660/settings%3Ai18n_updated_at +0 -1
@@ -0,0 +1,4 @@
1
+ = form_for resource, :as => :resource, :url => url_for( :action => resource.new_record? ? 'create' : 'update', :id => resource.id ), :validate => true, :class => "edit", :html => {:multipart => true} do |f|
2
+ = render "edit.header", :resource => resource
3
+ = render "edit.body", :f => f
4
+ = render "edit.footer", :resource => resource
@@ -0,0 +1,3 @@
1
+ .header
2
+ .padding
3
+ %h2= resource.new_record? ? t('create_new_resource') : resource_to_text(resource)
@@ -1,6 +1,6 @@
1
1
  .body.outset_box
2
- - if @list.empty?
2
+ - if resources.empty?
3
3
  .releaf_table.no_border
4
4
  .nothing_found= t("nothing_found")
5
5
  - else
6
- = render "index.table"
6
+ = render "index.table", :resources => resources
@@ -0,0 +1,20 @@
1
+ :ruby
2
+ text = resource.send(name)
3
+ if name =~ /_id$/
4
+ if resource.class.respond_to?(:reflect_on_association)
5
+ # FIXME what if association was set with :foreign_key option
6
+ rel_name = name.sub(/_id$/, '').to_sym
7
+ if resource.class.reflect_on_association(rel_name)
8
+ text = resource_to_text(resource.send(rel_name))
9
+ end
10
+ end
11
+ elsif name =~ /(thumbnail|image|photo|picture|avatar|logo|icon)_uid$/
12
+ unless resource.send(name).blank?
13
+ text = image_tag resource.send(name.sub(/_uid$/, '')).thumb('x16').url, :alt => ''
14
+ else
15
+ text = ""
16
+ end
17
+ end
18
+
19
+
20
+ %a.main{ :href => url_for( :action => list_action, :id => resource.id ) }= text
@@ -0,0 +1,28 @@
1
+ .footer.center
2
+ .padding
3
+ .stats
4
+ %span.total= resources.count \
5
+ = t("resourcesFound")
6
+
7
+ %span.actions
8
+ - if @features[:create]
9
+ %a.button.create_new_item{:href => url_for(:controller => controller.controller_name, :action => "new")}
10
+ = image_tag("releaf/icons/add.png", :alt => "add") \
11
+ %span= t('create_new_item')
12
+
13
+ %span.button_group.list_action_switch
14
+ - if @features[:show]
15
+ %button{:type => "button", :title => "switchToShow", "data-action" => "show", :class => list_action == "show" ? "active" : ""}>
16
+ = image_tag("releaf/icons/eye.png", :alt => "switchToShow")
17
+
18
+ - if @features[:edit]
19
+ %button{:type => "button", :title => "switchToEdit", "data-action" => "edit", :class => list_action == "edit" ? "active" : ""}>
20
+ = image_tag("releaf/icons/pencil.png", :alt => "switchToEdit")
21
+
22
+ - if @features[:destroy]
23
+ %button{:type => "button", :title => "switchToDelete", "data-action" => "confirm_destroy", :class => list_action == "confirm_destroy" ? "active" : ""}
24
+ = image_tag("releaf/icons/bin_empty.png", :alt => "switchToDelete")
25
+
26
+ - unless @continuous_scroll
27
+ - if resources.respond_to?(:page)
28
+ = will_paginate( resources, :class=> "button_group pagination", :link_separator => "", :renderer => "Releaf::PaginationRenderer::LinkRenderer", :previous_label => "<", :next_label => ">", :outer_window => 0, :inner_window => 2 )
@@ -0,0 +1,4 @@
1
+ .header
2
+ .padding
3
+ = render :partial => "index.search", :resources => resources
4
+ %h2= t("all_title")
@@ -0,0 +1,6 @@
1
+ .row{ 'data-id' => resource.id }
2
+ - fields_to_display.each do |name|
3
+ - if has_template? "_index.cell.#{name}"
4
+ = render "index.cell.#{name}", :resource => resource, :name => name
5
+ - else
6
+ = render 'index.cell', :resource => resource, :name => name
@@ -0,0 +1,5 @@
1
+ %form.search_form{:action => url_for( :controller => controller_name, :action => :index ), :title => "#{ resource_class.respond_to?( :filter ) ? '' : 'Add :filter scope to ' + resource_class.to_s + ' to enable searching' }"}
2
+ .special_field_wrap
3
+ %input.search{:name => "search", :type => "text", :value => params[:search], :autofocus => true, :disabled => !resource_class.respond_to?( :filter ) }
4
+ %button.no_styling{:type => "submit", :disabled => !resource_class.respond_to?( :filter )}>
5
+ = image_tag("releaf/icons/magnifier.png", :alt => "submit")
@@ -0,0 +1,24 @@
1
+ .releaf_table.no_border.selectable{"data-continuous" => @continuous_scroll ? "1" : "0", "data-items_per_page" => @resources_per_page, "data-loading" => t("loading"), "data-total" => resources.count}
2
+ .thead
3
+ %div
4
+ - valid_order_by_fields = resource_class.column_names
5
+
6
+ - fields_to_display.each do |name|
7
+ - label = name.sub(/_(id|uid|html)$/, '').to_s.humanize
8
+ %div
9
+ - if valid_order_by_fields.include? name
10
+
11
+ - if params[:order_by].blank? || params[:order_by].sub(/-reverse$/, '') != name
12
+ = link_to label, url_for(:order_by => name)
13
+
14
+ - else
15
+ - if params[:order_by] == name
16
+ = link_to label + ' ↑', url_for(:order_by => name + '-reverse')
17
+ - else
18
+ = link_to label + ' ↓', url_for(:order_by => name)
19
+
20
+ - else
21
+ = label
22
+ .tbody
23
+ - resources.each do |resource|
24
+ = render 'index.row', :resource => resource
@@ -0,0 +1,10 @@
1
+ .inner.standard_submenu
2
+ - if local_assigns.key?(:menu)
3
+ %ul.block
4
+ - menu.each_pair do |section_key, section|
5
+ %li
6
+ .section_title= t(section_key, :scope => "admin.base_menu")
7
+ %ul
8
+ - section.each do |resource|
9
+ %li{:class => ("active" if resource[:controller] == controller.class.name.underscore.sub(/_controller$/, '')) }
10
+ %a{:href => url_for(:controller => resource[:controller], :action => "index") }=t(resource[:controller], :scope => "admin.base_menu")
@@ -0,0 +1,3 @@
1
+ .body.outset_box
2
+ .section
3
+ = render 'show.fields', :resource => @resource, :view_prefix => 'show.field', :fields => fields_to_display
@@ -0,0 +1,20 @@
1
+ - name_without_id_or_type = name.sub(/_(id|type)$/, '')
2
+
3
+ - if resource.class.reflect_on_association(name_without_id_or_type).try(:options).try('[]', :polymorphic) == true
4
+ -# name =~ /_id$/ is required to prevent user template from being renedred 2x times:
5
+ -# first time for _id field, second time for _type field
6
+ - if name =~ /_id$/ && has_template?( "_#{view_prefix}.#{name_without_id_or_type}" )
7
+ = render "#{view_prefix}.#{name_without_id_or_type}", :resource => resource, :name => name, :view_prefix => view_prefix
8
+
9
+ - elsif has_template? "_#{view_prefix}.#{name}"
10
+ = render "#{view_prefix}.#{name}", :resource => resource, :name => name, :view_prefix => view_prefix
11
+ - elsif resource.send(name).blank? == false
12
+ - render_field_type, use_i18n = render_field_type(resource, name)
13
+ - if use_i18n and has_template?( "_show.field_type_#{render_field_type}_i18n" )
14
+ = render "show.field_type_#{render_field_type}_i18n", :resource => resource, :name => name
15
+
16
+ - elsif has_template?( "_show.field_type_#{render_field_type}" )
17
+ = render "show.field_type_#{render_field_type}", :resource => resource, :name => name
18
+
19
+ - else
20
+ = render "show.field_type_text", :resource => resource, :name => name
@@ -0,0 +1,9 @@
1
+ .field.no_label_wrap_padding.type_date{:'data-name' => name}
2
+ .label_wrap
3
+ .label= I18n.t(name.humanize, :scope => "models.#{resource.class.name.underscore}") + ':'
4
+ .value
5
+ - value = resource.send(name)
6
+ -# FIXME
7
+ = value
8
+ -# = I18n.l(value, :format => 'date_picker')
9
+ .clear
@@ -0,0 +1,9 @@
1
+ .field.no_label_wrap_padding.type_date_time{:'data-name' => name}
2
+ .label_wrap
3
+ .label= I18n.t(name.humanize, :scope => "models.#{resource.class.name.underscore}") + ':'
4
+ .value
5
+ - value = resource.send(name)
6
+ -# FIXME
7
+ = value
8
+ -# = I18n.l(value, :format => 'datetime_picker')
9
+ .clear
@@ -0,0 +1,6 @@
1
+ .field.no_label_wrap_padding.type_email{:'data-name' => name}
2
+ .label_wrap
3
+ .label= I18n.t(name.humanize, :scope => "models.#{resource.class.name.underscore}") + ':'
4
+ .value
5
+ = mail_to resource.send(name)
6
+ .clear
@@ -0,0 +1,7 @@
1
+ - m = name.sub(/_uid$/, '').to_s
2
+
3
+ .field.no_label_wrap_padding.type_file{:'data-name' => name}
4
+ .label_wrap
5
+ .label= I18n.t(m.humanize, :scope => "models.#{resource.class.name.underscore}") + ':'
6
+ .value= link_to I18n.t("common.Download"), resource.send(m).url
7
+ .clear
@@ -0,0 +1,10 @@
1
+ - m = name.sub(/_uid$/, '').to_s
2
+
3
+ .field.no_label_wrap_padding.type_image{:'data-name' => name}
4
+ .label_wrap
5
+ .label= I18n.t(m.humanize, :scope => "models.#{resource.class.name.underscore}") + ':'
6
+ .value
7
+ = link_to I18n.t("common.Download"), resource.send(m).url
8
+ .preview
9
+ = link_to image_tag(resource.send(m).thumb('x128').url, :alt => ''), resource.send(m).url, :target => :_blank, :data => { :lightbox => true }
10
+ .clear
@@ -0,0 +1,11 @@
1
+ - m = name.sub(/_id$/, '').to_s
2
+
3
+ .field.no_label_wrap_padding.type_item{:'data-name' => name}
4
+ .label_wrap
5
+ .label= I18n.t(m.humanize, :scope => "models.#{resource.class.name.underscore}") + ':'
6
+ .value
7
+ - if resource.class.reflect_on_association(m.to_sym)
8
+ = resource_to_text(resource.send(m))
9
+ - else
10
+ = resource.send(name)
11
+ .clear
@@ -0,0 +1,14 @@
1
+ .field.no_label_wrap_padding.type_link{:'data-name' => name}
2
+ .label_wrap
3
+ .label= I18n.t(name.humanize, :scope => "models.#{resource.class.name.underscore}") + ':'
4
+ .value
5
+ - value = resource.send(name)
6
+ - if value =~ /\A\d+\z/
7
+ - target = Releaf::Node.find_by_id(value)
8
+ - if target
9
+ = link_to resource_to_text(target), url_for(:action => :show, :id => value)
10
+ - else
11
+ = I18n.t("Link not found")
12
+ - else
13
+ = link_to value, value
14
+ .clear
@@ -0,0 +1,6 @@
1
+ .field.no_label_wrap_padding.type_password{:'data-name' => name}
2
+ .label_wrap
3
+ .label= I18n.t(name.humanize, :scope => "models.#{resource.class.name.underscore}") + ':'
4
+ .value
5
+ =I18n.t("Filtered")
6
+ .clear
@@ -0,0 +1,6 @@
1
+ .field.no_label_wrap_padding.type_richtext{:'data-name' => name}
2
+ .label_wrap
3
+ .label= I18n.t(name.humanize, :scope => "models.#{resource.class.name.underscore}") + ':'
4
+ .value
5
+ .raw_html= raw resource.send(name)
6
+ .clear
@@ -0,0 +1,6 @@
1
+ .field.no_label_wrap_padding.type_text{:'data-name' => name}
2
+ .label_wrap
3
+ .label= I18n.t(name.humanize, :scope => "models.#{resource.class.name.underscore}") + ':'
4
+ .value
5
+ = resource.send(name)
6
+ .clear
@@ -0,0 +1,6 @@
1
+ .field.no_label_wrap_padding.type_textarea{:'data-name' => name}
2
+ .label_wrap
3
+ .label= I18n.t(name.humanize, :scope => "models.#{resource.class.name.underscore}") + ':'
4
+ .value
5
+ = resource.send(name)
6
+ .clear
@@ -0,0 +1,9 @@
1
+ .field.no_label_wrap_padding.time_time{:'data-name' => name}
2
+ .label_wrap
3
+ .label= I18n.t(name.humanize, :scope => "models.#{resource.class.name.underscore}") + ':'
4
+ .value
5
+ - value = resource.send(name)
6
+ -# FIXME
7
+ = value
8
+ -# = I18n.l(value, :format => 'time_picker')
9
+ .clear
@@ -0,0 +1,7 @@
1
+ .field.no_label_wrap_padding.type_url{:'data-name' => name}
2
+ .label_wrap
3
+ .label= I18n.t(name.humanize, :scope => "models.#{resource.class.name.underscore}") + ':'
4
+ .value
5
+ - value = resource.send(name)
6
+ = link_to value, value
7
+ .clear
@@ -0,0 +1,36 @@
1
+ - if has_template? "_#{view_prefix}.#{field}"
2
+ = render "#{view_prefix}.#{field}", :resource => resource, :name => field
3
+
4
+ - else
5
+ - new_view_prefix = view_prefix + '.' + field
6
+
7
+
8
+ - case reflection.macro
9
+ - when :has_many
10
+ .nested_wrap{:'data-name' => field}
11
+ .nested_title= I18n.t(field)
12
+ .list
13
+ - resource.send(field).each do |subresource|
14
+ .resource
15
+ = render 'show.fields.has_many_template', :resource => subresource, :subfields => subfields, :view_prefix => new_view_prefix, :field => field
16
+
17
+ - when :belongs_to
18
+ .nested_wrap{:'data-name' => field}
19
+ .nested_title= I18n.t(field)
20
+ .item
21
+
22
+ - subitem = resource.send(field)
23
+
24
+ - if subfields.is_a? Array
25
+ - subfields.each do |subfield|
26
+ - if has_template? "_#{new_view_prefix}.#{subfield}"
27
+ = render "#{new_view_prefix}.#{subfield}", :resource => resource, :name => subfield
28
+ - else
29
+ = render 'show.fields', :resource => subresource, :fields => subfields, :view_prefix => new_view_prefix
30
+
31
+ - elsif subfields.is_a? String or subfields.is_a? Symbol
32
+ - if has_template? "_#{new_view_prefix}.#{field}"
33
+ = render "#{new_view_prefix}.#{field}", :resource => resource, :name => field
34
+ - else
35
+ = render 'show.field', :resource => subresource, :name => field, :view_prefix => new_view_prefix
36
+
@@ -0,0 +1,12 @@
1
+ - if subfields.is_a? Array
2
+ - subfields.each do |subfield|
3
+ - if has_template? "_#{view_prefix}.#{field}"
4
+ = render "#{view_prefix}.#{field}", :resource => resource, :name => field
5
+ - else
6
+ = render 'show.field', :resource => resource, :name => subfield, :view_prefix => view_prefix
7
+
8
+ - elsif subfields.is_a? String or subfields.is_a? Symbol
9
+ - if has_template? "_#{view_prefix}.#{field}"
10
+ = render "#{view_prefix}.#{field}", :resource => resource, :name => field
11
+ - else
12
+ = render 'show.field', :resource => resource, :name => field, :view_prefix => view_prefix
@@ -0,0 +1,17 @@
1
+ - fields.each do |field|
2
+ - if field.is_a?(String) or field.is_a?(Symbol)
3
+ - reflection = resource.class.reflections[field.to_sym]
4
+
5
+ - if (field.is_a?(String) or field.is_a?(Symbol)) && !reflection
6
+ - if has_template? "_#{view_prefix}.#{field}"
7
+ = render "#{view_prefix}.#{field}", :resource => resource, :name => field
8
+ - else
9
+ = render 'show.field', :resource => resource, :name => field, :view_prefix => view_prefix
10
+
11
+ - elsif field.is_a? Hash
12
+ - field.each_pair do |field, subfields|
13
+ - reflection = resource.class.reflections[field.to_sym]
14
+ = render 'show.fields.association', :resource => resource, :field => field, :subfields => subfields, :reflection => reflection, :view_prefix => view_prefix
15
+ - elsif reflection
16
+ - subfields = reflection.klass.column_names - %w[id created_at updated_at password password_confirmation encrypted_password position]
17
+ = render 'show.fields.association', :resource => resource, :field => field, :subfields => subfields, :reflection => reflection, :view_prefix => view_prefix
@@ -4,13 +4,15 @@
4
4
  %a.button{ :href => url_for( :action => 'index' ) }
5
5
  = image_tag 'releaf/icons/arrow_left.png', :alt => ''
6
6
  %span= t('back')
7
- -if @features[:edit]
7
+
8
+ - if @features[:edit]
8
9
  .block.center_block
9
- %a.button{ :href => url_for( :action => 'edit', :id => @item.id ) }
10
+ %a.button{ :href => url_for( :action => 'edit', :id => resource.id ) }
10
11
  = image_tag 'releaf/icons/page_white_edit.png', :alt => ''
11
12
  %span= t('edit')
12
- -if @features[:destroy]
13
+
14
+ - if @features[:destroy]
13
15
  .block.right_block
14
- %a.button{ :href => url_for( :action => 'confirm_destroy', :id => @item.id ) }
16
+ %a.button{ :href => url_for( :action => 'confirm_destroy', :id => resource.id ) }
15
17
  = image_tag('releaf/icons/bin_empty.png', :alt => '')
16
18
  %span= t('destroy')
@@ -0,0 +1,3 @@
1
+ .header
2
+ .padding
3
+ %h2= resource_to_text(resource)
@@ -0,0 +1,17 @@
1
+ .body.outset_box
2
+ .question= t('confirm_destroy')
3
+ .description= resource_to_text(@resource)
4
+ .buttons
5
+ = form_for @resource, :url => url_for( :action => 'destroy', :id => @resource.id ), :as => :resource, :method => :delete do |f|
6
+ %button{ :type => 'submit' }
7
+ = image_tag 'releaf/icons/bin_empty.png', :alt => ''
8
+ %span= t('yes')
9
+ - if @features[:show]
10
+ %a.button{ :href => url_for( :action => 'show', :id => @resource.id ) }
11
+ %span= t('no')
12
+ - elsif @features[:edit]
13
+ %a.button{ :href => url_for( :action => 'edit', :id => @resource.id ) }
14
+ %span= t('no')
15
+ - else
16
+ %a.button{ :href => url_for( :action => 'index' ) }
17
+ %span= t('no')
@@ -0,0 +1 @@
1
+ = render "edit.form", :resource => @resource
@@ -0,0 +1,3 @@
1
+ = render 'index.header', :resources => @resources
2
+ = render 'index.body', :resources => @resources
3
+ = render 'index.footer', :resources => @resources
@@ -0,0 +1 @@
1
+ = render "edit.form", :resource => @resource
@@ -0,0 +1,3 @@
1
+ = render 'show.header', :resource => @resource
2
+ = render 'show.body', :resource => @resource
3
+ = render 'show.footer', :resource => @resource
@@ -4,13 +4,15 @@
4
4
 
5
5
 
6
6
  .globalFieldContainer.collapsableSection.global_fields
7
- = render 'edit.field', :name => 'name', :f => f
7
+ = render 'edit.field', :name => 'name', :f => f, :view_prefix => 'edit.field'
8
8
 
9
9
  .field{ 'data-name' => 'template' }
10
10
  .label_wrap
11
11
  = f.label :content_type, 'Veids:', :title => f.object.content_type
12
12
  .value
13
- = f.select :content_type, options_for_select(@base_models.map { |m| m.name }, f.object.content_type || params[:content_type]), {:include_blank => f.object.new_record?}, {:title => @item.content_type, :disabled => f.object.new_record? == false }
13
+ %span= (f.object.content_type || params[:content_type])
14
+ - if f.object.new_record?
15
+ = hidden_field(:resource, :content_type, {:value => params[:content_type]})
14
16
  .clear
15
17
 
16
18
 
@@ -29,8 +31,8 @@
29
31
  = f.select :position, options_for_select(opt_for_select, @position)
30
32
  .clear
31
33
 
32
- = render 'edit.field', :name => 'visible', :f => f
33
- = render 'edit.field', :name => 'protected', :f => f
34
+ = render 'edit.field', :name => 'visible', :f => f, :view_prefix => 'edit.field'
35
+ = render 'edit.field', :name => 'protected', :f => f, :view_prefix => 'edit.field'
34
36
  .clear
35
37
 
36
38
 
@@ -40,6 +42,5 @@
40
42
  = image_tag("releaf/icons/129.png", :alt => "Parādīt pilnu sadaļu")
41
43
  .clear.persistent
42
44
 
43
- - if f.object.content
44
- = render 'edit.content_fields', :f => f
45
+ = render 'edit.content_fields', :f => f
45
46