glib-web 3.28.0 → 4.1.0

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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/concerns/glib/json/libs.rb +4 -4
  3. data/app/helpers/glib/json_ui/abstract_builder.rb +0 -8
  4. data/app/helpers/glib/json_ui/action_builder/components.rb +0 -5
  5. data/app/helpers/glib/json_ui/action_builder/dialogs.rb +0 -23
  6. data/app/helpers/glib/json_ui/action_builder/logics.rb +11 -0
  7. data/app/helpers/glib/json_ui/action_builder/popovers.rb +0 -9
  8. data/app/helpers/glib/json_ui/action_builder/windows.rb +1 -5
  9. data/app/helpers/glib/json_ui/action_builder.rb +0 -24
  10. data/app/helpers/glib/json_ui/builder/mouse_events.rb +0 -7
  11. data/app/helpers/glib/json_ui/default.rb +4 -4
  12. data/app/helpers/glib/json_ui/list_builders.rb +0 -3
  13. data/app/helpers/glib/json_ui/page_helper.rb +7 -1
  14. data/app/helpers/glib/json_ui/view_builder/fields.rb +7 -38
  15. data/app/helpers/glib/json_ui/view_builder/panels.rb +1 -0
  16. data/app/helpers/glib/json_ui/view_builder.rb +3 -14
  17. data/app/policies/glib/application_policy.rb +0 -6
  18. data/app/views/json_ui/garage/actions/_components.json.jbuilder +2 -6
  19. data/app/views/json_ui/garage/actions/_dialogs.json.jbuilder +0 -14
  20. data/app/views/json_ui/garage/actions/_reload.json.jbuilder +1 -1
  21. data/app/views/json_ui/garage/actions/partial_update.json.jbuilder +1 -1
  22. data/app/views/json_ui/garage/forms/_alert_post_data.json.jbuilder +1 -3
  23. data/app/views/json_ui/garage/forms/_partial_update_execute.json.jbuilder +1 -1
  24. data/app/views/json_ui/garage/forms/_read_more_text.json.jbuilder +27 -20
  25. data/app/views/json_ui/garage/forms/conditional_value.json.jbuilder +49 -68
  26. data/app/views/json_ui/garage/forms/dirty_prompt.json.jbuilder +0 -28
  27. data/app/views/json_ui/garage/forms/file_upload.json.jbuilder +1 -3
  28. data/app/views/json_ui/garage/forms/otp_field.json.jbuilder +11 -9
  29. data/app/views/json_ui/garage/forms/rich_text_preview.json.jbuilder +0 -1
  30. data/app/views/json_ui/garage/forms/selects.json.jbuilder +17 -24
  31. data/app/views/json_ui/garage/forms/show_hide.json.jbuilder +317 -271
  32. data/app/views/json_ui/garage/forms/timers.json.jbuilder +0 -90
  33. data/app/views/json_ui/garage/notifications/action_cable.json.jbuilder +3 -3
  34. data/app/views/json_ui/garage/pages/lifecycle_hooks.json.jbuilder +4 -0
  35. data/app/views/json_ui/garage/views/{components_update.json.jbuilder → components_replace.json.jbuilder} +6 -6
  36. data/app/views/json_ui/garage/views/controls.json.jbuilder +0 -32
  37. data/lib/glib/test_helpers.rb +2 -0
  38. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 575e99be2d5c58f1f7c9422f254b6a4b5b24180c82b38496e84c8dec22c41bcc
4
- data.tar.gz: 76e6c254672deb1e9cd34a9452978ef4c9c32fc276fb8ac3e1e6eec1cbe8df85
3
+ metadata.gz: 075c1d55a3db9efb8b8fd9302c410203f54f3feaf13e9debb3273fab7facf009
4
+ data.tar.gz: c9f19882259bb4e898578994734ece1c472a63b0dfffd7b41cb9fa8a3f89d1bb
5
5
  SHA512:
6
- metadata.gz: a32237713616d6611d7cc6e57f57d81e7ff02823a68ed1d633e5de7276d4894ce67f30ff1766bda40df3bde0d53a9d69db2c677b740b266ae040e98f91c72a0b
7
- data.tar.gz: 5fb068a0f809fc0ab4245fcbf1116758c253b04629a378fe8bd262486dc18d55490ac1cd854e0b4c1494a98cc4414abb108eb7f60baf1a84752565f66b7049ff
6
+ metadata.gz: 7c07ee59726cdf85c3cedf5970097fff38916c1e56d062332f61d7fd2692ebf316d9eacb32c9d6e4a65bedec4af28f66ceddf86fe95c84d0fba87ec215250ca6
7
+ data.tar.gz: 70d5e728d9730c9b0f2d63d9d34bea15654d8d8048eba682f114ec29c937020c1e058d205d523837a63ea54fa3ef878de498cd310cf1d96e52b435d7ded18109
@@ -74,7 +74,7 @@ module Glib::Json::Libs
74
74
  url.sub(/[\&\?]format=json/, '');
75
75
  end
76
76
 
77
- def glib_redirect_to(url, return_to_previous: false)
77
+ def glib_redirect_to(url, return_to_previous: false, status: :ok)
78
78
  url = __delete_redirect_back_url(url) if return_to_previous
79
79
 
80
80
  respond_to do |format|
@@ -87,7 +87,7 @@ module Glib::Json::Libs
87
87
  return
88
88
  end
89
89
 
90
- json_ui_redirect_to url
90
+ json_ui_redirect_to url, status: status
91
91
  end
92
92
  end
93
93
  end
@@ -235,7 +235,7 @@ module Glib::Json::Libs
235
235
  end
236
236
  end
237
237
 
238
- def json_ui_redirect_to(url)
238
+ def json_ui_redirect_to(url, status: :ok)
239
239
  # Use windows_reload instead of windows_open so clicking back will skip the bridging page.
240
240
  # on_response = { action: 'windows/open', url: url }
241
241
  on_response = { action: 'windows/reload', url: url }
@@ -248,7 +248,7 @@ module Glib::Json::Libs
248
248
 
249
249
  # Use onResponse because it is harder to guarantee that `onLoad` executes in Vuejs because it relies
250
250
  # on app.vue's reactivity.
251
- render json: { onResponse: on_response }
251
+ render json: { onResponse: on_response }, status: status
252
252
  end
253
253
 
254
254
  module ClassMethods
@@ -202,14 +202,6 @@ module Glib
202
202
  else
203
203
  data = {}
204
204
  name = value
205
- # data = { material: { name: value } }
206
-
207
- # name = value
208
-
209
- # TODO: deprecated
210
- # json.set!(propName) do
211
- # json.name name
212
- # end
213
205
  end
214
206
 
215
207
  json.set!(propName) do
@@ -10,11 +10,6 @@ class Glib::JsonUi::ActionBuilder
10
10
  action :onFind
11
11
  end
12
12
 
13
- class Update < Action
14
- string :targetId
15
- views :views
16
- end
17
-
18
13
  # Experimental
19
14
  class ReplaceChildren < Action
20
15
  string :targetId
@@ -7,26 +7,9 @@ class Glib::JsonUi::ActionBuilder
7
7
  action :onClose
8
8
  end
9
9
 
10
- # class Show < Action
11
- # string :body
12
- # action :onLoad
13
- # action :onClose
14
- # end
15
-
16
- # Deprecated in favour of `sheets/select`
17
- class Options < Action
18
- string :message
19
-
20
- def buttons(block)
21
- json.buttons do
22
- block.call page.menu_builder
23
- end
24
- end
25
- end
26
10
 
27
11
  class Show < Action
28
12
  panels_builder :content, :body
29
- bool :showClose # deprecated
30
13
  bool :disableCloseButton
31
14
  string :fullscreen # mobile, always
32
15
  length :width
@@ -45,7 +28,6 @@ class Glib::JsonUi::ActionBuilder
45
28
 
46
29
  class Open < Action
47
30
  string :url, cache: true
48
- bool :showClose # deprecated
49
31
  bool :disableCloseButton
50
32
  string :fullscreen
51
33
  length :width
@@ -54,13 +36,8 @@ class Glib::JsonUi::ActionBuilder
54
36
  bool :updateExisting
55
37
  end
56
38
 
57
- # Deprecation canceled. This is still useful for a scenario where the previous dialog
58
- # was unknown, so we simply want to reload its content.
59
39
  class Reload < Action
60
- # Deprecated. Should just use dialogs_show or dialogs_open if
61
- # these attributes are needed.
62
40
  string :url, cache: true
63
- bool :showClose # deprecated
64
41
  bool :disableCloseButton
65
42
  string :fullscreen # mobile, always
66
43
  length :width
@@ -0,0 +1,11 @@
1
+ class Glib::JsonUi::ActionBuilder
2
+ module Logics
3
+ class Set < Action
4
+ string :targetId
5
+ hash :conditionalData
6
+ hash :data
7
+ hash :variables
8
+ action :onSet
9
+ end
10
+ end
11
+ end
@@ -1,14 +1,5 @@
1
1
  class Glib::JsonUi::ActionBuilder
2
2
  module Popovers
3
- # Deprecated. Use popovers_show instead.
4
- class Open < Action
5
- string :key
6
- views :childViews
7
- string :placement
8
- int :offset
9
- int :width
10
- singleton_array :styleClass, :styleClasses
11
- end
12
3
 
13
4
  class Show < Action
14
5
  panels_builder :content, :body
@@ -20,6 +20,7 @@ class Glib::JsonUi::ActionBuilder
20
20
 
21
21
  class Reload < Action
22
22
  string :url, cache: true
23
+ bool :disableDirtyCheck
23
24
  action :onReload
24
25
  end
25
26
 
@@ -42,11 +43,6 @@ class Glib::JsonUi::ActionBuilder
42
43
  action :onOpen
43
44
  end
44
45
 
45
- # Any component can listen to the refresh_state event and react appropriately.
46
- # E.g. Stripe credit card component can refresh its token to make sure it is not stale.
47
- class RefreshState < Action
48
- end
49
-
50
46
  class Print < Action
51
47
  end
52
48
  end
@@ -110,30 +110,6 @@ module Glib
110
110
  end
111
111
  end
112
112
 
113
- module Logics
114
- # Future: Replace showIf and loadIf
115
- # Example:
116
- # `submitWhenNotDisplayed` is false by default
117
- # fields_text id: 'my_text', displayed: false, submitWhenNotDisplayed: true
118
- #
119
- # logics_if condition: { '==', BLAH1, BLAH2 }, true: ->(action) do
120
- # action.components_set targetId: 'my_text', displayed: true
121
- # end
122
- #
123
- # class If < Action
124
- # hash :condition
125
- # action :true
126
- # action :false
127
- # end
128
-
129
- class Set < Action
130
- string :targetId
131
- hash :conditionalData
132
- hash :variables
133
- action :onSet
134
- end
135
- end
136
-
137
113
  module Timeouts
138
114
  class Set < Action
139
115
  string :timerId
@@ -17,13 +17,6 @@ module Glib
17
17
  key = 'tooltip_test'
18
18
  end
19
19
  onMouseEnter ->(action) do
20
- # action.popovers_open(
21
- # key: key,
22
- # placement: options[:placement] || 'top',
23
- # childViews: ->(view) {
24
- # view.p styleClass: 'tooltip', text: options[:text]
25
- # }
26
- # )
27
20
 
