blob: 0cb789857e50b04f4b62e57cb44a3c7a02214cae (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
class GuiFunctionsController < ApplicationController
load_resource :gui_function
before_filter :load_user_groups
before_filter :spread_breadcrumbs
def index
@gui_functions = GuiFunction.order(:category, :name)
end
def show
@gui_function = GuiFunction.find(params[:id])
end
def new
@gui_function = GuiFunction.new
@user_groups.each do |user_group|
if @gui_function.user_groups.where(:id => user_group.id).count == 0
@gui_function.gui_function_memberships.build(:user_group_id => user_group.id, :activated => true)
end
end
end
def create
@gui_function = GuiFunction.new(params[:gui_function])
if @gui_function.save
redirect_to @gui_function, :notice => t('gui_functions.controller.successfuly_created')
else
render :new
end
end
def edit
@gui_function = GuiFunction.find(params[:id])
@user_groups.each do |user_group|
if @gui_function.user_groups.where(:id => user_group.id).count == 0
@gui_function.gui_function_memberships.build(:user_group_id => user_group.id, :activated => true)
end
end
end
def update
@gui_function = GuiFunction.find(params[:id])
if @gui_function.update_attributes(params[:gui_function])
redirect_to @gui_function, :notice => t('gui_functions.controller.successfuly_updated')
else
render :edit
end
end
def destroy
@gui_function = GuiFunction.find(params[:id])
@gui_function.destroy
redirect_to gui_functions_url, :notice => t('gui_functions.controller.successfuly_destroyed')
end
private
def load_user_groups
@user_groups = Tenant.find(@current_user.current_tenant).user_groups.order(:position)
end
def spread_breadcrumbs
add_breadcrumb t("gui_functions.index.page_title"), gui_functions_path
if @gui_function && !@gui_function.new_record?
add_breadcrumb @gui_function, gui_function_path(@gui_function)
end
end
end
|