mobile_workflow 0.10.2 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +3 -1
  3. data/app/controllers/concerns/mobile_workflow/param_parser.rb +6 -3
  4. data/app/controllers/concerns/mobile_workflow/s3_storable.rb +18 -12
  5. data/app/controllers/mobile_workflow/sns_notifications_controller.rb +25 -22
  6. data/app/helpers/mobile_workflow/application_helper.rb +2 -0
  7. data/app/jobs/mobile_workflow/add_attachment_job.rb +2 -1
  8. data/app/jobs/mobile_workflow/application_job.rb +2 -0
  9. data/app/mailers/mobile_workflow/application_mailer.rb +2 -0
  10. data/app/models/concerns/mobile_workflow/attachable.rb +3 -3
  11. data/app/models/concerns/mobile_workflow/displayable/steps/form.rb +12 -69
  12. data/app/models/concerns/mobile_workflow/displayable/steps/list.rb +6 -3
  13. data/app/models/concerns/mobile_workflow/displayable/steps/map.rb +8 -4
  14. data/app/models/concerns/mobile_workflow/displayable/steps/question.rb +14 -8
  15. data/app/models/concerns/mobile_workflow/displayable/steps/stack.rb +22 -75
  16. data/app/models/concerns/mobile_workflow/displayable/steps/styled_content/grid.rb +10 -21
  17. data/app/models/concerns/mobile_workflow/displayable/steps/styled_content/stack.rb +8 -28
  18. data/app/models/concerns/mobile_workflow/displayable.rb +10 -8
  19. data/bin/mwf +11 -10
  20. data/config/initializers/add_frozen_string_literal.rb +4 -3
  21. data/config/routes.rb +2 -0
  22. data/lib/generators/mobile_workflow/controller_generator.rb +26 -21
  23. data/lib/generators/mobile_workflow/install/install_generator.rb +55 -52
  24. data/lib/generators/mobile_workflow/install/templates/app/helpers/application_helper.rb +2 -0
  25. data/lib/generators/mobile_workflow/install/templates/app/models/ability.rb +2 -0
  26. data/lib/generators/mobile_workflow/install/templates/app/models/application_record.rb +2 -0
  27. data/lib/generators/mobile_workflow/install/templates/create_users.rb +2 -0
  28. data/lib/generators/mobile_workflow/install/templates/spec/factories/users.rb +2 -0
  29. data/lib/generators/mobile_workflow/model_generator.rb +7 -3
  30. data/lib/mobile_workflow/cli/app_builder.rb +147 -140
  31. data/lib/mobile_workflow/cli/app_server_cleaner.rb +19 -14
  32. data/lib/mobile_workflow/cli/app_server_generator.rb +53 -49
  33. data/lib/mobile_workflow/cli/aws_backend.rb +82 -74
  34. data/lib/mobile_workflow/cli/dokku_backend.rb +58 -55
  35. data/lib/mobile_workflow/cli/heroku_backend.rb +54 -49
  36. data/lib/mobile_workflow/cli.rb +9 -7
  37. data/lib/mobile_workflow/deprecated.rb +34 -0
  38. data/lib/mobile_workflow/displayable.rb +10 -9
  39. data/lib/mobile_workflow/engine.rb +3 -1
  40. data/lib/mobile_workflow/open_api_spec/parser.rb +25 -24
  41. data/lib/mobile_workflow/railtie.rb +3 -1
  42. data/lib/mobile_workflow/tasks/s3.rake +5 -3
  43. data/lib/mobile_workflow/tasks/set_env.rake +30 -31
  44. data/lib/mobile_workflow/version.rb +3 -1
  45. data/lib/mobile_workflow.rb +5 -2
  46. metadata +21 -21
  47. data/app/models/concerns/mobile_workflow/displayable/steps/pie_chart.rb +0 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f468888276f739eb0ae572c2d726273b2848cecb81340e63f0808127ff83c917
4
- data.tar.gz: 5bc7aff35b9be7f1938f3eabd2e01bf734608eca8db805cfa01b416508f60290
3
+ metadata.gz: 565b4daab2dbcebea8bafd74966da9c01e97a6fd81d313083128b81b4dc162ca
4
+ data.tar.gz: 720bb94a72b02aff18acc15183abd96710d5c2148b090f5063a9a29a6b5a92da
5
5
  SHA512:
6
- metadata.gz: 33f31ce284d0799276f6950c3b0ee6e820cb2107f1ad0de274b55c5fcc2d464b4f2304d6231201ef06419b2a621b85cfed8f8d42f546fc9a7ac47d5e7ea02559
7
- data.tar.gz: a298610029408fced69d431c5ebc37d6473570205fadc25e5fa260ed1c9560ae67d3d6c74b163a7efbbbcc3b340c0f98b892a27f59ac580208a59b19054fb08e
6
+ metadata.gz: d76be544e381b827f0d11bb6979861284c66e5c65ec43de707ef82abdbb8bdf7f792c15c01b9ac05292f391882a58e061c7f7ce973f22be2077dd450a8895a7a
7
+ data.tar.gz: 31c2bc449d1547721715068d6e60f708b94ebeea6f68bb55c4d39ca9c5db429e140a5b26d1fcf9b2110b5cd598e6cceb290f4077a3154ac45982bd4f7daba85a
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  begin
2
4
  require 'bundler/setup'
3
5
  rescue LoadError
@@ -14,7 +16,7 @@ RDoc::Task.new(:rdoc) do |rdoc|
14
16
  rdoc.rdoc_files.include('lib/**/*.rb')
15
17
  end
16
18
 
17
- APP_RAKEFILE = File.expand_path("spec/dummy/Rakefile", __dir__)
19
+ APP_RAKEFILE = File.expand_path('spec/dummy/Rakefile', __dir__)
18
20
  load 'rails/tasks/engine.rake'
19
21
 
20
22
  load 'rails/tasks/statistics.rake'
@@ -1,7 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module MobileWorkflow
2
4
  module ParamParser
3
5
  def mw_rewrite_payload_properties(model:, properties:)
4
- properties.each {|property| mw_rewrite_payload_property(model: model, model_property: property, params_property: property)}
6
+ properties.each do |property|
7
+ mw_rewrite_payload_property(model: model, model_property: property, params_property: property)
8
+ end
5
9
  end
6
10
 
7
11
  def mw_rewrite_payload_property(model:, model_property:, params_property:)
@@ -11,7 +15,6 @@ module MobileWorkflow
11
15
  def mw_rewrite_payload_array(model:, model_property:, params_property:)
12
16
  answer = params.dig(:payload, params_property, :answer)
13
17
  params[model][model_property] = answer[0] if answer
14
- end
18
+ end
15
19
  end
16
20
  end
17
-
@@ -1,43 +1,49 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'aws-sdk-s3'
2
4
 
3
5
  module MobileWorkflow
4
6
  module S3Storable
5
- if Object.const_defined?("Aws::S3")
7
+ if Object.const_defined?('Aws::S3')
6
8
  extend ActiveSupport::Concern
7
-
9
+
8
10
  def binary_urls(object)
9
11
  return unless params[:binaries]
10
-
12
+
11
13
  params[:binaries].map do |binary|
12
14
  identifier = binary[:identifier]
13
- object_attribute = identifier.split(".")[0] # ensure extension doesnt get added here
15
+ object_attribute = identifier.split('.')[0] # ensure extension doesnt get added here
14
16
  extension = binary[:mimetype].split('/')[1] # i.e. image/jpg --> jpg, video/mp4 --> mp4
15
17
  metadata = binary[:metadata]
16
18
 
17
19
  {
18
20
  identifier: identifier,
19
- url: presigned_url("#{object.class.name.underscore}/#{object.id}/#{object_attribute}/#{s3_object_uuid}.#{extension}", metadata: metadata),
20
- method: "PUT"
21
+ url: presigned_url(
22
+ "#{object.class.name.underscore}/#{object.id}/#{object_attribute}/#{s3_object_uuid}.#{extension}", metadata: metadata
23
+ ),
24
+ method: 'PUT'
21
25
  }
