glib-web 4.42.1 → 4.42.3

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.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/concerns/glib/json/libs.rb +4 -9
  3. data/app/controllers/concerns/glib/json/ui.rb +6 -8
  4. data/app/views/json_ui/garage/test_page/_header.json.jbuilder +84 -14
  5. data/app/views/json_ui/garage/test_page/browsers.json.jbuilder +101 -0
  6. data/app/views/json_ui/garage/test_page/calendar.json.jbuilder +109 -0
  7. data/app/views/json_ui/garage/test_page/calendar_empty_data.json.jbuilder +3 -0
  8. data/app/views/json_ui/garage/test_page/carousel.json.jbuilder +70 -0
  9. data/app/views/json_ui/garage/test_page/charts.json.jbuilder +370 -0
  10. data/app/views/json_ui/garage/test_page/column.json.jbuilder +121 -0
  11. data/app/views/json_ui/garage/test_page/commands.json.jbuilder +98 -0
  12. data/app/views/json_ui/garage/test_page/components.json.jbuilder +143 -0
  13. data/app/views/json_ui/garage/test_page/cookies.json.jbuilder +109 -0
  14. data/app/views/json_ui/garage/test_page/custom.json.jbuilder +56 -0
  15. data/app/views/json_ui/garage/test_page/flow.json.jbuilder +70 -0
  16. data/app/views/json_ui/garage/test_page/forms.json.jbuilder +105 -0
  17. data/app/views/json_ui/garage/test_page/grid.json.jbuilder +68 -0
  18. data/app/views/json_ui/garage/test_page/horizontal.json.jbuilder +68 -0
  19. data/app/views/json_ui/garage/test_page/http.json.jbuilder +87 -37
  20. data/app/views/json_ui/garage/test_page/image.json.jbuilder +145 -0
  21. data/app/views/json_ui/garage/test_page/list.json.jbuilder +75 -0
  22. data/app/views/json_ui/garage/test_page/lists_append.json.jbuilder +151 -0
  23. data/app/views/json_ui/garage/test_page/logics_set.json.jbuilder +7 -6
  24. data/app/views/json_ui/garage/test_page/multimedia_video.json.jbuilder +118 -0
  25. data/app/views/json_ui/garage/test_page/pagination.json.jbuilder +64 -0
  26. data/app/views/json_ui/garage/test_page/panels.json.jbuilder +113 -0
  27. data/app/views/json_ui/garage/test_page/popovers.json.jbuilder +112 -0
  28. data/app/views/json_ui/garage/test_page/progressCircle.json.jbuilder +119 -0
  29. data/app/views/json_ui/garage/test_page/responsive.json.jbuilder +100 -0
  30. data/app/views/json_ui/garage/test_page/scroll.json.jbuilder +77 -0
  31. data/app/views/json_ui/garage/test_page/split.json.jbuilder +82 -0
  32. data/app/views/json_ui/garage/test_page/storage_items.json.jbuilder +144 -0
  33. data/app/views/json_ui/garage/test_page/table.json.jbuilder +99 -0
  34. data/app/views/json_ui/garage/test_page/timeline.json.jbuilder +97 -0
  35. data/app/views/json_ui/garage/test_page/timeouts.json.jbuilder +86 -0
  36. data/app/views/json_ui/garage/test_page/ul.json.jbuilder +68 -0
  37. data/app/views/json_ui/garage/test_page/vertical.json.jbuilder +68 -0
  38. data/app/views/json_ui/garage/test_page/web.json.jbuilder +64 -0
  39. data/app/views/json_ui/garage/test_page/windows.json.jbuilder +129 -0
  40. data/lib/glib/rubocop/cops/multiline_method_call_style.rb +8 -0
  41. data/lib/tasks/db.rake +1 -0
  42. metadata +34 -1
@@ -0,0 +1,370 @@
1
+ json.title 'Test Page (Charts)'
2
+
3
+ default_plugins = {
4
+ datalabels: {
5
+ backgroundColor: 'skyblue',
6
+ borderRadius: 4,
7
+ color: 'white',
8
+ font: {
9
+ weight: 'bold'
10
+ },
11
+ padding: 6
12
+ }
13
+ }
14
+
15
+ line_series_revenue = [
16
+ -> do
17
+ json.title 'Revenue'
18
+
19
+ points = {
20
+ 'Jan' => 120,
21
+ 'Feb' => 80,
22
+ 'Mar' => 140,
23
+ 'Apr' => 110,
24
+ }
25
+ json.points points.map { |k, v| { x: k, y: v, label: v } }
26
+ end,
27
+ -> do
28
+ json.title 'Orders'
29
+
30
+ points = {
31
+ 'Jan' => 30,
32
+ 'Feb' => 45,
33
+ 'Mar' => 40,
34
+ 'Apr' => 60,
35
+ }
36
+ json.points points.map { |k, v| { x: k, y: v, label: v } }
37
+ end
38
+ ]
39
+
40
+ line_series_sessions = [
41
+ -> do
42
+ json.title 'Sessions'
43
+
44
+ points = {
45
+ 'Mon' => 60,
46
+ 'Tue' => 72,
47
+ 'Wed' => 68,
48
+ 'Thu' => 90,
49
+ 'Fri' => 120,
50
+ }
51
+ json.points points.map { |k, v| { x: k, y: v, label: v } }
52
+ end
53
+ ]
54
+
55
+ line_series_churn = [
56
+ -> do
57
+ json.title 'Churn'
58
+
59
+ points = {
60
+ 'Q1' => 4,
61
+ 'Q2' => 6,
62
+ 'Q3' => 5,
63
+ 'Q4' => 3,
64
+ }
65
+ json.points points.map { |k, v| { x: k, y: v, label: v } }
66
+ end
67
+ ]
68
+
69
+ page = json_ui_page json
70
+
71
+ page.body childViews: ->(body) do
72
+ render 'json_ui/garage/test_page/header', view: body
73
+
74
+ body.panels_responsive padding: glib_json_padding_body, childViews: ->(res) do
75
+ res.h2 text: 'Charts'
76
+ res.label text: 'Visualize trends, comparisons, and composition with line, column, pie, donut, and area charts.'
77
+ res.spacer height: 12
78
+ res.hr width: 'matchParent'
79
+ res.spacer height: 12
80
+
81
+ res.h2 text: 'Interactive preview'
82
+ res.label text: 'Swap data sets to confirm the chart updates without remounting.'
83
+ res.spacer height: 8
84
+ # res.panels_flow innerPadding: { bottom: 0 }, width: 'matchParent', childViews: ->(flow) do
85
+ # flow.button(
86
+ # text: 'Revenue vs Orders',
87
+ # onClick: ->(action) do
88
+ # action.components_set(
89
+ # targetId: 'charts_preview',
90
+ # data: {
91
+ # dataSeries: line_series_revenue,
92
+ # plugins: default_plugins,
93
+ # colors: ['#79AC78', '#3085C3'],
94
+ # legend: { display: false },
95
+ # formatYAxis: true
96
+ # }
97
+ # )
98
+ # end
99
+ # )
100
+ # flow.spacer width: 8
101
+ # flow.button(
102
+ # text: 'Sessions (single)',
103
+ # onClick: ->(action) do
104
+ # action.components_set(
105
+ # targetId: 'charts_preview',
106
+ # data: {
107
+ # dataSeries: line_series_sessions,
108
+ # colors: ['#E36414'],
109
+ # legend: { display: false },
110
+ # formatYAxis: true
111
+ # }
112
+ # )
113
+ # end
114
+ # )
115
+ # flow.spacer width: 8
116
+ # flow.button(
117
+ # text: 'Churn trend',
118
+ # onClick: ->(action) do
119
+ # action.components_set(
120
+ # targetId: 'charts_preview',
121
+ # data: {
122
+ # dataSeries: line_series_churn,
123
+ # colors: ['#5B0888'],
124
+ # legend: { display: false },
125
+ # formatYAxis: true
126
+ # }
127
+ # )
128
+ # end
129
+ # )
130
+ # flow.spacer width: 8
131
+ # flow.button(
132
+ # text: 'Clear data',
133
+ # onClick: ->(action) do
134
+ # action.components_set(
135
+ # targetId: 'charts_preview',
136
+ # data: { dataSeries: [] }
137
+ # )
138
+ # end
139
+ # )
140
+ # end
141
+ res.spacer height: 12
142
+ res.charts_line(
143
+ id: 'charts_preview',
144
+ dataSeries: line_series_revenue,
145
+ plugins: default_plugins,
146
+ colors: ['#79AC78', '#3085C3'],
147
+ legend: { display: false },
148
+ formatYAxis: true
149
+ )
150
+
151
+ res.spacer height: 16
152
+ res.hr width: 'matchParent'
153
+ res.spacer height: 16
154
+
155
+ res.h2 text: 'Line charts'
156
+ res.label text: 'Use line charts for time-series trends and comparisons.'
157
+ res.spacer height: 8
158
+ res.charts_line(
159
+ dataSeries: line_series_revenue,
160
+ plugins: default_plugins,
161
+ colors: ['#79AC78', '#3085C3'],
162
+ legend: { display: false },
163
+ formatYAxis: true
164
+ )
165
+
166
+ res.spacer height: 12
167
+ res.charts_line \
168
+ plugins: { customTooltip: true },
169
+ colors: ['#3085C3'],
170
+ legend: { display: false },
171
+ dataSeries: [
172
+ -> do
173
+ json.title 'Delta'
174
+
175
+ points = {
176
+ 'Jan' => 100,
177
+ 'Feb' => 78,
178
+ 'Mar' => 70,
179
+ 'Apr' => 62,
180
+ }
181
+
182
+ prev = nil
183
+ json.points do
184
+ points.each do |k, v|
185
+ diff = prev.nil? ? 0 : v - prev
186
+ direction = diff >= 0 ? 'up' : 'down'
187
+ json.child! do
188
+ json.x k
189
+ json.y v
190
+ json.tooltip do
191
+ json.childViews do
192
+ res.panels_responsive \
193
+ padding: { top: 8, right: 8, left: 8, bottom: 8 },
194
+ backgroundColor: '#EDE4E3',
195
+ styleClasses: ['rounded-corner'],
196
+ childViews: ->(tooltip) do
197
+ tooltip.label text: "Month #{k}", color: '#6C6A61'
198
+ tooltip.spacer height: 4
199
+ tooltip.label text: "Delta #{direction} #{diff.abs}", color: '#6C6A61'
200
+ end
201
+ end
202
+ end
203
+ end
204
+ prev = v
205
+ end
206
+ end
207
+ end
208
+ ]
209
+
210
+ res.spacer height: 16
211
+ res.hr width: 'matchParent'
212
+ res.spacer height: 16
213
+
214
+ res.h2 text: 'Column charts'
215
+ res.label text: 'Column charts compare categories or stacked totals.'
216
+ res.spacer height: 8
217
+ res.charts_column(
218
+ dataGroups: [
219
+ -> do
220
+ json.title 'Series A'
221
+
222
+ points = {
223
+ '2019' => 10,
224
+ '2020' => 16,
225
+ '2021' => 22,
226
+ }
227
+ json.points points
228
+ end,
229
+ -> do
230
+ json.title 'Series B'
231
+
232
+ points = {
233
+ '2019' => 24,
234
+ '2020' => 22,
235
+ '2021' => 18,
236
+ }
237
+ json.points points
238
+ end
239
+ ],
240
+ plugins: default_plugins,
241
+ colors: ['#7A71F4', '#53B3E4'],
242
+ legend: { override: true }
243
+ )
244
+
245
+ res.spacer height: 12
246
+ res.charts_column \
247
+ horizontal: true,
248
+ stacked: true,
249
+ dataGroups: [
250
+ -> do
251
+ json.title 'Hotels'
252
+
253
+ points = {
254
+ 'Hotel One' => 10,
255
+ 'Hotel Two' => 16,
256
+ 'Hotel Three' => 18,
257
+ }
258
+ json.points points
259
+ end,
260
+ -> do
261
+ json.title 'Resorts'
262
+
263
+ points = {
264
+ 'Hotel One' => 24,
265
+ 'Hotel Two' => 22,
266
+ 'Hotel Three' => 12,
267
+ }
268
+ json.points points
269
+ end
270
+ ],
271
+ colors: ['#7A71F4', '#53B3E4'],
272
+ legend: { override: true }
273
+
274
+ res.spacer height: 16
275
+ res.hr width: 'matchParent'
276
+ res.spacer height: 16
277
+
278
+ plugins = default_plugins.deep_dup
279
+ plugins[:datalabels][:formatType] = 'label'
280
+ res.h2 text: 'Pie and donut charts'
281
+ res.label text: 'Pie and donut charts show composition for a small set of categories.'
282
+ res.spacer height: 8
283
+ res.charts_pie \
284
+ colors: ['#FC5A8D', '#F5E216'],
285
+ plugins: plugins,
286
+ dataPoints: [
287
+ { title: 'Strawberry', value: 25, label: 'Strawberry' },
288
+ { title: 'Banana', value: 75, label: 'Banana' }
289
+ ],
290
+ legend: { display: false }
291
+
292
+ res.spacer height: 12
293
+ res.charts_pie \
294
+ styleClasses: ['donut'],
295
+ suffix: '%',
296
+ colors: ['#FC5A8D', '#F5E216'],
297
+ plugins: default_plugins.merge({
298
+ centerLabel: {
299
+ labels: [
300
+ {
301
+ text: 'Fruits',
302
+ font: {
303
+ weight: 'bold',
304
+ size: 20
305
+ }
306
+ },
307
+ { text: 'You like' }
308
+ ]
309
+ }
310
+ }),
311
+ dataPoints: [
312
+ { title: 'Strawberry', value: 25 },
313
+ { title: 'Banana', value: 75 }
314
+ ],
315
+ legend: { position: 'right', override: true }
316
+
317
+ res.spacer height: 16
318
+ res.hr width: 'matchParent'
319
+ res.spacer height: 16
320
+
321
+ res.h2 text: 'Area chart'
322
+ res.label text: 'Area charts emphasize volume across time.'
323
+ res.spacer height: 8
324
+ res.charts_area \
325
+ dataPoints: [
326
+ { title: 'Jan', value: 25 },
327
+ { title: 'Feb', value: 55 },
328
+ { title: 'Mar', value: 60 },
329
+ { title: 'Apr', value: 45 }
330
+ ],
331
+ colors: ['#5B0888']
332
+
333
+ res.spacer height: 16
334
+ res.hr width: 'matchParent'
335
+ res.spacer height: 16
336
+
337
+ res.h2 text: 'Edge cases'
338
+ res.label text: 'Confirm empty and zero-value inputs render without errors.'
339
+ res.spacer height: 8
340
+ res.label text: 'Empty line chart'
341
+ res.spacer height: 6
342
+ res.charts_line dataSeries: [], legend: { display: false }
343
+
344
+ res.spacer height: 12
345
+ res.label text: 'Zero-value pie chart'
346
+ res.spacer height: 6
347
+ res.charts_pie \
348
+ colors: ['#999999', '#CCCCCC'],
349
+ dataPoints: [
350
+ { title: 'Zero A', value: 0 },
351
+ { title: 'Zero B', value: 0 }
352
+ ],
353
+ legend: { display: false }
354
+
355
+ # res.spacer height: 16
356
+ # res.hr width: 'matchParent'
357
+ # res.spacer height: 16
358
+
359
+ # res.h2 text: 'Actions'
360
+ # res.spacer height: 8
361
+ # res.panels_flow innerPadding: { bottom: 0 }, width: 'matchParent', childViews: ->(flow) do
362
+ # flow.button(
363
+ # text: 'Open full charts demo',
364
+ # onClick: ->(action) do
365
+ # action.windows_open url: json_ui_garage_url(path: 'views/charts')
366
+ # end
367
+ # )
368
+ # end
369
+ end
370
+ end
@@ -0,0 +1,121 @@
1
+ json.title 'Test Page (Column)'
2
+
3
+ page = json_ui_page json
4
+
5
+ page.body(
6
+ childViews: ->(body) do
7
+ render 'json_ui/garage/test_page/header', view: body
8
+ body.panels_responsive(
9
+ padding: glib_json_padding_body,
10
+ childViews: ->(res) do
11
+ res.h2 text: 'Overview'
12
+ res.p text: 'Column panels define sizing, ordering, and padding within responsive grids.'
13
+ res.spacer height: 12
14
+ res.hr width: 'matchParent'
15
+ res.h2 text: 'Basic'
16
+ res.spacer height: 8
17
+ res.panels_responsive(
18
+ width: 'matchParent',
19
+ childViews: ->(grid) do
20
+ grid.panels_column(
21
+ id: 'column_main',
22
+ lg: { cols: 6 },
23
+ xs: { cols: 12 },
24
+ childViews: ->(col) do
25
+ col.label text: 'Resizable column'
26
+ end
27
+ )
28
+ grid.panels_column(
29
+ lg: { cols: 6 },
30
+ xs: { cols: 12 },
31
+ childViews: ->(col) do
32
+ col.label text: 'Static column'
33
+ end
34
+ )
35
+ end
36
+ )
37
+ res.spacer height: 12
38
+ res.hr width: 'matchParent'
39
+ res.h2 text: 'Variants and Props'
40
+ res.spacer height: 8
41
+ res.panels_flow(
42
+ innerPadding: { bottom: 0 },
43
+ childViews: ->(flow) do
44
+ flow.button(
45
+ text: '6 cols',
46
+ onClick: ->(action) do
47
+ action.snackbars_alert message: 'Not implemented yet!'
48
+ end
49
+ )
50
+ flow.spacer width: 4
51
+ flow.button(
52
+ text: '4 cols',
53
+ onClick: ->(action) do
54
+ action.snackbars_alert message: 'Not implemented yet!'
55
+ end
56
+ )
57
+ flow.spacer width: 4
58
+ flow.button(
59
+ text: 'Add padding',
60
+ onClick: ->(action) do
61
+ action.components_set targetId: 'column_main', data: { padding: { all: 12 } }
62
+ end
63
+ )
64
+ flow.spacer width: 4
65
+ flow.button(
66
+ text: 'Clear padding',
67
+ onClick: ->(action) do
68
+ action.components_set targetId: 'column_main', data: { padding: nil }
69
+ end
70
+ )
71
+ end
72
+ )
73
+ res.spacer height: 12
74
+ res.hr width: 'matchParent'
75
+ res.h2 text: 'Actions and Events'
76
+ res.spacer height: 8
77
+ res.label id: 'column_action_status', text: 'Click status: idle'
78
+ res.spacer height: 6
79
+ res.panels_responsive(
80
+ width: 'matchParent',
81
+ childViews: ->(grid) do
82
+ grid.panels_column(
83
+ lg: { cols: 12 },
84
+ onClick: ->(action) do
85
+ action.components_set targetId: 'column_action_status', data: { text: 'Click status: clicked' }
86
+ end,
87
+ styleClasses: ['card'],
88
+ padding: { all: 8 },
89
+ childViews: ->(col) do
90
+ col.label text: 'Click this column'
91
+ end
92
+ )
93
+ end
94
+ )
95
+ res.spacer height: 12
96
+ res.hr width: 'matchParent'
97
+ res.h2 text: 'Edge and Advanced'
98
+ res.spacer height: 8
99
+ res.label text: 'Hidden on extra small screens'
100
+ res.panels_responsive(
101
+ width: 'matchParent',
102
+ childViews: ->(grid) do
103
+ grid.panels_column(
104
+ xsOnly: { hide: true },
105
+ sm: { cols: 6 },
106
+ childViews: ->(col) do
107
+ col.label text: 'Hidden on xs'
108
+ end
109
+ )
110
+ grid.panels_column(
111
+ sm: { cols: 6 },
112
+ childViews: ->(col) do
113
+ col.label text: 'Always visible'
114
+ end
115
+ )
116
+ end
117
+ )
118
+ end
119
+ )
120
+ end
121
+ )
@@ -0,0 +1,98 @@
1
+ json.title 'Test Page (Commands)'
2
+
3
+ page = json_ui_page json
4
+
5
+ page.body(
6
+ childViews: ->(body) do
7
+ render 'json_ui/garage/test_page/header', view: body
8
+ body.panels_responsive(
9
+ padding: glib_json_padding_body,
10
+ childViews: ->(res) do
11
+ res.h2 text: 'Commands'
12
+ res.label text: 'Clipboard and command actions.'
13
+ res.spacer height: 12
14
+ res.hr width: 'matchParent'
15
+ res.spacer height: 12
16
+
17
+ res.h2 text: 'Overview'
18
+ res.label text: 'Use command actions to copy values into the system clipboard.'
19
+ res.spacer height: 12
20
+ res.hr width: 'matchParent'
21
+ res.spacer height: 12
22
+
23
+ res.h2 text: 'Basic example'
24
+ res.spacer height: 8
25
+ res.button(
26
+ text: 'commands/copy',
27
+ onClick: ->(action) do
28
+ action.commands_copy text: 'Paste this somewhere else'
29
+ end
30
+ )
31
+
32
+ res.spacer height: 16
33
+ res.hr width: 'matchParent'
34
+ res.spacer height: 16
35
+
36
+ res.h2 text: 'Variants/props'
37
+ res.spacer height: 8
38
+ res.panels_flow(
39
+ innerPadding: { bottom: 0 },
40
+ width: 'matchParent',
41
+ childViews: ->(flow) do
42
+ flow.button(
43
+ text: 'commands/copy (short)',
44
+ onClick: ->(action) do
45
+ action.commands_copy text: 'Copied from commands test page'
46
+ end
47
+ )
48
+ flow.spacer width: 8
49
+ flow.button(
50
+ text: 'commands/copy (long)',
51
+ onClick: ->(action) do
52
+ action.commands_copy text: 'Long text: Lorem ipsum dolor sit amet, consectetur adipiscing elit.'
53
+ end
54
+ )
55
+ end
56
+ )
57
+
58
+ res.spacer height: 16
59
+ res.hr width: 'matchParent'
60
+ res.spacer height: 16
61
+
62
+ res.h2 text: 'Actions/events'
63
+ res.spacer height: 8
64
+ res.label id: 'commands_status', text: 'Status: idle'
65
+ res.spacer height: 8
66
+ res.button(
67
+ text: 'commands/copy (with onCopy)',
68
+ onClick: ->(action) do
69
+ action.commands_copy(
70
+ text: 'Copied with callback',
71
+ onCopy: ->(subaction) do
72
+ subaction.runMultiple(
73
+ childActions: ->(ssaction) do
74
+ ssaction.logics_set targetId: 'commands_status', data: { text: 'Status: copied' }
75
+ ssaction.snackbars_alert message: 'Copied', styleClass: 'success'
76
+ end
77
+ )
78
+ end
79
+ )
80
+ end
81
+ )
82
+
83
+ res.spacer height: 16
84
+ res.hr width: 'matchParent'
85
+ res.spacer height: 16
86
+
87
+ res.h2 text: 'Edge/advanced'
88
+ res.spacer height: 8
89
+ res.button(
90
+ text: 'commands/copy (multiline)',
91
+ onClick: ->(action) do
92
+ action.commands_copy text: "Line 1\nLine 2\nLine 3"
93
+ end
94
+ )
95
+ end
96
+ )
97
+ end
98
+ )