glib-web 0.5.37 → 0.5.42
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 +4 -4
- data/app/controllers/concerns/glib/json/ui.rb +4 -1
- data/app/helpers/glib/json_ui/abstract_builder.rb +8 -0
- data/app/helpers/glib/json_ui/list_builders.rb +12 -13
- data/app/helpers/glib/json_ui/page_helper.rb +7 -2
- data/app/helpers/glib/json_ui/view_builder.rb +2 -0
- data/app/helpers/glib/json_ui/view_builder/fields.rb +8 -4
- data/app/helpers/glib/json_ui/view_builder/panels.rb +15 -0
- data/app/views/json_ui/garage/forms/conditional_value.json.jbuilder +36 -0
- data/app/views/json_ui/garage/forms/index.json.jbuilder +3 -0
- data/app/views/json_ui/garage/forms/show_hide.json.jbuilder +0 -0
- data/app/views/json_ui/garage/lists/edit_actions.json.jbuilder +12 -1
- data/app/views/json_ui/garage/lists/index.json.jbuilder +1 -1
- data/app/views/json_ui/garage/views/index.json.jbuilder +3 -0
- data/app/views/json_ui/garage/views/map_cluster_data.json.jbuilder +38 -0
- data/app/views/json_ui/garage/views/map_data.json.jbuilder +10 -2
- data/app/views/json_ui/garage/views/maps.json.jbuilder +31 -0
- data/app/views/json_ui/garage/views/misc.json.jbuilder +4 -4
- data/lib/glib/json_crawler/action_crawlers/nav_initiate.rb +3 -1
- data/lib/glib/json_crawler/action_crawlers/windows_open.rb +3 -1
- data/lib/glib/json_crawler/router.rb +2 -2
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ab405054fbe1b42c1027a1b17f3c347be295c9321b02a0bb34be63171d1ec84
|
4
|
+
data.tar.gz: 0f2ee1810c68d21052d45a9c2a8c8eecfc793b4dc6cb75ade1b3055786658ba5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe5d7dc16c90de11ac3202e08911df710815b510798ca1c97184faafbdd8ea9d1fe533caf04ff8e3ca40da0ffdb6e4ebed07e6b369c2693d7e833238621a88df
|
7
|
+
data.tar.gz: 85b8e9cb0c45abf9a5127842dc2f31f0be322e04833a28ff7bab5fbc1425f534cdee2d06cd92b6a2b7e0445d164a081edd268ad0d999c6957c4a3db63e6a4901
|
@@ -23,6 +23,7 @@ module Glib::Json::Ui
|
|
23
23
|
options = {}
|
24
24
|
options[:_render] = params[:_render]
|
25
25
|
options[:_locale] = params[:_locale]
|
26
|
+
options[:_preview] = params[:_preview]
|
26
27
|
options[:format] = :json if request.format == :json
|
27
28
|
options
|
28
29
|
end
|
@@ -56,7 +57,9 @@ module Glib::Json::Ui
|
|
56
57
|
@__json_ui_activated = true
|
57
58
|
request.variant = :ui
|
58
59
|
|
59
|
-
|
60
|
+
# Some bots (e.g. Line and DuckDuckGo) passes `*/*` in the `Accept` header
|
61
|
+
is_html = request.format.html? || request.format == '*/*'
|
62
|
+
if is_html && params[:_skip_render] != 'true'
|
60
63
|
@__json_ui_rendering = :vue
|
61
64
|
request.format = 'json'
|
62
65
|
end
|
@@ -263,6 +263,14 @@ module Glib
|
|
263
263
|
end
|
264
264
|
end
|
265
265
|
|
266
|
+
def self.menu(propName)
|
267
|
+
define_method(propName) do |value|
|
268
|
+
json.set! propName do
|
269
|
+
value.call(page.menu_builder)
|
270
|
+
end
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
266
274
|
def self.singleton_array(singletonName, arrayName)
|
267
275
|
array arrayName
|
268
276
|
|
@@ -7,23 +7,22 @@ module Glib
|
|
7
7
|
end
|
8
8
|
|
9
9
|
class AbstractTemplate < JsonUiElement
|
10
|
-
|
11
|
-
|
10
|
+
menu :leftButtons
|
11
|
+
menu :rightButtons
|
12
|
+
menu :editButtons
|
13
|
+
menu :chips
|
14
|
+
|
15
|
+
# def editButtons(block)
|
16
|
+
# json.editButtons do
|
12
17
|
# block.call page.menu_builder
|
13
18
|
# end
|
14
19
|
# end
|
15
20
|
|
16
|
-
def
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
def chips(block)
|
23
|
-
json.chips do
|
24
|
-
block.call page.menu_builder
|
25
|
-
end
|
26
|
-
end
|
21
|
+
# def chips(block)
|
22
|
+
# json.chips do
|
23
|
+
# block.call page.menu_builder
|
24
|
+
# end
|
25
|
+
# end
|
27
26
|
end
|
28
27
|
|
29
28
|
class Standard < AbstractTemplate
|
@@ -48,10 +48,15 @@ module Glib
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def json_ui_action(json)
|
51
|
-
@
|
52
|
-
@
|
51
|
+
@__json_ui_action ||= Page.new(json, self)
|
52
|
+
@__json_ui_action.action_builder
|
53
53
|
end
|
54
54
|
|
55
|
+
# def json_ui_view(json)
|
56
|
+
# @__json_ui_view ||= Page.new(json, self)
|
57
|
+
# @__json_ui_view.view_builder
|
58
|
+
# end
|
59
|
+
|
55
60
|
def json_ui_action_payload(&block)
|
56
61
|
dataJson = Jbuilder.new
|
57
62
|
block&.call Page.new(dataJson, self).action_builder
|
@@ -30,6 +30,7 @@ module Glib
|
|
30
30
|
hash :padding
|
31
31
|
singleton_array :styleClass, :styleClasses
|
32
32
|
hash :showIf
|
33
|
+
hash :valueIf
|
33
34
|
hash :analytics
|
34
35
|
|
35
36
|
# def initialize(json, page)
|
@@ -157,6 +158,7 @@ module Glib
|
|
157
158
|
float :longitude
|
158
159
|
int :zoom
|
159
160
|
string :dataUrl
|
161
|
+
bool :cluster
|
160
162
|
end
|
161
163
|
|
162
164
|
class Chip < View
|
@@ -4,6 +4,7 @@ class Glib::JsonUi::ViewBuilder
|
|
4
4
|
class AbstractField < View
|
5
5
|
bool :readOnly
|
6
6
|
hash :validation
|
7
|
+
# string :label
|
7
8
|
|
8
9
|
def label(label)
|
9
10
|
@label = label
|
@@ -39,20 +40,20 @@ class Glib::JsonUi::ViewBuilder
|
|
39
40
|
|
40
41
|
def prop(prop)
|
41
42
|
@prop = prop
|
42
|
-
# if (form = page.current_form)
|
43
|
-
# @name ||= form.field_name(prop)
|
44
|
-
# @value ||= form.field_value(prop)
|
45
|
-
# end
|
46
43
|
end
|
47
44
|
|
48
45
|
# Override
|
49
46
|
def created
|
50
47
|
if @prop && (form = page.current_form)
|
48
|
+
form.field_assert_respond_to(@prop)
|
49
|
+
|
51
50
|
@name ||= form.field_name(@prop, @multiple || false)
|
52
51
|
@value ||= form.field_value(@prop)
|
53
52
|
@label ||= form.field_label(@prop, @label_args || {})
|
54
53
|
@hint ||= form.hint_label(@prop, @hint_args || {})
|
55
54
|
@placeholder ||= form.placeholder_label(@prop, @placeholder_args || {})
|
55
|
+
|
56
|
+
@validation ||= form.field_validation(@prop)
|
56
57
|
end
|
57
58
|
json.name @name
|
58
59
|
json.value @value if @value
|
@@ -63,6 +64,9 @@ class Glib::JsonUi::ViewBuilder
|
|
63
64
|
# - Placeholder gets hidden when there is input which may be confusing
|
64
65
|
# - Placeholder competes with label for space
|
65
66
|
json.placeholder @placeholder if @placeholder
|
67
|
+
|
68
|
+
# TODO: Add a flag so the framework's user can turn it on and off.
|
69
|
+
# json.validation @validation if @validation
|
66
70
|
end
|
67
71
|
|
68
72
|
end
|
@@ -16,6 +16,11 @@ class Glib::JsonUi::ViewBuilder
|
|
16
16
|
@model.class.try(:reflect_on_association, prop)&.macro == :has_many
|
17
17
|
end
|
18
18
|
|
19
|
+
def field_assert_respond_to(prop)
|
20
|
+
# Identify a prop being used on a nil model or incorrect model.
|
21
|
+
raise "Invalid property `#{prop}` on '#{@model.class}'" unless @model.respond_to?(prop)
|
22
|
+
end
|
23
|
+
|
19
24
|
def field_name(prop, multiple)
|
20
25
|
suffix = is_array_association?(prop) || multiple ? '[]' : ''
|
21
26
|
"#{@model_name}[#{prop}]#{suffix}"
|
@@ -41,6 +46,16 @@ class Glib::JsonUi::ViewBuilder
|
|
41
46
|
I18n.t("dt_models.#{@model_name}.#{prop}.placeholder", args.merge(default: nil))
|
42
47
|
end
|
43
48
|
|
49
|
+
def field_validation(prop)
|
50
|
+
validations = {}
|
51
|
+
@model.class.validators_on(prop).each do |validator|
|
52
|
+
if validator.kind == :presence
|
53
|
+
validations[:required] = { message: 'Required' }
|
54
|
+
end
|
55
|
+
end
|
56
|
+
validations
|
57
|
+
end
|
58
|
+
|
44
59
|
def url(url)
|
45
60
|
@url = url
|
46
61
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
json.title 'Forms'
|
2
|
+
|
3
|
+
page = json_ui_page json
|
4
|
+
render "#{@path_prefix}/nav_menu", json: json, page: page
|
5
|
+
|
6
|
+
page.form url: json_ui_garage_url(path: 'forms/generic_post'), method: 'post', padding: glib_json_padding_body, childViews: ->(form) do
|
7
|
+
form.spacer height: 20
|
8
|
+
form.h2 text: 'Date'
|
9
|
+
form.spacer height: 6
|
10
|
+
form.fields_date name: 'user[date_start]', width: 'matchParent', label: 'Start Date', min: '2010-01-01', max: '2012-01-01', value: '2010-02-01'
|
11
|
+
form.fields_date name: 'user[date_end]', width: 'matchParent', label: 'End Date', min: '2010-01-01', max: '2012-01-01', valueIf: {
|
12
|
+
"+": [
|
13
|
+
{
|
14
|
+
"var": 'user[date_start]'
|
15
|
+
},
|
16
|
+
24 * 3600
|
17
|
+
]
|
18
|
+
}
|
19
|
+
|
20
|
+
form.spacer height: 20
|
21
|
+
form.h2 text: 'Date/Time'
|
22
|
+
form.spacer height: 6
|
23
|
+
form.fields_datetime name: 'user[datetime_start]', width: 'matchParent', label: 'Start Date', min: '2010-01-01', max: '2012-01-01', value: '2010-02-01T01:00'
|
24
|
+
form.fields_datetime name: 'user[datetime_end]', width: 'matchParent', label: 'End Date', min: '2010-01-01', max: '2012-01-01', valueIf: {
|
25
|
+
"+": [
|
26
|
+
{
|
27
|
+
"var": 'user[datetime_start]'
|
28
|
+
},
|
29
|
+
3600
|
30
|
+
]
|
31
|
+
}
|
32
|
+
|
33
|
+
form.spacer height: 20
|
34
|
+
form.fields_submit text: 'Submit'
|
35
|
+
form.spacer height: 40
|
36
|
+
end
|
@@ -36,6 +36,9 @@ json_ui_page json do |page|
|
|
36
36
|
template.thumbnail title: 'Show/Hide', onClick: ->(action) do
|
37
37
|
action.windows_open url: json_ui_garage_url(path: 'forms/show_hide')
|
38
38
|
end
|
39
|
+
template.thumbnail title: 'Conditional Value', onClick: ->(action) do
|
40
|
+
action.windows_open url: json_ui_garage_url(path: 'forms/conditional_value')
|
41
|
+
end
|
39
42
|
|
40
43
|
end
|
41
44
|
end, ->(section) do
|
File without changes
|
@@ -5,7 +5,18 @@ json_ui_page json do |page|
|
|
5
5
|
|
6
6
|
page.list firstSection: ->(section) do
|
7
7
|
section.rows builder: ->(template) do
|
8
|
-
template.thumbnail title: 'Click menu (web) or swipe left (Android/iOS)',
|
8
|
+
template.thumbnail title: 'Click menu (web) or swipe left (Android/iOS)', leftButtons: ->(menu) do
|
9
|
+
menu.button styleClass: 'icon', icon: 'check_box', onClick: ->(subaction) do
|
10
|
+
subaction.dialogs_alert message: 'Tick/untick'
|
11
|
+
end
|
12
|
+
end, rightButtons: ->(menu) do
|
13
|
+
menu.button styleClass: 'icon', icon: 'share', onClick: ->(subaction) do
|
14
|
+
subaction.dialogs_alert message: 'Share'
|
15
|
+
end
|
16
|
+
menu.button styleClass: 'icon', icon: 'open_in_new', onClick: ->(subaction) do
|
17
|
+
subaction.dialogs_alert message: 'Open'
|
18
|
+
end
|
19
|
+
end, editButtons: ->(menu) do
|
9
20
|
menu.button text: 'Edit', onClick: ->(action) do
|
10
21
|
action.dialogs_alert message: 'Perform action'
|
11
22
|
end
|
@@ -8,7 +8,7 @@ json_ui_page json do |page|
|
|
8
8
|
template.thumbnail icon: 'list', title: 'Templating', onClick: ->(action) do
|
9
9
|
action.windows_open url: json_ui_garage_url(path: 'lists/templating')
|
10
10
|
end
|
11
|
-
template.thumbnail title: '
|
11
|
+
template.thumbnail title: 'Action Buttons', onClick: ->(action) do
|
12
12
|
action.windows_open url: json_ui_garage_url(path: 'lists/edit_actions')
|
13
13
|
end
|
14
14
|
template.thumbnail title: 'FAB (Floating Action Button)', onClick: ->(action) do
|
@@ -22,6 +22,9 @@ json_ui_page json do |page|
|
|
22
22
|
template.thumbnail title: 'Banners', onClick: ->(action) do
|
23
23
|
action.windows_open url: json_ui_garage_url(path: 'views/banners')
|
24
24
|
end
|
25
|
+
template.thumbnail title: 'Maps', onClick: ->(action) do
|
26
|
+
action.windows_open url: json_ui_garage_url(path: 'views/maps')
|
27
|
+
end
|
25
28
|
template.thumbnail title: 'Misc', onClick: ->(action) do
|
26
29
|
action.windows_open url: json_ui_garage_url(path: 'views/misc')
|
27
30
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
json.pins do
|
3
|
+
locations = [
|
4
|
+
{ lat: -31.56391, lng: 147.154312 },
|
5
|
+
{ lat: -33.718234, lng: 150.363181 },
|
6
|
+
{ lat: -33.727111, lng: 150.371124 },
|
7
|
+
{ lat: -33.848588, lng: 151.209834 },
|
8
|
+
{ lat: -33.851702, lng: 151.216968 },
|
9
|
+
{ lat: -34.671264, lng: 150.863657 },
|
10
|
+
{ lat: -35.304724, lng: 148.662905 },
|
11
|
+
{ lat: -36.817685, lng: 175.699196 },
|
12
|
+
{ lat: -36.828611, lng: 175.790222 },
|
13
|
+
{ lat: -37.75, lng: 145.116667 },
|
14
|
+
{ lat: -37.759859, lng: 145.128708 },
|
15
|
+
{ lat: -37.765015, lng: 145.133858 },
|
16
|
+
{ lat: -37.770104, lng: 145.143299 },
|
17
|
+
{ lat: -37.7737, lng: 145.145187 },
|
18
|
+
{ lat: -37.774785, lng: 145.137978 },
|
19
|
+
{ lat: -37.819616, lng: 144.968119 },
|
20
|
+
{ lat: -38.330766, lng: 144.695692 },
|
21
|
+
{ lat: -39.927193, lng: 175.053218 },
|
22
|
+
{ lat: -41.330162, lng: 174.865694 },
|
23
|
+
{ lat: -42.734358, lng: 147.439506 },
|
24
|
+
{ lat: -42.734358, lng: 147.501315 },
|
25
|
+
{ lat: -42.735258, lng: 147.438 },
|
26
|
+
{ lat: -43.999792, lng: 170.463352 },
|
27
|
+
];
|
28
|
+
|
29
|
+
locations.each do |location|
|
30
|
+
json.child! do
|
31
|
+
json.latitude location[:lat]
|
32
|
+
json.longitude location[:lng]
|
33
|
+
json.infoWindow do
|
34
|
+
json.title "TEST #{rand(1000)}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
|
2
|
-
json
|
2
|
+
page = json_ui_page json
|
3
3
|
|
4
|
+
json.pins do
|
4
5
|
latitude = params[:lat]&.to_f
|
5
6
|
longitude = params[:long]&.to_f
|
6
7
|
|
@@ -37,7 +38,14 @@ json.pins do
|
|
37
38
|
json.infoWindow do
|
38
39
|
json.title 'You'
|
39
40
|
json.subtitle 'Current location'
|
40
|
-
|
41
|
+
|
42
|
+
json.body do
|
43
|
+
page.vertical_content padding: { top: 10 }, childViews: ->(body) do
|
44
|
+
body.button text: 'Info', onClick: ->(action) do
|
45
|
+
action.dialogs_alert message: "#{latitude}, #{longitude}"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
41
49
|
end
|
42
50
|
end
|
43
51
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
json.title 'Views'
|
2
|
+
|
3
|
+
json_ui_page json do |page|
|
4
|
+
render "#{@path_prefix}/nav_menu", json: json, page: page
|
5
|
+
|
6
|
+
page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
|
7
|
+
scroll.spacer height: 20
|
8
|
+
scroll.h2 text: 'Map with Markers'
|
9
|
+
scroll.spacer height: 6
|
10
|
+
scroll.map \
|
11
|
+
width: 'matchParent',
|
12
|
+
latitude: 13.4837,
|
13
|
+
longitude: 144.7917,
|
14
|
+
zoom: 11,
|
15
|
+
height: 250,
|
16
|
+
dataUrl: json_ui_garage_url(path: 'views/map_data')
|
17
|
+
|
18
|
+
scroll.spacer height: 20
|
19
|
+
scroll.h2 text: 'Map with Clustered Markers'
|
20
|
+
scroll.spacer height: 6
|
21
|
+
scroll.map \
|
22
|
+
width: 'matchParent',
|
23
|
+
latitude: -42.162376,
|
24
|
+
longitude: 172.671437,
|
25
|
+
zoom: 7,
|
26
|
+
height: 480,
|
27
|
+
cluster: true,
|
28
|
+
dataUrl: json_ui_garage_url(path: 'views/map_cluster_data')
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -20,10 +20,10 @@ json_ui_page json do |page|
|
|
20
20
|
scroll.datetime value: 1.week.ago, format: 'YYYY-MM-DD'
|
21
21
|
scroll.datetime value: DateTime.current, format: 'hh:mm:ss', tick: true
|
22
22
|
|
23
|
-
scroll.spacer height: 20
|
24
|
-
scroll.h2 text: 'Map'
|
25
|
-
scroll.spacer height: 6
|
26
|
-
scroll.map width: 'matchParent', latitude: 13.4837, longitude: 144.7917, zoom: 11, height: 250, dataUrl: json_ui_garage_url(path: 'views/map_data')
|
23
|
+
# scroll.spacer height: 20
|
24
|
+
# scroll.h2 text: 'Map'
|
25
|
+
# scroll.spacer height: 6
|
26
|
+
# scroll.map width: 'matchParent', latitude: 13.4837, longitude: 144.7917, zoom: 11, height: 250, dataUrl: json_ui_garage_url(path: 'views/map_data')
|
27
27
|
|
28
28
|
scroll.spacer height: 20
|
29
29
|
scroll.h2 text: 'Calendar'
|
@@ -30,8 +30,8 @@ module Glib
|
|
30
30
|
end
|
31
31
|
|
32
32
|
if args.is_a?(Hash) && args['rel'] != 'nofollow'
|
33
|
-
if (
|
34
|
-
process_action(http,
|
33
|
+
if (on_click = (args.fetch('onClick', nil)))
|
34
|
+
process_action(http, on_click)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
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.
|
4
|
+
version: 0.5.42
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ''
|
@@ -125,6 +125,7 @@ files:
|
|
125
125
|
- app/views/json_ui/garage/forms/basic.json.jbuilder
|
126
126
|
- app/views/json_ui/garage/forms/basic_post.json.jbuilder
|
127
127
|
- app/views/json_ui/garage/forms/checkboxes.json.jbuilder
|
128
|
+
- app/views/json_ui/garage/forms/conditional_value.json.jbuilder
|
128
129
|
- app/views/json_ui/garage/forms/dynamic_group.json.jbuilder
|
129
130
|
- app/views/json_ui/garage/forms/dynamic_select.json.jbuilder
|
130
131
|
- app/views/json_ui/garage/forms/dynamic_select_data.json.jbuilder
|
@@ -197,7 +198,9 @@ files:
|
|
197
198
|
- app/views/json_ui/garage/views/images.json.jbuilder
|
198
199
|
- app/views/json_ui/garage/views/index.json.jbuilder
|
199
200
|
- app/views/json_ui/garage/views/links.json.jbuilder
|
201
|
+
- app/views/json_ui/garage/views/map_cluster_data.json.jbuilder
|
200
202
|
- app/views/json_ui/garage/views/map_data.json.jbuilder
|
203
|
+
- app/views/json_ui/garage/views/maps.json.jbuilder
|
201
204
|
- app/views/json_ui/garage/views/markdowns.json.jbuilder
|
202
205
|
- app/views/json_ui/garage/views/misc.json.jbuilder
|
203
206
|
- app/views/json_ui/garage/views/texts.json.jbuilder
|