diff --git a/app/controllers/tasks_controller.rb b/app/controllers/tasks_controller.rb index ecd54d8d..2bf056c0 100644 --- a/app/controllers/tasks_controller.rb +++ b/app/controllers/tasks_controller.rb @@ -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 diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index e17fde3f..916b33f7 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -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 diff --git a/app/models/user.rb b/app/models/user.rb index 2675d0e8..0c4fc177 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -185,6 +185,10 @@ class User < ActiveRecord::Base end end + def token_attributes + {:id => id, :name => "#{nick} (#{ordergroup.try(:name)})"} + end + end # == Schema Information diff --git a/app/views/shared/_workgroup_members.haml b/app/views/shared/_workgroup_members.haml index b6410ec7..a09d6fbe 100644 --- a/app/views/shared/_workgroup_members.haml +++ b/app/views/shared/_workgroup_members.haml @@ -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)})" \ No newline at end of file diff --git a/app/views/tasks/_form.html.haml b/app/views/tasks/_form.html.haml index 032178d9..a92888f3 100644 --- a/app/views/tasks/_form.html.haml +++ b/app/views/tasks/_form.html.haml @@ -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 diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 185fecf3..fcf9a074 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -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