glib-web 0.5.40 → 0.5.45

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: 8b928a561f073b490adf1ea7cd8f5bfbf0da713c3cb580bc70384ea6c21579af
4
- data.tar.gz: fe3fc8437847278266fd2d50cb0fb0501305a582e76f8d4696979d3375559d48
3
+ metadata.gz: b863f20666907aa007728759d473d1e8dad478ba7efffcb66aa94fb898536a35
4
+ data.tar.gz: 21e14417f6a72d74e58a8e5ee1ebce72d2a21c11c6e5ba4fb363b7a6820f4c0b
5
5
  SHA512:
6
- metadata.gz: 39a4149930f9ce32a68a91fae80a6589d9829f6efffc3d62578750258cd54163e5cc05115ad476276cd0a4992f190c25626d578813d827aac2936b4054ee127e
7
- data.tar.gz: d890dec1c65fb22290234d16d88597fe39d54700009ce6d55f96cb69823167f01dc4fabc709828712a52e5e2a9165c01dbc7df29761f1dbfb095566a03679c66
6
+ metadata.gz: 15f888278858a1e6b8ebdc9944c6abcf07e4b0746dc91ffd3694be98552026a43a664e9da8c8fb63c45c8eb31f6506c487f40b98de5c92bca3679b341612ae8d
7
+ data.tar.gz: 3e2bdb8dbfeddacccbe3269bfe9973bd65cb398faa25207d315d1970b951647a1854d415db4004fd6485d335186ca1286b30c2397c588ae5d0104447b0e8fe42
@@ -48,10 +48,15 @@ module Glib
48
48
  end
49
49
 
50
50
  def json_ui_action(json)
51
- @__json_ui_section ||= Page.new(json, self)
52
- @__json_ui_section.action_builder
51
+ @__json_ui_action ||= Page.new(json, self)
52
+ @__json_ui_action.action_builder
53
53
  end
54
54
 
55
+ # def json_ui_view(json)
56
+ # @__json_ui_view ||= Page.new(json, self)
57
+ # @__json_ui_view.view_builder
58
+ # end
59
+
55
60
  def json_ui_action_payload(&block)
56
61
  dataJson = Jbuilder.new
57
62
  block&.call Page.new(dataJson, self).action_builder
@@ -148,6 +148,7 @@ module Glib
148
148
  end
149
149
 
150
150
  class Hr < View
151
+ color :color
151
152
  end
152
153
 
153
154
  class Spacer < View
@@ -4,6 +4,7 @@ class Glib::JsonUi::ViewBuilder
4
4
  class AbstractField < View
5
5
  bool :readOnly
6
6
  hash :validation
7
+ # string :label
7
8
 
8
9
  def label(label)
9
10
  @label = label
@@ -39,16 +40,13 @@ class Glib::JsonUi::ViewBuilder
39
40
 
40
41
  def prop(prop)
41
42
  @prop = prop
42
- # if (form = page.current_form)
43
- # @name ||= form.field_name(prop)
44
- # @value ||= form.field_value(prop)
45
- # end
46
-
47
43
  end
48
44
 
49
45
  # Override
50
46
  def created
51
47
  if @prop && (form = page.current_form)
48
+ form.field_assert_respond_to(@prop)
49
+
52
50
  @name ||= form.field_name(@prop, @multiple || false)
53
51
  @value ||= form.field_value(@prop)
54
52
  @label ||= form.field_label(@prop, @label_args || {})
@@ -56,7 +54,6 @@ class Glib::JsonUi::ViewBuilder
56
54
  @placeholder ||= form.placeholder_label(@prop, @placeholder_args || {})
57
55
 
58
56
  @validation ||= form.field_validation(@prop)
59
-
60
57
  end
61
58
  json.name @name
62
59
  json.value @value if @value
@@ -68,13 +65,15 @@ class Glib::JsonUi::ViewBuilder
68
65
  # - Placeholder competes with label for space
69
66
  json.placeholder @placeholder if @placeholder
70
67
 
71
- json.validation @validation if @validation
68
+ # TODO: Add a flag so the framework's user can turn it on and off.
69
+ # json.validation @validation if @validation
72
70
  end
73
71
 
74
72
  end
75
73
 
76
74
  class Text < AbstractField
77
75
  int :maxLength
76
+ icon :leftIcon
78
77
  end
79
78
 
80
79
  class Number < Text
@@ -16,6 +16,11 @@ class Glib::JsonUi::ViewBuilder
16
16
  @model.class.try(:reflect_on_association, prop)&.macro == :has_many
