Skip to content

Commit

Permalink
UI to update characters, first draft
Browse files Browse the repository at this point in the history
  • Loading branch information
kelsin committed Dec 27, 2010
1 parent e87d7e4 commit 8864f30
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
7 changes: 6 additions & 1 deletion app/controllers/characters_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ def edit

def update
if @current_account.admin || @current_account == @account
@character = Character.update(params[:id], params[:character])
if params[:armory_update] == 'true'
@character = Character.find(params[:id])
@character.update_from_armory!
else
@character = Character.update(params[:id], params[:character])
end
end

respond_to do |format|
Expand Down
4 changes: 3 additions & 1 deletion app/views/characters/_character.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<p id="<%=dom_id(character)%>_edit_link">
<%= link_to("Edit", edit_account_character_url(character.account, character),
:onclick => "$.get('#{edit_account_character_url(character.account, character)}', {}, null, 'script'); return false;") %>
| <%= link_to_remote("Update from Armory", :url => account_character_path(character.account, character, :armory_update => true),
:method => :put, :loading => "$('#character_#{character.id}_edit_link').html('Loading...');") %>
<% if character.raids.empty? %>
| <span id="<%=dom_id(character)%>_delete_link">
<%= link_to("Delete", account_character_url(character.account, character),
Expand All @@ -30,7 +32,7 @@
<ul>
<% character.loots.each do |loot| -%>
<li>
<%= link_to loot.item_name, loot.item_url, :class => 'loot' %>
<%= link_to loot.item_name, loot.item_url, :class => 'loot' %>
<%= link_to(loot.location.raid.name, raid_url(loot.location.raid), :class => 'tiny') %>
</li>
<% end -%>
Expand Down
11 changes: 1 addition & 10 deletions app/views/characters/_form.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,7 @@
<dl>
<dt>Name:</dt>
<dd><%= f.text_field :name %></dd>
<dt>Level:</dt>
<dd><%= f.text_field :level, :size => 5 %></dd>
<dt>Guild:</dt>
<dd><%= f.text_field :guild %></dd>
<% if character.new_record? %>
<dt>Race:</dt>
<dd><%= f.collection_select(:race_id, Race.find(:all), :id, :name) %></dd>
<dt>Class:</dt>
<dd><%= f.collection_select(:cclass_id, Cclass.find(:all), :id, :name) %></dd>
<% else %>
<% unless character.new_record? %>
<dt>Inactive:</dt>
<dd>
<%= f.check_box :inactive %>
Expand Down

0 comments on commit 8864f30

Please sign in to comment.