Fixed and refactored foodcoop/workgroups.
This commit is contained in:
parent
c87ead8da9
commit
06f2cc2007
6 changed files with 54 additions and 23 deletions
|
@ -14,13 +14,9 @@ class Foodcoop::WorkgroupsController < ApplicationController
|
||||||
def update
|
def update
|
||||||
@workgroup = Workgroup.find(params[:id])
|
@workgroup = Workgroup.find(params[:id])
|
||||||
if @workgroup.update_attributes(params[:workgroup])
|
if @workgroup.update_attributes(params[:workgroup])
|
||||||
flash[:notice] = "Arbeitsgruppe wurde aktualisiert"
|
redirect_to foodcoop_workgroups_url, :notice => "Arbeitsgruppe wurde aktualisiert"
|
||||||
redirect_to foodcoop_workgroups_url
|
|
||||||
else
|
else
|
||||||
render :action => 'edit'
|
render :action => 'edit'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def memberships
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,6 +10,8 @@ class Group < ActiveRecord::Base
|
||||||
|
|
||||||
before_destroy :check_last_admin_group
|
before_destroy :check_last_admin_group
|
||||||
|
|
||||||
|
attr_reader :user_tokens
|
||||||
|
|
||||||
# Returns true if the given user if is an member of this group.
|
# Returns true if the given user if is an member of this group.
|
||||||
def member?(user)
|
def member?(user)
|
||||||
memberships.find_by_user_id(user.id)
|
memberships.find_by_user_id(user.id)
|
||||||
|
@ -20,6 +22,10 @@ class Group < ActiveRecord::Base
|
||||||
User.all(:order => 'nick').reject { |u| users.include?(u) }
|
User.all(:order => 'nick').reject { |u| users.include?(u) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def user_tokens=(ids)
|
||||||
|
self.user_ids = ids.split(",")
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
# Check before destroy a group, if this is the last group with admin role
|
# Check before destroy a group, if this is the last group with admin role
|
||||||
|
|
|
@ -10,5 +10,3 @@
|
||||||
- if workgroup.member?(@current_user)
|
- if workgroup.member?(@current_user)
|
||||||
|
|
|
|
||||||
= link_to "Gruppe bearbeiten", edit_foodcoop_workgroup_path(workgroup)
|
= link_to "Gruppe bearbeiten", edit_foodcoop_workgroup_path(workgroup)
|
||||||
|
|
|
||||||
= link_to "Mitglieder bearbeiten", memberships_foodcoop_workgroup_path(workgroup)
|
|
||||||
|
|
|
@ -1,16 +1,41 @@
|
||||||
- title "Gruppe bearbeiten"
|
- title "Gruppe bearbeiten"
|
||||||
|
|
||||||
%p
|
= simple_form_for [:foodcoop, @workgroup] do |f|
|
||||||
%i
|
= f.input :name
|
||||||
Mitglieder kannst du
|
= f.input :description
|
||||||
= link_to "hier", :action => "memberships", :id => @workgroup
|
|
||||||
hinzufügen.
|
|
||||||
|
|
||||||
.edit_form{:style => "width:35em"}
|
= f.input :weekly_task
|
||||||
- form_for [:foodcoop, @workgroup] do |@form|
|
= f.input :weekday, :as => :select, :collection => Workgroup.weekdays, :input_html => {:class => 'weekly_option'}
|
||||||
= render :partial => "shared/group_form"
|
= 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"}
|
= f.input :user_tokens, :as => :string, :input_html => { 'data-pre' => @workgroup.users.map { |u| u.token_attributes }.to_json }
|
||||||
= submit_tag 'Speichern'
|
|
||||||
|
|
= f.submit
|
||||||
= link_to "Abbrechen", foodcoop_workgroups_path
|
= 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")
|
||||||
|
});
|
||||||
|
})
|
|
@ -201,12 +201,20 @@ de:
|
||||||
labels:
|
labels:
|
||||||
password: 'Passwort'
|
password: 'Passwort'
|
||||||
description: 'Beschreibung'
|
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:
|
task:
|
||||||
duration: 'Dauer'
|
duration: 'Dauer'
|
||||||
user_list: 'Verantwortliche'
|
user_list: 'Verantwortliche'
|
||||||
required_users: 'Anzahl'
|
required_users: 'Anzahl'
|
||||||
due_date: 'Wann erledigen?'
|
due_date: 'Wann erledigen?'
|
||||||
|
workgroup: 'Arbeitsgruppe'
|
||||||
hints:
|
hints:
|
||||||
task:
|
task:
|
||||||
duration: 'Wie lange dauert die Aufgabe, 1-3 Stunden'
|
duration: 'Wie lange dauert die Aufgabe, 1-3 Stunden'
|
||||||
|
|
|
@ -72,9 +72,7 @@ Foodsoft::Application.routes.draw do
|
||||||
|
|
||||||
resources :ordergroups, :only => [:index]
|
resources :ordergroups, :only => [:index]
|
||||||
|
|
||||||
resources :workgroups, :only => [:index, :edit, :update] do
|
resources :workgroups, :only => [:index, :edit, :update]
|
||||||
get :memberships, :on => :member
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
########### Article management
|
########### Article management
|
||||||
|
|
Loading…
Reference in a new issue