Skip to content

Commit

Permalink
break templates#new into multiple forms #114
Browse files Browse the repository at this point in the history
  • Loading branch information
zr2d2 committed Jun 22, 2012
1 parent 211892a commit 566a7fe
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 20 deletions.
31 changes: 31 additions & 0 deletions app/views/templates/_create_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<%= form_for(@template, :url => import_templates_path, :html => { :multipart => true }) do |f| %>
<% if @template.errors.any? %>
<div id="errorExplanation">
<h2><%= pluralize(@template.errors.count, "error") %> prohibited this template from being saved:</h2>
<ul>
<% @template.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>

<div class="field">
<%= label_tag :package %><br />
<%= file_field_tag :package %>
</div>
<hr />
<div class="field">
<%= label_tag :image %><br />
<%= file_field_tag :image %>
</div>
<div class="field">
<%= label_tag :descriptor %><br />
<%= file_field_tag :descriptor %>
</div>


<div class="actions">
<%= f.submit("Import Template") %>
</div>
<% end %>
44 changes: 31 additions & 13 deletions app/views/templates/_import_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,37 @@
</div>
<% end %>

<div class="field">
<%= label_tag :package %><br />
<%= file_field_tag :package %>
</div>
<hr />
<div class="field">
<%= label_tag :image %><br />
<%= file_field_tag :image %>
</div>
<div class="field">
<%= label_tag :descriptor %><br />
<%= file_field_tag :descriptor %>
</div>
<fieldset>
<div class="clearfix">
<%= f.label :name %>
<div class="input">
<%= f.text_field :name %>
</div>
</div>

<div class="clearfix">
<%= f.label :author %>
<div class="input">
<%= f.text_field :author %>
</div>
</div>

<div class="clearfix">
<%= f.label :is_hidden %>
<div class="input">
<%= f.check_box :is_hidden %>
</div>
</div>

<div class="clearfix">
<%= f.label "Upload Background" %>
<div class="input">
<%= f.fields_for :media do |media| %>
<%= media.file_field :file %>
<% end %>
</div>
</div>
</fieldset>


<div class="actions">
Expand Down
55 changes: 48 additions & 7 deletions app/views/templates/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,50 @@
<section class="MS-frame">
<header>
<h1>Select Template Source:</h1>
</header>
<div class="MS-outer">
<article>

<ul class="MS">
<li>
<%= link_to new_template_path(:type=> "import") do %>
<%= image_tag("ph/ph.png", :alt => "") %>
<div class="content">
<h2><%= "Import" %></h2>
</div>
<% end %>
</li>
<li>
<%= link_to new_template_path(:type=> "create") do %>
<%= image_tag("ph/ph.png", :alt => "") %>
<div class="content">
<h2><%= "Create" %></h2>
</div>
<% end %>
</li>

<div class="clear"></div>
</ul>
</article>
</div>
</section>

<section class="C no">
<header id="browse-header">
<%= back_button :back %>
<h1>New Template</h1>
</header>
<div id="browse-body" class="C-cont">
<%= render 'form' %>
</div>
<header id="template-header">
<%= back_button "#", :back %>
<h1><%= (params[:type] || 'import').capitalize + " Template" %></h1>
</header>
<div class="C-cont">
<article>
<% if params[:type] == "create" %>
<%= render 'create_form' %>
<% else %>
<%= render 'import_form' %>
<% end %>

</article>
<aside>
</aside>
<div class="clear"></div>
</div>
</section>

0 comments on commit 566a7fe

Please sign in to comment.