glib-web 0.5.8 → 0.5.9

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: d3229621ccc977c76e4adc70e1ab7271a76daf08
4
- data.tar.gz: fa4e7c9f17a1d9c6b6cd770771730e13f583eb7e
3
+ metadata.gz: 8cb6ba9cc8312e05a50ed1179f7690b3dd985410
4
+ data.tar.gz: b896cd852f0f42fa7e5a198ff6d3a49f5fca037e
5
5
  SHA512:
6
- metadata.gz: 2c1cf1ee7207ee7fa8276d6e94df95a6079bc011f429a0d9ca87a1305e4bb7201da04d13cda66de0c5872e7e1604374065dd307144e8e8d3110fcae424d5ae9f
7
- data.tar.gz: '09fb824243fc37c0cd3ce3d6f0d0b6a85944ab02fa5b88383df8be9ff93394608fc1e0c394b9eadfa7fa51dbd854da3e8cf7ee4ed1da2895cfcdec06509a731e'
6
+ metadata.gz: b151098400b68a0eea5271b0d513be08a527fb091668d25769375215d6975d2c71f10268d2303125c156fdba610cf8d6a965b6ec8eb9d3c18a61c32f5fc528f6
7
+ data.tar.gz: 030e32c03a9d1b4ad9b4141406d367b60de018b6ce7738eab0080ef5327a9b2958b363d84a182663bcaae9df4fa4b8b66554af4cbcc61a738cebc1d7511be292
@@ -31,6 +31,13 @@ module Glib::Json::Ui
31
31
  @__json_ui_activated
32
32
  end
33
33
 
34
+ def json_ui_lifecycle_prop(name)
35
+ if (hash = json_transformation_start).is_a?(Hash)
36
+ hash[name] ||= { 'action' => 'runMultiple', 'childActions' => [] }
37
+ hash[name]['childActions']
38
+ end
39
+ end
40
+
34
41
  def __json_ui_start(options)
35
42
  @__json_ui_activated = false
36
43
  @__json_ui_rendering = nil
@@ -69,6 +69,12 @@ module Glib
69
69
 
70
70
  private
71
71
 
72
+ def self.any(propName)
73
+ define_method(propName) do |value|
74
+ json.set! propName, value
75
+ end
76
+ end
77
+
72
78
  def self.date(propName)
73
79
  define_method(propName) do |value|
74
80
  json.set! propName, value&.to_date
@@ -191,7 +197,7 @@ module Glib
191
197
  json.set!(propName) do
192
198
  if name
193
199
  data[:material] ||= {}
194
- data[:material][:name] = name
200
+ data[:material][:name] = name
195
201
  end
196
202
 
197
203
  if (material = data[:material])
@@ -1,8 +1,18 @@
1
1
  module Glib
2
2
  module JsonUi
3
3
  class ActionBuilder < AbstractBuilder
4
- def method_missing m, *args
5
- add_singleton_element_v1 'action', m, *args
4
+ def initialize(json, page, multiple)
5
+ super(json, page)
6
+
7
+ @multiple = multiple
8
+ end
9
+
10
+ def method_missing(m, *args)
11
+ if @multiple
12
+ add_element_to_array_v1 'action', m, *args
13
+ else
14
+ add_singleton_element_v1 'action', m, *args
15
+ end
6
16
  end
7
17
 
8
18
  class Action < JsonUiElement
@@ -38,19 +48,31 @@ module Glib
38
48
 
39
49
  ### Action definitions
40
50
 
51
+ class RunMultiple < Action
52
+ def childActions(block)
53
+ json.childActions do
54
+ block.call ActionBuilder.new(json, page, true)
55
+ end
56
+ end
57
+ end
58
+
41
59
  module Forms
42
60
  class Submit < Action
43
61
  end
44
-
45
62
  end
46
63
 
47
- # Consider deprecating this. See Data
48
64
  module Auth
49
65
  class SaveCsrfToken < Action
50
66
  string :token
51
67
  action :onSave
52
68
  end
69
+ end
53
70
 
71
+ module Analytics
72
+ class LogEvent < Action
73
+ string :name
74
+ hash :params
75
+ end
54
76
  end
55
77
 
56
78
  module Timeouts
@@ -59,6 +81,10 @@ module Glib
59
81
  action :onTimeout
60
82
  end
61
83
 
84
+ # FUTURE
85
+ class Remove < Action
86
+ end
87
+
62
88
  # FUTURE
63
89
  class Clear < Action
64
90
  end
@@ -66,11 +92,15 @@ module Glib
66
92
 
67
93
  # FUTURE
68
94
  module Data
69
- class SaveCsrfToken < Action
70
- string :token
95
+ class Save < Action
96
+ string :key
97
+ string :value
71
98
  action :onSave
72
99
  end
73
100
 
101
+ class Remove < Action
102
+ end
103
+
74
104
  class Clear < Action
75
105
  end
76
106
  end
@@ -35,11 +35,16 @@ module Glib
35
35
  # json.attributes!
36
36
  # end
37
37
 
38
- def json_ui_section(json, &block)
38
+ def json_ui_section(json)
39
39
  @__json_ui_section ||= Page.new(json, self)
40
40
  @__json_ui_section.list_section_builder
