mobile_workflow 0.6.19 → 0.6.24
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 +4 -4
- data/app/controllers/concerns/mobile_workflow/s3_storable.rb +4 -3
- data/app/models/concerns/mobile_workflow/displayable.rb +50 -10
- data/lib/generators/mobile_workflow/install/install_generator.rb +3 -0
- data/lib/mobile_workflow.rb +1 -1
- data/lib/mobile_workflow/railtie.rb +13 -0
- data/lib/mobile_workflow/tasks/env_set.rake +58 -0
- data/lib/mobile_workflow/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9775519f09048d28dd30bf4f4483a469eed3660cea3860d8a24e67de1408799
|
4
|
+
data.tar.gz: 1d1a5f7c56a128b056e5d7cdb97b0e01c90525b0bb0aeffea409ffa4aecca9c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4209f4dd3e731a189da554458c36f06af935e51f5b2b2b52621e9123f4825d14b35c39b42f7a989aa051557db06f3a7edbce2ed43f905397b3bf4254fca30d8
|
7
|
+
data.tar.gz: c1781869445e2ba3ffb97824a071ad95a0735c9d778062df73e9d063c39f5590cf0a128a60e43fd5fe737bf322efa691e368316c304582f35d7901fd663cdb7b
|
@@ -6,12 +6,13 @@ module MobileWorkflow
|
|
6
6
|
def binary_urls(object)
|
7
7
|
return unless params["binaries"]
|
8
8
|
|
9
|
-
params["binaries"].
|
10
|
-
|
9
|
+
params["binaries"].map do |binary|
|
10
|
+
object_attribute = binary["identifier"]
|
11
|
+
extension = binary["mimetype"].split('/')[1] # i.e. image/jpg --> jpg, video/mp4 --> mp4
|
11
12
|
|
12
13
|
{
|
13
14
|
"identifier" => binary["identifier"],
|
14
|
-
"url" => presigned_url("#{object.class.name.underscore}/#{object.id}/#{
|
15
|
+
"url" => presigned_url("#{object.class.name.underscore}/#{object.id}/#{object_attribute}.#{extension}"),
|
15
16
|
"method" => "PUT"
|
16
17
|
}
|
17
18
|
end
|
@@ -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}
|
@@ -37,7 +38,7 @@ module MobileWorkflow
|
|
37
38
|
image_url = "https://source.unsplash.com/#{unsplash_id}/800x600"
|
38
39
|
end
|
39
40
|
|
40
|
-
{type: :image, previewURL: image_url, url: image_url}
|
41
|
+
{type: :image, previewURL: image_url, url: image_url}.compact
|
41
42
|
end
|
42
43
|
|
43
44
|
def mw_display_video(attachment, preview_options: { resize_to_fill: [600, 1200] })
|
@@ -48,35 +49,70 @@ module MobileWorkflow
|
|
48
49
|
validate_on_success!(on_success)
|
49
50
|
validate_button_style!(style)
|
50
51
|
|
51
|
-
{type: :button, label: label, style: style, onSuccess: on_success}
|
52
|
+
{type: :button, label: label, style: style, onSuccess: on_success}.compact
|
52
53
|
end
|
53
54
|
|
54
55
|
def mw_display_delete_button(url:, label: "Delete", method: :delete, style: :danger, on_success: :backward)
|
55
56
|
validate_on_success!(on_success)
|
56
57
|
validate_button_style!(style)
|
57
58
|
|
58
|
-
{type: :button, label: label, url: url, method: method, style: style, onSuccess: on_success}
|
59
|
+
{type: :button, label: label, url: url, method: method, style: style, onSuccess: on_success}.compact
|
59
60
|
end
|
60
|
-
|
61
|
-
def
|
61
|
+
|
62
|
+
def mw_display_url_button(label:, url:, method: :put, style: :primary, confirm_title: nil, confirm_text: nil, on_success: :reload)
|
62
63
|
validate_on_success!(on_success)
|
63
64
|
validate_button_style!(style)
|
64
65
|
|
65
|
-
{type: :button, label: label, url: url, method: method, style: style, onSuccess: on_success}
|
66
|
+
{type: :button, label: label, url: url, method: method, style: style, confirmTitle: confirm_title, confirmText: confirm_text, onSuccess: on_success}.compact
|
66
67
|
end
|
68
|
+
alias_method :mw_display_button_for_url, :mw_display_url_button
|
67
69
|
|
68
|
-
def
|
70
|
+
def mw_display_system_url_button(label:, apple_system_url: nil, android_deep_link: nil, style: :primary)
|
69
71
|
validate_button_style!(style)
|
70
72
|
raise 'Invalid android_deep_link' unless android_deep_link.start_with?('http')
|
71
73
|
|
72
74
|
{type: :button, label: label, appleSystemURL: apple_system_url, androidDeepLink: android_deep_link, style: style}.compact
|
73
75
|
end
|
76
|
+
alias_method :mw_display_button_for_system_url, :mw_display_system_url_button
|
74
77
|
|
75
|
-
def
|
78
|
+
def mw_display_modal_workflow_button(label:, modal_workflow_name:, style: :primary, on_success: :none)
|
76
79
|
validate_on_success!(on_success)
|
77
80
|
validate_button_style!(style)
|
78
81
|
|
79
|
-
{type: :button, label: label, modalWorkflow: modal_workflow_name, style: style, onSuccess: on_success}
|
82
|
+
{type: :button, label: label, modalWorkflow: modal_workflow_name, style: style, onSuccess: on_success}.compact
|
83
|
+
end
|
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
|
94
|
+
|
95
|
+
def mw_grid_large_section(id:, text:)
|
96
|
+
raise 'Missing id' if id.nil?
|
97
|
+
raise 'Missing text' if text.nil?
|
98
|
+
|
99
|
+
{ id: id, text: text, type: :largeSection }
|
100
|
+
end
|
101
|
+
|
102
|
+
def mw_grid_small_section(id:, text:)
|
103
|
+
raise 'Missing id' if id.nil?
|
104
|
+
raise 'Missing text' if text.nil?
|
105
|
+
|
106
|
+
{ id: id, text: text, type: :smallSection }
|
107
|
+
end
|
108
|
+
|
109
|
+
def mw_grid_item(id:, text:, image_attachment: nil)
|
110
|
+
raise 'Missing id' if id.nil?
|
111
|
+
raise 'Missing text' if text.nil?
|
112
|
+
|
113
|
+
item = { id: id, text: text, type: :item }
|
114
|
+
item[:imageURL] = preview_url(image_attachment, options: { resize_to_fill: [600, 600] }) if image_attachment
|
115
|
+
item
|
80
116
|
end
|
81
117
|
|
82
118
|
private
|
@@ -92,6 +128,10 @@ module MobileWorkflow
|
|
92
128
|
raise 'Unknown style' unless BUTTON_STYLES.include?(style)
|
93
129
|
end
|
94
130
|
|
131
|
+
def validate_question_style!(style)
|
132
|
+
raise 'Unknown style' unless QUESTION_STYLES.include?(style)
|
133
|
+
end
|
134
|
+
|
95
135
|
def preview_url(attachment, options:)
|
96
136
|
return nil unless attachment.attached?
|
97
137
|
|
@@ -52,6 +52,9 @@ module MobileWorkflow
|
|
52
52
|
def generate_models
|
53
53
|
say "Loading OpenAPI Spec: #{open_api_spec_path}"
|
54
54
|
say "Generating models"
|
55
|
+
|
56
|
+
copy_file("app/models/application_record.rb")
|
57
|
+
|
55
58
|
model_name_to_properties.each_pair do |model_name, model_properties|
|
56
59
|
|
57
60
|
if doorkeeper_oauth?
|
data/lib/mobile_workflow.rb
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'mobile_workflow'
|
2
|
+
require 'rails'
|
3
|
+
|
4
|
+
module MobileWorkflow
|
5
|
+
class Railtie < Rails::Railtie
|
6
|
+
railtie_name :mobile_workflow
|
7
|
+
|
8
|
+
rake_tasks do
|
9
|
+
path = File.expand_path(__dir__)
|
10
|
+
Dir.glob("#{path}/tasks/**/*.rake").each { |f| load f }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
def each_step(json, type)
|
4
|
+
json['workflows'].map{|w| w["steps"].select {|s| s["type"] == type.to_s}}.flatten.each do |step|
|
5
|
+
yield(step)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def replace_oauth(app_json)
|
10
|
+
client_id = ENV["CLIENT_ID"]
|
11
|
+
client_secret = ENV["CLIENT_SECRET"]
|
12
|
+
redirect_scheme = ENV["SCHEME"]
|
13
|
+
|
14
|
+
each_step(app_json, :networkOAuth2) do |step|
|
15
|
+
step["items"].each do |item|
|
16
|
+
if item["oAuth2ClientId"]
|
17
|
+
item["oAuth2ClientId"] = client_id
|
18
|
+
item["oAuth2ClientSecret"] = client_secret
|
19
|
+
item["oAuth2RedirectScheme"] = redirect_scheme
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def replace_servers(app_json)
|
26
|
+
server_url = ENV["SERVER_URL"]
|
27
|
+
base_url = ENV["PREVIOUS_SERVER_URL"]
|
28
|
+
|
29
|
+
app_json["servers"].each do |server|
|
30
|
+
server["url"] = server_url
|
31
|
+
end
|
32
|
+
|
33
|
+
each_step(app_json, :display) do |step|
|
34
|
+
step["items"].each do |item|
|
35
|
+
["appleSystemURL", "androidDeepLink"].each{|key| item[key] = item[key].gsub(base_url, server_url) }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def env_set(path)
|
41
|
+
app_json = JSON.parse(File.read(app_json_path))
|
42
|
+
replace_oauth(app_json)
|
43
|
+
replace_servers(app_json)
|
44
|
+
File.write(app_json_path, app_json.to_json)
|
45
|
+
end
|
46
|
+
|
47
|
+
namespace :env_set do
|
48
|
+
desc 'Update Android app.json to use new env'
|
49
|
+
task :android do
|
50
|
+
env_set(File.join('app', 'src', 'main', 'res', 'raw', 'app.json'))
|
51
|
+
end
|
52
|
+
|
53
|
+
desc 'Update iOS app.json to use new env'
|
54
|
+
task :ios do
|
55
|
+
project_name = ENV["PROJECT_NAME"]
|
56
|
+
env_set(File.join(project_name, project_name, "Resources", "app.json"))
|
57
|
+
end
|
58
|
+
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.
|
4
|
+
version: 0.6.24
|
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
|
11
|
+
date: 2021-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -137,6 +137,8 @@ files:
|
|
137
137
|
- lib/mobile_workflow/cli/heroku_backend.rb
|
138
138
|
- lib/mobile_workflow/engine.rb
|
139
139
|
- lib/mobile_workflow/open_api_spec/parser.rb
|
140
|
+
- lib/mobile_workflow/railtie.rb
|
141
|
+
- lib/mobile_workflow/tasks/env_set.rake
|
140
142
|
- lib/mobile_workflow/version.rb
|
141
143
|
homepage: https://github.com/futureworkshops/mobile_workflow
|
142
144
|
licenses:
|