glib-web 0.5.49 → 0.5.55

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: de169b420305a05364d54456a0673cd84551e04ada3db96d93fd68c3b0e7fff5
4
- data.tar.gz: 7c51e166d6e95ca1edb404c4faaf900b6a28a6f5ca940cabe7f534eddbfa8720
3
+ metadata.gz: 6ace32742af101135e30af9f461e49db725b3f3e0c4f759cc42b44f64c7852f4
4
+ data.tar.gz: ef9f3729d7f2e09bc2d0aa4dc87bc00652906579a2e1aaf09a38df4dc5bccbcb
5
5
  SHA512:
6
- metadata.gz: f00a06fe4f39340bc75b19553e19ce2f65f0d5f6bf64ea2287357b7e68475cc774062417cbd854e727905f7c3d434a0705f5322f083c22f4ace99dce79be7cc6
7
- data.tar.gz: fe0894ee4fd7580f86c603e9cd3572ff0550fb772ace25cc63f5a74002fe1a3ec5a9aecd5446b04d2c8823a7de9a8a19f4e82c7fe4f8dc2816b23eafee9dd1e8
6
+ metadata.gz: d30d0af0d967adf9f6da8bdaeed911bd8beb8657c6b0e3bfd49f3d87c6a5050aa080cde758b3b4a3fc03d4164ebbb2ae335f72ae27eeb569be743b7e13073b1a
7
+ data.tar.gz: e4e7ad6eebb9efd288881788be3bba82d6c8adc126981d7e1ea30f479950cfa954d9c4e84f709850efccab19878c50538b9a4bc6d10b3850fc2aa0b63526a00e
@@ -0,0 +1,28 @@
1
+ module Glib
2
+ module Channel
3
+ class IsTypingChannel < ApplicationCable::Channel
4
+ class << self
5
+ attr_accessor :channel_name
6
+ end
7
+
8
+ def channel_name
9
+ self.class.channel_name
10
+ end
11
+
12
+ def subscribed
13
+ stream_from "#{self.class.channel_name}_#{params['conversation_id']}"
14
+ end
15
+
16
+ def typing(data)
17
+ ActionCable.server.broadcast \
18
+ "#{self.class.channel_name}_#{params['conversation_id']}",
19
+ action: {
20
+ action: 'component/set',
21
+ name: User.find(data['user_id']).full_name,
22
+ status: data['status'],
23
+ user_id: data['user_id']
24
+ }
25
+ end
26
+ end
27
+ end
28
+ end
@@ -69,6 +69,11 @@ module Glib::Json::Libs
69
69
  end
70
70
  end
71
71
 
72
+ def glib_json_redirect_to(url)
73
+ render json: {
74
+ onResponse: { action: 'dialogs/close', onClose: { action: 'windows/open', url: url } }
75
+ }
76
+ end
72
77
 
73
78
  module ClassMethods
74
79
 
@@ -99,6 +99,7 @@ module Glib
99
99
  class Push < Action
100
100
  string :channel
101
101
  string :event
102
+ hash :payload
102
103
  end
103
104
  end
104
105
 
@@ -0,0 +1,8 @@
1
+ class Glib::JsonUi::ActionBuilder
2
+ module Lists
3
+ class ScrollToBottom < Action
4
+ action :onScroll
5
+ bool :animate
6
+ end
7
+ end
8
+ end
@@ -22,5 +22,10 @@ class Glib::JsonUi::ActionBuilder
22
22
  string :url, cache: true
23
23
  action :onReload
24
24
  end
25
+
26
+ class CloseWithReload < Action
27
+ string :fallbackUrl
28
+ action :onReload
29
+ end
25
30
  end
26
31
  end
@@ -12,6 +12,7 @@ module Glib
12
12
  menu :editButtons
13
13
  menu :chips
14
14
  singleton_array :styleClass, :styleClasses
15
+ color :backgroundColor
15
16
 
