glib-web 3.24.4 → 3.25.1

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: aba0dc03db2778a7a62e6222b3024ace73faa22c47d158a9088ed334db9515b0
4
- data.tar.gz: 2aa5ad7d865b21b3ae466aec5213af9553b118ac73db120a8def60aa624bee0a
3
+ metadata.gz: 838475dd1c241022699ae4cb206a3fac310be83932b8ec6d6094b61a9889d224
4
+ data.tar.gz: f24efaef3bf63350fb001bd461e3f73c47c0110b2d2b10bc53ef97258eea774a
5
5
  SHA512:
6
- metadata.gz: 2798441528eaab4548b034b65f79704daf77295ef8ed6751f2e1ea3f1719e9df12308d823fb251a0427d012e6bc5298bcbaf232ba47ada41128738bd8feee6a1
7
- data.tar.gz: c83bbb97e419a24350383d4a6ad3e83322a5a153f4da1437f028437aef50987721a494d58e9cf20ad5ae5efc356d757eb16112c2716bb82e931ce40063157290
6
+ metadata.gz: 8eaa39d50da3e146150414e1491d73170a1d833037bc623b50d46d83dfc111a762b67e7dc47825b7c3a89d6332c52a0e67f63c5de9049f7164e77f881658c753
7
+ data.tar.gz: '0940c9ba1f0beebf6088da4a42c1853defd8e67f8728c2ddf135e4c06168e39c0eec299f812e3e9601f1090aadf6b3295a6d265ca1309592325cc863dfa31440'
@@ -16,6 +16,12 @@ class Glib::JsonUi::ActionBuilder
16
16
  end
17
17
 
18
18
  # Experimental
19
+ class ReplaceChildren < Action
20
+ string :targetId
21
+ views :childViews
22
+ end
23
+
24
+ # Experimental. Can this be merged with `components_set` ?
19
25
  class Replace < Action
20
26
  string :targetId
21
27
  action :onReplace
@@ -109,6 +109,30 @@ module Glib
109
109
  end
110
110
  end
111
111
 
112
+ module Logics
113
+ # Future: Replace showIf and loadIf
114
+ # Example:
115
+ # `submitWhenNotDisplayed` is false by default
116
+ # fields_text id: 'my_text', displayed: false, submitWhenNotDisplayed: true
117
+ #
118
+ # logics_if condition: { '==', BLAH1, BLAH2 }, true: ->(action) do
119
+ # action.components_set targetId: 'my_text', displayed: true
120
+ # end
121
+ #
122
+ # class If < Action
123
+ # hash :condition
124
+ # action :true
125
+ # action :false
126
+ # end
127
+
128
+ class Set < Action
129
+ string :targetId
130
+ hash :conditionalData
131
+ hash :variables
132
+ action :onSet
133
+ end
134
+ end
135
+
112
136
  module Timeouts
113
137
  class Set < Action
114
138
  string :timerId
@@ -141,7 +165,24 @@ module Glib
141
165
  end
142
166
  end
143
167
 
168
+ module Cookies
169
+ class Save < Action
170
+ string :key
171
+ string :value
172
+ action :onSave
173
+ end
174
+
175
+ # FUTURE
176
+ # class Remove < Action
177
+ # end
178
+
179
+ # FUTURE
180
+ # class Clear < Action
181
+ # end
182
+ end
183
+
144
184
  # FUTURE
185
+
145
186
  module Data
146
187
  class Save < Action
147
188
  string :key
@@ -183,6 +183,12 @@ module Glib
183
183
  end
184
184
  end
185
185
 
186
+ def bodyFooter(options = {})
187
+ json.bodyFooter do
188
+ vertical_content(options)
189
+ end
190
+ end
191
+
186
192
  def header(options = {})
187
193
  json.header do
188
194
  vertical_content(options)
@@ -50,6 +50,17 @@ module Glib
50
50
 
51
51
  ###
52
52
 
53
+ ### Chart
54
+
55
+ def glib_chart_tooltip_template(options)
56
+ %{
57
+ <div style="border: 1px solid gray; border-radius: 6px;">
58
+ <div style="border-radius: 6px 6px 0 0; background-color: gray; padding: 4px; color: white;">#{options[:title]}</div>
59
+ <div style="border-radius: 0 0 6px 6px; background-color: white; padding: 4px" color: black;>#{options[:content]}</div>
60
+ </div>
61
+ }
62
+ end
63
+
53
64
  end
54
65
  end
55
66
  end
