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
|
||||
@task = Task.new(params[:task])
|
||||
if @task.errors.empty?
|
||||
@task.save
|
||||
flash[:notice] = "Aufgabe wurde erstellt"
|
||||
if @task.workgroup
|
||||
redirect_to :action => "workgroup", :id => @task.workgroup
|
||||
else
|
||||
redirect_to :action => "index"
|
||||
end
|
||||
if @task.save
|
||||
redirect_to tasks_url, :notice => "Aufgabe wurde erstellt"
|
||||
else
|
||||
render :template => "tasks/new"
|
||||
end
|
||||
|
@ -60,15 +54,6 @@ class TasksController < ApplicationController
|
|||
redirect_to :action => "index"
|
||||
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"
|
||||
# if there is already an assignment, only accepted will be set to true
|
||||
def accept
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
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
|
||||
def highlighted_required_users(task)
|
||||
unless task.enough_users_assigned?
|
||||
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
|
||||
|
|
|
@ -9,9 +9,10 @@ class Task < ActiveRecord::Base
|
|||
|
||||
# form will send user in string. responsibilities will added later
|
||||
attr_protected :users
|
||||
|
||||
validates_length_of :name, :minimum => 3
|
||||
validates_numericality_of :duration, :required_users, :only_integer => true, :greater_than => 1
|
||||
|
||||
validates :name, :presence => true, :length => { :minimum => 3 }
|
||||
validates :required_users, :presence => true
|
||||
validates_numericality_of :duration, :required_users, :only_integer => true, :greater_than => 0
|
||||
|
||||
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
|
||||
= form.hidden_field :weekly
|
||||
%p
|
||||
%b Name
|
||||
%br/
|
||||
= form.text_field :name
|
||||
%p
|
||||
%b Beschreibung
|
||||
%br/
|
||||
= 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
|
||||
= simple_form_for @task do |f|
|
||||
= f.input :name
|
||||
= f.input :description
|
||||
= f.input :duration, :as => :select, :collection => 1..3
|
||||
= f.input :user_list, :as => :string
|
||||
= f.input :required_users
|
||||
= f.association :workgroup
|
||||
= f.input :due_date, :include_blank => true
|
||||
= f.submit
|
|
@ -11,15 +11,7 @@
|
|||
%td= format_date(task.due_date) unless task.due_date.nil?
|
||||
%td= link_to "#{task.name} (#{task.duration}h)", task_path(task)
|
||||
%td
|
||||
- unless task.users.empty?
|
||||
- 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(", ")
|
||||
= task_assignments task
|
||||
= highlighted_required_users task
|
||||
%td
|
||||
- unless task.is_accepted?(@current_user)
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
- title "Aufgabe bearbeiten"
|
||||
|
||||
#form{:style => "float:left; width:39em"}
|
||||
- form_for @task do |form|
|
||||
= render :partial => 'form', :locals => {:form => form}
|
||||
= submit_tag "Speichern"
|
||||
|
|
||||
= link_to "Abbrechen", :action => "show", :id => @task
|
||||
= render('form')
|
||||
#workgroup_members{:style => "padding-left:41em"}
|
||||
%h3 Mitglieder der Gruppe
|
||||
#list
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
- title "Neue Aufgabe erstellen"
|
||||
|
||||
#form{:style => "float:left; width:39em"}
|
||||
- form_for @task do |form|
|
||||
= render :partial => 'form', :locals => {:form => form}
|
||||
= submit_tag "Aufgabe erstellen"
|
||||
|
||||
= render('form')
|
||||
|
||||
#workgroup_members{:style => "padding-left:41em"}
|
||||
%h3 Mitglieder der Arbeitsgruppen
|
||||
%i Klicke auf den Gruppennamen um die Mitglieder zu sehen
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
%td= @task.duration
|
||||
%tr
|
||||
%td Verantwortliche Menschen
|
||||
%td= render :partial => "assignments"
|
||||
%td= task_assignments(@task)
|
||||
%tr
|
||||
%td Arbeitsgruppe
|
||||
%td
|
||||
|
|
|
@ -51,6 +51,7 @@ SimpleForm.setup do |config|
|
|||
|
||||
# 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| "#{label}#{required}" }
|
||||
|
||||
# Whether attributes are required by default (or not). Default is true.
|
||||
# config.required_by_default = true
|
||||
|
|
|
@ -155,6 +155,7 @@ de:
|
|||
user: Benutzerinnen
|
||||
workgroup: Arbeitsgruppe
|
||||
ordergroup: Bestellgruppe
|
||||
task: Aufgabe
|
||||
attributes:
|
||||
article:
|
||||
price: Nettopreis
|
||||
|
@ -169,6 +170,11 @@ de:
|
|||
password: Passwort
|
||||
first_name: Vorname
|
||||
|
||||
helpers:
|
||||
submit:
|
||||
create: "%{model} speichern"
|
||||
update: "Änderungen speichern"
|
||||
|
||||
# Simple form i18n is used to build the forms
|
||||
simple_form:
|
||||
"yes": 'Ja'
|
||||
|
@ -191,4 +197,17 @@ de:
|
|||
# email: 'E-mail.'
|
||||
# hints:
|
||||
# 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 {
|
||||
float: left;
|
||||
width: 100px;
|
||||
width: 120px;
|
||||
text-align: right;
|
||||
margin: 2px 10px;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
|||
}
|
||||
|
||||
.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 {
|
||||
|
@ -25,7 +25,7 @@
|
|||
|
||||
.simple_form .error {
|
||||
clear: left;
|
||||
margin-left: 120px;
|
||||
margin-left: 140px;
|
||||
font-size: 12px;
|
||||
color: #D00;
|
||||
display: block;
|
||||
|
@ -33,7 +33,7 @@
|
|||
|
||||
.simple_form .hint {
|
||||
clear: left;
|
||||
margin-left: 120px;
|
||||
margin-left: 140px;
|
||||
font-size: 12px;
|
||||
color: #555;
|
||||
display: block;
|
||||
|
|
Loading…
Reference in a new issue