Some fixes for task module.

This commit is contained in:
benni 2011-05-15 22:06:54 +02:00
parent a4f71bd672
commit 6c98c7c755
6 changed files with 24 additions and 15 deletions

View File

@ -50,8 +50,7 @@ class TasksController < ApplicationController
def destroy
Task.find(params[:id]).destroy
flash[:notice] = "Aufgabe wurde gelöscht"
redirect_to :action => "index"
redirect_to tasks_url, :notice => "Aufgabe wurde gelöscht"
end
# assign current_user to the task and set the assignment to "accepted"
@ -63,8 +62,7 @@ class TasksController < ApplicationController
else
task.assignments.create(:user => current_user, :accepted => true)
end
flash[:notice] = "Du hast die Aufgabe übernommen"
redirect_to user_tasks_path
redirect_to user_tasks_path, :notice => "Du hast die Aufgabe übernommen"
end
# deletes assignment between current_user and given task
@ -75,8 +73,7 @@ class TasksController < ApplicationController
def update_status
Task.find(params[:id]).update_attribute("done", params[:task][:done])
flash[:notice] = "Aufgabenstatus wurde aktualisiert"
redirect_to :action => "index"
redirect_to tasks_url, :notice => "Aufgabenstatus wurde aktualisiert"
end
# Shows all tasks, which are already done
@ -88,8 +85,7 @@ class TasksController < ApplicationController
def workgroup
@group = Group.find(params[:id])
if @group.is_a? Ordergroup
flash[:error] = "Keine Arbeitsgruppe gefunden"
redirect_to :action => "index"
redirect_to tasks_url, :alert => "Keine Arbeitsgruppe gefunden"
end
end

View File

@ -4,7 +4,7 @@ class UsersController < ApplicationController
def index
@users = User.where("nick LIKE ?", "%#{params[:q]}%")
respond_to do |format|
format.json { render :json => @users.map { |u| {:id => u.id, :name => u.nick} } }
format.json { render :json => @users.map { |u| u.token_attributes } }
end
end

View File

@ -185,6 +185,10 @@ class User < ActiveRecord::Base
end
end
def token_attributes
{:id => id, :name => "#{nick} (#{ordergroup.try(:name)})"}
end
end
# == Schema Information

View File

@ -1,6 +1,6 @@
- for group in Group.find :all, :conditions => "type != 'Ordergroup'"
%h4= link_to_function group.name, "Element.toggle('workgroup_#{group.id}')"
%ul{:style => "display:none"}[group]
- for user in group.users.find :all, :order => "nick"
%li= user.nick + " (#{user.ordergroup.name if user.ordergroup})"
- for workgroup in Workgroup.all
%h4= link_to workgroup.name, "#", 'data-toggle_this' => "#workgroup_#{workgroup.id}"
%ul{:style => "display:none"}[workgroup]
- for user in workgroup.users.order("nick")
%li= "#{user.nick} (#{user.ordergroup.try(:name)})"

View File

@ -11,7 +11,7 @@
= f.input :name
= f.input :description
= f.input :duration, :as => :select, :collection => 1..3
= f.input :user_list, :as => :string, :input_html => { 'data-pre' => @task.users.map { |u| {:id => u.id, :name => u.nick} }.to_json }
= f.input :user_list, :as => :string, :input_html => { 'data-pre' => @task.users.map { |u| u.token_attributes }.to_json }
= f.input :required_users
= f.association :workgroup
= f.input :due_date, :include_blank => true

View File

@ -1,3 +1,12 @@
// Load following statements, when DOM is ready
$(function() {
$('a[data-toggle_this]').click(function() {
$($(this).data('toggle_this')).toggle();
return false;
});
});
// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults