glib-web 0.2.5 → 0.2.6

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
  SHA1:
3
- metadata.gz: 07f4814b44f64585a3862468a56d2c645eee1b5a
4
- data.tar.gz: 8f56b831228ffe905f9d46335f95b4e5199bcac3
3
+ metadata.gz: 91bbaabb7ba267a91d4f7ff4b8cdd3b142fe2dc2
4
+ data.tar.gz: 22db4840a440ef31d8161267f366c24ea0e39365
5
5
  SHA512:
6
- metadata.gz: 3f9752a9758a0674b3d7d889c35f34633f1ee021b1a8b3e6300677b38f4144d24731febb05606902af1a90237638a68808c597683f3a9fe96442f36853ce39a1
7
- data.tar.gz: c7e4bc6af22642572c2ba7c65dfcea6c57e0e229ce1031acfdbdd8f6eb109cb543ca0f38b80caaa03c23b71b8a70f76c6eb90da555edb4aa5f2e587380c339b9
6
+ metadata.gz: 4f70589581f61e65eb0f4dd4d09b07657c30fde7fc8067d0f30c6577ebfa55af9d42f7ad513e4cc7ae3058542619758d2d9bf04cfffaf372d1822a99a975ce35
7
+ data.tar.gz: 3ce7731eef560c59759fc483d16f3516d88f6f5e849489452d2a4c93120f805d128b3f1a4583e68fa67650ed41ae621c496b7b4f510294d53d6b31497914731e
@@ -48,8 +48,8 @@ module Glib
48
48
  block = options[:builder]
49
49
  json.rows do
50
50
  if (objects = options[:objects])
51
- objects.each do |object|
52
- block&.call @template, object
51
+ objects.each_with_index do |object, index|
52
+ block&.call @template, object, index
53
53
  end
54
54
  else
55
55
  block&.call @template
@@ -16,9 +16,7 @@ module Glib
16
16
 
17
17
  class Page
18
18
  attr_reader :json, :context, :view_builder, :action_builder, :menu_builder
19
- attr_reader :list_section_builder, :drawer_content_builder
20
-
21
- attr_reader :table_section_builder, :table_template_builder
19
+ attr_reader :list_section_builder, :drawer_content_builder, :table_section_builder
22
20
 
23
21
  # See Panels::Form
24
22
  attr_accessor :current_form
@@ -33,9 +31,8 @@ module Glib
33
31
 
34
32
  @list_section_builder = ListBuilders::Section.new(json, self, ListBuilders::Template.new(json, self))
35
33
  @drawer_content_builder = ListBuilders::Section.new(json, self, @menu_builder)
36
-
37
- @table_section_builder = TableBuilders::Section.new(json, self)
38
- @table_template_builder = TableBuilders::Template.new(json, self)
34
+ @table_section_builder = TableBuilders::Section.new(json, self, TableBuilders::Template.new(json, self))
35
+ # @table_template_builder = TableBuilders::Template.new(json, self)
39
36
  end
40
37
 
41
38
  def rightNavButtons
@@ -1,9 +1,17 @@
1
1
  module Glib
2
2
  module JsonUi
3
3
  module StylingHelper
4
- def body_padding
4
+ def json_padding_body
5
5
  { top: 12, left: 20, right: 20, bottom: 12 }
6
6
  end
7
+
8
+ def json_padding_list
9
+ { top: 12, bottom: 12, left: 16, right: 16 }
10
+ end
11
+
12
+ def json_padding_body_this
13
+ { top: 6, right: 10, bottom: 6, left: 10 }
14
+ end
7
15
  end
8
16
  end
9
17
  end
@@ -23,6 +23,11 @@ module Glib
23
23
  end
24
24
 
25
25
  class Section < AbstractBuilder
26
+ def initialize json, page, template
27
+ super json, page
28
+ @template = template
29
+ end
30
+
26
31
  def header(options = {})
27
32
  json.header do
28
33
  json.backgroundColor options[:backgroundColor]
@@ -32,18 +37,32 @@ module Glib
32
37
  end
33
38
  end
34
39
 
35
- def rows(array = nil)
36
- template = page.table_template_builder
40
+ def rows(options = {})
41
+ block = options[:builder]
37
42
  json.rows do
38
- if array
39
- array.each do |row|
40
- yield template, row
43
+ if (objects = options[:objects])
44
+ objects.each_with_index do |object, index|
45
+ block&.call @template, object, index
41
46
  end
42
47
  else
43
- yield template
48
+ block&.call @template
44
49
  end
45
50
  end
46
51
  end
52
+
53
+ # def rows(array = nil)
54
+ # template = page.table_template_builder
55
+ # json.rows do
56
+ # if array
57
+ # array.each do |row|
58
+ # yield template, row
59
+ # end
60
+ # else
61
+ # yield template
62
+ # end
63
+ # end
64
+ # end
65
+
47
66
  end
48
67
 
49
68
  end
@@ -80,6 +80,10 @@ module Glib
80
80
  string :dataUrl
81
81
  end
82
82
 
83
+ class Chip < View
84
+ string :text
85
+ end
86
+
83
87
  class Calendar < View
84
88
  string :dataUrl
85
89
  end
@@ -3,7 +3,7 @@ json.title 'Forms'
3
3
  json_ui_page json do |page|
4
4
  render "#{@path_prefix}/nav_menu", json: json, page: page
5
5
 
6
- page.form url: json_ui_garage_url(path: 'forms/basic_post'), method: 'post', padding: body_padding, childViews: ->(form) do
6
+ page.form url: json_ui_garage_url(path: 'forms/basic_post'), method: 'post', padding: json_padding_body, childViews: ->(form) do
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
 
@@ -5,7 +5,7 @@ json_ui_page json do |page|
5
5
 
6
6
  page.scroll childViews: ->(scroll) do
7
7
 
8
- scroll.panels_form url: json_ui_garage_url(path: 'forms/generic_post'), method: 'post', padding: body_padding, childViews: ->(form) do
8
+ scroll.panels_form url: json_ui_garage_url(path: 'forms/generic_post'), method: 'post', padding: json_padding_body, childViews: ->(form) do
9
9
  form.spacer height: 20
10
10
  form.h2 text: 'Check Group'
11
11
  form.fields_checkGroup name: 'user[skills][]', uncheckValue: 1, childViews: ->(group) do
@@ -3,7 +3,7 @@ json.title 'Forms'
3
3
  json_ui_page json do |page|
4
4
  render "#{@path_prefix}/nav_menu", json: json, page: page
5
5
 
6
- page.form url: json_ui_garage_url(path: 'forms/generic_post'), method: 'post', padding: body_padding, childViews: ->(form) do
6
+ page.form url: json_ui_garage_url(path: 'forms/generic_post'), method: 'post', padding: json_padding_body, childViews: ->(form) do
7
7
  form.h2 text: 'Dynamic Select'
8
8
  form.spacer height: 6
9
9
 
@@ -5,7 +5,7 @@ json_ui_page json do |page|
5
5
 
