glib-web 4.36.8 → 4.37.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 46f0038f026665e4c7c8cefecd766bf728ca5c807ef1216b42ae0fab40fd644a
4
- data.tar.gz: 06e074f158733ce9ea65bef4b53cddadabbe5eb468cb20175fbb8dc1352c7c81
3
+ metadata.gz: 4e3330ddf2fc14630ca3e1a47cc4500bb6ef0e6dd3cb9617a67d49034ccb3b95
4
+ data.tar.gz: bc130cbf2e69f387893fd3c84f6d5e431a9fc16e15ea17b7601281264c277727
5
5
  SHA512:
6
- metadata.gz: 6428f530b4309e009f66905ec030ee68acbd98b9543ef4480e8835408fe3601d856d98e6e517cd2d76e33a4311ee3e0b873c1e51179a5d68da5b35663e1dc2c9
7
- data.tar.gz: 61a08e0100e9d85582933e4931f19162e5b5303f309370420d0dc4d3cdd0c183dd9a5a4b325c506e4974ec913cc20518497251cfa76583615c67137bf8ddf47c
6
+ metadata.gz: 7b282c99b9141afaaf6662296f859451b9eb021276c294adfd8d402214bb42b91c4cd63da3a0713a4ec6a9c3dc6300c29758016a5e9db79ba4422671ea7da7da
7
+ data.tar.gz: 6432b2181a9f351ebd83d8adde7052b20f3b7b0a841fd98331532e1551efe475aacaf41cfd93de655badb1477f72251694b052d0c6c08089fbd9dcc17a098d34
@@ -20,7 +20,7 @@ module Glib
20
20
  icon :icon
21
21
  action :onClick
22
22
  bool :disabled
23
- # hash :tooltip
23
+ bool :expanded
24
24
  singleton_array :styleClass, :styleClasses
25
25
 
26
26
  def childButtons(block)
@@ -324,6 +324,7 @@ class Glib::JsonUi::ViewBuilder
324
324
 
325
325
  class Radio < View
326
326
  string :label
327
+ string :subtitle
327
328
  string :value
328
329
  action :onClick
329
330
  string :offIcon
@@ -58,6 +58,16 @@ if local_assigns[:top_nav] || json_ui_app_is_web?
58
58
  menu.divider
59
59
  menu.label text: 'Misc Menu'
60
60
 
61
+ menu.button icon: 'list', text: 'Parent', expanded: true, onClick: ->(action) do
62
+ end, childButtons: ->(parent) do
63
+ parent.button text: 'Child 1', onClick: ->(action) do
64
+ action.windows_open url: json_ui_garage_url(path: 'lists/index')
65
+ end
66
+ parent.button text: 'Child 2', onClick: ->(action) do
67
+ action.windows_open url: json_ui_garage_url(path: 'forms/index')
68
+ end
69
+ end
70
+
61
71
  menu.button icon: 'notifications', text: 'Notifications', onClick: ->(action) do
62
72
  action.windows_open url: json_ui_garage_url(path: 'notifications/index')
63
73
  end
@@ -16,6 +16,12 @@ section.rows builder: ->(template) do
16
16
  action.windows_reload url: json_ui_garage_url(path: 'actions/index', reload_counter: reload_counter + 1)
17
17
  end
18
18
 
19
+ template.thumbnail title: 'windows/reload (onReload)', onClick: ->(action) do
20
+ action.windows_reload onReload: ->(saction) do
21
+ saction.snackbars_alert message: 'onReload called'
22
+ end
23
+ end
24
+
19
25
  template.thumbnail title: "components/replace (counter: #{reload_counter})", onClick: ->(action) do
20
26
  action.http_get url: json_ui_garage_url(path: 'actions/partial_update', reload_counter: reload_counter + 1)
21
27
  end
@@ -0,0 +1,11 @@
1
+ panel.panels_vertical \
2
+ width: 'matchParent',
3
+ styleClass: 'card',
4
+ padding: glib_json_padding_body,
5
+ backgroundColor: '#b3bac2',
6
+ childViews: ->(vertical) do
7
+ vertical.h1 text: 'Header'
8
+ vertical.spacer height: 10
9
+ vertical.p text: 'This header uses a column layout to hide the heading on small screens.'
10
+ vertical.p text: 'On small screens, it will be replaced with a scrollable header.'
11
+ end
@@ -3,14 +3,27 @@ json.title 'Pages'
3
3
  page = json_ui_page json
4
4
  render "#{@path_prefix}/nav_menu", json: json, page: page
5
5
 
6
- page.header padding: glib_json_padding_body, backgroundColor: '#b3bac2', childViews: ->(header) do
7
- header.h1 text: 'Header'
8
- end
6
+ page.header(
7
+ padding: glib_json_padding_body,
8
+ backgroundColor: '#b3bac2',
9
+ childViews: ->(header) do
10
+ header.h1 text: 'Header'
11
+ end
12
+ )
9
13
 
10
- page.body height: 'matchParent', padding: glib_json_padding_body, childViews: ->(body) do
11
- body.button width: 'matchParent', height: 'matchParent', text: 'Full Width/Height'
12
- end
14
+ page.body(
15
+ height: 'matchParent',
16
+ padding: glib_json_padding_body,
17
+ childViews: ->(body) do
18
+ body.button width: 'matchParent', height: 'matchParent', text: 'Full Width/Height'
19
+ end
20
+ )
13
21
 
14
- page.footer height: 80, padding: glib_json_padding_body, backgroundColor: '#b3bac2', childViews: ->(footer) do
15
- footer.h1 text: 'Footer'
16
- end
22
+ page.footer(
23
+ height: 80,
24
+ padding: glib_json_padding_body,
25
+ backgroundColor: '#b3bac2',
26
+ childViews: ->(footer) do
27
+ footer.h1 text: 'Footer'
28
+ end
29
+ )
@@ -3,16 +3,41 @@ json.title 'Pages'
3
3
  page = json_ui_page json
4
4
  render "#{@path_prefix}/nav_menu", json: json, page: page
5
5
 
6
- page.header padding: glib_json_padding_body, backgroundColor: '#b3bac2', childViews: ->(header) do
7
- header.h1 text: 'Header'
8
- end
6
+ page.header(
7
+ childViews: ->(header) do
8
+ header.panels_column(
9
+ smAndDown: { hide: true },
10
+ childViews: ->(column) do
11
+ render "#{@path_prefix}/pages/header", panel: column, json: json
12
+ end
13
+ )
14
+ end
15
+ )
16
+
17
+ page.footer(
18
+ padding: glib_json_padding_body,
19
+ backgroundColor: '#b3bac2',
20
+ childViews: ->(footer) do
21
+ footer.h1 text: 'Footer'
22
+ end
23
+ )
9
24
 
10
- page.footer padding: glib_json_padding_body, backgroundColor: '#b3bac2', childViews: ->(footer) do
11
- footer.h1 text: 'Footer'
12
- end
25
+ page.scroll(
26
+ childViews: ->(scroll) do
27
+ scroll.panels_column(
28
+ md: { hide: true },
29
+ childViews: ->(column) do
30
+ render "#{@path_prefix}/pages/header", panel: scroll, json: json
31
+ end
32
+ )
13
33
 
14
- page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
15
- (1..100).each do |index|
16
- scroll.label text: 'Content'
34
+ scroll.panels_vertical(
35
+ padding: glib_json_padding_body,
36
+ childViews: ->(vertical) do
37
+ (1..100).each do |index|
38
+ vertical.label text: 'Content'
39
+ end
40
+ end
41
+ )
17
42
  end
18
- end
43
+ )
@@ -0,0 +1,32 @@
1
+ page = local_assigns[:page] || json_ui_page(json)
2
+
3
+ page.body childViews: ->(body) do
4
+ body.panels_responsive width: 300, styleClass: 'border rounded-lg popovers-menu bg-white pa-4', childViews: ->(res) do
5
+ res.panels_form method: 'POST', url: json_ui_garage_url(path: 'forms/generic_post_all'), width: 'matchParent', childViews: ->(form) do
6
+ render 'json_ui/garage/views/expand_shrink_ex',
7
+ title: 'Choose fruits',
8
+ id: 'fruit',
9
+ expand: false,
10
+ view: form do |view|
11
+ view.fields_checkGroup name: 'user[fruits][]', styleClass: 'pb-2', childViews: ->(cg) do
12
+ cg.fields_check label: 'Banana', checkValue: 'banana'
13
+ cg.fields_check label: 'Grape', checkValue: 'grape'
14
+ cg.fields_check label: 'Strawberry', checkValue: 'strawberry'
15
+ end
16
+ end
17
+ form.spacer height: 8
18
+ render 'json_ui/garage/views/expand_shrink_ex',
19
+ title: 'Choose drinks',
20
+ id: 'drink',
21
+ expand: true,
22
+ view: form do |view|
23
+ view.fields_checkGroup name: 'user[drinks][]', styleClass: 'pb-2', childViews: ->(cg) do
24
+ cg.fields_check label: 'Coffee', checkValue: 'coffee'
25
+ cg.fields_check label: 'Water', checkValue: 'water'
26
+ cg.fields_check label: 'Milk', checkValue: 'milk'
27
+ end
28
+ end
29
+ form.fields_submit text: 'submit'
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,28 @@
1
+ expand = local_assigns[:expand] || false
2
+
3
+ view.panels_responsive width: 'matchParent', childViews: ->(res) do
4
+ # shrink
5
+ res.panels_flow id: "#{id}-shrink", displayed: !expand, width: 'matchParent', styleClass: 'items-center justify-between flex-nowrap', childViews: ->(flow) do
6
+ flow.label text: title
7
+ flow.icon name: 'arrow_drop_down', size: 20, onClick: ->(action) do
8
+ action.runMultiple childActions: ->(saction) do
9
+ saction.components_set targetId: "#{id}-expand", data: { displayed: true }
10
+ saction.components_set targetId: "#{id}-shrink", data: { displayed: false }
11
+ end
12
+ end
13
+ end
14
+
15
+ # expand
16
+ res.panels_responsive id: "#{id}-expand", displayed: expand, width: 'matchParent', childViews: ->(sres) do
17
+ sres.panels_flow width: 'matchParent', styleClass: 'items-center justify-between flex-nowrap', childViews: ->(flow) do
18
+ flow.label text: title
19
+ flow.icon name: 'arrow_drop_up', size: 20, onClick: ->(action) do
20
+ action.runMultiple childActions: ->(saction) do
21
+ saction.components_set targetId: "#{id}-shrink", data: { displayed: true }
22
+ saction.components_set targetId: "#{id}-expand", data: { displayed: false }
23
+ end
24
+ end
25
+ end
26
+ yield(sres)
27
+ end
28
+ end
@@ -129,6 +129,18 @@ page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
129
129
  action.dialogs_alert message: 'Perform action'
130
130
  end
131
131
 
132
+ scroll.spacer height: 20
133
+ scroll.button text: 'popovers/show checkboxes', onClick: ->(action) do
134
+ action.popovers_show content: ->(pg) do
135
+ render 'json_ui/garage/views/checkbox_expand', page: pg
136
+ end
137
+ end
138
+
139
+ scroll.spacer height: 20
140
+ scroll.button text: 'popovers/open checkboxes', onClick: ->(action) do
141
+ action.popovers_open url: json_ui_garage_url(path: 'views/_checkbox_expand')
142
+ end
143
+
132
144
  scroll.spacer height: 20
133
145
  scroll.button \
134
146
  icon: 'info',
@@ -3,7 +3,8 @@ sleep 1
3
3
  page = json_ui_page json
4
4
 
5
5
  page.body childViews: ->(body) do
6
- body.panels_responsive styleClass: 'popover-menu', childViews: ->(sres) do
6
+ body.panels_form styleClass: 'popover-menu', childViews: ->(sres) do
7
+ sres.fields_select options: ['A', 'B'].map { |v| { text: v, value: v } }, name: 'user[select]', label: 'Select', width: 'matchParent'
7
8
  sres.p text: "Current time: #{DateTime.current}", styleClass: 'pb-2'
8
9
  sres.button text: 'Update', onClick: ->(action) do
9
10
  action.popovers_open url: json_ui_garage_url(path: 'views/popovers_open', key: params[:key]), key: params[:key], updateExisting: true
@@ -0,0 +1,181 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Glib
6
+ # Enforces parentheses style for multi-line method calls with arguments.
7
+ #
8
+ # @example
9
+ # # bad
10
+ # page.footer padding: glib_json_padding_body, backgroundColor: '#b3bac2', childViews: ->(footer) do
11
+ # footer.h1 text: 'Footer'
12
+ # end
13
+ #
14
+ # # bad
15
+ # page.footer \
16
+ # padding: glib_json_padding_body,
17
+ # backgroundColor: '#b3bac2',
18
+ # childViews: ->(footer) do
19
+ # footer.h1 text: 'Footer'
20
+ # end
21
+ #
22
+ # # good
23
+ # page.footer(
24
+ # padding: glib_json_padding_body,
25
+ # backgroundColor: '#b3bac2',
26
+ # childViews: ->(footer) do
27
+ # footer.h1 text: 'Footer'
28
+ # end
29
+ # )
30
+ class MultilineMethodCallStyle < Base
31
+ extend AutoCorrector
32
+
33
+ MSG = 'Use parentheses style for multi-line method calls: ' \
34
+ 'wrap arguments in parentheses and place each argument on its own line.'
35
+
36
+ def on_send(node)
37
+ return unless multi_line_call_with_args?(node)
38
+ return if proper_parentheses_style?(node)
39
+ return if proper_backslash_style?(node) && allow_backslash?
40
+
41
+ add_offense(node) do |corrector|
42
+ autocorrect(corrector, node)
43
+ end
44
+ end
45
+
46
+ alias on_csend on_send
47
+
48
+ private
49
+
50
+ def multi_line_call_with_args?(node)
51
+ node.multiline? && node.arguments.any?
52
+ end
53
+
54
+ def allow_backslash?
55
+ # Allow backslash style without warnings when configured
56
+ # Set to true to allow both styles (but auto-correct will still convert to parentheses)
57
+ # Set to false to enforce parentheses style always
58
+ cop_config.fetch('AllowBackslashStyle', true)
59
+ end
60
+
61
+ def proper_backslash_style?(node)
62
+ source = processed_source.buffer.source
63
+ method_end_pos = node.loc.selector.end_pos
64
+
65
+ # Check if there's a backslash right after the method name
66
+ next_char_pos = method_end_pos
67
+ while next_char_pos < source.length && source[next_char_pos] == ' '
68
+ next_char_pos += 1
69
+ end
70
+
71
+ return false unless source[next_char_pos] == '\\'
72
+
73
+ # Check that each argument is on its own line
74
+ args = collect_arguments(node)
75
+ return false if args.empty?
76
+
77
+ args.each_cons(2) do |arg1, arg2|
78
+ return false if arg1.loc.line == arg2.loc.line
79
+ end
80
+
81
+ true
82
+ end
83
+
84
+ def proper_parentheses_style?(node)
85
+ return false unless node.parenthesized?
86
+
87
+ # Check that first argument is on a new line after opening paren
88
+ first_arg = node.first_argument
89
+ return false if first_arg.loc.line == node.loc.selector.line
90
+
91
+ # Check that each argument is on its own line
92
+ args = collect_arguments(node)
93
+ return false if args.empty?
94
+
95
+ args.each_cons(2) do |arg1, arg2|
96
+ return false if arg1.loc.line == arg2.loc.line
97
+ end
98
+
99
+ # Check that closing paren is on its own line
100
+ source = processed_source.buffer.source
101
+ close_paren_pos = node.loc.end.begin_pos
102
+ line_start = source.rindex("\n", close_paren_pos) || 0
103
+ line_content = source[line_start...close_paren_pos].strip
104
+
105
+ return false unless line_content.empty?
106
+
107
+ true
108
+ end
109
+
110
+ def collect_arguments(node)
111
+ args = []
112
+
113
+ node.arguments.each do |arg|
114
+ if arg.hash_type?
115
+ # For hash arguments, treat each pair as a separate argument
116
+ arg.pairs.each { |pair| args << pair }
117
+ else
118
+ args << arg
119
+ end
120
+ end
121
+
122
+ args
123
+ end
124
+
125
+ def autocorrect(corrector, node)
126
+ method_end_pos = node.loc.selector.end_pos
127
+
128
+ # Find the indentation of the method call
129
+ line_begin_pos = processed_source.buffer.line_range(node.loc.line).begin_pos
130
+ base_indent = node.source_range.begin_pos - line_begin_pos
131
+ arg_indent = ' ' * (base_indent + 2)
132
+
133
+ # Build the new argument list
134
+ arg_parts = []
135
+ node.arguments.each do |arg|
136
+ next if arg.block_pass_type? # Skip block arguments like &block
137
+
138
+ if arg.hash_type?
139
+ arg.pairs.each do |pair|
140
+ arg_parts << pair.source
141
+ end
142
+ else
143
+ arg_parts << arg.source
144
+ end
145
+ end
146
+
147
+ # Build the replacement with parentheses style
148
+ if arg_parts.any?
149
+ # Opening paren on same line as method, arguments on separate lines
150
+ replacement = "(\n#{arg_indent}" + arg_parts.join(",\n#{arg_indent}")
151
+
152
+ # If there's a block, add it on the last argument line
153
+ if node.block_literal?
154
+ block_source = node.block_literal.source
155
+ replacement += " #{block_source}"
156
+ end
157
+
158
+ # Closing paren on its own line at base indentation
159
+ replacement += "\n#{' ' * base_indent})"
160
+ else
161
+ # No arguments, just the block (shouldn't happen for multi-line, but handle it)
162
+ replacement = if node.block_literal?
163
+ " #{node.block_literal.source}"
164
+ else
165
+ '()'
166
+ end
167
+ end
168
+
169
+ # Remove everything from method name to end of node
170
+ range = Parser::Source::Range.new(
171
+ processed_source.buffer,
172
+ method_end_pos,
173
+ node.source_range.end_pos
174
+ )
175
+
176
+ corrector.replace(range, replacement)
177
+ end
178
+ end
179
+ end
180
+ end
181
+ end
data/lib/glib/rubocop.rb CHANGED
@@ -1 +1,2 @@
1
1
  require_relative 'rubocop/cops/localize'
2
+ require_relative 'rubocop/cops/multiline_method_call_style'
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: 4.36.8
4
+ version: 4.37.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
@@ -321,6 +321,7 @@ files:
321
321
  - app/views/json_ui/garage/notifications/android_post.json.jbuilder
322
322
  - app/views/json_ui/garage/notifications/index.json.jbuilder
323
323
  - app/views/json_ui/garage/notifications/web_socket.json.jbuilder
324
+ - app/views/json_ui/garage/pages/_header.json.jbuilder
324
325
  - app/views/json_ui/garage/pages/custom_style_class.json.jbuilder
325
326
  - app/views/json_ui/garage/pages/full_width.json.jbuilder
326
327
  - app/views/json_ui/garage/pages/full_width_height.json.jbuilder
@@ -378,6 +379,8 @@ files:
378
379
  - app/views/json_ui/garage/test_page/selectable.json.jbuilder
379
380
  - app/views/json_ui/garage/test_page/window.json.jbuilder
380
381
  - app/views/json_ui/garage/views/_chart_data.json.jbuilder
382
+ - app/views/json_ui/garage/views/_checkbox_expand.json.jbuilder
383
+ - app/views/json_ui/garage/views/_expand_shrink_ex.json.jbuilder
381
384
  - app/views/json_ui/garage/views/banners.json.jbuilder
382
385
  - app/views/json_ui/garage/views/calendar_data.json.jbuilder
383
386
  - app/views/json_ui/garage/views/charts.json.jbuilder
@@ -439,6 +442,7 @@ files:
439
442
  - lib/glib/mailer_tester.rb
440
443
  - lib/glib/rubocop.rb
441
444
  - lib/glib/rubocop/cops/localize.rb
445
+ - lib/glib/rubocop/cops/multiline_method_call_style.rb
442
446
  - lib/glib/snapshot.rb
443
447
  - lib/glib/test_helpers.rb
444
448
  - lib/glib/time_freezable_mailer.rb