17
17
  end
18
18
 
19
+ def field_assert_respond_to(prop)
20
+ # Identify a prop being used on a nil model or incorrect model.
21
+ raise "Invalid property `#{prop}` on '#{@model.class}'" unless @model.respond_to?(prop)
22
+ end
23
+
19
24
  def field_name(prop, multiple)
20
25
  suffix = is_array_association?(prop) || multiple ? '[]' : ''
21
26
  "#{@model_name}[#{prop}]#{suffix}"
@@ -88,7 +93,7 @@ class Glib::JsonUi::ViewBuilder
88
93
  json.childViews do
89
94
  if @method != :get
90
95
  json.child! do
91
- json.view 'fields/hidden-v1'
96
+ json.view 'fields/hidden'
92
97
  json.name 'authenticity_token'
93
98
  json.value page.context.form_authenticity_token
94
99
  end
@@ -1,23 +1,22 @@
1
1
  json.title 'Actions'
2
2
 
3
- json_ui_page json do |page|
4
- render "#{@path_prefix}/nav_menu", json: json, page: page, top_nav: true
3
+ page = json_ui_page json
4
+ render "#{@path_prefix}/nav_menu", json: json, page: page, top_nav: true
5
5
 
6
- page.list sections: [
7
- ->(section) do
8
- render "#{@path_prefix}/actions/reload", section: section
9
- end, ->(section) do
10
- render "#{@path_prefix}/actions/dialogs", section: section
11
- end, ->(section) do
12
- render "#{@path_prefix}/actions/snackbars", section: section
13
- end, ->(section) do
14
- render "#{@path_prefix}/actions/sheets", section: section
15
- end, ->(section) do
16
- render "#{@path_prefix}/actions/windows", section: section
17
- end, ->(section) do
18
- render "#{@path_prefix}/actions/timeouts", section: section
19
- end, ->(section) do
20
- render "#{@path_prefix}/actions/http", section: section
21
- end
22
- ]
23
- end
6
+ page.list sections: [
7
+ ->(section) do
8
+ render "#{@path_prefix}/actions/reload", section: section
9
+ end, ->(section) do
10
+ render "#{@path_prefix}/actions/dialogs", section: section
11
+ end, ->(section) do
12
+ render "#{@path_prefix}/actions/snackbars", section: section
13
+ end, ->(section) do
14
+ render "#{@path_prefix}/actions/sheets", section: section
15
+ end, ->(section) do
16
+ render "#{@path_prefix}/actions/windows", section: section
17
+ end, ->(section) do
18
+ render "#{@path_prefix}/actions/timeouts", section: section
19
+ end, ->(section) do
20
+ render "#{@path_prefix}/actions/http", section: section
21
+ end
22
+ ]
@@ -1,22 +1,21 @@
1
1
  json.title 'Forms'
2
2
 
3
- json_ui_page json do |page|
4
- render "#{@path_prefix}/nav_menu", json: json, page: page
3
+ page = json_ui_page json
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: glib_json_padding_body, childViews: ->(form) do
7
- form.fields_text name: 'user[name]', width: 'matchParent', label: 'Name'
8
- form.fields_password name: 'user[password]', width: 'matchParent', label: 'Password'
6
+ page.form url: json_ui_garage_url(path: 'forms/basic_post'), method: 'post', padding: glib_json_padding_body, childViews: ->(form) do
7
+ form.fields_text name: 'user[name]', width: 'matchParent', label: 'Name'
8
+ form.fields_password name: 'user[password]', width: 'matchParent', label: 'Password'
9
9
 
10
- form.panels_split width: 'matchParent', content: ->(split) do
11
- split.left childViews: ->(left) do
12
- if params[:mode] == 'dialog'
13
- left.button styleClass: 'link', text: 'cancel', onClick: ->(action) { action.dialogs_close }
14
- end
15
- end
16
- split.right childViews: ->(right) do
17
- # right.button text: 'Submit', onClick: ->(action) { action.forms_submit }
18
- right.fields_submit text: 'Submit'
10
+ form.panels_split width: 'matchParent', content: ->(split) do
11
+ split.left childViews: ->(left) do
12
+ if params[:mode] == 'dialog'
13
+ left.button styleClass: 'link', text: 'cancel', onClick: ->(action) { action.dialogs_close }
19
14
  end
20
15
  end
16
+ split.right childViews: ->(right) do
17
+ # right.button text: 'Submit', onClick: ->(action) { action.forms_submit }
18
+ right.fields_submit text: 'Submit'
19
+ end
21
20
  end