6
6
  page.list sections: [
7
7
  ->(section) do
8
- section.header padding: { top: 12, bottom: 12, left: 16, right: 16 }, childViews: ->(header) do
8
+ section.header padding: json_padding_list, childViews: ->(header) do
9
9
  header.h2 text: 'Submission Logics'
10
10
  end
11
11
 
@@ -25,7 +25,7 @@ json_ui_page json do |page|
25
25
 
26
26
  end
27
27
  end, ->(section) do
28
- section.header padding: { top: 12, bottom: 12, left: 16, right: 16 }, childViews: ->(header) do
28
+ section.header padding: json_padding_list, childViews: ->(header) do
29
29
  header.h2 text: 'Form Fields'
30
30
  end
31
31
 
@@ -42,7 +42,7 @@ json_ui_page json do |page|
42
42
 
43
43
  end
44
44
  end, ->(section) do
45
- section.header padding: { top: 12, bottom: 12, left: 16, right: 16 }, childViews: ->(header) do
45
+ section.header padding: json_padding_list, childViews: ->(header) do
46
46
  header.h2 text: 'Web Only'
47
47
  end
48
48
 
@@ -53,7 +53,7 @@ json_ui_page json do |page|
53
53
 
54
54
  end
55
55
  end, ->(section) do
56
- section.header padding: { top: 12, bottom: 12, left: 16, right: 16 }, childViews: ->(header) do
56
+ section.header padding: json_padding_list, childViews: ->(header) do
57
57
  header.h2 text: 'Experimental (not required yet)'
58
58
  end
59
59
 
@@ -3,7 +3,7 @@ json.title 'Forms'
3
3
  json_ui_page json do |page|
4
4
  render "#{@path_prefix}/nav_menu", json: json, page: page
5
5
 
6
- page.form url: json_ui_garage_url(path: 'forms/generic_post'), method: 'post', padding: body_padding, childViews: ->(form) do
6
+ page.form url: json_ui_garage_url(path: 'forms/generic_post'), method: 'post', padding: json_padding_body, childViews: ->(form) do
7
7
  form.h2 text: 'Radio Group'
8
8
  form.spacer height: 6
9
9
  form.h4 text: 'Gender'
@@ -49,25 +49,4 @@ json_ui_page json do |page|
49
49
 
50
50
  end
51
51
 
52
-
53
- # scroll.panels_form url: json_ui_garage_url(path: 'forms/generic_post'), method: 'post', padding: body_padding, childViews: ->(form) do
54
- # form.spacer height: 20
55
- # form.h2 text: 'Radio Group'
56
- # form.spacer height: 6
57
- # form.h4 text: 'Gender'
58
- # form.fields_radioGroup name: 'user[gender]', childViews: ->(group) do
59
- # group.fields_radio value: 'M', label: 'Male'
60
- # group.fields_radio value: 'F', label: 'Female'
61
- # end
62
-
63
- # form.button text: 'Submit', onClick: ->(action) { action.forms_submit }
64
- # end
65
-
66
- # scroll.panels_form url: json_ui_garage_url(path: 'forms/generic_post'), method: 'post', padding: body_padding, childViews: ->(form) do
67
- # form.spacer height: 20
68
- # form.h2 text: 'Single Check'
69
- # form.fields_check name: 'user[employer]', value: 2, uncheckValue: 1, label: 'I am an employer'
70
-
71
- # form.button text: 'Submit', onClick: ->(action) { action.forms_submit }
72
- # end
73
52
  end
@@ -27,61 +27,3 @@ json_ui_page json do |page|
27
27
 
28
28
  end
29
29
  end
30
-
31
- # json_body_with_list json do
32
- # json.rows do
33
- # json.child! do
34
- # json.template 'thumbnail-v1'
35
- # json.title 'Pages'
36
- # json.onClick do
37
- # json.action 'windows/open-v1'
38
- # json.url json_ui_garage_url(path: 'pages/index')
39
- # end
40
- # end
41
-
42
- # json.child! do
43
- # json.template 'thumbnail-v1'
44
- # json.title 'Lists'
45
- # json.onClick do
46
- # json.action 'windows/open-v1'
47
- # json.url json_ui_garage_url(path: 'lists/index')
48
- # end
49
- # end
50
-
51
- # json.child! do
52
- # json.template 'thumbnail-v1'
53
- # json.title 'Forms'
54
- # json.onClick do
55
- # json.action 'windows/open-v1'
56
- # json.url json_ui_garage_url(path: 'forms/index')
57
- # end
58
- # end
59
-
60
- # json.child! do
61
- # json.template 'thumbnail-v1'
62
- # json.title 'Panels'
63
- # json.onClick do
64
- # json.action 'windows/open-v1'
65
- # json.url json_ui_garage_url(path: 'panels/index')
66
- # end
67
- # end
68
-
69
- # json.child! do
70
- # json.template 'thumbnail-v1'
71
- # json.title 'Views'
72
- # json.onClick do
73
- # json.action 'windows/open-v1'
74
- # json.url json_ui_garage_url(path: 'views/index')
75
- # end
76
- # end
77
-
78
- # json.child! do
79
- # json.template 'thumbnail-v1'
80
- # json.title 'Actions'
81
- # json.onClick do
82
- # json.action 'windows/open-v1'
83
- # json.url json_ui_garage_url(path: 'actions/index')
84
- # end
85
- # end
86
- # end
87
- # end
@@ -10,7 +10,7 @@ json_ui_page json do |page|
10
10
 
11
11
  section.rows builder: ->(template) do
12
12
  template.thumbnail title: 'Click me', onClick: ->(action) do
13
- action.dialogs_alert message: 'Perform action'
13
+ action.windows_openWeb url: 'https://www.google.com'
14
14
  end
15
15
  template.thumbnail title: 'Item with subtitle', subtitle: 'Item subtitle'
16
16
  template.thumbnail title: 'Item with thumbnail image', subtitle: 'Item subtitle', imageUrl: @sample_image_url
@@ -3,8 +3,8 @@ json.title 'Panels'
3
3
  json_ui_page json do |page|
4
4
  render "#{@path_prefix}/nav_menu", json: json, page: page
5
5
 
6
- page.scroll backgroundColor: '#fafafa', padding: body_padding, childViews: ->(scroll) do
7
- scroll.panels_card width: 'matchParent', padding: body_padding, childViews: ->(card) do
6
+ page.scroll backgroundColor: '#fafafa', padding: json_padding_body_this, childViews: ->(scroll) do
7
+ scroll.panels_card width: 'matchParent', padding: json_padding_body, childViews: ->(card) do
8
8
  card.h1 text: 'With Default Layout'
9
9
  card.spacer height: 6
10
10
  card.button text: 'Button1'
@@ -12,9 +12,9 @@ json_ui_page json do |page|
12
12
  card.button text: 'Button3'
13
13
  end
14
14
 
15
- scroll.spacer height: 20
15
+ scroll.spacer height: 10
16
16
 
17
- scroll.panels_card width: 'matchParent', padding: body_padding, childViews: ->(card) do
17
+ scroll.panels_card width: 'matchParent', padding: json_padding_body, childViews: ->(card) do
18
18
  card.h1 text: 'With Child Panel'
19
19
  card.spacer height: 6
20
20
  card.panels_horizontal backgroundColor: '#b3bac2', childViews: ->(panel) do
@@ -3,8 +3,9 @@ json.title 'Panels'
3
3
  json_ui_page json do |page|
4
4
  render "#{@path_prefix}/nav_menu", json: json, page: page
5
5
 
6
- page.scroll padding: body_padding, childViews: ->(scroll) do
7
- scroll.panels_custom template: 'thumbnail', data: { title: 'Title' }
6
+ page.scroll padding: json_padding_body, childViews: ->(scroll) do
7
+ scroll.panels_custom template: 'thumbnail', data: { imageUrl: @sample_image_url, title: 'Title', subtitle: 'Subtitle' }
8
+ scroll.spacer height: 6
8
9
  scroll.panels_custom template: 'nonExistentTemplate'
9
10
  end
10
11
  end
@@ -3,27 +3,65 @@ json.title 'Panels'
3
3
  json_ui_page json do |page|
4
4
  render "#{@path_prefix}/nav_menu", json: json, page: page, top_nav: true
5
5
 
6
- page.list firstSection: ->(section) do
7
- section.rows builder: ->(template) do
8
- template.thumbnail title: 'Card', onClick: ->(action) do
9
- action.windows_open url: json_ui_garage_url(path: 'panels/card')
10
- end
11
- template.thumbnail title: 'Vertical', onClick: ->(action) do
12
- action.windows_open url: json_ui_garage_url(path: 'panels/vertical')
13
- end
14
- template.thumbnail title: 'Horizontal', onClick: ->(action) do
15
- action.windows_open url: json_ui_garage_url(path: 'panels/horizontal')
16
- end
17
- template.thumbnail title: 'Split', onClick: ->(action) do
18
- action.windows_open url: json_ui_garage_url(path: 'panels/split')
6
+
7
+ page.list sections: [
8
+ ->(section) do
9
+ section.rows builder: ->(template) do
10
+ template.thumbnail title: 'Card', onClick: ->(action) do
11
+ action.windows_open url: json_ui_garage_url(path: 'panels/card')
12
+ end
13
+ template.thumbnail title: 'Vertical', onClick: ->(action) do
14
+ action.windows_open url: json_ui_garage_url(path: 'panels/vertical')
15
+ end
16
+ template.thumbnail title: 'Horizontal', onClick: ->(action) do
17
+ action.windows_open url: json_ui_garage_url(path: 'panels/horizontal')
18
+ end
19
+ template.thumbnail title: 'Split', onClick: ->(action) do
20
+ action.windows_open url: json_ui_garage_url(path: 'panels/split')
21
+ end
22
+ template.thumbnail title: 'Carousel', onClick: ->(action) do
23
+ action.windows_open url: json_ui_garage_url(path: 'panels/carousel')
24
+ end
25
+ template.thumbnail title: 'Custom', onClick: ->(action) do
26
+ action.windows_open url: json_ui_garage_url(path: 'panels/custom')
27
+ end
28
+
19
29
  end
20
- template.thumbnail title: 'Carousel', onClick: ->(action) do
21
- action.windows_open url: json_ui_garage_url(path: 'panels/carousel')
30
+ end, ->(section) do
31
+ section.header padding: json_padding_list, childViews: ->(header) do
32
+ header.h2 text: 'Web Only'
22
33
  end
23
- template.thumbnail title: 'Custom', onClick: ->(action) do
24
- action.windows_open url: json_ui_garage_url(path: 'panels/custom')
34
+
35
+ section.rows builder: ->(template) do
36
+ template.thumbnail title: 'Table', onClick: ->(action) do
37
+ action.windows_open url: json_ui_garage_url(path: 'panels/table')
38
+ end
39
+
25
40
  end
26
41
  end
42
+ ]
43
+
44
+ # page.list firstSection: ->(section) do
45
+ # section.rows builder: ->(template) do
46
+ # template.thumbnail title: 'Card', onClick: ->(action) do
47
+ # action.windows_open url: json_ui_garage_url(path: 'panels/card')
48
+ # end
49
+ # template.thumbnail title: 'Vertical', onClick: ->(action) do
50
+ # action.windows_open url: json_ui_garage_url(path: 'panels/vertical')
51
+ # end
52
+ # template.thumbnail title: 'Horizontal', onClick: ->(action) do
53
+ # action.windows_open url: json_ui_garage_url(path: 'panels/horizontal')
54
+ # end
55
+ # template.thumbnail title: 'Split', onClick: ->(action) do
56
+ # action.windows_open url: json_ui_garage_url(path: 'panels/split')
57
+ # end
58
+ # template.thumbnail title: 'Carousel', onClick: ->(action) do
59
+ # action.windows_open url: json_ui_garage_url(path: 'panels/carousel')
60
+ # end
61
+ # template.thumbnail title: 'Custom', onClick: ->(action) do
62
+ # action.windows_open url: json_ui_garage_url(path: 'panels/custom')
63
+ # end
64
+ # end
27
65
 
28
- end
66
+ # end
29
67
  end
@@ -0,0 +1,25 @@
1
+ json.title 'Panels'
2
+
3
+ json_ui_page json do |page|
4
+ render "#{@path_prefix}/nav_menu", json: json, page: page
5
+
6
+ page.table firstSection: ->(section) do
7
+ section.header cellViews: ->(header) do
8
+ header.label text: 'Heading1'
9
+ header.label text: 'Heading2'
10
+ header.label text: 'Heading3'
11
+ end
12
+
13
+ items = [1, 2, 3]
14
+ section.rows objects: items, builder: ->(row, item, index) do
15
+ row.default cellViews: ->(cell) do
16
+ cell.label text: "Data #{item}"
17
+ cell.label text: "Data #{item}"
18
+ cell.label text: "Data #{item}"
19
+ end, onClick: ->(action) do
20
+ action.windows_openWeb url: 'https://www.google.com'
21
+ end
22
+ end
23
+ end
24
+
25
+ end
@@ -3,7 +3,30 @@ json.title 'Views'
3
3
  json_ui_page json do |page|
4
4
  render "#{@path_prefix}/nav_menu", json: json, page: page
5
5
 
6
- page.scroll padding: body_padding, childViews: ->(scroll) do
6
+ page.scroll padding: json_padding_body, childViews: ->(scroll) do
7
+ scroll.h1 text: 'Heading 1'
8
+
9
+ scroll.spacer height: 10
10
+ scroll.h2 text: 'Heading 2'
11
+
12
+ scroll.spacer height: 10
13
+ scroll.h3 text: 'Heading 3'
14
+
15
+ scroll.spacer height: 10
16
+ scroll.h4 text: 'Heading 4'
17
+
18
+ scroll.spacer height: 10
19
+ scroll.label text: 'Label'
20
+
21
+ scroll.spacer height: 20
22
+ scroll.hr width: 'matchParent'
23
+ scroll.spacer height: 20
24
+
25
+ scroll.h2 text: 'Chip'
26
+ scroll.spacer height: 6
27
+ scroll.chip text: 'pending'
28
+
29
+ scroll.spacer height: 20
7
30
  scroll.h2 text: 'Map'
8
31
  scroll.spacer height: 6
9
32
  scroll.map width: 'matchParent', latitude: 13.4837, longitude: 144.7917, zoom: 11, height: 250, dataUrl: json_ui_garage_url(path: 'views/map_data')
@@ -3,7 +3,7 @@ json.title 'Views'
3
3
  json_ui_page json do |page|
4
4
  render "#{@path_prefix}/nav_menu", json: json, page: page
5
5
 
6
- page.scroll padding: body_padding, childViews: ->(scroll) do
6
+ page.scroll padding: json_padding_body, childViews: ->(scroll) do
7
7
  scroll.h2 text: 'Avatar'
8
8
  scroll.spacer height: 6
9
9
  scroll.avatar url: 'https://www.wpjournalist.nl/wp-content/uploads/2019/03/avatar-jongen-voorbeeld-1.jpg'
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.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
@@ -83,6 +83,7 @@ files:
83
83
  - app/views/json_ui/garage/panels/horizontal.json.jbuilder
84
84
  - app/views/json_ui/garage/panels/index.json.jbuilder
85
85
  - app/views/json_ui/garage/panels/split.json.jbuilder
86
+ - app/views/json_ui/garage/panels/table.json.jbuilder
86
87
  - app/views/json_ui/garage/panels/vertical.json.jbuilder
87
88
  - app/views/json_ui/garage/views/basic.json.jbuilder
88
89
  - app/views/json_ui/garage/views/calendar_data.json.jbuilder