mobile_workflow 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/concerns/mobile_workflow/displayable.rb +13 -4
- data/lib/generators/mobile_workflow/controller_generator.rb +0 -8
- data/lib/generators/mobile_workflow/install/install_generator.rb +4 -8
- data/lib/generators/mobile_workflow/install/templates/api_controller.rb.erb +6 -1
- data/lib/generators/mobile_workflow/templates/controller.rb.erb +4 -7
- data/lib/generators/mobile_workflow/templates/controller_spec.rb.erb +2 -2
- data/lib/mobile_workflow/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24275da71a904cd964d375ab0eea9678d71cda4c6aaba01d9f6bcb0c8c122d48
|
4
|
+
data.tar.gz: 5fea2ff0337152f12bb11a8e4e0dad5193d17bb6a44644b3f7b5800de213f7c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26e0e811ed07bd4bfc616ac938ef549e6ad9a5a1335dd1f601c34411fb595a0aa8813c219103cf2ede81eedfa935a195440d9a62a03b97fbe8384db0520e65cb
|
7
|
+
data.tar.gz: 1aab026098618375eae9fe91311fa2771111be6f72cfc3436cf6b8f9de274aba158fe5bf87b1b3cd648118570e92dde2ee22724379a16b1b0699c26ceb339da0
|
@@ -17,11 +17,20 @@ module MobileWorkflow
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def mw_display_image(attachment)
|
20
|
-
{type: :image, previewURL: preview_url(attachment, height:
|
20
|
+
{type: :image, previewURL: preview_url(attachment, height: 600, width: 1200), url: attachment_url(attachment)}
|
21
|
+
end
|
22
|
+
|
23
|
+
def mw_display_unsplash_image(image_url)
|
24
|
+
if image_url.start_with? "https://unsplash.com/photos"
|
25
|
+
unsplash_id = image_url.split('/').last
|
26
|
+
image_url = "https://source.unsplash.com/#{unsplash_id}/800x600"
|
27
|
+
end
|
28
|
+
|
29
|
+
{type: :image, previewURL: image_url, url: image_url}
|
21
30
|
end
|
22
31
|
|
23
32
|
def mw_display_video(attachment)
|
24
|
-
{type: :video, previewURL: preview_url(attachment, height:
|
33
|
+
{type: :video, previewURL: preview_url(attachment, height: 600, width: 1200), url: attachment_url(attachment)}
|
25
34
|
end
|
26
35
|
|
27
36
|
def mw_display_button(label:, style: :primary, on_success: :forward)
|
@@ -45,11 +54,11 @@ module MobileWorkflow
|
|
45
54
|
{type: :button, label: label, url: url, method: method, style: style, onSuccess: on_success}
|
46
55
|
end
|
47
56
|
|
48
|
-
def mw_display_button_for_modal_workflow(label:,
|
57
|
+
def mw_display_button_for_modal_workflow(label:, modal_workflow_name:, style: :primary, on_success: :none)
|
49
58
|
validate_on_success!(on_success)
|
50
59
|
validate_button_style!(style)
|
51
60
|
|
52
|
-
{type: :button, label: label, modalWorkflow:
|
61
|
+
{type: :button, label: label, modalWorkflow: modal_workflow_name, style: style, onSuccess: on_success}
|
53
62
|
end
|
54
63
|
|
55
64
|
private
|
@@ -23,14 +23,6 @@ module MobileWorkflow
|
|
23
23
|
params = attributes_names.map{ |name| ":#{name}" }
|
24
24
|
params.join(", ")
|
25
25
|
end
|
26
|
-
|
27
|
-
def rewrite_params
|
28
|
-
if attributes_names
|
29
|
-
init_params = "\n\t\tparams[:#{singular_table_name}] = {}\n"
|
30
|
-
rewrite_params = attributes_names.map {|name| "params[:#{singular_table_name}][:#{name}] = params.dig(:payload, :#{name}, :answer)" }.join("\n\t\t")
|
31
|
-
init_params + rewrite_params
|
32
|
-
end
|
33
|
-
end
|
34
26
|
end
|
35
27
|
end
|
36
28
|
end
|
@@ -94,14 +94,10 @@ module MobileWorkflow
|
|
94
94
|
end
|
95
95
|
|
96
96
|
def model_property_type(property)
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
'attachment'
|
102
|
-
else
|
103
|
-
'string'
|
104
|
-
end
|
97
|
+
return property["type"] unless property["type"].blank?
|
98
|
+
return 'attachment' if property['$ref'] == "#/components/schemas/attachment"
|
99
|
+
|
100
|
+
raise 'Unknown property type'
|
105
101
|
end
|
106
102
|
end
|
107
103
|
end
|
@@ -1,9 +1,14 @@
|
|
1
1
|
class ApiController < ActionController::API
|
2
|
+
rescue_from CanCan::AccessDenied do |exception|
|
3
|
+
Rails.logger.debug "Access denied on #{exception.action} #{exception.subject.inspect}"
|
4
|
+
head :forbidden
|
5
|
+
end
|
6
|
+
|
2
7
|
<% if options[:doorkeeper_oauth] %>
|
3
8
|
before_action :doorkeeper_authorize!, unless: :anonymous_action?
|
4
9
|
|
5
10
|
def current_resource_owner
|
6
|
-
User.find(doorkeeper_token.resource_owner_id) if doorkeeper_token
|
11
|
+
User.find(doorkeeper_token.resource_owner_id) if doorkeeper_token&.accessible?
|
7
12
|
end
|
8
13
|
alias_method :current_user, :current_resource_owner
|
9
14
|
|
@@ -24,19 +24,16 @@ class <%= controller_class_name %>Controller < ApiController
|
|
24
24
|
private
|
25
25
|
def rewrite_payload
|
26
26
|
# Use this method to make any changes to params to make them compatible with ActiveRecord
|
27
|
-
|
28
|
-
# 1. Example to get
|
29
|
-
# params[:payload][:name] = params.dig(:payload, :name, :answer)
|
30
|
-
|
31
|
-
# 2. Example to get selected id from a list
|
27
|
+
|
28
|
+
# 1. Example to get selected id from a list
|
32
29
|
# passport_id = params.dig(:payload, :choose_passport, :selected, :id)
|
33
30
|
|
34
31
|
Rails.logger.debug "Pre-rewrite params: #{params}"
|
35
|
-
|
32
|
+
# Do your rewriting here
|
36
33
|
end
|
37
34
|
|
38
35
|
def <%= singular_table_name.underscore %>_params
|
39
|
-
params.require(
|
36
|
+
params.require(:payload).permit(<%= permitted_params %>)
|
40
37
|
end
|
41
38
|
end
|
42
39
|
<% end %>
|
@@ -8,7 +8,7 @@ RSpec.describe <%= controller_class_name %>Controller do
|
|
8
8
|
let(:json_response) { JSON.parse(response.body, symbolize_names: true) }
|
9
9
|
|
10
10
|
describe 'GET #index' do
|
11
|
-
let!(:<%= controller_class_name.singularize.underscore %>) {
|
11
|
+
let!(:<%= controller_class_name.singularize.underscore %>) { create(:<%= controller_class_name.singularize.underscore %>) }
|
12
12
|
before(:each) { get :index, params: params }
|
13
13
|
|
14
14
|
context 'ok' do
|
@@ -18,7 +18,7 @@ RSpec.describe <%= controller_class_name %>Controller do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
describe 'GET #show' do
|
21
|
-
let(:<%= controller_class_name.singularize.underscore %>) {
|
21
|
+
let(:<%= controller_class_name.singularize.underscore %>) { create(:<%= controller_class_name.singularize.underscore %>) }
|
22
22
|
let(:params) { { id: <%= controller_class_name.singularize.underscore %>.id } }
|
23
23
|
before(:each) { get :show, params: params }
|
24
24
|
|
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.
|
4
|
+
version: 0.4.0
|
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: 2020-12-
|
11
|
+
date: 2020-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|