22
26
  end
23
27
  end
24
-
28
+
25
29
  private
30
+
26
31
  def s3_object_uuid
27
32
  SecureRandom.uuid
28
33
  end
29
-
34
+
30
35
  def presigned_url(key, metadata: nil)
31
36
  presigner.presigned_url(:put_object, bucket: ENV['AWS_BUCKET_NAME'], key: key, metadata: metadata)
32
37
  end
33
-
38
+
34
39
  def presigner
35
40
  Aws::S3::Presigner.new(client: s3_client)
36
41
  end
37
-
42
+
38
43
  def s3_client
39
- Aws::S3::Client.new(region: ENV['AWS_REGION'], access_key_id: ENV['AWS_ACCESS_ID'], secret_access_key: ENV['AWS_SECRET_KEY'])
44
+ Aws::S3::Client.new(region: ENV['AWS_REGION'], access_key_id: ENV['AWS_ACCESS_ID'],
45
+ secret_access_key: ENV['AWS_SECRET_KEY'])
40
46
  end
41
47
  end
42
48
  end
43
- end
49
+ end
@@ -1,13 +1,15 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'aws-sdk-sns'
2
4
 
3
5
  module MobileWorkflow
4
6
  class SnsNotificationsController < ActionController::API
5
- if Object.const_defined?("Aws::S3") && Object.const_defined?("Aws::SNS")
7
+ if Object.const_defined?('Aws::S3') && Object.const_defined?('Aws::SNS')
6
8
  before_action :verify_request_authenticity
7
-
9
+
8
10
  def create
9
11
  Rails.logger.info("Message body: #{message_body}")
10
-
12
+
11
13
  case message_body['Type']
12
14
  when 'SubscriptionConfirmation'
13
15
  confirm_subscription ? (head :ok) : (head :bad_request)
@@ -20,62 +22,63 @@ module MobileWorkflow
20
22
  rescue ActiveRecord::RecordNotFound
21
23
  head :not_found
22
24
  end
23
-
25
+
24
26
  private
25
-
27
+
26
28
  def verify_request_authenticity
27
29
  head :unauthorized if raw_post.blank?
28
-
29
- #head :unauthorized if raw_post.blank? || !message_verifier.authentic?(raw_post) # Not working
30
+
31
+ # head :unauthorized if raw_post.blank? || !message_verifier.authentic?(raw_post) # Not working
30
32
  end
31
-
33
+
32
34
  def object
33
35
  @object ||= begin
34
36
  object_class_name, object_id = key_identifiers
35
37
  object_class_name.camelcase.constantize.find(object_id.to_i)
36
38
  end
37
39
  end
38
-
40
+
39
41
  def attribute_name
40
42
  key_identifiers[2]
41
43
  end
42
-
44
+
43
45
  def key_identifiers
44
- object_class_name, object_id, attribute_name = object_key.split("/")
45
- return object_class_name, object_id, attribute_name
46
+ object_class_name, object_id, attribute_name = object_key.split('/')
47
+ [object_class_name, object_id, attribute_name]
46
48
  end
47
-
49
+
48
50
  def object_key
49
51
  message = JSON.parse(message_body['Message'])
50
- message['Records'][0]['s3']['object']['key']
52
+ message['Records'][0]['s3']['object']['key']
51
53
  end
52
-
54
+
53
55
  def message_body
54
56
  @message_body ||= JSON.parse(raw_post)
55
57
  end
56
-
58
+
57
59
  def raw_post
58
60
  @raw_post ||= request.raw_post
59
61
  end
60
-
62
+
61
63
  def message_verifier
62
64
  @message_verifier ||= Aws::SNS::MessageVerifier.new
63
65
  end
64
-
66
+
65
67
  def confirm_subscription
