dryml_generators/rapid/pages.dryml.erb in hobo-0.8.5 vs dryml_generators/rapid/pages.dryml.erb in hobo-0.8.6
- old
+ new
@@ -1,23 +1,24 @@
<!-- ====== Main Navigation ====== -->
<def tag="main-nav">
- <navigation class="main-nav" merge-attrs>
+ <navigation class="main-nav" merge-attrs param="default">
<nav-item href="#{base_url}/">Home</nav-item>
<% models.select { |m| linkable?(m, :index) }[0..4].each do |m| -%>
- <nav-item with="&<%= m.name %>"><%= m.name.titleize.pluralize %></nav-item>
+ <nav-item with="&<%= m.name %>"><%= m.view_hints.model_name.titleize.pluralize %></nav-item>
<% end -%>
</navigation>
</def>
- <% each_controller do -%>
+<% each_controller do -%>
<!-- ====== <%= model.name %> Pages ====== -->
<%
new_link = linkable?(:new)
+new_form = !new_link && linkable?(model, :create, :method => :post)
-%>
<def tag="index-page" for="<%= model.name %>">
<page merge title="<%= model_name :title, :plural %>">
@@ -34,15 +35,32 @@
<% if new_link -%>
<a action="new" to="&model" param="new-link"/>
<% end -%>
+<% if view_hints.paginate? -%>
<page-nav param="top-page-nav"/>
-
+
+<% end -%>
+<% if view_hints.sortable? -%>
+ <sortable-collection param="collection"/>
+<% else -%>
<collection param/>
-
+<% end -%>
+
+<% if view_hints.paginate? -%>
<page-nav param="bottom-page-nav"/>
+
+<% end -%>
+
+<% if new_form -%>
+ <div param="new-form">
+ <h3 param="new-form-heading">New <%= model_name :title %></h3>
+ <form with="&new_for_current_user <%= model %>" param/>
+ </div>
+
+<% end -%>
</section>
</content:>
</page>
</def>
@@ -85,30 +103,33 @@
add_link = collection && linkable?(collection_class, :"new_for_#{owner}")
add_form = !add_link && linkable?(collection_class, :"create_for_#{owner}", :method => :post)
end
end
-aside_collections = model.view_hints.secondary_children unless model.view_hints.secondary_children.empty?
+unless model.view_hints.secondary_children.empty?
+ aside_collections = model.view_hints.secondary_children.map { |c| [model.reflections[c], model.reverse_reflection(c)] }
+ aside_collections.reject! { |refl, reverse| reverse.nil? }
+end
-%>
<def tag="show-page" for="<%= model.name %>">
<page merge title="<%= model_name :title %>">
<body: class="show-page <%= model_class %>" param/>
<content: param>
<% if aside_collections -%>
- <section-group param="content-body">
+ <section-group>
<section param="main-content">
<% end -%>
<header param="content-header">
<% if back_link -%>
- <a:<%= back_link %> param="parent-link">« <name/></a>
+ <a:<%= back_link %> param="parent-link">« <name/></a:<%= back_link %>>
<% end -%>
<h2 param="heading"><name/></h2>
<% if boolean_fields -%>
- <field-names-where-true fields="<%= boolean_fields * ', ' %>" param/>
+ <record-flags fields="<%= boolean_fields * ', ' %>" param/>
<% end -%>
<% if creator_link -%>
<a:<%= model.creator_attribute %> param="creator-link"/>
<% elsif creator -%>
@@ -130,42 +151,49 @@
<% end -%>
<% if collection -%>
<section param="collection-section">
<h3 param="collection-heading"><%= '<Your/>' if is_user_model %><%= collection.to_s.titleize %></h3>
-<% if sortable_collection?(collection) -%>
+<% if sortable_collection?(collection) -%>
<sortable-collection:<%= collection %> param="collection"/>
-<% else -%>
+<% else -%>
<collection:<%= collection %> param/>
-<% end -%>
-<% if add_link -%>
+<% end -%>
+<% if add_link -%>
- <a:<%= collection %> action="new" if="&can_create?(@<%= model_name.underscore %>.<%= collection %>)" param="new-link">New <%= collection.to_s.singularize.titleize %></a>
-<% elsif add_form -%>
+ <a:<%= collection %> action="new" if="&can_create?(@<%= model_name.underscore %>.<%= collection %>)" param="new-link">New <%= collection.to_s.singularize.titleize %></a:<%= collection %>>
+<% elsif add_form -%>
<section param="add-to-collection" if="&can_create?(@<%= model_name.underscore %>.<%= collection %>)">
<h3 param="add-form-heading">Add <%= a_or_an collection.to_s.singularize.titleize %></h3>
- <form with="&@<%= collection_class.name.underscore %> || @<%= model_name.underscore %>.<%= collection %>.new_candidate" owner="<%= owner %>" without-cancel param>
+ <form with="&@<%= collection_class.name.underscore %> || new_for_current_user(@<%= model_name.underscore %>.<%= collection %>)" owner="<%= owner %>" without-cancel param>
<field-list: skip="<%= owner %>"/>
<submit: label="Add"/>
</form>
</section>
-<% end -%>
+<% end -%>
</section>
<% end # of main collection -%>
</section>
<% if aside_collections -%>
</section>
<aside param>
-<% for collection in aside_collections -%>
- <preview-with-more:<%= collection %>.recent param="preview-<%= collection %>">
-<% if is_user_model -%>
- <heading:><Your with="&@<%= model_name.underscore %>"/> <%= collection.to_s.titleize %></heading:>
-<% end -%>
+<% for refl, reverse_refl in aside_collections -%>
+<% if linkable?(refl.klass, :"index_for_#{reverse_refl.name}") -%>
+ <preview-with-more:<%= refl.name %>.recent param="<%= refl.name %>-preview">
+<% if is_user_model -%>
+ <heading:><Your with="&@<%= model_name.underscore %>"/> <%= refl.name.to_s.titleize %></heading:>
+<% end -%>
<more:>more</more:>
- </preview-with-more>
-<% end -%>
+ </preview-with-more:<%= refl.name %>.recent>
+<% else -%>
+ <section param="<%= refl.name %>-collection-section">
+ <h3 param="<%= refl.name %>-collection"><%= refl.name.to_s.titleize %></h3>
+ <collection:<%= refl.name %>/>
+ </section>
+<% end -%>
+<% end -%>
</aside>
</section-group>
<% end -%>
</content:>