@@ -10,6 +10,7 @@ class Glib::JsonUi::ViewBuilder
10
10
  bool :disableDirtyCheck
11
11
  action :onChange
12
12
  string :paramNameForFormData
13
+ string :paramNameForFieldName
13
14
 
14
15
  def default_url_options
15
16
  { only_path: true }
@@ -172,6 +173,11 @@ class Glib::JsonUi::ViewBuilder
172
173
  string :cacheKey
173
174
  end
174
175
 
176
+ # Deprecated
177
+ # Just use fields_select with options provided by the backend. This allows greater flexibility,
178
+ # which is important because different systems might want to use different values for
179
+ # countries as well as for regions, e.g. alpha2 vs alpha3
180
+ # See app/views/json_ui/garage/forms/pickers.json.jbuilder for an example
175
181
  class Country < AbstractField
176
182
  hash :region
177
183
  end
@@ -0,0 +1,12 @@
1
+
2
+ section.header padding: glib_json_padding_list, childViews: ->(header) do
3
+ header.h3 id: 'cookie', text: 'Cookies'
4
+ end
5
+
6
+ section.rows builder: ->(template) do
7
+ template.thumbnail title: 'cookies/save', onClick: ->(action) do
8
+ action.cookies_save key: 'glib_cookie', value: "test_cookie_#{DateTime.current.to_i}", onSave: ->(subaction) do
9
+ subaction.snackbars_alert message: 'Saved'
10
+ end
11
+ end
12
+ end
@@ -23,5 +23,7 @@ panel.panels_list id: 'action_list', sections: [
23
23
  render "#{@path_prefix}/actions/components", section: section
24
24
  end, ->(section) do
25
25
  render "#{@path_prefix}/actions/fields", section: section
26
+ end, ->(section) do
27
+ render "#{@path_prefix}/actions/cookies", section: section
26
28
  end
27
29
  ]
@@ -81,9 +81,82 @@ page.form \
81
81
  form.spacer height: 20
82
82
  form.h2 text: 'Country'
83
83
  form.spacer height: 6
84
- region_field = { name: 'user[city]', label: 'City' }
85
- form.fields_country name: 'user[country]', width: 'matchParent', label: 'Country', region: nil
86
- form.fields_country name: 'user[country_with_region]', width: 'matchParent', label: 'Country with region', region: region_field
84
+ # region_field = { name: 'user[city]', label: 'City' }
85
+ # form.fields_country name: 'user[country]', width: 'matchParent', label: 'Country', region: nil
86
+ # form.fields_country name: 'user[country_with_region]', width: 'matchParent', label: 'Country with region', region: region_field
87
+
88
+ countries = [
89
+ {
90
+ code: 'AU',
91
+ name: 'Australia',
92
+ regions: ['ACT', 'New South Wales', 'Victoria', 'Western Australia']
93
+ },
94
+ {
95
+ code: 'ID',
96
+ name: 'Indonesia',
97
+ regions: ['Jawa Barat', 'Java Tengah', 'Jawa Timur', 'Sumatra Utara', 'Sumatra Barat', 'Sumatra Selatan']
98
+ }
99
+ ]
100
+ region_registry = countries.map do |c|
101
+ [c[:code], c[:regions].map { |r| { value: r, text: r } } ]
102
+ end.to_h
103
+ form.fields_select \
104
+ name: 'user[country1]',
105
+ width: 'matchParent',
106
+ label: 'Country',
107
+ options: countries.map { |c| { value: c[:code], text: c[:name] } },
108
+ paramNameForFormData: 'variables',
109
+ onChange: ->(action) do
110
+ action.logics_set targetId: 'region_code1', conditionalData: {
111
+ options: {
112
+ '[]' => [{ 'var': 'static[region_registry]' }, { 'var': 'user[country1]' }]
113
+ }
114
+ }, variables: {
115
+ 'static[region_registry]' => region_registry
116
+ }
117
+ end
118
+
119
+ form.fields_select \
120
+ name: 'user[region1]',
121
+ width: 'matchParent',
122
+ label: 'Region',
123
+ id: 'region_code1',
124
+ options: []
125
+
126
+ form.spacer height: 20
127
+
128
+ selected_country = 'AU'
129
+ form.fields_select \
130
+ name: 'user[country2]',
131
+ width: 'matchParent',
132
+ label: 'Country',
133
+ options: countries.map { |c| { value: c[:code], text: c[:name] } },
134
+ paramNameForFormData: 'variables',
135
+ value: selected_country,
136
+ onChange: ->(action) do
137
+ action.logics_set targetId: 'region_code2', conditionalData: {
138
+ options: {
139
+ '??' => [
140
+ {
141
+ '[]' => [{ 'var': 'static[region_registry]' }, { 'var': 'user[country2]' }]
142
+ },
143
+ []
144
+ ]
145
+ },
146
+ value: nil
147
+ }, variables: {
148
+ 'static[region_registry]' => region_registry
149
+ }
150
+ end
151
+
152
+ form.fields_select \
153
+ name: 'user[region2]',
154
+ width: 'matchParent',
155
+ label: 'Region',
156
+ id: 'region_code2',
157
+ value: 'Victoria',
158
+ options: region_registry[selected_country]
159
+ form.label text: 'This select options should not be blank'
87
160
 