66
68
  sns_client.confirm_subscription(
67
69
  topic_arn: message_body['TopicArn'],
68
70
  token: message_body['Token']
69
71
  )
70
- return true
72
+ true
71
73
  rescue Aws::SNS::Errors::ServiceError => e
72
74
  Rails.logger.warn(e.message)
73
- return false
75
+ false
74
76
  end
75
77
 
76
78
  def sns_client
77
- Aws::SNS::Client.new(region: ENV['AWS_REGION'], access_key_id: ENV['AWS_ACCESS_ID'], secret_access_key: ENV['AWS_SECRET_KEY'])
79
+ Aws::SNS::Client.new(region: ENV['AWS_REGION'], access_key_id: ENV['AWS_ACCESS_ID'],
80
+ secret_access_key: ENV['AWS_SECRET_KEY'])
78
81
  end
79
82
  end
80
- end
83
+ end
81
84
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module MobileWorkflow
2
4
  module ApplicationHelper
3
5
  end
@@ -20,7 +20,8 @@ module MobileWorkflow
20
20
  end
21
21
 
22
22
  def s3_bucket
23
- Aws::S3::Resource.new(region: ENV['AWS_REGION'], access_key_id: ENV['AWS_ACCESS_ID'], secret_access_key: ENV['AWS_SECRET_KEY']).bucket(ENV['AWS_BUCKET_NAME'])
23
+ Aws::S3::Resource.new(region: ENV['AWS_REGION'], access_key_id: ENV['AWS_ACCESS_ID'],
24
+ secret_access_key: ENV['AWS_SECRET_KEY']).bucket(ENV['AWS_BUCKET_NAME'])
24
25
  end
25
26
 
26
27
  def hex_to_base64_digest(hexdigest)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module MobileWorkflow
2
4
  class ApplicationJob < ActiveJob::Base
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module MobileWorkflow
2
4
  class ApplicationMailer < ActionMailer::Base
3
5
  default from: 'from@example.com'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module MobileWorkflow
2
4
  module Attachable
3
5
  extend ActiveSupport::Concern
@@ -10,8 +12,6 @@ module MobileWorkflow
10
12
  rails_representation_url(attachment.variant(options), host: heroku_attachment_host)
11
13
  elsif attachment.previewable?
12
14
  rails_representation_url(attachment.preview(options), host: heroku_attachment_host)
13
- else
14
- return nil
15
15
  end
16
16
  end
17
17
 
@@ -33,4 +33,4 @@ module MobileWorkflow
33
33
  "https://#{app_name}.herokuapp.com"
34
34
  end
35
35
  end
36
- end
36
+ end
@@ -1,79 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'app_rail/steps'
3
4
 
4
5
  module MobileWorkflow
5
6
  module Displayable
6
7
  module Steps
7
8
  module Form
8
- def mw_form_section(label:, id:)
9
- raise 'Missing label' if label.nil?
10
- raise 'Missing id' if id.nil?
11
-
12
- { item_type: :section, id: id, label: label }
13
- end
14
-
15
- def mw_form_multiple_selection(label:, multiple_selection_options:, id:, selection_type: :single, optional: false, show_other_option: false)
16
- raise 'Missing label' if label.nil?
17
- raise 'Missing id' if id.nil?
18
- raise 'Missing multiple selection options' if multiple_selection_options.nil?
19
-
20
- { item_type: :multiple_selection, id: id, label: label,
21
- multiple_selection_options: multiple_selection_options, selection_type: selection_type, optional: optional, show_other_option: show_other_option }
22
- end
23
-
24
- def mw_form_multiple_selection_options(text:, hint: nil, is_pre_selected: false)
25
- raise 'Missing text' if text.nil?
26
-
27
- { text: text, hint: hint, isPreSelected: is_pre_selected }
28
- end
29
-
30
- def mw_form_number(label:, id:, placeholder: nil, optional: false, symbol_position: :leading, default_text_answer: nil, hint: nil)
31
- raise 'Missing label' if label.nil?
32
- raise 'Missing id' if id.nil?
33
-
34
- { item_type: :number, number_type: :number, id: id, label: label,
35
- placeholder: placeholder, optional: optional, symbol_position: symbol_position, default_text_answer: default_text_answer, hint: hint }
36
- end
37
-
38
- def mw_form_text(label:, id:, placeholder: nil, optional: false, multiline: false, default_text_answer: nil, hint: nil)
39
- raise 'Missing label' if label.nil?
40
- raise 'Missing id' if id.nil?
41
-
42
- { item_type: :text, id: id, label: label, placeholder: placeholder,
43
- optional: optional, multiline: multiline, default_text_answer: default_text_answer, hint: hint }
44
- end
45
-
46
- def mw_form_date(label:, id:, optional: false, default_text_answer: nil)
47
- raise 'Missing label' if label.nil?
48
- raise 'Missing id' if id.nil?
49
-
50
- { item_type: :date, date_type: :calendar, id: id, label: label, optional: optional,
51
- default_text_answer: default_text_answer }
52
- end
53
-
54
- def mw_form_time(label:, id:, optional: false, default_text_answer: nil)
55
- raise 'Missing label' if label.nil?
56
- raise 'Missing id' if id.nil?
57
-
58
- { item_type: :time, id: id, label: label, optional: optional,
59
- default_text_answer: default_text_answer }
60
- end
61
-
62
- def mw_form_email(label:, id:, placeholder: nil, optional: false, default_text_answer: nil)
63
- raise 'Missing label' if label.nil?
64
- raise 'Missing id' if id.nil?
65
-
66
- { item_type: :email, id: id, label: label, placeholder: placeholder,
67
- optional: optional, default_text_answer: default_text_answer }
68
- end
69
-
70
- def mw_form_password(label:, id:, placeholder: nil, optional: false, default_text_answer: nil, hint: nil)
71
- raise 'Missing label' if label.nil?
72
- raise 'Missing id' if id.nil?
73
-
74
- { item_type: :secure, id: id, label: label, placeholder: placeholder,
75
- optional: optional, default_text_answer: default_text_answer, hint: hint }
76
- end
9
+ extend MobileWorkflow::Deprecated
10
+ include AppRail::Steps::CoreForms::Form
11
+ deprecated_alias :mw_form_section, :ar_core_forms_form_section
12
+ deprecated_alias :mw_form_multiple_selection, :ar_core_forms_form_multiple_selection
13
+ deprecated_alias :mw_form_multiple_selection_options, :ar_core_forms_form_multiple_selection_options
14
+ deprecated_alias :mw_form_number, :ar_core_forms_form_number
15
+ deprecated_alias :mw_form_text, :ar_core_forms_form_text
16
+ deprecated_alias :mw_form_date, :ar_core_forms_form_date
17
+ deprecated_alias :mw_form_time, :ar_core_forms_form_time
18
+ deprecated_alias :mw_form_email, :ar_core_forms_form_email
19
+ deprecated_alias :mw_form_password, :ar_core_forms_form_password
77
20
  end
78
21
  end
79
22
  end
@@ -1,13 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'app_rail/steps'
2
4
 
3
5
  module MobileWorkflow
4
6
  module Displayable
5
7
  module Steps
6
8
  module List
9
+ extend MobileWorkflow::Deprecated
7
10
  include AppRail::Steps::Core::List
8
- alias_method :mw_list_item, :ar_core_list_item
9
- alias_method :mw_list_search_suggestion, :ar_core_list_search_suggestion
11
+ deprecated_alias :mw_list_item, :ar_core_list_item
12
+ deprecated_alias :mw_list_search_suggestion, :ar_core_list_search_suggestion
10
13
  end
11
14
  end
12
15
  end
13
- end
16
+ end
@@ -1,11 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'app_rail/steps'
4
+
1
5
  module MobileWorkflow
2
6
  module Displayable
3
7
  module Steps
4
8
  module Map
