Skip to content

Commit

Permalink
various cleanup and move show page to use form
Browse files Browse the repository at this point in the history
  • Loading branch information
trvsdnn committed Nov 14, 2012
1 parent 8d5cd5a commit f3dd25a
Show file tree
Hide file tree
Showing 17 changed files with 112 additions and 164 deletions.
8 changes: 6 additions & 2 deletions app/controllers/favorites_controller.rb
Expand Up @@ -21,9 +21,13 @@ def create

def destroy
@item = get_item

current_user.defavorite!(@item)
redirect_to favorites_path, :notice => "#{@item.title} removed from favorites"

if params[:item_type] =~ /Account\z/
redirect_to [ :accounts, @item ], :notice => "#{@item.title} removed from favorites"
else
redirect_to @item, :notice => "#{@item.title} removed from favorites"
end
end

private
Expand Down
38 changes: 22 additions & 16 deletions app/views/accounts/generic_accounts/_form.html.erb
Expand Up @@ -2,8 +2,10 @@

<div class="span8">
<%= form_for [ :accounts, @account ] do |f| %>
<%= f.label :title %>
<%= f.text_field :title, :class => 'span7' %>
<% if controller.action_name != 'show' %>
<%= f.label :title %>
<%= f.text_field :title, :class => 'span7' %>
<% end %>
<%= f.label :username %>
<%= f.text_field :username, :class => 'span7' %>
Expand All @@ -13,20 +15,24 @@
<%= f.label :comments %>
<%= f.text_area :comments, :class => 'span8', :rows => 6 %>
<% if controller.action_name != 'show' %>
<fieldset>
<legend>Groups</legend>
<br />
<%= hidden_field_tag "generic_account[group_ids][]", nil%>
<% @allowed_groups.each do |group| %>
<label class="checkbox inline">
<%= check_box_tag 'generic_account[group_ids][]', group.id, @account.groups.include?(group) %>
<%= group.name %>
</label>
<% end %>
</fieldset>


<fieldset>
<legend>Groups</legend>
<br />
<%= hidden_field_tag "generic_account[group_ids][]", nil%>
<% @allowed_groups.each do |group| %>
<label class="checkbox inline">
<%= check_box_tag 'generic_account[group_ids][]', group.id, @account.groups.include?(group) %>
<%= group.name %>
</label>
<% end %>
</fieldset>

<hr />
<button type="submit" class="btn"><%= @account.new_record? ? 'Create' : 'Update' %> Account</button>
<hr />
<button type="submit" class="btn"><%= @account.new_record? ? 'Create' : 'Update' %> Account</button>
<% end %>
<% end %>
</div>
6 changes: 2 additions & 4 deletions app/views/accounts/generic_accounts/edit.html.erb
@@ -1,7 +1,5 @@
<div class="page-header">
<h2>Edit <%= @account.title %></h2>
<h2>Edit &ldquo;<%= @account.title %>&rdquo;</h2>
</div>

<div class="row">
<%= render 'form' %>
</div>
<%= render 'form' %>
7 changes: 3 additions & 4 deletions app/views/accounts/generic_accounts/new.html.erb
@@ -1,7 +1,6 @@
<div class="page-header">
<h2>New Group</h2>
<h2>Add a New Generic Account</h2>
</div>

<div class="row">
<%= render 'form' %>
</div>
<%= render 'form' %>

22 changes: 2 additions & 20 deletions app/views/accounts/generic_accounts/show.html.erb
@@ -1,4 +1,4 @@
<div class='page-header'>
<div class="page-header">
<h2>
<%= render 'shared/favorite', :item => @account %>
<%= @account.title %>
Expand All @@ -9,22 +9,4 @@
</h2>
</div>

<dl>
<dt>Title</dt>
<dd><%= @account.title %></dd>
<p></p>
<dt>Username</dt>
<dd><%= @account.username %></dd>
<p></p>
<dt>Password</dt>
<dd><%= @account.password %></dd>
<p></p>
<dt>Created</dt>
<dd><%= fmt_datetime(@account.created_at) %></dd>
<p></p>
<dt>Updated</dt>
<dd><%= fmt_datetime(@account.updated_at) %></dd>
<p></p>
<dt>Comments</dt>
<dd><%= @account.comments %></dd>
</dl>
<%= render 'form' %>
35 changes: 20 additions & 15 deletions app/views/accounts/web_accounts/_form.html.erb
Expand Up @@ -2,8 +2,10 @@

