glib-web 0.5.21 → 0.5.26
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/app/controllers/concerns/glib/analytics/funnel.rb +61 -0
- data/app/controllers/concerns/glib/json/libs.rb +4 -4
- data/app/controllers/concerns/glib/json/ui.rb +11 -0
- data/app/helpers/glib/dynamic_images_helper.rb +7 -4
- data/app/helpers/glib/json_ui/abstract_builder.rb +153 -154
- data/app/helpers/glib/json_ui/action_builder.rb +27 -28
- data/app/helpers/glib/json_ui/analytics_helper.rb +17 -0
- data/app/helpers/glib/json_ui/dynamic_field_builders.rb +4 -4
- data/app/helpers/glib/json_ui/list_builders.rb +3 -0
- data/app/helpers/glib/json_ui/menu_builder.rb +38 -1
- data/app/helpers/glib/json_ui/page_helper.rb +7 -4
- data/app/helpers/glib/json_ui/response_helper.rb +2 -0
- data/app/helpers/glib/json_ui/split_builders.rb +1 -1
- data/app/helpers/glib/json_ui/table_builders.rb +7 -7
- data/app/helpers/glib/json_ui/view_builder.rb +37 -20
- data/app/helpers/glib/json_ui/view_builder/fields.rb +1 -0
- data/app/helpers/glib/json_ui/view_builder/panels.rb +1 -0
- data/app/views/json_ui/garage/forms/pickers.json.jbuilder +4 -3
- data/app/views/json_ui/garage/forms/selects.json.jbuilder +0 -0
- data/app/views/json_ui/garage/lists/_autoload_section.json.jbuilder +7 -1
- data/app/views/json_ui/garage/lists/index.json.jbuilder +3 -0
- data/app/views/json_ui/garage/lists/reordering.json.jbuilder +24 -0
- data/app/views/json_ui/garage/panels/custom.json.jbuilder +2 -2
- data/app/views/json_ui/garage/panels/responsive.json.jbuilder +11 -1
- data/app/views/json_ui/garage/panels/split.json.jbuilder +0 -1
- data/app/views/json_ui/garage/panels/vertical.json.jbuilder +1 -1
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d252c5420953a389ed9f8b0a981f383a66141bdc936229fc9b5c983265d0eef2
|
4
|
+
data.tar.gz: 1dad156eac314b636f0534011afc82f78e6eced5c1f5c5ea07f0ee7d12a44212
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 675bdae2fffceb43ee5b67bf065103cae5804bdc78a74cfd705f1ca08ac09b2186aac5b74f5f47d3c2cee9a48c9c8b67a3ca7b584e0ba362bf832761ba94685d
|
7
|
+
data.tar.gz: 978559ce9fb7e52d5d2119f6cd45da338e9f0c01c76fe72de16afae59ec48ffaaa7f88d0ab9d3ab6276d9afc1572b78a05057d54680b1ee323e507375330f160
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Glib::Analytics
|
2
|
+
module Funnel
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
# include Overrides
|
7
|
+
extend ClassMethods
|
8
|
+
|
9
|
+
helper_method :glib_analytics_feature_segment
|
10
|
+
helper_method :glib_analytics_feature_referer
|
11
|
+
helper_method :glib_analytics_included?
|
12
|
+
end
|
13
|
+
|
14
|
+
# module Overrides
|
15
|
+
|
16
|
+
# # Expose protected method
|
17
|
+
# public # Override
|
18
|
+
# def policy_scope(*args)
|
19
|
+
# super
|
20
|
+
# end
|
21
|
+
# end
|
22
|
+
|
23
|
+
def glib_analytics_included?
|
24
|
+
true
|
25
|
+
end
|
26
|
+
|
27
|
+
def glib_analytics_feature_segment
|
28
|
+
# To be overridden
|
29
|
+
nil
|
30
|
+
end
|
31
|
+
|
32
|
+
def glib_analytics_feature_referer
|
33
|
+
group = request.headers['GApp-Analytics-Referer-Group']
|
34
|
+
action = request.headers['GApp-Analytics-Referer-Action']
|
35
|
+
segment = request.headers['GApp-Analytics-Referer-Segment']
|
36
|
+
placement = request.headers['GApp-Analytics-Referer-Placement']
|
37
|
+
|
38
|
+
if group && action
|
39
|
+
return { group: group, action: action, segment: segment, placement: placement }
|
40
|
+
end
|
41
|
+
|
42
|
+
nil
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
module ClassMethods
|
48
|
+
# def glib_auth_inited?
|
49
|
+
# @@__glib_auth_init ||= false
|
50
|
+
# end
|
51
|
+
|
52
|
+
# def glib_analytics_init
|
53
|
+
# @@__glib_analytics_init = true
|
54
|
+
# end
|
55
|
+
|
56
|
+
# def glib_analytics_inited?
|
57
|
+
# @@__glib_analytics_init ||= false
|
58
|
+
# end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -9,17 +9,17 @@ module Glib::Json::Libs
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def json_ui_app_bundle_id
|
12
|
-
@json_ui_app_bundle_id ||= request.headers['JsonUiApp-Bundle-Id']
|
12
|
+
@json_ui_app_bundle_id ||= request.headers['GApp-Bundle-Id'] || request.headers['JsonUiApp-Bundle-Id']
|
13
13
|
end
|
14
14
|
|
15
15
|
def json_ui_app_build_version
|
16
|
-
@json_ui_app_build_version ||= request.headers['JsonUiApp-Build-Version']
|
16
|
+
@json_ui_app_build_version ||= request.headers['GApp-Build-Version'] || request.headers['JsonUiApp-Build-Version']
|
17
17
|
@json_ui_app_build_version = params[:build_version] if @json_ui_app_build_version.nil? && Rails.env.development? # For easy testing
|
18
18
|
@json_ui_app_build_version
|
19
19
|
end
|
20
20
|
|
21
21
|
def json_ui_app_device_os
|
22
|
-
@json_ui_app_device_os ||= request.headers['JsonUiApp-Device-Os']
|
22
|
+
@json_ui_app_device_os ||= request.headers['GApp-Device-Os'] || request.headers['JsonUiApp-Device-Os']
|
23
23
|
@json_ui_app_device_os = params[:device_os] if @json_ui_app_device_os.nil? && Rails.env.development? # For easy testing
|
24
24
|
@json_ui_app_device_os || 'web'
|
25
25
|
end
|
@@ -59,7 +59,7 @@ module Glib::Json::Libs
|
|
59
59
|
# raise exception
|
60
60
|
# end
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
63
|
def glib_json_handle_500(exception)
|
64
64
|
if json_ui_activated? && Rails.env.production?
|
65
65
|
Rollbar.error(exception) if defined?(Rollbar)
|
@@ -38,6 +38,17 @@ module Glib::Json::Ui
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
+
def json_ui_response_lifecycle_prop
|
42
|
+
prop_name = 'onResponse'
|
43
|
+
if (hash = json_transformation_start).is_a?(Hash) && hash[prop_name] # A valid response
|
44
|
+
if hash[prop_name]['action'] != 'runMultiple'
|
45
|
+
childActions = [hash[prop_name]]
|
46
|
+
hash[prop_name] = { 'action' => 'runMultiple', 'childActions' => childActions }
|
47
|
+
childActions
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
41
52
|
def __json_ui_start(options)
|
42
53
|
@__json_ui_activated = false
|
43
54
|
@__json_ui_rendering = nil
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Glib
|
2
2
|
module DynamicImagesHelper
|
3
3
|
# NOTE: The bucket should probably be set as a parameter for json_libs
|
4
|
-
def
|
4
|
+
def glib_dynamic_image_url(blob_key, width: 100, height: 100, fit: 'clip', bucket: Rails.application.config.try(:aws_s3_bucket), signature_key: nil)
|
5
5
|
return unless blob_key.present?
|
6
6
|
|
7
7
|
full_params_hash = {
|
@@ -10,17 +10,20 @@ module Glib
|
|
10
10
|
w: width,
|
11
11
|
h: height,
|
12
12
|
fit: fit,
|
13
|
-
expires: 1.hours.from_now.to_i
|
13
|
+
# expires: 1.hours.from_now.to_i
|
14
|
+
expires: 1.month.from_now.end_of_month.to_i
|
14
15
|
}
|
16
|
+
|
15
17
|
request_params_hash = full_params_hash.except(:bucket_name, :blob_key)
|
16
18
|
|
17
|
-
if (private_key =
|
19
|
+
if (private_key = signature_key)
|
18
20
|
encryption_service = EncryptionService.new(bucket, private_key)
|
21
|
+
# This produces different signature every time.
|
22
|
+
# TODO: Use digest instead, because we really only need to verify. We don't need to be able to decrypt.
|
19
23
|
signature = encryption_service.encrypt(full_params_hash)
|
20
24
|
request_params_hash = request_params_hash.merge(signature: signature)
|
21
25
|
end
|
22
26
|
|
23
|
-
# TODO: This should probably be set as a parameter for json_libs
|
24
27
|
uri = URI::HTTPS.build(
|
25
28
|
host: 'imageserver-demo.herokuapp.com',
|
26
29
|
path: "/image/#{bucket}/#{blob_key}",
|
@@ -10,7 +10,7 @@ module Glib
|
|
10
10
|
|
11
11
|
private
|
12
12
|
def capitalize_first_letter_and_leave_others_alone(str)
|
13
|
-
str.slice(0,1).capitalize + str.slice(1..-1)
|
13
|
+
str.slice(0, 1).capitalize + str.slice(1..-1)
|
14
14
|
end
|
15
15
|
|
16
16
|
def add_singleton_element(type, name, *args)
|
@@ -19,7 +19,7 @@ module Glib
|
|
19
19
|
args = [yield] if block_given?
|
20
20
|
|
21
21
|
# TODO: consider caching these instances
|
22
|
-
"#{self.class.name}::#{name_components.map{ |str| capitalize_first_letter_and_leave_others_alone(str) }.join('::')}".constantize.new(json, @page).props(*args)
|
22
|
+
"#{self.class.name}::#{name_components.map { |str| capitalize_first_letter_and_leave_others_alone(str) }.join('::')}".constantize.new(json, @page).props(*args)
|
23
23
|
end
|
24
24
|
|
25
25
|
def add_element_to_array(type, name, *args)
|
@@ -29,15 +29,15 @@ module Glib
|
|
29
29
|
end
|
30
30
|
|
31
31
|
# TODO: Consider removing this in favour of non 'v1' suffix
|
32
|
-
def add_singleton_element_v1
|
32
|
+
def add_singleton_element_v1(type, name, *args)
|
33
33
|
name_components = name.to_s.split('_')
|
34
34
|
json.set! type, "#{name_components.join('/')}-v1" if type
|
35
35
|
args = [yield] if block_given?
|
36
|
-
"#{self.class.name}::#{name_components.map{ |str| capitalize_first_letter_and_leave_others_alone(str) }.join('::')}".constantize.new(json, @page).props(*args)
|
36
|
+
"#{self.class.name}::#{name_components.map { |str| capitalize_first_letter_and_leave_others_alone(str) }.join('::')}".constantize.new(json, @page).props(*args)
|
37
37
|
end
|
38
38
|
|
39
39
|
# TODO: Consider removing this in favour of non 'v1' suffix
|
40
|
-
def add_element_to_array_v1
|
40
|
+
def add_element_to_array_v1(type, name, *args)
|
41
41
|
json.child! do
|
42
42
|
add_singleton_element_v1 type, name, *args
|
43
43
|
end
|
@@ -68,219 +68,218 @@ module Glib
|
|
68
68
|
end
|
69
69
|
|
70
70
|
private
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
71
|
+
def self.any(propName)
|
72
|
+
define_method(propName) do |value|
|
73
|
+
json.set! propName, value
|
74
|
+
end
|
75
75
|
end
|
76
|
-
end
|
77
76
|
|
78
|
-
|
79
|
-
|
80
|
-
|
77
|
+
def self.date(propName)
|
78
|
+
define_method(propName) do |value|
|
79
|
+
json.set! propName, value&.to_date
|
81
80
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
81
|
+
# if (value = value&.to_s)
|
82
|
+
# if !Rails.env.production?
|
83
|
+
# raise "Invalid date for #{propName}: #{value}" unless value =~ /^\d{4}-\d{2}-\d{2}$/
|
84
|
+
# end
|
86
85
|
|
87
|
-
|
88
|
-
|
86
|
+
# json.set! propName, value
|
87
|
+
# end
|
88
|
+
end
|
89
89
|
end
|
90
|
-
end
|
91
90
|
|
92
|
-
|
93
|
-
|
94
|
-
|
91
|
+
def self.date_time(propName)
|
92
|
+
define_method(propName) do |value|
|
93
|
+
json.set! propName, value&.to_datetime
|
95
94
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
95
|
+
# if (value = value&.to_s)
|
96
|
+
# if !Rails.env.production?
|
97
|
+
# try Date.parse(value) rescue raise "Invalid date: #{value}"
|
98
|
+
# end
|
100
99
|
|
101
|
-
|
102
|
-
|
100
|
+
# json.set! propName, value
|
101
|
+
# end
|
102
|
+
end
|
103
103
|
end
|
104
|
-
end
|
105
104
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
105
|
+
def self.color(propName)
|
106
|
+
define_method(propName) do |value|
|
107
|
+
if (value = value&.to_s)
|
108
|
+
if !Rails.env.production?
|
109
|
+
if !value.match /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/i
|
110
|
+
raise "Invalid color: #{value}"
|
111
|
+
end
|
112
112
|
end
|
113
|
-
end
|
114
113
|
|
115
|
-
|
114
|
+
json.set! propName, value
|
115
|
+
end
|
116
116
|
end
|
117
117
|
end
|
118
|
-
end
|
119
118
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
119
|
+
def self.length(propName)
|
120
|
+
define_method(propName) do |value|
|
121
|
+
if value
|
122
|
+
if !Rails.env.production?
|
123
|
+
case value
|
124
|
+
when 'matchParent'
|
125
|
+
when 'wrapContent'
|
126
|
+
else
|
127
|
+
if !value.is_a? Integer
|
128
|
+
raise "Invalid length: #{value}"
|
129
|
+
end
|
130
130
|
end
|
131
131
|
end
|
132
|
-
end
|
133
132
|
|
134
|
-
|
133
|
+
json.set! propName, value
|
134
|
+
end
|
135
135
|
end
|
136
136
|
end
|
137
|
-
end
|
138
137
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
138
|
+
def self.string(propName, options = {})
|
139
|
+
define_method(propName) do |value|
|
140
|
+
str = value&.to_s
|
141
|
+
instance_variable_set("@#{propName}", str) if options[:cache]
|
142
|
+
json.set! propName, str
|
143
|
+
end
|
144
144
|
end
|
145
|
-
end
|
146
145
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
146
|
+
# Support either string or dynamic_text hash
|
147
|
+
def self.text(propName, options = {})
|
148
|
+
define_method(propName) do |value|
|
149
|
+
if value.is_a?(Hash)
|
150
|
+
json.set! propName, value
|
151
|
+
else
|
152
|
+
json.set! propName, value&.to_s
|
153
|
+
end
|
154
154
|
end
|
155
155
|
end
|
156
|
-
end
|
157
156
|
|
158
|
-
|
159
|
-
|
160
|
-
|
157
|
+
def self.int(propName)
|
158
|
+
define_method(propName) do |value|
|
159
|
+
json.set! propName, value&.to_i
|
160
|
+
end
|
161
161
|
end
|
162
|
-
end
|
163
162
|
|
164
|
-
|
165
|
-
|
166
|
-
|
163
|
+
def self.float(propName)
|
164
|
+
define_method(propName) do |value|
|
165
|
+
json.set! propName, value&.to_f
|
166
|
+
end
|
167
167
|
end
|
168
|
-
end
|
169
168
|
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
169
|
+
def self.bool(propName, options = {})
|
170
|
+
define_method(propName) do |value|
|
171
|
+
bool = value == true
|
172
|
+
instance_variable_set("@#{propName}", bool) if options[:cache]
|
173
|
+
json.set! propName, bool
|
174
|
+
end
|
175
175
|
end
|
176
|
-
end
|
177
176
|
|
178
|
-
|
179
|
-
|
177
|
+
def self.icon(propName, options = {})
|
178
|
+
define_method(propName) do |value|
|
180
179
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
180
|
+
if value.is_a?(Hash)
|
181
|
+
data = value
|
182
|
+
name = data[:name]
|
183
|
+
else
|
184
|
+
data = {}
|
185
|
+
name = value
|
186
|
+
# data = { material: { name: value } }
|
188
187
|
|
189
|
-
|
188
|
+
# name = value
|
190
189
|
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
end
|
196
|
-
|
197
|
-
json.set!(propName) do
|
198
|
-
if name
|
199
|
-
data[:material] ||= {}
|
200
|
-
data[:material][:name] = name
|
190
|
+
# TODO: deprecated
|
191
|
+
# json.set!(propName) do
|
192
|
+
# json.name name
|
193
|
+
# end
|
201
194
|
end
|
202
195
|
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
196
|
+
json.set!(propName) do
|
197
|
+
if name
|
198
|
+
data[:material] ||= {}
|
199
|
+
data[:material][:name] = name
|
207
200
|
end
|
208
|
-
end
|
209
201
|
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
202
|
+
if (material = data[:material])
|
203
|
+
json.material do
|
204
|
+
json.name material[:name]
|
205
|
+
json.size material[:size] if material[:size]
|
206
|
+
end
|
214
207
|
end
|
215
|
-
end
|
216
208
|
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
209
|
+
if (fa = data[:fa])
|
210
|
+
json.fa do
|
211
|
+
json.name fa[:name]
|
212
|
+
json.size fa[:size] if fa[:size]
|
213
|
+
end
|
221
214
|
end
|
222
|
-
end
|
223
215
|
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
json.badge do
|
229
|
-
json.text badge
|
216
|
+
if (custom = data[:custom])
|
217
|
+
json.custom do
|
218
|
+
json.name custom[:name]
|
219
|
+
json.size custom[:size] if custom[:size]
|
230
220
|
end
|
231
221
|
end
|
232
|
-
end
|
233
222
|
|
234
|
-
|
223
|
+
if (badge = data[:badge])
|
224
|
+
if badge.is_a?(Hash)
|
225
|
+
json.badge badge
|
226
|
+
else
|
227
|
+
json.badge do
|
228
|
+
json.text badge
|
229
|
+
end
|
230
|
+
end
|
231
|
+
end
|
235
232
|
|
236
|
-
|
233
|
+
end
|
237
234
|
|
238
|
-
|
235
|
+
# raise "Invalid properties: #{options.keys}" if options.size > 0
|
239
236
|
|
237
|
+
# instance_variable_set("@#{propName}", name) if options[:cache]
|
238
|
+
|
239
|
+
end
|
240
240
|
end
|
241
|
-
end
|
242
241
|
|
243
|
-
|
244
|
-
|
245
|
-
|
242
|
+
def self.action(propName)
|
243
|
+
define_method(propName) do |value|
|
244
|
+
json.set!(propName) { value.call(page.action_builder) }
|
245
|
+
end
|
246
246
|
end
|
247
|
-
end
|
248
247
|
|
249
|
-
|
250
|
-
|
251
|
-
|
248
|
+
def self.views(propName)
|
249
|
+
define_method(propName) do |value|
|
250
|
+
json.set!(propName) { value.call(page.view_builder) }
|
251
|
+
end
|
252
252
|
end
|
253
|
-
end
|
254
253
|
|
255
|
-
|
256
|
-
|
257
|
-
|
254
|
+
def self.array(propName)
|
255
|
+
define_method(propName) do |value|
|
256
|
+
json.set! propName, value&.to_a
|
257
|
+
end
|
258
258
|
end
|
259
|
-
end
|
260
259
|
|
261
|
-
|
262
|
-
|
263
|
-
|
260
|
+
def self.hash(propName)
|
261
|
+
define_method(propName) do |value|
|
262
|
+
json.set! propName, value
|
263
|
+
end
|
264
264
|
end
|
265
|
-
end
|
266
265
|
|
267
|
-
|
268
|
-
|
266
|
+
def self.singleton_array(singletonName, arrayName)
|
267
|
+
array arrayName
|
269
268
|
|
270
|
-
|
271
|
-
|
269
|
+
define_method(singletonName) do |value|
|
270
|
+
json.set! arrayName, [value]
|
271
|
+
end
|
272
272
|
end
|
273
|
-
end
|
274
273
|
|
275
|
-
|
276
|
-
|
277
|
-
|
274
|
+
def self.panels_builder(propName, *panelNames)
|
275
|
+
define_method(propName) do |value|
|
276
|
+
value.call(page.content_builder(panelNames))
|
277
|
+
end
|
278
278
|
end
|
279
|
-
end
|
280
279
|
|
281
|
-
|
282
|
-
|
283
|
-
|
280
|
+
def created
|
281
|
+
# To be overridden
|
282
|
+
end
|
284
283
|
|
285
284
|
end
|
286
285
|
end
|
@@ -16,34 +16,33 @@ module Glib
|
|
16
16
|
end
|
17
17
|
|
18
18
|
class Action < JsonUiElement
|
19
|
-
def analytics(value)
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
# Override
|
29
|
-
def created
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
end
|
46
|
-
|
19
|
+
# def analytics(value)
|
20
|
+
# if value.is_a?(String)
|
21
|
+
# @analyticsEnabled = true
|
22
|
+
# @analyticsId = value
|
23
|
+
# else
|
24
|
+
# @analyticsEnabled = value == true
|
25
|
+
# end
|
26
|
+
# end
|
27
|
+
|
28
|
+
# # Override
|
29
|
+
# def created
|
30
|
+
# if @analyticsEnabled
|
31
|
+
# suffix = @analyticsId
|
32
|
+
# # TODO: recognize_path() needs `method` as a second argument for POST request
|
33
|
+
# if suffix.nil? && @url && (route = Rails.application.routes.recognize_path(@url))
|
34
|
+
# suffix = "#{route[:controller]}_#{route[:action]}"
|
35
|
+
# end
|
36
|
+
|
37
|
+
# if suffix
|
38
|
+
# json.analytics do
|
39
|
+
# json.track :event
|
40
|
+
# json.nameSuffix suffix
|
41
|
+
# end
|
42
|
+
# end
|
43
|
+
|
44
|
+
# end
|
45
|
+
# end
|
47
46
|
end
|
48
47
|
|
49
48
|
### Action definitions
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Glib
|
2
|
+
module JsonUi
|
3
|
+
module AnalyticsHelper
|
4
|
+
def __json_ui_analytics(json)
|
5
|
+
if try(:glib_analytics_included?)
|
6
|
+
json.analytics do
|
7
|
+
json.feature do
|
8
|
+
json.group controller_name
|
9
|
+
json.action action_name
|
10
|
+
json.segment glib_analytics_feature_segment
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module Glib
|
2
2
|
module JsonUi
|
3
3
|
module DynamicFieldBuilders
|
4
|
-
|
4
|
+
|
5
5
|
class Group < AbstractBuilder
|
6
|
-
def initialize
|
6
|
+
def initialize(json, page, template)
|
7
7
|
super json, page
|
8
8
|
@template = template
|
9
9
|
end
|
@@ -15,11 +15,11 @@ module Glib
|
|
15
15
|
|
16
16
|
def template(options = {})
|
17
17
|
# json.template do
|
18
|
-
|
18
|
+
page.vertical_content(options)
|
19
19
|
# end
|
20
20
|
end
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
@@ -35,6 +35,9 @@ module Glib
|
|
35
35
|
action :onLongPress
|
36
36
|
icon :icon
|
37
37
|
bool :avatar
|
38
|
+
action :onReorder
|
39
|
+
string :paramNameForFormData
|
40
|
+
string :paramNameForNewIndex
|
38
41
|
|
39
42
|
# # NOTE: Experimental. Still deciding whether this needs to be a full blown panel or
|
40
43
|
# # an array of badges (with relevant properties, e.g. text, color, etc)
|
@@ -1,11 +1,41 @@
|
|
1
1
|
module Glib
|
2
2
|
module JsonUi
|
3
3
|
class MenuBuilder < AbstractBuilder
|
4
|
-
def method_missing
|
4
|
+
def method_missing(m, *args)
|
5
5
|
add_element_to_array_v1 nil, m, *args
|
6
6
|
end
|
7
7
|
|
8
8
|
class MenuItem < JsonUiElement
|
9
|
+
hash :analytics
|
10
|
+
|
11
|
+
# def initialize(json, page)
|
12
|
+
# super(json, page)
|
13
|
+
|
14
|
+
# # Can be improved by making it configurable site-wide.
|
15
|
+
# @analyticsEnabled = true
|
16
|
+
# end
|
17
|
+
|
18
|
+
# def analytics(value)
|
19
|
+
# if value.is_a?(Hash)
|
20
|
+
# @analyticsEnabled = true
|
21
|
+
# @analyticsId = value
|
22
|
+
# else
|
23
|
+
# @analyticsEnabled = value == true
|
24
|
+
# end
|
25
|
+
# end
|
26
|
+
|
27
|
+
# # Override
|
28
|
+
# def created
|
29
|
+
# json.analytics do
|
30
|
+
# if @analyticsEnabled
|
31
|
+
# if @analyticsId
|
32
|
+
# json.placement @analyticsId
|
33
|
+
# end
|
34
|
+
# else
|
35
|
+
# json.disabled true
|
36
|
+
# end
|
37
|
+
# end
|
38
|
+
# end
|
9
39
|
end
|
10
40
|
|
11
41
|
class Button < MenuItem
|
@@ -21,7 +51,10 @@ module Glib
|
|
21
51
|
end
|
22
52
|
end
|
23
53
|
|
54
|
+
# Override
|
24
55
|
def created
|
56
|
+
super
|
57
|
+
|
25
58
|
json.type 'button'
|
26
59
|
end
|
27
60
|
end
|
@@ -29,6 +62,8 @@ module Glib
|
|
29
62
|
class Divider < MenuItem
|
30
63
|
# Override
|
31
64
|
def created
|
65
|
+
super
|
66
|
+
|
32
67
|
json.type 'divider'
|
33
68
|
end
|
34
69
|
end
|
@@ -39,6 +74,8 @@ module Glib
|
|
39
74
|
|
40
75
|
# Override
|
41
76
|
def created
|
77
|
+
super
|
78
|
+
|
42
79
|
json.type 'label'
|
43
80
|
end
|
44
81
|
end
|
@@ -3,10 +3,10 @@ module Glib
|
|
3
3
|
module PageHelper
|
4
4
|
def json_ui_garage_url(options = {})
|
5
5
|
Glib::Web::Engine.routes.url_helpers.json_ui_garage_url(options.merge(
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
protocol: request.protocol,
|
7
|
+
host: request.host,
|
8
|
+
port: request.port,
|
9
|
+
_render: params[:_render], format: params[:format])
|
10
10
|
)
|
11
11
|
end
|
12
12
|
|
@@ -17,6 +17,9 @@ module Glib
|
|
17
17
|
# TODO: Remove the block
|
18
18
|
def json_ui_page(json, &block)
|
19
19
|
@__json_ui_page ||= Page.new(json, self)
|
20
|
+
|
21
|
+
__json_ui_analytics(json)
|
22
|
+
|
20
23
|
block&.call @__json_ui_page
|
21
24
|
@__json_ui_page
|
22
25
|
end
|
@@ -2,10 +2,10 @@ module Glib
|
|
2
2
|
module JsonUi
|
3
3
|
module TableBuilders
|
4
4
|
class Template < AbstractBuilder
|
5
|
-
def method_missing
|
5
|
+
def method_missing(m, *args)
|
6
6
|
add_element_to_array 'template', m, *args
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
class AbstractTemplate < JsonUiElement
|
10
10
|
|
11
11
|
def editButtons(block)
|
@@ -13,9 +13,9 @@ module Glib
|
|
13
13
|
block.call page.menu_builder
|
14
14
|
end
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
class Default < AbstractTemplate
|
20
20
|
views :cellViews
|
21
21
|
action :onClick
|
@@ -23,9 +23,9 @@ module Glib
|
|
23
23
|
array :colStyles
|
24
24
|
end
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
class Section < AbstractBuilder
|
28
|
-
def initialize
|
28
|
+
def initialize(json, page, template)
|
29
29
|
super json, page
|
30
30
|
@template = template
|
31
31
|
end
|
@@ -68,7 +68,7 @@ module Glib
|
|
68
68
|
# end
|
69
69
|
|
70
70
|
end
|
71
|
-
|
71
|
+
|
72
72
|
end
|
73
73
|
end
|
74
74
|
end
|
@@ -28,29 +28,46 @@ module Glib
|
|
28
28
|
length :height
|
29
29
|
color :backgroundColor
|
30
30
|
hash :padding
|
31
|
-
# array :styleClasses
|
32
31
|
singleton_array :styleClass, :styleClasses
|
33
32
|
hash :showIf
|
33
|
+
hash :analytics
|
34
34
|
|
35
|
-
def
|
36
|
-
|
37
|
-
@analyticsEnabled = true
|
38
|
-
@analyticsId = value
|
39
|
-
else
|
40
|
-
@analyticsEnabled = value == true
|
41
|
-
end
|
42
|
-
end
|
35
|
+
# def initialize(json, page)
|
36
|
+
# super(json, page)
|
43
37
|
|
44
|
-
#
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
38
|
+
# # Can be improved by making it configurable site-wide.
|
39
|
+
# @analyticsEnabled = true
|
40
|
+
# end
|
41
|
+
|
42
|
+
# def analytics(value)
|
43
|
+
# if value.is_a?(String)
|
44
|
+
# @analyticsEnabled = true
|
45
|
+
# @analyticsId = value
|
46
|
+
# else
|
47
|
+
# @analyticsEnabled = value == true
|
48
|
+
# end
|
49
|
+
# end
|
50
|
+
|
51
|
+
# # Override
|
52
|
+
# def created
|
53
|
+
# # if @analyticsEnabled
|
54
|
+
# # context = page.context
|
55
|
+
# # json.analytics do
|
56
|
+
# # content = @analyticsId || (@text || @icon)&.gsub(/\s+/, '_')&.downcase || 'nil'
|
57
|
+
# # json.namePrefix [context.controller_name, context.action_name, content].join('_')
|
58
|
+
# # end
|
59
|
+
# # end
|
60
|
+
|
61
|
+
# json.analytics do
|
62
|
+
# if @analyticsEnabled
|
63
|
+
# if @analyticsId
|
64
|
+
# json.placement @analyticsId
|
65
|
+
# end
|
66
|
+
# else
|
67
|
+
# json.disabled true
|
68
|
+
# end
|
69
|
+
# end
|
70
|
+
# end
|
54
71
|
|
55
72
|
end
|
56
73
|
|
@@ -182,4 +199,4 @@ module Glib
|
|
182
199
|
|
183
200
|
end
|
184
201
|
end
|
185
|
-
end
|
202
|
+
end
|
@@ -2,7 +2,7 @@ json.title 'Forms'
|
|
2
2
|
|
3
3
|
json_ui_page json do |page|
|
4
4
|
render "#{@path_prefix}/nav_menu", json: json, page: page
|
5
|
-
|
5
|
+
|
6
6
|
page.form url: json_ui_garage_url(path: 'forms/generic_post'), method: 'post', padding: glib_json_padding_body, childViews: ->(form) do
|
7
7
|
form.h2 text: 'Radio Group'
|
8
8
|
form.spacer height: 6
|
@@ -12,7 +12,7 @@ json_ui_page json do |page|
|
|
12
12
|
group.fields_radio value: 'M', label: 'Male'
|
13
13
|
group.fields_radio value: 'F', label: 'Female'
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
form.spacer height: 20
|
17
17
|
form.h2 text: 'Single Checkbox'
|
18
18
|
form.fields_check name: 'user[age_range]', value: '16+', checkValue: '16+', uncheckValue: '0-16', label: 'I am over 16 (has default value)'
|
@@ -36,7 +36,8 @@ json_ui_page json do |page|
|
|
36
36
|
form.spacer height: 6
|
37
37
|
form.fields_latLong name: 'user[address]', width: 'matchParent', label: 'Type an address', value: 'Sydney Harbour Bridge',
|
38
38
|
latitudeField: { name: 'user[latitude]', label: 'Lat', value: -33.8523063, readOnly: true },
|
39
|
-
longitudeField: { name: 'user[longitude]', label: 'Long', value: 151.21078710000006, readOnly: true }
|
39
|
+
longitudeField: { name: 'user[longitude]', label: 'Long', value: 151.21078710000006, readOnly: true },
|
40
|
+
zoomField: { name: 'user[zoom]', label: 'Zoom' }
|
40
41
|
|
41
42
|
form.spacer height: 20
|
42
43
|
form.fields_submit text: 'Submit'
|
File without changes
|
@@ -17,6 +17,12 @@ section.rows builder: ->(row) do
|
|
17
17
|
batch_count = 30
|
18
18
|
batch_count.times do |i|
|
19
19
|
index = page_index * batch_count + i
|
20
|
-
|
20
|
+
if local_assigns[:reorder]
|
21
|
+
row.thumbnail title: "Item #{index}", onReorder: ->(action) do
|
22
|
+
action.dialogs_notification title: "Item #{index}"
|
23
|
+
end, paramNameForFormData: 'message', paramNameForNewIndex: 'new_index'
|
24
|
+
else
|
25
|
+
row.thumbnail title: "Item #{index}"
|
26
|
+
end
|
21
27
|
end
|
22
28
|
end
|
@@ -23,6 +23,9 @@ json_ui_page json do |page|
|
|
23
23
|
template.thumbnail title: 'Autoload All', onClick: ->(action) do
|
24
24
|
action.windows_open url: json_ui_garage_url(path: 'lists/autoload_all')
|
25
25
|
end
|
26
|
+
template.thumbnail title: 'Reordering', onClick: ->(action) do
|
27
|
+
action.windows_open url: json_ui_garage_url(path: 'lists/reordering')
|
28
|
+
end
|
26
29
|
end
|
27
30
|
|
28
31
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
page_index = params[:page].to_i
|
2
|
+
next_page = {
|
3
|
+
url: json_ui_garage_url(path: 'lists/reordering', page: page_index + 1, section_only: 'v1'),
|
4
|
+
autoload: 'asNeeded'
|
5
|
+
}
|
6
|
+
|
7
|
+
page = json_ui_page json
|
8
|
+
|
9
|
+
if params[:section_only].present?
|
10
|
+
json.nextPage next_page if page_index < 3
|
11
|
+
json.sections do
|
12
|
+
json.child! do
|
13
|
+
render 'json_ui/garage/lists/autoload_section', page: page, page_index: page_index, reorder: true
|
14
|
+
end
|
15
|
+
end
|
16
|
+
else
|
17
|
+
json.title 'Lists'
|
18
|
+
|
19
|
+
render "#{@path_prefix}/nav_menu", json: json, page: page
|
20
|
+
|
21
|
+
page.list nextPage: next_page, firstSection: ->(section) do
|
22
|
+
render 'json_ui/garage/lists/autoload_section', page: page, page_index: page_index, reorder: true
|
23
|
+
end
|
24
|
+
end
|
@@ -2,13 +2,13 @@ json.title 'Panels'
|
|
2
2
|
|
3
3
|
json_ui_page json do |page|
|
4
4
|
render "#{@path_prefix}/nav_menu", json: json, page: page
|
5
|
-
|
5
|
+
|
6
6
|
page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
|
7
7
|
scroll.h2 text: 'Thumbnail Template'
|
8
8
|
scroll.spacer height: 6
|
9
9
|
scroll.panels_custom template: 'thumbnail', width: 'matchParent', backgroundColor: '#fafafa',
|
10
10
|
data: { imageUrl: glib_json_image_standard_url, title: 'Title', subtitle: 'Use the same template from list templates' }
|
11
|
-
|
11
|
+
|
12
12
|
scroll.spacer height: 20
|
13
13
|
scroll.h2 text: 'Non-existent Template'
|
14
14
|
scroll.spacer height: 6
|
@@ -71,7 +71,7 @@ page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
|
|
71
71
|
# responsive.panels_column lg: { cols: 4 }, childViews: ->(column) do
|
72
72
|
# column.button width: 'matchParent', text: '2'
|
73
73
|
# end
|
74
|
-
|
74
|
+
|
75
75
|
responsive.panels_column lg: { cols: 8 }, backgroundColor: '#c3cad2', childViews: ->(column) do
|
76
76
|
column.button text: '1'
|
77
77
|
end
|
@@ -84,5 +84,15 @@ page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
|
|
84
84
|
end
|
85
85
|
|
86
86
|
scroll.spacer height: 20
|
87
|
+
scroll.h2 text: 'With onClick'
|
88
|
+
scroll.spacer height: 6
|
89
|
+
scroll.panels_responsive backgroundColor: '#c3cad2', padding: { left: 20, right: 20, top: 10, bottom: 10 }, childViews: ->(responsive) do
|
90
|
+
responsive.h4 text: 'Heading'
|
91
|
+
responsive.label text: 'Label'
|
92
|
+
end, onClick: ->(action) do
|
93
|
+
action.windows_open url: json_ui_garage_url(path: 'home/blank')
|
94
|
+
end
|
95
|
+
|
96
|
+
scroll.spacer height: 20
|
87
97
|
|
88
98
|
end
|
@@ -2,7 +2,7 @@ json.title 'Panels'
|
|
2
2
|
|
3
3
|
json_ui_page json do |page|
|
4
4
|
render "#{@path_prefix}/nav_menu", json: json, page: page
|
5
|
-
|
5
|
+
|
6
6
|
page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
|
7
7
|
scroll.h1 text: 'Basic'
|
8
8
|
scroll.panels_vertical backgroundColor: '#b3bac2', childViews: ->(panel) do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glib-web
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.26
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ''
|
@@ -64,6 +64,7 @@ executables: []
|
|
64
64
|
extensions: []
|
65
65
|
extra_rdoc_files: []
|
66
66
|
files:
|
67
|
+
- app/controllers/concerns/glib/analytics/funnel.rb
|
67
68
|
- app/controllers/concerns/glib/auth/policy.rb
|
68
69
|
- app/controllers/concerns/glib/json/dynamic_text.rb
|
69
70
|
- app/controllers/concerns/glib/json/libs.rb
|
@@ -84,6 +85,7 @@ files:
|
|
84
85
|
- app/helpers/glib/json_ui/action_builder/sheets.rb
|
85
86
|
- app/helpers/glib/json_ui/action_builder/snackbars.rb
|
86
87
|
- app/helpers/glib/json_ui/action_builder/windows.rb
|
88
|
+
- app/helpers/glib/json_ui/analytics_helper.rb
|
87
89
|
- app/helpers/glib/json_ui/dynamic_field_builders.rb
|
88
90
|
- app/helpers/glib/json_ui/generic_builders.rb
|
89
91
|
- app/helpers/glib/json_ui/list_builders.rb
|
@@ -149,6 +151,7 @@ files:
|
|
149
151
|
- app/views/json_ui/garage/lists/edit_actions.json.jbuilder
|
150
152
|
- app/views/json_ui/garage/lists/fab.json.jbuilder
|
151
153
|
- app/views/json_ui/garage/lists/index.json.jbuilder
|
154
|
+
- app/views/json_ui/garage/lists/reordering.json.jbuilder
|
152
155
|
- app/views/json_ui/garage/lists/templating.json.jbuilder
|
153
156
|
- app/views/json_ui/garage/notifications/android_post.json.jbuilder
|
154
157
|
- app/views/json_ui/garage/notifications/index.json.jbuilder
|