Permalink
Browse files

Intermediate commit.

  • Loading branch information...
mark-d-holmberg committed Apr 5, 2012
1 parent 4f7a2e2 commit 4acd9e6210504c5d3b030402adf442c4391fbfca
@@ -23,3 +23,7 @@ jQuery ->
$("div#foo ul li.hide").click (event) ->
$("div#foo").animate
width: 'toggle'
+
+ $("div#foo ul li.remote a").click (event) ->
+ $.getScript(this.href);
+ return false;
@@ -19,6 +19,10 @@
margin: 0 auto;
margin-top: 1em;
margin-bottom: 1em;
+ position: absolute;
+ bottom: 0;
+ left: 25%;
+ z-index: 99999;
}
form#new_survey {
@@ -45,6 +45,8 @@ section {
}
&#user-flyout {
background-color: orange;
+ border: 1px solid black;
+ border-left: none;
width: 20px;
height: 35em;
padding: 0;
@@ -65,6 +67,9 @@ div {
padding: 0;
margin: 0;
position: absolute;
+ display: none;
+ border: 1px solid black;
+ border-left: none;
&li {
list-style-type: none;
position: relative;
@@ -1,5 +1,6 @@
class UsersController < ApplicationController
load_and_authorize_resource
+ skip_load_resource :only => :destroy
#SPEC: 2.1 Student Column
#SPEC: 2.1.1 List all students(users)
@@ -36,6 +37,10 @@ def show
#SPEC: 2.1.3 Add a new User(student)
def new
+ respond_to do |format|
+ format.html # index.html.erb
+ format.js { render :new, :layout => false }
+ end
end
def create
@@ -101,9 +106,13 @@ def update_my_details
#SPEC: 2.1.4 Delete a User(student)
def destroy
- authorize! :destroy, User, :id => current_user.id
+ authorize! :destroy, User
+ @user = User.find(params[:id])
@user.destroy
- redirect_to users_url
+ respond_to do |format|
+ format.html
+ format.js { flash[:notice] = "User Destroyed" }
+ end
end
def search
@@ -12,7 +12,7 @@
<section id="user-flyout">
<div id="foo">
<ul>
- <li><%= link_to "New", new_user_path %></li>
+ <li class="remote"><%= link_to "New", new_user_path, :remote => true %></li>
<li><%= link_to "Search", user_search_path %></li>
<li class="hide"><<</li>
</ul>
@@ -1,4 +1,4 @@
-<%= form_for(@user) do |f| %>
+<%= form_for(@user, :remote => remote) do |f| %>
<%= render "shared/error_messages", :target => @user %>
<div class="field">
<%= f.label :name %><br />
@@ -0,0 +1,3 @@
+<%= title "New User" %>
+<%= markdown "###{yield(:title)}" %>
+<%= render :partial => "form", :locals => { :remote => true } %>
@@ -2,5 +2,8 @@
<% @student.each do |student| %>
<%= student.name.inspect %><br />
<%= student.email.inspect %>
+ <% if can? :destroy, student %>
+ <%= link_to "Destroy", student, :class => "delete", confirm: 'Are you sure?', method: :delete, :remote => true %>
+ <% end %>
<% end %>
</div>
@@ -0,0 +1,2 @@
+$("#result").empty();
+$("li.ui-selected").remove();
@@ -0,0 +1 @@
+$("#result").html('<%= escape_javascript(render('users/new_remote')) %>');

0 comments on commit 4acd9e6

Please sign in to comment.