22
21
  end
@@ -1,44 +1,43 @@
1
1
  json.title 'Forms'
2
2
 
3
- json_ui_page json do |page|
4
- render "#{@path_prefix}/nav_menu", json: json, page: page
5
-
6
- page.scroll childViews: ->(scroll) do
3
+ page = json_ui_page json
4
+ render "#{@path_prefix}/nav_menu", json: json, page: page
7
5
 
8
- scroll.panels_form url: json_ui_garage_url(path: 'forms/generic_post'), method: 'post', padding: glib_json_padding_body, childViews: ->(form) do
9
- form.spacer height: 20
10
- form.h2 text: 'Check Group'
11
- form.fields_checkGroup name: 'user[skills][]', uncheckValue: 1, childViews: ->(group) do
12
- form.fields_check value: 2, label: 'Game Development'
13
- form.fields_check value: 3, label: 'Web Development'
14
- form.fields_check value: 4, label: 'Mobile Development'
15
- end
6
+ page.scroll childViews: ->(scroll) do
7
+
8
+ scroll.panels_form url: json_ui_garage_url(path: 'forms/generic_post'), method: 'post', padding: glib_json_padding_body, childViews: ->(form) do
9
+ form.spacer height: 20
10
+ form.h2 text: 'Check Group'
11
+ form.fields_checkGroup name: 'user[skills][]', uncheckValue: 1, childViews: ->(group) do
12
+ form.fields_check value: 2, label: 'Game Development'
13
+ form.fields_check value: 3, label: 'Web Development'
14
+ form.fields_check value: 4, label: 'Mobile Development'
15
+ end
16
16
 
17
- form.spacer height: 20
18
- form.h2 text: 'Rating'
19
- form.spacer height: 6
20
- form.fields_radioGroup name: 'user[rating1][]', iconOfSelected: 'star', iconOfBeforeSelected: 'star', iconOfAfterSelected: 'star_border', childViews: ->(panel) do
21
- panel.panels_horizontal childViews: ->(panel) do
22
- panel.fields_radio value: 1
23
- panel.fields_radio value: 2
24
- panel.fields_radio value: 3
25
- panel.fields_radio value: 4
26
- panel.fields_radio value: 5
27
- end
17
+ form.spacer height: 20
18
+ form.h2 text: 'Rating'
19
+ form.spacer height: 6
20
+ form.fields_radioGroup name: 'user[rating1][]', iconOfSelected: 'star', iconOfBeforeSelected: 'star', iconOfAfterSelected: 'star_border', childViews: ->(panel) do
21
+ panel.panels_horizontal childViews: ->(panel) do
22
+ panel.fields_radio value: 1
23
+ panel.fields_radio value: 2
24
+ panel.fields_radio value: 3
25
+ panel.fields_radio value: 4
26
+ panel.fields_radio value: 5
28
27
  end
29
- form.fields_radioGroup name: 'user[rating2][]', iconOfSelected: 'star', iconOfBeforeSelected: 'star', iconOfAfterSelected: 'star_border', value: 1, childViews: ->(panel) do
30
- panel.panels_horizontal childViews: ->(panel) do
31
- panel.fields_radio value: 1
32
- panel.fields_radio value: 2
33
- panel.fields_radio value: 3
34
- panel.fields_radio value: 4
35
- panel.fields_radio value: 5
36
- end
28
+ end
29
+ form.fields_radioGroup name: 'user[rating2][]', iconOfSelected: 'star', iconOfBeforeSelected: 'star', iconOfAfterSelected: 'star_border', value: 1, childViews: ->(panel) do
30
+ panel.panels_horizontal childViews: ->(panel) do
31
+ panel.fields_radio value: 1
32
+ panel.fields_radio value: 2
33
+ panel.fields_radio value: 3
34
+ panel.fields_radio value: 4
35
+ panel.fields_radio value: 5
37
36
  end
38
-
39
- form.spacer height: 20
40
- form.button text: 'Submit', onClick: ->(action) { action.forms_submit }
41
37
  end
42
-
38
+
39
+ form.spacer height: 20
40
+ form.button text: 'Submit', onClick: ->(action) { action.forms_submit }
43
41
  end
42
+
44
43
  end
@@ -1,22 +1,57 @@
1
1
  json.title 'Forms'
2
2
 