41
41
  end
42
42
 
43
+ def json_ui_action(json)
44
+ @__json_ui_section ||= Page.new(json, self)
45
+ @__json_ui_section.action_builder
46
+ end
47
+
43
48
  class Page
44
49
  attr_reader :json, :context, :view_builder, :action_builder, :menu_builder
45
50
  attr_reader :list_section_builder, :table_section_builder, :drawer_content_builder, :split_content_builder
@@ -52,7 +57,7 @@ module Glib
52
57
  @context = context
53
58
 
54
59
  @view_builder = ViewBuilder.new(json, self, true)
55
- @action_builder = ActionBuilder.new(json, self)
60
+ @action_builder = ActionBuilder.new(json, self, false)
56
61
  @menu_builder = MenuBuilder.new(json, self)
57
62
 
58
63
  @list_section_builder = ListBuilders::Section.new(json, self, ListBuilders::Template.new(json, self))
@@ -15,7 +15,7 @@ module Glib
15
15
  @json = json
16
16
  @context = context
17
17
 
18
- @action_builder = ActionBuilder.new(json, self)
18
+ @action_builder = ActionBuilder.new(json, self, false)
19
19
  end
20
20
  end
21
21
  end
@@ -103,8 +103,13 @@ class Glib::JsonUi::ViewBuilder
103
103
  end
104
104
 
105
105
  class Check < Text
106
- string :uncheckValue
107
- string :checkValue
106
+ any :uncheckValue
107
+ any :checkValue
108
+
109
+
110
+ def value(value)
111
+ @value = value if value != Glib::Value::DEFAULT
112
+ end
108
113
 
109
114
  # Where possible, use value instead of this
110
115
  bool :checked
@@ -3,7 +3,7 @@ json.title 'Forms'
3
3
  page = json_ui_page json
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: glib_json_padding_body, childViews: ->(form) do
6
+ page.form url: json_ui_garage_url(path: 'forms/generic_post'), method: 'post', padding: glib_json_padding_body, childViews: ->(form) do
7
7
  form.h1 text: 'Text'
8
8
  form.fields_password name: 'user[text1]', width: 'matchParent', label: 'Type "show"'
9
9
  form.label text: 'Typed', showIf: {
@@ -29,7 +29,7 @@ page.form url: json_ui_garage_url(path: 'forms/basic_post'), method: 'post', pad
29
29
 
30
30
  form.spacer height: 20
31
31
  form.h1 text: 'Check'
32
- form.fields_check name: 'user[check1]', value: 'on', label: 'Show text'
32
+ form.fields_check name: 'user[check1]', checkValue: 'on', label: 'Show text'
33
33
  form.spacer height: 10
34
34
  form.label text: 'Checked', showIf: {
35
35
  "==": [
@@ -70,7 +70,7 @@ page.form url: json_ui_garage_url(path: 'forms/basic_post'), method: 'post', pad
70
70
  }
71
71
 
72
72
  form.spacer height: 20
73
- form.h1 text: 'Combo1'
73
+ form.h1 text: 'Combined conditions'
74
74
  form.label text: 'Select the same option on both the radio and select fields above'
75
75
  form.spacer height: 10
76
76
  form.h3 text: 'Same!', showIf: {
@@ -84,5 +84,22 @@ page.form url: json_ui_garage_url(path: 'forms/basic_post'), method: 'post', pad
84
84
  ]
85
85
  }
86
86
 
87
+ form.spacer height: 20
88
+ form.h1 text: 'Show/hide another field'
89
+ form.label text: ''
90
+ form.spacer height: 10
91
+ form.fields_check name: 'user[check2]', checkValue: 'on', label: 'Show field'
92
+ form.spacer height: 10
93
+ form.fields_text width: 'matchParent', label: 'Comment (optional)', name: 'user[comment]', value: 'This field can be submitted when it is hidden, but it is not necessary (i.e. up to the app)', showIf: {
94
+ "==": [
95
+ {
96
+ "var": 'user[check2]'
97
+ },
98
+ 'on'
99
+ ]
100
+ }
101
+
102
+ form.spacer height: 20
103
+ form.fields_submit text: 'Submit'
87
104
  form.spacer height: 40
88
105
  end
@@ -7,7 +7,7 @@ json_ui_page json do |page|
7
7
  form.fields_email name: 'user[email]', width: 'matchParent', label: 'Email'
8
8
  form.fields_url name: 'user[url]', width: 'matchParent', label: 'URL'
9
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'
10
+ form.fields_password name: 'user[password]', width: 'matchParent', label: 'Password', hint: 'Should contain at least 6 characters'
11
11
  form.fields_textarea name: 'user[textarea]', width: 'matchParent', label: 'Textarea with maxLength', maxLength: 50, validation: { required: { message: 'Required' } }
12
12
 
13
13
  options = ['male', 'female'].map { |i| { text: i.humanize, value: i } }
@@ -31,7 +31,7 @@ module Glib
31
31
 
32
32
  include_params = case name
33
33
  when 'fields/check', 'fields/check-v1'
34
- child['checked']
34
+ child['checkValue'] == child['value']
35
35
  else
36
36
  true
37
37
  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.5.8
4
+ version: 0.5.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''