Class: EnumerationsController

Inherits:
ApplicationController show all
Includes:
CustomFieldsHelper
Defined in:
app/controllers/enumerations_controller.rb

Overview

– copyright ChiliProject is a project management system.

Copyright (C) 2010-2013 the ChiliProject Team

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

See doc/COPYRIGHT.rdoc for more details. ++

Instance Method Summary collapse

Methods included from CustomFieldsHelper

#custom_field_formats_for_select, #custom_field_label_tag, #custom_field_tag, #custom_field_tag_for_bulk_edit, #custom_field_tag_with_label, #custom_fields_tabs, #format_value, #render_api_custom_values, #show_value

Methods included from Redmine::MenuManager::MenuController

#current_menu_item, included, #menu_items, #redirect_to_project_menu_item

Methods included from Redmine::Search::Controller

#default_search_scope, #default_search_scopes, included

Methods included from Redmine::I18n

#current_language, #day_name, #find_language, #format_date, #format_time, included, #l, #l_hours, #l_or_humanize, #ll, #month_name, #set_language_if_valid, #valid_languages

Instance Method Details

#createObject


42
43
44
45
46
47
48
49
50
51
# File 'app/controllers/enumerations_controller.rb', line 42

def create
  @enumeration = Enumeration.new(params[:enumeration])
  @enumeration.type = params[:enumeration][:type]
  if @enumeration.save
    flash[:notice] = l(:notice_successful_create)
    redirect_to :action => 'list', :type => @enumeration.type
  else
    render :action => 'new'
  end
end

#destroyObject


68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'app/controllers/enumerations_controller.rb', line 68

def destroy
  @enumeration = Enumeration.find(params[:id])
  if !@enumeration.in_use?
    # No associated objects
    @enumeration.destroy
    redirect_to :action => 'index'
    return
  elsif params[:reassign_to_id]
    if reassign_to = @enumeration.class.find_by_id(params[:reassign_to_id])
      @enumeration.destroy(reassign_to)
      redirect_to :action => 'index'
      return
    end
  end
  @enumerations = @enumeration.class.find(:all) - [@enumeration]
#rescue
#  flash[:error] = 'Unable to delete enumeration'
#  redirect_to :action => 'index'
end

#editObject


53
54
55
# File 'app/controllers/enumerations_controller.rb', line 53

def edit
  @enumeration = Enumeration.find(params[:id])
end

#indexObject


22
23
24
25
# File 'app/controllers/enumerations_controller.rb', line 22

def index
  list
  render :action => 'list'
end

#listObject


31
32
# File 'app/controllers/enumerations_controller.rb', line 31

def list
end

#newObject


34
35
36
37
38
39
40
# File 'app/controllers/enumerations_controller.rb', line 34

def new
  begin
    @enumeration = params[:type].constantize.new
  rescue NameError
    @enumeration = Enumeration.new
  end
end

#updateObject


57
58
59
60
61
62
63
64
65
66
# File 'app/controllers/enumerations_controller.rb', line 57

def update
  @enumeration = Enumeration.find(params[:id])
  @enumeration.type = params[:enumeration][:type] if params[:enumeration][:type]
  if @enumeration.update_attributes(params[:enumeration])
    flash[:notice] = l(:notice_successful_update)
    redirect_to :action => 'list', :type => @enumeration.type
  else
    render :action => 'edit'
  end
end