Class: Admin::FieldsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Admin::FieldsController
- Defined in:
- app/controllers/admin/fields_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
-
#create ⇒ Object
POST /fields POST /fields.xml AJAX —————————————————————————-.
-
#destroy ⇒ Object
DELETE /fields/1 DELETE /fields/1.xml HTML and AJAX —————————————————————————-.
-
#edit ⇒ Object
GET /fields/1/edit AJAX —————————————————————————-.
-
#index ⇒ Object
GET /fields GET /fields.xml HTML —————————————————————————-.
-
#new ⇒ Object
GET /fields/new GET /fields/new.xml AJAX —————————————————————————-.
-
#show ⇒ Object
GET /fields/1 GET /fields/1.xml HTML —————————————————————————-.
-
#sort ⇒ Object
POST /fields/sort —————————————————————————-.
-
#update ⇒ Object
PUT /fields/1 PUT /fields/1.xml AJAX —————————————————————————-.
Instance Method Details
#create ⇒ Object
POST /fields POST /fields.xml AJAX
60 61 62 63 64 |
# File 'app/controllers/admin/fields_controller.rb', line 60 def create @field = CustomField.create(params[:field]) respond_with(@field) end |
#destroy ⇒ Object
DELETE /fields/1 DELETE /fields/1.xml HTML and AJAX
79 80 81 82 83 84 |
# File 'app/controllers/admin/fields_controller.rb', line 79 def destroy @field = CustomField.find(params[:id]) @field.destroy respond_with(@field) end |
#edit ⇒ Object
GET /fields/1/edit AJAX
47 48 49 50 51 52 53 54 55 |
# File 'app/controllers/admin/fields_controller.rb', line 47 def edit @field = Field.find(params[:id]) if params[:previous].to_s =~ /(\d+)\z/ @previous = Field.find_by_id($1) || $1.to_i end respond_with(@field) end |
#index ⇒ Object
GET /fields GET /fields.xml HTML
26 27 |
# File 'app/controllers/admin/fields_controller.rb', line 26 def index end |
#new ⇒ Object
GET /fields/new GET /fields/new.xml AJAX
39 40 41 42 43 |
# File 'app/controllers/admin/fields_controller.rb', line 39 def new @field = CustomField.new(:field_group_id => params[:field_group_id]) respond_with(@custom_field) end |
#show ⇒ Object
GET /fields/1 GET /fields/1.xml HTML
32 33 34 |
# File 'app/controllers/admin/fields_controller.rb', line 32 def show respond_with(@field) end |
#sort ⇒ Object
POST /fields/sort
88 89 90 91 92 93 94 95 96 97 |
# File 'app/controllers/admin/fields_controller.rb', line 88 def sort field_group_id = params[:field_group_id].to_i field_ids = params["fields_field_group_#{field_group_id}"] || [] field_ids.each_with_index do |id, index| Field.update_all({:position => index+1, :field_group_id => field_group_id}, {:id => id}) end render :nothing => true end |
#update ⇒ Object
PUT /fields/1 PUT /fields/1.xml AJAX
69 70 71 72 73 74 |
# File 'app/controllers/admin/fields_controller.rb', line 69 def update @field = Field.find(params[:id]) @field.update_attributes(params[:field]) respond_with(@field) end |