glib-web 0.2.11 → 0.2.12

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 28296441cfbabaa9915d315407f81ee8ff6c3d0f
4
- data.tar.gz: 44bafc6c627fe454fca1630bd9e3288f8c71b52c
3
+ metadata.gz: 70a139ad04c9474b9ed21f76b4de4635191a19f9
4
+ data.tar.gz: c27f5af86e354a217f6f7703452beb8529a7d737
5
5
  SHA512:
6
- metadata.gz: 6e043b39a9176c67a66027b2aed616d9c0b30c423047c72e3a48a075c5854ab85ae75e8ef50050b7a00faf6ad9afe535231e17b422642cf6c4c2a60e8be19ac0
7
- data.tar.gz: e35a72b90a294c8cfee957d62788dab43a78801308cb17db43d0889ffce133e97175102456b70a4b5df6607ba3b10969719169dccafbb4d5758d7d585ff4c926
6
+ metadata.gz: 6166a3a64dcdbd590920add4aa4d301501cad52dce40f7ae13bb211c9fbd893a41030b68fdb80d1a83f6709feb29fb03463022d911c0ef29f06d4e2a4d122f77
7
+ data.tar.gz: 9270f172fe0eb7a15fc51e3611073958061cfcfa2a5e7eec758ffff21cad6e0383da191b5cb21bd58749a5101e68862dc262886027cf592c36d19af557836bfe
@@ -143,9 +143,11 @@ module Glib
143
143
  end
144
144
  end
145
145
 
146
- def self.bool propName
146
+ def self.bool propName, options = {}
147
147
  define_method(propName) do |value|
148
- json.set! propName, value == true
148
+ bool = value == true
149
+ instance_variable_set("@#{propName}", bool) if options[:cache]
150
+ json.set! propName, bool
149
151
  end
150
152
  end
151
153
 
@@ -68,6 +68,7 @@ module Glib
68
68
 
69
69
  def body(options = {})
70
70
  json.body do
71
+ # raise "OPT: #{options}"
71
72
  vertical_content(options)
72
73
  end
73
74
  end
@@ -106,7 +107,7 @@ module Glib
106
107
  def vertical_content(options)
107
108
  options = options.reverse_merge(width: 'matchParent')
108
109
 
109
- [:padding, :backgroundColor, :width, :height].each do |name|
110
+ [:padding, :backgroundColor, :width, :height, :align].each do |name|
110
111
  if (value = options[name])
111
112
  json.set! name, value
112
113
  end
@@ -13,14 +13,19 @@ class Glib::JsonUi::ViewBuilder
13
13
  end
14
14
 
15
15
  def prop(prop)
16
- if (form = page.current_form)
17
- @name ||= form.field_name(prop)
18
- @value ||= form.field_value(prop)
19
- end
16
+ @prop = prop
17
+ # if (form = page.current_form)
18
+ # @name ||= form.field_name(prop)
19
+ # @value ||= form.field_value(prop)
20
+ # end
20
21
  end
21
22
 
22
23
  # Override
23
24
  def created
25
+ if (@prop && form = page.current_form)
26
+ @name ||= form.field_name(@prop, @multiple || false)
27
+ @value ||= form.field_value(@prop)
28
+ end
24
29
  json.name @name
25
30
  json.value @value
26
31
  end
@@ -72,14 +77,14 @@ class Glib::JsonUi::ViewBuilder
72
77
  class Select < AbstractField
73
78
  array :options
74
79
  bool :readOnly
75
- bool :multiple
80
+ bool :multiple, cache: true
76
81
  bool :manualEntry
77
82
  end
78
83
 
79
84
  class DynamicSelect < AbstractField
80
85
  array :selectedOptions
81
86
  string :url
82
- bool :multiple
87
+ bool :multiple, cache: true
83
88
 
84
89
  # Override
85
90
  def value(value)
@@ -4,11 +4,15 @@ class Glib::JsonUi::ViewBuilder
4
4
  # boolean :local
5
5
 
6
6
  def is_association?(prop)
7
- @model.class.reflect_on_association(prop)
7
+ # Not all model is ActiveRecord
8
+ if @model.class.respond_to?(:reflect_on_association)
9
+ return @model.class.reflect_on_association(prop)
10
+ end
11
+ return false
8
12
  end
9
13
 
10
- def field_name(prop)
11
- suffix = is_association?(prop) ? '[]' : ''
14
+ def field_name(prop, multiple)
15
+ suffix = is_association?(prop) || multiple ? '[]' : ''
12
16
  "#{@model_name}[#{prop}]#{suffix}"
13
17
  end
14
18
 
@@ -45,23 +49,13 @@ class Glib::JsonUi::ViewBuilder
45
49
 
46
50
  # Override
47
51
  def created
52
+ @method ||= :get
53
+
48
54
  json.url @url
49
55
  json.method @method
50
- end
51
-
52
- def childViews(block)
53
- # insert_method_field = false
54
- # method = @args[:method].to_sym
55
- # case method
56
- # when :patch, :put, :delete
57
- # json.method :post
58
- # insert_method_field = true
59
- # else
60
- # json.method method
61
- # end
62
-
56
+
63
57
  json.childViews do
64
- if @method.downcase != 'get'
58
+ if @method != :get
65
59
  json.child! do
66
60
  json.view 'fields/hidden-v1'
67
61
  json.name 'authenticity_token'
@@ -79,9 +73,14 @@ class Glib::JsonUi::ViewBuilder
79
73
 
80
74
  # NOTE: this pattern will not work for views that can be nested. Luckily forms shouldn't be nested anyway.
81
75
  page.current_form = self
82
- block.call(page.view_builder)
76
+ @childViewsBlock.call(page.view_builder)
83
77
  page.current_form = nil
84
78
  end
79
+
80
+ end
81
+
82
+ def childViews(block)
83
+ @childViewsBlock = block
85
84
  end
86
85
  end
87
86
 
@@ -115,6 +114,7 @@ class Glib::JsonUi::ViewBuilder
115
114
 
116
115
  class Scroll < View
117
116
  views :childViews
117
+ string :align
118
118
  end
119
119
 
120
120
  class Split < View
@@ -123,6 +123,17 @@ class Glib::JsonUi::ViewBuilder
123
123
  views :rightViews
124
124
  end
125
125
 
126
+ class Responsive < View
127
+ views :childViews
128
+ end
129
+
130
+ class Column < View
131
+ int :lg
132
+ int :md
133
+ int :sm
134
+ views :childViews
135
+ end
136
+
126
137
  class Vertical < View
127
138
  views :childViews
128
139
  string :distribution
@@ -58,10 +58,29 @@ module Glib
58
58
  string :text
59
59
  end
60
60
 
61
- class Spacer < View
61
+ class P < View
62
+ string :text
63
+ end
64
+
65
+ class Label < View
66
+ string :text
67
+ action :onClick
62
68
  end
63
69
 
64
- class Hr < View
70
+ class Image < View
71
+ string :url
72
+ string :base64Data
73
+ action :onClick
74
+ end
75
+
76
+ class Avatar < View
77
+ string :url
78
+ action :onClick
79
+ end
80
+
81
+ class Icon < View
82
+ string :name
83
+ action :onClick
65
84
  end
66
85
 
67
86
  class Button < View
@@ -76,23 +95,10 @@ module Glib
76
95
  action :onClick
77
96
  end
78
97
 
79
- class Image < View
80
- string :url
81
- string :base64Data
82
- action :onClick
83
- end
84
-
85
- class Avatar < View
86
- string :url
87
- action :onClick
98
+ class Hr < View
88
99
  end
89
100
 
90
- class P < View
91
- string :text
92
- end
93
-
94
- class Label < View
95
- string :text
101
+ class Spacer < View
96
102
  end
97
103
 
98
104
  class Map < View
@@ -5,6 +5,11 @@ json_ui_page json do |page|
5
5
 
6
6
  page.form url: json_ui_garage_url(path: 'forms/submission_indicator_post'), method: 'post', padding: { top: 12, left: 20, right: 20, bottom: 12 }, childViews: ->(form) do
7
7
  form.button text: 'This button gets disabled on submit', onClick: ->(action) { action.forms_submit }
8
+
9
+ # This needs to be long enough that the FAB is roughly at the bottom of a mobile screen.
10
+ # Ideally the spacer can expand dynamically depending on available space.
11
+ form.spacer height: 400
12
+
8
13
  form.fab icon: 'send', onClick: ->(action) { action.forms_submit }
9
14
  end
10
15
  end
@@ -14,11 +14,8 @@ json_ui_page json do |page|
14
14
  template.thumbnail title: 'Infinite Scroll', onClick: ->(action) do
15
15
  action.windows_open url: json_ui_garage_url(path: 'lists/infinite_scroll')
16
16
  end
17
- template.thumbnail title: 'FAB (Floating Action Button) 1', onClick: ->(action) do
18
- action.windows_open url: json_ui_garage_url(path: 'lists/fab1')
19
- end
20
- template.thumbnail title: 'FAB (Floating Action Button) 2', onClick: ->(action) do
21
- action.windows_open url: json_ui_garage_url(path: 'lists/fab2')
17
+ template.thumbnail title: 'FAB (Floating Action Button)', onClick: ->(action) do
18
+ action.windows_open url: json_ui_garage_url(path: 'lists/fab')
22
19
  end
23
20
  end
24
21
 
@@ -6,7 +6,7 @@ image_url2 = 'https://s.abcnews.com/images/International/Guam03-gty-jrl-170809_1
6
6
  json_ui_page json do |page|
7
7
  render "#{@path_prefix}/nav_menu", json: json, page: page
8
8
 
9
- page.scroll padding: { top: 12, bottom: 12, left: 16, right: 16 }, childViews: ->(scroll) do
9
+ page.scroll padding: json_padding_body, childViews: ->(scroll) do
10
10
  scroll.h1 text: 'Carousel panel'
11
11
  scroll.panels_carousel width: 'matchParent', childViews: ->(carousel) do
12
12
  carousel.image url: image_url1, width: 'matchParent'
@@ -3,7 +3,7 @@ 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: { top: 12, bottom: 12, left: 16, right: 16 }, childViews: ->(scroll) do
6
+ page.scroll padding: json_padding_body, childViews: ->(scroll) do
7
7
  scroll.h1 text: 'Horizontal panel'
8
8
  scroll.panels_horizontal backgroundColor: '#b3bac2', childViews: ->(panel) do
9
9
  panel.button text: '1'
@@ -10,15 +10,18 @@ json_ui_page json do |page|
10
10
  end
11
11
 
12
12
  section.rows builder: ->(template) do
13
- template.thumbnail title: 'Vertical', onClick: ->(action) do
13
+ template.thumbnail title: 'Vertical', subtitle: 'Arrange child components vertically', onClick: ->(action) do
14
14
  action.windows_open url: json_ui_garage_url(path: 'panels/vertical')
15
15
  end
16
- template.thumbnail title: 'Horizontal', onClick: ->(action) do
16
+ template.thumbnail title: 'Horizontal', subtitle: 'Arrange child components horizontally', onClick: ->(action) do
17
17
  action.windows_open url: json_ui_garage_url(path: 'panels/horizontal')
18
18
  end
19
- template.thumbnail title: 'Carousel', onClick: ->(action) do
19
+ template.thumbnail title: 'Carousel', subtitle: 'Arrange child components horizontally in a carousel', onClick: ->(action) do
20
20
  action.windows_open url: json_ui_garage_url(path: 'panels/carousel')
21
21
  end
22
+ template.thumbnail title: 'Responsive', subtitle: 'Arrange *column panels* horizontally using flex', onClick: ->(action) do
23
+ action.windows_open url: json_ui_garage_url(path: 'panels/responsive')
24
+ end
22
25
 
23
26
  end
24
27
  end, ->(section) do
@@ -38,8 +41,6 @@ json_ui_page json do |page|
38
41
  template.thumbnail title: 'List', subtitle: 'Sub-panels: header, footer', onClick: ->(action) do
39
42
  action.windows_open url: json_ui_garage_url(path: 'lists/index')
40
43
  end
41
- template.thumbnail title: 'Flex', subtitle: 'TODO', onClick: ->(action) do
42
- end
43
44
  end
44
45
  end, ->(section) do
45
46
  section.header padding: json_padding_list, childViews: ->(header) do
@@ -72,6 +73,9 @@ json_ui_page json do |page|
72
73
  template.thumbnail title: 'Card', subtitle: 'Adds card-like bevel', onClick: ->(action) do
73
74
  action.windows_open url: json_ui_garage_url(path: 'panels/card')
74
75
  end
76
+ template.thumbnail title: 'Column', subtitle: 'Adds control over layout inside a responsive panel', onClick: ->(action) do
77
+ action.windows_open url: json_ui_garage_url(path: 'panels/responsive')
78
+ end
75
79
 
76
80
  end
77
81
  end, ->(section) do
@@ -0,0 +1,43 @@
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.scroll padding: json_padding_body, childViews: ->(scroll) do
7
+ scroll.label text: 'Shrink the browser\'s width to see how the column panels are rearranged. On mobile screens, they are always arranged vertically'
8
+
9
+ scroll.spacer height: 20
10
+ scroll.h2 text: 'Responsive panel with 12 columns'
11
+ scroll.spacer height: 6
12
+ scroll.panels_responsive childViews: ->(horizontal) do
13
+ horizontal.panels_column lg: 8, backgroundColor: '#c3cad2', childViews: ->(column) do
14
+ column.button text: '1'
15
+ end
16
+ horizontal.panels_column lg: 4, backgroundColor: '#b3bac2', childViews: ->(column) do
17
+ column.button text: '2'
18
+ end
19
+ end
20
+
21
+ scroll.spacer height: 20
22
+ scroll.h2 text: 'Responsive panel with more than 12 columns'
23
+ scroll.spacer height: 6
24
+ scroll.panels_responsive childViews: ->(horizontal) do
25
+ horizontal.panels_column lg: 4, backgroundColor: '#c3cad2', childViews: ->(column) do
26
+ column.button text: '1'
27
+ end
28
+ horizontal.panels_column lg: 4, backgroundColor: '#b3bac2', childViews: ->(column) do
29
+ column.button text: '2'
30
+ end
31
+ horizontal.panels_column lg: 4, backgroundColor: '#c3cad2', childViews: ->(column) do
32
+ column.button text: '3'
33
+ end
34
+ horizontal.panels_column lg: 4, backgroundColor: '#b3bac2', childViews: ->(column) do
35
+ column.button text: '4'
36
+ end
37
+ horizontal.panels_column lg: 4, backgroundColor: '#c3cad2', childViews: ->(column) do
38
+ column.button text: '5'
39
+ end
40
+ end
41
+
42
+ end
43
+ end
@@ -3,7 +3,7 @@ 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: { top: 12, bottom: 12, left: 16, right: 16 }, childViews: ->(scroll) do
6
+ page.scroll padding: json_padding_body, childViews: ->(scroll) do
7
7
  scroll.h1 text: 'Vertical panel'
8
8
  scroll.panels_vertical backgroundColor: '#b3bac2', childViews: ->(panel) do
9
9
  panel.button text: 'Button1'
@@ -8,6 +8,11 @@ json_ui_page json do |page|
8
8
  scroll.spacer height: 6
