mobile_workflow 0.6.22 → 0.6.23

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 15803a733ac27c65f4abddf88dce1147aca5c2ca75b5c783c0e1a75f242755c9
4
- data.tar.gz: ef3d92ad7e2a184bb2982b14d6c882e9145e5ed91ba6cbf29af655db156b89c3
3
+ metadata.gz: '090b3070564f994192df8405b3e82cffe5e7898d1ff5a5d7d74b6f82894356a0'
4
+ data.tar.gz: 17733e78cf3e0b6f180a3db9f6e4baf41e6d5616d805f91bc8af0a0053dfa9bd
5
5
  SHA512:
6
- metadata.gz: abdfd2cf2f74eaff5eccbac2818d1e19cef70d2a9d300e924e72bfaddddcfee4bc403daa6f48fbe931115268978651951f492ee501f0d3645847dccf7e378c54
7
- data.tar.gz: 33e6c55c6da66aea09bcc17741e417c1bd6c2a4e213572736db4e7e84f86b5d09cb79b760a475a6322524d3cee1980d29a7f979af6c9e2bce90aada3ccab44fc
6
+ metadata.gz: 62098f3fa6656bc4f5e29034fbade9f0087cfcb4462a161cf70549a272d94cc98bd2055a71b734a1089a0ebba80e9c309d36e5a51c4c1cb1cdeb4e39f7de3208
7
+ data.tar.gz: 31facdd89a123b1682d2bf6f5ea5fc72370c3e08462c16c614d6225f03cc1b939c8b8e8952c5d7051ab0154d9cd4c9533e2e9de2ad285e5a477f3fd08b76d9d4
@@ -5,7 +5,8 @@ module MobileWorkflow
5
5
 
6
6
  ON_SUCCESS_OPTIONS = [:none, :reload, :backward, :forward]
7
7
  BUTTON_STYLES = [:primary, :outline, :danger]
8
- CONTENT_MODE_OPTIONS = [:scale_aspect_fill, :scale_aspect_fit]
8
+ CONTENT_MODE_OPTIONS = [:scale_aspect_fill, :scale_aspect_fit]
9
+ QUESTION_STYLES = [:single_choice, :multiple_choice]
9
10
 
10
11
  def mw_list_item(id: self.id, text:, detail_text: nil, sf_symbol_name: nil, image_attachment: nil)
11
12
  mw_list_item = {id: id, text: text, detailText: detail_text, sfSymbolName: sf_symbol_name}
@@ -81,6 +82,15 @@ module MobileWorkflow
81
82
  {type: :button, label: label, modalWorkflow: modal_workflow_name, style: style, onSuccess: on_success}.compact
82
83
  end
83
84
  alias_method :mw_display_button_for_modal_workflow, :mw_display_modal_workflow_button
85
+
86
+ def mw_text_choice_question(question:, style:, text_choices:)
87
+ raise 'Missing question' if question.blank?
88
+ raise 'Text Choices should be a hash' unless text_choices.is_a?(Hash)
89
+ validate_question_style!(style)
90
+
91
+ text_choices_a = text_choices.map{|k, v| {_class: "ORKTextChoice", exclusive: false, text: k, value: v} }.to_a
92
+ { question: question, answerFormat: { _class: "ORKTextChoiceAnswerFormat", style: style.to_s.camelize(:lower), textChoices: text_choices_a}}
93
+ end
84
94
 
85
95
  private
86
96
  def validate_on_success!(on_success)
@@ -95,6 +105,10 @@ module MobileWorkflow
95
105
  raise 'Unknown style' unless BUTTON_STYLES.include?(style)
96
106
  end
97
107
 
108
+ def validate_question_style!(style)
109
+ raise 'Unknown style' unless QUESTION_STYLES.include?(style)
110
+ end
111
+
98
112
  def preview_url(attachment, options:)
99
113
  return nil unless attachment.attached?
100
114
 
@@ -1,5 +1,5 @@
1
1
  module MobileWorkflow
2
- VERSION = '0.6.22'
2
+ VERSION = '0.6.23'
3
3
  RUBY_VERSION = '2.7.2'
4
4
  RAILS_VERSION = '6.1.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mobile_workflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.22
4
+ version: 0.6.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Brooke-Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-18 00:00:00.000000000 Z
11
+ date: 2021-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails