adminpanel 2.6.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/adminpanel.gemspec +6 -6
- data/app/assets/images/adminpanel/magnifier.png +0 -0
- data/app/assets/javascripts/adminpanel/bootstrap-data-confirm.coffee.erb +142 -0
- data/app/assets/javascripts/adminpanel/dom-filter.coffee +15 -0
- data/app/assets/javascripts/adminpanel/dropzone.js +1728 -0
- data/app/assets/javascripts/adminpanel/filter-side-menu.coffee +4 -0
- data/app/assets/javascripts/adminpanel/gallery.js.coffee.erb +79 -0
- data/app/assets/javascripts/adminpanel/realm.js +0 -3
- data/app/assets/stylesheets/adminpanel/_search-input.scss.erb +11 -0
- data/app/assets/stylesheets/adminpanel/bootstrap.css.erb +1 -1
- data/app/assets/stylesheets/adminpanel/dropzone.css +515 -0
- data/app/assets/stylesheets/adminpanel/theme.css.scss.erb +1 -1
- data/app/controllers/adminpanel/analytics_controller.rb +7 -51
- data/app/controllers/adminpanel/application_controller.rb +1 -0
- data/app/controllers/adminpanel/roles_controller.rb +4 -1
- data/app/controllers/adminpanel/sections_controller.rb +1 -7
- data/app/controllers/concerns/adminpanel/facebook_actions.rb +3 -0
- data/app/controllers/concerns/adminpanel/gallery_actions.rb +31 -0
- data/app/controllers/concerns/adminpanel/rest_actions.rb +4 -1
- data/app/helpers/adminpanel/analytics_helper.rb +8 -18
- data/app/helpers/adminpanel/application_helper.rb +10 -2
- data/app/helpers/adminpanel/router_helper.rb +6 -2
- data/app/helpers/adminpanel/shared_pages_helper.rb +5 -3
- data/app/models/adminpanel/analytic.rb +4 -0
- data/app/models/adminpanel/image.rb +31 -0
- data/app/models/adminpanel/sectionfile.rb +1 -3
- data/app/models/concerns/adminpanel/base.rb +51 -7
- data/app/models/concerns/adminpanel/sortable_gallery.rb +12 -17
- data/app/views/adminpanel/analytics/_header.html.erb +1 -1
- data/app/views/adminpanel/form/_adminpanel_file_field.html.erb +27 -23
- data/app/views/adminpanel/icons/_delete.html.erb +1 -0
- data/app/views/adminpanel/sections/edit.html.erb +1 -12
- data/app/views/adminpanel/shared/_form_fields.html.erb +1 -0
- data/app/views/adminpanel/templates/destroy.js.erb +3 -0
- data/app/views/adminpanel/templates/index.html.erb +4 -4
- data/app/views/adminpanel/templates/show.html.erb +57 -52
- data/app/views/layouts/adminpanel/_side_menu.html.erb +18 -3
- data/config/initializers/adminpanel/assets.rb +4 -0
- data/config/locales/en.yml +24 -9
- data/config/locales/es.yml +18 -33
- data/config/routes.rb +10 -5
- data/lib/adminpanel/version.rb +1 -1
- data/lib/generators/adminpanel/gallery/gallery_generator.rb +0 -8
- data/lib/generators/adminpanel/gallery/templates/gallery_template.rb +7 -18
- data/lib/generators/adminpanel/gallery/templates/uploader.rb +1 -1
- data/lib/generators/adminpanel/initialize/templates/create_adminpanel_tables.rb +9 -5
- data/lib/generators/adminpanel/resource/resource_generator.rb +12 -16
- data/lib/generators/adminpanel/resource/resource_generator_helper.rb +23 -16
- data/test/dummy/.gitignore +2 -2
- data/test/dummy/app/controllers/adminpanel/products_controller.rb +1 -1
- data/test/dummy/app/models/adminpanel/galleryfile.rb +1 -13
- data/test/dummy/app/models/adminpanel/photo.rb +2 -9
- data/test/dummy/app/models/adminpanel/product.rb +1 -0
- data/test/dummy/config/initializers/carrierwave.rb +5 -0
- data/test/dummy/db/schema.rb +10 -18
- data/test/dummy/test/fixtures/adminpanel/galleries.yml +3 -3
- data/test/dummy/test/fixtures/adminpanel/images.yml +60 -0
- data/test/dummy/test/fixtures/adminpanel/products.yml +2 -2
- data/test/dummy/test/fixtures/{dog fries.png → attachments/dog-fries.png} +0 -0
- data/test/dummy/test/fixtures/attachments/hipster.jpg +0 -0
- data/test/dummy/test/fixtures/attachments/thumb_hipster.jpg +0 -0
- data/test/features/shared/form/belongs_to_remote_test.rb +1 -4
- data/test/features/shared/form/resource_field_test.rb +1 -1
- data/test/features/shared/resource/edit_test.rb +2 -5
- data/test/features/shared/resource/new_test.rb +5 -2
- data/test/features/shared/ui/dropzone_element_generation_test.rb +27 -0
- data/test/features/shared/ui/filtering_test.rb +29 -0
- data/test/generators/gallery_generator_test.rb +0 -10
- data/test/generators/resource_generator_test.rb +30 -6
- data/test/helpers/shared_pages_helper_test.rb +22 -43
- data/test/models/adminpanel/image_test.rb +31 -0
- data/test/models/adminpanel/sortable_gallery_unit_test.rb +8 -8
- data/test/support/view_case.rb +2 -2
- metadata +53 -43
- data/app/assets/images/adminpanel/dialogs.png +0 -0
- data/app/assets/images/adminpanel/icons-big.png +0 -0
- data/app/assets/images/adminpanel/icons-small.png +0 -0
- data/app/assets/images/adminpanel/select2.png +0 -0
- data/app/assets/images/adminpanel/select2x2.png +0 -0
- data/app/assets/images/adminpanel/toolbar.png +0 -0
- data/app/assets/javascripts/adminpanel/jquery.knob.js +0 -652
- data/app/assets/javascripts/adminpanel/jquery.masonry.min.js +0 -10
- data/app/assets/javascripts/adminpanel/jquery.slimscroll.min.js +0 -14
- data/app/views/adminpanel/analytics/_fb_statistic_widget.html.erb +0 -63
- data/app/views/adminpanel/analytics/fb.html.erb +0 -106
- data/test/dummy/config/carrierwave.rb +0 -6
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/test/fixtures/adminpanel/galleryfiles.yml +0 -42
- data/test/features/shared/ui/max_images_gallery_test.rb +0 -51
|
@@ -767,7 +767,7 @@ table.table thead .sorting_desc_disabled { background: url(<%= asset_path 'admin
|
|
|
767
767
|
margin:0 10px;
|
|
768
768
|
}
|
|
769
769
|
.widget{
|
|
770
|
-
|
|
770
|
+
margin-bottom: 15px;
|
|
771
771
|
-moz-border-radius: 3px 3px 3px 3px;
|
|
772
772
|
-webkit-border-radius: 3px 3px 3px 3px;
|
|
773
773
|
border-radius: 3px 3px 3px 3px;
|
|
@@ -4,7 +4,8 @@ module Adminpanel
|
|
|
4
4
|
include Adminpanel::Analytics::InstagramAnalytics
|
|
5
5
|
|
|
6
6
|
skip_before_action :set_resource_collection
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
before_action :set_fb_token
|
|
8
9
|
|
|
9
10
|
API_VERSION = 'v3'
|
|
10
11
|
CACHED_API_FILE = "#{Rails.root}/tmp/cache/analytics-#{API_VERSION}.cache"
|
|
@@ -81,50 +82,6 @@ module Adminpanel
|
|
|
81
82
|
end
|
|
82
83
|
end
|
|
83
84
|
|
|
84
|
-
def fb
|
|
85
|
-
authorize! :read, Adminpanel::Analytic
|
|
86
|
-
if params[:insight].present?
|
|
87
|
-
period = params[:insight]
|
|
88
|
-
else
|
|
89
|
-
period = 'day' #default period
|
|
90
|
-
end
|
|
91
|
-
page_graph = Koala::Facebook::API.new(@auth.value)
|
|
92
|
-
@impressions,
|
|
93
|
-
@impressions_unique,
|
|
94
|
-
|
|
95
|
-
@new_likes,
|
|
96
|
-
@total_likes,
|
|
97
|
-
|
|
98
|
-
@hidden,
|
|
99
|
-
@hidden_unique,
|
|
100
|
-
|
|
101
|
-
@consumptions,
|
|
102
|
-
@consumptions_unique,
|
|
103
|
-
|
|
104
|
-
@views,
|
|
105
|
-
@views_unique,
|
|
106
|
-
|
|
107
|
-
@stories = page_graph.batch do |api|
|
|
108
|
-
#all information on same request
|
|
109
|
-
api.get_connections('me', 'insights', metric: 'page_impressions', period: period) #eye
|
|
110
|
-
api.get_connections('me', 'insights', metric: 'page_impressions_unique', period: period) #eye
|
|
111
|
-
|
|
112
|
-
api.get_connections('me', 'insights', metric: 'page_fan_adds') #fb-thumb
|
|
113
|
-
api.get_connections('me', 'insights', metric: 'page_fans') #fb-thumb
|
|
114
|
-
|
|
115
|
-
api.get_connections('me', 'insights', metric: 'page_negative_feedback', period: period)
|
|
116
|
-
api.get_connections('me', 'insights', metric: 'page_negative_feedback_unique', period: period)
|
|
117
|
-
|
|
118
|
-
api.get_connections('me', 'insights', metric: 'page_consumptions', period: period)
|
|
119
|
-
api.get_connections('me', 'insights', metric: 'page_consumptions_unique', period: period)
|
|
120
|
-
|
|
121
|
-
api.get_connections('me', 'insights', metric: 'page_views')
|
|
122
|
-
api.get_connections('me', 'insights', metric: 'page_views_unique')
|
|
123
|
-
|
|
124
|
-
api.get_connections('me', 'insights', metric: 'page_stories', period: period)
|
|
125
|
-
end
|
|
126
|
-
end
|
|
127
|
-
|
|
128
85
|
# uses @client to fetch replies and tweets, for some statics
|
|
129
86
|
def twitter
|
|
130
87
|
authorize! :read, Adminpanel::Analytic
|
|
@@ -153,12 +110,11 @@ module Adminpanel
|
|
|
153
110
|
end
|
|
154
111
|
end
|
|
155
112
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
redirect_to analytics_path
|
|
113
|
+
private
|
|
114
|
+
|
|
115
|
+
def set_fb_token
|
|
116
|
+
@fb_auth = Adminpanel::Auth.find_by_key('facebook')
|
|
161
117
|
end
|
|
162
|
-
|
|
118
|
+
|
|
163
119
|
end
|
|
164
120
|
end
|
|
@@ -56,6 +56,7 @@ module Adminpanel
|
|
|
56
56
|
@fb_auths_count ||= Auth.find_by_key('facebook')
|
|
57
57
|
end
|
|
58
58
|
|
|
59
|
+
# Creates or updates the Facebook Auth token.
|
|
59
60
|
def update_fb_auth(account_selected_name)
|
|
60
61
|
auth = Auth.find_by(key: 'facebook', name: account_selected_name)
|
|
61
62
|
if auth.nil?
|
|
@@ -70,6 +71,8 @@ module Adminpanel
|
|
|
70
71
|
end
|
|
71
72
|
end
|
|
72
73
|
|
|
74
|
+
# Extracts the name of the model
|
|
75
|
+
# @return Name of the model [String]
|
|
73
76
|
def model_name
|
|
74
77
|
@model.name.demodulize.downcase # ex: posts
|
|
75
78
|
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module Adminpanel
|
|
2
|
+
module GalleryActions
|
|
3
|
+
extend ActiveSupport::Concern
|
|
4
|
+
|
|
5
|
+
def add_to_gallery
|
|
6
|
+
image_class = params[:model].constantize
|
|
7
|
+
image = image_class.new(file: params[:file], model_type: params[:parent_object_class])
|
|
8
|
+
image.model_id = params[:resource_id] if params[:resource_id]
|
|
9
|
+
|
|
10
|
+
if image.save
|
|
11
|
+
response = {
|
|
12
|
+
class: image_class.to_controller_name,
|
|
13
|
+
id: image.id
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
respond_to do |f|
|
|
17
|
+
f.json{ render status: :ok, json: response.to_json }
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def remove_image
|
|
23
|
+
@image = params[:model].constantize.find(params[:id])
|
|
24
|
+
@image.destroy
|
|
25
|
+
|
|
26
|
+
respond_to do |f|
|
|
27
|
+
f.json{ render status: :ok, json: @image.to_json }
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
module Adminpanel
|
|
2
2
|
module AnalyticsHelper
|
|
3
|
-
def first_fb_value metric
|
|
4
|
-
total = 0.0
|
|
5
|
-
# metric.first['values'].each do |value|
|
|
6
|
-
# if value['value'] != []
|
|
7
|
-
# total = total + value['value'].to_f
|
|
8
|
-
# end
|
|
9
|
-
# end
|
|
10
|
-
# return total
|
|
11
|
-
metric.first['values'].last['value'].to_f
|
|
12
|
-
end
|
|
13
3
|
|
|
14
4
|
def days_to_substract
|
|
15
5
|
if params[:insight] == 'day'
|
|
@@ -23,14 +13,6 @@ module Adminpanel
|
|
|
23
13
|
end
|
|
24
14
|
end
|
|
25
15
|
|
|
26
|
-
def divide_metrics metric_1, metric_2
|
|
27
|
-
if first_fb_value(metric_2) != 0.0
|
|
28
|
-
return first_fb_value(metric_1) / first_fb_value(metric_2)
|
|
29
|
-
else
|
|
30
|
-
return 0
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
16
|
def insight
|
|
35
17
|
return 'day' if !params[:insight].present?
|
|
36
18
|
return 'day' if params[:insight] == 'day'
|
|
@@ -46,6 +28,14 @@ module Adminpanel
|
|
|
46
28
|
"http://www.twitter.com/#{tweet.user.screen_name}/status/#{tweet.id}"
|
|
47
29
|
end
|
|
48
30
|
|
|
31
|
+
def fb_insights(fb_auth)
|
|
32
|
+
if fb_auth
|
|
33
|
+
"#{Koala::Facebook::API.new(fb_auth.value).get_object('me')['link']}insights"
|
|
34
|
+
else
|
|
35
|
+
'#'
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
49
39
|
def exist_instagram_account?
|
|
50
40
|
if @instagram_token.nil?
|
|
51
41
|
false
|
|
@@ -6,13 +6,21 @@ module Adminpanel
|
|
|
6
6
|
|
|
7
7
|
def adminpanel_form_for(name, *args, &block)
|
|
8
8
|
options = args.extract_options!
|
|
9
|
-
options.reverse_merge! builder: Adminpanel::AdminpanelFormBuilder, html: { class:
|
|
9
|
+
options.reverse_merge! builder: Adminpanel::AdminpanelFormBuilder, html: { class: 'form-horizontal' }
|
|
10
|
+
if name.class.has_gallery?
|
|
11
|
+
options[:html][:"data-parent-object-class"] = name.class.to_s
|
|
12
|
+
options[:html][:"data-parent-object-id"] = name.id
|
|
13
|
+
options[:html][:"data-dropzone"] = name.class.to_s.demodulize.underscore
|
|
14
|
+
options[:html][:"data-dropzone-galleries"] = name.class.galleries.to_json
|
|
15
|
+
options[:html][:"data-dropzone-url"] = url_for(controller: name.class.to_controller_name, action: :add_to_gallery)
|
|
16
|
+
options[:html][:"data-dropzone-delete-url"] = url_for(controller: name.class.to_controller_name, action: :remove_image)
|
|
17
|
+
end
|
|
10
18
|
|
|
11
19
|
form_for(name, *(args << options), &block)
|
|
12
20
|
end
|
|
13
21
|
|
|
14
22
|
def full_title(page_title)
|
|
15
|
-
base_title = t("
|
|
23
|
+
base_title = I18n.t("panel-title")
|
|
16
24
|
if page_title.empty?
|
|
17
25
|
base_title
|
|
18
26
|
else
|
|
@@ -4,8 +4,8 @@ module Adminpanel
|
|
|
4
4
|
resource_class(resource).has_sortable_gallery?
|
|
5
5
|
end
|
|
6
6
|
|
|
7
|
-
def
|
|
8
|
-
resource_class(resource).
|
|
7
|
+
def sortable_galleries(resource)
|
|
8
|
+
resource_class(resource).sortable_galleries
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def resources_parameters(resource)
|
|
@@ -20,6 +20,10 @@ module Adminpanel
|
|
|
20
20
|
resource_class(resource).twitter_share?
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
+
def has_gallery?(resource)
|
|
24
|
+
resource_class(resource).has_gallery?
|
|
25
|
+
end
|
|
26
|
+
|
|
23
27
|
def resource_is_sortable?(resource)
|
|
24
28
|
resource_class(resource).is_sortable?
|
|
25
29
|
end
|
|
@@ -14,7 +14,7 @@ module Adminpanel
|
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
def pluralize_model(class_name)
|
|
17
|
-
|
|
17
|
+
demodulize_class(class_name).pluralize
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
def relationship_ids(class_string)
|
|
@@ -50,8 +50,8 @@ module Adminpanel
|
|
|
50
50
|
).url_for_oauth_code
|
|
51
51
|
end
|
|
52
52
|
|
|
53
|
-
def field_value(
|
|
54
|
-
case
|
|
53
|
+
def field_value(attr_type, attribute, object)
|
|
54
|
+
case attr_type
|
|
55
55
|
when 'select'
|
|
56
56
|
belong_to_object_name(object, attribute.gsub('_id', ''))
|
|
57
57
|
when 'checkbox'
|
|
@@ -65,6 +65,8 @@ module Adminpanel
|
|
|
65
65
|
li_tags.html_safe
|
|
66
66
|
end
|
|
67
67
|
when 'file_field'
|
|
68
|
+
object[attribute]
|
|
69
|
+
when 'image_field'
|
|
68
70
|
content_tag :ul do
|
|
69
71
|
image_tag(object.send("#{attribute}_url", :thumb))
|
|
70
72
|
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module Adminpanel
|
|
2
|
+
class Image < ActiveRecord::Base
|
|
3
|
+
include Adminpanel::Base
|
|
4
|
+
|
|
5
|
+
belongs_to :model, polymorphic: true
|
|
6
|
+
|
|
7
|
+
before_save :store_file_size_and_content_type
|
|
8
|
+
# after_save :delete_old_unused_images
|
|
9
|
+
before_destroy :remove_attachment
|
|
10
|
+
|
|
11
|
+
private
|
|
12
|
+
def remove_attachment
|
|
13
|
+
self.remove_file!
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def store_file_size_and_content_type
|
|
17
|
+
if file.present? && file_changed?
|
|
18
|
+
self.content_type = file.file.content_type
|
|
19
|
+
self.file_size = file.file.size
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# def delete_old_unused_images
|
|
24
|
+
# self.class.where('created_at < ?', Time.now - 30.minutes)
|
|
25
|
+
# .delete_all(
|
|
26
|
+
# model_id: nil,
|
|
27
|
+
# type: self.type
|
|
28
|
+
# )
|
|
29
|
+
# end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -3,11 +3,15 @@ module Adminpanel
|
|
|
3
3
|
extend ActiveSupport::Concern
|
|
4
4
|
|
|
5
5
|
module ClassMethods
|
|
6
|
+
FILE_FIELD_NAME = 'adminpanel_file_field'
|
|
7
|
+
|
|
6
8
|
|
|
7
9
|
# Adminpanel API
|
|
8
10
|
def mount_images(relation)
|
|
9
|
-
has_many relation, dependent: :destroy
|
|
11
|
+
has_many relation, dependent: :destroy, as: :model
|
|
10
12
|
accepts_nested_attributes_for relation, allow_destroy: true
|
|
13
|
+
after_save :destroy_unattached_images
|
|
14
|
+
after_save :correlative_order_gallery, if: Proc.new { |model| model.class.has_sortable_gallery? }
|
|
11
15
|
end
|
|
12
16
|
|
|
13
17
|
# implementing cache by default.
|
|
@@ -61,7 +65,7 @@ module Adminpanel
|
|
|
61
65
|
properties['show'] == 'true' ||
|
|
62
66
|
(
|
|
63
67
|
properties['show'] == type &&
|
|
64
|
-
properties['type'] !=
|
|
68
|
+
properties['type'] != FILE_FIELD_NAME #file fields get only displayed in form
|
|
65
69
|
)
|
|
66
70
|
)
|
|
67
71
|
display_attributes << attribute
|
|
@@ -76,7 +80,7 @@ module Adminpanel
|
|
|
76
80
|
def has_gallery?
|
|
77
81
|
form_attributes.each do |fields|
|
|
78
82
|
fields.each do |attribute, properties|
|
|
79
|
-
if properties['type'] ==
|
|
83
|
+
if properties['type'] == FILE_FIELD_NAME
|
|
80
84
|
return true
|
|
81
85
|
end
|
|
82
86
|
end
|
|
@@ -84,12 +88,39 @@ module Adminpanel
|
|
|
84
88
|
return false
|
|
85
89
|
end
|
|
86
90
|
|
|
91
|
+
#Returns an array of all the adminpanel_field_field fields found in form_attributes
|
|
92
|
+
def galleries
|
|
93
|
+
galleries = {}
|
|
94
|
+
form_attributes.each do |fields|
|
|
95
|
+
fields.each do |attribute, properties|
|
|
96
|
+
if properties['type'] == FILE_FIELD_NAME
|
|
97
|
+
galleries["#{attribute.singularize}"] = "adminpanel/#{attribute}".classify.constantize.to_s
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
return galleries
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def sortable_galleries
|
|
106
|
+
galleries = {}
|
|
107
|
+
form_attributes.each do |fields|
|
|
108
|
+
fields.each do |attribute, properties|
|
|
109
|
+
if properties['type'] == FILE_FIELD_NAME && "adminpanel/#{attribute}".classify.constantize.is_sortable?
|
|
110
|
+
galleries["#{attribute.singularize}"] = "adminpanel/#{attribute}".classify.constantize.to_s
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
galleries
|
|
116
|
+
end
|
|
117
|
+
|
|
87
118
|
# returns the attribute that should be namespaced to be the class
|
|
88
119
|
# ex: returns 'productfiles', so class is Adminpanel::Productfile
|
|
89
120
|
def gallery_relationship
|
|
90
121
|
form_attributes.each do |fields|
|
|
91
122
|
fields.each do |attribute, properties|
|
|
92
|
-
if properties['type'] ==
|
|
123
|
+
if properties['type'] == FILE_FIELD_NAME
|
|
93
124
|
return attribute
|
|
94
125
|
end
|
|
95
126
|
end
|
|
@@ -152,9 +183,11 @@ module Adminpanel
|
|
|
152
183
|
end
|
|
153
184
|
|
|
154
185
|
def has_sortable_gallery?
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
186
|
+
!sortable_galleries.empty?
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
def to_controller_name
|
|
190
|
+
to_s.demodulize.underscore.pluralize
|
|
158
191
|
end
|
|
159
192
|
|
|
160
193
|
private
|
|
@@ -176,6 +209,17 @@ module Adminpanel
|
|
|
176
209
|
false
|
|
177
210
|
end
|
|
178
211
|
end
|
|
212
|
+
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
def destroy_unattached_images
|
|
216
|
+
self.class.galleries.each{|gallery| gallery.last.constantize.delete_all(model_id: nil) }
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
def correlative_order_gallery
|
|
220
|
+
self.class.galleries.each do |gallery|
|
|
221
|
+
self.send(gallery.first.pluralize).ordered.each_with_index{ |image, index| image.update(position: index + 1) }
|
|
222
|
+
end
|
|
179
223
|
end
|
|
180
224
|
end
|
|
181
225
|
end
|