5
- def mw_map_item(id: self.id, text:, detail_text: nil, latitude:, longitude:)
6
- {id: id.to_s, text: text, detailText: detail_text, latitude: latitude, longitude: longitude}.compact
7
- end
9
+ extend MobileWorkflow::Deprecated
10
+ include AppRail::Steps::Maps::Map
11
+ deprecated_alias :mw_map_item, :ar_maps_map_item
8
12
  end
9
13
  end
10
14
  end
11
- end
15
+ end
@@ -1,25 +1,31 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module MobileWorkflow
2
4
  module Displayable
3
5
  module Steps
4
6
  module Question
5
- QUESTION_STYLES = [:single_choice, :multiple_choice]
6
-
7
+ QUESTION_STYLES = %i[single_choice multiple_choice].freeze
8
+
7
9
  def mw_text_choice_question(question:, style:, text_choices:)
8
10
  raise 'Missing question' if question.empty?
9
11
  raise 'Text Choices should be a hash' unless text_choices.is_a?(Hash)
10
12
 
11
13
  validate_question_style!(style)
12
-
13
- text_choices_a = text_choices.map{|k, v| {_class: "ORKTextChoice", exclusive: false, text: k, value: v} }.to_a
14
- { question: question, answerFormat: { _class: "ORKTextChoiceAnswerFormat", style: camelcase_converter(style.to_s, first_letter: :lower), textChoices: text_choices_a}}
14
+
15
+ text_choices_a = text_choices.map do |k, v|
16
+ { _class: 'ORKTextChoice', exclusive: false, text: k, value: v }
17
+ end.to_a
18
+ { question: question,
19
+ answerFormat: { _class: 'ORKTextChoiceAnswerFormat', style: camelcase_converter(style.to_s, first_letter: :lower),
20
+ textChoices: text_choices_a } }
15
21
  end
16
22
 
17
23
  private
18
-
24
+
19
25
  def validate_question_style!(style)
20
- raise 'Unknown style' unless QUESTION_STYLES.include?(style)
26
+ raise 'Unknown style' unless QUESTION_STYLES.include?(style)
21
27
  end
22
28
  end
23
29
  end
24
30
  end
25
- end
31
+ end
@@ -1,83 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'app_rail/steps'
4
+
1
5
  module MobileWorkflow
2
6
  module Displayable
3
7
  module Steps
4
8
  module Stack
5
- CONTENT_MODE_OPTIONS = [:scale_aspect_fill, :scale_aspect_fit]
6
-
7
- def mw_display_text(text:, label: nil)
8
- {type: :text, label: label, text: text.to_s}.compact
9
- end
10
-
11
- def mw_display_image(preview_url:, attachment_url:, content_mode: :scale_aspect_fill)
12
- validate_content_mode!(content_mode)
13
-
14
- {type: :image, contentMode: camelcase_converter(content_mode.to_s, first_letter: :lower), previewURL: preview_url, url: attachment_url}
15
- end
16
-
17
- def mw_display_unsplash_image(image_url)
18
- if image_url.start_with? "https://unsplash.com/photos"
19
- unsplash_id = image_url.split('/').last
20
- image_url = "https://source.unsplash.com/#{unsplash_id}/800x600"
21
- end
22
-
23
- {type: :image, previewURL: image_url, url: image_url}.compact
24
- end
25
-
26
- def mw_display_video(preview_url:, attachment_url:)
27
- {type: :video, previewURL: preview_url, url: attachment_url}
28
- end
29
-
30
- def mw_display_button(label:, style: :primary, on_success: :forward, sf_symbol_name: nil, material_icon_name: nil)
31
- validate_on_success!(on_success)
32
- validate_button_style!(style)
33
-
34
- {type: :button, label: label, style: style, onSuccess: on_success, sfSymbolName: sf_symbol_name, materialIconName: material_icon_name}.compact
35
- end
36
-
37
- def mw_display_delete_button(url:, label: "Delete", method: :delete, style: :danger, on_success: :backward)
38
- validate_on_success!(on_success)
39
- validate_button_style!(style)
40
-
41
- {type: :button, label: label, url: url, method: method, style: style, onSuccess: on_success, sfSymbolName: 'trash', materialIconName: 'delete'}.compact
42
- end
43
-
44
- def mw_display_url_button(url:, label:, method: :put, style: :primary, confirm_title: nil, confirm_text: nil, on_success: :reload, sf_symbol_name: nil, material_icon_name: nil)
45
- validate_on_success!(on_success)
46
- validate_button_style!(style)
47
-
48
- {type: :button, label: label, url: url, method: method, style: style, confirmTitle: confirm_title, confirmText: confirm_text, onSuccess: on_success, sfSymbolName: sf_symbol_name, materialIconName: material_icon_name}.compact
49
- end
50
- alias_method :mw_display_button_for_url, :mw_display_url_button
51
-
52
- def mw_display_system_url_button(label:, apple_system_url: nil, android_deep_link: nil, style: :primary, sf_symbol_name: nil, material_icon_name: nil)
53
- validate_button_style!(style)
54
- raise 'Invalid android_deep_link' if android_deep_link && !android_deep_link.start_with?('http')
55
-
56
- {type: :button, label: label, appleSystemURL: apple_system_url, androidDeepLink: android_deep_link, style: style, sfSymbolName: sf_symbol_name, materialIconName: material_icon_name}.compact
57
- end
58
- alias_method :mw_display_button_for_system_url, :mw_display_system_url_button
59
-
60
- def mw_display_link_button(label:, link_id:, style: :primary, on_success: :none, sf_symbol_name: nil, material_icon_name: nil)
61
- validate_on_success!(on_success)
62
- validate_button_style!(style)
63
-
64
- {type: :button, label: label, linkId: link_id, style: style, onSuccess: on_success, sfSymbolName: sf_symbol_name, materialIconName: material_icon_name}.compact
65
- end
66
-
67
- # Remove this method once V1 is no longer being used
68
- def mw_display_modal_workflow_button(label:, modal_workflow_name:, style: :primary, on_success: :none, sf_symbol_name: nil, material_icon_name: nil)
69
- validate_on_success!(on_success)
70
- validate_button_style!(style)
71
-
72
- {type: :button, label: label, modalWorkflow: modal_workflow_name, style: style, onSuccess: on_success, sfSymbolName: sf_symbol_name, materialIconName: material_icon_name}.compact
73
- end
74
- alias_method :mw_display_button_for_modal_workflow, :mw_display_modal_workflow_button
9
+ extend MobileWorkflow::Deprecated
10
+ include AppRail::Steps::Core::Stack
11
+ deprecated_alias :mw_display_text, :ar_core_stack_text
12
+ deprecated_alias :mw_display_image, :ar_core_stack_image
13
+ deprecated_alias :mw_display_unsplash_image, :ar_core_stack_unsplash_image
14
+ deprecated_alias :mw_display_video, :ar_core_stack_video
15
+ deprecated_alias :mw_display_button, :ar_core_stack_button
16
+ deprecated_alias :mw_display_delete_button, :ar_core_stack_delete_button
17
+ deprecated_alias :mw_display_url_button, :ar_core_stack_url_button
18
+ deprecated_alias :mw_display_button_for_url, :ar_core_stack_url_button
19
+ deprecated_alias :mw_display_url_button, :ar_core_stack_url_button
20
+ deprecated_alias :mw_display_system_url_button, :ar_core_stack_system_url_button
21
+ deprecated_alias :mw_display_button_for_system_url, :ar_core_stack_system_url_button
22
+ deprecated_alias :mw_display_link_button, :ar_core_stack_link_button
75
23
 
76
- private
77
- def validate_content_mode!(on_success)
78
- raise 'Unknown content_mode' unless CONTENT_MODE_OPTIONS.include?(on_success)
79
- end
24
+ # Core V1
25
+ deprecated_alias :mw_display_modal_workflow_button, :ar_core_stack_modal_workflow_button
26
+ deprecated_alias :mw_display_button_for_modal_workflow, :ar_core_stack_modal_workflow_button
80
27
  end
