glib-web 0.5.8 → 0.5.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/concerns/glib/json/ui.rb +7 -0
- data/app/helpers/glib/json_ui/abstract_builder.rb +7 -1
- data/app/helpers/glib/json_ui/action_builder.rb +39 -6
- data/app/helpers/glib/json_ui/list_builders.rb +18 -4
- data/app/helpers/glib/json_ui/page_helper.rb +7 -2
- data/app/helpers/glib/json_ui/response_helper.rb +1 -1
- data/app/helpers/glib/json_ui/view_builder/fields.rb +7 -2
- data/app/views/json_ui/garage/actions/_sheets.json.jbuilder +0 -1
- data/app/views/json_ui/garage/forms/show_hide.json.jbuilder +20 -3
- data/app/views/json_ui/garage/forms/text_validation.json.jbuilder +1 -1
- data/app/views/json_ui/garage/lists/chat.json.jbuilder +112 -0
- data/app/views/json_ui/garage/lists/edit_actions.json.jbuilder +25 -1
- data/app/views/json_ui/garage/lists/index.json.jbuilder +3 -0
- data/app/views/json_ui/garage/tables/_autoload_section.json.jbuilder +1 -2
- data/app/views/json_ui/garage/tables/autoload_as_needed.json.jbuilder +19 -19
- data/lib/glib/json_crawler.rb +1 -0
- data/lib/glib/json_crawler/action_crawler.rb +4 -1
- data/lib/glib/json_crawler/action_crawlers/action_http.rb +2 -5
- data/lib/glib/json_crawler/action_crawlers/forms_submit.rb +2 -2
- data/lib/glib/json_crawler/action_crawlers/nav_initiate.rb +2 -0
- data/lib/glib/json_crawler/action_crawlers/run_multiple.rb +13 -0
- data/lib/glib/json_crawler/action_crawlers/windows_open.rb +3 -0
- data/lib/glib/json_crawler/router.rb +35 -29
- metadata +3 -2
- data/app/views/app/views/json_ui/vue/renderer.html.erb +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f440c189aedc472b187e045fc6a7f860450f8301
|
4
|
+
data.tar.gz: 395891b80b5ca90022b42f5216003d57006a5ebc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29f95c4110b05050e3d5a28035c12c62c1bae2448798882f629fb1e2c0fd5a9b9e40c9df149f6ec90233dbce339d1a83830c99245cee5a33559c7fe7c3d283e7
|
7
|
+
data.tar.gz: 01fee1f715657b457dfd1f4e2026db4e014c5912c446c12e6042b8b416e0119e9da985491d37fee39af24c3576a40d3da41d2c3916820b4b13b4da71cdc1a6fd
|
@@ -31,6 +31,13 @@ module Glib::Json::Ui
|
|
31
31
|
@__json_ui_activated
|
32
32
|
end
|
33
33
|
|
34
|
+
def json_ui_page_lifecycle_prop(name)
|
35
|
+
if (hash = json_transformation_start).is_a?(Hash) && hash['body'] # A valid page
|
36
|
+
hash[name] ||= { 'action' => 'runMultiple', 'childActions' => [] }
|
37
|
+
hash[name]['childActions']
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
34
41
|
def __json_ui_start(options)
|
35
42
|
@__json_ui_activated = false
|
36
43
|
@__json_ui_rendering = nil
|
@@ -69,6 +69,12 @@ module Glib
|
|
69
69
|
|
70
70
|
private
|
71
71
|
|
72
|
+
def self.any(propName)
|
73
|
+
define_method(propName) do |value|
|
74
|
+
json.set! propName, value
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
72
78
|
def self.date(propName)
|
73
79
|
define_method(propName) do |value|
|
74
80
|
json.set! propName, value&.to_date
|
@@ -191,7 +197,7 @@ module Glib
|
|
191
197
|
json.set!(propName) do
|
192
198
|
if name
|
193
199
|
data[:material] ||= {}
|
194
|
-
data[:material][:name] = name
|
200
|
+
data[:material][:name] = name
|
195
201
|
end
|
196
202
|
|
197
203
|
if (material = data[:material])
|
@@ -1,8 +1,18 @@
|
|
1
1
|
module Glib
|
2
2
|
module JsonUi
|
3
3
|
class ActionBuilder < AbstractBuilder
|
4
|
-
def
|
5
|
-
|
4
|
+
def initialize(json, page, multiple)
|
5
|
+
super(json, page)
|
6
|
+
|
7
|
+
@multiple = multiple
|
8
|
+
end
|
9
|
+
|
10
|
+
def method_missing(m, *args)
|
11
|
+
if @multiple
|
12
|
+
add_element_to_array_v1 'action', m, *args
|
13
|
+
else
|
14
|
+
add_singleton_element_v1 'action', m, *args
|
15
|
+
end
|
6
16
|
end
|
7
17
|
|
8
18
|
class Action < JsonUiElement
|
@@ -38,19 +48,34 @@ module Glib
|
|
38
48
|
|
39
49
|
### Action definitions
|
40
50
|
|
51
|
+
class RunMultiple < Action
|
52
|
+
def childActions(block)
|
53
|
+
json.childActions do
|
54
|
+
block.call ActionBuilder.new(json, page, true)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
41
59
|
module Forms
|
42
60
|
class Submit < Action
|
43
61
|
end
|
44
|
-
|
45
62
|
end
|
46
63
|
|
47
|
-
# Consider deprecating this. See Data
|
48
64
|
module Auth
|
49
65
|
class SaveCsrfToken < Action
|
50
66
|
string :token
|
51
67
|
action :onSave
|
52
68
|
end
|
53
69
|
|
70
|
+
class Restart < Action
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
module Analytics
|
75
|
+
class LogEvent < Action
|
76
|
+
string :name
|
77
|
+
hash :params
|
78
|
+
end
|
54
79
|
end
|
55
80
|
|
56
81
|
module Timeouts
|
@@ -59,6 +84,10 @@ module Glib
|
|
59
84
|
action :onTimeout
|
60
85
|
end
|
61
86
|
|
87
|
+
# FUTURE
|
88
|
+
class Remove < Action
|
89
|
+
end
|
90
|
+
|
62
91
|
# FUTURE
|
63
92
|
class Clear < Action
|
64
93
|
end
|
@@ -66,11 +95,15 @@ module Glib
|
|
66
95
|
|
67
96
|
# FUTURE
|
68
97
|
module Data
|
69
|
-
class
|
70
|
-
string :
|
98
|
+
class Save < Action
|
99
|
+
string :key
|
100
|
+
string :value
|
71
101
|
action :onSave
|
72
102
|
end
|
73
103
|
|
104
|
+
class Remove < Action
|
105
|
+
end
|
106
|
+
|
74
107
|
class Clear < Action
|
75
108
|
end
|
76
109
|
end
|
@@ -7,7 +7,11 @@ module Glib
|
|
7
7
|
end
|
8
8
|
|
9
9
|
class AbstractTemplate < JsonUiElement
|
10
|
-
#
|
10
|
+
# def contextButtons(block)
|
11
|
+
# json.contextButtons do
|
12
|
+
# block.call page.menu_builder
|
13
|
+
# end
|
14
|
+
# end
|
11
15
|
|
12
16
|
def editButtons(block)
|
13
17
|
json.editButtons do
|
@@ -22,12 +26,13 @@ module Glib
|
|
22
26
|
end
|
23
27
|
end
|
24
28
|
|
25
|
-
class
|
29
|
+
class Standard < AbstractTemplate
|
26
30
|
string :title
|
27
31
|
string :subtitle
|
28
32
|
string :subsubtitle
|
29
33
|
string :imageUrl
|
30
34
|
action :onClick
|
35
|
+
action :onLongPress
|
31
36
|
icon :icon
|
32
37
|
bool :avatar
|
33
38
|
|
@@ -36,10 +41,19 @@ module Glib
|
|
36
41
|
# views :accessoryViews
|
37
42
|
end
|
38
43
|
|
39
|
-
class Featured <
|
44
|
+
class Featured < Standard
|
40
45
|
end
|
41
46
|
|
42
|
-
class
|
47
|
+
class Thumbnail < Standard
|
48
|
+
end
|
49
|
+
|
50
|
+
class CommentOutgoing < Standard
|
51
|
+
end
|
52
|
+
|
53
|
+
class CommentIncoming < Standard
|
54
|
+
end
|
55
|
+
|
56
|
+
class Custom < Standard
|
43
57
|
string :template
|
44
58
|
|
45
59
|
# TODO: Experimental
|
@@ -35,11 +35,16 @@ module Glib
|
|
35
35
|
# json.attributes!
|
36
36
|
# end
|
37
37
|
|
38
|
-
def json_ui_section(json
|
38
|
+
def json_ui_section(json)
|
39
39
|
@__json_ui_section ||= Page.new(json, self)
|
40
40
|
@__json_ui_section.list_section_builder
|
41
41
|
end
|
42
42
|
|
43
|
+
def json_ui_action(json)
|
44
|
+
@__json_ui_section ||= Page.new(json, self)
|
45
|
+
@__json_ui_section.action_builder
|
46
|
+
end
|
47
|
+
|
43
48
|
class Page
|
44
49
|
attr_reader :json, :context, :view_builder, :action_builder, :menu_builder
|
45
50
|
attr_reader :list_section_builder, :table_section_builder, :drawer_content_builder, :split_content_builder
|
@@ -52,7 +57,7 @@ module Glib
|
|
52
57
|
@context = context
|
53
58
|
|
54
59
|
@view_builder = ViewBuilder.new(json, self, true)
|
55
|
-
@action_builder = ActionBuilder.new(json, self)
|
60
|
+
@action_builder = ActionBuilder.new(json, self, false)
|
56
61
|
@menu_builder = MenuBuilder.new(json, self)
|
57
62
|
|
58
63
|
@list_section_builder = ListBuilders::Section.new(json, self, ListBuilders::Template.new(json, self))
|
@@ -103,8 +103,13 @@ class Glib::JsonUi::ViewBuilder
|
|
103
103
|
end
|
104
104
|
|
105
105
|
class Check < Text
|
106
|
-
|
107
|
-
|
106
|
+
any :uncheckValue
|
107
|
+
any :checkValue
|
108
|
+
|
109
|
+
|
110
|
+
def value(value)
|
111
|
+
@value = value if value != Glib::Value::DEFAULT
|
112
|
+
end
|
108
113
|
|
109
114
|
# Where possible, use value instead of this
|
110
115
|
bool :checked
|
@@ -3,7 +3,7 @@ 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/
|
6
|
+
page.form url: json_ui_garage_url(path: 'forms/generic_post'), method: 'post', padding: glib_json_padding_body, childViews: ->(form) do
|
7
7
|
form.h1 text: 'Text'
|
8
8
|
form.fields_password name: 'user[text1]', width: 'matchParent', label: 'Type "show"'
|
9
9
|
form.label text: 'Typed', showIf: {
|
@@ -29,7 +29,7 @@ page.form url: json_ui_garage_url(path: 'forms/basic_post'), method: 'post', pad
|
|
29
29
|
|
30
30
|
form.spacer height: 20
|
31
31
|
form.h1 text: 'Check'
|
32
|
-
form.fields_check name: 'user[check1]',
|
32
|
+
form.fields_check name: 'user[check1]', checkValue: 'on', label: 'Show text'
|
33
33
|
form.spacer height: 10
|
34
34
|
form.label text: 'Checked', showIf: {
|
35
35
|
"==": [
|
@@ -70,7 +70,7 @@ page.form url: json_ui_garage_url(path: 'forms/basic_post'), method: 'post', pad
|
|
70
70
|
}
|
71
71
|
|
72
72
|
form.spacer height: 20
|
73
|
-
form.h1 text: '
|
73
|
+
form.h1 text: 'Combined conditions'
|
74
74
|
form.label text: 'Select the same option on both the radio and select fields above'
|
75
75
|
form.spacer height: 10
|
76
76
|
form.h3 text: 'Same!', showIf: {
|
@@ -84,5 +84,22 @@ page.form url: json_ui_garage_url(path: 'forms/basic_post'), method: 'post', pad
|
|
84
84
|
]
|
85
85
|
}
|
86
86
|
|
87
|
+
form.spacer height: 20
|
88
|
+
form.h1 text: 'Show/hide another field'
|
89
|
+
form.label text: ''
|
90
|
+
form.spacer height: 10
|
91
|
+
form.fields_check name: 'user[check2]', checkValue: 'on', label: 'Show field'
|
92
|
+
form.spacer height: 10
|
93
|
+
form.fields_text width: 'matchParent', label: 'Comment (optional)', name: 'user[comment]', value: 'This field can be submitted when it is hidden, but it is not necessary (i.e. up to the app)', showIf: {
|
94
|
+
"==": [
|
95
|
+
{
|
96
|
+
"var": 'user[check2]'
|
97
|
+
},
|
98
|
+
'on'
|
99
|
+
]
|
100
|
+
}
|
101
|
+
|
102
|
+
form.spacer height: 20
|
103
|
+
form.fields_submit text: 'Submit'
|
87
104
|
form.spacer height: 40
|
88
105
|
end
|
@@ -7,7 +7,7 @@ json_ui_page json do |page|
|
|
7
7
|
form.fields_email name: 'user[email]', width: 'matchParent', label: 'Email'
|
8
8
|
form.fields_url name: 'user[url]', width: 'matchParent', label: 'URL'
|
9
9
|
form.fields_number name: 'user[number]', width: 'matchParent', label: 'Number', validation: { required: { message: 'Required' } }
|
10
|
-
form.fields_password name: 'user[password]', width: 'matchParent', label: 'Password'
|
10
|
+
form.fields_password name: 'user[password]', width: 'matchParent', label: 'Password', hint: 'Should contain at least 6 characters'
|
11
11
|
form.fields_textarea name: 'user[textarea]', width: 'matchParent', label: 'Textarea with maxLength', maxLength: 50, validation: { required: { message: 'Required' } }
|
12
12
|
|
13
13
|
options = ['male', 'female'].map { |i| { text: i.humanize, value: i } }
|
@@ -0,0 +1,112 @@
|
|
1
|
+
json.title 'Lists'
|
2
|
+
|
3
|
+
liked = params[:liked] == 'true'
|
4
|
+
|
5
|
+
json_ui_page json do |page|
|
6
|
+
render "#{@path_prefix}/nav_menu", json: json, page: page
|
7
|
+
|
8
|
+
page.list firstSection: ->(section) do
|
9
|
+
section.header padding: { top: 12, left: 16, right: 16, bottom: 12 }, childViews: ->(header) do
|
10
|
+
header.h3 text: 'Chat with John Doe'
|
11
|
+
end
|
12
|
+
|
13
|
+
section.rows builder: ->(template) do
|
14
|
+
# template.thumbnail title: "windows/reload (timestamp: #{DateTime.current.to_i}) -- #{liked}", onClick: ->(action) do
|
15
|
+
# action.windows_reload
|
16
|
+
# end, onLongPress: ->(action) do
|
17
|
+
# action.sheets_select message: "Context Menu (#{DateTime.current.to_i})", buttons: ->(menu) do
|
18
|
+
# if liked
|
19
|
+
# menu.button text: 'Cancel 👍', onClick: ->(subaction) do
|
20
|
+
# subaction.windows_reload url: json_ui_garage_url(path: 'lists/chat', liked: false)
|
21
|
+
# end
|
22
|
+
# else
|
23
|
+
# menu.button text: 'Give 👍', onClick: ->(subaction) do
|
24
|
+
# subaction.windows_reload url: json_ui_garage_url(path: 'lists/chat', liked: true)
|
25
|
+
# end
|
26
|
+
# end
|
27
|
+
# end
|
28
|
+
# end
|
29
|
+
|
30
|
+
template.commentOutgoing subtitle: 'Hey!', subsubtitle: l(10.minutes.ago, format: :short), imageUrl: glib_json_image_standard_url, chips: ->(menu) do
|
31
|
+
menu.button text: '😊 2', styleClass: 'info'
|
32
|
+
end
|
33
|
+
|
34
|
+
template.commentOutgoing subtitle: 'How are you?', subsubtitle: l(DateTime.current, format: :short)
|
35
|
+
|
36
|
+
template.commentIncoming title: 'John Doe', subtitle: 'Very well', subsubtitle: l(7.minutes.ago, format: :short), imageUrl: glib_json_image_standard_url, chips: ->(menu) do
|
37
|
+
menu.button text: "👍 #{liked ? 2 : 1}"
|
38
|
+
end, onLongPress: ->(action) do
|
39
|
+
action.sheets_select message: 'Context Menu', buttons: ->(menu) do
|
40
|
+
if liked
|
41
|
+
menu.button text: 'Cancel 👍', onClick: ->(subaction) do
|
42
|
+
subaction.windows_reload url: json_ui_garage_url(path: 'lists/chat', liked: false)
|
43
|
+
end
|
44
|
+
else
|
45
|
+
menu.button text: 'Give 👍', onClick: ->(subaction) do
|
46
|
+
subaction.windows_reload url: json_ui_garage_url(path: 'lists/chat', liked: true)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
section.footer padding: { top: 12, left: 16, right: 16, bottom: 12 }, childViews: ->(footer) do
|
54
|
+
# footer.
|
55
|
+
|
56
|
+
# json.ws({
|
57
|
+
# "socket" => {
|
58
|
+
# "endpoint" => "/socket/websocket",
|
59
|
+
# "params" => {
|
60
|
+
# vsn: '2.0.0',
|
61
|
+
# token: 'TOKEN'
|
62
|
+
# }
|
63
|
+
# },
|
64
|
+
# # "topic" => "room:30",
|
65
|
+
# # "event" => "comments_updated",
|
66
|
+
# "topic" => "links",
|
67
|
+
# "events" => ["new_link_added"],
|
68
|
+
# "header" => {
|
69
|
+
# "user_id" => 2,
|
70
|
+
# "prev_item_id" => nil,
|
71
|
+
# "last_item_id" => nil
|
72
|
+
# }
|
73
|
+
# })
|
74
|
+
|
75
|
+
# page.form url: json_ui_garage_url(path: 'forms/basic_post'), method: 'post', padding: glib_json_padding_body, paramNameForFormData: 'formData', onSubmit: ->(action) do
|
76
|
+
# json.action "ws/push"
|
77
|
+
# json.topic "links"
|
78
|
+
# json.event "new_link"
|
79
|
+
# json.payload({
|
80
|
+
# "club_id": "2",
|
81
|
+
# "room_id": "30",
|
82
|
+
# "user_id": "2"
|
83
|
+
# # title: "TITLE",
|
84
|
+
# # url: "URL"
|
85
|
+
# })
|
86
|
+
|
87
|
+
# end, childViews: ->(form) do
|
88
|
+
# form.spacer height: 14
|
89
|
+
# form.label text: "Message: #{params[:message]}"
|
90
|
+
# form.spacer height: 14
|
91
|
+
|
92
|
+
# form.fields_text name: 'message[body]', width: 'matchParent', label: 'Message'
|
93
|
+
|
94
|
+
# # TODO: Change this to radio for selecting alert vs reload response
|
95
|
+
# form.fields_password name: 'user[password]', width: 'matchParent', label: 'Password'
|
96
|
+
|
97
|
+
# form.fields_hidden name: 'baseUrl', width: 'matchParent', value: json_ui_garage_url(path: 'notifications/web_socket')
|
98
|
+
|
99
|
+
# form.panels_split width: 'matchParent', content: ->(split) do
|
100
|
+
# # split.left childViews: ->(left) do
|
101
|
+
# # if params[:mode] == 'dialog'
|
102
|
+
# # left.button styleClass: 'link', text: 'cancel', onClick: ->(action) { action.dialogs_close }
|
103
|
+
# # end
|
104
|
+
# # end
|
105
|
+
# split.right childViews: ->(right) do
|
106
|
+
# right.button text: 'Submit', onClick: ->(action) { action.forms_submit }
|
107
|
+
# end
|
108
|
+
# end
|
109
|
+
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
@@ -2,7 +2,7 @@ json.title 'Lists'
|
|
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.list firstSection: ->(section) do
|
7
7
|
section.rows builder: ->(template) do
|
8
8
|
template.thumbnail title: 'Click menu (web) or swipe left (Android/iOS)', editButtons: ->(menu) do
|
@@ -13,6 +13,30 @@ json_ui_page json do |page|
|
|
13
13
|
action.dialogs_alert message: 'Perform action'
|
14
14
|
end
|
15
15
|
end
|
16
|
+
|
17
|
+
template.thumbnail title: 'Long press to get an alert', onLongPress: ->(action) do
|
18
|
+
action.dialogs_alert message: 'This is an alert'
|
19
|
+
end
|
20
|
+
|
21
|
+
template.thumbnail title: 'Long press to see menu', onLongPress: ->(action) do
|
22
|
+
action.sheets_select message: 'Context Menu', buttons: ->(menu) do
|
23
|
+
menu.button icon: 'edit', text: 'Edit', onClick: ->(subaction) do
|
24
|
+
subaction.dialogs_alert message: 'Perform action'
|
25
|
+
end
|
26
|
+
menu.button icon: 'delete', text: 'Delete', onClick: ->(subaction) do
|
27
|
+
subaction.dialogs_alert message: 'Perform action'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# template.thumbnail title: 'Long press to see menu', contextButtons: ->(menu) do
|
33
|
+
# menu.button text: 'Edit', onClick: ->(action) do
|
34
|
+
# action.dialogs_alert message: 'Perform action'
|
35
|
+
# end
|
36
|
+
# menu.button text: 'Delete', onClick: ->(action) do
|
37
|
+
# action.dialogs_alert message: 'Perform action'
|
38
|
+
# end
|
39
|
+
# end
|
16
40
|
end
|
17
41
|
|
18
42
|
end
|
@@ -17,6 +17,9 @@ json_ui_page json do |page|
|
|
17
17
|
template.thumbnail title: 'FAB (Floating Action Button)', onClick: ->(action) do
|
18
18
|
action.windows_open url: json_ui_garage_url(path: 'lists/fab')
|
19
19
|
end
|
20
|
+
template.thumbnail title: 'Chat Prototype', onClick: ->(action) do
|
21
|
+
action.windows_open url: json_ui_garage_url(path: 'lists/chat')
|
22
|
+
end
|
20
23
|
end
|
21
24
|
|
22
25
|
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
batch_count = 30
|
3
2
|
items = (1..batch_count)
|
4
3
|
section = page.table_section_builder
|
@@ -10,4 +9,4 @@ section.rows objects: items, builder: ->(row, item, index) do
|
|
10
9
|
end, onClick: ->(action) do
|
11
10
|
action.windows_open url: json_ui_garage_url(path: 'home/blank')
|
12
11
|
end
|
13
|
-
end
|
12
|
+
end
|
@@ -1,39 +1,39 @@
|
|
1
1
|
|
2
2
|
page_index = params[:page].to_i
|
3
3
|
next_page = {
|
4
|
-
url: json_ui_garage_url(path: 'tables/
|
4
|
+
url: json_ui_garage_url(path: 'tables/autoload_as_needed', page: page_index + 1, section_only: 'v1'),
|
5
5
|
autoload: 'asNeeded'
|
6
6
|
}
|
7
7
|
|
8
|
+
page = json_ui_page json
|
8
9
|
column_indexes = (1..3)
|
10
|
+
|
9
11
|
if params[:section_only].present?
|
12
|
+
sleep 1
|
13
|
+
|
10
14
|
json.nextPage next_page if page_index < 3
|
11
|
-
|
12
|
-
json.
|
13
|
-
|
14
|
-
render 'json_ui/garage/tables/autoload_section', page: page, page_index: page_index, column_indexes: column_indexes
|
15
|
-
end
|
15
|
+
json.sections do
|
16
|
+
json.child! do
|
17
|
+
render 'json_ui/garage/tables/autoload_section', page: page, page_index: page_index, column_indexes: column_indexes
|
16
18
|
end
|
17
19
|
end
|
18
20
|
else
|
19
21
|
json.title 'Tables'
|
20
22
|
|
21
|
-
|
22
|
-
render "#{@path_prefix}/nav_menu", json: json, page: page
|
23
|
+
render "#{@path_prefix}/nav_menu", json: json, page: page
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
25
|
+
page.table nextPage: next_page, firstSection: ->(section) do
|
26
|
+
section.header cellViews: ->(header) do
|
27
|
+
column_indexes.each do |i|
|
28
|
+
header.label text: "Heading#{i}"
|
29
29
|
end
|
30
|
-
|
31
|
-
render "#{@path_prefix}/tables/autoload_section", page: page, page_index: page_index, column_indexes: column_indexes
|
32
|
-
end, onScrollToBottom: ->(action) do
|
33
|
-
action.snackbars_alert message: 'Scrolled to Bottom'
|
34
|
-
end, onScrollToTop: ->(action) do
|
35
|
-
action.snackbars_alert message: 'Scrolled to Top'
|
36
30
|
end
|
31
|
+
|
32
|
+
render "#{@path_prefix}/tables/autoload_section", page: page, page_index: page_index, column_indexes: column_indexes
|
33
|
+
end, onScrollToBottom: ->(action) do
|
34
|
+
action.snackbars_alert message: 'Scrolled to Bottom'
|
35
|
+
end, onScrollToTop: ->(action) do
|
36
|
+
action.snackbars_alert message: 'Scrolled to Top'
|
37
37
|
end
|
38
38
|
|
39
39
|
end
|
data/lib/glib/json_crawler.rb
CHANGED
@@ -8,3 +8,4 @@ require_relative './json_crawler/action_crawlers/windows_open'
|
|
8
8
|
require_relative './json_crawler/action_crawlers/action_http'
|
9
9
|
require_relative './json_crawler/action_crawlers/forms_submit'
|
10
10
|
require_relative './json_crawler/action_crawlers/menu'
|
11
|
+
require_relative './json_crawler/action_crawlers/run_multiple'
|
@@ -4,11 +4,8 @@ module Glib
|
|
4
4
|
def initialize(method, http, args, controller)
|
5
5
|
@http = http
|
6
6
|
json = @http.send(method, args['url'], controller, args.fetch('formData', {}))
|
7
|
-
|
8
|
-
unless json.nil?
|
9
|
-
click(json)
|
10
|
-
end
|
7
|
+
perform(json['onResponse'])
|
11
8
|
end
|
12
9
|
end
|
13
10
|
end
|
14
|
-
end
|
11
|
+
end
|
@@ -31,7 +31,7 @@ module Glib
|
|
31
31
|
|
32
32
|
include_params = case name
|
33
33
|
when 'fields/check', 'fields/check-v1'
|
34
|
-
child['
|
34
|
+
child['checkValue'] == child['value']
|
35
35
|
else
|
36
36
|
true
|
37
37
|
end
|
@@ -41,7 +41,7 @@ module Glib
|
|
41
41
|
end
|
42
42
|
|
43
43
|
json = @http.patch url, action, params
|
44
|
-
|
44
|
+
perform(json['onResponse'])
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
@@ -3,6 +3,7 @@ module Glib
|
|
3
3
|
class WindowsOpen < ActionCrawler
|
4
4
|
def initialize(http, args, action)
|
5
5
|
@http = http
|
6
|
+
|
6
7
|
if (url = args['url'])
|
7
8
|
json = @http.get(url, action, args.except('url'))
|
8
9
|
|
@@ -20,6 +21,8 @@ module Glib
|
|
20
21
|
click button
|
21
22
|
end
|
22
23
|
end
|
24
|
+
|
25
|
+
perform(json['onLoad'])
|
23
26
|
end
|
24
27
|
end
|
25
28
|
end
|
@@ -19,6 +19,7 @@ module Glib
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def step(http, args)
|
22
|
+
# TODO: Refactor
|
22
23
|
case args['view']
|
23
24
|
when 'fields/submit-v1', 'fields/submit'
|
24
25
|
@depth += 1
|
@@ -29,40 +30,45 @@ module Glib
|
|
29
30
|
end
|
30
31
|
|
31
32
|
if args.is_a?(Hash) && args['rel'] != 'nofollow'
|
32
|
-
if (onClick = (args.fetch('onClick', nil)
|
33
|
-
|
34
|
-
params = onClick
|
33
|
+
if (onClick = (args.fetch('onClick', nil)))
|
34
|
+
process_action(http, onClick)
|
35
35
|
end
|
36
|
+
end
|
37
|
+
end
|
36
38
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
39
|
+
def process_action(http, spec)
|
40
|
+
action = spec['action']
|
41
|
+
params = spec
|
42
|
+
|
43
|
+
if action.present?
|
44
|
+
@depth += 1
|
45
|
+
case action
|
46
|
+
when 'initiate_navigation'
|
47
|
+
@read_only_actions.add([action, params['url']])
|
48
|
+
JsonCrawler::NavInitiate.new(http, params, action)
|
49
|
+
when 'runMultiple-v1', 'runMultiple'
|
50
|
+
JsonCrawler::RunMultiple.new(http, params, action)
|
51
|
+
when 'windows/open-v1', 'dialogs/open-v1', 'windows/reload-v1', 'windows/open', 'dialogs/open', 'windows/reload'
|
52
|
+
@read_only_actions.add([action, params['url']])
|
53
|
+
JsonCrawler::WindowsOpen.new(http, params, action)
|
54
|
+
when 'sheets/select-v1', 'sheets/select'
|
55
|
+
JsonCrawler::Menu.new(http, params, action)
|
56
|
+
when 'http/post-v1', 'http/post'
|
57
|
+
JsonCrawler::ActionHttp.new(:post, http, params, action)
|
58
|
+
when 'forms/submit-v1', 'forms/submit'
|
59
|
+
forms = @visitor.forms
|
60
|
+
# raise 'Submit action needs to be inside a form' if forms.size < 1
|
61
|
+
JsonCrawler::FormsSubmit.new(http, forms.last)
|
62
|
+
else
|
63
|
+
unless [
|
64
|
+
'http/delete-v1', 'dialogs/oauth-v1', 'windows/openWeb-v1',
|
65
|
+
'http/delete', 'dialogs/oauth', 'windows/openWeb'
|
66
|
+
].include?(action)
|
44
67
|
@read_only_actions.add([action, params['url']])
|
45
|
-
JsonCrawler::WindowsOpen.new(http, params, action)
|
46
|
-
when 'sheets/select-v1', 'sheets/select'
|
47
|
-
JsonCrawler::Menu.new(http, params, action)
|
48
|
-
when 'http/post-v1', 'http/post'
|
49
|
-
JsonCrawler::ActionHttp.new(:post, http, params, action)
|
50
|
-
when 'forms/submit-v1', 'forms/submit'
|
51
|
-
forms = @visitor.forms
|
52
|
-
# raise 'Submit action needs to be inside a form' if forms.size < 1
|
53
|
-
JsonCrawler::FormsSubmit.new(http, forms.last)
|
54
|
-
else
|
55
|
-
unless [
|
56
|
-
'http/delete-v1', 'dialogs/oauth-v1', 'windows/openWeb-v1',
|
57
|
-
'http/delete', 'dialogs/oauth', 'windows/openWeb'
|
58
|
-
].include?(action)
|
59
|
-
@read_only_actions.add([action, params['url']])
|
60
|
-
end
|
61
|
-
self.log action, params['url']
|
62
68
|
end
|
63
|
-
|
64
|
-
# child
|
69
|
+
self.log action, params['url']
|
65
70
|
end
|
71
|
+
@depth -= 1
|
66
72
|
end
|
67
73
|
end
|
68
74
|
|
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.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ''
|
@@ -107,7 +107,6 @@ files:
|
|
107
107
|
- app/validators/email_typo_validator.rb
|
108
108
|
- app/validators/email_validator.rb
|
109
109
|
- app/validators/url_validator.rb
|
110
|
-
- app/views/app/views/json_ui/vue/renderer.html.erb
|
111
110
|
- app/views/json_ui/garage/_nav_menu.json.jbuilder
|
112
111
|
- app/views/json_ui/garage/actions/_dialogs.json.jbuilder
|
113
112
|
- app/views/json_ui/garage/actions/_http.json.jbuilder
|
@@ -144,6 +143,7 @@ files:
|
|
144
143
|
- app/views/json_ui/garage/home/index.json.jbuilder
|
145
144
|
- app/views/json_ui/garage/home/slow.json.jbuilder
|
146
145
|
- app/views/json_ui/garage/lists/_infinite_scroll_section.json.jbuilder
|
146
|
+
- app/views/json_ui/garage/lists/chat.json.jbuilder
|
147
147
|
- app/views/json_ui/garage/lists/edit_actions.json.jbuilder
|
148
148
|
- app/views/json_ui/garage/lists/fab.json.jbuilder
|
149
149
|
- app/views/json_ui/garage/lists/index.json.jbuilder
|
@@ -214,6 +214,7 @@ files:
|
|
214
214
|
- lib/glib/json_crawler/action_crawlers/forms_submit.rb
|
215
215
|
- lib/glib/json_crawler/action_crawlers/menu.rb
|
216
216
|
- lib/glib/json_crawler/action_crawlers/nav_initiate.rb
|
217
|
+
- lib/glib/json_crawler/action_crawlers/run_multiple.rb
|
217
218
|
- lib/glib/json_crawler/action_crawlers/windows_open.rb
|
218
219
|
- lib/glib/json_crawler/coverage.rb
|
219
220
|
- lib/glib/json_crawler/http.rb
|
@@ -1,35 +0,0 @@
|
|
1
|
-
<!-- Deprecated. Use layouts instead
|
2
|
-
<!DOCTYPE html>
|
3
|
-
<html>
|
4
|
-
|
5
|
-
<head>
|
6
|
-
<meta charset="utf-8" />
|
7
|
-
<meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport" />
|
8
|
-
|
9
|
-
<title>App</title>
|
10
|
-
<%= csrf_meta_tags %>
|
11
|
-
|
12
|
-
<%= javascript_pack_tag 'vue_renderer', defer: true %>
|
13
|
-
<%#= javascript_include_tag 'vue_renderer_extras', defer: true %>
|
14
|
-
|
15
|
-
<%= stylesheet_pack_tag 'vue_renderer' %>
|
16
|
-
<% if (custom_css_path = options[:custom_css_path]) %>
|
17
|
-
<%= stylesheet_link_tag custom_css_path, media: 'all' %>
|
18
|
-
<% end %>
|
19
|
-
|
20
|
-
<link href="https://fonts.googleapis.com/css?family=Material+Icons" rel="stylesheet" />
|
21
|
-
</head>
|
22
|
-
|
23
|
-
<body>
|
24
|
-
<noscript>Please enable JavaScript to view this web site.</noscript>
|
25
|
-
<div id="app"></div>
|
26
|
-
|
27
|
-
<script>
|
28
|
-
var __page = <%= raw @__json_ui_orig_page%>;
|
29
|
-
</script>
|
30
|
-
|
31
|
-
<% locals[:footer_block]&.call %>
|
32
|
-
</body>
|
33
|
-
|
34
|
-
</html>
|
35
|
-
-->
|