adminpanel 2.6.0 → 2.6.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -94,7 +94,7 @@ module Adminpanel
94
94
  def enum_field(method, *args)
95
95
  select(
96
96
  method,
97
- self.object.class.send(method.pluralize).map{|option, value|
97
+ self.object.class.send(method.to_s.pluralize).map{|option, value|
98
98
  [I18n.t("#{self.object.class.name.demodulize.downcase}.#{option}"), option]
99
99
  },
100
100
  *args
@@ -216,14 +216,15 @@ module Adminpanel
216
216
  end
217
217
 
218
218
  def datepickerize_base(method, options)
219
- options.reverse_merge! 'value' => Time.now.strftime("%d-%m-%Y")
219
+ options['data'] ||= {}
220
+ options['data']['date_format'] ||= 'dd-mm-yyyy'
221
+ options['data']['date'] ||= Time.now.strftime("%d-%m-%Y")
222
+ options['value'] = options['data']['date']
223
+
220
224
  @template.content_tag(
221
225
  :div,
222
226
  class: 'input-append date datepicker datepicker-basic',
223
- data: {
224
- date_format: 'dd-mm-yyyy',
225
- date: options['value']
226
- }
227
+ data: options['data']
227
228
  ) do
228
229
  text_field_original(method, options) +
229
230
  (
@@ -1,3 +1,3 @@
1
1
  module Adminpanel
2
- VERSION = '2.6.0'
2
+ VERSION = '2.6.1'
3
3
  end
@@ -30,7 +30,7 @@ module Adminpanel
30
30
  end
31
31
 
32
32
  def class_name
33
- "#{lower_name.capitalize}"
33
+ "#{reference_name.camelize}file"
34
34
  end
35
35
 
36
36
  end
@@ -40,7 +40,7 @@ module Adminpanel
40
40
  "app/models/adminpanel/#{resource_migrating}.rb",
41
41
  after: ' ['
42
42
  ) do
43
- indent ("\n" + get_attribute_hash + ','), 8
43
+ indent ("\n" + form_attributes_hash + ','), 8
44
44
  end
45
45
  end
46
46
 
@@ -23,6 +23,9 @@ module Adminpanel
23
23
  when 'wysiwyg'
24
24
  fields_to_delete << attribute
25
25
  fields << attribute.split(':').first + ':' + 'text'
26
+ when 'datepicker'
27
+ fields_to_delete << attribute
28
+ fields << attribute.split(':').first + ':' + 'date'
26
29
  when 'belongs_to'
27
30
  fields_to_delete << attribute
28
31
  fields << attribute.split(':').first + ':' + 'select'
@@ -76,7 +76,7 @@ module Adminpanel
76
76
  end.join(",\n")
77
77
  end
78
78
 
79
- def get_attribute_hash
79
+ def form_attributes_hash
80
80
  fields.map do |attribute|
81
81
  assign_attributes_variables(attribute)
82
82
  send(@attr_type + '_form_hash')
@@ -107,8 +107,8 @@ module Adminpanel
107
107
  attribute_hash(@attr_field, 'boolean')
108
108
  end
109
109
 
110
- def datepicker_form_hash
111
- attribute_hash(@attr_field, 'datepicker')
110
+ def date_form_hash
111
+ attribute_hash(@attr_field, 'date')
112
112
  end
113
113
 
114
114
  def file_field_form_hash
@@ -148,7 +148,7 @@ module Adminpanel
148
148
  end
149
149
 
150
150
  def model_type(model_name)
151
- "'options' => Proc.new { |object|\n" +
151
+ "'options' => Proc.new { |#{resource_name.downcase}_instance|\n" +
152
152
  indent("Adminpanel::#{model_name}.all\n", 2) +
153
153
  '}'
154
154
  end
@@ -12,7 +12,7 @@ module Adminpanel
12
12
 
13
13
  def self.form_attributes
14
14
  [
15
- <%= indent(get_attribute_hash, 8) + "," %>
15
+ <%= indent(form_attributes_hash, 8) + "," %>
16
16
  <%= indent(file_field_form_hash, 8) if has_gallery? %>
17
17
  ]
18
18
  end
@@ -13,20 +13,29 @@ class GalleryGeneratorTest < Rails::Generators::TestCase
13
13
  /t.integer :product_id/,
14
14
  /create_table :adminpanel_productfiles/
15
15
  )
16
- end
17
-
18
- def test_the_generation_of_the_productfile
19
- run_generator ['Product']
20
16
  assert_file(
21
17
  'app/models/adminpanel/productfile.rb',
22
18
  /mount_uploader :file, ProductfileUploader/
23
19
  )
20
+ assert_file(
21
+ 'app/uploaders/adminpanel/productfile_uploader.rb'
22
+ )
24
23
  end
25
24
 
26
- def test_the_generation_of_the_productfile_uploader
27
- run_generator ['Product']
25
+ def test_the_generation_of_the_snake_cases_migration
26
+ run_generator ['snake_case']
27
+ assert_migration(
28
+ 'db/migrate/create_adminpanel_snake_casefiles.rb',
29
+ /t.integer :snake_case_id/,
30
+ /create_table :adminpanel_snake_casefiles/
31
+ )
28
32
  assert_file(
29
- 'app/uploaders/adminpanel/productfile_uploader.rb'
33
+ 'app/models/adminpanel/snake_casefile.rb',
34
+ /mount_uploader :file, SnakeCasefileUploader/
35
+ )
36
+ assert_file(
37
+ 'app/uploaders/adminpanel/snake_casefile_uploader.rb',
38
+ /class SnakeCase/
30
39
  )
31
40
  end
32
41
 
@@ -7,6 +7,7 @@ class ResourceGeneratorTest < Rails::Generators::TestCase
7
7
  setup :prepare_destination
8
8
 
9
9
  def after_setup
10
+ # Create setup dynamically to test over it.
10
11
  Dir.mkdir Rails.root.join('tmp', 'generators', 'config')
11
12
  Dir.mkdir Rails.root.join('tmp', 'generators', 'config', 'initializers')
12
13
  File.open Rails.root.join('tmp', 'generators', 'config', 'initializers', 'adminpanel_setup.rb'), 'w' do |f|
@@ -139,7 +140,7 @@ class ResourceGeneratorTest < Rails::Generators::TestCase
139
140
  /'quantity' => {/,
140
141
  /'type' => 'number_field',/,
141
142
  /'date' => {/,
142
- /'type' => 'datepicker',/,
143
+ /'type' => 'date',/,
143
144
  /'admin_postfiles' => {/,
144
145
  /'type' => 'adminpanel_file_field',/,
145
146
  /'category_ids' => {/,
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: 2.6.0
4
+ version: 2.6.1
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: 2015-06-01 00:00:00.000000000 Z
13
+ date: 2015-07-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -38,14 +38,14 @@ dependencies:
38
38
  requirements:
39
39
  - - '='
40
40
  - !ruby/object:Gem::Version
41
- version: 4.1.0
41
+ version: 4.2.7
42
42
  type: :runtime
43
43
  prerelease: false
44
44
  version_requirements: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - '='
47
47
  - !ruby/object:Gem::Version
48
- version: 4.1.0
48
+ version: 4.2.7
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: bcrypt
51
51
  requirement: !ruby/object:Gem::Requirement
@@ -92,20 +92,20 @@ dependencies:
92
92
  requirements:
93
93
  - - "~>"
94
94
  - !ruby/object:Gem::Version
95
- version: 1.10.1
95
+ version: 1.11.0
96
96
  - - ">="
97
97
  - !ruby/object:Gem::Version
98
- version: 1.10.1
98
+ version: 1.11.0
99
99
  type: :runtime
100
100
  prerelease: false
101
101
  version_requirements: !ruby/object:Gem::Requirement
102
102
  requirements:
103
103
  - - "~>"
104
104
  - !ruby/object:Gem::Version
105
- version: 1.10.1
105
+ version: 1.11.0
106
106
  - - ">="
107
107
  - !ruby/object:Gem::Version
108
- version: 1.10.1
108
+ version: 1.11.0
109
109
  - !ruby/object:Gem::Dependency
110
110
  name: friendly_id
111
111
  requirement: !ruby/object:Gem::Requirement
@@ -130,28 +130,28 @@ dependencies:
130
130
  name: google-api-client
131
131
  requirement: !ruby/object:Gem::Requirement
132
132
  requirements:
133
- - - '='
133
+ - - "~>"
134
134
  - !ruby/object:Gem::Version
135
- version: 0.8.2
135
+ version: 0.8.6
136
136
  type: :runtime
137
137
  prerelease: false
138
138
  version_requirements: !ruby/object:Gem::Requirement
139
139
  requirements:
140
- - - '='
140
+ - - "~>"
141
141
  - !ruby/object:Gem::Version
142
- version: 0.8.2
142
+ version: 0.8.6
143
143
  - !ruby/object:Gem::Dependency
144
144
  name: instagram
145
145
  requirement: !ruby/object:Gem::Requirement
146
146
  requirements:
147
- - - '='
147
+ - - "~>"
148
148
  - !ruby/object:Gem::Version
149
149
  version: 1.1.3
150
150
  type: :runtime
151
151
  prerelease: false
152
152
  version_requirements: !ruby/object:Gem::Requirement
153
153
  requirements:
154
- - - '='
154
+ - - "~>"
155
155
  - !ruby/object:Gem::Version
156
156
  version: 1.1.3
157
157
  - !ruby/object:Gem::Dependency
@@ -240,30 +240,42 @@ dependencies:
240
240
  name: jquery-rails
241
241
  requirement: !ruby/object:Gem::Requirement
242
242
  requirements:
243
- - - '='
243
+ - - "~>"
244
+ - !ruby/object:Gem::Version
245
+ version: 4.0.4
246
+ - - ">="
244
247
  - !ruby/object:Gem::Version
245
- version: 4.0.3
248
+ version: 4.0.4
246
249
  type: :runtime
247
250
  prerelease: false
248
251
  version_requirements: !ruby/object:Gem::Requirement
249
252
  requirements:
250
- - - '='
253
+ - - "~>"
254
+ - !ruby/object:Gem::Version
255
+ version: 4.0.4
256
+ - - ">="
251
257
  - !ruby/object:Gem::Version
252
- version: 4.0.3
258
+ version: 4.0.4
253
259
  - !ruby/object:Gem::Dependency
254
260
  name: jquery-ui-rails
255
261
  requirement: !ruby/object:Gem::Requirement
256
262
  requirements:
257
- - - '='
263
+ - - "~>"
264
+ - !ruby/object:Gem::Version
265
+ version: 5.0.5
266
+ - - ">="
258
267
  - !ruby/object:Gem::Version
259
- version: 5.0.3
268
+ version: 5.0.5
260
269
  type: :runtime
261
270
  prerelease: false
262
271
  version_requirements: !ruby/object:Gem::Requirement
263
272
  requirements:
264
- - - '='
273
+ - - "~>"
274
+ - !ruby/object:Gem::Version
275
+ version: 5.0.5
276
+ - - ">="
265
277
  - !ruby/object:Gem::Version
266
- version: 5.0.3
278
+ version: 5.0.5
267
279
  - !ruby/object:Gem::Dependency
268
280
  name: sass-rails
269
281
  requirement: !ruby/object:Gem::Requirement