81
28
  end
82
29
  end
83
- end
30
+ end
@@ -1,30 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'app_rail/steps'
4
+
1
5
  module MobileWorkflow
2
6
  module Displayable
3
7
  module Steps
4
8
  module StyledContent
5
9
  module Grid
6
- def mw_grid_large_section(id:, text:)
7
- raise 'Missing id' if id.nil?
8
- raise 'Missing text' if text.nil?
9
-
10
- { id: id, text: text, type: :largeSection }
11
- end
12
-
13
- def mw_grid_small_section(id:, text:)
14
- raise 'Missing id' if id.nil?
15
- raise 'Missing text' if text.nil?
16
-
17
- { id: id, text: text, type: :smallSection }
18
- end
19
-
20
- def mw_grid_item(id: self.id, text:, detail_text: nil, preview_url: nil)
21
- raise 'Missing id' if id.nil?
22
- raise 'Missing text' if text.nil?
23
-
24
- { id: id, text: text, type: :item, detailText: detail_text, imageURL: preview_url }.compact
25
- end
10
+ extend MobileWorkflow::Deprecated
11
+ include AppRail::Steps::StyledContent::Grid
12
+ deprecated_alias :mw_grid_large_section, :ar_styled_content_grid_large_section
13
+ deprecated_alias :mw_grid_small_section, :ar_styled_content_grid_small_section
14
+ deprecated_alias :mw_grid_item, :ar_styled_content_grid_item
26
15
  end
27
16
  end
28
17
  end
29
18
  end
30
- end
19
+ end
@@ -1,38 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'app_rail/steps'
4
+
3
5
  module MobileWorkflow
4
6
  module Displayable
5
7
  module Steps
6
8
  module StyledContent
7
9
  module Stack
8
- def mw_stack_title(title:)
9
- raise 'Missing title' if title.nil?
10
-
11
- { id: id, title: title, type: :title }
12
- end
13
-
14
- def mw_stack_text(text:)
15
- raise 'Missing text' if text.nil?
16
-
17
- { text: text, type: :text }
18
- end
19
-
20
- def mw_stack_list_item(text:, detail_text: nil, preview_url: nil)
21
- raise 'Missing text' if text.nil?
22
-
23
- { text: text, detailText: detail_text, type: :listItem, imageURL: preview_url }.compact
24
- end
25
-
26
- # Remove `modal_workflow_name` argument once V1 is no longer being used
27
- def mw_stack_button(label:, url: nil, method: :nil, on_success: :none, style: :primary, modal_workflow_name: nil, link_id: nil, link_url: nil, sf_symbol_name: nil, apple_system_url: nil, android_deep_link: nil, confirm_title: nil, confirm_text: nil, share_text: nil, share_image_url: nil)
28
- raise 'Missing label' if label.nil?
29
-
30
- validate_on_success!(on_success)
31
- validate_button_style!(style)
32
-
33
- { type: :button, label: label, url: url, method: method, onSuccess: on_success, style: style,
34
- modalWorkflow: modal_workflow_name, linkId: link_id, linkURL: link_url, sfSymbolName: sf_symbol_name, appleSystemURL: apple_system_url, androidDeepLink: android_deep_link, confirmTitle: confirm_title, confirmText: confirm_text, shareText: share_text, shareImageURL: share_image_url }.compact
35
- end
10
+ extend MobileWorkflow::Deprecated
11
+ include AppRail::Steps::StyledContent::Stack
12
+ deprecated_alias :mw_stack_title, :ar_styled_content_stack_title
13
+ deprecated_alias :mw_stack_text, :ar_styled_content_stack_text
14
+ deprecated_alias :mw_stack_list_item, :ar_styled_content_stack_list_item
15
+ deprecated_alias :mw_stack_button, :ar_styled_content_stack_button
36
16
  end
37
17
  end
38
18
  end