28
21
  action.popovers_show(
29
22
  key: key,
@@ -3,12 +3,12 @@ module Glib
3
3
  module Default
4
4
  def default_accepts(value)
5
5
  default_max_size_error = {
6
- body: I18n.t('common.accepts.max_file_size_error.body', default: '') || 'Files exceed the maximum size',
7
- button: I18n.t('common.accepts.max_file_size_error.button', default: '') || 'Dismiss'
6
+ body: I18n.t('glib.accepts.max_file_size_error.body', default: nil) || 'Files exceed the maximum size',
7
+ button: I18n.t('glib.accepts.max_file_size_error.button', default: nil) || 'Dismiss'
8
8
  }
9
9
  default_max_length_error = {
10
- body: I18n.t('common.accepts.max_file_length_error.body', default: '') || 'Files exceed the maximum limit per upload',
11
- button: I18n.t('common.accepts.max_file_length_error.button', default: '') || 'Dismiss'
10
+ body: I18n.t('glib.accepts.max_file_length_error.body', default: nil) || 'Files exceed the maximum limit per upload',
11
+ button: I18n.t('glib.accepts.max_file_length_error.button', default: nil) || 'Dismiss'
12
12
  }
13
13
 
14
14
  {
@@ -43,9 +43,6 @@ module Glib
43
43
  string :paramNameForNewSectionIndex
44
44
  string :paramNameForNewSectionedRowIndex
45
45
 
46
- string :id # Deprecated
47
- string :paramNameForNewIndex # Deprecated
48
-
49
46
  panels_builder :accessory, :header, :body, :footer
50
47
  end
51
48
 
@@ -237,7 +237,7 @@ module Glib
237
237
  def form(options = {})
238
238
  form = Glib::JsonUi::ViewBuilder::Panels::Form.new(json, self)
239
239
  form.childViews(->(view_builder) { })
240
- panel_options = options.slice!(:url, :method, :local, :onSubmit, :paramNameForFormData, :model, :onChange)
240
+ panel_options = options.slice!(:url, :method, :local, :onSubmit, :paramNameForFormData, :model, :onChange, :onChangeAndLoad)
241
241
 
242
242
  json.fullPageForm do
243
243
  json.view 'panels/fullPageForm'
@@ -283,6 +283,12 @@ module Glib
283
283
  end
284
284
  end
285
285
 
286
+ if (on_unload = options[:unload])
287
+ json.onUnload do
288
+ on_unload.call @action_builder
289
+ end
290
+ end
291
+
286
292
  if (on_refocus = options[:refocus])
287
293
  json.onRefocus do
288
294
  on_refocus.call @action_builder
@@ -9,6 +9,7 @@ class Glib::JsonUi::ViewBuilder
9
9
  hash :validation
10
10
  bool :disableDirtyCheck
11
11
  action :onChange
12
+ action :onChangeAndLoad
12
13
  string :paramNameForFormData
13
14
  string :paramNameForFieldName
14
15
 
@@ -155,9 +156,6 @@ class Glib::JsonUi::ViewBuilder
155
156
  def value(value)
156
157
  @value = value if value != Glib::Value::DEFAULT
157
158
  end
158
-
159
- # TODO: Remove (deprecated). Where possible, use value instead of this
160
- bool :checked
161
159
  end
162
160
 
163
161
  # This doesn't use camel case because some terms have become single words (e.g. snackbar)
@@ -173,15 +171,6 @@ class Glib::JsonUi::ViewBuilder
173
171
  string :cacheKey
174
172
  end
175
173
 
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
181
- class Country < AbstractField
182
- hash :region
183
- end
184
-
185
174
  class Select < AbstractField
186
175
  array :options
187
176
  # bool :readOnly
@@ -209,14 +198,6 @@ class Glib::JsonUi::ViewBuilder
209
198
  end
210
199
  end
211
200
 
212
- # TODO: Remove (deprecated)
213
- class Autocomplete < AbstractField
214
- array :options
215
- # bool :readOnly
216
- bool :multiple, cache: true
217
- # bool :manualEntry
218
- hash :append
219
- end
220
201
 
221
202
  class DynamicSelect < AbstractField
222
203
  array :selectedOptions
@@ -286,7 +267,6 @@ class Glib::JsonUi::ViewBuilder
286
267
  string :fileUrl
287
268
  string :fileTitle
288
269
  string :uploadText
289
- string :uploadIcon # deprecated
290
270
  hash :placeholderView
291
271
  hash :infoSpec
292
272
  string :storagePrefix
@@ -298,9 +278,9 @@ class Glib::JsonUi::ViewBuilder
298
278
 
299
279
  def created
300
280
  @buttonLabels ||= ActiveSupport::HashWithIndifferentAccess.new
301
- @buttonLabels['change'] ||= I18n.t('common.change') if I18n.exists?('common.change')
302
- @buttonLabels['upload'] ||= I18n.t('common.upload') if I18n.exists?('common.upload')
303
- @buttonLabels['delete'] ||= I18n.t('common.delete') if I18n.exists?('common.delete')
281
+ @buttonLabels['change'] ||= I18n.t('glib.change') if I18n.exists?('glib.change')
282
+ @buttonLabels['upload'] ||= I18n.t('glib.upload') if I18n.exists?('glib.upload')
283
+ @buttonLabels['delete'] ||= I18n.t('glib.delete') if I18n.exists?('glib.delete')
304
284
 
305
285
  json.set! :buttonLabels, @buttonLabels
306
286
 
@@ -331,7 +311,6 @@ class Glib::JsonUi::ViewBuilder
331
311
  array :files
332
312
  string :directUploadUrl
333
313
  string :uploadTitle
334
- string :uploadFailedText # deprecated
335
314
  action :onFinishUpload
336
315
  string :strategy # can be "delegate" or "dropUpload"
337
316
  string :url # http post end point if you don't want to use onFinishUpload
@@ -341,15 +320,6 @@ class Glib::JsonUi::ViewBuilder
341
320
 
342
321
  required :accepts, :directUploadUrl
343
322
 
344
- # deprecated
345
- def title(value)
346
- @placeholder = value
347
- end
348
-
349
- # deprecated
350
- def subtitle(value)
351
- @hint = value
352
- end
353
323
 
354
324
  def accepts(value)
355
325
  @accepts = value
@@ -366,11 +336,11 @@ class Glib::JsonUi::ViewBuilder
366
336
  def created
367
337
  super
368
338
 
369
- @placeholder ||= I18n.t('common.multi_upload.placeholder', default: nil)
370
- @hint ||= I18n.t('common.multi_upload.hint', default: nil)
339
+ @placeholder ||= I18n.t('glib.multi_upload.placeholder', default: nil)
340
+ @hint ||= I18n.t('glib.multi_upload.hint', default: nil)
371
341
 
372
342
  ['200', '403', '401', 'else'].each do |status|
373
- key = "common.multi_upload.responseMessages.#{status}"
343
+ key = "glib.multi_upload.responseMessages.#{status}"
374
344
  @responseMessages[status] = I18n.t(key) if I18n.exists?(key)
375
345
  end
376
346
  json.responseMessages (@responseMessages || {}).reverse_merge({
@@ -469,7 +439,6 @@ class Glib::JsonUi::ViewBuilder
469
439
  class Otp < AbstractField
470
440
  int :length
471
441
  string :type
472
- string :align # deprecated
473
442
  end
474
443
 
475
444
  class Rating < AbstractField
@@ -6,6 +6,7 @@ class Glib::JsonUi::ViewBuilder
6
6
 
7
7
  action :onSubmit
8
8
  action :onChange
9
+ action :onChangeAndLoad
9
10
  string :paramNameForFormData
10
11
  bool :local
11
12
 
@@ -41,16 +41,15 @@ module Glib
41
41
  hash :padding
42
42
  singleton_array :styleClass, :styleClasses
43
43
 
44
- hash :valueIf
45
-
46
44
  hash :showIf
47
45
  hash :loadIf
48
46
  action :onIfTrue
49
47
  action :onIfFalse
50
48
 
49
+ bool :displayed
50
+ bool :submitWhenNotDisplayed
51
+
51
52
  hash :analytics
52
- # hash :tooltip
53
- array :extensions # deprecated
54
53
  hash :dragData
55
54
 
56
55
  def self.component_name
@@ -166,9 +165,6 @@ module Glib
166
165
  class Icon < View
167
166
  badgeable
168
167
 
169
- # TODO: Remove later. Deprecated.
170
- icon :spec
171
-
172
168
  action :onClick
173
169
  color :color
174
170
 
@@ -204,13 +200,6 @@ module Glib
204
200
  action :onClick
205
201
  color :color
206
202
  bool :disabled
207
-
208
- # TODO: This should be deprecated in favour of `popovers/open`
209
- def childButtons(block)
210
- json.childButtons do
211
- block.call page.menu_builder
212
- end
213
- end
214
203
  end
215
204
 
216
205
  class Fab < View
@@ -125,12 +125,6 @@ module Glib
125
125
  controller.helpers
126
126
  end
127
127
 
128
- # TODO: Remove. Deprecated
129
- # private # Used by child
130
- # def public?
131
- # true
132
- # end
133
-
134
128
  class Scope
135
129
  attr_reader :user, :scope
136
130
 
@@ -4,14 +4,10 @@ section.header padding: glib_json_padding_list, childViews: ->(header) do
4
4
  end
5
5
 
6
6
  section.rows builder: ->(template) do
7
- template.thumbnail title: 'components/update (Deprecated)', onClick: ->(action) do
8
- action.windows_open url: json_ui_garage_url(path: 'views/components_update')
7
+ template.thumbnail title: 'components/replace', onClick: ->(action) do
8
+ action.windows_open url: json_ui_garage_url(path: 'views/components_replace')
9
9
  end
10
10
 
11
- # template.thumbnail title: 'components/replace', onClick: ->(action) do
12
- # action.windows_open url: json_ui_garage_url(path: 'views/components')
13
- # end
14
-
15
11
  template.thumbnail title: 'components/set', onClick: ->(action) do
16
12
  action.windows_open url: json_ui_garage_url(path: 'views/components_set')
17
13
  end
@@ -40,20 +40,6 @@ section.rows builder: ->(template) do
40
40
  # end
41
41
  # end
42
42
 
43
- # TODO: Deprecate
44
- template.thumbnail title: 'dialogs/option (Deprecated)', onClick: ->(action) do
45
- # TODO: Rename to `dialogs/menu`
46
- action.dialogs_options message: 'Select one', buttons: ->(menu) do
47
- menu.button text: 'Option1', onClick: ->(action) do
48
- action.dialogs_alert message: 'Option 1'
49
- end
50
- menu.button text: 'Option2', onClick: ->(action) do
51
- action.dialogs_alert message: 'Option 2'
52
- end
53
- menu.button text: 'Cancel'
54
- end
55
- end
56
-
57
43
  template.thumbnail title: 'dialogs/show', onClick: ->(action) do
58
44
  render 'json_ui/garage/actions/dialogs_show', json: json, action: action, dialog_mode: :show
59
45
  end
@@ -16,7 +16,7 @@ section.rows builder: ->(template) do
16
16
  action.windows_reload url: json_ui_garage_url(path: 'actions/index', reload_counter: reload_counter + 1)
17
17
  end
18
18
 
19
- template.thumbnail title: "components/update (counter: #{reload_counter})", onClick: ->(action) do
19
+ template.thumbnail title: "components/replace (counter: #{reload_counter})", onClick: ->(action) do
20
20
  action.http_get url: json_ui_garage_url(path: 'actions/partial_update', reload_counter: reload_counter + 1)
21
21
  end
22
22
  end
@@ -1,5 +1,5 @@
1
1
  json_ui_response_with_view json do |action|
2
- action.components_update targetId: 'action_list', views: ->(update) do
2
+ action.components_replace targetId: 'action_list', views: ->(update) do
3
3
  render "#{@path_prefix}/actions/list", panel: update
4
4
  end
5
5
  end
@@ -7,6 +7,4 @@ info = "Method: #{request.method}\nForm Data:\n"
7
7
 
8
8
  info += JSON.pretty_generate(params.require(:user).to_unsafe_h)
9
9
 
10
- action.dialogs_alert message: info, onClose: ->(action) do
11
- action.windows_refreshState
12
- end
10
+ action.dialogs_alert message: info
@@ -1,5 +1,5 @@
1
1
  name = params[:name]
2
- action.components_update targetId: 'greeting', views: ->(update) do
2
+ action.components_replace targetId: 'greeting', views: ->(update) do
3
3
  update.panels_vertical childViews: ->(vertical) do
4
4
  name = params[:name]
5
5
  vertical.fields_hidden name: 'name', value: name
@@ -6,26 +6,9 @@ if text.length > min_chars
6
6
  form.markdown \
7
7
  text: text.truncate(min_chars),
8
8
  styleClasses: ['line-clamp', "line-clamp-#{max_lines}"],
9
- showIf: {
10
- "!=": [
11
- {
12
- "var": toggle_name
13
- },
14
- 'true'
15
- ]
16
- }
17
- form.markdown \
18
- text: text,
19
- showIf: {
20
- "==": [
21
- {
22
- "var": toggle_name
23
- },
24
- 'true'
25
- ]
26
- }
9
+ id: "#{id}-off"
10
+ form.markdown id: "#{id}-on", text: text
27
11
 
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.
29
12
  form.fields_check \
30
13
  width: 'matchParent',
31
14
  offIcon: 'expand_more',
@@ -35,7 +18,31 @@ if text.length > min_chars
35
18
  checkValue: 'true',
36
19
  uncheckValue: nil,
37
20
  name: toggle_name,
38
- disableDirtyCheck: true
21
+ disableDirtyCheck: true,
22
+ onChangeAndLoad: ->(action) do
23
+ action.runMultiple childActions: ->(saction) do
24
+ saction.logics_set targetId: "#{id}-on", conditionalData: {
25
+ displayed: {
26
+ "==": [
27
+ {
28
+ "var": toggle_name
29
+ },
30
+ 'true'
31
+ ]
32
+ }
33
+ }
34
+ saction.logics_set targetId: "#{id}-off", conditionalData: {
35
+ displayed: {
36
+ "!=": [
37
+ {
38
+ "var": toggle_name
39
+ },
40
+ 'true'
41
+ ]
42
+ }
43
+ }
44
+ end
45
+ end
39
46
 
40
47
  @__read_more_index += 1
41
48
  end