Class: Admin::FieldGroupsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/admin/field_groups_controller.rb

Overview

Copyright © 2008-2013 Michael Dvorkin and contributors.

Fat Free CRM is freely distributable under the terms of MIT license. See MIT-LICENSE file or www.opensource.org/licenses/mit-license.php


Instance Method Summary collapse

Instance Method Details

#confirmObject

GET /admin/field_groups/1/confirm AJAX




75
76
77
# File 'app/controllers/admin/field_groups_controller.rb', line 75

def confirm
  @field_group = FieldGroup.find(params[:id])
end

#createObject

POST /admin/field_groups POST /admin/field_groups.xml AJAX




34
35
36
37
38
# File 'app/controllers/admin/field_groups_controller.rb', line 34

def create
  @field_group = FieldGroup.create(params[:field_group])

  respond_with(@field_group)
end

#destroyObject

DELETE /admin/field_groups/1 DELETE /admin/field_groups/1.xml AJAX




53
54
55
56
57
58
# File 'app/controllers/admin/field_groups_controller.rb', line 53

def destroy
  @field_group = FieldGroup.find(params[:id])
  @field_group.destroy

  respond_with(@field_group)
end

#editObject

GET /admin/field_groups/1/edit AJAX




21
22
23
24
25
26
27
28
29
# File 'app/controllers/admin/field_groups_controller.rb', line 21

def edit
  @field_group = FieldGroup.find(params[:id])

  if params[:previous].to_s =~ /(\d+)\z/
    @previous = FieldGroup.find_by_id($1) || $1.to_i
  end

  respond_with(@field_group)
end

#newObject

GET /admin/field_groups/new GET /admin/field_groups/new.xml AJAX




13
14
15
16
17
# File 'app/controllers/admin/field_groups_controller.rb', line 13

def new
  @field_group = FieldGroup.new(:klass_name => params[:klass_name])

  respond_with(@field_group)
end

#sortObject

POST /admin/field_groups/sort




62
63
64
65
66
67
68
69
70
71
# File 'app/controllers/admin/field_groups_controller.rb', line 62

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

#updateObject

PUT /admin/field_groups/1 PUT /admin/field_groups/1.xml AJAX




43
44
45
46
47
48
# File 'app/controllers/admin/field_groups_controller.rb', line 43

def update
  @field_group = FieldGroup.find(params[:id])
  @field_group.update_attributes(params[:field_group])

  respond_with(@field_group)
end