adminpanel 3.1.0 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/adminpanel.gemspec +1 -0
  3. data/app/assets/javascripts/adminpanel/realm.js +43 -43
  4. data/app/assets/javascripts/adminpanel/trix-upload.coffee +45 -0
  5. data/app/controllers/concerns/adminpanel/gallery_actions.rb +2 -1
  6. data/app/controllers/concerns/adminpanel/rest_actions.rb +12 -11
  7. data/app/helpers/adminpanel/adminpanel_form_builder.rb +28 -2
  8. data/app/helpers/adminpanel/application_helper.rb +14 -9
  9. data/app/helpers/adminpanel/router_helper.rb +1 -1
  10. data/app/models/adminpanel/image.rb +1 -8
  11. data/app/models/concerns/adminpanel/base.rb +63 -37
  12. data/app/views/adminpanel/icons/_delete.html.erb +3 -0
  13. data/app/views/adminpanel/icons/_edit.html.erb +6 -1
  14. data/app/views/adminpanel/icons/_facebook.html.erb +3 -1
  15. data/app/views/adminpanel/icons/_new.html.erb +6 -1
  16. data/app/views/adminpanel/icons/_show.html.erb +6 -1
  17. data/app/views/adminpanel/icons/_twitter.html.erb +3 -0
  18. data/config/routes.rb +2 -2
  19. data/lib/adminpanel/version.rb +1 -1
  20. data/test/dummy/app/controllers/adminpanel/test_objects_controller.rb +4 -0
  21. data/test/dummy/app/models/adminpanel/test_object.rb +3 -0
  22. data/test/dummy/app/models/adminpanel/textfile.rb +7 -0
  23. data/test/dummy/config/initializers/adminpanel_setup.rb +1 -0
  24. data/test/features/shared/form/checkbox_test.rb +0 -1
  25. data/test/features/shared/form/enum_field_test.rb +0 -1
  26. data/test/features/shared/form/has_many_through_remote_test.rb +1 -2
  27. data/test/features/shared/form/modal_contents_test.rb +0 -1
  28. data/test/features/shared/form/resource_field_test.rb +0 -1
  29. data/test/features/shared/form/select_test.rb +0 -1
  30. data/test/features/shared/form/wysiwyg_test.rb +23 -0
  31. metadata +24 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0dabdd27ecf752a66c20e0b2199b03137a16be78
4
- data.tar.gz: f805cee1bda91e50223bf6ecf6901b04e1e5290e
3
+ metadata.gz: e5f00c2db221e6cb620e033aa8a68858d6b3981a
4
+ data.tar.gz: 5bd1f80432627e6a24dd8a133ea42eb652dde722
5
5
  SHA512:
6
- metadata.gz: 9e161090ba658140efac3b49198595ed904b473deba28873d7e64cd72b88e77ce1ade33ad946560757c90479cb7ad6797cae1f2559077bde85221937f366cc77
7
- data.tar.gz: 392c942c45621ebb2f557799a97ac1d430a0459613f3d79a35785141a70512672727dbc89a97ebc6cc3548e30b031edc70177f0d49ffa43eb6fc91e5dc3c6eb3
6
+ metadata.gz: 271dcd2b02ed4b3ef483d2ada2e043910a9894b7c4660fda66e066bac6e18aae5034d76d04825c48205a8094c5837d47c6a992a0f9b0245164f59499958b042f
7
+ data.tar.gz: f32a7d5d6d64d5af11b35fd42286a7b7c0dbc529c185ba0b5d011c22750eb1ab942bb71b222d82a43d2660a821cac84815b3ba5cddc656eee01b48dd9c6f5af2
data/adminpanel.gemspec CHANGED
@@ -54,4 +54,5 @@ Gem::Specification.new do |spec|
54
54
  spec.add_development_dependency 'minitest-capybara','0.7.1'
55
55
  spec.add_development_dependency 'poltergeist'
56
56
  spec.add_development_dependency 'sqlite3', '~> 1.3', '>= 1.3.10'
57
+ spec.add_development_dependency 'byebug'
57
58
  end
@@ -1,15 +1,15 @@
1
1
  var ready = function(){
2
2
 
3
3
  // toggle arrow on menu items
4
- $('.accordion-heading .accordion-toggle').click(function(){
5
- $('.accordion-heading .accordion-toggle').not($(this)[0], '.accordion-heading .accordion-toggle.collapse').addClass('collapsed');
6
- });
4
+ // $('.accordion-heading .accordion-toggle').click(function(){
5
+ // $('.accordion-heading .accordion-toggle').not($(this)[0], '.accordion-heading .accordion-toggle.collapse').addClass('collapsed');
6
+ // });
7
7
 
8
8
  // show the overview boxes on the dashboard once they are loaded
9
- $('.overview_boxes .box_row').css('display', 'inline-block');
9
+ // $('.overview_boxes .box_row').css('display', 'inline-block');
10
10
 
11
11
  // init tooltips on .tips class elements, text for the tooltip is in the data-title attribute on the element itself
12
- // $('.tip').tooltip();
12
+ $('[data-toggle="tooltip"]').tooltip();
13
13
 
14
14
  // init popover on .pop class elements
15
15
  // $('.pop').popover({
@@ -25,22 +25,22 @@ var ready = function(){
25
25
 
26
26
 
27
27
  // funtion to slide menu out from the left
28
- $('.slide_menu_left').click(function(e){
29
-
30
- e.preventDefault();
31
- if($(".nav-collapse.collapse").hasClass('open_left')){
32
- sidemenu_close();
33
- }else{
34
- sidemenu_open();
35
- $('.main_container').bind('click', function(){
36
- sidemenu_close();
37
- });
38
- // var handler = function() {
39
- // sidemenu_close();
40
- // };
41
- // $(window).bind('resize', handler);
42
- }
43
- });
28
+ // $('.slide_menu_left').click(function(e){
29
+ //
30
+ // e.preventDefault();
31
+ // if($(".nav-collapse.collapse").hasClass('open_left')){
32
+ // sidemenu_close();
33
+ // }else{
34
+ // sidemenu_open();
35
+ // $('.main_container').bind('click', function(){
36
+ // sidemenu_close();
37
+ // });
38
+ // // var handler = function() {
39
+ // // sidemenu_close();
40
+ // // };
41
+ // // $(window).bind('resize', handler);
42
+ // }
43
+ // });
44
44
 
45
45
 
46
46
  // collapse function for the widget
@@ -65,25 +65,25 @@ $(document).on('page:load', ready);
65
65
  //----- Side menu functions -----
66
66
 
67
67
  // slide menu out of view
68
- function sidemenu_close(){
69
- $(".main_container").stop().animate({
70
- 'left': '0'
71
- }, 250, 'swing');
72
- $(".nav-collapse.collapse").stop().animate({
73
- 'left': '-150px'
74
- }, 250, 'swing').removeClass('open_left');
75
- $('.main_container').unbind('click');
76
- if(typeof handler != 'undefined'){
77
- $(window).unbind('resize', handler);
78
- }
79
- }
80
-
81
- // slide menu in
82
- function sidemenu_open(){
83
- $(".main_container").stop().animate({
84
- 'left': '150px'
85
- }, 250, 'swing');
86
- $(".nav-collapse.collapse").stop().animate({
87
- 'left': '0'
88
- }, 250, 'swing').addClass('open_left');
89
- }
68
+ // function sidemenu_close(){
69
+ // $(".main_container").stop().animate({
70
+ // 'left': '0'
71
+ // }, 250, 'swing');
72
+ // $(".nav-collapse.collapse").stop().animate({
73
+ // 'left': '-150px'
74
+ // }, 250, 'swing').removeClass('open_left');
75
+ // $('.main_container').unbind('click');
76
+ // if(typeof handler != 'undefined'){
77
+ // $(window).unbind('resize', handler);
78
+ // }
79
+ // }
80
+ //
81
+ // // slide menu in
82
+ // function sidemenu_open(){
83
+ // $(".main_container").stop().animate({
84
+ // 'left': '150px'
85
+ // }, 250, 'swing');
86
+ // $(".nav-collapse.collapse").stop().animate({
87
+ // 'left': '0'
88
+ // }, 250, 'swing').addClass('open_left');
89
+ // }
@@ -0,0 +1,45 @@
1
+ document.addEventListener "trix-attachment-add", (event) ->
2
+ attachment = event.attachment
3
+ if attachment.file
4
+ return uploadAttachment(event)
5
+
6
+ document.addEventListener "trix-attachment-remove", (event) ->
7
+ image_url = event.attachment.attachment.preloadedURL
8
+ $("input[data-url='#{image_url}']").remove()
9
+
10
+ uploadAttachment = (e) ->
11
+ $element = $(e.srcElement)
12
+ $form = $('form:first')
13
+ host = $form.data('trix-url')
14
+ attachment = e.attachment
15
+ file = attachment.file
16
+ formData = new FormData
17
+ formData.append("parent_object_class", $form.data('parent-class'))
18
+ formData.append("model", $element.data('uploader-class'))
19
+ formData.append("file", file)
20
+
21
+ xhr = new XMLHttpRequest
22
+ xhr.open("POST", host, true)
23
+
24
+ xhr.upload.onprogress = (event) ->
25
+ progress = event.loaded / event.total * 100
26
+ return attachment.setUploadProgress(progress)
27
+
28
+ xhr.onload = ->
29
+ if (xhr.status is 204 || xhr.status is 200)
30
+ response = JSON.parse(xhr.responseText)
31
+
32
+ uploader = $element.data('uploader-name')
33
+ console.log $element
34
+ console.log uploader
35
+ $form.append("<input type=\"hidden\" name=\"#{$form.data('params-key')}[#{uploader.slice(0, -1)}_ids][]\" value=\"#{response.id}\" />")
36
+ return attachment.setAttributes({
37
+ url: response.image_url,
38
+ href: response.image_url
39
+ })
40
+
41
+ xhr.setRequestHeader(
42
+ "X-CSRF-Token",
43
+ $('meta[name="csrf-token"]').attr('content')
44
+ )
45
+ return xhr.send(formData)
@@ -10,7 +10,8 @@ module Adminpanel
10
10
  if image.save
11
11
  response = {
12
12
  class: image_class.to_controller_name,
13
- id: image.id
13
+ id: image.id,
14
+ image_url: image.file_url(:thumb)
14
15
  }
15
16
 
16
17
  respond_to do |f|
@@ -31,7 +31,12 @@ module Adminpanel
31
31
  def new
32
32
  @resource_instance = @model.new
33
33
  respond_to do |format|
34
- render_new(format)
34
+ format.html do
35
+ render 'adminpanel/templates/new'
36
+ end
37
+ format.js do
38
+ render 'adminpanel/templates/new'
39
+ end
35
40
  end
36
41
  end
37
42
 
@@ -52,7 +57,12 @@ module Adminpanel
52
57
  end
53
58
  end
54
59
  else
55
- render_new(format)
60
+ format.html do
61
+ render 'adminpanel/templates/new'
62
+ end
63
+ format.js do
64
+ render 'adminpanel/templates/new'
65
+ end
56
66
  end
57
67
  end
58
68
  end
@@ -102,14 +112,5 @@ module Adminpanel
102
112
  resource = controller_name.singularize.to_sym
103
113
  "#{resource}_params"
104
114
  end
105
-
106
- def render_new(format)
107
- format.html do
108
- render 'adminpanel/templates/new'
109
- end
110
- format.js do
111
- render 'adminpanel/templates/new'
112
- end
113
- end
114
115
  end
115
116
  end
@@ -55,7 +55,14 @@ module Adminpanel
55
55
 
56
56
  options = args.extract_options!
57
57
 
58
- hidden_field(method, id: "#{self.object.class.to_s.demodulize}-trix-#{method}") + base_layout(method, options, 'trix_field')
58
+ hidden_field(
59
+ method,
60
+ id: "#{self.object.class.to_s.demodulize}-trix-#{method}"
61
+ ) + base_layout(
62
+ method,
63
+ options,
64
+ 'trix_field'
65
+ )
59
66
  end
60
67
 
61
68
  def text_area(method, *args)
@@ -204,10 +211,29 @@ module Adminpanel
204
211
  options = args.extract_options!
205
212
  options.reverse_merge! input: "#{self.object.class.to_s.demodulize}-trix-#{method}", id: "#{method}-trix-editor"
206
213
  options[:class] << ' trix-content'
214
+ options[:data] ||= {}
215
+ editor_images = []
216
+ if options['uploader'].present?
217
+ options[:data][:uploader_name] = options['uploader'].to_s
218
+ options[:data][:uploader_class] = "Adminpanel::#{options['uploader'].to_s.singularize.capitalize}"
219
+ relation_name = "#{options['uploader'].to_s.singularize}_ids"
220
+ editor_images = self.object.send(options['uploader'].to_s)
221
+ empty_uploader_field = @template.hidden_field_tag "#{self.object.class.name.demodulize.underscore}[#{relation_name}][]"
222
+ end
207
223
 
208
- @template.content_tag 'trix-editor', options do
224
+ editor = @template.content_tag 'trix-editor', options do
209
225
  self.object.send(method)
210
226
  end
227
+ editor_images_fields = editor_images.map {|image|
228
+ @template.hidden_field_tag(
229
+ "#{self.object.class.name.demodulize.underscore}[#{relation_name}][]",
230
+ image.id,
231
+ data: {
232
+ url: image.file_url(:thumb)
233
+ }
234
+ )
235
+ }.join('').html_safe
236
+ editor + empty_uploader_field + editor_images_fields
211
237
  end
212
238
 
213
239
  private
@@ -4,19 +4,24 @@ module Adminpanel
4
4
  include BreadcrumbsHelper
5
5
  include SharedPagesHelper
6
6
 
7
- def adminpanel_form_for(name, *args, &block)
7
+ def adminpanel_form_for(object, *args, &block)
8
8
  options = args.extract_options!
9
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)
10
+ if @model.has_gallery?
11
+ options[:html][:"data-parent-object-class"] = @model.to_s
12
+ options[:html][:"data-parent-object-id"] = object.id
13
+ options[:html][:"data-dropzone"] = @model.to_s.demodulize.underscore
14
+ options[:html][:"data-dropzone-galleries"] = @model.galleries.to_json
15
+ options[:html][:"data-dropzone-url"] = url_for(controller: @model.to_controller_name, action: :add_to_gallery)
16
+ options[:html][:"data-dropzone-delete-url"] = url_for(controller: @model.to_controller_name, action: :remove_image)
17
+ end
18
+ if @model.has_trix_gallery?
19
+ options[:html][:"data-trix-url"] = url_for(controller: @model.to_controller_name, action: :add_to_gallery)
20
+ options[:html][:"data-parent-class"] ||= @model.to_s
21
+ options[:html][:"data-params-key"] ||= @model.to_s.demodulize.underscore
17
22
  end
18
23
 
19
- form_for(name, *(args << options), &block)
24
+ form_for(object, *(args << options), &block)
20
25
  end
21
26
 
22
27
  def full_title(page_title)
@@ -21,7 +21,7 @@ module Adminpanel
21
21
  end
22
22
 
23
23
  def has_gallery?(resource)
24
- resource_class(resource).has_gallery?
24
+ resource_class(resource).has_gallery? || resource_class(resource).has_trix_gallery?
25
25
  end
26
26
 
27
27
  def resource_is_sortable?(resource)
@@ -5,7 +5,7 @@ module Adminpanel
5
5
  belongs_to :model, polymorphic: true
6
6
 
7
7
  before_save :store_file_size_and_content_type
8
- # after_save :delete_old_unused_images
8
+
9
9
  before_destroy :remove_attachment
10
10
 
11
11
  private
@@ -20,12 +20,5 @@ module Adminpanel
20
20
  end
21
21
  end
22
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
23
  end
31
24
  end
@@ -1,12 +1,14 @@
1
+ # Adminpanel API
2
+ # This file must be included on every adminpanel resource.
3
+
1
4
  module Adminpanel
2
5
  module Base
3
6
  extend ActiveSupport::Concern
4
7
 
5
8
  module ClassMethods
6
- FILE_FIELD_NAME = 'adminpanel_file_field'
9
+ FILE_FIELD_NAME = 'adminpanel_file_field'
7
10
 
8
11
 
9
- # Adminpanel API
10
12
  def mount_images(relation)
11
13
  has_many relation, dependent: :destroy, as: :model
12
14
  accepts_nested_attributes_for relation, allow_destroy: true
@@ -31,7 +33,7 @@ module Adminpanel
31
33
  'please overwrite self.display_name'
32
34
  end
33
35
 
34
- # side menu icon
36
+ # fontawesome icon to be used in the side-menu
35
37
  def icon
36
38
  'truck'
37
39
  end
@@ -59,7 +61,7 @@ module Adminpanel
59
61
  def display_attributes(type)
60
62
  display_attributes = []
61
63
  form_attributes.each do |attribute|
62
- attribute.each do |name, properties|
64
+ attribute.each do |_, properties|
63
65
  if (
64
66
  properties['show'].nil? ||
65
67
  properties['show'] == 'true' ||
@@ -75,8 +77,8 @@ module Adminpanel
75
77
  return display_attributes
76
78
  end
77
79
 
78
- # return true if model has adminpanel_file_field in
79
- # it's attributes
80
+ # Check if this models has a gallery in its attributes
81
+ # @return boolean
80
82
  def has_gallery?
81
83
  form_attributes.each do |fields|
82
84
  fields.each do |attribute, properties|
@@ -85,16 +87,32 @@ module Adminpanel
85
87
  end
86
88
  end
87
89
  end
88
- return false
90
+ false
89
91
  end
90
92
 
91
- #Returns an array of all the adminpanel_field_field fields found in form_attributes
93
+ # Check if this models has a trix editor with a gallery in its attributes
94
+ # @return boolean
95
+ def has_trix_gallery?
96
+ form_attributes.each do |fields|
97
+ fields.each do |attribute, properties|
98
+ if properties['type'] == 'wysiwyg_field' || properties['uploader'].present?
99
+ return true
100
+ end
101
+ end
102
+ end
103
+ false
104
+ end
105
+
106
+ # Returns an array with all the adminpanel_file_field`s attributes found
107
+ # in form_attributes
108
+ # @return Hash
109
+ # => { sectionfiles: Adminpanel::SectionFile, ... }
92
110
  def galleries
93
111
  galleries = {}
94
112
  form_attributes.each do |fields|
95
- fields.each do |attribute, properties|
113
+ fields.each do |relation, properties|
96
114
  if properties['type'] == FILE_FIELD_NAME
97
- galleries["#{attribute.singularize}"] = "adminpanel/#{attribute}".classify.constantize.to_s
115
+ galleries["#{relation.singularize}"] = "adminpanel/#{relation}".classify.constantize.to_s
98
116
  end
99
117
  end
100
118
  end
@@ -102,12 +120,15 @@ module Adminpanel
102
120
  return galleries
103
121
  end
104
122
 
123
+ # Returns an array with all the adminpanel_file_field`s attributes who are
124
+ # sortable found in form_attributes
125
+ # @return Hash
105
126
  def sortable_galleries
106
127
  galleries = {}
107
128
  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
129
+ fields.each do |relation, properties|
130
+ if properties['type'] == FILE_FIELD_NAME && "adminpanel/#{relation}".classify.constantize.is_sortable?
131
+ galleries["#{relation.singularize}"] = "adminpanel/#{relation}".classify.constantize.to_s
111
132
  end
112
133
  end
113
134
  end
@@ -133,7 +154,8 @@ module Adminpanel
133
154
  "adminpanel/#{gallery_relationship}".classify.constantize
134
155
  end
135
156
 
136
- # returns all the class of the attributes of a given type.
157
+ # Search for a model attribute's that are of a given type
158
+ # @return Array
137
159
  # Usage:
138
160
  # To get all classes of all belongs_to attributes:
139
161
  # @model.relationships_of('belongs_to')
@@ -150,12 +172,14 @@ module Adminpanel
150
172
  return classes_of_relation
151
173
  end
152
174
 
175
+ # routes options to be used when generating this model routes
176
+ # @return Hash
153
177
  def routes_options
154
178
  { path: collection_name.parameterize }
155
179
  end
156
180
 
157
181
  def has_route?(route)
158
- if (!exclude?(route)) && include_route(route)
182
+ if (!exclude_route?(route)) && include_route?(route)
159
183
  true
160
184
  else
161
185
  false
@@ -170,10 +194,12 @@ module Adminpanel
170
194
  false
171
195
  end
172
196
 
197
+ # Additional member routes for this resource
173
198
  def member_routes
174
199
  []
175
200
  end
176
201
 
202
+ # Additional collection routes for this resource
177
203
  def collection_routes
178
204
  []
179
205
  end
@@ -192,34 +218,34 @@ module Adminpanel
192
218
 
193
219
  private
194
220
 
195
- def exclude?(route)
196
- if routes_options[:except].nil?
197
- false
198
- elsif routes_options[:except].include?(route)
199
- true
200
- else
201
- false
221
+ def exclude_route?(route)
222
+ if routes_options[:except].nil?
223
+ false
224
+ elsif routes_options[:except].include?(route)
225
+ true
226
+ else
227
+ false
228
+ end
202
229
  end
203
- end
204
230
 
205
- def include_route(route)
206
- if routes_options[:only].nil? || routes_options[:only].include?(route)
207
- true
208
- else
209
- false
231
+ def include_route?(route)
232
+ if routes_options[:only].nil? || routes_options[:only].include?(route)
233
+ true
234
+ else
235
+ false
236
+ end
210
237
  end
211
- end
212
238
 
213
- end
239
+ end
214
240
 
215
- def destroy_unattached_images
216
- self.class.galleries.each{|gallery| gallery.last.constantize.delete_all(model_id: nil) }
217
- end
241
+ def destroy_unattached_images
242
+ self.class.galleries.each{|gallery| gallery.last.constantize.delete_all(model_id: nil) }
243
+ end
218
244
 
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) }
245
+ def correlative_order_gallery
246
+ self.class.galleries.each do |gallery|
247
+ self.send(gallery.first.pluralize).ordered.each_with_index{ |image, index| image.update(position: index + 1) }
248
+ end
222
249
  end
223
- end
224
250
  end
225
251
  end
@@ -12,6 +12,9 @@
12
12
  method: :delete,
13
13
  remote: true,
14
14
  data: {
15
+ toggle: :tooltip,
16
+ placement: :left,
17
+ title: I18n.t('action.delete', resource: resource.name),
15
18
  confirm: I18n.t('action.delete_confirmation', resource: resource.name)
16
19
  }
17
20
  )
@@ -8,7 +8,12 @@
8
8
  ),
9
9
  [:edit, resource],
10
10
  title: I18n.t('action.update', resource: resource.name),
11
- class: 'spinner-link'
11
+ data: {
12
+ toggle: :tooltip,
13
+ placement: :left,
14
+ title: I18n.t('action.update', resource: resource.name)
15
+ },
16
+ class: 'tip spinner-link'
12
17
  )
13
18
  %>
14
19
  <% end %>
@@ -6,8 +6,10 @@ if @model.fb_share? && can?(:publish, @model)
6
6
  else
7
7
  link = '#'
8
8
  options = { target: "#fb-#{resource.id}", toggle: 'modal' }
9
-
10
9
  end
10
+ options[:toggle] ||= ''
11
+ options[:toggle] << ' tooltip'
12
+ options[:title] = 'Compartir en Facebook'
11
13
  %>