16
17
  # def editButtons(block)
17
18
  # json.editButtons do
@@ -109,6 +109,7 @@ module Glib
109
109
  end
110
110
 
111
111
  class Label < AbstractText
112
+ hash :actionCable
112
113
  # string :format
113
114
  action :onClick
114
115
  end
@@ -12,6 +12,7 @@ class Glib::JsonUi::ViewBuilder
12
12
  icon :icon
13
13
  string :message
14
14
  singleton_array :styleClass, :styleClasses
15
+ color :color
15
16
 
16
17
  def buttons(block)
17
18
  json.buttons do
@@ -76,6 +76,8 @@ class Glib::JsonUi::ViewBuilder
76
76
  icon :leftIcon
77
77
  string :leftText
78
78
  string :rightText
79
+ action :onTypeStart
80
+ action :onTypeEnd
79
81
  end
80
82
 
81
83
  class Number < Text
@@ -234,5 +236,11 @@ class Glib::JsonUi::ViewBuilder
234
236
  class CreditCard < AbstractField
235
237
  string :publicKey
236
238
  end
239
+
240
+ class Rating < AbstractField
241
+ bool :halfIncrements
242
+ string :color
243
+ int :size
244
+ end
237
245
  end
238
246
  end
@@ -3,5 +3,10 @@ module Glib
3
3
  def glib_url_current(new_params)
4
4
  url_for(params.to_unsafe_h.merge(new_params.merge(only_path: false)))
5
5
  end
6
+
7
+ def glib_url_equals_current?(url)
8
+ route = Rails.application.routes.recognize_path(url)
9
+ route[:controller] == controller_name && route[:action] == action_name
10
+ end
6
11
  end
7
12
  end
@@ -0,0 +1,12 @@
1
+
2
+ section.header padding: glib_json_padding_list, childViews: ->(header) do
3
+ header.h3 text: 'Lists'
4
+ end
5
+
6
+ section.rows builder: ->(template) do
7
+ template.thumbnail title: 'lists/scrollToBottom', onClick: ->(action) do
8
+ action.lists_scrollToBottom animate: true, onScroll: ->(subaction) do
9
+ subaction.dialogs_alert message: 'Bottom reached'
10
+ end
11
+ end
12
+ end
@@ -6,6 +6,8 @@ render "#{@path_prefix}/nav_menu", json: json, page: page, top_nav: true
6
6
  page.list sections: [
7
7
  ->(section) do
8
8
  render "#{@path_prefix}/actions/reload", section: section
9
+ end, ->(section) do
10
+ render "#{@path_prefix}/actions/lists", section: section
9
11
  end, ->(section) do
10
12
  render "#{@path_prefix}/actions/dialogs", section: section
11
13
  end, ->(section) do
@@ -16,7 +16,7 @@ page.list sections: [
16
16
  template.thumbnail title: "Submission Flow (timestamp: #{DateTime.current.to_i})", onClick: ->(action) do
17
17
  action.windows_open url: json_ui_garage_url(path: 'forms/submission_flow')
18
18
  end
19
- template.thumbnail title: "Submission Indicator", onClick: ->(action) do
19
+ template.thumbnail title: 'Submission Indicator', onClick: ->(action) do
20
20
  action.windows_open url: json_ui_garage_url(path: 'forms/submission_indicator')
21
21
  end
22
22
  template.thumbnail title: 'GET Request', onClick: ->(action) do
@@ -59,7 +59,6 @@ page.list sections: [
59
59
  template.thumbnail title: 'Floating Submit', onClick: ->(action) do
60
60
  action.windows_open url: json_ui_garage_url(path: 'forms/floating_submit')
61
61
  end
62
-
63
62
  end
64
63
  end, ->(section) do
65
64
  section.header padding: glib_json_padding_list, childViews: ->(header) do
@@ -3,7 +3,12 @@ json.title 'Forms'
3
3
  page = json_ui_page json
4
4
  render "#{@path_prefix}/nav_menu", json: json, page: page
5
5
 
6
- page.form url: json_ui_garage_url(path: 'forms/generic_post'), method: 'post', padding: glib_json_padding_body, childViews: ->(form) do
6
+ page.form \
7
+ url: json_ui_garage_url(path: 'forms/generic_post'),
8
+ method: 'post',
9
+ padding: glib_json_padding_body,
10
+ childViews: ->(form) do
11
+
7
12
  form.h2 text: 'Radio Group'
8
13
  form.spacer height: 6
9
14
  form.h4 text: 'Gender'
@@ -15,15 +20,40 @@ page.form url: json_ui_garage_url(path: 'forms/generic_post'), method: 'post', p
15
20
 
16
21
  form.spacer height: 20
17
22
  form.h2 text: 'Single Checkbox'
18
- form.fields_check name: 'user[age_range]', value: '16+', checkValue: '16+', uncheckValue: '0-16', label: 'I am over 16 (has default value)'
19
- form.fields_check name: 'user[employer]', checkValue: 1, label: 'I am an employer (no default value)'
20
- form.fields_check name: 'user[enabled]', checkValue: true, label: 'Enable', styleClass: 'switch', value: 'true'
23
+ form.fields_check \
24
+ name: 'user[age_range]',
25
+ value: '16+',
26
+ checkValue: '16+',
27
+ uncheckValue: '0-16',
28
+ label: 'I am over 16 (has default value)'
29
+ form.fields_check \
30
+ name: 'user[employer]',
31
+ checkValue: 1,
32
+ label: 'I am an employer (no default value)'
33
+ form.fields_check \
34
+ name: 'user[enabled]',
35
+ checkValue: true,
36
+ label: 'Enable',
37
+ styleClass: 'switch',
38
+ value: 'true'
21
39
 
22
40
  form.spacer height: 20
23
41
  form.h2 text: 'Date/Time'
24
42
  form.spacer height: 6
25
- form.fields_date name: 'user[date]', width: 'matchParent', label: 'Date', min: '2010-01-01', max: '2012-01-01', value: '2010-02-01'
26
- form.fields_datetime name: 'user[date_time]', width: 'matchParent', label: 'Date Time', min: '2018-06-09T00:00', max: '2018-06-17T00:00', value: '2018-06-15T19:30'
43
+ form.fields_date \
44
+ name: 'user[date]',
45
+ width: 'matchParent',
46
+ label: 'Date',
47
+ min: '2010-01-01',
48
+ max: '2012-01-01',
49
+ value: '2010-02-01'
50
+ form.fields_datetime \
51
+ name: 'user[date_time]',
52
+ width: 'matchParent',
53
+ label: 'Date Time',
54
+ min: '2018-06-09T00:00',
55
+ max: '2018-06-17T00:00',
56
+ value: '2018-06-15T19:30'
27
57
 
28
58
  form.spacer height: 20
29
59
  form.h2 text: 'Country'
@@ -34,13 +64,39 @@ page.form url: json_ui_garage_url(path: 'forms/generic_post'), method: 'post', p
34
64
  form.spacer height: 20
35
65
  form.h2 text: 'Map'
36
66
  form.spacer height: 6
37
- form.fields_location name: 'user[address]', width: 'matchParent', label: 'Type an address', value: 'Sydney Harbour Bridge',
67
+ form.fields_location \
68
+ name: 'user[address]',
69
+ width: 'matchParent',
70
+ label: 'Type an address',
71
+ value: 'Sydney Harbour Bridge',
38
72
  autocompleteOptions: { componentRestrictions: { country: 'au' }, types: ['(cities)'] },
39
73
  latitudeField: { view: 'fields/text', name: 'user[latitude]', label: 'Lat', value: -33.8523063, readOnly: true },
40
74
  longitudeField: { view: 'fields/text', name: 'user[longitude]', label: 'Long', value: 151.21078710000006, readOnly: true },
41
75
  zoomField: { view: 'fields/text', name: 'user[zoom]', label: 'Zoom' }
42
76
 
43
77
  form.spacer height: 20
44
- form.fields_submit text: 'Submit'
78
+ form.h2 text: 'Rating'
79
+ form.spacer height: 6
80
+ form.fields_rating \
81
+ name: 'user[rating_summary1]',
82
+ value: 1,
83
+ color: 'primary'
84
+ form.fields_rating \
85
+ name: 'user[rating_summary2]',
86
+ value: 1.5,
87
+ halfIncrements: true,
88
+ color: 'secondary'
89
+ form.fields_rating \
90
+ name: 'user[rating_summary3]',
91
+ value: 2,
92
+ color: 'ternary',
93
+ size: 35
94
+ form.fields_rating \
95
+ name: 'user[rating_summary4]',
96
+ value: 3,
97
+ readOnly: true,
98
+ size: 40
45
99
 
100
+ form.spacer height: 20
101
+ form.fields_submit text: 'Submit'
46
102
  end
@@ -2,15 +2,15 @@ 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/submission_flow_post'), method: 'post', padding: { top: 12, left: 20, right: 20, bottom: 12 }, childViews: ->(form) do
7
7
  form.fields_radioGroup name: 'user[flow]', childViews: ->(group) do
8
8
  group.h3 text: 'Flow'
9
9
  group.spacer height: 6
10
- group.fields_radio value: 'close_reload', label: 'close+reload - useful for form submission in mobile apps'
11
- group.fields_radio value: 'open', label: 'open - useful for form submission in web app'
12
- group.fields_radio value: 'close_alert', label: 'close+alert - useful for non-model form (e.g. contact us) in both mobile/web'
13
- group.fields_radio value: 'alert_close', label: 'alert+close - useful for non-model form (e.g. contact us) in both mobile/web'
10
+ group.fields_radio value: 'open', label: 'open - useful for form create'
11
+ group.fields_radio value: 'close_with_reload', label: 'closeWithReload - useful for form update'
12
+ group.fields_radio value: 'close_alert', label: 'close+alert - useful for non-model form (e.g. contact us)'
13
+ group.fields_radio value: 'alert_close', label: 'alert+close - useful for non-model form (e.g. contact us)'
14
14
  end
15
15
  form.button text: 'Submit', onClick: ->(action) { action.forms_submit }
16
16
  end
@@ -5,10 +5,12 @@ json_ui_response json do |action|
5
5
  action.dialogs_alert message: 'Please enter all required information'
6
6
  else
7
7
  case flow
8
- when 'close_reload'
9
- action.windows_close onClose: ->(action) do
10
- action.windows_reload
11
- end
8
+ when 'close_with_reload'
9
+ # action.windows_close onClose: ->(action) do
10
+ # action.windows_reload
11
+ # end
12
+
13
+ action.windows_closeWithReload fallbackUrl: json_ui_garage_url(path: 'forms/index')
12
14
  when 'close_alert'
13
15
  action.windows_close onClose: ->(action) do
14
16
  action.dialogs_alert message: 'Thanks for the submission!'
@@ -2,30 +2,34 @@ json.title 'Menu'
2
2
 
3
3
  json_ui_page json do |page|
4
4
  render "#{@path_prefix}/nav_menu", json: json, page: page, top_nav: true
5
-
5
+
6
6
  page.list firstSection: ->(section) do
7
7
  section.rows builder: ->(template) do
8
- template.thumbnail title: 'Pages', onClick: ->(action) do
8
+ template.thumbnail title: 'Pages', onClick: ->(action) do
9
9
  action.windows_open url: json_ui_garage_url(path: 'pages/index')
10
10
  end
11
- template.thumbnail title: 'Lists', onClick: ->(action) do
11
+ template.thumbnail title: 'Panels', onClick: ->(action) do
12
+ action.windows_open url: json_ui_garage_url(path: 'panels/index')
13
+ end
14
+ template.thumbnail title: 'Lists', onClick: ->(action) do
12
15
  action.windows_open url: json_ui_garage_url(path: 'lists/index')
13
16
  end
14
- template.thumbnail title: 'Forms', onClick: ->(action) do
17
+ template.thumbnail title: 'Forms', onClick: ->(action) do
15
18
  action.windows_open url: json_ui_garage_url(path: 'forms/index')
16
19
  end
17
- template.thumbnail title: 'Panels', onClick: ->(action) do
18
- action.windows_open url: json_ui_garage_url(path: 'panels/index')
19
- end
20
- template.thumbnail title: 'Views', onClick: ->(action) do
20
+ template.thumbnail title: 'Views', onClick: ->(action) do
21
21
  action.windows_open url: json_ui_garage_url(path: 'views/index')
22
22
  end
23
- template.thumbnail title: 'Actions', onClick: ->(action) do
23
+ template.thumbnail title: 'Actions', onClick: ->(action) do
24
24
  action.windows_open url: json_ui_garage_url(path: 'actions/index')
25
25
  end
26
- template.thumbnail title: 'Tables (Web Only)', onClick: ->(action) do
26
+ template.thumbnail title: 'Tables (Web Only)', onClick: ->(action) do
27
27
  action.windows_open url: json_ui_garage_url(path: 'tables/index')
28
28
  end
29
+ # Disabled to prevent errors in crawler tests due to external dependencies
30
+ # template.thumbnail title: 'Services', onClick: ->(action) do
31
+ # action.windows_open url: json_ui_garage_url(path: 'services/index')
32
+ # end
29
33
  end
30
34
 
31
35
  end
@@ -1,3 +1,4 @@
1
+ json.title 'ActionCable Real-time Update'
1
2
  page = json_ui_page json
2
3
 
3
4
  # Implement a page that shows how ActionCable works in json_ui
@@ -9,14 +10,16 @@ page = json_ui_page json
9
10
  # end
10
11
  # end
11
12
 
12
- # 2. Example for textarea
13
- # - TODO: Put onKeyUp in Textarea class in app/helpers/glib/json_ui/view_builder/fields.rb
14
- # - TODO: Implement onKeyUp in glib-web-npm
15
- # - TODO: Implement cables_push in glib-web-npm
16
- # form.fields_textarea prop: :content, width: 'matchParent', label: 'Message', onKeyUp: ->(action) do
17
- # action.cables_push channel: 'message', event: 'typing'
13
+ # page.form url: json_ui_garage_url(path: 'forms/basic_post'), method: 'post', padding: glib_json_padding_body, childViews: ->(form) do
14
+ # form.fields_textarea \
15
+ # width: 'matchParent',
16
+ # label: 'Message',
17
+ # onKeyUp: ->(action) do
18
+ # action.cables_push channel: 'isTypingChannel', data: { conversationId: 1, userId: 1 }
19
+ # end
18
20
  # end
19
21
 
22
+
20
23
  # 3. Example for online status
21
24
  # - TODO: Implement "repeat: true" in glib-web-npm
22
25
  # page.on load: ->(action) do
@@ -24,3 +27,71 @@ page = json_ui_page json
24
27
  # subaction.cables_push channel: 'message', event: 'online'
25
28
  # end
26
29
  # end
30
+
31
+
32
+ # put on app/channels/is_typing_channel.rb
33
+ # class IsTypingChannel < Glib::Channel::IsTypingChannel
34
+ # self.channel_name = 'IsTypingChannel'
35
+ # end
36
+
37
+ page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
38
+
39
+ channel = 'IsTypingChannel'
40
+ first_user = User.first
41
+ second_user = User.offset(1).first
42
+
43
+ scroll.panels_split width: 'matchParent', content: ->(content) do
44
+ content.left childViews: ->(left) do
45
+ left.fields_textarea \
46
+ width: 440,
47
+ label: "Messages from #{first_user.full_name}",
48
+ onTypeStart: lambda { |action|
49
+ action.cables_push \
50
+ channel: channel, event: 'typing',
51
+ payload: { status: true, user_id: first_user.id }
52
+ },
53
+ onTypeEnd: lambda { |action|
54
+ action.cables_push \
55
+ channel: channel,
56
+ event: 'typing',
57
+ payload: { status: false, user_id: first_user.id }
58
+ }
59
+ left.spacer height: 10
60
+
61
+ socket_config = {
62
+ channel: channel,
63
+ filterKey: first_user.id,
64
+ params: {
65
+ conversation: 2
66
+ }
67
+ }
68
+ left.label actionCable: socket_config, text: ' '
69
+ end
70
+ content.right childViews: ->(right) do
71
+ right.fields_textarea \
72
+ width: 440,
73
+ label: "Messages from #{second_user.full_name}",
74
+ onTypeStart: lambda { |action|
75
+ action.cables_push \
76
+ channel: channel, event: 'typing',
77
+ payload: { status: true, user_id: second_user.id }
78
+ },
79
+ onTypeEnd: lambda { |action|
80
+ action.cables_push \
81
+ channel: channel,
82
+ event: 'typing',
83
+ payload: { status: false, user_id: second_user.id }
84
+ }
85
+ right.spacer height: 10
86
+
87
+ socket_config = {
88
+ channel: channel,
89
+ filterKey: second_user.id,
90
+ params: {
91
+ conversation: 2
92
+ }
93
+ }
94
+ right.label actionCable: socket_config, text: ' '
95
+ end
96
+ end
97
+ 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.49
4
+ version: 0.5.55
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
@@ -17,9 +17,6 @@ dependencies:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 5.2.3
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: 6.1.0
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
@@ -27,9 +24,6 @@ dependencies:
27
24
  - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: 5.2.3
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: 6.1.0
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: pundit
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -58,12 +52,27 @@ dependencies:
58
52
  - - "~>"
59
53
  - !ruby/object:Gem::Version
60
54
  version: '2.1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: actioncable
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 6.0.1
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 6.0.1
61
69
  description:
62
70
  email: ''
63
71
  executables: []
64
72
  extensions: []
65
73
  extra_rdoc_files: []
66
74
  files:
75
+ - app/channels/glib/channel/is_typing_channel.rb
67
76
  - app/controllers/concerns/glib/analytics/funnel.rb
68
77
  - app/controllers/concerns/glib/auth/policy.rb
69
78
  - app/controllers/concerns/glib/json/dynamic_text.rb
@@ -83,6 +92,7 @@ files:
83
92
  - app/helpers/glib/json_ui/action_builder.rb
84
93
  - app/helpers/glib/json_ui/action_builder/dialogs.rb
85
94
  - app/helpers/glib/json_ui/action_builder/http.rb
95
+ - app/helpers/glib/json_ui/action_builder/lists.rb
86
96
  - app/helpers/glib/json_ui/action_builder/sheets.rb
87
97
  - app/helpers/glib/json_ui/action_builder/snackbars.rb
88
98
  - app/helpers/glib/json_ui/action_builder/windows.rb
@@ -114,6 +124,7 @@ files:
114
124
  - app/views/json_ui/garage/_nav_menu.json.jbuilder
115
125
  - app/views/json_ui/garage/actions/_dialogs.json.jbuilder
116
126
  - app/views/json_ui/garage/actions/_http.json.jbuilder
127
+ - app/views/json_ui/garage/actions/_lists.json.jbuilder
117
128
  - app/views/json_ui/garage/actions/_reload.json.jbuilder
118
129
  - app/views/json_ui/garage/actions/_sheets.json.jbuilder
119
130
  - app/views/json_ui/garage/actions/_snackbars.json.jbuilder