dryml_generators/rapid/pages.dryml.erb in hobo-0.8.3 vs dryml_generators/rapid/pages.dryml.erb in hobo-0.8.4
- old
+ new
@@ -31,11 +31,11 @@
</header>
<section param="content-body">
<% if new_link -%>
- <a action="new" to="&model" merge-params/>
+ <a action="new" to="&model" param="new-link"/>
<% end -%>
<page-nav param="top-page-nav"/>
<collection param/>
@@ -72,80 +72,104 @@
creator = model.creator_attribute
creator_link = creator && model.reflections[creator] && linkable?(model.reflections[creator].klass, :show)
edit_link = linkable?(:edit)
main_content = model.primary_content_attribute
show_fields = standard_fields(:belongs_to).*.to_s - [model.name_attribute, main_content, creator, back_link, *boolean_fields].*.to_s
-collection = model.dependent_collections.sort_by(&:to_s).first
+
+is_user_model = model < Hobo::User
+
+collection = model.view_hints.primary_children
if collection
collection_class = model.reflections[collection].klass
owner = model.reverse_reflection(collection)._?.name
if owner
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?
-%>
<def tag="show-page" for="<%= model.name %>">
<page merge title="<%= model_name :title %>">
<body: class="show-page <%= model_class %>" param/>
<content: param>
- <header param="content-header">
+<% if aside_collections -%>
+ <section-group param="content-body">
+ <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>
<% end -%>
- <h2 param="heading"><name/></h2>
-<% if boolean_fields.any? -%>
+ <h2 param="heading"><name/></h2>
+<% if boolean_fields -%>
- <field-names-where-true fields="<%= boolean_fields * ', ' %>" param/>
+ <field-names-where-true fields="<%= boolean_fields * ', ' %>" param/>
<% end -%>
<% if creator_link -%>
- <a:<%= model.creator_attribute %> param="creator-link"/>
+ <a:<%= model.creator_attribute %> param="creator-link"/>
<% elsif creator -%>
- <view:get-creator param="creator-name"/>
+ <view:get-creator param="creator-name"/>
<% end -%>
<% if edit_link -%>
- <a action="edit" if="&can_edit?" param="edit-link">Edit <%= model_name :title %></a>
+ <a action="edit" if="&can_edit?" param="edit-link">Edit <%= model_name :title %></a>
<% end -%>
- </header>
+ </header>
- <section param="content-body">
+ <section param="content-body"<%= ' with-flash-messages' if aside_collections %>>
<% if main_content -%>
- <view:<%= main_content %> param="primary-content"/>
+ <view:<%= main_content %> param="description"/>
<% end -%>
<% if show_fields.any? -%>
- <field-list fields="<%= show_fields * ', ' %>" param/>
+ <field-list fields="<%= show_fields * ', ' %>" param/>
<% end -%>
<% if collection -%>
- <section param="collection-section">
- <h3 param="collection-heading"><%= collection.to_s.titleize %></h3>
+ <section param="collection-section">
+ <h3 param="collection-heading"><%= '<Your/>' if is_user_model %><%= collection.to_s.titleize %></h3>
<% if sortable_collection?(collection) -%>
- <sortable-collection:<%= collection %> param="collection"/>
+ <sortable-collection:<%= collection %> param="collection"/>
<% else -%>
- <collection:<%= collection %> param/>
+ <collection:<%= collection %> param/>
<% 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>
+ <a:<%= collection %> action="new" if="&can_create?(@<%= model_name.underscore %>.<%= collection %>)" param="new-link">New <%= collection.to_s.singularize.titleize %></a>
<% 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" owner="<%= owner %>" method="post" without-cancel param>
- <field-list: skip="<%= owner %>"/>
- <submit: label="Add"/>
- </form>
- </section>
+ <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>
+ <field-list: skip="<%= owner %>"/>
+ <submit: label="Add"/>
+ </form>
+ </section>
<% 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 -%>
- </section>
+ <more:>more</more:>
+ </preview-with-more>
+<% end -%>
+ </aside>
+ </section-group>
+<% end -%>
</content:>
</page>
</def>
@@ -158,11 +182,11 @@
<body: class="edit-page <%= model_class %>" param/>
<content:>
<section param="content-header">
- <h2 param="heading"><name/></h2>
+ <h2 param="heading">Edit <type-name/></h2>
<delete-button label="Remove This <%= model_name :title %>" param/>
</section>
<section param="content-body">
<form param/>
@@ -177,10 +201,12 @@
collection_name = model.reverse_reflection(owner).name.to_s
owner_model = model.reflections[owner].klass
linkable_owner = linkable?(owner_model, :show)
owner_tag = linkable_owner ? "a" : "name"
+owner_is_user = owner_model < Hobo::User
+
owner = model.reflections[owner].macro == :has_many ? owner.to_s.singularize : owner.to_s
-%>
<% if :index.in? actions -%>
<%
new_link = :new.in?(actions)
@@ -190,21 +216,26 @@
<page merge title="<%= model_name :title, :plural %> for #{name :with => @<%= owner %>, :no_wrapper => true}">
<body: class="index-for-owner-page <%= owner.dasherize %> <%= model_class %>" param/>
<content: param>
<header param="content-header">
- <% if linkable_owner %><div param="back-to">Back to <a with="&@<%= owner %>"/></div><% end %>
+<% if linkable_owner -%>
+ <div param="back-to">Back to <a with="&@<%= owner %>"/></div>
+<% end -%>
+<% if owner_is_user %>
+ <h2 param="heading"><Your with="¤t_user"/> <%= model_name :title, :plural %></h2>
+<% else -%>
<h2 param="heading"><%= model_name :title, :plural %></h2>
<h3 param="subheading">For: <<%= owner_tag %> with="&@<%= owner %>"/></h3>
-
+<% end -%>
<p param="count" if>There <count prefix="are"/></p>
</header>
<section param="content-body">
<% if new_link -%>
- <a action="new" to="&model" merge-params/>
+ <a action="new" to="&model" param="new-link"/>
<% end -%>
<page-nav param="top-page-nav"/>
<collection param/>
@@ -225,11 +256,11 @@
<body: class="new-for-owner-page <% owner.dasherize %> <%= model_class %>" param/>
<content: param>
<header param="content-header">
<h2 param="heading">New <%= collection_name.singularize.titleize %></h2>
- <h3 class="subheading" param>For: <<%= owner_tag %> with="&@<%= owner %>"/></h3>
+ <h3 param="subheading">For: <<%= owner_tag %> with="&@<%= owner %>"/></h3>
</header>
<section param="content-body">
<form owner="<%= owner %>" method="post" param>
<field-list: skip="<%= owner %>"/>
@@ -241,12 +272,11 @@
</def>
<% end -%>
<% end # of owner_actions.each_pair -%>
-<% if defined? model::Lifecycle -%>
-<% model::Lifecycle.creators.values.where.publishable?.*.name.each do |creator| -%>
+<% creator_names.each do |creator| -%>
<def tag="<%= creator.dasherize %>-page" polymorphic/>
<def tag="<%= creator.dasherize %>-page" for="<%= model.name %>">
<page title="<%= creator.titleize %>" merge>
@@ -264,11 +294,11 @@
</page>
</def>
<% end -%>
-<% model::Lifecycle.transitions.where.publishable?.*.name.each do |transition| -%>
+<% transition_names.each do |transition| -%>
<def tag="<%= transition.dasherize %>-page" polymorphic/>
<def tag="<%= transition.dasherize %>-page" for="<%= model.name %>">
<page title="<%= transition.titleize %>" merge>
<body: class="lifecycle-transition-page <%= transition.dasherize -%>-page" param/>
@@ -285,8 +315,7 @@
</page>
</def>
<% end -%>
-<% end # of if defined? model::Lifecycle -%>
<% end # of each_model do -%>