12
14
  <%=
13
15
  link_to(
@@ -11,7 +11,12 @@
11
11
  action: :new
12
12
  },
13
13
  title: I18n.t('action.create', resource: @model.display_name),
14
- class: 'spinner-link'
14
+ class: 'spinner-link',
15
+ data: {
16
+ toggle: :tooltip,
17
+ placement: :left,
18
+ title: I18n.t('action.create', resource: @model.display_name),
19
+ }
15
20
  )
16
21
  %>
17
22
  <% end %>
@@ -9,7 +9,12 @@
9
9
  [resource],
10
10
  class: 'spinner-link',
11
11
  title: I18n.t('action.show', resource: resource.name),
12
- id: 'show-resource-icon'
12
+ id: 'show-resource-icon',
13
+ data: {
14
+ toggle: :tooltip,
15
+ placement: :left,
16
+ title: I18n.t('action.show', resource: resource.name)
17
+ }
13
18
  )
14
19
  %>
15
20
  <% end %>
@@ -7,6 +7,9 @@ if @model.twitter_share?
7
7
  link = '#'
8
8
  options = { target: "#twitter-#{resource.id}", toggle: 'modal' }
9
9
  end
10
+ options[:toggle] ||= ''
11
+ options[:toggle] << ' tooltip'
12
+ options[:title] = 'Compartir en Facebook'
10
13
  %>
11
14
  <%=
12
15
  link_to(
data/config/routes.rb CHANGED
@@ -47,7 +47,7 @@ Adminpanel::Engine.routes.draw do
47
47
  if has_fb_share?(resource)
48
48
  # include facebook concern
49
49
  get :fb_choose_page, as: 'fb_choose_page', path: I18n.t('routes.publish', location: I18n.t('routes.facebook_page'))
50
- post :fb_save_token, as: 'fb_save_token', path: 'guardar-token-fb'
50
+ post :fb_save_token, as: 'fb_save_token', path: 'guardar-token-fb'
51
51
  post :fb_publish, to: "#{resource}#fb_publish", as: 'fb_publish', path: I18n.t('routes.publish', location: 'facebook')
52
52
  end
53
53
 
@@ -67,7 +67,7 @@ Adminpanel::Engine.routes.draw do
67
67
 
68
68
  if has_gallery?(resource)
69
69
  post :add_to_gallery, to: "#{resource}#add_to_gallery", as: 'add_to_gallery', path: I18n.t('routes.add_to_gallery')
70
- delete :remove_image, to: "#{resource}#remove_image", as: 'remove_image', path: I18n.t('routes.remove_image')
70
+ delete :remove_image, to: "#{resource}#remove_image", as: 'remove_image', path: I18n.t('routes.remove_image')
71
71
  end
72
72
  end
73
73
  end
@@ -1,3 +1,3 @@
1
1
  module Adminpanel
2
- VERSION = '3.1.0'
2
+ VERSION = '3.2.0'
3
3
  end
@@ -0,0 +1,4 @@
1
+ module Adminpanel
2
+ class TestObjectsController < Adminpanel::ApplicationController
3
+ end
4
+ end
@@ -4,6 +4,8 @@ module Adminpanel
4
4
  has_and_belongs_to_many :categories,
5
5
  join_table: "adminpanel_test_object_category"
6
6
 
7
+ mount_images :textfiles
8
+
7
9
  def self.form_attributes
8
10
  [
9
11
  {
@@ -29,6 +31,7 @@ module Adminpanel
29
31
  {
30
32
  'text' => {
31
33
  'type' => 'wysiwyg_field',
34
+ 'uploader' => 'textfiles',
32
35
  'label' => 'wysi'
33
36
  }
34
37
  },
@@ -0,0 +1,7 @@
1
+ module Adminpanel
2
+ class Textfile < Image
3
+ include Adminpanel::Base
4
+ mount_uploader :file, FileResourcefileUploader
5
+
6
+ end
7
+ end
@@ -23,6 +23,7 @@ Adminpanel.setup do |config|
23
23
  :users,
24
24
  :mugs,
25
25
  :salesmen,
26
+ :test_objects,
26
27
  :file_resources
27
28
  ]
28
29
  end
@@ -1,7 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class CheckboxTest < ViewCase
4
- fixtures :all
5
4
 
6
5
  setup :sign_in
7
6
  teardown :teardown
@@ -1,7 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class EnumFieldTest < ViewCase
4
- fixtures :all
5
4
 
6
5
  setup :sign_in
7
6
 
@@ -1,6 +1,5 @@
1
1
  require 'test_helper'
2
- require 'adminpanel/product'
3
- require 'adminpanel/category'
2
+
4
3
  class HasManyThroughRemoteTest < ViewCase
5
4
 
6
5
  setup :visit_adminpanel_new_department_path
@@ -1,7 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class ModalContentsTest < ViewCase
4
- fixtures :all
5
4
 
6
5
  setup :visit_adminpanel_new_user
7
6
 
@@ -1,7 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class ResourceFieldTest < ViewCase
4
- fixtures :all
5
4
 
6
5
  setup :sign_in
7
6
 
@@ -1,7 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class SelectTest < ViewCase
4
- fixtures :all
5
4
 
6
5
  setup :sign_in
7
6
  teardown :teardown
@@ -0,0 +1,23 @@
1
+ require 'test_helper'
2
+
3
+ class WysiwygTest < ViewCase
4
+
5
+ setup :sign_in
6
+ teardown :teardown
7
+
8
+ def test_form_with_trix_data_attributes_when_uploader
9
+ visit adminpanel.new_test_object_path
10
+
11
+ assert_equal '/adminpanel/please-overwrite-self-display_names/agregar-a-galeria', find('form')['data-trix-url'], "data-trix-url not correct"
12
+ assert_equal 'Adminpanel::TestObject', find('form')['data-parent-class'], "data-parent-class not correct"
13
+ assert_equal 'test_object', find('form')['data-params-key'], "data-params-key not correct"
14
+
15
+ assert_selector 'input[name="test_object[textfile_ids][]"]'
16
+ end
17
+
18
+ private
19
+ def sign_in
20
+ visit adminpanel.signin_path
21
+ login
22
+ end
23
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adminpanel
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jose Ramon Camacho
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-03-28 00:00:00.000000000 Z
13
+ date: 2016-04-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -424,6 +424,20 @@ dependencies:
424
424
  - - ">="
425
425
  - !ruby/object:Gem::Version
426
426
  version: 1.3.10
427
+ - !ruby/object:Gem::Dependency
428
+ name: byebug
429
+ requirement: !ruby/object:Gem::Requirement
430
+ requirements:
431
+ - - ">="
432
+ - !ruby/object:Gem::Version
433
+ version: '0'
434
+ type: :development
435
+ prerelease: false
436
+ version_requirements: !ruby/object:Gem::Requirement
437
+ requirements:
438
+ - - ">="
439
+ - !ruby/object:Gem::Version
440
+ version: '0'
427
441
  description: |-
428
442
  Gem that focus on making a public site's resources very quickly while being very configurable!,
429
443
  supports facebook sharing, twitter, instagram and google analytics integration
@@ -491,6 +505,7 @@ files:
491
505
  - app/assets/javascripts/adminpanel/sortable.js.coffee
492
506
  - app/assets/javascripts/adminpanel/spinner.js.coffee
493
507
  - app/assets/javascripts/adminpanel/tables.js
508
+ - app/assets/javascripts/adminpanel/trix-upload.coffee
494
509
  - app/assets/javascripts/adminpanel/trix.js.erb
495
510
  - app/assets/stylesheets/adminpanel/_clearfix.css
496
511
  - app/assets/stylesheets/adminpanel/_search-input.scss.erb
@@ -641,6 +656,7 @@ files:
641
656
  - test/dummy/app/controllers/adminpanel/mugs_controller.rb
642
657
  - test/dummy/app/controllers/adminpanel/products_controller.rb
643
658
  - test/dummy/app/controllers/adminpanel/salesmen_controller.rb
659
+ - test/dummy/app/controllers/adminpanel/test_objects_controller.rb
644
660
  - test/dummy/app/controllers/application_controller.rb
645
661
  - test/dummy/app/mailers/.gitkeep
646
662
  - test/dummy/app/models/adminpanel/categorization.rb
@@ -656,6 +672,7 @@ files:
656
672
  - test/dummy/app/models/adminpanel/product.rb
657
673
  - test/dummy/app/models/adminpanel/salesman.rb
658
674
  - test/dummy/app/models/adminpanel/test_object.rb
675
+ - test/dummy/app/models/adminpanel/textfile.rb
659
676
  - test/dummy/app/uploader/adminpanel/file_resourcefile_uploader.rb
660
677
  - test/dummy/app/uploader/adminpanel/photo_uploader.rb
661
678
  - test/dummy/app/uploader/adminpanel/section_uploader.rb
@@ -705,6 +722,7 @@ files:
705
722
  - test/features/shared/form/modal_contents_test.rb
706
723
  - test/features/shared/form/resource_field_test.rb
707
724
  - test/features/shared/form/select_test.rb
725
+ - test/features/shared/form/wysiwyg_test.rb
708
726
  - test/features/shared/resource/edit_test.rb
709
727
  - test/features/shared/resource/index_test.rb
710
728
  - test/features/shared/resource/new_test.rb
@@ -753,7 +771,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
753
771
  requirements:
754
772
  - imagemagick installed
755
773
  rubyforge_project:
756
- rubygems_version: 2.2.2
774
+ rubygems_version: 2.4.5.1
757
775
  signing_key:
758
776
  specification_version: 4
759
777
  summary: Made with <3 by CoDN
@@ -770,6 +788,7 @@ test_files:
770
788
  - test/dummy/app/controllers/adminpanel/mugs_controller.rb
771
789
  - test/dummy/app/controllers/adminpanel/products_controller.rb
772
790
  - test/dummy/app/controllers/adminpanel/salesmen_controller.rb
791
+ - test/dummy/app/controllers/adminpanel/test_objects_controller.rb
773
792
  - test/dummy/app/controllers/application_controller.rb
774
793
  - test/dummy/app/mailers/.gitkeep
775
794
  - test/dummy/app/models/adminpanel/categorization.rb
@@ -785,6 +804,7 @@ test_files:
785
804
  - test/dummy/app/models/adminpanel/product.rb
786
805
  - test/dummy/app/models/adminpanel/salesman.rb
787
806
  - test/dummy/app/models/adminpanel/test_object.rb
807
+ - test/dummy/app/models/adminpanel/textfile.rb
788
808
  - test/dummy/app/uploader/adminpanel/file_resourcefile_uploader.rb
789
809
  - test/dummy/app/uploader/adminpanel/photo_uploader.rb
790
810
  - test/dummy/app/uploader/adminpanel/section_uploader.rb
@@ -834,6 +854,7 @@ test_files:
834
854
  - test/features/shared/form/modal_contents_test.rb
835
855
  - test/features/shared/form/resource_field_test.rb
836
856
  - test/features/shared/form/select_test.rb
857
+ - test/features/shared/form/wysiwyg_test.rb
837
858
  - test/features/shared/resource/edit_test.rb
838
859
  - test/features/shared/resource/index_test.rb
839
860
  - test/features/shared/resource/new_test.rb
@@ -860,4 +881,3 @@ test_files:
860
881
  - test/support/view_case.rb
861
882
  - test/tasks/adminpanel_rake_test.rb
862
883
  - test/test_helper.rb
863
- has_rdoc: