glib-web 1.1.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- 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 +72 -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/panels/timeline.json.jbuilder +58 -51
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9d76762411f8762de62b8e1605f781b27be3d3485aa13d26a4a0ec7c66b009f
|
4
|
+
data.tar.gz: ec38270488ca88e627e6e8fee65e8f1c6836ec934d1d7d04e9cd22afc4a354e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee41e67561c834b9595351dfd673fbd4248efff597834643eb0980eec294948f0c6c272d8da7fe66707d8c5d98cd2de96d61d3d658a49a3810f9afcb2a8be6bb
|
7
|
+
data.tar.gz: f90be25cb55468d2f93db5242e1ae3518a096aeac9161e47fee5265a19e0cf5b57ed3ddcf4a52926e3b7b5cfeb4bb377fb70142dac8d99c1938970828d6431fc
|
@@ -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,81 @@ 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
|
-
json.view 'fields/richText-v1'
|
20
|
-
json.width 'matchParent'
|
21
|
-
json.label 'Content'
|
22
|
-
json.name 'user[bio]'
|
23
|
-
json.value "<p>Test <img src='{{image1}}'</p>"
|
24
|
-
json.produce 'html'
|
25
|
-
|
26
|
-
json.images do
|
27
|
-
json.child! do
|
28
|
-
json.value 'eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBFQT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--193dc0d939b9558fc4973fafbba91d989cbb04d4'
|
29
|
-
# json.fileTitle "hita i hanom hg.jpg"
|
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**.'
|
9
|
+
|
10
|
+
page.form url: json_ui_garage_url(path: 'forms/basic_post'), method: 'post', padding: { top: 20, bottom: 20 }, childViews: ->(form) do
|
11
|
+
form.panels_column lg: { cols: 6 }, padding: { left: 10, right: 10 }, childViews: ->(column) do
|
12
|
+
column.fields_text \
|
13
|
+
name: 'user[name]',
|
14
|
+
width: 'matchParent',
|
15
|
+
label: 'Name',
|
16
|
+
value: initial_name,
|
17
|
+
onChange: ->(action) do
|
18
|
+
action.forms_submit overrideUrl: json_ui_garage_url(path: 'forms/rich_text_preview')
|
31
19
|
end
|
32
|
-
end
|
33
20
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
21
|
+
column.fields_richText \
|
22
|
+
width: 'matchParent',
|
23
|
+
produce: :markdown,
|
24
|
+
label: 'Content',
|
25
|
+
name: 'user[message]',
|
26
|
+
# value: "<p>Test <img src='{{image1}}'</p>",
|
27
|
+
value: glib_format_markdown(initial_message),
|
28
|
+
# TODO: Include the image in the `value`
|
29
|
+
images: [
|
30
|
+
{
|
31
|
+
value: 'eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBFQT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--193dc0d939b9558fc4973fafbba91d989cbb04d4',
|
32
|
+
fileUrl: 'https://imageserver-demo.herokuapp.com/image/itinerarybuilder-demo/o6CKzNt67PWnkPdUEnWMt7pr?h=100&w=100'
|
33
|
+
}
|
34
|
+
],
|
35
|
+
imageUploader: {
|
36
|
+
name: 'user[images_attributes][]',
|
37
|
+
accepts: { fileType: 'image/*', maxFileSize: 5000 },
|
38
|
+
directUploadUrl: rails_direct_uploads_url
|
39
|
+
},
|
40
|
+
onChange: ->(action) do
|
41
|
+
action.forms_submit overrideUrl: json_ui_garage_url(path: 'forms/rich_text_preview')
|
42
|
+
end
|
43
|
+
|
44
|
+
# json.child! do
|
45
|
+
# json.view 'fields/richText-v1'
|
46
|
+
# json.width 'matchParent'
|
47
|
+
# json.label 'Content'
|
48
|
+
# json.name 'user[bio]'
|
49
|
+
# json.value "<p>Test <img src='{{image1}}'</p>"
|
50
|
+
# json.produce 'html'
|
51
|
+
|
52
|
+
# json.images do
|
53
|
+
# json.child! do
|
54
|
+
# json.value 'eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBFQT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--193dc0d939b9558fc4973fafbba91d989cbb04d4'
|
55
|
+
# # json.fileTitle "hita i hanom hg.jpg"
|
56
|
+
# json.fileUrl 'https://imageserver-demo.herokuapp.com/image/itinerarybuilder-demo/o6CKzNt67PWnkPdUEnWMt7pr?h=100&w=100'
|
57
|
+
# end
|
58
|
+
# end
|
59
|
+
|
60
|
+
# json.imageUploader do
|
61
|
+
# json.name 'user[images_attributes][]'
|
62
|
+
# json.accepts(fileType: 'image/*', maxFileSize: 5000)
|
63
|
+
# json.directUploadUrl rails_direct_uploads_url
|
64
|
+
# end
|
65
|
+
# end
|
66
|
+
end
|
67
|
+
|
68
|
+
form.panels_column lg: { cols: 6 }, padding: { left: 10, right: 10 }, childViews: ->(column) do
|
69
|
+
column.panels_vertical id: 'preview', childViews: ->(inner) do
|
70
|
+
inner.label text: "Hello #{initial_name},"
|
71
|
+
inner.spacer height: 18
|
72
|
+
inner.markdown text: initial_message
|
38
73
|
end
|
39
74
|
end
|
40
75
|
|
41
|
-
form.
|
76
|
+
form.panels_column lg: { cols: 12 }, padding: { top: 10, left: 10, right: 10 }, childViews: ->(column) do
|
77
|
+
column.panels_split width: 'matchParent', content: ->(split) do
|
78
|
+
split.right childViews: ->(right) do
|
79
|
+
right.fields_submit text: 'Submit'
|
80
|
+
end
|
81
|
+
end
|
82
|
+
# column.button text: 'Submit', onClick: ->(action) { action.forms_submit }
|
83
|
+
end
|
42
84
|
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
|
@@ -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.1.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
|