Class: Spina::Admin::PhotosController
Instance Method Summary
collapse
#current_admin_path
#current_account, #error_explanation!, #image_tag_with_at2x, #link_to_add_fields, #markdown
Instance Method Details
#create ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
|
# File 'app/controllers/spina/admin/photos_controller.rb', line 16
def create
@photo = Photo.create!(photo_params)
respond_to do |format|
format.js do
render params[:media_library] ? :create : :create_and_select
end
format.json do
render json: { file_url: @photo.file_url }
end
end
end
|
#destroy ⇒ Object
28
29
30
31
32
|
# File 'app/controllers/spina/admin/photos_controller.rb', line 28
def destroy
@photo = Photo.find(params[:id])
@photo.destroy
redirect_to spina.admin_photos_url
end
|
#enhance ⇒ Object
34
35
36
37
38
|
# File 'app/controllers/spina/admin/photos_controller.rb', line 34
def enhance
@photo = Photo.find(params[:id])
@photo.remote_file_url = params[:new_image]
@photo.save
end
|
#index ⇒ Object
10
11
12
13
14
|
# File 'app/controllers/spina/admin/photos_controller.rb', line 10
def index
add_breadcrumb I18n.t('spina.website.photos'), spina.admin_photos_path
@photos = Photo.sorted.page(params[:page])
@photo = Photo.new
end
|
#insert_photo ⇒ Object
70
71
72
|
# File 'app/controllers/spina/admin/photos_controller.rb', line 70
def insert_photo
@photo = Photo.find(params[:photo_id]) if params[:photo_id].present?
end
|
#insert_photo_collection ⇒ Object
74
75
76
|
# File 'app/controllers/spina/admin/photos_controller.rb', line 74
def insert_photo_collection
@photos = Photo.find(params[:photo_ids]) if params[:photo_ids].present?
end
|
#link ⇒ Object
40
41
42
|
# File 'app/controllers/spina/admin/photos_controller.rb', line 40
def link
@photo = Photo.find(params[:id])
end
|
#photo_collection_select ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'app/controllers/spina/admin/photos_controller.rb', line 57
def photo_collection_select
selected = params[:selected_photo_ids] || Array.new
@photos = Photo.order_by_ids(selected).sorted.page(params[:page])
@selected_photos = Photo.where(id: selected)
@photo = Photo.new
if params[:page].present?
render :multi_picker_infinite_scroll
else
render :photo_collection_select
end
end
|
#photo_select ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'app/controllers/spina/admin/photos_controller.rb', line 44
def photo_select
selected = params[:selected_photo_id] || Array.new
@photos = Photo.order_by_ids(selected).sorted.page(params[:page])
@selected_photo = Photo.find(selected)
@photo = Photo.new
if params[:page].present?
render :single_picker_infinite_scroll
else
render :photo_select
end
end
|
#wysihtml5_insert ⇒ Object
78
79
80
|
# File 'app/controllers/spina/admin/photos_controller.rb', line 78
def wysihtml5_insert
@photo = Photo.find(params[:photo_id])
end
|
#wysihtml5_select ⇒ Object
82
83
84
85
86
87
88
89
90
91
|
# File 'app/controllers/spina/admin/photos_controller.rb', line 82
def wysihtml5_select
@photos = Photo.sorted.page(params[:page])
@photo = Photo.new
if params[:page].present?
render :wysihtml5_infinite_scroll
else
render :wysihtml5_select
end
end
|