forest_liana 1.6.16 → 1.6.17
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3af7548b5ab0b459b0ee602c39b2816a86bbfc7a
|
|
4
|
+
data.tar.gz: 99a284d5170879dbba02bdead5eadfae178ee127
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4f82f6c9bfce7ef74c3d693b04b5864deae6d0e147d9a7cec37978f3cc141ce21e66b413da5208d408c53a2dcaec4e04cd1f0baf95bca84c7d4dd4f7be545a14
|
|
7
|
+
data.tar.gz: 590fd61a4eee69af5d80410932469db157769d888df45af0b3c741b91b3c3e06c029461ae7d913c1ba774afa4441c7d67de845ee1a7c0b1beb4064d472541465
|
|
@@ -128,7 +128,8 @@ module ForestLiana
|
|
|
128
128
|
def extract_smart_fields_values
|
|
129
129
|
# NOTICE: Look for some Smart Field setters and apply them if any.
|
|
130
130
|
ForestLiana.schema_for_resource(@resource).fields.each do |field|
|
|
131
|
-
if field.try(:[], :set)
|
|
131
|
+
if field.try(:[], :set) &&
|
|
132
|
+
@params['data']['attributes'].has_key?(field[:field])
|
|
132
133
|
# WARNING: The Smart Fields setters may override other changes.
|
|
133
134
|
@attributes = field[:set].call(@attributes,
|
|
134
135
|
@params['data']['attributes'][field[:field]])
|
|
@@ -229,6 +229,8 @@ module ForestLiana
|
|
|
229
229
|
schema = { field: column.name, type: get_type_for(column) }
|
|
230
230
|
add_enum_values_if_is_enum(schema, column)
|
|
231
231
|
add_enum_values_if_is_sti_model(schema, column)
|
|
232
|
+
add_default_value(schema, column)
|
|
233
|
+
add_validations(schema, column)
|
|
232
234
|
end
|
|
233
235
|
|
|
234
236
|
def get_schema_for_association(association)
|
|
@@ -294,6 +296,98 @@ module ForestLiana
|
|
|
294
296
|
column.name == @model.inheritance_column) || column.name == 'type'
|
|
295
297
|
end
|
|
296
298
|
|
|
299
|
+
def add_default_value(column_schema, column)
|
|
300
|
+
# TODO: detect/introspect the attribute default value with Rails 5
|
|
301
|
+
# ex: attribute :email, :string, default: 'arnaud@forestadmin.com'
|
|
302
|
+
column_schema['default-value'] = column.default if column.default
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
def add_validations(column_schema, column)
|
|
306
|
+
if @model._validators? && @model._validators[column.name.to_sym].size > 0
|
|
307
|
+
column_schema[:validations] = []
|
|
308
|
+
|
|
309
|
+
@model._validators[column.name.to_sym].each do |validator|
|
|
310
|
+
case validator
|
|
311
|
+
when ActiveRecord::Validations::PresenceValidator
|
|
312
|
+
column_schema[:validations] << {
|
|
313
|
+
type: 'is present',
|
|
314
|
+
message: validator.options[:message]
|
|
315
|
+
}
|
|
316
|
+
column_schema['is-required'] = true
|
|
317
|
+
when ActiveModel::Validations::NumericalityValidator
|
|
318
|
+
validator.options.each do |option, value|
|
|
319
|
+
case option
|
|
320
|
+
when :greater_than, :greater_than_or_equal_to
|
|
321
|
+
column_schema[:validations] << {
|
|
322
|
+
type: 'is greater than',
|
|
323
|
+
value: value,
|
|
324
|
+
message: validator.options[:message]
|
|
325
|
+
}
|
|
326
|
+
when :less_than, :less_than_or_equal_to
|
|
327
|
+
column_schema[:validations] << {
|
|
328
|
+
type: 'is less than',
|
|
329
|
+
value: value,
|
|
330
|
+
message: validator.options[:message]
|
|
331
|
+
}
|
|
332
|
+
end
|
|
333
|
+
end
|
|
334
|
+
when ActiveModel::Validations::LengthValidator
|
|
335
|
+
validator.options.each do |option, value|
|
|
336
|
+
case option
|
|
337
|
+
when :minimum
|
|
338
|
+
column_schema[:validations] << {
|
|
339
|
+
type: 'is longer than',
|
|
340
|
+
value: value,
|
|
341
|
+
message: validator.options[:message]
|
|
342
|
+
}
|
|
343
|
+
when :maximum
|
|
344
|
+
column_schema[:validations] << {
|
|
345
|
+
type: 'is shorter than',
|
|
346
|
+
value: value,
|
|
347
|
+
message: validator.options[:message]
|
|
348
|
+
}
|
|
349
|
+
when :is
|
|
350
|
+
column_schema[:validations] << {
|
|
351
|
+
type: 'is longer than',
|
|
352
|
+
value: value,
|
|
353
|
+
message: validator.options[:message]
|
|
354
|
+
}
|
|
355
|
+
column_schema[:validations] << {
|
|
356
|
+
type: 'is shorter than',
|
|
357
|
+
value: value,
|
|
358
|
+
message: validator.options[:message]
|
|
359
|
+
}
|
|
360
|
+
end
|
|
361
|
+
end
|
|
362
|
+
when ActiveModel::Validations::FormatValidator
|
|
363
|
+
validator.options.each do |option, value|
|
|
364
|
+
case option
|
|
365
|
+
when :with
|
|
366
|
+
options = /\?([imx]){0,3}/.match(validator.options[:with].to_s)
|
|
367
|
+
options = options && options[1] ? options[1] : ''
|
|
368
|
+
regex = value.source
|
|
369
|
+
|
|
370
|
+
# NOTICE: Transform a Ruby regex into a JS one
|
|
371
|
+
regex = regex.sub('\\A' , '^').sub('\\Z' , '$').sub('\\z' , '$')
|
|
372
|
+
|
|
373
|
+
column_schema[:validations] << {
|
|
374
|
+
type: 'is like',
|
|
375
|
+
value: "/#{regex}/#{options}",
|
|
376
|
+
message: validator.options[:message]
|
|
377
|
+
}
|
|
378
|
+
end
|
|
379
|
+
end
|
|
380
|
+
end
|
|
381
|
+
end
|
|
382
|
+
|
|
383
|
+
if column_schema[:validations].size == 0
|
|
384
|
+
column_schema.delete(:validations)
|
|
385
|
+
end
|
|
386
|
+
end
|
|
387
|
+
|
|
388
|
+
column_schema
|
|
389
|
+
end
|
|
390
|
+
|
|
297
391
|
def get_ref_for(association)
|
|
298
392
|
if association.options[:polymorphic] == true
|
|
299
393
|
'*.id'
|
|
@@ -33,7 +33,7 @@ module ForestLiana
|
|
|
33
33
|
private
|
|
34
34
|
|
|
35
35
|
def analyze_model?(model)
|
|
36
|
-
|
|
36
|
+
model && model.table_exists? && !SchemaUtils.habtm?(model) &&
|
|
37
37
|
SchemaUtils.model_included?(model) && !SchemaUtils.sti_child?(model)
|
|
38
38
|
end
|
|
39
39
|
|
data/lib/forest_liana/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: forest_liana
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.6.
|
|
4
|
+
version: 1.6.17
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sandro Munda
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-08-
|
|
11
|
+
date: 2017-08-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -16,14 +16,14 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
19
|
+
version: '4.0'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
26
|
+
version: '4.0'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: jsonapi-serializers
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -122,8 +122,9 @@ dependencies:
|
|
|
122
122
|
- - ">="
|
|
123
123
|
- !ruby/object:Gem::Version
|
|
124
124
|
version: '0'
|
|
125
|
-
description:
|
|
126
|
-
admin
|
|
125
|
+
description: Forest is a modern admin interface that works on all major web frameworks.
|
|
126
|
+
forest_liana is the gem that makes Forest admin work on any Rails application (Rails
|
|
127
|
+
>= 4.0).
|
|
127
128
|
email:
|
|
128
129
|
- sandro@munda.me
|
|
129
130
|
executables: []
|
|
@@ -318,7 +319,7 @@ rubyforge_project:
|
|
|
318
319
|
rubygems_version: 2.5.1
|
|
319
320
|
signing_key:
|
|
320
321
|
specification_version: 4
|
|
321
|
-
summary:
|
|
322
|
+
summary: Official Rails Liana for Forest
|
|
322
323
|
test_files:
|
|
323
324
|
- test/dummy/app/assets/javascripts/application.js
|
|
324
325
|
- test/dummy/app/assets/stylesheets/application.css
|