88
161
  form.spacer height: 20
89
162
  form.h2 text: 'Map'
@@ -70,8 +70,12 @@ page.form url: json_ui_garage_url(path: 'forms/generic_post'), method: 'post', p
70
70
  accessory.header padding: { x: 16, y: 10 }, childViews: ->(header) do
71
71
  header.label text: 'Header'
72
72
  end
73
- accessory.footer padding: { x: 16, y: 10 }, childViews: ->(footer) do
74
- footer.label text: 'Footer'
73
+ accessory.footer styleClass: 'select-footer', padding: { x: 16, y: 10 }, childViews: ->(footer) do
74
+ footer.h3 text: 'Footer'
75
+ # footer.spacer height: 4
76
+ footer.p styleClass: 'select-footer-paragraph', text: %(
77
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Tortor consequat id porta nibh venenatis cras sed. Amet consectetur adipiscing elit duis tristique sollicitudin nibh. Proin sagittis nisl rhoncus mattis rhoncus urna neque viverra justo. Velit egestas dui id ornare arcu odio. Pretium nibh ipsum consequat nisl vel pretium. Bibendum at varius vel pharetra. Leo duis ut diam quam nulla porttitor massa id. Consectetur libero id faucibus nisl tincidunt eget nullam non. Eu facilisis sed odio morbi quis. Eu volutpat odio facilisis mauris sit amet massa vitae tortor. Sed odio morbi quis commodo odio aenean sed. Sit amet justo donec enim diam. Ullamcorper a lacus vestibulum sed arcu non odio euismod.
78
+ )
75
79
  footer.spacer height: 14
76
80
  footer.label text: 'Click me', onClick: ->(action) do
77
81
  action.components_findClosest view: 'fields/select', onFind: ->(subaction) do
@@ -61,6 +61,32 @@ else
61
61
  # scroll.h1 text: 'Line chart using remote data'
62
62
  # render "#{@path_prefix}/views/chart_data", json: json, builder: scroll
63
63
 
64
+ scroll.h2 text: 'Line chart with custom tooltip'
65
+ scroll.charts_line \
66
+ plugins: { customTooltip: true },
67
+ colors: ['#79AC78', '#3085C3'], legend: { display: false },
68
+ dataSeries: [
69
+ -> do
70
+ json.title 'Line'
71
+
72
+ points = {
73
+ 'Jan' => 100,
74
+ 'Feb' => 78,
75
+ 'Mar' => 70,
76
+ 'Apr' => 62,
77
+ }
78
+ prev = points['Jan']
79
+
80
+
81
+ json.points points.map { |k, v|
82
+ delta = prev - v
83
+ tooltip = v < prev ? "<div>Delta</div><div>▼ #{delta}</div>" : "<div>Delta</div><div>▲ #{delta}</div>"
84
+ prev = v
85
+ { x: k, y: v, tooltip: glib_chart_tooltip_template(title: "Summary #{k}", content: tooltip) }
86
+ }
87
+ end
88
+ ]
89
+
64
90
  scroll.h2 text: 'Column chart (Clustered)'
65
91
  scroll.charts_column dataGroups: [
66
92
  -> do
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: 3.24.4
4
+ version: 3.25.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
@@ -140,6 +140,7 @@ files:
140
140
  - app/views/json_ui/garage/_nav_menu.json.jbuilder
141
141
  - app/views/json_ui/garage/actions/_commands.json.jbuilder
142
142
  - app/views/json_ui/garage/actions/_components.json.jbuilder
143
+ - app/views/json_ui/garage/actions/_cookies.json.jbuilder
143
144
  - app/views/json_ui/garage/actions/_dialogs.json.jbuilder
144
145
  - app/views/json_ui/garage/actions/_dialogs_show.json.jbuilder
145
146
  - app/views/json_ui/garage/actions/_fields.json.jbuilder