Class: Admin::FieldGroupsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Admin::FieldGroupsController
- Defined in:
- app/controllers/admin/field_groups_controller.rb
Overview
Fat Free CRM Copyright © 2008-2011 by Michael Dvorkin
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see <www.gnu.org/licenses/>.
Instance Method Summary collapse
-
#confirm ⇒ Object
GET /admin/field_groups/1/confirm AJAX —————————————————————————-.
-
#create ⇒ Object
POST /admin/field_groups POST /admin/field_groups.xml AJAX —————————————————————————-.
-
#destroy ⇒ Object
DELETE /admin/field_groups/1 DELETE /admin/field_groups/1.xml AJAX —————————————————————————-.
-
#edit ⇒ Object
GET /admin/field_groups/1/edit AJAX —————————————————————————-.
-
#new ⇒ Object
GET /admin/field_groups/new GET /admin/field_groups/new.xml AJAX —————————————————————————-.
-
#sort ⇒ Object
POST /admin/field_groups/sort —————————————————————————-.
-
#update ⇒ Object
PUT /admin/field_groups/1 PUT /admin/field_groups/1.xml AJAX —————————————————————————-.
Instance Method Details
#confirm ⇒ Object
GET /admin/field_groups/1/confirm AJAX
121 122 123 124 125 126 |
# File 'app/controllers/admin/field_groups_controller.rb', line 121 def confirm @field_group = FieldGroup.find(params[:id]) rescue ActiveRecord::RecordNotFound respond_to_not_found(:js, :xml) end |
#create ⇒ Object
POST /admin/field_groups POST /admin/field_groups.xml AJAX
53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/controllers/admin/field_groups_controller.rb', line 53 def create @field_group = FieldGroup.new(params[:field_group]) respond_to do |format| if @field_group.save format.js # create.js.rjs format.xml { render :xml => @field_group, :status => :created, :location => @field_group } else format.js # create.js.rjs format.xml { render :xml => @field_group.errors, :status => :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /admin/field_groups/1 DELETE /admin/field_groups/1.xml AJAX
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'app/controllers/admin/field_groups_controller.rb', line 90 def destroy @field_group = FieldGroup.find(params[:id]) respond_to do |format| if @field_group.destroy # Redirect to fields index format.js { render(:destroy) { |page| page.redirect_to admin_fields_url } } format.xml { head :ok } else flash[:warning] = t(:msg_cant_delete_field_group, @field_group.name) format.js # destroy.js.rjs format.xml { render :xml => @field_group.errors, :status => :unprocessable_entity } end end end |
#edit ⇒ Object
GET /admin/field_groups/1/edit AJAX
38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/controllers/admin/field_groups_controller.rb', line 38 def edit @field_group = FieldGroup.find(params[:id]) if params[:previous].to_s =~ /(\d+)\z/ @previous = FieldGroup.find($1) end rescue ActiveRecord::RecordNotFound @previous ||= $1.to_i respond_to_not_found(:js) end |
#new ⇒ Object
GET /admin/field_groups/new GET /admin/field_groups/new.xml AJAX
24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/controllers/admin/field_groups_controller.rb', line 24 def new @field_group = FieldGroup.new(:klass_name => params[:klass_name]) respond_to do |format| format.js # new.js.rjs format.xml { render :xml => @field_group } end rescue ActiveRecord::RecordNotFound respond_to_not_found(:html, :xml) end |
#sort ⇒ Object
POST /admin/field_groups/sort
108 109 110 111 112 113 114 115 116 117 |
# File 'app/controllers/admin/field_groups_controller.rb', line 108 def sort asset = params[:asset] field_group_ids = params["#{asset}_field_groups"] field_group_ids.each_with_index do |id, index| FieldGroup.update_all({:position => index+1}, {:id => id}) end render :nothing => true end |
#update ⇒ Object
PUT /admin/field_groups/1 PUT /admin/field_groups/1.xml AJAX
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'app/controllers/admin/field_groups_controller.rb', line 70 def update @field_group = FieldGroup.find(params[:id]) respond_to do |format| if @field_group.update_attributes(params[:field_group]) format.js format.xml { head :ok } else format.js format.xml { render :xml => @field_group.errors, :status => :unprocessable_entity } end end rescue ActiveRecord::RecordNotFound respond_to_not_found(:js, :xml) end |