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
|
||||
@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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
= 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")
|
||||
});
|
||||
})
|
|
@ -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'
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue