glib-web 1.1.0 → 2.2.0
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/helpers/glib/format_helper.rb +20 -0
- data/app/helpers/glib/json_ui/action_builder.rb +2 -0
- data/app/helpers/glib/json_ui/view_builder/fields.rb +1 -1
- data/app/helpers/glib/json_ui/view_builder/panels.rb +1 -5
- data/app/views/json_ui/garage/forms/rich_text.json.jbuilder +84 -30
- data/app/views/json_ui/garage/forms/rich_text_preview.json.jbuilder +11 -0
- data/app/views/json_ui/garage/forms/submit_on_change.json.jbuilder +1 -1
- data/app/views/json_ui/garage/forms/text_validation.json.jbuilder +6 -0
- data/app/views/json_ui/garage/pages/index.json.jbuilder +4 -0
- data/app/views/json_ui/garage/pages/redirect_onload.json.jbuilder +9 -0
- data/app/views/json_ui/garage/panels/timeline.json.jbuilder +58 -51
- 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: 7a1aa1166513349077001fdad47d5d2e0df83da63bc55297e7eb40354f56c9d1
|
4
|
+
data.tar.gz: df6ba1dad3fd78b07e6e121c038609df563eabb56383f0e31ee6a1b5c379a4cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ceba57602f78f46ac76175ae5e449d3192ce91919ab600e242b9f6d7e314e29b65df369c69c289725df48481cdece02b6f6308c1f7267ef22450fa44776d40b
|
7
|
+
data.tar.gz: ca87f3e87349e24ba0a6674148a13767ab6670d1df3525084932873564987a088543b2d8870b84650e2cea8723432185e4c88df1308cc5fb3a726fa549ec8eaa
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Glib
|
2
|
+
module FormatHelper
|
3
|
+
require 'redcarpet/render_strip'
|
4
|
+
|
5
|
+
class CustomRenderer < Redcarpet::Render::XHTML
|
6
|
+
def strikethrough(text)
|
7
|
+
"<s>#{text}</s>"
|
8
|
+
end
|
9
|
+
|
10
|
+
def block_quote(quote)
|
11
|
+
"<blockquote>#{quote}</blockquote>"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def glib_format_markdown(content)
|
16
|
+
markdown = Redcarpet::Markdown.new(CustomRenderer, strikethrough: true, underline: false, no_intra_emphasis: true)
|
17
|
+
markdown.render(content).delete("\n")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -155,12 +155,8 @@ class Glib::JsonUi::ViewBuilder
|
|
155
155
|
end
|
156
156
|
|
157
157
|
class Timeline < View
|
158
|
-
color :completedColor
|
159
|
-
color :uncompletedColor
|
160
158
|
singleton_array :styleClass, :styleClasses
|
161
|
-
|
162
|
-
string :completedIcon
|
163
|
-
array :items
|
159
|
+
array :events
|
164
160
|
views :childViews
|
165
161
|
end
|
166
162
|
|
@@ -4,39 +4,93 @@ page = json_ui_page json
|
|
4
4
|
|
5
5
|
render "#{@path_prefix}/nav_menu", json: json, page: page
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
json.fileUrl 'https://imageserver-demo.herokuapp.com/image/itinerarybuilder-demo/o6CKzNt67PWnkPdUEnWMt7pr?h=100&w=100'
|
7
|
+
initial_name = 'John Doe'
|
8
|
+
# initial_message = "This is a **message**.\n\n```\n Code line 1\n\n Code line 2\n```\nSignature"
|
9
|
+
initial_message =<<-TEXT
|
10
|
+
This is a **message**.
|
11
|
+
## Header 1
|
12
|
+
```
|
13
|
+
Code line 1
|
14
|
+
Code line 2
|
15
|
+
```
|
16
|
+
## Header 2
|
17
|
+
`Inline code`
|
18
|
+
Signature
|
19
|
+
TEXT
|
20
|
+
|
21
|
+
page.form url: json_ui_garage_url(path: 'forms/basic_post'), method: 'post', padding: { top: 20, bottom: 20 }, childViews: ->(form) do
|
22
|
+
form.panels_column lg: { cols: 6 }, padding: { left: 10, right: 10 }, childViews: ->(column) do
|
23
|
+
column.fields_text \
|
24
|
+
name: 'user[name]',
|
25
|
+
width: 'matchParent',
|
26
|
+
label: 'Name',
|
27
|
+
value: initial_name,
|
28
|
+
onChange: ->(action) do
|
29
|
+
action.forms_submit overrideUrl: json_ui_garage_url(path: 'forms/rich_text_preview')
|
31
30
|
end
|
32
|
-
end
|
33
31
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
32
|
+
column.fields_richText \
|
33
|
+
width: 'matchParent',
|
34
|
+
produce: :markdown,
|
35
|
+
label: 'Content',
|
36
|
+
name: 'user[message]',
|
37
|
+
# value: "<p>Test <img src='{{image1}}'</p>",
|
38
|
+
# value: glib_format_markdown(initial_message),
|
39
|
+
value: initial_message,
|
40
|
+
# TODO: Include the image in the `value`
|
41
|
+
images: [
|
42
|
+
{
|
43
|
+
value: 'eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBFQT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--193dc0d939b9558fc4973fafbba91d989cbb04d4',
|
44
|
+
fileUrl: 'https://imageserver-demo.herokuapp.com/image/itinerarybuilder-demo/o6CKzNt67PWnkPdUEnWMt7pr?h=100&w=100'
|
45
|
+
}
|
46
|
+
],
|
47
|
+
imageUploader: {
|
48
|
+
name: 'user[images_attributes][]',
|
49
|
+
accepts: { fileType: 'image/*', maxFileSize: 5000 },
|
50
|
+
directUploadUrl: rails_direct_uploads_url
|
51
|
+
},
|
52
|
+
onChange: ->(action) do
|
53
|
+
action.forms_submit overrideUrl: json_ui_garage_url(path: 'forms/rich_text_preview')
|
54
|
+
end
|
55
|
+
|
56
|
+
# json.child! do
|
57
|
+
# json.view 'fields/richText-v1'
|
58
|
+
# json.width 'matchParent'
|
59
|
+
# json.label 'Content'
|
60
|
+
# json.name 'user[bio]'
|
61
|
+
# json.value "<p>Test <img src='{{image1}}'</p>"
|
62
|
+
# json.produce 'html'
|
63
|
+
|
64
|
+
# json.images do
|
65
|
+
# json.child! do
|
66
|
+
# json.value 'eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBFQT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--193dc0d939b9558fc4973fafbba91d989cbb04d4'
|
67
|
+
# # json.fileTitle "hita i hanom hg.jpg"
|
68
|
+
# json.fileUrl 'https://imageserver-demo.herokuapp.com/image/itinerarybuilder-demo/o6CKzNt67PWnkPdUEnWMt7pr?h=100&w=100'
|
69
|
+
# end
|
70
|
+
# end
|
71
|
+
|
72
|
+
# json.imageUploader do
|
73
|
+
# json.name 'user[images_attributes][]'
|
74
|
+
# json.accepts(fileType: 'image/*', maxFileSize: 5000)
|
75
|
+
# json.directUploadUrl rails_direct_uploads_url
|
76
|
+
# end
|
77
|
+
# end
|
78
|
+
end
|
79
|
+
|
80
|
+
form.panels_column lg: { cols: 6 }, padding: { left: 10, right: 10 }, childViews: ->(column) do
|
81
|
+
column.panels_vertical id: 'preview', childViews: ->(inner) do
|
82
|
+
inner.label text: "Hello #{initial_name},"
|
83
|
+
inner.spacer height: 18
|
84
|
+
inner.markdown text: initial_message
|
38
85
|
end
|
39
86
|
end
|
40
87
|
|
41
|
-
form.
|
88
|
+
form.panels_column lg: { cols: 12 }, padding: { top: 10, left: 10, right: 10 }, childViews: ->(column) do
|
89
|
+
column.panels_split width: 'matchParent', content: ->(split) do
|
90
|
+
split.right childViews: ->(right) do
|
91
|
+
right.fields_submit text: 'Submit'
|
92
|
+
end
|
93
|
+
end
|
94
|
+
# column.button text: 'Submit', onClick: ->(action) { action.forms_submit }
|
95
|
+
end
|
42
96
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
data = params[:user] || {}
|
2
|
+
|
3
|
+
json_ui_response_with_view json do |action|
|
4
|
+
action.components_update targetId: 'preview', views: ->(update) do
|
5
|
+
update.panels_vertical childViews: ->(vertical) do
|
6
|
+
vertical.label text: "Hello #{data[:name]},"
|
7
|
+
vertical.spacer height: 18
|
8
|
+
vertical.markdown text: data[:message]
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -68,7 +68,7 @@ page.scroll childViews: ->(scroll) do
|
|
68
68
|
form.spacer height: 20
|
69
69
|
form.h2 text: 'Text'
|
70
70
|
form.fields_text \
|
71
|
-
name: 'user[
|
71
|
+
name: 'user[image_url]',
|
72
72
|
width: 'matchParent',
|
73
73
|
onChange: ->(action) do
|
74
74
|
action.sheets_select message: 'Submit data?', buttons: ->(menu) do
|
@@ -8,6 +8,12 @@ page.form \
|
|
8
8
|
method: 'post',
|
9
9
|
padding: glib_json_padding_body,
|
10
10
|
childViews: ->(form) do
|
11
|
+
form.fields_text \
|
12
|
+
name: 'user[name]',
|
13
|
+
width: 'matchParent',
|
14
|
+
label: 'Name',
|
15
|
+
validation: { required: { message: 'Required' }, format: { regex: 'Doe$', message: 'The name has to end with "Doe"' } }
|
16
|
+
|
11
17
|
form.fields_email \
|
12
18
|
name: 'user[email]',
|
13
19
|
width: 'matchParent',
|
@@ -29,6 +29,10 @@ json_ui_page json do |page|
|
|
29
29
|
template.thumbnail title: 'Lifecycle Hooks', onClick: ->(action) do
|
30
30
|
action.windows_open url: json_ui_garage_url(path: 'pages/lifecycle_hooks')
|
31
31
|
end
|
32
|
+
|
33
|
+
template.thumbnail title: 'Redirect onLoad', onClick: ->(action) do
|
34
|
+
action.windows_open url: json_ui_garage_url(path: 'pages/redirect_onload')
|
35
|
+
end
|
32
36
|
end
|
33
37
|
end,
|
34
38
|
->(section) do
|
@@ -4,67 +4,74 @@ page = json_ui_page json
|
|
4
4
|
render "#{@path_prefix}/nav_menu", json: json, page: page
|
5
5
|
|
6
6
|
page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
|
7
|
-
scroll.h2 text: 'Basic timeline'
|
8
|
-
scroll.spacer height: 8
|
9
|
-
|
10
7
|
timeline_items = [
|
11
|
-
{
|
12
|
-
{
|
13
|
-
{
|
14
|
-
{
|
15
|
-
{
|
8
|
+
{ icon: 'place', color: '#4BB543' },
|
9
|
+
{ icon: 'check_circle', color: 'blue' },
|
10
|
+
{ icon: 'hourglass_empty', color: 'blue', label: 'Pending' },
|
11
|
+
{ icon: 'radio_button_unchecked' },
|
12
|
+
{ icon: 'radio_button_unchecked' },
|
16
13
|
]
|
17
14
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
15
|
+
scroll.h2 text: 'Basic timeline'
|
16
|
+
scroll.panels_timeline \
|
17
|
+
events: timeline_items,
|
18
|
+
childViews: ->(timeline) do
|
19
|
+
timeline.label styleClass: 'mt-2', text: 'Order submitted'
|
20
|
+
|
21
|
+
timeline.label styleClass: 'mt-2', text: 'Finding you a driver'
|
22
|
+
|
23
|
+
timeline.panels_vertical styleClass: 'mt-2', childViews: ->(vertical) do
|
24
|
+
vertical.h4 text: 'Driver found, picking you up..'
|
25
|
+
vertical.spacer height: 16
|
26
|
+
render 'json_ui/garage/panels/timeline_content', tview: vertical
|
27
|
+
end
|
28
|
+
|
29
|
+
timeline.label styleClass: 'mt-2', text: 'On the way'
|
30
|
+
|
31
|
+
timeline.label styleClass: 'mt-2', text: 'Arrived'
|
26
32
|
end
|
27
|
-
end
|
28
33
|
|
29
|
-
|
30
|
-
|
34
|
+
timeline_items = [
|
35
|
+
{ icon: 'place', color: '#4BB543' },
|
36
|
+
{ icon: 'check_circle', color: 'blue' },
|
37
|
+
{ icon: 'check_circle', color: 'blue' },
|
38
|
+
{ icon: 'check_circle', color: 'blue' },
|
39
|
+
{ icon: 'flag', color: '#FFA500' },
|
40
|
+
]
|
31
41
|
|
32
|
-
|
33
|
-
name: :custom,
|
34
|
-
label: 'Completed item with a custom icon',
|
35
|
-
completed: true,
|
36
|
-
uncompletedIcon: 'place',
|
37
|
-
completedIcon: 'place'
|
38
|
-
}
|
39
|
-
custom_uncompleted_item = {
|
40
|
-
name: :custom,
|
41
|
-
label: 'Uncompleted item with a custom icon',
|
42
|
-
uncompletedIcon: 'flag',
|
43
|
-
completedIcon: 'flag'
|
44
|
-
}
|
45
|
-
scroll.h2 text: 'Timeline with outlined dots, custom icons and custom colors'
|
46
|
-
scroll.spacer height: 8
|
42
|
+
scroll.h2 text: 'Timeline with outlined dots'
|
47
43
|
scroll.panels_timeline \
|
48
|
-
items: [custom_completed_item] + timeline_items + [custom_uncompleted_item],
|
49
|
-
completedColor: '#4BB543',
|
50
|
-
uncompletedColor: '#FFA500',
|
51
44
|
styleClasses: ['outlined'],
|
52
|
-
|
53
|
-
|
54
|
-
|
45
|
+
events: timeline_items,
|
46
|
+
childViews: ->(timeline) do
|
47
|
+
timeline.panels_vertical childViews: ->(vertical) do
|
48
|
+
vertical.h4 text: 'Order submitted'
|
49
|
+
vertical.spacer height: 2
|
50
|
+
timeline.label text: '15 minutes ago'
|
51
|
+
end
|
55
52
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
53
|
+
timeline.panels_vertical childViews: ->(vertical) do
|
54
|
+
vertical.h4 text: 'Finding you a driver'
|
55
|
+
vertical.spacer height: 2
|
56
|
+
timeline.label text: '15 minutes ago'
|
57
|
+
end
|
58
|
+
|
59
|
+
timeline.panels_vertical childViews: ->(vertical) do
|
60
|
+
vertical.h4 text: 'Driver found'
|
61
|
+
vertical.spacer height: 2
|
62
|
+
timeline.label text: '12 minutes ago'
|
63
|
+
end
|
64
|
+
|
65
|
+
timeline.panels_vertical childViews: ->(vertical) do
|
66
|
+
vertical.h4 text: 'On the way'
|
67
|
+
vertical.spacer height: 2
|
68
|
+
timeline.label text: 'Duration: 11 minutes'
|
69
|
+
end
|
63
70
|
|
64
|
-
|
65
|
-
|
71
|
+
timeline.panels_vertical childViews: ->(vertical) do
|
72
|
+
vertical.h4 text: 'Arrived'
|
73
|
+
vertical.spacer height: 2
|
74
|
+
timeline.label text: '1 minute ago'
|
66
75
|
end
|
67
|
-
tview.spacer height: 16
|
68
76
|
end
|
69
|
-
scroll.spacer height: 32
|
70
77
|
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:
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ''
|
@@ -88,6 +88,7 @@ files:
|
|
88
88
|
- app/helpers/glib/dynamic_images_helper.rb
|
89
89
|
- app/helpers/glib/dynamic_texts_helper.rb
|
90
90
|
- app/helpers/glib/enum_helper.rb
|
91
|
+
- app/helpers/glib/format_helper.rb
|
91
92
|
- app/helpers/glib/forms_helper.rb
|
92
93
|
- app/helpers/glib/json_ui/abstract_builder.rb
|
93
94
|
- app/helpers/glib/json_ui/action_builder.rb
|
@@ -171,6 +172,7 @@ files:
|
|
171
172
|
- app/views/json_ui/garage/forms/pickers.json.jbuilder
|
172
173
|
- app/views/json_ui/garage/forms/ratings.json.jbuilder
|
173
174
|
- app/views/json_ui/garage/forms/rich_text.json.jbuilder
|
175
|
+
- app/views/json_ui/garage/forms/rich_text_preview.json.jbuilder
|
174
176
|
- app/views/json_ui/garage/forms/selects.json.jbuilder
|
175
177
|
- app/views/json_ui/garage/forms/show_hide.json.jbuilder
|
176
178
|
- app/views/json_ui/garage/forms/styled_boxes.json.jbuilder
|
@@ -209,6 +211,7 @@ files:
|
|
209
211
|
- app/views/json_ui/garage/pages/loading_indicator.json.jbuilder
|
210
212
|
- app/views/json_ui/garage/pages/nav_buttons.json.jbuilder
|
211
213
|
- app/views/json_ui/garage/pages/nested_scroll.json.jbuilder
|
214
|
+
- app/views/json_ui/garage/pages/redirect_onload.json.jbuilder
|
212
215
|
- app/views/json_ui/garage/pages/tab_bar.json.jbuilder
|
213
216
|
- app/views/json_ui/garage/panels/_hover_views_content.json.jbuilder
|
214
217
|
- app/views/json_ui/garage/panels/_styled.json.jbuilder
|