glib-web 0.3.0 → 0.3.1
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/application/json/libs.rb +34 -0
- data/app/helpers/glib/json_ui/view_builder/panels.rb +15 -0
- data/app/helpers/glib/json_ui/view_builder.rb +19 -1
- data/app/views/json_ui/garage/_nav_menu.json.jbuilder +4 -0
- data/app/views/json_ui/garage/actions/index.json.jbuilder +1 -1
- data/app/views/json_ui/garage/forms/basic.json.jbuilder +5 -1
- data/app/views/json_ui/garage/home/index.json.jbuilder +3 -0
- data/app/views/json_ui/garage/lists/infinite_scroll.json.jbuilder +1 -0
- data/app/views/json_ui/garage/panels/index.json.jbuilder +0 -3
- 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/exportable.json.jbuilder +31 -0
- data/app/views/json_ui/garage/{panels/table.json.jbuilder → tables/horizontal_scroll.json.jbuilder} +8 -7
- data/app/views/json_ui/garage/tables/index.json.jbuilder +20 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4565ecc5336a937378291a2da6bda57a1653fcb
|
4
|
+
data.tar.gz: 683fceedfb9f9488f06113a19707a4dc83ab895a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a652b793dd21095afe8dda2b293d1bdd501a4191e06154adb46f8693a656edd39ddea07f85aa1a0e52d1d5eb70c31a22248a541675138f54e710818dc9e9fdb6
|
7
|
+
data.tar.gz: eb2e5b6dd40994b1d0e0f6bcdd7ea02ab93d379c3d25e7816bffa3e677130d6ff3027f38bd385135376fb9d65ed93fbef06fdfe6998647eaa197d4fb3781a481
|
@@ -54,6 +54,40 @@ module Concerns::Application::Json::Libs
|
|
54
54
|
after_action :__json_transformation_commit
|
55
55
|
after_action :__json_validate_perform
|
56
56
|
end
|
57
|
+
|
58
|
+
def json_libs_set_locale
|
59
|
+
before_action do
|
60
|
+
# Need to explicitly fallback to EN
|
61
|
+
I18n.locale = params[:_locale] || :en
|
62
|
+
rescue
|
63
|
+
I18n.locale = :en
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def json_libs_force_json_ui
|
68
|
+
before_action do
|
69
|
+
if params[:_render] != 'v1'
|
70
|
+
redirect_to url_for(params.to_unsafe_h.merge(_render: 'v1'))
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def json_libs_rescue_csrf
|
76
|
+
rescue_from ActionController::InvalidAuthenticityToken do |exception|
|
77
|
+
sign_out(:user)
|
78
|
+
|
79
|
+
respond_to do |format|
|
80
|
+
format.json do
|
81
|
+
render json: {
|
82
|
+
onResponse: {
|
83
|
+
action: 'windows/open-v1',
|
84
|
+
url: root_url
|
85
|
+
}
|
86
|
+
}
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
57
91
|
|
58
92
|
end
|
59
93
|
end
|
@@ -110,11 +110,25 @@ class Glib::JsonUi::ViewBuilder
|
|
110
110
|
end
|
111
111
|
|
112
112
|
class Table < View
|
113
|
+
hash :nextPage
|
114
|
+
hash :export
|
115
|
+
hash :import
|
116
|
+
|
113
117
|
def firstSection(block)
|
114
118
|
json.sections [1] do
|
115
119
|
block.call page.table_section_builder
|
116
120
|
end
|
117
121
|
end
|
122
|
+
|
123
|
+
def sections(blocks)
|
124
|
+
json.sections do
|
125
|
+
blocks.each do |block|
|
126
|
+
json.child! do
|
127
|
+
block.call page.table_section_builder
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
118
132
|
end
|
119
133
|
|
120
134
|
class Scroll < View
|
@@ -148,6 +162,7 @@ class Glib::JsonUi::ViewBuilder
|
|
148
162
|
class Horizontal < View
|
149
163
|
views :childViews
|
150
164
|
string :distribution
|
165
|
+
string :align
|
151
166
|
end
|
152
167
|
|
153
168
|
class Carousel < View
|
@@ -43,27 +43,32 @@ module Glib
|
|
43
43
|
|
44
44
|
class H1 < View
|
45
45
|
string :text
|
46
|
-
|
46
|
+
color :color
|
47
47
|
end
|
48
48
|
|
49
49
|
class H2 < View
|
50
50
|
string :text
|
51
|
+
color :color
|
51
52
|
end
|
52
53
|
|
53
54
|
class H3 < View
|
54
55
|
string :text
|
56
|
+
color :color
|
55
57
|
end
|
56
58
|
|
57
59
|
class H4 < View
|
58
60
|
string :text
|
61
|
+
color :color
|
59
62
|
end
|
60
63
|
|
61
64
|
class P < View
|
62
65
|
string :text
|
66
|
+
color :color
|
63
67
|
end
|
64
68
|
|
65
69
|
class Label < View
|
66
70
|
string :text
|
71
|
+
color :color
|
67
72
|
action :onClick
|
68
73
|
end
|
69
74
|
|
@@ -129,6 +134,19 @@ module Glib
|
|
129
134
|
block.call page.menu_builder
|
130
135
|
end
|
131
136
|
end
|
137
|
+
|
138
|
+
# def options(options)
|
139
|
+
# current_url = page.context.request.base_url + page.context.request.fullpath
|
140
|
+
|
141
|
+
# buttons ->(menu) do
|
142
|
+
# options.each do |tab|
|
143
|
+
# menu.button text: tab[:text], disabled: tab[:url] == current_url, onClick: ->(action) do
|
144
|
+
# action.windows_reload url: tab[:url]
|
145
|
+
# end
|
146
|
+
# end
|
147
|
+
# end
|
148
|
+
# end
|
149
|
+
|
132
150
|
end
|
133
151
|
|
134
152
|
end
|
@@ -34,6 +34,10 @@ if local_assigns[:top_nav] || json_ui_app_is_web?
|
|
34
34
|
action.windows_open url: json_ui_garage_url(path: 'actions/index')
|
35
35
|
end
|
36
36
|
|
37
|
+
menu.button text: 'Tables (Web Only)', onClick: ->(action) do
|
38
|
+
action.windows_open url: json_ui_garage_url(path: 'tables/index')
|
39
|
+
end
|
40
|
+
|
37
41
|
menu.divider
|
38
42
|
menu.label text: 'Misc Menu'
|
39
43
|
|
@@ -37,7 +37,7 @@ json_ui_page json do |page|
|
|
37
37
|
end
|
38
38
|
|
39
39
|
template.thumbnail title: 'dialogs/open', onClick: ->(action) do
|
40
|
-
action.dialogs_open url: json_ui_garage_url(path: 'forms/basic')
|
40
|
+
action.dialogs_open url: json_ui_garage_url(path: 'forms/basic', mode: 'dialog')
|
41
41
|
end
|
42
42
|
|
43
43
|
template.thumbnail title: 'dialogs/snackbar (Legacy)', onClick: ->(action) do
|
@@ -7,7 +7,11 @@ json_ui_page json do |page|
|
|
7
7
|
form.fields_text name: 'user[name]', width: 'matchParent', label: 'Name'
|
8
8
|
form.fields_password name: 'user[password]', width: 'matchParent', label: 'Password'
|
9
9
|
|
10
|
-
form.panels_split width: 'matchParent',
|
10
|
+
form.panels_split width: 'matchParent', leftViews: ->(split) do
|
11
|
+
if params[:mode] == 'dialog'
|
12
|
+
split.button styleClass: 'link', text: 'cancel', onClick: ->(action) { action.dialogs_close }
|
13
|
+
end
|
14
|
+
end, rightViews: ->(split) do
|
11
15
|
split.button text: 'Submit', onClick: ->(action) { action.forms_submit }
|
12
16
|
end
|
13
17
|
end
|
@@ -23,6 +23,9 @@ json_ui_page json do |page|
|
|
23
23
|
template.thumbnail title: 'Actions', onClick: ->(action) do
|
24
24
|
action.windows_open url: json_ui_garage_url(path: 'actions/index')
|
25
25
|
end
|
26
|
+
template.thumbnail title: 'Tables (Web Only)', onClick: ->(action) do
|
27
|
+
action.windows_open url: json_ui_garage_url(path: 'tables/index')
|
28
|
+
end
|
26
29
|
end
|
27
30
|
|
28
31
|
end
|
@@ -52,9 +52,6 @@ json_ui_page json do |page|
|
|
52
52
|
template.thumbnail title: 'List', subtitle: 'Rows without columns', onClick: ->(action) do
|
53
53
|
action.windows_open url: json_ui_garage_url(path: 'lists/index')
|
54
54
|
end
|
55
|
-
template.thumbnail title: 'Table (Web only)', subtitle: 'Rows with columns', onClick: ->(action) do
|
56
|
-
action.windows_open url: json_ui_garage_url(path: 'panels/table')
|
57
|
-
end
|
58
55
|
|
59
56
|
end
|
60
57
|
end, ->(section) do
|
@@ -0,0 +1,13 @@
|
|
1
|
+
|
2
|
+
batch_count = 30
|
3
|
+
items = (1..batch_count)
|
4
|
+
section = page.table_section_builder
|
5
|
+
section.rows objects: items, builder: ->(row, item, index) do
|
6
|
+
row.default cellViews: ->(cell) do
|
7
|
+
column_indexes.each do |i|
|
8
|
+
cell.label text: "Data #{page_index * batch_count + item}"
|
9
|
+
end
|
10
|
+
end, onClick: ->(action) do
|
11
|
+
action.windows_open url: json_ui_garage_url(path: 'home/blank')
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
page_index = params[:page].to_i
|
3
|
+
next_page = {
|
4
|
+
url: json_ui_garage_url(path: 'tables/autoload_all', page: page_index + 1, section_only: 'v1'),
|
5
|
+
autoload: 'all'
|
6
|
+
}
|
7
|
+
|
8
|
+
column_indexes = (1..3)
|
9
|
+
# TODO: Cater
|
10
|
+
# - for SEO: one URL for a standalone page and one URL for pagination only
|
11
|
+
# - for generic approach, e.g. excluding nav_menu when there is no change
|
12
|
+
if params[:section_only].present?
|
13
|
+
json.nextPage next_page if page_index < 3
|
14
|
+
json_ui_page json do |page|
|
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
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
else
|
22
|
+
json.title 'Tables'
|
23
|
+
|
24
|
+
json_ui_page json do |page|
|
25
|
+
render "#{@path_prefix}/nav_menu", json: json, page: page
|
26
|
+
|
27
|
+
page.table nextPage: next_page, firstSection: ->(section) do
|
28
|
+
section.header cellViews: ->(header) do
|
29
|
+
column_indexes.each do |i|
|
30
|
+
header.label text: "Heading#{i}"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
render "#{@path_prefix}/tables/autoload_section", page: page, page_index: page_index, column_indexes: column_indexes
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
json.title 'Tables'
|
2
|
+
|
3
|
+
json_ui_page json do |page|
|
4
|
+
render "#{@path_prefix}/nav_menu", json: json, page: page
|
5
|
+
|
6
|
+
page.table export: { label: 'Export', fileName: 'output' }, import: { submitUrl: json_ui_garage_url(path: 'forms/generic_post'), paramName: 'user' }, firstSection: ->(section) do
|
7
|
+
section.header cellViews: ->(header) do
|
8
|
+
header.label text: 'field1'
|
9
|
+
header.label text: 'field2'
|
10
|
+
header.label text: 'field3'
|
11
|
+
header.label text: 'field4'
|
12
|
+
header.label text: 'field5'
|
13
|
+
header.label text: 'field6'
|
14
|
+
end
|
15
|
+
|
16
|
+
items = [1, 2, 3]
|
17
|
+
section.rows objects: items, builder: ->(row, item, index) do
|
18
|
+
row.default cellViews: ->(cell) do
|
19
|
+
cell.label text: "Data #{item}"
|
20
|
+
cell.label text: "Data 'A' #{item}"
|
21
|
+
cell.label text: 'Data "B"' + " #{item}"
|
22
|
+
cell.label text: "Data , #{item}"
|
23
|
+
cell.label text: "Line A#{item}\nLine B#{item}"
|
24
|
+
cell.label text: "Line A#{item}\rLine B#{item}"
|
25
|
+
end, onClick: ->(action) do
|
26
|
+
action.windows_open url: json_ui_garage_url(path: 'home/blank')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
data/app/views/json_ui/garage/{panels/table.json.jbuilder → tables/horizontal_scroll.json.jbuilder}
RENAMED
@@ -1,21 +1,22 @@
|
|
1
|
-
json.title '
|
1
|
+
json.title 'Tables'
|
2
2
|
|
3
3
|
json_ui_page json do |page|
|
4
4
|
render "#{@path_prefix}/nav_menu", json: json, page: page
|
5
5
|
|
6
|
+
column_indexes = (1..20)
|
6
7
|
page.table firstSection: ->(section) do
|
7
8
|
section.header cellViews: ->(header) do
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
column_indexes.each do |i|
|
10
|
+
header.label text: "Heading#{i}"
|
11
|
+
end
|
11
12
|
end
|
12
13
|
|
13
14
|
items = [1, 2, 3]
|
14
15
|
section.rows objects: items, builder: ->(row, item, index) do
|
15
16
|
row.default cellViews: ->(cell) do
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
column_indexes.each do |i|
|
18
|
+
cell.label text: "Data #{item}"
|
19
|
+
end
|
19
20
|
end, onClick: ->(action) do
|
20
21
|
action.windows_open url: json_ui_garage_url(path: 'home/blank')
|
21
22
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
json.title 'Tables'
|
2
|
+
|
3
|
+
json_ui_page json do |page|
|
4
|
+
render "#{@path_prefix}/nav_menu", json: json, page: page, top_nav: true
|
5
|
+
|
6
|
+
page.list firstSection: ->(section) do
|
7
|
+
section.rows builder: ->(template) do
|
8
|
+
template.thumbnail title: 'Horizontal Scroll', onClick: ->(action) do
|
9
|
+
action.windows_open url: json_ui_garage_url(path: 'tables/horizontal_scroll')
|
10
|
+
end
|
11
|
+
template.thumbnail title: 'Exportable', onClick: ->(action) do
|
12
|
+
action.windows_open url: json_ui_garage_url(path: 'tables/exportable')
|
13
|
+
end
|
14
|
+
template.thumbnail title: 'Autoload All', onClick: ->(action) do
|
15
|
+
action.windows_open url: json_ui_garage_url(path: 'tables/autoload_all')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
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.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ''
|
@@ -91,8 +91,12 @@ files:
|
|
91
91
|
- app/views/json_ui/garage/panels/index.json.jbuilder
|
92
92
|
- app/views/json_ui/garage/panels/responsive.json.jbuilder
|
93
93
|
- app/views/json_ui/garage/panels/split.json.jbuilder
|
94
|
-
- app/views/json_ui/garage/panels/table.json.jbuilder
|
95
94
|
- app/views/json_ui/garage/panels/vertical.json.jbuilder
|
95
|
+
- app/views/json_ui/garage/tables/_autoload_section.json.jbuilder
|
96
|
+
- app/views/json_ui/garage/tables/autoload_all.json.jbuilder
|
97
|
+
- app/views/json_ui/garage/tables/exportable.json.jbuilder
|
98
|
+
- app/views/json_ui/garage/tables/horizontal_scroll.json.jbuilder
|
99
|
+
- app/views/json_ui/garage/tables/index.json.jbuilder
|
96
100
|
- app/views/json_ui/garage/views/banners.json.jbuilder
|
97
101
|
- app/views/json_ui/garage/views/calendar_data.json.jbuilder
|
98
102
|
- app/views/json_ui/garage/views/carousels.json.jbuilder
|