Skip to content

Commit

Permalink
team management
Browse files Browse the repository at this point in the history
  • Loading branch information
ssayer committed Jan 25, 2012
1 parent db48c55 commit e99a490
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 33 deletions.
15 changes: 15 additions & 0 deletions app/assets/stylesheets/patients.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,21 @@
}
}

#teamDialog {

ol {
list-style-type: none;
}

td {
padding:10px;
}

a {
color: $linkcolor;
}
}



#patientcontainer, {
Expand Down
7 changes: 6 additions & 1 deletion app/assets/stylesheets/providers.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ form#providerForm {
padding-right: 25px;
padding-bottom: 20px;
}

a {
font-size:12px;
color: $linkcolor;
}
}

.paren {
Expand All @@ -39,7 +44,7 @@ table#providerList {
}

td {
padding-right:65px;
padding-right:110px;

a {
color :$linkcolor;
Expand Down
39 changes: 20 additions & 19 deletions app/controllers/teams_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,51 @@ class TeamsController < ApplicationController
load_resource except: %w{index}
authorize_resource
before_filter :authenticate_user!
before_filter :get_teams

def index
@teams = Team.alphabetical
end

def new
@team = Team.new
@providers = Provider.alphabetical
end

def edit
@providers = Provider.alphabetical
end

def create
@team = Team.create(params[:team])
if params[:provider_ids]
@providers = Provider.find(params[:provider_ids])
@team.providers.concat(@providers)

respond_to do |wants|
wants.html { redirect_to :action => "index" }
wants.js { render partial: "update_form"}
end

redirect_to :action => "index"
end

def update
@team.update_attributes(params[:team])
if params[:provider_ids]
providers = Provider.find(params[:provider_ids])
@team.providers.concat providers
@teams = Team.alphabetical

respond_to do |wants|
wants.html { redirect_to :action => "index" }
wants.js { render partial: "update_form"}
end
@team.save
redirect_to :action => "edit"

end

def destroy
@team.destroy
redirect_to :action => "index"

respond_to do |wants|
wants.html { redirect_to :action => "index" }
wants.js { render partial: "update_form"}
end
end



private
def find_model
@team = Team.find(params[:id])

def get_teams
@teams = Team.alphabetical
end

end
3 changes: 2 additions & 1 deletion app/views/providers/_edit_profile.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ provider:
</td>
<td>
<%= f.label :team_id, "select team:" %><br>
<%= f.collection_select :team_id, Team.alphabetical, :id, :name, {include_blank: true}, {style: "width:175px"}%>
<%= f.collection_select :team_id, Team.alphabetical, :id, :name, {include_blank: true}, {style: "width:175px"}%><br>
<%= link_to "edit teams", teams_path, remote: true %>
</td>
<td colspan="2">
<%= f.label :organization, "organization:" %><br>
Expand Down
7 changes: 1 addition & 6 deletions app/views/teams/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
<%= semantic_form_for @team do |f| %>
<%= f.buttons %>
<%= semantic_form_for @team, remote: true do |f| %>
<%= f.inputs :name %>
<% @providers.each do |pv| %>
<%= check_box_tag "provider_ids[]", pv.id, @team.providers.include?(pv), id: pv.id %>
<%= label_tag pv.id, pv.full_name %><br>
<% end %>
<%= f.buttons %>
<% end %>
5 changes: 5 additions & 0 deletions app/views/teams/_team.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<tr>
<td><%= team.name %></td>
<td><%= link_to "edit", edit_team_path(team), remote: true%></td>
<td><%= link_to "delete", team_path(team), method: 'delete', remote: true, confirm: "Are you sure you want to delete this team?" %></td>
</tr>
1 change: 1 addition & 0 deletions app/views/teams/_team_list.js.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$(".dialog").html("<%= escape_javascript( link_to 'add team', new_team_path, remote: true ) %>").prepend("<table id='teamTable'><%= render_js partial: 'team', collection: @teams %></table>").dialog({height: 600, width: 800, modal: true, title: "Teams"});
2 changes: 2 additions & 0 deletions app/views/teams/_update_form.js.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
$(".dialog").dialog("close")
$("select#provider_team_id").html('<%= escape_javascript(options_from_collection_for_select(@teams, :id, :name)) %>').prepend("<option selected='selected'></option>")
1 change: 1 addition & 0 deletions app/views/teams/edit.js.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$(".dialog").html("<%=render_js partial: 'form' %>");
10 changes: 4 additions & 6 deletions app/views/teams/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<ol>
<% @teams.each do |team| %>
<li><%= link_to team.name, edit_team_path(team) %></li>
<% end %>
</ol>
<%= link_to "create team", new_team_path%>
<table id='teamTable'>
<%= render partial: 'team', collection: @teams %>
</table>
<%= link_to "new team", new_team_path %>
6 changes: 6 additions & 0 deletions app/views/teams/index.js.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
if ($(".dialog").length == 0) {
$("body").append("<div id='teamDialog' class='dialog' />");
};

<%= render partial: 'team_list' %>

1 change: 1 addition & 0 deletions app/views/teams/new.js.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$(".dialog").html("<%=render_js partial: 'form' %>");

0 comments on commit e99a490

Please sign in to comment.