Class: EntitiesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/entities_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

Methods inherited from ApplicationController

#auto_complete

Instance Method Details

#attachObject

Common attach handler for all core controllers.




23
24
25
26
27
28
29
# File 'app/controllers/entities_controller.rb', line 23

def attach
  @attachment = find_class(params[:assets]).find(params[:asset_id])
  @attached = entity.attach!(@attachment)
  entity.reload

  respond_with(entity)
end

#contactsObject

GET /entities/contacts AJAX




65
66
# File 'app/controllers/entities_controller.rb', line 65

def contacts
end

#discardObject

Common discard handler for all core controllers.




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

def discard
  @attachment = find_class(params[:attachment]).find(params[:attachment_id])
  entity.discard!(@attachment)
  entity.reload

  respond_with(entity)
end

#field_groupObject




84
85
86
87
88
89
90
91
92
# File 'app/controllers/entities_controller.rb', line 84

def field_group
  if @tag = Tag.find_by_name(params[:tag].strip)
    if @field_group = FieldGroup.find_by_tag_id_and_klass_name(@tag.id, klass.to_s)
      @asset = klass.find_by_id(params[:asset_id]) || klass.new
      render('fields/group') && return
    end
  end
  render plain: ''
end

#leadsObject

GET /entities/leads AJAX




70
71
# File 'app/controllers/entities_controller.rb', line 70

def leads
end

#opportunitiesObject

GET /entities/opportunities AJAX




75
76
# File 'app/controllers/entities_controller.rb', line 75

def opportunities
end

#subscribeObject

Common subscribe handler for all core controllers.




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

def subscribe
  entity.subscribed_users += [current_user.id]
  entity.save

  respond_with(@entity) do |format|
    format.js { render 'subscription_update', entity: entity }
  end
end

#unsubscribeObject

Common unsubscribe handler for all core controllers.




54
55
56
57
58
59
60
61
# File 'app/controllers/entities_controller.rb', line 54

def unsubscribe
  entity.subscribed_users -= [current_user.id]
  entity.save

  respond_with(entity) do |format|
    format.js { render 'subscription_update', entity: entity }
  end
end

#versionsObject

GET /entities/versions AJAX




80
81
# File 'app/controllers/entities_controller.rb', line 80

def versions
end