9
9
  scroll.avatar url: json_image_avatar_url
10
10
 
11
+ scroll.spacer height: 20
12
+ scroll.h2 text: 'Icon'
13
+ scroll.spacer height: 6
14
+ scroll.icon name: 'info'
15
+
11
16
  scroll.spacer height: 20
12
17
  scroll.h2 text: 'Image with URL'
13
18
  scroll.spacer height: 6
@@ -21,7 +21,14 @@ json_ui_page json do |page|
21
21
  scroll.spacer height: 20
22
22
  scroll.h2 text: 'Button with link style'
23
23
  scroll.spacer height: 6
24
- scroll.button text: 'Link', styleClass: 'link', onClick: ->(action) do
24
+ scroll.button text: 'Styled Button', styleClass: 'link', onClick: ->(action) do
25
+ action.windows_open url: json_ui_garage_url(path: 'home/blank')
26
+ end
27
+
28
+ scroll.spacer height: 20
29
+ scroll.h2 text: 'Label with onClick URL'
30
+ scroll.spacer height: 6
31
+ scroll.label text: 'Clickable Link', onClick: ->(action) do
25
32
  action.windows_open url: json_ui_garage_url(path: 'home/blank')
26
33
  end
27
34
 
@@ -41,6 +48,13 @@ json_ui_page json do |page|
41
48
  action.windows_open url: json_ui_garage_url(path: 'home/blank')
42
49
  end
43
50
 
51
+ scroll.spacer height: 20
52
+ scroll.h2 text: 'Icon with onClick'
53
+ scroll.spacer height: 6
54
+ scroll.icon name: 'info', onClick: ->(action) do
55
+ action.windows_open url: json_ui_garage_url(path: 'home/blank')
56
+ end
57
+
44
58
  scroll.fab icon: 'add', onClick: ->(action) do
45
59
  action.windows_open url: json_ui_garage_url(path: 'home/blank')
46
60
  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: 0.2.11
4
+ version: 0.2.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
@@ -72,8 +72,7 @@ files:
72
72
  - app/views/json_ui/garage/home/index.json.jbuilder
73
73
  - app/views/json_ui/garage/lists/_infinite_scroll_section.json.jbuilder
74
74
  - app/views/json_ui/garage/lists/edit_actions.json.jbuilder
75
- - app/views/json_ui/garage/lists/fab1.json.jbuilder
76
- - app/views/json_ui/garage/lists/fab2.json.jbuilder
75
+ - app/views/json_ui/garage/lists/fab.json.jbuilder
77
76
  - app/views/json_ui/garage/lists/index.json.jbuilder
78
77
  - app/views/json_ui/garage/lists/infinite_scroll.json.jbuilder
79
78
  - app/views/json_ui/garage/lists/templating.json.jbuilder
@@ -87,6 +86,7 @@ files:
87
86
  - app/views/json_ui/garage/panels/custom.json.jbuilder
88
87
  - app/views/json_ui/garage/panels/horizontal.json.jbuilder
89
88
  - app/views/json_ui/garage/panels/index.json.jbuilder
89
+ - app/views/json_ui/garage/panels/responsive.json.jbuilder
90
90
  - app/views/json_ui/garage/panels/split.json.jbuilder
91
91
  - app/views/json_ui/garage/panels/table.json.jbuilder
92
92
  - app/views/json_ui/garage/panels/vertical.json.jbuilder
@@ -1,13 +0,0 @@
1
- json.title 'Lists'
2
-
3
- json_ui_page json do |page|
4
- render "#{@path_prefix}/nav_menu", json: json, page: page
5
-
6
- page.header childViews: ->(header) do
7
- header.fab icon: 'add', onClick: ->(action) { action.dialogs_alert message: 'Perform action' }
8
- end
9
-
10
- page.list firstSection: ->(section) do
11
- render 'json_ui/garage/lists/infinite_scroll_section', json: json, page: 0
12
- end
13
- end