azahara_schema 0.3.5 → 0.3.6
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/lib/azahara_schema/attribute_formatter.rb +13 -13
- data/lib/azahara_schema/schema.rb +8 -6
- data/lib/azahara_schema/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d41cee35775a78e8ef619042baf4a3e44e3b72488d0e6b4be145baf20d3d8175
|
4
|
+
data.tar.gz: ac919eeeb5a76024b2222f60d1afaae85b0c4d3d756c0c63564e3b6d4f8adeb2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9140e0d6cdfa550323172bd59932934ba988818fb8b13f9f580dc55a1e8c5db717820ee0fa2e0420be5fc4a77aee2d234c5bfc407ad836ecfc09f015a943d377
|
7
|
+
data.tar.gz: a09337cfaffcb0f6cb8fae65c6abec8313e9a59cfb1e7f33e9bbaa258aa2db95cce445219e82995922c9db5c74fc83cb9455111b1a7ed20a7a0baa4a387ab007
|
@@ -47,24 +47,29 @@ module AzaharaSchema
|
|
47
47
|
'fa'
|
48
48
|
end
|
49
49
|
|
50
|
-
def
|
51
|
-
val = attribute.value(entity)
|
50
|
+
def human_value(attribute, value, **options)
|
52
51
|
case attribute.type
|
53
52
|
when 'love'
|
54
|
-
attribute.available_values.detect{|l, v| v ==
|
53
|
+
attribute.available_values.detect{|l, v| v == value }.try(:[], 0)
|
55
54
|
when 'list'
|
56
|
-
attribute.attribute_name.human_list_value(
|
55
|
+
attribute.attribute_name.human_list_value(value, options)
|
56
|
+
when 'datetime'
|
57
|
+
value ? l(value) : value
|
57
58
|
else
|
58
|
-
|
59
|
+
value
|
59
60
|
end
|
60
61
|
end
|
61
62
|
|
63
|
+
def attribute_human_value(attribute, entity, **options)
|
64
|
+
human_value(attribute, attribute.value(entity))
|
65
|
+
end
|
66
|
+
|
62
67
|
def formatted_value(attribute, entity, **options)
|
63
68
|
real_formatter(attribute).format_value(attribute, attribute_human_value(attribute, entity), formatting_options(attribute,entity).merge(options))
|
64
69
|
end
|
65
70
|
|
66
71
|
def html_formatted_value(attribute, entity, **options)
|
67
|
-
format_value_html(attribute, attribute
|
72
|
+
format_value_html(attribute, attribute_human_value(attribute, entity, options), formatting_options(attribute,entity).merge(options))
|
68
73
|
end
|
69
74
|
|
70
75
|
def attribute_html_label(attribute, **options)
|
@@ -75,19 +80,14 @@ module AzaharaSchema
|
|
75
80
|
template.content_tag('div', class: 'attribute') do
|
76
81
|
s = ''.html_safe
|
77
82
|
s << template.content_tag('div', attribute_html_label(attribute, options), class: 'label')
|
78
|
-
s << template.content_tag('div',
|
83
|
+
s << template.content_tag('div', html_formatted_value(attribute, entity, options), class: 'value')
|
79
84
|
s
|
80
85
|
end
|
81
86
|
end
|
82
87
|
|
83
88
|
|
84
89
|
def format_value(attribute, unformated_value, **options)
|
85
|
-
|
86
|
-
when 'datetime'
|
87
|
-
unformated_value ? l(unformated_value) : unformated_value
|
88
|
-
else
|
89
|
-
unformated_value
|
90
|
-
end
|
90
|
+
unformated_value
|
91
91
|
end
|
92
92
|
|
93
93
|
def format_value_html(attribute, unformated_value, **options)
|
@@ -32,9 +32,13 @@ module AzaharaSchema
|
|
32
32
|
AzaharaSchema::Schema.new(model, *attributes)
|
33
33
|
end
|
34
34
|
|
35
|
-
def self.attribute_type(model, name)
|
36
|
-
col
|
37
|
-
|
35
|
+
def self.attribute_type(model, name, col=nil)
|
36
|
+
col ||= model.columns_hash[name.to_s]
|
37
|
+
if model.defined_enums[col.name]
|
38
|
+
'list'
|
39
|
+
else
|
40
|
+
col && col.type
|
41
|
+
end
|
38
42
|
end
|
39
43
|
|
40
44
|
def self.attribute(model, name, attr_type=nil)
|
@@ -43,9 +47,7 @@ module AzaharaSchema
|
|
43
47
|
end
|
44
48
|
|
45
49
|
def self.attribute_for_column(model, col, attr_type=nil)
|
46
|
-
attr_type
|
47
|
-
attr_type ||= col.type
|
48
|
-
attribute(model, col.name, attr_type)
|
50
|
+
attribute(model, col.name, attr_type || attribute_type(model, col.name, col) )
|
49
51
|
end
|
50
52
|
|
51
53
|
def self.enabled_filters(*filter_names)
|
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.3.
|
4
|
+
version: 0.3.6
|
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: 2018-
|
11
|
+
date: 2018-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|