<div class="span8">
<%= form_for [ :accounts, @account ] do |f| %>
<%= f.label :title %>
<%= f.text_field :title, :class => 'span7' %>
<% if controller.action_name != 'show' %>
<%= f.label :title %>
<%= f.text_field :title, :class => 'span7' %>
<% end %>
<%= f.label :url %>
<%= f.text_field :url, :class => 'span7' %>
Expand All @@ -16,20 +18,23 @@
<%= f.label :comments %>
<%= f.text_area :comments, :class => 'span8', :rows => 6 %>
<% if controller.action_name != 'show' %>
<fieldset>
<legend>Groups</legend>
<br />
<%= hidden_field_tag "web_account[group_ids][]", nil%>
<% @allowed_groups.each do |group| %>
<label class="checkbox inline">
<%= check_box_tag 'web_account[group_ids][]', group.id, @account.groups.include?(group) %>
<%= group.name %>
</label>
<% end %>
</fieldset>

<fieldset>
<legend>Groups</legend>
<br />
<%= hidden_field_tag "web_account[group_ids][]", nil%>
<% @allowed_groups.each do |group| %>
<label class="checkbox inline">
<%= check_box_tag 'web_account[group_ids][]', group.id, @account.groups.include?(group) %>
<%= group.name %>
</label>
<% end %>
</fieldset>
<hr />
<button type="submit" class="btn"><%= @account.new_record? ? 'Create' : 'Update' %> Account</button>
<% end %>
<hr />
<button type="submit" class="btn"><%= @account.new_record? ? 'Create' : 'Update' %> Account</button>
<% end %>
</div>
6 changes: 2 additions & 4 deletions app/views/accounts/web_accounts/edit.html.erb
@@ -1,7 +1,5 @@
<div class="page-header">
<h2>Edit <%= @account.title %></h2>
<h2>Edit &ldquo;<%= @account.title %>&rdquo;</h2>
</div>

<div class="row">
<%= render 'form' %>
</div>
<%= render 'form' %>
6 changes: 2 additions & 4 deletions app/views/accounts/web_accounts/new.html.erb
@@ -1,7 +1,5 @@
<div class="page-header">
<h2>Add a new Account</h2>
<h2>Add a New Web Account</h2>
</div>

<div class="row">
<%= render 'form' %>
</div>
<%= render 'form' %>
25 changes: 2 additions & 23 deletions app/views/accounts/web_accounts/show.html.erb
@@ -1,4 +1,4 @@
<div class='page-header'>
<div class="page-header">
<h2>
<%= render 'shared/favorite', :item => @account %>
<%= @account.title %>
Expand All @@ -9,25 +9,4 @@
</h2>
</div>

<dl>
<dt>Title</dt>
<dd><%= @account.title %></dd>
<p></p>
<dt>URL</dt>
<dd><%= @account.url %></dd>
<p></p>
<dt>Username</dt>
<dd><%= @account.username %></dd>
<p></p>
<dt>Password</dt>
<dd><%= @account.password %></dd>
<p></p>
<dt>Created</dt>
<dd><%= fmt_datetime(@account.created_at) %></dd>
<p></p>
<dt>Updated</dt>
<dd><%= fmt_datetime(@account.updated_at) %></dd>
<p></p>
<dt>Comments</dt>
<dd><%= @account.comments %></dd>
</dl>
<%= render 'form' %>
37 changes: 20 additions & 17 deletions app/views/notes/_form.html.erb
Expand Up @@ -2,26 +2,29 @@

<div class="span8">
<%= form_for @note do |f| %>
<%= f.label :title %>
<%= f.text_field :title, :class => 'span7' %>
<% if controller.action_name != 'show' %>
<%= f.label :title %>
<%= f.text_field :title, :class => 'span7' %>
<% end %>
<%= f.label :body %>
<%= f.text_area :body, :class => 'span8', :rows => 10 %>
<% if controller.action_name != 'show' %>
<fieldset>
<legend>Groups</legend>
<br />
<%= hidden_field_tag "note[group_ids][]", nil%>
<% @allowed_groups.each do |group| %>
<label class="checkbox inline">
<%= check_box_tag 'note[group_ids][]', group.id, @note.groups.include?(group) %>
<%= group.name %>
</label>
<% end %>
</fieldset>

