azahara_schema 0.1.3 → 0.1.5
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: 8f7f9fca28c48e48db64c1fff3f830700b6e3c52
|
4
|
+
data.tar.gz: e0fbdebd3f9656fbb739684d4d37da76a8825d84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6804635de61f3adf1ebefec3476052195dd507231083906f163abe8e0dd80a6e41dc2518216f561de9a132117bb759c25b481616d0ddac4ea43141d9b8666cf
|
7
|
+
data.tar.gz: d9d8df57a99ce9a9cae33299015448153f688dd68a5d023847c1c33e14b55f72143c23ff486d8f2841f1999fb4a187b7caf3424e10a81375921007645416a376
|
@@ -7,7 +7,7 @@ module AzaharaSchema
|
|
7
7
|
|
8
8
|
def filter_field(schema, filter)
|
9
9
|
case filter.format.format_name
|
10
|
-
when 'list'
|
10
|
+
when 'list', 'love'
|
11
11
|
select :f, filter.filter_name, options_for_select( list_values_for_select(filter), schema.value_for(filter.filter_name) ), {include_blank: true}, class: 'form-control value-field'
|
12
12
|
else
|
13
13
|
text_field :f, filter.filter_name, value: schema.value_for(filter.filter_name), class: 'form-control value-field'
|
@@ -17,8 +17,12 @@ module AzaharaSchema
|
|
17
17
|
# translates values to list_values
|
18
18
|
# TODO: not needed to do it for every value - for example districts are not translatable
|
19
19
|
def list_values_for_select(attribute)
|
20
|
-
attribute.
|
21
|
-
|
20
|
+
if attribute.format.format_name == 'list'
|
21
|
+
attribute.available_values.collect do |l, val|
|
22
|
+
[t(l, scope: [:activerecord, :attributes, attribute.model.model_name.i18n_key, attribute.name.to_s.pluralize], default: l.to_s), val]
|
23
|
+
end
|
24
|
+
else
|
25
|
+
attribute.available_values
|
22
26
|
end
|
23
27
|
end
|
24
28
|
|
@@ -156,7 +156,10 @@ module AzaharaSchema
|
|
156
156
|
|
157
157
|
def available_associations
|
158
158
|
@available_associations ||= model.reflect_on_all_associations.select do |association|
|
159
|
-
association.klass != model &&
|
159
|
+
association.klass != model &&
|
160
|
+
!association.options[:polymorphic] &&
|
161
|
+
!association_path.include?( association.name.to_s.singularize.to_sym ) &&
|
162
|
+
!association_path.include?( association.name.to_s.pluralize.to_sym )
|
160
163
|
end.collect do |association|
|
161
164
|
AzaharaSchema::Schema.schema_for(association.klass, parent_schema: self, association: association)
|
162
165
|
end
|
@@ -203,7 +206,9 @@ module AzaharaSchema
|
|
203
206
|
end
|
204
207
|
|
205
208
|
def as_json(options={})
|
206
|
-
entities.as_json(build_json_options!(options))
|
209
|
+
res_ary = entities.as_json(build_json_options!(options))
|
210
|
+
columns.each{|col| res_ary.each{|attr_hash| attr_hash[col.name] = col.available_values.detect{|l, v| v == attr_hash[col.name] }.try(:[], 0) } if col.type == 'love' }
|
211
|
+
res_ary
|
207
212
|
end
|
208
213
|
|
209
214
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: azahara_schema
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ondřej Ezr
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|