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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7d54f11d392b1b330e30746a54d6cc10eba3d3f050754b8c6957ecd70790d02e
4
- data.tar.gz: 8d55496374c7da6c3570de7ad986b526026a395f11fd387e05d66f35944a54a3
3
+ metadata.gz: d9d76762411f8762de62b8e1605f781b27be3d3485aa13d26a4a0ec7c66b009f
4
+ data.tar.gz: ec38270488ca88e627e6e8fee65e8f1c6836ec934d1d7d04e9cd22afc4a354e5
5
5
  SHA512:
6
- metadata.gz: 0b6c09ef7d53a989b1e5ad99815f36ba9dc84384c176aefd58cb2112cfb8d02352ee0617443a4e8569a955dd459fe71429a59f3fe60d26cf3575e06f35b13f98
7
- data.tar.gz: 89d3f2502a153de10c649abfc09406b0041b954aaff9f15405827c550c7024a8886fec7c92ac6e4fca8a324852235c764207034e00e5e28b1c2201bdc097c617
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
@@ -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,81 @@ 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**.'
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
- json.imageUploader do
35
- json.name 'user[images_attributes][]'
36
- json.accepts(fileType: 'image/*', maxFileSize: 5000)
37
- json.directUploadUrl rails_direct_uploads_url
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.button text: 'Submit', onClick: ->(action) { action.forms_submit }
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[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
@@ -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.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