glib-web 0.15.4 → 0.16.0

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: 99bf3258f6448750d3db9022e35d80e45f67e8b7e60ce5aecccabc7d19906c58
4
- data.tar.gz: 0c51b914c22854ec4632dcc755a0fe55789f9a8ad4d40a4db722ecdd07e2e619
3
+ metadata.gz: 35210713e1cd16fb62b922a7b78f6c045a49d3eaa14e4a4adeb9630771c38059
4
+ data.tar.gz: a923627989ea43af99a03ad68ffb7f7784837eb4a4b3053304122eca5a8d1eac
5
5
  SHA512:
6
- metadata.gz: a310b5e78a79a69e85b91f56a0f7ed91caf37db79ff655607d890dad1b449613ec885394a418f01db3d535e209bff140de5ff103711b4e4a3bd0806f27701d7c
7
- data.tar.gz: da97a6021872ad5b623ef57d1969e82d3d692fb62cf965cf0bd460174f36a89fa10e974d11ed7dc2888894d5dd432b27845c3986efdb5a796ed88297cb970b95
6
+ metadata.gz: d57258dec4e72d2301cb8489139900a2e03e5177c073537db94cffa8dd9ef7dd69fba94434ee469f1762ade2845772eabdb2e89f1aa4cf8c9230c6cdb46087fe
7
+ data.tar.gz: d4e9622c9c1ad29f65b8b3d7505633845ffb003e910b498c4676c2ddf6cb9c14c9ebd8057325b0b031c2c7c0897e6ffea0c1ee8442fc0209ba2c671539dd891e
@@ -4,9 +4,9 @@ class Glib::JsonUi::ViewBuilder
4
4
  class AbstractField < View
5
5
  bool :readOnly
6
6
  hash :validation
7
- # bool :submitOnChange
8
7
  bool :disableDirtyCheck
9
8
  action :onChange
9
+ string :paramNameForFormData
10
10
 
11
11
  def label(label)
12
12
  @label = label
@@ -1,6 +1,11 @@
1
- panel.panels_form width: 'matchParent', childViews: ->(visibility) do
1
+ # display_key = local_assigns[:display_key] || :has_content
2
+ display_key = :has_content
3
+ @__banner_index ||= 0
4
+ toggle_name = "__banner_#{@__banner_index}"
5
+
6
+ panel.form_if_not_exists width: 'matchParent', childViews: ->(visibility) do
2
7
  state = {
3
- has_content: false
8
+ display_key => false
4
9
  }
5
10
  style_classes ||= nil
6
11
  style_class ||= nil
@@ -19,10 +24,12 @@ panel.panels_form width: 'matchParent', childViews: ->(visibility) do
19
24
  showIf: {
20
25
  "==": [
21
26
  {
22
- "var": 'banner'
27
+ "var": toggle_name
23
28
  },
24
29
  'show'
25
30
  ]
26
31
  }
27
- visibility.fields_hidden name: 'banner', value: state[:has_content] ? 'show' : 'hide'
32
+ visibility.fields_hidden name: toggle_name, value: state[display_key] ? 'show' : 'hide'
28
33
  end
34
+
35
+ @__banner_index += 1
@@ -1,14 +1,17 @@
1
1
  if text.length > min_chars
2
+ @__read_more_index ||= 0
3
+
2
4
  panel.form_if_not_exists childViews: ->(form) do
5
+ toggle_name = "__expand_#{@__read_more_index}"
3
6
  form.markdown \
4
7
  text: text.truncate(min_chars),
5
8
  styleClasses: ['line-clamp', "line-clamp-#{max_lines}"],
6
9
  showIf: {
7
10
  "!=": [
8
11
  {
9
- "var": 'expand'
12
+ "var": toggle_name
10
13
  },
11
- 'expand'
14
+ 'true'
12
15
  ]
13
16
  }
14
17
  form.markdown \
@@ -16,21 +19,25 @@ if text.length > min_chars
16
19
  showIf: {
17
20
  "==": [
18
21
  {
19
- "var": 'expand'
22
+ "var": toggle_name
20
23
  },
21
- 'expand'
24
+ 'true'
22
25
  ]
23
26
  }
27
+
28
+ # NOTE: Don't put a valueIf here in an attempt to implement accordions. It won't work due to circular updates, presumably between valueIf and the on/off icons and labels.
24
29
  form.fields_check \
25
30
  width: 'matchParent',
26
31
  offIcon: 'expand_more',
27
32
  onIcon: 'expand_less',
28
33
  label: 'Read more',
29
34
  onLabel: 'Read less',
30
- checkValue: 'expand',
35
+ checkValue: 'true',
31
36
  uncheckValue: nil,
32
- name: 'expand',
37
+ name: toggle_name,
33
38
  disableDirtyCheck: true