<fieldset>
<legend>Groups</legend>
<br />
<%= hidden_field_tag "note[group_ids][]", nil%>
<% @allowed_groups.each do |group| %>
<label class="checkbox inline">
<%= check_box_tag 'note[group_ids][]', group.id, @note.groups.include?(group) %>
<%= group.name %>
</label>
<% end %>
</fieldset>

<hr />
<button type="submit" class="btn"><%= @note.new_record? ? 'Create' : 'Update' %> Note</button>
<hr />
<button type="submit" class="btn"><%= @note.new_record? ? 'Create' : 'Update' %> Note</button>
<% end %>
<% end %>
</div>
6 changes: 2 additions & 4 deletions app/views/notes/edit.html.erb
@@ -1,7 +1,5 @@
<div class="page-header">
<h2>Edit <%= @note.title %></h2>
<h2>Edit &ldquo;<%= @note.title %>&rdquo;</h2>
</div>

<div class="row">
<%= render 'form' %>
</div>
<%= render 'form' %>
6 changes: 2 additions & 4 deletions app/views/notes/new.html.erb
@@ -1,7 +1,5 @@
<div class="page-header">
<h2>Add a new Note</h2>
<h2>Add a New Note</h2>
</div>

<div class="row">
<%= render 'form' %>
</div>
<%= render 'form' %>
6 changes: 2 additions & 4 deletions app/views/notes/show.html.erb
@@ -1,4 +1,4 @@
<div class='page-header'>
<div class="page-header">
<h2>
<%= render 'shared/favorite', :item => @note %>
<%= @note.title %>
Expand All @@ -9,6 +9,4 @@
</h2>
</div>

<div class="well">
<%= @note.body %>
</div>
<%= render 'form' %>
36 changes: 20 additions & 16 deletions app/views/software_licenses/_form.html.erb
Expand Up @@ -2,8 +2,10 @@

<div class="span8">
<%= form_for @license do |f| %>
<%= f.label :title %>
<%= f.text_field :title, :class => 'span7' %>
<% if controller.action_name != 'show' %>
<%= f.label :title %>
<%= f.text_field :title, :class => 'span7' %>
<% end %>
<%= f.label :license_key %>
<%= f.text_field :license_key, :class => 'span7' %>
Expand All @@ -13,20 +15,22 @@
<%= f.label :comments %>
<%= f.text_area :comments, :class => 'span8', :rows => 6 %>
<% if controller.action_name != 'show' %>
<fieldset>
<legend>Groups</legend>
<br />
<%= hidden_field_tag "software_license[group_ids][]", nil%>
<% @allowed_groups.each do |group| %>
<label class="checkbox inline">
<%= check_box_tag 'software_license[group_ids][]', group.id, @license.groups.include?(group) %>
<%= group.name %>
</label>
<% end %>
</fieldset>

<fieldset>
<legend>Groups</legend>
<br />
<%= hidden_field_tag "software_license[group_ids][]", nil%>
<% @allowed_groups.each do |group| %>
<label class="checkbox inline">
<%= check_box_tag 'software_license[group_ids][]', group.id, @license.groups.include?(group) %>
<%= group.name %>
</label>
<% end %>
</fieldset>

<hr/>
<button type="submit" class="btn"><%= @license.new_record? ? 'Create' : 'Update' %> License</button>
<hr/>
<button type="submit" class="btn"><%= @license.new_record? ? 'Create' : 'Update' %> License</button>
<% end %>
<% end %>
</div>
6 changes: 2 additions & 4 deletions app/views/software_licenses/edit.html.erb
@@ -1,7 +1,5 @@
<div class="page-header">
<h2>Edit <%= @license.title %></h2>
<h2>Edit &ldquo;<%= @license.title %>&rdquo;</h2>
</div>

<div class="row">
<%= render 'form' %>
</div>
<%= render 'form' %>
4 changes: 1 addition & 3 deletions app/views/software_licenses/new.html.erb
Expand Up @@ -2,6 +2,4 @@
<h2>Add a New License</h2>
</div>

<div class="row">
<%= render 'form' %>
</div>
<%= render 'form' %>

0 comments on commit f3dd25a

Please sign in to comment.