glib-web 0.13.1 → 0.14.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/glib/json_ui/abstract_builder.rb +31 -8
- data/app/helpers/glib/json_ui/menu_builder.rb +2 -2
- data/app/helpers/glib/json_ui/response_helper.rb +3 -10
- data/app/helpers/glib/json_ui/view_builder.rb +10 -3
- data/app/views/json_ui/garage/_nav_menu.json.jbuilder +2 -4
- data/app/views/json_ui/garage/forms/full_window_form.json.jbuilder +19 -0
- data/app/views/json_ui/garage/forms/index.json.jbuilder +5 -0
- data/app/views/json_ui/garage/forms/submit_on_change.json.jbuilder +13 -1
- data/app/views/json_ui/garage/pages/full_width.json.jbuilder +18 -18
- data/app/views/json_ui/garage/pages/tab_bar.json.jbuilder +15 -2
- data/app/views/json_ui/garage/views/banners.json.jbuilder +2 -2
- data/app/views/json_ui/garage/views/controls.json.jbuilder +12 -5
- data/app/views/json_ui/garage/views/icons.json.jbuilder +4 -0
- data/app/views/json_ui/garage/views/images.json.jbuilder +7 -6
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a291c995ace4d47df8d25452fb05610864b635e2b9d5389cc8355350d3deef22
|
4
|
+
data.tar.gz: 74ae4397312a86bca319d08e21f06d166d27ac98e4e5bb7181e8d18877a70eed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87a1ba8c343d1bd48978452a14ede6ee419cfe7694eb5935c72ae3437e4077264d29a15dc23f049fddbc9c6bf6f3d4622904cd534fbef509c3b67f332420084e
|
7
|
+
data.tar.gz: 99894f959d190a9ce3c515b5a4c9bece814e59ffa87826f69675c78f6592ec1400f387f7d7226c7bc9d236ec0e705c77c45ce9d7d9d1502c3177bc65068f1266
|
@@ -129,13 +129,7 @@ module Glib
|
|
129
129
|
|
130
130
|
def self.color(propName)
|
131
131
|
define_method(propName) do |value|
|
132
|
-
if (value = value
|
133
|
-
if !Rails.env.production?
|
134
|
-
if !value.match /^#([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/i
|
135
|
-
raise "Invalid color: #{value}"
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
132
|
+
if (value = to_color(value))
|
139
133
|
json.set! propName, value
|
140
134
|
end
|
141
135
|
end
|
@@ -162,7 +156,7 @@ module Glib
|
|
162
156
|
|
163
157
|
def self.string(propName, options = {})
|
164
158
|
define_method(propName) do |value|
|
165
|
-
str = value
|
159
|
+
str = to_string(value)
|
166
160
|
instance_variable_set("@#{propName}", str) if options[:cache]
|
167
161
|
json.set! propName, str
|
168
162
|
end
|
@@ -264,6 +258,15 @@ module Glib
|
|
264
258
|
end
|
265
259
|
end
|
266
260
|
|
261
|
+
def self.badgeable
|
262
|
+
define_method(:badge) do |value|
|
263
|
+
json.badge do
|
264
|
+
json.text to_string(value[:text])
|
265
|
+
json.backgroundColor to_color(value[:backgroundColor])
|
266
|
+
end
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
267
270
|
def self.action(propName)
|
268
271
|
define_method(propName) do |value|
|
269
272
|
json.set!(propName) { value.call(page.action_builder) }
|
@@ -318,6 +321,26 @@ module Glib
|
|
318
321
|
# To be overridden
|
319
322
|
end
|
320
323
|
|
324
|
+
### Reusable value converters
|
325
|
+
|
326
|
+
def to_string(value)
|
327
|
+
value&.to_s
|
328
|
+
end
|
329
|
+
|
330
|
+
def to_color(value)
|
331
|
+
value = value&.to_s
|
332
|
+
|
333
|
+
if value
|
334
|
+
if !Rails.env.production?
|
335
|
+
if !value.match /^#([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/i
|
336
|
+
raise "Invalid color: #{value}"
|
337
|
+
end
|
338
|
+
end
|
339
|
+
end
|
340
|
+
|
341
|
+
value
|
342
|
+
end
|
343
|
+
|
321
344
|
end
|
322
345
|
end
|
323
346
|
end
|
@@ -39,12 +39,12 @@ module Glib
|
|
39
39
|
end
|
40
40
|
|
41
41
|
class Button < MenuItem
|
42
|
+
badgeable
|
43
|
+
|
42
44
|
string :text
|
43
45
|
icon :icon
|
44
46
|
action :onClick
|
45
47
|
bool :disabled
|
46
|
-
color :badgeColor
|
47
|
-
string :badgeContent
|
48
48
|
singleton_array :styleClass, :styleClasses
|
49
49
|
|
50
50
|
def childButtons(block)
|
@@ -16,25 +16,18 @@ module Glib
|
|
16
16
|
end
|
17
17
|
|
18
18
|
json.onResponse do
|
19
|
-
response =
|
19
|
+
response = Glib::JsonUi::PageHelper::Page.new(json, self)
|
20
20
|
yield response.action_builder
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
class Response
|
25
|
-
attr_reader :action_builder
|
25
|
+
attr_reader :action_builder
|
26
26
|
|
27
|
-
def initialize(json, context
|
27
|
+
def initialize(json, context)
|
28
28
|
@json = json
|
29
29
|
@context = context
|
30
|
-
|
31
30
|
@action_builder = ActionBuilder.new(json, self, false)
|
32
|
-
|
33
|
-
if with_view_builder
|
34
|
-
@view_builder = ViewBuilder.new(json, self, true)
|
35
|
-
@list_section_builder = ListBuilders::Section.new(json, self, ListBuilders::Template.new(json, self))
|
36
|
-
@table_section_builder = TableBuilders::Section.new(json, self, TableBuilders::Template.new(json, self))
|
37
|
-
end
|
38
31
|
end
|
39
32
|
end
|
40
33
|
end
|
@@ -127,6 +127,8 @@ module Glib
|
|
127
127
|
end
|
128
128
|
|
129
129
|
class Image < View
|
130
|
+
badgeable
|
131
|
+
|
130
132
|
string :url
|
131
133
|
string :base64Data
|
132
134
|
action :onClick
|
@@ -134,12 +136,16 @@ module Glib
|
|
134
136
|
end
|
135
137
|
|
136
138
|
class Avatar < View
|
139
|
+
badgeable
|
140
|
+
|
137
141
|
int :size
|
138
142
|
string :url
|
139
143
|
action :onClick
|
140
144
|
end
|
141
145
|
|
142
146
|
class Icon < View
|
147
|
+
badgeable
|
148
|
+
|
143
149
|
# TODO: Remove later. Deprecated.
|
144
150
|
icon :spec
|
145
151
|
|
@@ -171,6 +177,8 @@ module Glib
|
|
171
177
|
# end
|
172
178
|
|
173
179
|
class Button < View
|
180
|
+
badgeable
|
181
|
+
|
174
182
|
icon :icon, cache: true
|
175
183
|
string :text, cache: true
|
176
184
|
action :onClick
|
@@ -207,11 +215,10 @@ module Glib
|
|
207
215
|
end
|
208
216
|
|
209
217
|
class Chip < View
|
218
|
+
badgeable
|
219
|
+
|
210
220
|
string :text
|
211
221
|
action :onClick
|
212
|
-
|
213
|
-
string :badgeContent
|
214
|
-
color :badgeColor
|
215
222
|
end
|
216
223
|
|
217
224
|
class Calendar < View
|
@@ -52,13 +52,11 @@ if local_assigns[:top_nav] || json_ui_app_is_web?
|
|
52
52
|
action.windows_open url: json_ui_garage_url
|
53
53
|
end
|
54
54
|
|
55
|
-
menu.button icon: 'refresh', text: 'Reload', onClick: ->(action) do
|
55
|
+
menu.button icon: 'refresh', text: 'Reload', badge: { text: '!' }, onClick: ->(action) do
|
56
56
|
action.windows_reload
|
57
57
|
end
|
58
58
|
|
59
|
-
#
|
60
|
-
# menu.button icon: { name: 'zoom_in', badge: '!' }, text: 'Diagnostics', onClick: ->(action) do
|
61
|
-
menu.button icon: 'zoom_in', text: 'Diagnostics', badgeContent: '!', onClick: ->(action) do
|
59
|
+
menu.button icon: { name: 'zoom_in', badge: { text: '?', backgroundColor: '#00ffff' } }, text: 'Diagnostics', onClick: ->(action) do
|
62
60
|
action.dialogs_alert message: %{
|
63
61
|
Bundle ID: #{json_ui_app_bundle_id || '<unknown>'}
|
64
62
|
App Version: #{json_ui_app_build_version || '<unknown>'}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
json.title 'Forms'
|
2
|
+
|
3
|
+
page = json_ui_page json
|
4
|
+
|
5
|
+
render "#{@path_prefix}/nav_menu", json: json, page: page
|
6
|
+
|
7
|
+
# The form will be automatically injected into the window.
|
8
|
+
#page.template 'full_window_form'
|
9
|
+
|
10
|
+
# TODO: This needs to produce page-level form attributes
|
11
|
+
page.form url: json_ui_garage_url(path: 'forms/basic_post'), method: 'post', padding: glib_json_padding_body, childViews: ->(form) do
|
12
|
+
# page.scroll padding: glib_json_padding_body, childViews: ->(form) do
|
13
|
+
form.fields_text name: 'user[name]', width: 'matchParent', label: 'Name'
|
14
|
+
form.fields_password name: 'user[password]', width: 'matchParent', label: 'Password'
|
15
|
+
end
|
16
|
+
|
17
|
+
page.footer padding: glib_json_padding_body, backgroundColor: '#b3bac2', childViews: ->(footer) do
|
18
|
+
footer.fields_submit text: 'Submit'
|
19
|
+
end
|
@@ -91,6 +91,11 @@ page.list sections: [
|
|
91
91
|
action.windows_open url: json_ui_garage_url(path: 'forms/styled_boxes')
|
92
92
|
end
|
93
93
|
end
|
94
|
+
# section.rows builder: ->(template) do
|
95
|
+
# template.thumbnail title: 'Full Window', onClick: ->(action) do
|
96
|
+
# action.windows_open url: json_ui_garage_url(path: 'forms/full_window_form')
|
97
|
+
# end
|
98
|
+
# end
|
94
99
|
end, ->(section) do
|
95
100
|
section.header padding: glib_json_padding_list, childViews: ->(header) do
|
96
101
|
header.h2 text: 'Web Only'
|
@@ -49,7 +49,7 @@ page.scroll childViews: ->(scroll) do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
form.spacer height: 20
|
52
|
-
form.
|
52
|
+
form.h2 text: 'Radio Group'
|
53
53
|
form.fields_radioGroup \
|
54
54
|
name: 'user[seniority]',
|
55
55
|
value: 'show',
|
@@ -65,6 +65,18 @@ page.scroll childViews: ->(scroll) do
|
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
+
form.spacer height: 20
|
69
|
+
form.h2 text: 'Text'
|
70
|
+
form.fields_text \
|
71
|
+
name: 'user[video_url]',
|
72
|
+
width: 'matchParent',
|
73
|
+
onChange: ->(action) do
|
74
|
+
action.sheets_select message: 'Submit data?', buttons: ->(menu) do
|
75
|
+
menu.button text: 'Yes, submit', onClick: ->(subaction) do
|
76
|
+
action.forms_submit
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
68
80
|
end
|
69
81
|
|
70
82
|
end
|
@@ -1,29 +1,29 @@
|
|
1
1
|
json.title 'Pages'
|
2
2
|
|
3
|
-
json_ui_page json
|
4
|
-
render "#{@path_prefix}/nav_menu", json: json, page: page
|
3
|
+
page = json_ui_page json
|
5
4
|
|
6
|
-
|
5
|
+
render "#{@path_prefix}/nav_menu", json: json, page: page
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
page.template 'fullWidth'
|
8
|
+
|
9
|
+
page.header childViews: ->(header) do
|
10
|
+
header.panels_vertical width: 'matchParent', styleClass: 'card', padding: glib_json_padding_body, childViews: ->(vertical) do
|
11
|
+
vertical.h1 text: 'Header'
|
13
12
|
end
|
13
|
+
header.spacer height: 10
|
14
|
+
end
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
16
|
+
page.footer childViews: ->(footer) do
|
17
|
+
footer.spacer height: 10
|
18
|
+
footer.panels_vertical width: 'matchParent', styleClass: 'card', padding: glib_json_padding_body, childViews: ->(vertical) do
|
19
|
+
vertical.h1 text: 'Footer'
|
20
20
|
end
|
21
|
+
end
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
23
|
+
page.body childViews: ->(scroll) do
|
24
|
+
scroll.panels_vertical width: 'matchParent', styleClass: 'card', padding: glib_json_padding_body, childViews: ->(vertical) do
|
25
|
+
(1..100).each do |index|
|
26
|
+
vertical.label text: 'Content'
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -7,6 +7,20 @@ json_ui_page json do |page|
|
|
7
7
|
scroll.panels_column lg: { cols: 8 }, childViews: ->(column) do
|
8
8
|
column.h2 text: 'Tab Bar with Badge'
|
9
9
|
column.tabBar buttons: ->(menu) do
|
10
|
+
badges = [
|
11
|
+
{
|
12
|
+
text: nil,
|
13
|
+
backgroundColor: nil
|
14
|
+
},
|
15
|
+
{
|
16
|
+
text: 8,
|
17
|
+
backgroundColor: '#272551'
|
18
|
+
},
|
19
|
+
{
|
20
|
+
text: '⭐⭐⭐',
|
21
|
+
backgroundColor: '#008000'
|
22
|
+
}
|
23
|
+
]
|
10
24
|
{
|
11
25
|
'FIRST' => 'home',
|
12
26
|
'SECOND' => 'schedule',
|
@@ -15,8 +29,7 @@ json_ui_page json do |page|
|
|
15
29
|
menu.button \
|
16
30
|
icon: icon,
|
17
31
|
text: text,
|
18
|
-
|
19
|
-
badgeColor: [nil, '#272551', '#008000'][index],
|
32
|
+
badge: badges[index],
|
20
33
|
disabled: params[:tab].to_i == index,
|
21
34
|
onClick: ->(action) do
|
22
35
|
action.windows_reload \
|
@@ -19,7 +19,7 @@ json_ui_page json do |page|
|
|
19
19
|
scroll.h2 text: 'With select options'
|
20
20
|
scroll.spacer height: 6
|
21
21
|
scroll.banners_select width: 'matchParent', icon: 'info', message: 'This is a select banner', buttons: ->(menu) do
|
22
|
-
menu.button icon: 'add', text: 'Add',
|
22
|
+
menu.button icon: 'add', text: 'Add', badge: { text: 80 }, onClick: ->(action) do
|
23
23
|
action.windows_open url: json_ui_garage_url(path: 'home/blank')
|
24
24
|
end
|
25
25
|
menu.button icon: 'edit', text: 'Edit', onClick: ->(action) do
|
@@ -33,7 +33,7 @@ json_ui_page json do |page|
|
|
33
33
|
submenu.button \
|
34
34
|
icon: 'add',
|
35
35
|
text: 'Option1',
|
36
|
-
|
36
|
+
badge: { text: 3 },
|
37
37
|
onClick: ->(action) do
|
38
38
|
action.windows_open url: json_ui_garage_url(path: 'home/blank')
|
39
39
|
end
|
@@ -11,13 +11,20 @@ page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
|
|
11
11
|
action.dialogs_alert message: 'Perform action'
|
12
12
|
end
|
13
13
|
|
14
|
-
scroll.
|
14
|
+
scroll.spacer height: 10
|
15
|
+
scroll.button text: 'Button with built-in classes', styleClasses: ['rounded', 'outlined', 'tile', 'depressed'], onClick: ->(action) do
|
15
16
|
action.dialogs_alert message: 'Perform action'
|
16
17
|
end
|
17
18
|
|
18
|
-
scroll.
|
19
|
-
|
20
|
-
|
19
|
+
scroll.spacer height: 10
|
20
|
+
scroll.button \
|
21
|
+
icon: 'info',
|
22
|
+
text: 'Button with Icon and Tooltip',
|
23
|
+
tooltip: { text: 'Tooltip text' },
|
24
|
+
badge: { text: '3' },
|
25
|
+
onClick: ->(action) do
|
26
|
+
action.dialogs_alert message: 'Perform action'
|
27
|
+
end
|
21
28
|
scroll.spacer height: 20
|
22
29
|
|
23
30
|
scroll.button \
|
@@ -38,7 +45,7 @@ page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
|
|
38
45
|
action.dialogs_alert message: 'Perform action'
|
39
46
|
end
|
40
47
|
scroll.spacer height: 10
|
41
|
-
scroll.chip text: 'With Badge',
|
48
|
+
scroll.chip text: 'With Badge', badge: { text: '99' }
|
42
49
|
|
43
50
|
scroll.spacer height: 20
|
44
51
|
scroll.h2 text: 'Switch'
|
@@ -12,4 +12,8 @@ page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
|
|
12
12
|
scroll.h2 text: 'Icon with color'
|
13
13
|
scroll.icon name: 'home', color: '#9370DB'
|
14
14
|
scroll.icon name: 'home', color: '#9370DB80'
|
15
|
+
|
16
|
+
scroll.spacer height: 20
|
17
|
+
scroll.h2 text: 'Icon with badge'
|
18
|
+
scroll.icon name: 'home', badge: { text: '22', backgroundColor: '#00ff00' }
|
15
19
|
end
|
@@ -13,10 +13,11 @@ page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
|
|
13
13
|
url: glib_json_image_avatar_url,
|
14
14
|
tooltip: { text: 'This is a tooltip' }
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
scroll.h2 text: 'Avatar with badge'
|
17
|
+
scroll.spacer height: 6
|
18
|
+
scroll.avatar \
|
19
|
+
url: glib_json_image_avatar_url,
|
20
|
+
badge: { text: '1', backgroundColor: '#0000ff' }
|
20
21
|
|
21
22
|
scroll.spacer height: 20
|
22
23
|
scroll.h2 text: 'Image with base64 data'
|
@@ -46,9 +47,9 @@ page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
|
|
46
47
|
scroll.image url: glib_json_image_standard_url
|
47
48
|
|
48
49
|
scroll.spacer height: 20
|
49
|
-
scroll.h2 text: 'Original size'
|
50
|
+
scroll.h2 text: 'Original size with badge'
|
50
51
|
scroll.spacer height: 6
|
51
|
-
scroll.image url: small_image_url
|
52
|
+
scroll.image url: small_image_url, badge: { text: '1', backgroundColor: '#0000ff' }
|
52
53
|
|
53
54
|
# Reference: https://docs.imgix.com/apis/url/size/fit#clip
|
54
55
|
scroll.spacer height: 20
|
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.
|
4
|
+
version: 0.14.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ''
|
@@ -153,6 +153,7 @@ files:
|
|
153
153
|
- app/views/json_ui/garage/forms/dynamic_select_data.json.jbuilder
|
154
154
|
- app/views/json_ui/garage/forms/file_upload.json.jbuilder
|
155
155
|
- app/views/json_ui/garage/forms/floating_submit.json.jbuilder
|
156
|
+
- app/views/json_ui/garage/forms/full_window_form.json.jbuilder
|
156
157
|
- app/views/json_ui/garage/forms/generic_post.json.jbuilder
|
157
158
|
- app/views/json_ui/garage/forms/index.json.jbuilder
|
158
159
|
- app/views/json_ui/garage/forms/local_request.json.jbuilder
|