diff --git a/app/controllers/foodcoop/workgroups_controller.rb b/app/controllers/foodcoop/workgroups_controller.rb index 8bbd88ae..947bc9ed 100644 --- a/app/controllers/foodcoop/workgroups_controller.rb +++ b/app/controllers/foodcoop/workgroups_controller.rb @@ -14,13 +14,9 @@ class Foodcoop::WorkgroupsController < ApplicationController def update @workgroup = Workgroup.find(params[:id]) if @workgroup.update_attributes(params[:workgroup]) - flash[:notice] = "Arbeitsgruppe wurde aktualisiert" - redirect_to foodcoop_workgroups_url + redirect_to foodcoop_workgroups_url, :notice => "Arbeitsgruppe wurde aktualisiert" else render :action => 'edit' end end - - def memberships - end end diff --git a/app/models/group.rb b/app/models/group.rb index fc197d3f..79aa299b 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -9,6 +9,8 @@ class Group < ActiveRecord::Base validate :last_admin_on_earth, :on => :update before_destroy :check_last_admin_group + + attr_reader :user_tokens # Returns true if the given user if is an member of this group. def member?(user) @@ -20,6 +22,10 @@ class Group < ActiveRecord::Base User.all(:order => 'nick').reject { |u| users.include?(u) } end + def user_tokens=(ids) + self.user_ids = ids.split(",") + end + protected # Check before destroy a group, if this is the last group with admin role diff --git a/app/views/foodcoop/workgroups/_workgroup.html.haml b/app/views/foodcoop/workgroups/_workgroup.html.haml index ead035b7..d117fbd7 100644 --- a/app/views/foodcoop/workgroups/_workgroup.html.haml +++ b/app/views/foodcoop/workgroups/_workgroup.html.haml @@ -10,5 +10,3 @@ - if workgroup.member?(@current_user) | = link_to "Gruppe bearbeiten", edit_foodcoop_workgroup_path(workgroup) - | - = link_to "Mitglieder bearbeiten", memberships_foodcoop_workgroup_path(workgroup) diff --git a/app/views/foodcoop/workgroups/edit.html.haml b/app/views/foodcoop/workgroups/edit.html.haml index 556bb6e2..04558f35 100644 --- a/app/views/foodcoop/workgroups/edit.html.haml +++ b/app/views/foodcoop/workgroups/edit.html.haml @@ -1,16 +1,41 @@ - title "Gruppe bearbeiten" -%p - %i - Mitglieder kannst du - = link_to "hier", :action => "memberships", :id => @workgroup - hinzufügen. += simple_form_for [:foodcoop, @workgroup] do |f| + = f.input :name + = f.input :description -.edit_form{:style => "width:35em"} - - form_for [:foodcoop, @workgroup] do |@form| - = render :partial => "shared/group_form" + = f.input :weekly_task + = f.input :weekday, :as => :select, :collection => Workgroup.weekdays, :input_html => {:class => 'weekly_option'} + = f.input :task_name, :input_html => {:class => 'weekly_option'} + = f.input :task_required_users, :input_html => {:class => 'weekly_option'} + = f.input :task_duration, :input_html => {:class => 'weekly_option'} + = f.input :task_description, :input_html => {:class => 'weekly_option'} - %p{:style => "clear:both"} - = submit_tag 'Speichern' - | - = link_to "Abbrechen", foodcoop_workgroups_path \ No newline at end of file + = f.input :user_tokens, :as => :string, :input_html => { 'data-pre' => @workgroup.users.map { |u| u.token_attributes }.to_json } + + = f.submit + = link_to "oder abbrechen", foodcoop_workgroups_path + +- content_for :head do + :javascript + function toggleWeeklyTask() { + $('.weekly_option').each(function() { + if ($("#workgroup_weekly_task").is(':checked')) { + $(this).removeAttr('disabled'); + } else { + $(this).attr('disabled', 'disabled'); + } + }); + } + + $(function() { + toggleWeeklyTask(); + $('#workgroup_weekly_task').click(function() { + toggleWeeklyTask(); + }) + + $("#workgroup_user_tokens").tokenInput("#{users_path(:format => :json)}", { + crossDomain: false, + prePopulate: $("#workgroup_user_tokens").data("pre") + }); + }) \ No newline at end of file diff --git a/config/locales/de.yml b/config/locales/de.yml index 5c339f1f..f9fc3414 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -201,12 +201,20 @@ de: labels: password: 'Passwort' description: 'Beschreibung' - workgroup: 'Arbeitsgruppe' + workgroup: + weekly_task: 'Monatlichen Job definieren?' + weekday: 'Wochentag' + task_name: 'Name für Job' + task_required_users: 'Benötige Verantwortliche' + task_duration: 'Vor. Dauer in Stunden' + task_description: 'Beschreibung' + user_tokens: 'Mitglieder' task: duration: 'Dauer' user_list: 'Verantwortliche' required_users: 'Anzahl' due_date: 'Wann erledigen?' + workgroup: 'Arbeitsgruppe' hints: task: duration: 'Wie lange dauert die Aufgabe, 1-3 Stunden' diff --git a/config/routes.rb b/config/routes.rb index 3994aaaa..86aef29b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -72,9 +72,7 @@ Foodsoft::Application.routes.draw do resources :ordergroups, :only => [:index] - resources :workgroups, :only => [:index, :edit, :update] do - get :memberships, :on => :member - end + resources :workgroups, :only => [:index, :edit, :update] end ########### Article management