Some fixes for task module.
This commit is contained in:
parent
a4f71bd672
commit
6c98c7c755
6 changed files with 24 additions and 15 deletions
|
@ -50,8 +50,7 @@ class TasksController < ApplicationController
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
Task.find(params[:id]).destroy
|
Task.find(params[:id]).destroy
|
||||||
flash[:notice] = "Aufgabe wurde gelöscht"
|
redirect_to tasks_url, :notice => "Aufgabe wurde gelöscht"
|
||||||
redirect_to :action => "index"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# assign current_user to the task and set the assignment to "accepted"
|
# assign current_user to the task and set the assignment to "accepted"
|
||||||
|
@ -63,8 +62,7 @@ class TasksController < ApplicationController
|
||||||
else
|
else
|
||||||
task.assignments.create(:user => current_user, :accepted => true)
|
task.assignments.create(:user => current_user, :accepted => true)
|
||||||
end
|
end
|
||||||
flash[:notice] = "Du hast die Aufgabe übernommen"
|
redirect_to user_tasks_path, :notice => "Du hast die Aufgabe übernommen"
|
||||||
redirect_to user_tasks_path
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# deletes assignment between current_user and given task
|
# deletes assignment between current_user and given task
|
||||||
|
@ -75,8 +73,7 @@ class TasksController < ApplicationController
|
||||||
|
|
||||||
def update_status
|
def update_status
|
||||||
Task.find(params[:id]).update_attribute("done", params[:task][:done])
|
Task.find(params[:id]).update_attribute("done", params[:task][:done])
|
||||||
flash[:notice] = "Aufgabenstatus wurde aktualisiert"
|
redirect_to tasks_url, :notice => "Aufgabenstatus wurde aktualisiert"
|
||||||
redirect_to :action => "index"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Shows all tasks, which are already done
|
# Shows all tasks, which are already done
|
||||||
|
@ -88,8 +85,7 @@ class TasksController < ApplicationController
|
||||||
def workgroup
|
def workgroup
|
||||||
@group = Group.find(params[:id])
|
@group = Group.find(params[:id])
|
||||||
if @group.is_a? Ordergroup
|
if @group.is_a? Ordergroup
|
||||||
flash[:error] = "Keine Arbeitsgruppe gefunden"
|
redirect_to tasks_url, :alert => "Keine Arbeitsgruppe gefunden"
|
||||||
redirect_to :action => "index"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ class UsersController < ApplicationController
|
||||||
def index
|
def index
|
||||||
@users = User.where("nick LIKE ?", "%#{params[:q]}%")
|
@users = User.where("nick LIKE ?", "%#{params[:q]}%")
|
||||||
respond_to do |format|
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -185,6 +185,10 @@ class User < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def token_attributes
|
||||||
|
{:id => id, :name => "#{nick} (#{ordergroup.try(:name)})"}
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
- for group in Group.find :all, :conditions => "type != 'Ordergroup'"
|
- for workgroup in Workgroup.all
|
||||||
%h4= link_to_function group.name, "Element.toggle('workgroup_#{group.id}')"
|
%h4= link_to workgroup.name, "#", 'data-toggle_this' => "#workgroup_#{workgroup.id}"
|
||||||
%ul{:style => "display:none"}[group]
|
%ul{:style => "display:none"}[workgroup]
|
||||||
- for user in group.users.find :all, :order => "nick"
|
- for user in workgroup.users.order("nick")
|
||||||
%li= user.nick + " (#{user.ordergroup.name if user.ordergroup})"
|
%li= "#{user.nick} (#{user.ordergroup.try(:name)})"
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
= f.input :name
|
= f.input :name
|
||||||
= f.input :description
|
= f.input :description
|
||||||
= f.input :duration, :as => :select, :collection => 1..3
|
= 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.input :required_users
|
||||||
= f.association :workgroup
|
= f.association :workgroup
|
||||||
= f.input :due_date, :include_blank => true
|
= f.input :due_date, :include_blank => true
|
||||||
|
|
|
@ -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
|
// Place your application-specific JavaScript functions and classes here
|
||||||
// This file is automatically included by javascript_include_tag :defaults
|
// This file is automatically included by javascript_include_tag :defaults
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue