glib-web 0.5.5
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 +7 -0
- data/app/controllers/concerns/glib/auth/policy.rb +148 -0
- data/app/controllers/concerns/glib/json/dynamic_text.rb +126 -0
- data/app/controllers/concerns/glib/json/libs.rb +144 -0
- data/app/controllers/concerns/glib/json/new_dynamic_text.rb +122 -0
- data/app/controllers/concerns/glib/json/transformation.rb +11 -0
- data/app/controllers/concerns/glib/json/traversal.rb +85 -0
- data/app/controllers/concerns/glib/json/ui.rb +70 -0
- data/app/controllers/concerns/glib/json/validation.rb +13 -0
- data/app/controllers/glib/home_controller.rb +16 -0
- data/app/helpers/glib/app_feature_support_helper.rb +16 -0
- data/app/helpers/glib/dynamic_images_helper.rb +52 -0
- data/app/helpers/glib/dynamic_texts_helper.rb +42 -0
- data/app/helpers/glib/forms_helper.rb +15 -0
- data/app/helpers/glib/json_ui/abstract_builder.rb +281 -0
- data/app/helpers/glib/json_ui/action_builder.rb +81 -0
- data/app/helpers/glib/json_ui/action_builder/dialogs.rb +58 -0
- data/app/helpers/glib/json_ui/action_builder/http.rb +19 -0
- data/app/helpers/glib/json_ui/action_builder/sheets.rb +15 -0
- data/app/helpers/glib/json_ui/action_builder/snackbars.rb +41 -0
- data/app/helpers/glib/json_ui/action_builder/windows.rb +25 -0
- data/app/helpers/glib/json_ui/dynamic_field_builders.rb +25 -0
- data/app/helpers/glib/json_ui/generic_builders.rb +28 -0
- data/app/helpers/glib/json_ui/list_builders.rb +87 -0
- data/app/helpers/glib/json_ui/menu_builder.rb +52 -0
- data/app/helpers/glib/json_ui/page_helper.rb +187 -0
- data/app/helpers/glib/json_ui/response_helper.rb +23 -0
- data/app/helpers/glib/json_ui/split_builders.rb +32 -0
- data/app/helpers/glib/json_ui/styling_helper.rb +25 -0
- data/app/helpers/glib/json_ui/table_builders.rb +74 -0
- data/app/helpers/glib/json_ui/view_builder.rb +185 -0
- data/app/helpers/glib/json_ui/view_builder/banners.rb +24 -0
- data/app/helpers/glib/json_ui/view_builder/charts.rb +33 -0
- data/app/helpers/glib/json_ui/view_builder/fields.rb +213 -0
- data/app/helpers/glib/json_ui/view_builder/panels.rb +219 -0
- data/app/models/glib/active_storage/attachment.rb +9 -0
- data/app/models/glib/active_storage/blob.rb +9 -0
- data/app/models/glib/dynamic_text_record.rb +9 -0
- data/app/models/glib/text.rb +96 -0
- data/app/policies/glib/application_policy.rb +164 -0
- data/app/validators/email_typo_validator.rb +38 -0
- data/app/validators/email_validator.rb +7 -0
- data/app/validators/url_validator.rb +20 -0
- data/app/views/app/views/json_ui/vue/renderer.html.erb +35 -0
- data/app/views/json_ui/garage/_nav_menu.json.jbuilder +71 -0
- data/app/views/json_ui/garage/actions/_dialogs.json.jbuilder +104 -0
- data/app/views/json_ui/garage/actions/_http.json.jbuilder +18 -0
- data/app/views/json_ui/garage/actions/_reload.json.jbuilder +17 -0
- data/app/views/json_ui/garage/actions/_sheets.json.jbuilder +19 -0
- data/app/views/json_ui/garage/actions/_snackbars.json.jbuilder +33 -0
- data/app/views/json_ui/garage/actions/_timeouts.json.jbuilder +18 -0
- data/app/views/json_ui/garage/actions/_windows.json.jbuilder +24 -0
- data/app/views/json_ui/garage/actions/dialogs_oauth_post.json.jbuilder +6 -0
- data/app/views/json_ui/garage/actions/index.json.jbuilder +23 -0
- data/app/views/json_ui/garage/forms/_alert_post_data.json.jbuilder +7 -0
- data/app/views/json_ui/garage/forms/basic.json.jbuilder +34 -0
- data/app/views/json_ui/garage/forms/basic_post.json.jbuilder +8 -0
- data/app/views/json_ui/garage/forms/checkboxes.json.jbuilder +44 -0
- data/app/views/json_ui/garage/forms/dynamic_group.json.jbuilder +41 -0
- data/app/views/json_ui/garage/forms/dynamic_select.json.jbuilder +25 -0
- data/app/views/json_ui/garage/forms/dynamic_select_data.json.jbuilder +38 -0
- data/app/views/json_ui/garage/forms/file_upload.json.jbuilder +58 -0
- data/app/views/json_ui/garage/forms/floating_submit.json.jbuilder +31 -0
- data/app/views/json_ui/garage/forms/generic_post.json.jbuilder +3 -0
- data/app/views/json_ui/garage/forms/get_request.json.jbuilder +28 -0
- data/app/views/json_ui/garage/forms/index.json.jbuilder +101 -0
- data/app/views/json_ui/garage/forms/pickers.json.jbuilder +46 -0
- data/app/views/json_ui/garage/forms/rich_text.json.jbuilder +40 -0
- data/app/views/json_ui/garage/forms/selects.json.jbuilder +70 -0
- data/app/views/json_ui/garage/forms/show_hide.json.jbuilder +88 -0
- data/app/views/json_ui/garage/forms/styled_boxes.json.jbuilder +32 -0
- data/app/views/json_ui/garage/forms/submission_flow.json.jbuilder +17 -0
- data/app/views/json_ui/garage/forms/submission_flow_post.json.jbuilder +24 -0
- data/app/views/json_ui/garage/forms/submission_indicator.json.jbuilder +63 -0
- data/app/views/json_ui/garage/forms/submission_indicator_post.json.jbuilder +25 -0
- data/app/views/json_ui/garage/forms/text_validation.json.jbuilder +22 -0
- data/app/views/json_ui/garage/home/blank.json.jbuilder +11 -0
- data/app/views/json_ui/garage/home/index.json.jbuilder +32 -0
- data/app/views/json_ui/garage/home/slow.json.jbuilder +11 -0
- data/app/views/json_ui/garage/lists/_infinite_scroll_section.json.jbuilder +20 -0
- data/app/views/json_ui/garage/lists/edit_actions.json.jbuilder +19 -0
- data/app/views/json_ui/garage/lists/fab.json.jbuilder +14 -0
- data/app/views/json_ui/garage/lists/index.json.jbuilder +23 -0
- data/app/views/json_ui/garage/lists/infinite_scroll.json.jbuilder +38 -0
- data/app/views/json_ui/garage/lists/templating.json.jbuilder +35 -0
- data/app/views/json_ui/garage/notifications/index.json.jbuilder +18 -0
- data/app/views/json_ui/garage/notifications/web_socket.json.jbuilder +60 -0
- data/app/views/json_ui/garage/pages/flat_centered.json.jbuilder +29 -0
- data/app/views/json_ui/garage/pages/full_width.json.jbuilder +29 -0
- data/app/views/json_ui/garage/pages/full_width_height.json.jbuilder +16 -0
- data/app/views/json_ui/garage/pages/index.json.jbuilder +47 -0
- data/app/views/json_ui/garage/pages/layout.json.jbuilder +19 -0
- data/app/views/json_ui/garage/pages/loading_indicator.json.jbuilder +10 -0
- data/app/views/json_ui/garage/pages/nav_buttons.json.jbuilder +21 -0
- data/app/views/json_ui/garage/pages/tab_bar.json.jbuilder +27 -0
- data/app/views/json_ui/garage/panels/_styled.json.jbuilder +78 -0
- data/app/views/json_ui/garage/panels/card.json.jbuilder +4 -0
- data/app/views/json_ui/garage/panels/carousel.json.jbuilder +16 -0
- data/app/views/json_ui/garage/panels/custom.json.jbuilder +17 -0
- data/app/views/json_ui/garage/panels/flow.json.jbuilder +49 -0
- data/app/views/json_ui/garage/panels/horizontal.json.jbuilder +91 -0
- data/app/views/json_ui/garage/panels/index.json.jbuilder +132 -0
- data/app/views/json_ui/garage/panels/outlined.json.jbuilder +4 -0
- data/app/views/json_ui/garage/panels/responsive.json.jbuilder +88 -0
- data/app/views/json_ui/garage/panels/split.json.jbuilder +183 -0
- data/app/views/json_ui/garage/panels/vertical.json.jbuilder +50 -0
- data/app/views/json_ui/garage/services/dynamic_text.json.jbuilder +13 -0
- data/app/views/json_ui/garage/services/image.json.jbuilder +47 -0
- data/app/views/json_ui/garage/services/index.json.jbuilder +17 -0
- data/app/views/json_ui/garage/tables/_autoload_section.json.jbuilder +13 -0
- data/app/views/json_ui/garage/tables/autoload_all.json.jbuilder +38 -0
- data/app/views/json_ui/garage/tables/autoload_as_needed.json.jbuilder +39 -0
- data/app/views/json_ui/garage/tables/export_import.json.jbuilder +29 -0
- data/app/views/json_ui/garage/tables/horizontal_scroll.json.jbuilder +26 -0
- data/app/views/json_ui/garage/tables/index.json.jbuilder +26 -0
- data/app/views/json_ui/garage/tables/layout.json.jbuilder +38 -0
- data/app/views/json_ui/garage/views/_chart_data.json.jbuilder +17 -0
- data/app/views/json_ui/garage/views/banners.json.jbuilder +51 -0
- data/app/views/json_ui/garage/views/calendar_data.json.jbuilder +30 -0
- data/app/views/json_ui/garage/views/carousels.json.jbuilder +37 -0
- data/app/views/json_ui/garage/views/charts.json.jbuilder +115 -0
- data/app/views/json_ui/garage/views/images.json.jbuilder +89 -0
- data/app/views/json_ui/garage/views/index.json.jbuilder +48 -0
- data/app/views/json_ui/garage/views/links.json.jbuilder +70 -0
- data/app/views/json_ui/garage/views/map_data.json.jbuilder +43 -0
- data/app/views/json_ui/garage/views/markdowns.json.jbuilder +41 -0
- data/app/views/json_ui/garage/views/misc.json.jbuilder +34 -0
- data/app/views/json_ui/garage/views/texts.json.jbuilder +41 -0
- data/app/views/layouts/json_ui/renderer.html.erb +32 -0
- data/config/routes.rb +8 -0
- data/lib/generators/glib/install_generator.rb +24 -0
- data/lib/generators/templates/20191017062519_create_texts.rb +12 -0
- data/lib/generators/templates/20191024063257_add_scope_to_texts.rb +7 -0
- data/lib/generators/templates/20191112095018_add_lang_to_texts.rb +7 -0
- data/lib/generators/templates/20191126071051_create_active_storage_tables.active_storage.rb +27 -0
- data/lib/generators/templates/database.yml +107 -0
- data/lib/generators/templates/dynamic_text.rb +2 -0
- data/lib/glib-web.rb +8 -0
- data/lib/glib/crypt.rb +1 -0
- data/lib/glib/crypt/utils.rb +26 -0
- data/lib/glib/dynamic_text.rb +1 -0
- data/lib/glib/dynamic_text/config.rb +21 -0
- data/lib/glib/engine.rb +7 -0
- data/lib/glib/json_crawler.rb +10 -0
- data/lib/glib/json_crawler/action_crawler.rb +20 -0
- data/lib/glib/json_crawler/action_crawlers/action_http.rb +14 -0
- data/lib/glib/json_crawler/action_crawlers/forms_submit.rb +48 -0
- data/lib/glib/json_crawler/action_crawlers/menu.rb +12 -0
- data/lib/glib/json_crawler/action_crawlers/nav_initiate.rb +15 -0
- data/lib/glib/json_crawler/action_crawlers/windows_open.rb +28 -0
- data/lib/glib/json_crawler/coverage.rb +20 -0
- data/lib/glib/json_crawler/http.rb +120 -0
- data/lib/glib/json_crawler/router.rb +86 -0
- data/lib/glib/test_helpers.rb +40 -0
- data/lib/glib/value.rb +7 -0
- data/lib/glib/version.rb +5 -0
- data/lib/tasks/db.rake +95 -0
- metadata +246 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Glib
|
|
2
|
+
module JsonUi
|
|
3
|
+
module ResponseHelper
|
|
4
|
+
def json_ui_response(json)
|
|
5
|
+
json.onResponse do
|
|
6
|
+
response = Response.new(json, self)
|
|
7
|
+
yield response.action_builder
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
class Response
|
|
12
|
+
attr_reader :action_builder
|
|
13
|
+
|
|
14
|
+
def initialize(json, context)
|
|
15
|
+
@json = json
|
|
16
|
+
@context = context
|
|
17
|
+
|
|
18
|
+
@action_builder = ActionBuilder.new(json, self)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module Glib
|
|
2
|
+
module JsonUi
|
|
3
|
+
module SplitBuilders
|
|
4
|
+
|
|
5
|
+
class Content < AbstractBuilder
|
|
6
|
+
def initialize json, page, template
|
|
7
|
+
super json, page
|
|
8
|
+
@template = template
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def left(options = {})
|
|
12
|
+
json.left do
|
|
13
|
+
page.vertical_content(options)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def center(options = {})
|
|
18
|
+
json.center do
|
|
19
|
+
page.vertical_content(options)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def right(options = {})
|
|
24
|
+
json.right do
|
|
25
|
+
page.vertical_content(options)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module Glib
|
|
2
|
+
module JsonUi
|
|
3
|
+
module StylingHelper
|
|
4
|
+
def glib_json_padding_body
|
|
5
|
+
{ top: 12, left: 20, right: 20, bottom: 12 }
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def glib_json_padding_list
|
|
9
|
+
{ top: 12, bottom: 12, left: 16, right: 16 }
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def glib_json_image_standard_url
|
|
13
|
+
'https://cdn-images-1.medium.com/max/1200/1*Qc0XxYm-qAZL-7tjjlNfrg.png'
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def glib_json_image_avatar_url
|
|
17
|
+
'https://www.wpjournalist.nl/wp-content/uploads/2019/03/avatar-jongen-voorbeeld-1.jpg'
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def glib_json_image_blob_key
|
|
21
|
+
'o6CKzNt67PWnkPdUEnWMt7pr'
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
module Glib
|
|
2
|
+
module JsonUi
|
|
3
|
+
module TableBuilders
|
|
4
|
+
class Template < AbstractBuilder
|
|
5
|
+
def method_missing m, *args
|
|
6
|
+
add_element_to_array 'template', m, *args
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
class AbstractTemplate < JsonUiElement
|
|
10
|
+
|
|
11
|
+
def editButtons(block)
|
|
12
|
+
json.editButtons do
|
|
13
|
+
block.call page.menu_builder
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
class Default < AbstractTemplate
|
|
20
|
+
views :cellViews
|
|
21
|
+
action :onClick
|
|
22
|
+
array :colSpans
|
|
23
|
+
array :colStyles
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
class Section < AbstractBuilder
|
|
28
|
+
def initialize json, page, template
|
|
29
|
+
super json, page
|
|
30
|
+
@template = template
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def header(options = {})
|
|
34
|
+
json.header do
|
|
35
|
+
json.backgroundColor options[:backgroundColor]
|
|
36
|
+
json.cellViews do
|
|
37
|
+
options[:cellViews]&.call page.view_builder
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def rows(options = {})
|
|
43
|
+
block = options.delete(:builder)
|
|
44
|
+
json.rows do
|
|
45
|
+
if (objects = options.delete(:objects))
|
|
46
|
+
objects.each_with_index do |object, index|
|
|
47
|
+
block&.call @template, object, index
|
|
48
|
+
end
|
|
49
|
+
else
|
|
50
|
+
block&.call @template
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
raise "Invalid properties: #{options.keys}" if options.size > 0
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# def rows(array = nil)
|
|
58
|
+
# template = page.table_template_builder
|
|
59
|
+
# json.rows do
|
|
60
|
+
# if array
|
|
61
|
+
# array.each do |row|
|
|
62
|
+
# yield template, row
|
|
63
|
+
# end
|
|
64
|
+
# else
|
|
65
|
+
# yield template
|
|
66
|
+
# end
|
|
67
|
+
# end
|
|
68
|
+
# end
|
|
69
|
+
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
module Glib
|
|
2
|
+
module JsonUi
|
|
3
|
+
class ViewBuilder < AbstractBuilder
|
|
4
|
+
def initialize(json, page, multiple)
|
|
5
|
+
super(json, page)
|
|
6
|
+
|
|
7
|
+
@multiple = multiple
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def add_view(name, *args)
|
|
11
|
+
if @multiple
|
|
12
|
+
add_element_to_array_v1 'view', name, *args
|
|
13
|
+
else
|
|
14
|
+
add_singleton_element_v1 'view', name, *args
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def method_missing(m, *args)
|
|
19
|
+
add_view m, *args
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
class View < JsonUiElement
|
|
23
|
+
length :width
|
|
24
|
+
length :height
|
|
25
|
+
color :backgroundColor
|
|
26
|
+
hash :padding
|
|
27
|
+
# array :styleClasses
|
|
28
|
+
singleton_array :styleClass, :styleClasses
|
|
29
|
+
hash :showIf
|
|
30
|
+
|
|
31
|
+
def analytics(value)
|
|
32
|
+
if value.is_a?(String)
|
|
33
|
+
@analyticsEnabled = true
|
|
34
|
+
@analyticsId = value
|
|
35
|
+
else
|
|
36
|
+
@analyticsEnabled = value == true
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Override
|
|
41
|
+
def created
|
|
42
|
+
if @analyticsEnabled
|
|
43
|
+
context = page.context
|
|
44
|
+
json.analytics do
|
|
45
|
+
content = @analyticsId || (@text || @icon)&.gsub(/\s+/, '_')&.downcase || 'nil'
|
|
46
|
+
json.namePrefix [context.controller_name, context.action_name, content].join('_')
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
### View definitions
|
|
54
|
+
|
|
55
|
+
class AbstractText < View
|
|
56
|
+
string :textAlign
|
|
57
|
+
text :text
|
|
58
|
+
color :color
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
class H1 < AbstractText
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
class H2 < AbstractText
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
class H3 < AbstractText
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
class H4 < AbstractText
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
class H5 < AbstractText
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
class H6 < AbstractText
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
class P < AbstractText
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
class Markdown < AbstractText
|
|
83
|
+
bool :previewVideo
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
class Label < AbstractText
|
|
87
|
+
# string :format
|
|
88
|
+
action :onClick
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
class Image < View
|
|
92
|
+
string :url
|
|
93
|
+
string :base64Data
|
|
94
|
+
action :onClick
|
|
95
|
+
string :fit
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
class Avatar < View
|
|
99
|
+
string :url
|
|
100
|
+
action :onClick
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
class Icon < View
|
|
104
|
+
icon :spec
|
|
105
|
+
action :onClick
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# class Banner < View
|
|
109
|
+
# icon :icon
|
|
110
|
+
# string :text
|
|
111
|
+
# end
|
|
112
|
+
|
|
113
|
+
class Button < View
|
|
114
|
+
icon :icon, cache: true
|
|
115
|
+
string :text, cache: true
|
|
116
|
+
action :onClick
|
|
117
|
+
color :color
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
class Fab < View
|
|
121
|
+
icon :icon
|
|
122
|
+
action :onClick
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
class Hr < View
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
class Spacer < View
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
class Map < View
|
|
132
|
+
float :latitude
|
|
133
|
+
float :longitude
|
|
134
|
+
int :zoom
|
|
135
|
+
string :dataUrl
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
class Chip < View
|
|
139
|
+
string :text
|
|
140
|
+
action :onClick
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
class Calendar < View
|
|
144
|
+
string :dataUrl
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
class TabBar < View
|
|
148
|
+
color :color
|
|
149
|
+
|
|
150
|
+
def buttons(block)
|
|
151
|
+
json.buttons do
|
|
152
|
+
block.call page.menu_builder
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
# Should be deprecated
|
|
157
|
+
# def tabButtons(block)
|
|
158
|
+
# json.tabButtons do
|
|
159
|
+
# block.call page.menu_builder
|
|
160
|
+
# end
|
|
161
|
+
# end
|
|
162
|
+
|
|
163
|
+
# def options(options)
|
|
164
|
+
# current_url = page.context.request.base_url + page.context.request.fullpath
|
|
165
|
+
|
|
166
|
+
# buttons ->(menu) do
|
|
167
|
+
# options.each do |tab|
|
|
168
|
+
# menu.button text: tab[:text], disabled: tab[:url] == current_url, onClick: ->(action) do
|
|
169
|
+
# action.windows_reload url: tab[:url]
|
|
170
|
+
# end
|
|
171
|
+
# end
|
|
172
|
+
# end
|
|
173
|
+
# end
|
|
174
|
+
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
class Datetime < View
|
|
178
|
+
date_time :value
|
|
179
|
+
string :format
|
|
180
|
+
bool :tick
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
class Glib::JsonUi::ViewBuilder
|
|
2
|
+
module Banners
|
|
3
|
+
|
|
4
|
+
class Alert < View
|
|
5
|
+
icon :icon
|
|
6
|
+
string :message
|
|
7
|
+
# string :message_format
|
|
8
|
+
singleton_array :styleClass, :styleClasses
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
class Select < View
|
|
12
|
+
icon :icon
|
|
13
|
+
string :message
|
|
14
|
+
singleton_array :styleClass, :styleClasses
|
|
15
|
+
|
|
16
|
+
def buttons(block)
|
|
17
|
+
json.buttons do
|
|
18
|
+
block.call page.menu_builder
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
class Glib::JsonUi::ViewBuilder
|
|
2
|
+
module Charts
|
|
3
|
+
class Line < View
|
|
4
|
+
hash :nextPage
|
|
5
|
+
|
|
6
|
+
def dataSeries(blocks)
|
|
7
|
+
json.dataSeries do
|
|
8
|
+
blocks.each do |block|
|
|
9
|
+
json.child! do
|
|
10
|
+
block.call
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
class Column < View
|
|
19
|
+
bool :stacked
|
|
20
|
+
|
|
21
|
+
def dataGroups(blocks)
|
|
22
|
+
json.dataGroups do
|
|
23
|
+
blocks.each do |block|
|
|
24
|
+
json.child! do
|
|
25
|
+
block.call
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
class Glib::JsonUi::ViewBuilder
|
|
2
|
+
module Fields
|
|
3
|
+
|
|
4
|
+
class AbstractField < View
|
|
5
|
+
hash :validation
|
|
6
|
+
|
|
7
|
+
def label(label)
|
|
8
|
+
@label = label
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def label_args(label_args)
|
|
12
|
+
@label_args = label_args
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def hint(hint)
|
|
16
|
+
@hint = hint
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def hint_args(hint_args)
|
|
20
|
+
@hint_args = hint_args
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def placeholder(placeholder)
|
|
24
|
+
@placeholder = placeholder
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def placeholder_args(placeholder_args)
|
|
28
|
+
@placeholder_args = placeholder_args
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def name(name)
|
|
32
|
+
@name = name if name != Glib::Value::DEFAULT
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def value(value)
|
|
36
|
+
@value = value if value != Glib::Value::DEFAULT
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def prop(prop)
|
|
40
|
+
@prop = prop
|
|
41
|
+
# if (form = page.current_form)
|
|
42
|
+
# @name ||= form.field_name(prop)
|
|
43
|
+
# @value ||= form.field_value(prop)
|
|
44
|
+
# end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Override
|
|
48
|
+
def created
|
|
49
|
+
if @prop && (form = page.current_form)
|
|
50
|
+
@name ||= form.field_name(@prop, @multiple || false)
|
|
51
|
+
@value ||= form.field_value(@prop)
|
|
52
|
+
@label ||= form.field_label(@prop, @label_args || {})
|
|
53
|
+
@hint ||= form.hint_label(@prop, @hint_args || {})
|
|
54
|
+
@placeholder ||= form.placeholder_label(@prop, @placeholder_args || {})
|
|
55
|
+
end
|
|
56
|
+
json.name @name
|
|
57
|
+
json.value @value if @value
|
|
58
|
+
json.label @label if @label
|
|
59
|
+
json.hint @hint if @hint
|
|
60
|
+
|
|
61
|
+
# In general, use hint over placeholder for the following reasons:
|
|
62
|
+
# - Placeholder gets hidden when there is input which may be confusing
|
|
63
|
+
# - Placeholder competes with label for space
|
|
64
|
+
json.placeholder @placeholder if @placeholder
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
class Text < AbstractField
|
|
70
|
+
int :maxLength
|
|
71
|
+
bool :readOnly
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
class Number < Text
|
|
75
|
+
int :min
|
|
76
|
+
int :max
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
class Email < Text
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
class Url < Text
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
class Password < Text
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
class Hidden < Text
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# Benefits of using `fields/submit` over `button`
|
|
92
|
+
# - On the web, it translates to input[type=submit] which provides builtin functionality such as
|
|
93
|
+
# submitting upon pressing enter on a field and remembering values for autofill.
|
|
94
|
+
# - We can attach name-value param to it. See https://www.w3schools.com/tags/att_button_value.asp
|
|
95
|
+
# - It has a default onClick so no need to specify `onClick: ->(action) { action.forms_submit }`
|
|
96
|
+
class Submit < AbstractField
|
|
97
|
+
string :text
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
class CheckGroup < AbstractField
|
|
101
|
+
views :childViews
|
|
102
|
+
string :uncheckValue
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
class Check < Text
|
|
106
|
+
string :uncheckValue
|
|
107
|
+
string :checkValue
|
|
108
|
+
|
|
109
|
+
# Where possible, use value instead of this
|
|
110
|
+
bool :checked
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
# This doesn't use camel case because some terms have become single words (e.g. snackbar)
|
|
114
|
+
class Textarea < Text
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
class RichText < Text
|
|
118
|
+
array :images
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
class Country < AbstractField
|
|
122
|
+
hash :region
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
class Select < AbstractField
|
|
126
|
+
array :options
|
|
127
|
+
bool :readOnly
|
|
128
|
+
bool :multiple, cache: true
|
|
129
|
+
# bool :manualEntry
|
|
130
|
+
hash :append
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
class Autocomplete < AbstractField
|
|
134
|
+
array :options
|
|
135
|
+
bool :readOnly
|
|
136
|
+
bool :multiple, cache: true
|
|
137
|
+
# bool :manualEntry
|
|
138
|
+
hash :append
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
class DynamicSelect < AbstractField
|
|
142
|
+
array :selectedOptions
|
|
143
|
+
string :url
|
|
144
|
+
bool :multiple, cache: true
|
|
145
|
+
|
|
146
|
+
# Override
|
|
147
|
+
def value(value)
|
|
148
|
+
raise 'Use selectedOptions instead (for clarity)'
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
class DynamicGroup < AbstractField
|
|
153
|
+
string :titlePrefix
|
|
154
|
+
panels_builder :content, :template
|
|
155
|
+
|
|
156
|
+
# NOTE: Consider using sub-panel instead (e.g. groupTemplate)
|
|
157
|
+
# views :groupTemplateViews
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
class RadioGroup < View
|
|
161
|
+
string :name
|
|
162
|
+
string :value
|
|
163
|
+
views :childViews
|
|
164
|
+
|
|
165
|
+
string :iconOfBeforeSelected
|
|
166
|
+
string :iconOfSelected
|
|
167
|
+
string :iconOfAfterSelected
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
class Radio < View
|
|
171
|
+
string :label
|
|
172
|
+
string :value
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
class File < Text
|
|
176
|
+
# file_rules = { fileType: 'image/*', maxFileSize: 5000 }
|
|
177
|
+
# file_rules = { fileType: 'video/*', maxFileSize: 50000 }
|
|
178
|
+
# file_rules = { fileType: 'application/pdf', maxFileSize: 5000 }
|
|
179
|
+
hash :accepts
|
|
180
|
+
|
|
181
|
+
string :directUploadUrl
|
|
182
|
+
string :fileUrl
|
|
183
|
+
string :fileTitle
|
|
184
|
+
hash :placeholderView
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
class Date < AbstractField
|
|
188
|
+
date :min
|
|
189
|
+
date :max
|
|
190
|
+
|
|
191
|
+
# Override
|
|
192
|
+
def value(value)
|
|
193
|
+
super(value&.to_date)
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
# This doesn't use camel case to be consistent with the html input equivalent
|
|
198
|
+
class Datetime < AbstractField
|
|
199
|
+
date_time :min
|
|
200
|
+
date_time :max
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
class LatLong < AbstractField
|
|
204
|
+
hash :latitudeField
|
|
205
|
+
hash :longitudeField
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
class StripeToken < AbstractField
|
|
209
|
+
string :publicKey
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
end
|
|
213
|
+
end
|