phlexi-display 0.0.3 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/phlexi/display/base.rb +23 -7
- data/lib/phlexi/display/builder.rb +77 -20
- data/lib/phlexi/display/components/association.rb +41 -0
- data/lib/phlexi/display/components/base.rb +1 -0
- data/lib/phlexi/display/components/color.rb +20 -0
- data/lib/phlexi/display/components/concerns/displays_value.rb +33 -17
- data/lib/phlexi/display/components/date_time.rb +14 -14
- data/lib/phlexi/display/components/email.rb +43 -0
- data/lib/phlexi/display/components/enum.rb +17 -0
- data/lib/phlexi/display/components/integer.rb +17 -0
- data/lib/phlexi/display/components/json.rb +25 -0
- data/lib/phlexi/display/components/password.rb +23 -0
- data/lib/phlexi/display/components/placeholder.rb +1 -1
- data/lib/phlexi/display/components/time.rb +15 -0
- data/lib/phlexi/display/components/url.rb +44 -0
- data/lib/phlexi/display/html.rb +15 -0
- data/lib/phlexi/display/options/inferred_types.rb +29 -0
- data/lib/phlexi/display/theme.rb +30 -16
- data/lib/phlexi/display/version.rb +1 -1
- data/lib/phlexi/display.rb +3 -6
- metadata +16 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f519ac0a922ec274d4a45f66208e470d807f7d2fc34f9154ca6758c0de77b8c
|
4
|
+
data.tar.gz: d0a493ad4678d4d41ae0b0e06cdd53b510d72208e45c0fe59d1c351c5392dd62
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1ac7dfb74665e852aa8e39f14b2dc85583ba8201da09cb22f6821147e7538b9503035285c285ad7dd530ade7b0e5ab9df6f02c4f0b7d5ef3594295235592b5e
|
7
|
+
data.tar.gz: e4a83a95a323eecbdfca20af2601b9291311b9292eae6de6888b3279ba52889bdf0d09b8988d0972377660215a8a10fad5d6eeda4daa0dbbbdbc630dc385a803
|
data/lib/phlexi/display/base.rb
CHANGED
@@ -15,10 +15,18 @@ module Phlexi
|
|
15
15
|
#
|
16
16
|
# @attr_reader [Symbol] key The display's key, derived from the record or explicitly set
|
17
17
|
# @attr_reader [ActiveModel::Model, nil] object The display's associated object
|
18
|
-
class Base <
|
18
|
+
class Base < Phlexi::Display::HTML
|
19
19
|
class Namespace < Phlexi::Field::Structure::Namespace; end
|
20
20
|
|
21
|
-
class Builder < Builder; end
|
21
|
+
class Builder < Phlexi::Display::Builder; end
|
22
|
+
|
23
|
+
def self.inline(*, **, &block)
|
24
|
+
raise ArgumentError, "block is required" unless block
|
25
|
+
|
26
|
+
new(*, **) do |f|
|
27
|
+
f.instance_exec(&block)
|
28
|
+
end
|
29
|
+
end
|
22
30
|
|
23
31
|
attr_reader :key, :object
|
24
32
|
|
@@ -33,7 +41,6 @@ module Phlexi
|
|
33
41
|
# @option options [Class] :namespace_klass Custom namespace class
|
34
42
|
# @option options [Class] :builder_klass Custom field builder class
|
35
43
|
def initialize(record, attributes: {}, **options)
|
36
|
-
@display_class = options.delete(:class)
|
37
44
|
@attributes = attributes
|
38
45
|
@namespace_klass = options.delete(:namespace_klass) || self.class::Namespace
|
39
46
|
@builder_klass = options.delete(:builder_klass) || self.class::Builder
|
@@ -46,8 +53,8 @@ module Phlexi
|
|
46
53
|
# Renders the display template.
|
47
54
|
#
|
48
55
|
# @return [void]
|
49
|
-
def view_template
|
50
|
-
display_template
|
56
|
+
def view_template(&)
|
57
|
+
display_wrapper { display_template(&) }
|
51
58
|
end
|
52
59
|
|
53
60
|
# Executes the display's content block.
|
@@ -55,7 +62,7 @@ module Phlexi
|
|
55
62
|
#
|
56
63
|
# @return [void]
|
57
64
|
def display_template
|
58
|
-
|
65
|
+
yield if block_given?
|
59
66
|
end
|
60
67
|
|
61
68
|
protected
|
@@ -92,10 +99,13 @@ module Phlexi
|
|
92
99
|
def initialize_namespace
|
93
100
|
@namespace = namespace_klass.root(key, object: object, builder_klass: builder_klass)
|
94
101
|
end
|
102
|
+
|
95
103
|
# Retrieves the display's CSS classes.
|
96
104
|
#
|
97
105
|
# @return [String] The display's CSS classes
|
98
|
-
|
106
|
+
def display_class
|
107
|
+
themed(:base)
|
108
|
+
end
|
99
109
|
|
100
110
|
# Generates the display attributes hash.
|
101
111
|
#
|
@@ -106,6 +116,12 @@ module Phlexi
|
|
106
116
|
class: display_class
|
107
117
|
}, attributes)
|
108
118
|
end
|
119
|
+
|
120
|
+
def display_wrapper(&)
|
121
|
+
div(**display_attributes) do
|
122
|
+
yield
|
123
|
+
end
|
124
|
+
end
|
109
125
|
end
|
110
126
|
end
|
111
127
|
end
|
@@ -5,13 +5,9 @@ require "phlex"
|
|
5
5
|
module Phlexi
|
6
6
|
module Display
|
7
7
|
# Builder class is responsible for building display fields with various options and components.
|
8
|
-
#
|
9
|
-
# @attr_reader [Structure::DOM] dom The DOM structure for the field.
|
10
|
-
# @attr_reader [Hash] options Options for the field.
|
11
|
-
# @attr_reader [Object] object The object associated with the field.
|
12
|
-
# @attr_reader [Hash] attributes Attributes for the field.
|
13
|
-
# @attr_accessor [Object] value The value of the field.
|
14
8
|
class Builder < Phlexi::Field::Builder
|
9
|
+
include Phlexi::Display::Options::InferredTypes
|
10
|
+
|
15
11
|
# Creates a label tag for the field.
|
16
12
|
#
|
17
13
|
# @param attributes [Hash] Additional attributes for the label.
|
@@ -43,14 +39,15 @@ module Phlexi
|
|
43
39
|
def string_tag(**, &)
|
44
40
|
create_component(Components::String, :string, **, &)
|
45
41
|
end
|
42
|
+
alias_method :search_tag, :string_tag
|
46
43
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
44
|
+
def text_tag(**, &)
|
45
|
+
create_component(Components::String, :text, **, &)
|
46
|
+
end
|
47
|
+
|
48
|
+
def phone_tag(**, &)
|
49
|
+
create_component(Components::String, :phone, **, &)
|
50
|
+
end
|
54
51
|
|
55
52
|
# Creates a number display tag for the field.
|
56
53
|
#
|
@@ -60,6 +57,18 @@ module Phlexi
|
|
60
57
|
create_component(Components::Number, :number, **, &)
|
61
58
|
end
|
62
59
|
|
60
|
+
def integer_tag(**, &)
|
61
|
+
create_component(Components::Integer, :integer, **, &)
|
62
|
+
end
|
63
|
+
|
64
|
+
def json_tag(**, &)
|
65
|
+
create_component(Components::JSON, :json, **, &)
|
66
|
+
end
|
67
|
+
|
68
|
+
def hstore_tag(**, &)
|
69
|
+
create_component(Components::JSON, :hstore, **, &)
|
70
|
+
end
|
71
|
+
|
63
72
|
# Creates a datetime display for the field.
|
64
73
|
#
|
65
74
|
# @param attributes [Hash] Additional attributes for the datetime display.
|
@@ -68,6 +77,14 @@ module Phlexi
|
|
68
77
|
create_component(Components::DateTime, :datetime, **, &)
|
69
78
|
end
|
70
79
|
|
80
|
+
def date_tag(**, &)
|
81
|
+
create_component(Components::DateTime, :date, **, &)
|
82
|
+
end
|
83
|
+
|
84
|
+
def time_tag(**, &)
|
85
|
+
create_component(Components::Time, :time, **, &)
|
86
|
+
end
|
87
|
+
|
71
88
|
# # Creates a boolean display tag for the field.
|
72
89
|
# #
|
73
90
|
# # @param attributes [Hash] Additional attributes for the boolean display.
|
@@ -76,13 +93,53 @@ module Phlexi
|
|
76
93
|
# create_component(Components::Boolean, :boolean, **, &)
|
77
94
|
# end
|
78
95
|
|
79
|
-
#
|
80
|
-
#
|
81
|
-
#
|
82
|
-
#
|
83
|
-
|
84
|
-
|
85
|
-
|
96
|
+
# Creates a color display tag for the field.
|
97
|
+
#
|
98
|
+
# @param attributes [Hash] Additional attributes for the color display.
|
99
|
+
# @return [Components::Color] The color component.
|
100
|
+
def color_tag(**, &)
|
101
|
+
create_component(Components::Color, :color, **, &)
|
102
|
+
end
|
103
|
+
|
104
|
+
# Creates a password display tag for the field.
|
105
|
+
#
|
106
|
+
# @param attributes [Hash] Additional attributes for the password display.
|
107
|
+
# @return [Components::Password] The password component.
|
108
|
+
def password_tag(**, &)
|
109
|
+
create_component(Components::Password, :password, **, &)
|
110
|
+
end
|
111
|
+
|
112
|
+
# Creates a enum display tag for the field.
|
113
|
+
#
|
114
|
+
# @param attributes [Hash] Additional attributes for the enum display.
|
115
|
+
# @return [Components::Enum] The enum component.
|
116
|
+
def enum_tag(**, &)
|
117
|
+
create_component(Components::Enum, :enum, **, &)
|
118
|
+
end
|
119
|
+
|
120
|
+
# Creates a email display tag for the field.
|
121
|
+
#
|
122
|
+
# @param attributes [Hash] Additional attributes for the email display.
|
123
|
+
# @return [Components::Email] The email component.
|
124
|
+
def email_tag(**, &)
|
125
|
+
create_component(Components::Email, :email, **, &)
|
126
|
+
end
|
127
|
+
|
128
|
+
# Creates a url display tag for the field.
|
129
|
+
#
|
130
|
+
# @param attributes [Hash] Additional attributes for the url display.
|
131
|
+
# @return [Components::Url] The url component.
|
132
|
+
def url_tag(**, &)
|
133
|
+
create_component(Components::Url, :url, **, &)
|
134
|
+
end
|
135
|
+
|
136
|
+
# Creates an association display tag for the field.
|
137
|
+
#
|
138
|
+
# @param attributes [Hash] Additional attributes for the association display.
|
139
|
+
# @return [Components::Association] The association component.
|
140
|
+
def association_tag(**, &)
|
141
|
+
create_component(Components::Association, :association, **, &)
|
142
|
+
end
|
86
143
|
|
87
144
|
# # Creates an attachment display tag for the field.
|
88
145
|
# #
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Phlexi
|
4
|
+
module Display
|
5
|
+
module Components
|
6
|
+
class Association < Base
|
7
|
+
include Concerns::DisplaysValue
|
8
|
+
|
9
|
+
def render_value(value)
|
10
|
+
p(**attributes) {
|
11
|
+
display_name_of(value)
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
protected
|
16
|
+
|
17
|
+
def display_name_of(obj, separator: ", ")
|
18
|
+
return unless obj.present?
|
19
|
+
|
20
|
+
# Retrieve the value from a predefined list
|
21
|
+
%i[to_label name title].each do |method|
|
22
|
+
name = obj.public_send(method) if obj.respond_to?(method)
|
23
|
+
return name if name.present?
|
24
|
+
end
|
25
|
+
|
26
|
+
# Maybe this is a record?
|
27
|
+
if (primary_key = Phlexi::Field.object_primary_key(obj))
|
28
|
+
return "#{obj.class.model_name.human} ##{primary_key}"
|
29
|
+
end
|
30
|
+
|
31
|
+
# Oh well. Just convert it to a string.
|
32
|
+
obj.to_s
|
33
|
+
end
|
34
|
+
|
35
|
+
def normalize_value(value)
|
36
|
+
value
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Phlexi
|
4
|
+
module Display
|
5
|
+
module Components
|
6
|
+
class Color < Base
|
7
|
+
include Concerns::DisplaysValue
|
8
|
+
|
9
|
+
def render_value(value)
|
10
|
+
div(**attributes) {
|
11
|
+
div(class: themed(:color_indicator), style: "background-color: #{value};") {
|
12
|
+
whitespace
|
13
|
+
}
|
14
|
+
p { value }
|
15
|
+
}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -6,11 +6,34 @@ module Phlexi
|
|
6
6
|
module Concerns
|
7
7
|
module DisplaysValue
|
8
8
|
def view_template
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
return render(field.placeholder_tag(**@placeholder_attributes)) unless field.has_value?
|
10
|
+
|
11
|
+
if field.multiple? && field.value.respond_to?(:each)
|
12
|
+
wrapped {
|
13
|
+
field.value.each { |value|
|
14
|
+
value = normalize_value(value)
|
15
|
+
render_value(value)
|
16
|
+
}
|
17
|
+
}
|
12
18
|
else
|
13
|
-
|
19
|
+
wrapped {
|
20
|
+
value = normalize_value(field.value)
|
21
|
+
render_value(value)
|
22
|
+
}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def wrapped(&)
|
27
|
+
div(
|
28
|
+
id: attributes.delete(:id),
|
29
|
+
class: tokens(component_name, "value_wrapper", themed(:value_wrapper), themed(:"#{component_name}_value_wrapper")),
|
30
|
+
&
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
def render_values(values)
|
35
|
+
values.each do |value|
|
36
|
+
render_value(normalize_value(value))
|
14
37
|
end
|
15
38
|
end
|
16
39
|
|
@@ -19,7 +42,6 @@ module Phlexi
|
|
19
42
|
# @return [String] the formatted field value for display.
|
20
43
|
def render_value(value)
|
21
44
|
raise NotImplementedError, "#{self.class}#render_value"
|
22
|
-
# format_value()
|
23
45
|
end
|
24
46
|
|
25
47
|
protected
|
@@ -31,18 +53,12 @@ module Phlexi
|
|
31
53
|
attributes[:id] = field.dom.id if attributes[:id] == "#{field.dom.id}_#{component_name}"
|
32
54
|
end
|
33
55
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
# end
|
41
|
-
# end
|
42
|
-
|
43
|
-
# def format_array_value(array)
|
44
|
-
# array.map { |item| format_single_value(item) }.join(", ")
|
45
|
-
# end
|
56
|
+
def build_component_class
|
57
|
+
return if attributes[:class] == false
|
58
|
+
|
59
|
+
super
|
60
|
+
attributes[:class] = tokens(component_name, "value", attributes[:class].sub(component_name, ""))
|
61
|
+
end
|
46
62
|
|
47
63
|
def normalize_value(value)
|
48
64
|
value.to_s
|
@@ -11,8 +11,7 @@ module Phlexi
|
|
11
11
|
# @param value [String, Date, Time, DateTime] The value to be rendered
|
12
12
|
# @return [void]
|
13
13
|
def render_value(value)
|
14
|
-
|
15
|
-
p(**attributes) { formatted_value }
|
14
|
+
p(**attributes) { value }
|
16
15
|
end
|
17
16
|
|
18
17
|
protected
|
@@ -20,27 +19,28 @@ module Phlexi
|
|
20
19
|
def build_attributes
|
21
20
|
super
|
22
21
|
|
23
|
-
@options = {
|
24
|
-
|
25
|
-
}.merge(attributes.delete(:options) || {}).compact
|
22
|
+
@options = attributes.delete(:options) || {}
|
23
|
+
@formats = Array(@options.delete(:format)).compact + default_formats
|
26
24
|
end
|
27
25
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
def format_value(value)
|
27
|
+
@formats.each do |fmt|
|
28
|
+
return I18n.l(value, **@options, format: fmt)
|
29
|
+
rescue
|
30
|
+
nil
|
31
|
+
end
|
32
32
|
end
|
33
33
|
|
34
|
-
def
|
35
|
-
:long
|
34
|
+
def default_formats
|
35
|
+
[:long]
|
36
36
|
end
|
37
37
|
|
38
38
|
def normalize_value(value)
|
39
39
|
case value
|
40
|
-
when
|
41
|
-
value
|
40
|
+
when ::DateTime, ::Date, ::Time
|
41
|
+
format_value(value)
|
42
42
|
else
|
43
|
-
|
43
|
+
value.to_s
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Phlexi
|
4
|
+
module Display
|
5
|
+
module Components
|
6
|
+
class Email < Base
|
7
|
+
include Concerns::DisplaysValue
|
8
|
+
|
9
|
+
def render_value(value)
|
10
|
+
a(**attributes, href: "mailto:#{value}", target: "_blank") {
|
11
|
+
icon
|
12
|
+
plain value
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
protected
|
17
|
+
|
18
|
+
def icon
|
19
|
+
icon_theme = themed(:prefixed_icon)
|
20
|
+
svg(
|
21
|
+
xmlns: "http://www.w3.org/2000/svg",
|
22
|
+
width: icon_theme || "24",
|
23
|
+
height: icon_theme || "24",
|
24
|
+
class: icon_theme,
|
25
|
+
viewbox: "0 0 24 24",
|
26
|
+
fill: "none",
|
27
|
+
stroke: "currentColor",
|
28
|
+
stroke_width: "2",
|
29
|
+
stroke_linecap: "round",
|
30
|
+
stroke_linejoin: "round"
|
31
|
+
) do |s|
|
32
|
+
s.path(stroke: "none", d: "M0 0h24v24H0z", fill: "none")
|
33
|
+
s.path(
|
34
|
+
d:
|
35
|
+
"M3 7a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v10a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-10z"
|
36
|
+
)
|
37
|
+
s.path(d: "M3 7l9 6l9 -6")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
module Phlexi
|
6
|
+
module Display
|
7
|
+
module Components
|
8
|
+
class JSON < Base
|
9
|
+
include Concerns::DisplaysValue
|
10
|
+
|
11
|
+
def render_value(value)
|
12
|
+
pre(**attributes) {
|
13
|
+
value
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def normalize_value(value)
|
20
|
+
::JSON.pretty_generate(value)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Phlexi
|
4
|
+
module Display
|
5
|
+
module Components
|
6
|
+
class Password < Base
|
7
|
+
include Concerns::DisplaysValue
|
8
|
+
|
9
|
+
def render_value(value)
|
10
|
+
p(**attributes) {
|
11
|
+
value
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
protected
|
16
|
+
|
17
|
+
def normalize_value(value)
|
18
|
+
"••••••••"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Phlexi
|
4
|
+
module Display
|
5
|
+
module Components
|
6
|
+
class Url < Base
|
7
|
+
include Concerns::DisplaysValue
|
8
|
+
|
9
|
+
def render_value(value)
|
10
|
+
a(**attributes, href: value, target: "_blank") {
|
11
|
+
icon
|
12
|
+
plain value
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
protected
|
17
|
+
|
18
|
+
def icon
|
19
|
+
icon_theme = themed(:prefixed_icon)
|
20
|
+
svg(
|
21
|
+
xmlns: "http://www.w3.org/2000/svg",
|
22
|
+
width: icon_theme || "24",
|
23
|
+
height: icon_theme || "24",
|
24
|
+
class: icon_theme,
|
25
|
+
viewbox: "0 0 24 24",
|
26
|
+
fill: "none",
|
27
|
+
stroke: "currentColor",
|
28
|
+
stroke_width: "2",
|
29
|
+
stroke_linecap: "round",
|
30
|
+
stroke_linejoin: "round"
|
31
|
+
) do |s|
|
32
|
+
s.path(stroke: "none", d: "M0 0h24v24H0z", fill: "none")
|
33
|
+
s.path(d: "M9 15l6 -6")
|
34
|
+
s.path(d: "M11 6l.463 -.536a5 5 0 0 1 7.071 7.072l-.534 .464")
|
35
|
+
s.path(
|
36
|
+
d:
|
37
|
+
"M13 18l-.397 .534a5.068 5.068 0 0 1 -7.127 0a4.972 4.972 0 0 1 0 -7.071l.524 -.463"
|
38
|
+
)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Phlexi
|
2
|
+
module Display
|
3
|
+
class HTML < (defined?(::ApplicationComponent) ? ::ApplicationComponent : Phlex::HTML)
|
4
|
+
module Behaviour
|
5
|
+
protected
|
6
|
+
|
7
|
+
def themed(component)
|
8
|
+
Phlexi::Display::Theme.instance.resolve_theme(component)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
include Behaviour
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Phlexi
|
4
|
+
module Display
|
5
|
+
module Options
|
6
|
+
module InferredTypes
|
7
|
+
private
|
8
|
+
|
9
|
+
def infer_field_component
|
10
|
+
case inferred_field_type
|
11
|
+
when :string, :text
|
12
|
+
infer_string_field_type || inferred_field_type
|
13
|
+
when :float, :decimal
|
14
|
+
:number
|
15
|
+
when :json, :jsonb
|
16
|
+
:json
|
17
|
+
# when :attachment, :binary
|
18
|
+
# :attachment
|
19
|
+
# end
|
20
|
+
when :integer, :association, :hstore, :date, :time, :datetime
|
21
|
+
inferred_field_type
|
22
|
+
else
|
23
|
+
:string
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/phlexi/display/theme.rb
CHANGED
@@ -1,21 +1,35 @@
|
|
1
1
|
module Phlexi
|
2
2
|
module Display
|
3
|
-
class Theme
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
3
|
+
class Theme < Phlexi::Field::Theme
|
4
|
+
def self.theme
|
5
|
+
@theme ||= {
|
6
|
+
base: nil,
|
7
|
+
label: nil,
|
8
|
+
description: nil,
|
9
|
+
placeholder: nil,
|
10
|
+
value_wrapper: nil,
|
11
|
+
string: nil,
|
12
|
+
text: :string,
|
13
|
+
phone: :string,
|
14
|
+
number: :string,
|
15
|
+
integer: :string,
|
16
|
+
datetime: :string,
|
17
|
+
date: :datetime,
|
18
|
+
time: :datetime,
|
19
|
+
association: :string,
|
20
|
+
attachment: :string,
|
21
|
+
color: :string,
|
22
|
+
color_icon: :string,
|
23
|
+
email: :string,
|
24
|
+
url: :email,
|
25
|
+
json: :string,
|
26
|
+
hstore: :json,
|
27
|
+
password: :string,
|
28
|
+
enum: :string,
|
29
|
+
prefixed_icon: nil,
|
30
|
+
link: nil,
|
31
|
+
wrapper: nil
|
32
|
+
}.freeze
|
19
33
|
end
|
20
34
|
end
|
21
35
|
end
|
data/lib/phlexi/display.rb
CHANGED
@@ -12,20 +12,17 @@ module Phlexi
|
|
12
12
|
loader.inflector.inflect(
|
13
13
|
"phlexi-display" => "Phlexi",
|
14
14
|
"phlexi" => "Phlexi",
|
15
|
-
"
|
15
|
+
"html" => "HTML",
|
16
|
+
"json" => "JSON"
|
16
17
|
)
|
17
18
|
loader.push_dir(File.expand_path("..", __dir__))
|
18
19
|
loader.setup
|
19
20
|
end
|
20
21
|
|
21
|
-
COMPONENT_BASE = (defined?(::ApplicationComponent) ? ::ApplicationComponent : Phlex::HTML)
|
22
|
-
|
23
|
-
NIL_VALUE = :__i_phlexi_display_nil_value_i__
|
24
|
-
|
25
22
|
class Error < StandardError; end
|
26
23
|
end
|
27
24
|
end
|
28
25
|
|
29
26
|
def Phlexi.Display(...)
|
30
|
-
Phlexi::Display::Base.
|
27
|
+
Phlexi::Display::Base.inline(...)
|
31
28
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phlexi-display
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Froelich
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-09-
|
11
|
+
date: 2024-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: phlex
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.11'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: phlexi-field
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: activesupport
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -53,7 +53,7 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: zeitwerk
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
@@ -200,16 +200,27 @@ files:
|
|
200
200
|
- lib/phlexi/display.rb
|
201
201
|
- lib/phlexi/display/base.rb
|
202
202
|
- lib/phlexi/display/builder.rb
|
203
|
+
- lib/phlexi/display/components/association.rb
|
203
204
|
- lib/phlexi/display/components/base.rb
|
205
|
+
- lib/phlexi/display/components/color.rb
|
204
206
|
- lib/phlexi/display/components/concerns/displays_value.rb
|
205
207
|
- lib/phlexi/display/components/date_time.rb
|
206
208
|
- lib/phlexi/display/components/description.rb
|
209
|
+
- lib/phlexi/display/components/email.rb
|
210
|
+
- lib/phlexi/display/components/enum.rb
|
207
211
|
- lib/phlexi/display/components/hint.rb
|
212
|
+
- lib/phlexi/display/components/integer.rb
|
213
|
+
- lib/phlexi/display/components/json.rb
|
208
214
|
- lib/phlexi/display/components/label.rb
|
209
215
|
- lib/phlexi/display/components/number.rb
|
216
|
+
- lib/phlexi/display/components/password.rb
|
210
217
|
- lib/phlexi/display/components/placeholder.rb
|
211
218
|
- lib/phlexi/display/components/string.rb
|
219
|
+
- lib/phlexi/display/components/time.rb
|
220
|
+
- lib/phlexi/display/components/url.rb
|
212
221
|
- lib/phlexi/display/components/wrapper.rb
|
222
|
+
- lib/phlexi/display/html.rb
|
223
|
+
- lib/phlexi/display/options/inferred_types.rb
|
213
224
|
- lib/phlexi/display/theme.rb
|
214
225
|
- lib/phlexi/display/version.rb
|
215
226
|
- sig/phlexi/display.rbs
|