glib-web 1.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7d54f11d392b1b330e30746a54d6cc10eba3d3f050754b8c6957ecd70790d02e
4
- data.tar.gz: 8d55496374c7da6c3570de7ad986b526026a395f11fd387e05d66f35944a54a3
3
+ metadata.gz: 7a1aa1166513349077001fdad47d5d2e0df83da63bc55297e7eb40354f56c9d1
4
+ data.tar.gz: df6ba1dad3fd78b07e6e121c038609df563eabb56383f0e31ee6a1b5c379a4cb
5
5
  SHA512:
6
- metadata.gz: 0b6c09ef7d53a989b1e5ad99815f36ba9dc84384c176aefd58cb2112cfb8d02352ee0617443a4e8569a955dd459fe71429a59f3fe60d26cf3575e06f35b13f98
7
- data.tar.gz: 89d3f2502a153de10c649abfc09406b0041b954aaff9f15405827c550c7024a8886fec7c92ac6e4fca8a324852235c764207034e00e5e28b1c2201bdc097c617
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
@@ -57,6 +57,8 @@ module Glib
57
57
 
58
58
  module Forms
59
59
  class Submit < Action
60
+ # Change the URL to submit and bypass all frontend validations.
61
+ string :overrideUrl
60
62
  end
61
63
  end
62
64
 
@@ -143,7 +143,7 @@ class Glib::JsonUi::ViewBuilder
143
143
  class RichText < Text
144
144
  array :images
145
145
  hash :imageUploader
146
- string :produce # html or markdown
146
+ string :produce # `html` or `markdown`
147
147
  end
148
148
 
149
149
  class Country < AbstractField
@@ -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
- string :uncompletedIcon
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
- page.form url: json_ui_garage_url(path: 'forms/basic_post'), method: 'post', padding: { top: 12, left: 20, right: 20, bottom: 12 }, childViews: ->(form) do
8
- form.fields_text name: 'user[name]', width: 'matchParent', label: 'Name', value: 'Rich Text Editor'
9
-
10
- # images = [
11
- # {
12
- # value: "eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBFQT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--193dc0d939b9558fc4973fafbba91d989cbb04d4",
13
- # fileUrl: "https://imageserver-demo.herokuapp.com/image/itinerarybuilder-demo/o6CKzNt67PWnkPdUEnWMt7pr?h=100&w=100"
14
- # }
15
- # ]
16
- # form.fields_richText name: 'user[bio]', width: 'matchParent', label: 'Content', images: images, value: '<p>Test {{image1}}</p>'
17
-
18
- json.child! do
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**.\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
- json.imageUploader do
35
- json.name 'user[images_attributes][]'
36
- json.accepts(fileType: 'image/*', maxFileSize: 5000)
37
- json.directUploadUrl rails_direct_uploads_url
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.button text: 'Submit', onClick: ->(action) { action.forms_submit }
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[video_url]',
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
@@ -0,0 +1,9 @@
1
+ json.title 'Pages'
2
+
3
+ page = json_ui_page json
4
+
5
+ render "#{@path_prefix}/nav_menu", json: json, page: page
6
+
7
+ page.on load: ->(action) do
8
+ action.windows_open url: json_ui_garage_url
9
+ end
@@ -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
- { name: :submitted, label: 'Order submitted' },
12
- { name: :finding, label: 'Finding you a driver' },
13
- { name: :driver_assigned, label: 'Driver found, picking you up..' },
14
- { name: :otw, label: 'On the way' },
15
- { name: :arrived, label: 'Arrived' }
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
- # Defining active or completed item
19
- active_name = :driver_assigned
20
- timeline_items.each_with_index do |h, i|
21
- if h[:name] == active_name
22
- h[:active] = true
23
- break
24
- else
25
- h[:completed] = true
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
- scroll.panels_timeline items: timeline_items
30
- scroll.spacer height: 32
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
- custom_completed_item = {
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
- completedIcon: 'check',
53
- uncompletedIcon: 'hourglass_empty'
54
- scroll.spacer height: 32
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
- scroll.h2 text: 'Timeline with childViews'
57
- scroll.panels_timeline \
58
- items: timeline_items,
59
- childViews: ->(tview) do
60
- tview.spacer height: 16
61
- render 'json_ui/garage/panels/timeline_content', tview: tview
62
- tview.spacer height: 16
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
- tview.button text: 'Reset', onClick: ->(action) do
65
- action.windows_reload url: json_ui_garage_url(path: 'panels/timeline')
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: 1.1.0
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