Class: InboxItems::InboxItemsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/inbox_items/inbox_items_controller.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject



27
28
29
30
31
# File 'app/controllers/inbox_items/inbox_items_controller.rb', line 27

def destroy
	@inbox_item = current_user.inbox_items.find(params[:id])
	@inbox_item.destroy
	redirect_to inbox_items_path, notice: t(:inbox_item_was_removed)
end

#editObject



8
9
10
11
12
13
14
15
16
# File 'app/controllers/inbox_items/inbox_items_controller.rb', line 8

def edit
	@inbox_item = current_user.inbox_items.find(params[:id])
	@inbox_item.mark_as_read! if @inbox_item.may_mark_as_read?
	@inbox_item.convert = true unless @inbox_item.converted?
	@inbox_item.log_type = 'lab_notes'
	@inbox_item.date = @inbox_item.created_at.to_date
	@projects = current_user.projects.not_archived.not_deleted.all.collect { |p| [p.project_name, p.id] }
	@inbox_item.project_id = @projects.first[1] if @projects.count == 1
end

#file_redirectObject



33
34
35
36
37
# File 'app/controllers/inbox_items/inbox_items_controller.rb', line 33

def file_redirect
	@inbox_item = current_user.inbox_items.find(params[:id])
	@file_upload = @inbox_item.file_uploads.find(params[:file_upload_id])
	redirect_to @file_upload.public_url if @file_upload.url.present?
end

#indexObject



4
5
6
# File 'app/controllers/inbox_items/inbox_items_controller.rb', line 4

def index
	@inbox_items = current_user.inbox_items.order(id: :desc).unconverted.all
end

#updateObject



18
19
20
21
22
23
24
25
# File 'app/controllers/inbox_items/inbox_items_controller.rb', line 18

def update
	@inbox_item = current_user.inbox_items.find(params[:id])
	
	if @inbox_item.update_attributes(item_params)
		@inbox_item.convert_to_log_item! if item_params[:convert] == '1'
		redirect_to inbox_items_path, notice: 'Updated'
	end
end