typus-rails4 4.0.0.beta6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (198) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +488 -0
  3. data/Gemfile +57 -0
  4. data/Gemfile.lock +253 -0
  5. data/MIT-LICENSE +20 -0
  6. data/README.md +101 -0
  7. data/Rakefile +51 -0
  8. data/app/assets/javascripts/typus/application.js +11 -0
  9. data/app/assets/javascripts/typus/custom.js +2 -0
  10. data/app/assets/javascripts/typus/jquery-2.1.1.min.js +4 -0
  11. data/app/assets/javascripts/typus/jquery.application.js +30 -0
  12. data/app/assets/stylesheets/typus/application.css +6 -0
  13. data/app/assets/stylesheets/typus/custom.scss +4 -0
  14. data/app/assets/stylesheets/typus/overrides.scss +10 -0
  15. data/app/assets/stylesheets/typus/signin.scss +45 -0
  16. data/app/controllers/admin/account_controller.rb +47 -0
  17. data/app/controllers/admin/base_controller.rb +40 -0
  18. data/app/controllers/admin/dashboard_controller.rb +6 -0
  19. data/app/controllers/admin/resource_controller.rb +8 -0
  20. data/app/controllers/admin/resources_controller.rb +268 -0
  21. data/app/controllers/admin/session_controller.rb +43 -0
  22. data/app/controllers/concerns/admin/actions.rb +88 -0
  23. data/app/controllers/concerns/admin/acts_as_list.rb +35 -0
  24. data/app/controllers/concerns/admin/ancestry.rb +26 -0
  25. data/app/controllers/concerns/admin/autocomplete.rb +11 -0
  26. data/app/controllers/concerns/admin/bulk.rb +76 -0
  27. data/app/controllers/concerns/admin/featured_image.rb +22 -0
  28. data/app/controllers/concerns/admin/filters.rb +57 -0
  29. data/app/controllers/concerns/admin/format.rb +49 -0
  30. data/app/controllers/concerns/admin/headless.rb +23 -0
  31. data/app/controllers/concerns/admin/hooks.rb +4 -0
  32. data/app/controllers/concerns/admin/multisite.rb +10 -0
  33. data/app/controllers/concerns/admin/navigation.rb +27 -0
  34. data/app/controllers/concerns/admin/trash.rb +65 -0
  35. data/app/helpers/admin/base_helper.rb +78 -0
  36. data/app/helpers/admin/resources/data_types/belongs_to_helper.rb +88 -0
  37. data/app/helpers/admin/resources/data_types/boolean_helper.rb +33 -0
  38. data/app/helpers/admin/resources/data_types/date_helper.rb +16 -0
  39. data/app/helpers/admin/resources/data_types/datetime_helper.rb +19 -0
  40. data/app/helpers/admin/resources/data_types/dragonfly_helper.rb +49 -0
  41. data/app/helpers/admin/resources/data_types/float_helper.rb +2 -0
  42. data/app/helpers/admin/resources/data_types/has_and_belongs_to_many_helper.rb +59 -0
  43. data/app/helpers/admin/resources/data_types/has_many_helper.rb +76 -0
  44. data/app/helpers/admin/resources/data_types/has_one_helper.rb +44 -0
  45. data/app/helpers/admin/resources/data_types/integer_helper.rb +13 -0
  46. data/app/helpers/admin/resources/data_types/paperclip_helper.rb +49 -0
  47. data/app/helpers/admin/resources/data_types/selector_helper.rb +11 -0
  48. data/app/helpers/admin/resources/data_types/string_helper.rb +38 -0
  49. data/app/helpers/admin/resources/data_types/text_helper.rb +6 -0
  50. data/app/helpers/admin/resources/data_types/transversal_helper.rb +8 -0
  51. data/app/helpers/admin/resources/data_types/tree_helper.rb +28 -0
  52. data/app/helpers/admin/resources/display_helper.rb +27 -0
  53. data/app/helpers/admin/resources/filters_helper.rb +18 -0
  54. data/app/helpers/admin/resources/form_helper.rb +85 -0
  55. data/app/helpers/admin/resources/list_helper.rb +31 -0
  56. data/app/helpers/admin/resources/pagination_helper.rb +28 -0
  57. data/app/helpers/admin/resources/relationships_helper.rb +33 -0
  58. data/app/helpers/admin/resources/sidebar_helper.rb +34 -0
  59. data/app/helpers/admin/resources/table_helper.rb +69 -0
  60. data/app/helpers/admin/resources_helper.rb +25 -0
  61. data/app/mailers/admin/mailer.rb +19 -0
  62. data/app/views/admin/account/_form.html.erb +17 -0
  63. data/app/views/admin/account/forgot_password.html.erb +16 -0
  64. data/app/views/admin/account/new.html.erb +10 -0
  65. data/app/views/admin/dashboard/_sidebar.html.erb +14 -0
  66. data/app/views/admin/dashboard/index.html.erb +8 -0
  67. data/app/views/admin/dashboard/styles.html.erb +153 -0
  68. data/app/views/admin/dashboard/widgets/_applications.html.erb +44 -0
  69. data/app/views/admin/dashboard/widgets/_default.html.erb +43 -0
  70. data/app/views/admin/dashboard/widgets/_models.html.erb +23 -0
  71. data/app/views/admin/dashboard/widgets/_models_extended.html.erb +25 -0
  72. data/app/views/admin/dashboard/widgets/_resources.html.erb +23 -0
  73. data/app/views/admin/dashboard/widgets/_users.html.erb +23 -0
  74. data/app/views/admin/mailer/reset_password_instructions.html.erb +7 -0
  75. data/app/views/admin/mailer/reset_password_instructions.text.erb +7 -0
  76. data/app/views/admin/resource/_sidebar.html.erb +14 -0
  77. data/app/views/admin/resources/_edit.html.erb +0 -0
  78. data/app/views/admin/resources/_form.html.erb +28 -0
  79. data/app/views/admin/resources/_form_javascripts.html.erb +0 -0
  80. data/app/views/admin/resources/_form_modal.html.erb +13 -0
  81. data/app/views/admin/resources/_index.html.erb +0 -0
  82. data/app/views/admin/resources/_new.html.erb +0 -0
  83. data/app/views/admin/resources/_pagination.html.erb +15 -0
  84. data/app/views/admin/resources/_show.html.erb +0 -0
  85. data/app/views/admin/resources/_sidebar.html.erb +1 -0
  86. data/app/views/admin/resources/destroy.html.erb +16 -0
  87. data/app/views/admin/resources/edit.html.erb +22 -0
  88. data/app/views/admin/resources/edit/_actions.html.erb +7 -0
  89. data/app/views/admin/resources/edit/_recently_edited.html.erb +8 -0
  90. data/app/views/admin/resources/index.html.erb +29 -0
  91. data/app/views/admin/resources/new.html.erb +20 -0
  92. data/app/views/admin/resources/show.html.erb +26 -0
  93. data/app/views/admin/session/new.html.erb +18 -0
  94. data/app/views/admin/shared/_head.html.erb +24 -0
  95. data/app/views/admin/shared/_modals.html.erb +3 -0
  96. data/app/views/admin/shared/_sidebar_placeholder.html.erb +0 -0
  97. data/app/views/admin/templates/README.md +5 -0
  98. data/app/views/admin/templates/_belongs_to.html.erb +8 -0
  99. data/app/views/admin/templates/_boolean.html.erb +7 -0
  100. data/app/views/admin/templates/_date.html.erb +6 -0
  101. data/app/views/admin/templates/_datetime.html.erb +8 -0
  102. data/app/views/admin/templates/_dragonfly.html.erb +6 -0
  103. data/app/views/admin/templates/_dragonfly_form_preview.html.erb +21 -0
  104. data/app/views/admin/templates/_dragonfly_preview.html.erb +12 -0
  105. data/app/views/admin/templates/_has_and_belongs_to_many.html.erb +21 -0
  106. data/app/views/admin/templates/_has_many.html.erb +18 -0
  107. data/app/views/admin/templates/_has_one.html.erb +14 -0
  108. data/app/views/admin/templates/_json.html.erb +11 -0
  109. data/app/views/admin/templates/_paperclip.html.erb +5 -0
  110. data/app/views/admin/templates/_paperclip_form_preview.html.erb +21 -0
  111. data/app/views/admin/templates/_paperclip_preview.html.erb +12 -0
  112. data/app/views/admin/templates/_password.html.erb +6 -0
  113. data/app/views/admin/templates/_position.html.erb +5 -0
  114. data/app/views/admin/templates/_profile_sidebar.html.erb +4 -0
  115. data/app/views/admin/templates/_selector.html.erb +4 -0
  116. data/app/views/admin/templates/_string.html.erb +4 -0
  117. data/app/views/admin/templates/_string_with_preview.html.erb +11 -0
  118. data/app/views/admin/templates/_text.html.erb +11 -0
  119. data/app/views/admin/templates/_text_with_ckeditor.html.erb +24 -0
  120. data/app/views/admin/templates/_text_with_ckeditor_and_assets.html.erb +38 -0
  121. data/app/views/admin/templates/_time.html.erb +9 -0
  122. data/app/views/admin/templates/_tree.html.erb +6 -0
  123. data/app/views/admin/templates/modals/_belongs_to.html.erb +60 -0
  124. data/app/views/admin/templates/modals/_dragonfly.html.erb +13 -0
  125. data/app/views/admin/templates/modals/_has_and_belongs_to_many.html.erb +25 -0
  126. data/app/views/admin/templates/modals/_has_many.html.erb +59 -0
  127. data/app/views/admin/templates/modals/_paperclip.html.erb +13 -0
  128. data/app/views/helpers/admin/base/_apps.html.erb +86 -0
  129. data/app/views/helpers/admin/base/_breadcrumbs.html.erb +6 -0
  130. data/app/views/helpers/admin/base/_flash_message.html.erb +3 -0
  131. data/app/views/helpers/admin/base/_login_info.html.erb +0 -0
  132. data/app/views/helpers/admin/dashboard/_resources.html.erb +19 -0
  133. data/app/views/helpers/admin/resources/_actions.html.erb +18 -0
  134. data/app/views/helpers/admin/resources/_errors.html.erb +12 -0
  135. data/app/views/helpers/admin/resources/_filters.html.erb +16 -0
  136. data/app/views/helpers/admin/resources/_search.html.erb +17 -0
  137. data/app/views/helpers/admin/resources/_sidebar.html.erb +4 -0
  138. data/app/views/helpers/admin/resources/_table.html.erb +45 -0
  139. data/app/views/helpers/admin/resources/sidebar/_item.html.erb +26 -0
  140. data/app/views/helpers/admin/resources/sidebar/_items.html.erb +14 -0
  141. data/app/views/helpers/admin/resources/sidebar/_items_index.html.erb +57 -0
  142. data/app/views/layouts/admin/base.html.erb +30 -0
  143. data/app/views/layouts/admin/headless.html.erb +1 -0
  144. data/app/views/layouts/admin/session.html.erb +26 -0
  145. data/bin/run-tests +7 -0
  146. data/bin/setup +9 -0
  147. data/config/locales/typus.en.yml +125 -0
  148. data/config/routes.rb +46 -0
  149. data/lib/generators/templates/config/initializers/typus.rb +34 -0
  150. data/lib/generators/templates/config/initializers/typus_authentication.rb +18 -0
  151. data/lib/generators/templates/config/initializers/typus_resources.rb +24 -0
  152. data/lib/generators/templates/config/typus/README +58 -0
  153. data/lib/generators/templates/config/typus/application.yml +3 -0
  154. data/lib/generators/templates/config/typus/application_roles.yml +4 -0
  155. data/lib/generators/templates/config/typus/typus.yml +15 -0
  156. data/lib/generators/templates/config/typus/typus_roles.yml +4 -0
  157. data/lib/generators/templates/controller.erb +2 -0
  158. data/lib/generators/templates/migration.erb +22 -0
  159. data/lib/generators/templates/view.html.erb +13 -0
  160. data/lib/generators/typus/config_generator.rb +67 -0
  161. data/lib/generators/typus/controller_generator.rb +26 -0
  162. data/lib/generators/typus/initializers_generator.rb +20 -0
  163. data/lib/generators/typus/migration_generator.rb +94 -0
  164. data/lib/generators/typus/model_generator.rb +93 -0
  165. data/lib/generators/typus/typus_generator.rb +54 -0
  166. data/lib/generators/typus/views_generator.rb +19 -0
  167. data/lib/support/active_record.rb +42 -0
  168. data/lib/support/fake_user.rb +47 -0
  169. data/lib/support/hash.rb +8 -0
  170. data/lib/support/object.rb +9 -0
  171. data/lib/support/string.rb +40 -0
  172. data/lib/tasks/typus.rake +11 -0
  173. data/lib/typus.rb +215 -0
  174. data/lib/typus/authentication/base.rb +39 -0
  175. data/lib/typus/authentication/devise.rb +19 -0
  176. data/lib/typus/authentication/http_basic.rb +18 -0
  177. data/lib/typus/authentication/none.rb +15 -0
  178. data/lib/typus/authentication/none_with_role.rb +15 -0
  179. data/lib/typus/authentication/session.rb +123 -0
  180. data/lib/typus/configuration.rb +43 -0
  181. data/lib/typus/engine.rb +4 -0
  182. data/lib/typus/orm/active_record.rb +10 -0
  183. data/lib/typus/orm/active_record/admin_user.rb +65 -0
  184. data/lib/typus/orm/active_record/class_methods.rb +104 -0
  185. data/lib/typus/orm/active_record/instance_methods.rb +76 -0
  186. data/lib/typus/orm/active_record/search.rb +43 -0
  187. data/lib/typus/orm/base/class_methods.rb +188 -0
  188. data/lib/typus/orm/base/search.rb +70 -0
  189. data/lib/typus/regex.rb +11 -0
  190. data/lib/typus/resources.rb +55 -0
  191. data/lib/typus/version.rb +10 -0
  192. data/typus.gemspec +27 -0
  193. data/vendor/assets/chosen/LICENSE.md +24 -0
  194. data/vendor/assets/chosen/chosen-sprite.png +0 -0
  195. data/vendor/assets/chosen/chosen-sprite@2x.png +0 -0
  196. data/vendor/assets/chosen/chosen.jquery.js +1239 -0
  197. data/vendor/assets/chosen/chosen.scss +437 -0
  198. metadata +271 -0
@@ -0,0 +1,8 @@
1
+ <% locals = { attribute: attribute, related: related, attribute_id: attribute_id } %>
2
+
3
+ <%= render partial: 'admin/templates/modals/belongs_to', locals: locals %>
4
+
5
+ <div class="form-group" id="<%= attribute_id %>_li">
6
+ <%= form.label attribute, label_text, { class: 'control-label' } %> <%= build_label_text_for_belongs_to(related, html_options, options) %>
7
+ <%= form.select related_fk, values, options, html_options %>
8
+ </div>
@@ -0,0 +1,7 @@
1
+ <% options.delete(:class) %>
2
+
3
+ <div class="checkbox" id="<%= attribute_id %>">
4
+ <label>
5
+ <%= form.check_box attribute, options %> <%= label_text %>
6
+ </label>
7
+ </div>
@@ -0,0 +1,6 @@
1
+ <div class="control-group" id="<%= attribute_id %>">
2
+ <%= form.label attribute, label_text, { :class => "control-label" } %>
3
+ <div class="controls">
4
+ <%= form.date_select attribute, options, html_options %>
5
+ </div>
6
+ </div>
@@ -0,0 +1,8 @@
1
+ <% html_options = { class: 'control-label' } %>
2
+
3
+ <div class="form-group" id="<%= attribute_id %>">
4
+ <%= form.label attribute, label_text, { class: 'control-label' } %>
5
+ <div class="controls">
6
+ <%= form.datetime_select attribute, options, html_options %>
7
+ </div>
8
+ </div>
@@ -0,0 +1,6 @@
1
+ <div class="form-group" id="<%= attribute_id %>">
2
+ <%= form.label attribute, link_to_detach_attribute_for_dragonfly(attribute) %>
3
+ <%= form.file_field attribute, options %>
4
+ <%= typus_dragonfly_preview(@item, attribute, 'dragonfly_form_preview') %>
5
+ <%= form.hidden_field "retained_#{attribute}" %>
6
+ </div>
@@ -0,0 +1,21 @@
1
+ <div class="media">
2
+ <% html_options = { 'class' => 'pull-left thumbnail', 'data-toggle' => 'modal', 'modal-id' => "#{item.id}_#{attribute}" } %>
3
+
4
+ <%= render partial: 'admin/templates/modals/dragonfly',
5
+ locals: { html_options: html_options, preview: preview, attachment: attachment } %>
6
+
7
+ <%= link_to "#preview_#{html_options['modal-id']}", html_options do %>
8
+ <%= image_tag thumb, class: 'media-object', alt: preview %>
9
+ <% end %>
10
+
11
+ <div class="media-body">
12
+ <dl>
13
+ <dt>File name</dt>
14
+ <dd><%= attachment.name %></dd>
15
+ <dt>File type</dt>
16
+ <dd><%= attachment.mime_type %></dd>
17
+ <dt>Dimensions</dt>
18
+ <dd><%= attachment.width %> x <%= attachment.height %></dd>
19
+ </dl>
20
+ </div>
21
+ </div>
@@ -0,0 +1,12 @@
1
+ <% if headless_mode? %>
2
+ <%= image_tag thumb, alt: preview %>
3
+ <% else %>
4
+ <% html_options = { 'data-toggle' => 'modal', 'modal-id' => "#{item.id}_#{attribute}" } %>
5
+
6
+ <%= render partial: 'admin/templates/modals/dragonfly',
7
+ locals: { html_options: html_options, preview: preview, attachment: attachment } %>
8
+
9
+ <%= link_to "#preview_#{html_options['modal-id']}", html_options do %>
10
+ <%= image_tag table_thumb, alt: preview %>
11
+ <% end %>
12
+ <% end %>
@@ -0,0 +1,21 @@
1
+ <% chosen_class = "chzn-select-#{attribute_id}" %>
2
+
3
+ <%= render partial: 'admin/templates/modals/has_and_belongs_to_many',
4
+ locals: { attribute: attribute, attribute_id: attribute_id } %>
5
+
6
+ <div class="control-group" id="<%= attribute_id %>">
7
+ <%= form.label attribute, label_text, { class: 'control-label' } %>
8
+ <%= hidden_field_tag related_ids %>
9
+ <div class="controls">
10
+ <%= select_tag related_ids,
11
+ options_from_collection_for_select(values.all, 'id', 'to_label', related_items.map(&:id)),
12
+ html_options.merge(:multiple => true,
13
+ :id => attribute_id,
14
+ :class => chosen_class,
15
+ 'data-placeholder' => t('Select Some Options')) %>
16
+ </div>
17
+ </div>
18
+
19
+ <script type="text/javascript">
20
+ // $(document).ready(function () { $(".<%= chosen_class %>").chosen(); });
21
+ </script>
@@ -0,0 +1,18 @@
1
+ <%= render partial: 'admin/templates/modals/has_many' %>
2
+
3
+ <div class="box_relationships" id="<%= association_name %>">
4
+
5
+ <h2>
6
+ <%= @resource.human_attribute_name(association_name) %>
7
+ <%= " (#{@data.count})" if @resource.typus_options_for(:counters) %>
8
+ <small><%= add_new %></small>
9
+ </h2>
10
+
11
+ <% if @items.any? -%>
12
+ <%= table %>
13
+ <%= admin_paginate(@model_to_relate) %>
14
+ <% else %>
15
+ <p><%= t('typus.shared.no_entries_found') %></p>
16
+ <% end %>
17
+
18
+ </div>
@@ -0,0 +1,14 @@
1
+ <div class="box_relationships" id="<%= association_name %>">
2
+
3
+ <h2>
4
+ <%= association_name.titleize.humanize %>
5
+ <small><%= add_new %></small>
6
+ </h2>
7
+
8
+ <% if @items.any? -%>
9
+ <%= table %>
10
+ <% else %>
11
+ <p><%= t("typus.shared.no_entries_found") %></p>
12
+ <% end %>
13
+
14
+ </div>
@@ -0,0 +1,11 @@
1
+ <%
2
+ custom = { :rows => @resource.typus_options_for(:form_rows) }
3
+ options = options.merge!(custom)
4
+ %>
5
+
6
+ <div class="form-group" id="<%= attribute_id %>">
7
+ <%= form.label attribute, label_text.html_safe, { :class => "control-label" } %>
8
+ <div class="controls">
9
+ <%= form.text_area attribute, options %>
10
+ </div>
11
+ </div>
@@ -0,0 +1,5 @@
1
+ <div class="form-group" id="<%= attribute_id %>">
2
+ <%= form.label attribute, link_to_detach_attribute_for_paperclip(attribute) %>
3
+ <%= form.file_field attribute, options %>
4
+ <%= typus_paperclip_preview(@item, attribute, 'paperclip_form_preview') %>
5
+ </div>
@@ -0,0 +1,21 @@
1
+ <div class="media">
2
+ <% html_options = { 'class' => 'pull-left thumbnail', 'data-toggle' => 'modal', 'modal-id' => "#{item.id}_#{attribute}" } %>
3
+
4
+ <%= render partial: 'admin/templates/modals/paperclip',
5
+ locals: { html_options: html_options, preview: preview, attachment: attachment } %>
6
+
7
+ <%= link_to "#preview_#{html_options['modal-id']}", html_options do %>
8
+ <%= image_tag thumb, class: 'media-object', alt: preview %>
9
+ <% end %>
10
+
11
+ <div class="media-body">
12
+ <dl>
13
+ <dt>File name</dt>
14
+ <dd><%= attachment.original_filename %></dd>
15
+ <dt>File type</dt>
16
+ <dd>MISSING<%# = attachment.mime_type %></dd>
17
+ <dt>Dimensions</dt>
18
+ <dd>MISSING<%#= attachment.width %> x <%#= attachment.height %></dd>
19
+ </dl>
20
+ </div>
21
+ </div>
@@ -0,0 +1,12 @@
1
+ <% if headless_mode? %>
2
+ <%= image_tag thumb, alt: preview %>
3
+ <% else %>
4
+ <% html_options = { 'data-toggle' => 'modal', 'modal-id' => "#{item.id}_#{attribute}" } %>
5
+
6
+ <%= render partial: 'admin/templates/modals/paperclip',
7
+ locals: { html_options: html_options, preview: preview, attachment: attachment, attribute: attribute } %>
8
+
9
+ <%= link_to "#preview_#{html_options['modal-id']}", html_options do %>
10
+ <%= image_tag table_thumb, alt: preview %>
11
+ <% end %>
12
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <div class="form-group" id="<%= attribute_id %>">
2
+ <%= form.label attribute, label_text %>
3
+ <div class="controls">
4
+ <%= form.password_field attribute, options.merge(:value => @item.send(attribute)) %>
5
+ </div>
6
+ </div>
@@ -0,0 +1,5 @@
1
+ <%= item.position %>
2
+
3
+ <div class="position">
4
+ <%= html_position.join(connector).html_safe %>
5
+ </div>
@@ -0,0 +1,4 @@
1
+ <h2>Profile</h2>
2
+
3
+ <p>Replace this sidebar dropping a file named <code>_profile_sidebar.html.erb</code>
4
+ on <code>app/views/admin/templates</code> folder.</p>
@@ -0,0 +1,4 @@
1
+ <div class="form-group" id="<%= attribute_id %>">
2
+ <%= form.label attribute, label_text, { class: 'control-label' } %>
3
+ <%= form.select attribute, @resource.send(attribute.pluralize), options, { class: 'form-control' } %>
4
+ </div>
@@ -0,0 +1,4 @@
1
+ <div class="form-group" id="<%= attribute_id %>">
2
+ <%= form.label attribute, label_text %>
3
+ <%= form.text_field attribute, options %>
4
+ </div>
@@ -0,0 +1,11 @@
1
+ <%
2
+ unless @item.new_record?
3
+ text = link_to(t('typus.buttons.preview'), send("#{@item.class.model_name.downcase}_path",@item.to_param), :target => "_blank")
4
+ label_text << "<small>#{text}</small>"
5
+ end
6
+ %>
7
+
8
+ <li id="<%= attribute_id %>">
9
+ <%= form.label attribute, raw(label_text) %>
10
+ <%= form.text_field attribute, options %>
11
+ </li>
@@ -0,0 +1,11 @@
1
+ <%
2
+ custom = { :rows => @resource.typus_options_for(:form_rows) }
3
+ options = options.merge!(custom)
4
+ %>
5
+
6
+ <div class="form-group" id="<%= attribute_id %>">
7
+ <%= form.label attribute, label_text.html_safe, { :class => "control-label" } %>
8
+ <div class="controls">
9
+ <%= form.text_area attribute, options %>
10
+ </div>
11
+ </div>
@@ -0,0 +1,24 @@
1
+ <% content_for :javascripts do %>
2
+ <script type="text/javascript">
3
+ var CKEDITOR_BASEPATH = '/assets/ckeditor/';
4
+ </script>
5
+
6
+ <%= javascript_include_tag 'ckeditor/ckeditor' %>
7
+ <%= javascript_include_tag 'ckeditor/adapters/jquery' %>
8
+
9
+ <script type="text/javascript">
10
+ $(document).ready(function() {
11
+ $(".rich_text").ckeditor();
12
+ });
13
+ </script>
14
+ <% end %>
15
+
16
+ <%
17
+ custom = { :rows => @resource.typus_options_for(:form_rows), :class => "rich_text" }
18
+ options = options.merge!(custom)
19
+ %>
20
+
21
+ <li id="<%= attribute_id %>">
22
+ <%= form.label attribute, label_text %>
23
+ <%= form.text_area attribute, options %>
24
+ </li>
@@ -0,0 +1,38 @@
1
+ <% content_for :javascripts do %>
2
+ <script type="text/javascript">
3
+ var CKEDITOR_BASEPATH = '/assets/ckeditor/';
4
+ </script>
5
+
6
+ <%= javascript_include_tag 'ckeditor/ckeditor' %>
7
+ <%= javascript_include_tag 'ckeditor/adapters/jquery' %>
8
+
9
+ <script type="text/javascript">
10
+ $(document).ready(function() {
11
+ $(".rich_text").ckeditor();
12
+ });
13
+ </script>
14
+ <% end %>
15
+
16
+ <%
17
+ custom = { :rows => @resource.typus_options_for(:form_rows), :class => "rich_text" }
18
+ options = options.merge!(custom)
19
+ %>
20
+
21
+ <%
22
+ unless params[:_popup]
23
+ input = "#{@resource.model_name.to_s.underscore.gsub("/", "_")}_#{attribute}"
24
+ insert_picture = <<-DATA
25
+ <small>
26
+ #{link_to "Insert picture",
27
+ {:controller => "/admin/assets", :_popup => true, :_input => input},
28
+ {:class => "iframe", :style => "font-size: 10px; background: black; color: white; padding: 2px 5px; -moz-border-radius: 3px; -webkit-border-radius: 3px;"}}
29
+ </small>
30
+ DATA
31
+ label_text << insert_picture.html_safe
32
+ end
33
+ %>
34
+
35
+ <div class="clearfix" id="<%= attribute_id %>">
36
+ <%= form.label attribute, label_text.html_safe %>
37
+ <%= form.text_area attribute, options %>
38
+ </div>
@@ -0,0 +1,9 @@
1
+ <%
2
+ custom = { :include_blank => false }
3
+ options.merge!(custom)
4
+ %>
5
+
6
+ <li id="<%= attribute_id %>">
7
+ <%= form.label attribute, label_text %>
8
+ <%= form.time_select attribute, options, html_options %>
9
+ </li>
@@ -0,0 +1,6 @@
1
+ <% unless values.empty? %>
2
+ <li id="<%= attribute_id %>">
3
+ <%= form.label label_text %>
4
+ <%= form.select :parent_id, values, { :include_blank => true } %>
5
+ </li>
6
+ <% end %>
@@ -0,0 +1,60 @@
1
+ <% content_for "modal_for_#{attribute}" do %>
2
+
3
+ <% new_page_title = t('typus.resources.add.title', resource: related.model_name.human.titleize) %>
4
+
5
+ <div id="modal-from-dom-<%= attribute_id %>" class="modal fade">
6
+ <div class="modal-dialog">
7
+ <div class="modal-content">
8
+
9
+ <div class="modal-header">
10
+ <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
11
+ <h4 class="modal-title"><%= new_page_title %></h4>
12
+ </div>
13
+
14
+ <div class="modal-body"></div>
15
+
16
+ <div class="modal-footer">
17
+ <% html_options = { id: 'modal-form-submit', class: 'btn btn-primary' } %>
18
+ <%= link_to t('typus.buttons.save'), { anchor: '', _continue: true }, html_options %>
19
+ </div>
20
+
21
+ <script>
22
+
23
+ <% object_id = "new_#{related.model_name.to_s.downcase}" %>
24
+
25
+ $('#modal-form-submit').click(function(e){
26
+ e.preventDefault();
27
+
28
+ $('#<%= object_id %>').submit(function() {
29
+
30
+ // Get the action url:
31
+ var action;
32
+ action = $('#<%= object_id %>').attr('action');
33
+
34
+ $.post(action, $(this).serialize(), function(data){})
35
+ .success(function(data, text, xhr) {
36
+ $('.modal-body').html(data);
37
+
38
+ var option = new Option($("#_label").attr("value"), $("#_id").attr("value"), true, true);
39
+ parent.$("#<%= attribute_id %>").prepend(option);
40
+
41
+ $("#modal-from-dom-<%= attribute_id %>").modal('hide');
42
+ })
43
+ .error(function(request, status, error) {
44
+ $('.modal-body').html(request.responseText);
45
+ });
46
+
47
+ return false;
48
+ });
49
+
50
+ $('#<%= related.model_name.to_s.downcase %>').submit();
51
+
52
+ return false;
53
+ });
54
+ </script>
55
+
56
+ </div>
57
+ </div>
58
+ </div>
59
+
60
+ <% end %>
@@ -0,0 +1,13 @@
1
+ <div id="preview_<%= html_options['modal-id'] %>" class="modal fade">
2
+ <div class="modal-dialog">
3
+ <div class="modal-content">
4
+ <div class="modal-header">
5
+ <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
6
+ <h4 class="modal-title"><%= attachment.name %></h4>
7
+ </div>
8
+ <div class="modal-body">
9
+ <%= image_tag preview %>
10
+ </div>
11
+ </div>
12
+ </div>
13
+ </div>
@@ -0,0 +1,25 @@
1
+ <% content_for "modal_for_#{attribute}" do %>
2
+
3
+ <% new_page_title = t('typus.resources.add.title', :resource => attribute.titleize.singularize) %>
4
+
5
+ <div id="modal-from-dom-<%= attribute_id %>" class="modal fade">
6
+ <div class="modal-dialog">
7
+ <div class="modal-content">
8
+
9
+ <div class="modal-header">
10
+ <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
11
+ <h4 class="modal-title"><%= new_page_title %></h4>
12
+ </div>
13
+
14
+ <div class="modal-body"></div>
15
+
16
+ <div class="modal-footer">
17
+ <% html_options = { id: 'modal-form-submit', class: 'btn btn-primary' } %>
18
+ <%= link_to t('typus.buttons.save'), '#', html_options %>
19
+ </div>
20
+
21
+ </div>
22
+ </div>
23
+ </div>
24
+
25
+ <% end %>
@@ -0,0 +1,59 @@
1
+ <%
2
+ new_page_title = t('typus.resources.add.title', :resource => @model_to_relate.model_name.human.titleize)
3
+ html_class = "new_#{@model_to_relate.model_name.to_s.downcase}"
4
+ html_modal_class = "modal-from-dom-#{@model_to_relate.table_name}"
5
+ modal_association = "#{@resource.model_name.to_s.downcase}_#{@model_to_relate.table_name}"
6
+ %>
7
+
8
+ <div id="<%= html_modal_class %>" class="modal fade">
9
+ <div class="modal-dialog">
10
+ <div class="modal-content">
11
+
12
+ <div class="modal-header">
13
+ <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
14
+ <h4 class="modal-title"><%= new_page_title %></h4>
15
+ </div>
16
+
17
+ <div class="modal-body"></div>
18
+
19
+ <div class="modal-footer">
20
+ <% html_options = { id: "modal-form-submit-#{modal_association}", class: 'btn btn-primary' } %>
21
+ <%= link_to t('typus.buttons.save'), '#', html_options %>
22
+ </div>
23
+
24
+ <script>
25
+ $('#modal-form-submit-<%= modal_association %>').on('click', function(e){
26
+ e.preventDefault();
27
+
28
+ var form_data = $('#<%= html_class %>').serialize();
29
+ var my_data = $("#view_ip").attr('value');
30
+
31
+ $('#<%= html_class %>').on('submit', function(event) {
32
+
33
+ event.preventDefault();
34
+
35
+ // Get the action url:
36
+ var action = $('#<%= html_class %>').attr('action');
37
+ var form_data = $('#<%= html_class %>').serialize();
38
+
39
+ $.post(action, form_data, function(data){})
40
+ .success(function(data, text, xhr) {
41
+ $("#<%= html_modal_class %>").modal('hide');
42
+ parent.location.reload();
43
+ })
44
+ .error(function(request, status, error) {
45
+ $('#<%= html_modal_class %> .modal-body').html(request.responseText);
46
+ });
47
+
48
+ return false;
49
+ });
50
+
51
+ $('#<%= html_class %>').submit();
52
+ return false;
53
+ });
54
+
55
+ </script>
56
+
57
+ </div>
58
+ </div>
59
+ </div>