39
+
40
+ @__read_more_index += 1
34
41
  end
35
42
  else
36
43
  panel.markdown text: text
@@ -4,7 +4,6 @@ page = json_ui_page json
4
4
  render "#{@path_prefix}/nav_menu", json: json, page: page
5
5
 
6
6
  page.form url: json_ui_garage_url(path: 'forms/generic_post'), method: 'post', padding: glib_json_padding_body, childViews: ->(form) do
7
- # page.scroll childViews: ->(form) do
8
7
  form.h1 text: 'Text'
9
8
  form.fields_password name: 'user[text1]', width: 'matchParent', label: 'Type "show"', value: ''
10
9
  form.label text: 'Typed', showIf: {
@@ -136,7 +135,6 @@ page.form url: json_ui_garage_url(path: 'forms/generic_post'), method: 'post', p
136
135
 
137
136
  form.spacer height: 20
138
137
  form.h1 text: 'Show/hide another field'
139
- form.label text: ''
140
138
  form.spacer height: 10
141
139
  form.fields_check name: 'user[check3]', checkValue: 'on', label: 'Show field'
142
140
  form.spacer height: 10
@@ -151,7 +149,14 @@ page.form url: json_ui_garage_url(path: 'forms/generic_post'), method: 'post', p
151
149
 
152
150
  form.spacer height: 20
153
151
  form.h1 text: 'Show more/less text'
154
- form.label text: ''
152
+ form.spacer height: 10
153
+ render "#{@path_prefix}/forms/read_more_text",
154
+ panel: form,
155
+ min_chars: 300,
156
+ max_lines: 2,
157
+ text: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."
158
+
159
+ form.spacer height: 10
155
160
  render "#{@path_prefix}/forms/read_more_text",
156
161
  panel: form,
157
162
  min_chars: 300,
@@ -159,37 +164,30 @@ page.form url: json_ui_garage_url(path: 'forms/generic_post'), method: 'post', p
159
164
  text: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."
160
165
 
161
166
  form.spacer height: 20
162
- form.fields_submit text: 'Submit'
163
- form.spacer height: 40
164
- end
167
+ form.h1 text: 'Show/hide conditional banner'
168
+ form.spacer height: 10
169
+ form.label text: 'The following banner does not appear because its menu is empty'
170
+ form.spacer height: 8
171
+
172
+ render "#{@path_prefix}/forms/conditional_banner", panel: form, message: 'Admin menu 1' do |menu, state|
173
+ # This banner will not show because it does not have any content
174
+ # state[:has_content] = false
175
+ end
165
176
 
166
- # panel.panels_form width: 'matchParent', childViews: ->(visibility) do
167
- # state = {
168
- # has_content: false
169
- # }
170
- # style_classes ||= nil
171
- # style_class ||= nil
172
- # padding ||= nil
173
- # id ||= nil
174
-
175
- # visibility.banners_select \
176
- # id: id,
177
- # width: 'matchParent',
178
- # styleClass: style_class || (style_classes ? nil : 'warning'),
179
- # message: message,
180
- # padding: padding,
181
- # buttons: ->(menu) do
182
- # yield(menu, state)
183
- # end,
184
- # showIf: {
185
- # "==": [
186
- # {
187
- # "var": 'banner'
188
- # },
189
- # 'show'
190
- # ]
191
- # }
192
- # visibility.fields_hidden name: 'banner', value: state[:has_content] ? 'show' : 'hide'
193
- # end
177
+ form.spacer height: 10
178
+ form.label text: 'The following banner appears because it has at least one menu item'
179
+ form.spacer height: 8
180
+
181
+ render "#{@path_prefix}/forms/conditional_banner", panel: form, message: 'Admin menu 2' do |menu, state|
182
+ state[:has_content] = true
194
183
 
184
+ menu.button styleClass: 'link', text: 'Add', onClick: ->(action) do
185
+ action.dialogs_alert message: 'Do something'
186
+ end
187
+ end
195
188
 
189
+ form.spacer height: 20
190
+ form.fields_submit text: 'Submit'
191
+
192
+ form.spacer height: 40
193
+ end
@@ -79,12 +79,12 @@ page.scroll childViews: ->(scroll) do
79
79
  end
80
80
 
81
81
  form.spacer height: 20
82
- form.h2 text: 'Text (Asynchronous) -- TODO'
82
+ form.h2 text: 'Text (Asynchronous)'
83
83
  form.fields_text \
84
84
  name: 'user[video_url]',
85
85
  width: 'matchParent',
86
86
  onChange: ->(action) do
87
- action.http_post # TODO
87
+ action.http_post url: json_ui_garage_url(path: 'forms/generic_post')
88
88
  end
89
89
  end
90
90
 
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.15.4
4
+ version: 0.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''