Some fixes for tasks.
This commit is contained in:
parent
03d84aed1d
commit
2e56bfe895
12 changed files with 53 additions and 87 deletions
|
@ -17,14 +17,8 @@ class TasksController < ApplicationController
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@task = Task.new(params[:task])
|
@task = Task.new(params[:task])
|
||||||
if @task.errors.empty?
|
if @task.save
|
||||||
@task.save
|
redirect_to tasks_url, :notice => "Aufgabe wurde erstellt"
|
||||||
flash[:notice] = "Aufgabe wurde erstellt"
|
|
||||||
if @task.workgroup
|
|
||||||
redirect_to :action => "workgroup", :id => @task.workgroup
|
|
||||||
else
|
|
||||||
redirect_to :action => "index"
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
render :template => "tasks/new"
|
render :template => "tasks/new"
|
||||||
end
|
end
|
||||||
|
@ -60,15 +54,6 @@ class TasksController < ApplicationController
|
||||||
redirect_to :action => "index"
|
redirect_to :action => "index"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Delete an given Assignment
|
|
||||||
# currently used in edit-view
|
|
||||||
def drop_assignment
|
|
||||||
ass = Assignment.find(params[:id])
|
|
||||||
task = ass.task
|
|
||||||
ass.destroy
|
|
||||||
redirect_to :action => "show", :id => task
|
|
||||||
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"
|
||||||
# if there is already an assignment, only accepted will be set to true
|
# if there is already an assignment, only accepted will be set to true
|
||||||
def accept
|
def accept
|
||||||
|
|
|
@ -1,10 +1,16 @@
|
||||||
module TasksHelper
|
module TasksHelper
|
||||||
|
|
||||||
|
def task_assignments(task)
|
||||||
|
task.assignments.map do |ass|
|
||||||
|
content_tag :span, ass.user.nick, :class => (ass.accepted? ? 'accepted' : 'unaccepted')
|
||||||
|
end.join(", ").html_safe
|
||||||
|
end
|
||||||
|
|
||||||
# generate colored number of still required users
|
# generate colored number of still required users
|
||||||
def highlighted_required_users(task)
|
def highlighted_required_users(task)
|
||||||
unless task.enough_users_assigned?
|
unless task.enough_users_assigned?
|
||||||
still_required = task.required_users - task.assignments.select { |ass| ass.accepted }.size
|
still_required = task.required_users - task.assignments.select { |ass| ass.accepted }.size
|
||||||
"<small style='color:red;font-weight:bold'>(#{still_required})</small>"
|
"<small style='color:red;font-weight:bold'>(#{still_required})</small>".html_safe
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,9 +9,10 @@ class Task < ActiveRecord::Base
|
||||||
|
|
||||||
# form will send user in string. responsibilities will added later
|
# form will send user in string. responsibilities will added later
|
||||||
attr_protected :users
|
attr_protected :users
|
||||||
|
|
||||||
validates_length_of :name, :minimum => 3
|
validates :name, :presence => true, :length => { :minimum => 3 }
|
||||||
validates_numericality_of :duration, :required_users, :only_integer => true, :greater_than => 1
|
validates :required_users, :presence => true
|
||||||
|
validates_numericality_of :duration, :required_users, :only_integer => true, :greater_than => 0
|
||||||
|
|
||||||
after_save :update_ordergroup_stats
|
after_save :update_ordergroup_stats
|
||||||
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
- @task.assignments.each do |ass|
|
|
||||||
= ass.user.nick
|
|
||||||
%small= link_to icon(:delete, :title => "#{ass.user.nick} entfernen"), |
|
|
||||||
{:action => "drop_assignment", :id => ass}, |
|
|
||||||
:confirm => 'Bist du sicher?', :method => "post" |
|
|
|
@ -1,36 +1,9 @@
|
||||||
= form.error_messages
|
= simple_form_for @task do |f|
|
||||||
= form.hidden_field :weekly
|
= f.input :name
|
||||||
%p
|
= f.input :description
|
||||||
%b Name
|
= f.input :duration, :as => :select, :collection => 1..3
|
||||||
%br/
|
= f.input :user_list, :as => :string
|
||||||
= form.text_field :name
|
= f.input :required_users
|
||||||
%p
|
= f.association :workgroup
|
||||||
%b Beschreibung
|
= f.input :due_date, :include_blank => true
|
||||||
%br/
|
= f.submit
|
||||||
= form.text_area :description, :cols => 50, :rows => 10
|
|
||||||
%p
|
|
||||||
%b Dauer
|
|
||||||
%small Wie lange dauert die Aufgabe, 1-3 Stunden
|
|
||||||
%br/
|
|
||||||
= form.select :duration, options_for_select(1..3, @task.duration)
|
|
||||||
%p
|
|
||||||
%b Verantwortliche
|
|
||||||
%small Aufgaben können mehrere Verantwortliche haben
|
|
||||||
/%br/
|
|
||||||
/= render :partial => "assignments"
|
|
||||||
%p
|
|
||||||
%small Benutze Kommas um mehrere Benutzerinnen zu trennen
|
|
||||||
%br/
|
|
||||||
= text_field_with_auto_complete :task, :user_list, {}, {:tokens => ","}
|
|
||||||
%p
|
|
||||||
%b Wieviel Benutzerinnen werden insgesamt benötigt?
|
|
||||||
%br/
|
|
||||||
= form.text_field :required_users, :size => 3
|
|
||||||
%p
|
|
||||||
%b Arbeitsgruppe
|
|
||||||
%br/
|
|
||||||
= form.select :workgroup_id, Workgroup.all(:order => 'name').collect {|g| [ g.name, g.id ] }, { :include_blank => true }
|
|
||||||
%p
|
|
||||||
%b Fälligkeit
|
|
||||||
%br/
|
|
||||||
= form.date_select :due_date, :start_year => 2007, :include_blank => true
|
|
|
@ -11,15 +11,7 @@
|
||||||
%td= format_date(task.due_date) unless task.due_date.nil?
|
%td= format_date(task.due_date) unless task.due_date.nil?
|
||||||
%td= link_to "#{task.name} (#{task.duration}h)", task_path(task)
|
%td= link_to "#{task.name} (#{task.duration}h)", task_path(task)
|
||||||
%td
|
%td
|
||||||
- unless task.users.empty?
|
= task_assignments task
|
||||||
- owner = Array.new
|
|
||||||
- task.assignments.each do |ass|
|
|
||||||
- if ass.accepted?
|
|
||||||
- nick = "<span class='accepted'>#{ass.user.nick.to_s}</span>"
|
|
||||||
- else
|
|
||||||
- nick = "<span class='unaccepted'>#{ass.user.nick.to_s} ?</span>"
|
|
||||||
- owner << nick
|
|
||||||
= owner.join(", ")
|
|
||||||
= highlighted_required_users task
|
= highlighted_required_users task
|
||||||
%td
|
%td
|
||||||
- unless task.is_accepted?(@current_user)
|
- unless task.is_accepted?(@current_user)
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
- title "Aufgabe bearbeiten"
|
- title "Aufgabe bearbeiten"
|
||||||
|
|
||||||
#form{:style => "float:left; width:39em"}
|
#form{:style => "float:left; width:39em"}
|
||||||
- form_for @task do |form|
|
= render('form')
|
||||||
= render :partial => 'form', :locals => {:form => form}
|
|
||||||
= submit_tag "Speichern"
|
|
||||||
|
|
|
||||||
= link_to "Abbrechen", :action => "show", :id => @task
|
|
||||||
#workgroup_members{:style => "padding-left:41em"}
|
#workgroup_members{:style => "padding-left:41em"}
|
||||||
%h3 Mitglieder der Gruppe
|
%h3 Mitglieder der Gruppe
|
||||||
#list
|
#list
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
- title "Neue Aufgabe erstellen"
|
- title "Neue Aufgabe erstellen"
|
||||||
|
|
||||||
#form{:style => "float:left; width:39em"}
|
#form{:style => "float:left; width:39em"}
|
||||||
- form_for @task do |form|
|
= render('form')
|
||||||
= render :partial => 'form', :locals => {:form => form}
|
|
||||||
= submit_tag "Aufgabe erstellen"
|
|
||||||
|
|
||||||
#workgroup_members{:style => "padding-left:41em"}
|
#workgroup_members{:style => "padding-left:41em"}
|
||||||
%h3 Mitglieder der Arbeitsgruppen
|
%h3 Mitglieder der Arbeitsgruppen
|
||||||
%i Klicke auf den Gruppennamen um die Mitglieder zu sehen
|
%i Klicke auf den Gruppennamen um die Mitglieder zu sehen
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
%td= @task.duration
|
%td= @task.duration
|
||||||
%tr
|
%tr
|
||||||
%td Verantwortliche Menschen
|
%td Verantwortliche Menschen
|
||||||
%td= render :partial => "assignments"
|
%td= task_assignments(@task)
|
||||||
%tr
|
%tr
|
||||||
%td Arbeitsgruppe
|
%td Arbeitsgruppe
|
||||||
%td
|
%td
|
||||||
|
|
|
@ -51,6 +51,7 @@ SimpleForm.setup do |config|
|
||||||
|
|
||||||
# How the label text should be generated altogether with the required text.
|
# How the label text should be generated altogether with the required text.
|
||||||
# config.label_text = lambda { |label, required| "#{required} #{label}" }
|
# config.label_text = lambda { |label, required| "#{required} #{label}" }
|
||||||
|
config.label_text = lambda { |label, required| "#{label}#{required}" }
|
||||||
|
|
||||||
# Whether attributes are required by default (or not). Default is true.
|
# Whether attributes are required by default (or not). Default is true.
|
||||||
# config.required_by_default = true
|
# config.required_by_default = true
|
||||||
|
|
|
@ -155,6 +155,7 @@ de:
|
||||||
user: Benutzerinnen
|
user: Benutzerinnen
|
||||||
workgroup: Arbeitsgruppe
|
workgroup: Arbeitsgruppe
|
||||||
ordergroup: Bestellgruppe
|
ordergroup: Bestellgruppe
|
||||||
|
task: Aufgabe
|
||||||
attributes:
|
attributes:
|
||||||
article:
|
article:
|
||||||
price: Nettopreis
|
price: Nettopreis
|
||||||
|
@ -169,6 +170,11 @@ de:
|
||||||
password: Passwort
|
password: Passwort
|
||||||
first_name: Vorname
|
first_name: Vorname
|
||||||
|
|
||||||
|
helpers:
|
||||||
|
submit:
|
||||||
|
create: "%{model} speichern"
|
||||||
|
update: "Änderungen speichern"
|
||||||
|
|
||||||
# Simple form i18n is used to build the forms
|
# Simple form i18n is used to build the forms
|
||||||
simple_form:
|
simple_form:
|
||||||
"yes": 'Ja'
|
"yes": 'Ja'
|
||||||
|
@ -191,4 +197,17 @@ de:
|
||||||
# email: 'E-mail.'
|
# email: 'E-mail.'
|
||||||
# hints:
|
# hints:
|
||||||
# username: 'User name to sign in.'
|
# username: 'User name to sign in.'
|
||||||
# password: 'No special characters, please.'
|
# password: 'No special characters, please.'
|
||||||
|
labels:
|
||||||
|
password: 'Passwort'
|
||||||
|
description: 'Beschreibung'
|
||||||
|
workgroup: 'Arbeitsgruppe'
|
||||||
|
task:
|
||||||
|
duration: 'Dauer'
|
||||||
|
user_list: 'Verantwortliche'
|
||||||
|
required_users: 'Anzahl'
|
||||||
|
due_date: 'Wann erledigen?'
|
||||||
|
hints:
|
||||||
|
task:
|
||||||
|
duration: 'Wie lange dauert die Aufgabe, 1-3 Stunden'
|
||||||
|
required_users: 'Wieviel Benutzerinnen werden insgesamt benötigt?'
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
.simple_form label {
|
.simple_form label {
|
||||||
float: left;
|
float: left;
|
||||||
width: 100px;
|
width: 120px;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
margin: 2px 10px;
|
margin: 2px 10px;
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.simple_form div.boolean, .simple_form input[type='submit'] {
|
.simple_form div.boolean, .simple_form input[type='submit'] {
|
||||||
margin-left: 120px;
|
margin-left: 140px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.simple_form div.boolean label, .simple_form label.collection_radio {
|
.simple_form div.boolean label, .simple_form label.collection_radio {
|
||||||
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
.simple_form .error {
|
.simple_form .error {
|
||||||
clear: left;
|
clear: left;
|
||||||
margin-left: 120px;
|
margin-left: 140px;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
color: #D00;
|
color: #D00;
|
||||||
display: block;
|
display: block;
|
||||||
|
@ -33,7 +33,7 @@
|
||||||
|
|
||||||
.simple_form .hint {
|
.simple_form .hint {
|
||||||
clear: left;
|
clear: left;
|
||||||
margin-left: 120px;
|
margin-left: 140px;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
color: #555;
|
color: #555;
|
||||||
display: block;
|
display: block;
|
||||||
|
|
Loading…
Reference in a new issue