glib-web 0.5.20 → 0.5.25

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d1d6528e82e0ce768820820d544d382db8f412e2e0ea2d5e572ab16065f7b173
4
- data.tar.gz: 2c8d52f0b60d4ac9b8253bbc1f7cc67c7172647981b5e036d4bedc306827f97a
3
+ metadata.gz: d08542637c79970affe100bdedd24353ab9fa549c8fdc719e3c47cb51cef2896
4
+ data.tar.gz: 4c7864a098a56b650bc97855a4b8c3251d638bc6f129d0d6997fc26d0f6acf25
5
5
  SHA512:
6
- metadata.gz: 591bb9bb58b8034ee825c49f27483f8b1a756efc586de444c49b9bce35727fac47eb7852511b81dd0762736cdad7fd5972172c74d73d3b8f69218beaead56611
7
- data.tar.gz: b7a9552472085631f0123187103b1667652428f58a45863539e1ca2d8a2ef219b59357655f88abe4c9a2291fda805627ddc9a385b51f69d4bdd04d37aac80c95
6
+ metadata.gz: 1a9a74182efee4e14507965ddbf55f56f0321974938463422d6303286bb81b9c96cf6f12630108afb181f358ff5de1dea68524b85690cebe9a506c9a5625933c
7
+ data.tar.gz: cb2d0dbc95f38b4cbfc2b2957c8bf8c4d96491416464b8e19900dabdbcb7d6e6cef85a9091bd8b2d808d614d3ad5963cd6be1f8d7b988f0d462b2648b20d13b2
@@ -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)
@@ -66,6 +66,7 @@ module Glib::Json::Traversal
66
66
 
67
67
  # Generic menu buttons
68
68
  traverse_multiple view['buttons'], block
69
+ traverse_multiple view['childButtons'], block
69
70
 
70
71
  # Split panel
71
72
  traverse_vertical_content view['left'], block
@@ -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
@@ -16,34 +16,33 @@ module Glib
16
16
  end
17
17
 
18
18
  class Action < JsonUiElement
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
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
@@ -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)
@@ -6,6 +6,36 @@ module Glib
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
@@ -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,6 +2,8 @@ module Glib
2
2
  module JsonUi
3
3
  module ResponseHelper
4
4
  def json_ui_response(json)
5
+ __json_ui_analytics(json)
6
+
5
7
  json.onResponse do
6
8
  response = Response.new(json, self)
7
9
  yield response.action_builder
@@ -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 analytics(value)
36
- if value.is_a?(String)
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
- # Override
45
- def created
46
- if @analyticsEnabled
47
- context = page.context
48
- json.analytics do
49
- content = @analyticsId || (@text || @icon)&.gsub(/\s+/, '_')&.downcase || 'nil'
50
- json.namePrefix [context.controller_name, context.action_name, content].join('_')
51
- end
52
- end
53
- end
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
 
@@ -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
- row.thumbnail title: "Item #{index}"
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
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.20
4
+ version: 0.5.25
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