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.




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

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




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

def contacts
end

#discardObject

Common discard handler for all core controllers.




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

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

  respond_with(entity)
end

#field_groupObject




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

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




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

def leads
end

#opportunitiesObject

GET /entities/opportunities AJAX




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

def opportunities
end

#subscribeObject

Common subscribe handler for all core controllers.




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

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.




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

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




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

def versions
end