Skip to content
Browse files

various cleanup and move show page to use form

  • Loading branch information...
1 parent 8d5cd5a commit f3dd25a0b0c83904c4768148c9fc940d25181d91 @blahed committed Nov 14, 2012
View
8 app/controllers/favorites_controller.rb
@@ -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
View
38 app/views/accounts/generic_accounts/_form.html.erb
@@ -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' %>
@@ -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>
View
6 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' %>
View
7 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' %>
+
View
22 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 %>
@@ -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' %>
View
35 app/views/accounts/web_accounts/_form.html.erb
@@ -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' %>
@@ -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>
View
6 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' %>
View
6 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' %>
View
25 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 %>
@@ -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' %>
View
37 app/views/notes/_form.html.erb
@@ -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>
View
6 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' %>
View
6 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' %>
View
6 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 %>
@@ -9,6 +9,4 @@
</h2>
</div>
-<div class="well">
- <%= @note.body %>
-</div>
+<%= render 'form' %>
View
36 app/views/software_licenses/_form.html.erb
@@ -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' %>
@@ -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>
View
6 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' %>
View
4 app/views/software_licenses/new.html.erb
@@ -2,6 +2,4 @@
<h2>Add a New License</h2>
</div>
-<div class="row">
- <%= render 'form' %>
-</div>
+<%= render 'form' %>
View
22 app/views/software_licenses/show.html.erb
@@ -1,4 +1,4 @@
-<div class='page-header'>
+<div class="page-header">
<h2>
<%= render 'shared/favorite', :item => @license %>
<%= @license.title %>
@@ -9,22 +9,4 @@
</h2>
</div>
-<dl>
- <dt>Title</dt>
- <dd><%= @license.title %></dd>
- <p></p>
- <dt>Key</dt>
- <dd><%= @license.license_key %></dd>
- <p></p>
- <dt>Licensed to</dt>
- <dd><%= @license.licensed_to %></dd>
- <p></p>
- <dt>Created</dt>
- <dd><%= fmt_datetime(@license.created_at) %></dd>
- <p></p>
- <dt>Updated</dt>
- <dd><%= fmt_datetime(@license.updated_at) %></dd>
- <p></p>
- <dt>Comments</dt>
- <dd><%= @license.comments %></dd>
-</dl>
+<%= render 'form' %>

0 comments on commit f3dd25a

Please sign in to comment.
Something went wrong with that request. Please try again.