3
- json_ui_page json do |page|
4
- render "#{@path_prefix}/nav_menu", json: json, page: page
3
+ page = json_ui_page json
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: glib_json_padding_body, childViews: ->(form) do
7
- form.fields_email name: 'user[email]', width: 'matchParent', label: 'Email'
8
- form.fields_url name: 'user[url]', width: 'matchParent', label: 'URL'
9
- form.fields_number name: 'user[number]', width: 'matchParent', label: 'Number', validation: { required: { message: 'Required' } }
10
- form.fields_password name: 'user[password]', width: 'matchParent', label: 'Password', hint: 'Should contain at least 6 characters'
11
- form.fields_textarea name: 'user[textarea]', width: 'matchParent', label: 'Textarea with maxLength', maxLength: 50, validation: { required: { message: 'Required' } }
6
+ page.form \
7
+ url: json_ui_garage_url(path: 'forms/generic_post'),
8
+ method: 'post',
9
+ padding: glib_json_padding_body,
10
+ childViews: ->(form) do
11
+ form.fields_email \
12
+ name: 'user[email]',
13
+ width: 'matchParent',
14
+ label: 'Email'
15
+
16
+ form.fields_url \
17
+ name: 'user[url]',
18
+ width: 'matchParent',
19
+ label: 'URL'
20
+
21
+ form.fields_number \
22
+ name: 'user[number]',
23
+ width: 'matchParent',
24
+ label: 'Number',
25
+ validation: { required: { message: 'Required' } },
26
+ leftIcon: 'attach_money'
27
+
28
+ form.fields_password \
29
+ name: 'user[password]',
30
+ width: 'matchParent',
31
+ label: 'Password',
32
+ hint: 'Should contain at least 6 characters'
33
+
34
+ form.fields_textarea \
35
+ name: 'user[textarea]',
36
+ width: 'matchParent',
37
+ label: 'Textarea with maxLength',
38
+ maxLength: 50,
39
+ validation: { required: { message: 'Required' } }
12
40
 
13
41
  options = ['male', 'female'].map { |i| { text: i.humanize, value: i } }
14
- form.fields_select name: 'user[gender]', width: 'matchParent', label: 'Gender', validation: { required: { message: 'Required' } }, options: options
42
+ form.fields_select \
43
+ name: 'user[gender]',
44
+ width: 'matchParent',
45
+ label: 'Gender',
46
+ validation: { required: { message: 'Required' } },
47
+ options: options
15
48
 
16
49
  form.spacer height: 20
17
- form.fields_stripeToken name: 'user[stripe_token]', width: 'matchParent', publicKey: 'pk_test_TYooMQauvdEDq54NiTphI7jx'
50
+ form.fields_stripeToken \
51
+ name: 'user[stripe_token]',
52
+ width: 'matchParent',
53
+ publicKey: 'pk_test_TYooMQauvdEDq54NiTphI7jx'
18
54
 
19
55
  form.spacer height: 30
20
56
  form.fields_submit text: 'Submit'
21
57
  end
22
- end
@@ -24,12 +24,15 @@ json.pins do
24
24
  { lat: -42.734358, lng: 147.501315 },
25
25
  { lat: -42.735258, lng: 147.438 },
26
26
  { lat: -43.999792, lng: 170.463352 },
27
+ { lat: 49.003109, lng: 108.490479, size: 3500000 },
28
+ { lat: -6.611423, lng: 141.922091, size: 3700 },
27
29
  ];
28
30
 
29
31
  locations.each do |location|
30
32
  json.child! do
31
33
  json.latitude location[:lat]
32
34
  json.longitude location[:lng]
35
+ json.clusterSize location[:size]
33
36
  json.infoWindow do
34
37
  json.title "TEST #{rand(1000)}"
35
38
  end
@@ -1,6 +1,7 @@
1
1
 
2
- json.pins do
2
+ page = json_ui_page json
3
3
 
4
+ json.pins do
4
5
  latitude = params[:lat]&.to_f
5
6
  longitude = params[:long]&.to_f
6
7
 
@@ -37,7 +38,14 @@ json.pins do
37
38
  json.infoWindow do
38
39
  json.title 'You'
39
40
  json.subtitle 'Current location'
40
- json.subsubtitle "#{latitude}, #{longitude}"
41
+
42
+ json.body do
43
+ page.vertical_content padding: { top: 10 }, childViews: ->(body) do
44
+ body.button text: 'Info', onClick: ->(action) do
45
+ action.dialogs_alert message: "#{latitude}, #{longitude}"
46
+ end
47
+ end
48
+ end
41
49
  end
42
50
  end
43
51
  end
File without changes
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.5.40
4
+ version: 0.5.45
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''