riddler_admin 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/riddler_admin/application.js +0 -1
  3. data/app/assets/javascripts/riddler_admin/preview_contexts.js +2 -0
  4. data/app/assets/javascripts/riddler_admin/publish_requests.js +2 -0
  5. data/app/assets/javascripts/riddler_admin/steps.js +36 -22
  6. data/app/assets/stylesheets/riddler_admin/application.scss +3 -0
  7. data/app/assets/stylesheets/riddler_admin/preview_contexts.css +4 -0
  8. data/app/assets/stylesheets/riddler_admin/publish_requests.css +4 -0
  9. data/app/controllers/riddler_admin/application_controller.rb +24 -2
  10. data/app/controllers/riddler_admin/dashboard_controller.rb +8 -0
  11. data/app/controllers/riddler_admin/elements_controller.rb +6 -2
  12. data/app/controllers/riddler_admin/preview_contexts_controller.rb +60 -0
  13. data/app/controllers/riddler_admin/publish_requests_controller.rb +90 -0
  14. data/app/controllers/riddler_admin/slugs_controller.rb +67 -0
  15. data/app/controllers/riddler_admin/steps_controller.rb +73 -20
  16. data/app/helpers/riddler_admin/application_helper.rb +19 -0
  17. data/app/helpers/riddler_admin/preview_contexts_helper.rb +4 -0
  18. data/app/helpers/riddler_admin/publish_requests_helper.rb +4 -0
  19. data/app/models/riddler_admin/application_record.rb +4 -4
  20. data/app/models/riddler_admin/content_definition.rb +87 -0
  21. data/app/models/riddler_admin/element.rb +52 -10
  22. data/app/models/riddler_admin/elements/heading.rb +6 -0
  23. data/app/models/riddler_admin/elements/image.rb +18 -0
  24. data/app/models/riddler_admin/elements/link.rb +18 -0
  25. data/app/models/riddler_admin/elements/{copy.rb → text.rb} +7 -1
  26. data/app/models/riddler_admin/elements/variant.rb +19 -0
  27. data/app/models/riddler_admin/preview_context.rb +83 -0
  28. data/app/models/riddler_admin/publish_request.rb +57 -0
  29. data/app/models/riddler_admin/slug.rb +90 -0
  30. data/app/models/riddler_admin/step.rb +66 -4
  31. data/app/models/riddler_admin/steps/variant.rb +19 -0
  32. data/app/validators/parseable_predicate_validator.rb +8 -0
  33. data/app/views/layouts/riddler_admin/application.html.erb +11 -4
  34. data/app/views/riddler_admin/_element.html.erb +14 -10
  35. data/app/views/riddler_admin/_element_container.html.erb +11 -0
  36. data/app/views/riddler_admin/_navbar.html.erb +29 -0
  37. data/app/views/riddler_admin/_preview_step.html.erb +39 -0
  38. data/app/views/riddler_admin/_step.html.erb +35 -0
  39. data/app/views/riddler_admin/_step_container.html.erb +11 -0
  40. data/app/views/riddler_admin/dashboard/index.html.erb +44 -0
  41. data/app/views/riddler_admin/elements/_form.html.erb +37 -0
  42. data/app/views/riddler_admin/elements/_new.html.erb +41 -8
  43. data/app/views/riddler_admin/elements/_show.html.erb +3 -1
  44. data/app/views/riddler_admin/elements/edit.js.erb +2 -0
  45. data/app/views/riddler_admin/elements/heading/_detail.html.erb +0 -0
  46. data/app/views/riddler_admin/elements/heading/_form.html.erb +8 -2
  47. data/app/views/riddler_admin/elements/image/_detail.html.erb +0 -0
  48. data/app/views/riddler_admin/elements/image/_form.html.erb +12 -0
  49. data/app/views/riddler_admin/elements/link/_detail.html.erb +0 -0
  50. data/app/views/riddler_admin/elements/link/_form.html.erb +12 -0
  51. data/app/views/riddler_admin/elements/show.js.erb +2 -2
  52. data/app/views/riddler_admin/elements/text/_detail.html.erb +0 -0
  53. data/app/views/riddler_admin/elements/text/_form.html.erb +4 -0
  54. data/app/views/riddler_admin/elements/variant/_detail.html.erb +6 -0
  55. data/app/views/riddler_admin/elements/variant/_form.html.erb +1 -0
  56. data/app/views/riddler_admin/preview_contexts/_form.html.erb +44 -0
  57. data/app/views/riddler_admin/preview_contexts/edit.html.erb +10 -0
  58. data/app/views/riddler_admin/preview_contexts/index.html.erb +43 -0
  59. data/app/views/riddler_admin/preview_contexts/new.html.erb +10 -0
  60. data/app/views/riddler_admin/preview_contexts/show.html.erb +45 -0
  61. data/app/views/riddler_admin/publish_requests/_actions.html.erb +19 -0
  62. data/app/views/riddler_admin/publish_requests/_form.html.erb +53 -0
  63. data/app/views/riddler_admin/publish_requests/approve.js.erb +2 -0
  64. data/app/views/riddler_admin/publish_requests/edit.html.erb +10 -0
  65. data/app/views/riddler_admin/publish_requests/index.html.erb +62 -0
  66. data/app/views/riddler_admin/publish_requests/new.html.erb +10 -0
  67. data/app/views/riddler_admin/publish_requests/publish.js.erb +2 -0
  68. data/app/views/riddler_admin/publish_requests/show.html.erb +25 -0
  69. data/app/views/riddler_admin/slugs/_form.html.erb +48 -0
  70. data/app/views/riddler_admin/slugs/edit.html.erb +10 -0
  71. data/app/views/riddler_admin/slugs/index.html.erb +44 -0
  72. data/app/views/riddler_admin/slugs/new.html.erb +10 -0
  73. data/app/views/riddler_admin/slugs/show.html.erb +18 -0
  74. data/app/views/riddler_admin/steps/_definition.html.erb +11 -0
  75. data/app/views/riddler_admin/steps/_form.html.erb +45 -17
  76. data/app/views/riddler_admin/steps/_new_sub_step.html.erb +56 -0
  77. data/app/views/riddler_admin/steps/_visual_preview.html.erb +24 -0
  78. data/app/views/riddler_admin/steps/content/_show.html.erb +53 -25
  79. data/app/views/riddler_admin/steps/edit.html.erb +15 -4
  80. data/app/views/riddler_admin/steps/index.html.erb +24 -10
  81. data/app/views/riddler_admin/steps/internal_preview.js.erb +5 -0
  82. data/app/views/riddler_admin/steps/new.html.erb +10 -5
  83. data/app/views/riddler_admin/steps/new.js.erb +3 -0
  84. data/app/views/riddler_admin/steps/preview.json.erb +1 -0
  85. data/app/views/riddler_admin/steps/show.html.erb +26 -11
  86. data/app/views/riddler_admin/steps/show.js.erb +4 -0
  87. data/app/views/riddler_admin/steps/variant/_show.html.erb +59 -0
  88. data/config/routes.rb +20 -1
  89. data/db/migrate/20181124201519_riddler_admin_genesis.rb +72 -0
  90. data/lib/riddler_admin.rb +29 -2
  91. data/lib/riddler_admin/configuration.rb +44 -0
  92. data/lib/riddler_admin/version.rb +1 -1
  93. metadata +75 -30
  94. data/app/views/riddler_admin/elements/copy/_class.html.erb +0 -3
  95. data/app/views/riddler_admin/elements/copy/_form.html.erb +0 -2
  96. data/app/views/riddler_admin/elements/heading/_class.html.erb +0 -3
  97. data/app/views/riddler_admin/steps/_preview.html.erb +0 -5
  98. data/db/migrate/20181124201519_create_riddler_admin_steps.rb +0 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9561218c85dfee3d311a84b0681f7464ea5f02712fe940f698775d816a4f9913
4
- data.tar.gz: 225ca8ed1782b0600e07911c81befc5a4fe21530a2a6095e967d262f8e6d16dd
3
+ metadata.gz: 7fbe7363be1d7d9cf092e6b2975ac881b0ff97a84422027ec805f4bfe2aaa691
4
+ data.tar.gz: b6cf8b5a66cef3385193c6a1fc4e977ab90f6afedf1f5b57157e79ee0d1dc791
5
5
  SHA512:
6
- metadata.gz: 04da84f8aa2b102182e9ac084c6c5d86879cd3629f883371cfe511de9a4ed8e8431b602522c622806b0ad9117f66410d57d383b09fc4b3cfe15bed5ed16737b7
7
- data.tar.gz: 0fa37404a58600285e9f58984d35dd9cf9d3a67e93dba9416337d9a6d0741d559d16be8b20a76705b315307f44afff110a0f507928a8963b98ab79fc61ad3191
6
+ metadata.gz: 602a2498403c370eb45442fc6aa9a48b7c967f5839736306b92279677e6057311f901c659879c4590ef3eaede5ace1b8f6ef8eaf585e675756d7dff8a55eccff
7
+ data.tar.gz: e110592d9e29ed2297d59ac06f246e130f5e607f78423f5efefa8fdc2726809d43b4246af3601f99b7ed17d17413ca2851e63d05f32b76ccaeb4b349aad528ce
@@ -16,6 +16,5 @@
16
16
  //= require jquery-ui/widgets/draggable
17
17
  //= require jquery-ui/widgets/droppable
18
18
  //= require jquery-ui/widgets/sortable
19
- //= require popper
20
19
  //= require bootstrap-sprockets
21
20
  //= require_tree .
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -1,42 +1,56 @@
1
1
  // Place all the behaviors and hooks related to the matching controller here.
2
2
  // All this logic will automatically be available in application.js.
3
3
  $(document).ready(function(){
4
+ $('.step-context-preview').on('click', function(evt) {
5
+ var stepId = $(this).data('stepId'),
6
+ pctxId = $(this).data('pctxId')
4
7
 
5
- $("#step-elements").sortable({
8
+ var url = window.riddler_admin_path + "steps/" + stepId + "/internal_preview?pctx_id=" + pctxId
9
+
10
+ Rails.ajax({
11
+ type: "GET",
12
+ url: url,
13
+ success: function(data){
14
+ eval(data);
15
+ }
16
+ })
17
+ });
18
+
19
+ $(".element-container").sortable({
6
20
  revert: 50,
7
21
  opacity: 0.5,
22
+ handle: ".handle",
8
23
  cursor: "move",
24
+ containment: "parent",
9
25
  forcePlaceholderSize: true,
10
26
  update: function(event, ui) {
11
27
  element_ids = $(this).sortable("toArray", { attribute: "data-id" })
12
28
 
29
+ var url = window.riddler_admin_path + "elements/sort"
13
30
  Rails.ajax({
14
31
  type: "PUT",
15
- url: "/riddler_admin/elements/sort",
32
+ url: url,
16
33
  data: $.param({ element_order: element_ids })
17
34
  })
18
- },
19
-
20
-
21
- old_update: function(event, ui) {
22
- params = {
23
- type: ui.item.data("klass"),
24
- step_id: ui.item.parent().data("stepId")
25
- }
26
- $.get("/riddler_admin/elements/new", params, function(data) {
27
- ui.item.removeAttr("style");
28
- ui.item.html(data);
29
- });
30
35
  }
31
36
  })
32
37
 
33
- /*
34
- $(".element-classes-draggable").draggable({
35
- connectToSortable: "#step-elements",
36
- revertDuration: 50,
37
- revert: "invalid",
38
- helper: "clone"
39
- })
40
- */
38
+ $(".step-container").sortable({
39
+ revert: 50,
40
+ opacity: 0.5,
41
+ handle: ".handle",
42
+ cursor: "move",
43
+ containment: "parent",
44
+ forcePlaceholderSize: true,
45
+ update: function(event, ui) {
46
+ step_ids = $(this).sortable("toArray", { attribute: "data-id" })
41
47
 
48
+ url = window.riddler_admin_path + "steps/sort"
49
+ Rails.ajax({
50
+ type: "PUT",
51
+ url: url,
52
+ data: $.param({ step_order: step_ids })
53
+ })
54
+ }
55
+ })
42
56
  })
@@ -11,4 +11,7 @@
11
11
  * It is generally better to create a new file per style scope.
12
12
  *
13
13
  */
14
+
15
+ $primary: #6f42c1 !default;
16
+
14
17
  @import "bootstrap";
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -1,5 +1,27 @@
1
1
  module RiddlerAdmin
2
- class ApplicationController < ActionController::Base
3
- protect_from_forgery with: :exception
2
+ class ApplicationController < ::RiddlerAdmin.config.base_controller
3
+ before_action :authorize_riddler_admin
4
+ helper_method :riddler_current_user, :riddler_user_can_approve?, :riddler_user_can_deploy?
5
+
6
+ def riddler_current_user
7
+ self.send ::RiddlerAdmin.config.current_user_method
8
+ end
9
+
10
+ def riddler_user_can_approve?
11
+ return true if ::RiddlerAdmin.config.user_can_approve_block.nil?
12
+ ::RiddlerAdmin.config.user_can_approve_block.call riddler_current_user
13
+ end
14
+
15
+ def riddler_user_can_deploy?
16
+ return true if ::RiddlerAdmin.config.user_can_deploy_block.nil?
17
+ ::RiddlerAdmin.config.user_can_deploy_block.call riddler_current_user
18
+ end
19
+
20
+ private
21
+
22
+ def authorize_riddler_admin
23
+ return true if ::RiddlerAdmin.config.controller_authorization_block.nil?
24
+ ::RiddlerAdmin.config.controller_authorization_block.call self
25
+ end
4
26
  end
5
27
  end
@@ -0,0 +1,8 @@
1
+ require_dependency "riddler_admin/application_controller"
2
+
3
+ module RiddlerAdmin
4
+ class DashboardController < ApplicationController
5
+ def index
6
+ end
7
+ end
8
+ end
@@ -8,9 +8,13 @@ module RiddlerAdmin
8
8
  # GET /elements/new
9
9
  def new
10
10
  hash = {}
11
+
11
12
  if step = Step.find_by_id(params["step_id"])
12
13
  hash[:container] = step
14
+ elsif element = RiddlerAdmin::Element.find_by_id(params[:element_id])
15
+ hash[:container] = element
13
16
  end
17
+
14
18
  @element = @element_class.new hash
15
19
  end
16
20
 
@@ -68,12 +72,12 @@ module RiddlerAdmin
68
72
 
69
73
  # Only allow a trusted parameter "white list" through.
70
74
  def element_create_params
71
- params.require(:element).permit(:id, :name, :type, :text, :container_type, :container_id)
75
+ params.require(:element).permit(:id, :name, :type, :text, :container_type, :container_id, :url, :include_predicate)
72
76
  end
73
77
 
74
78
  # Only allow a trusted parameter "white list" through.
75
79
  def element_params
76
- params.require(:element).permit(:name, :text)
80
+ params.require(:element).permit(:name, :text, :url, :include_predicate)
77
81
  end
78
82
  end
79
83
  end
@@ -0,0 +1,60 @@
1
+ require_dependency "riddler_admin/application_controller"
2
+
3
+ module RiddlerAdmin
4
+ class PreviewContextsController < ApplicationController
5
+ before_action :set_preview_context, only: [:show, :edit, :update, :destroy]
6
+
7
+ def index
8
+ @preview_contexts = PreviewContext.all
9
+ end
10
+
11
+ def show
12
+ end
13
+
14
+ def new
15
+ @preview_context = PreviewContext.new
16
+ end
17
+
18
+ def create
19
+ @preview_context = PreviewContext.new preview_context_params
20
+
21
+ if @preview_context.save
22
+ @preview_context.refresh_data input_headers: request.headers.to_h
23
+
24
+ redirect_to @preview_context, notice: "Preview context was successfully created."
25
+ else
26
+ render :new
27
+ end
28
+ end
29
+
30
+ def edit
31
+ end
32
+
33
+ def update
34
+ if @preview_context.update preview_context_params
35
+ @preview_context.refresh_data input_headers: request.headers.to_h
36
+
37
+ redirect_to @preview_context, notice: "Preview context was successfully updated."
38
+ else
39
+ render :edit
40
+ end
41
+ end
42
+
43
+ def destroy
44
+ @preview_context.destroy
45
+ redirect_to preview_contexts_url, notice: "Preview context was successfully destroyed."
46
+ end
47
+
48
+ private
49
+
50
+ # Use callbacks to share common setup or constraints between actions.
51
+ def set_preview_context
52
+ @preview_context = PreviewContext.find params[:id]
53
+ end
54
+
55
+ # Only allow a trusted parameter "white list" through.
56
+ def preview_context_params
57
+ params.require(:preview_context).permit(:title, :params, :headers)
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,90 @@
1
+ require_dependency "riddler_admin/application_controller"
2
+
3
+ module RiddlerAdmin
4
+ class PublishRequestsController < ApplicationController
5
+ before_action :set_publish_request, only: [:show, :edit, :update, :destroy, :approve, :publish]
6
+ before_action :check_approval_ability, only: :approve
7
+
8
+ def index
9
+ @publish_requests = PublishRequest.all
10
+ end
11
+
12
+ def show
13
+ @preview_contexts = ::RiddlerAdmin::PreviewContext.all
14
+ end
15
+
16
+ def approve
17
+ @publish_request.approve riddler_current_user
18
+ end
19
+
20
+ def publish
21
+ @publish_request.publish
22
+ end
23
+
24
+ def new
25
+ hash = {}
26
+
27
+ if step = Step.find_by_id(params["step_id"])
28
+ hash[:content] = step
29
+ @publish_request = PublishRequest.new hash
30
+ @definition = step.definition_hash.to_yaml
31
+ else
32
+ redirect_to publish_requests_path, notice: "Content must be provided in step_id"
33
+ end
34
+ end
35
+
36
+ def create
37
+ @publish_request = PublishRequest.new publish_request_params
38
+
39
+ if @publish_request.save
40
+ redirect_to @publish_request, notice: "Publish request was successfully created."
41
+ else
42
+ render :new
43
+ end
44
+ end
45
+
46
+ def edit
47
+ if @publish_request.approved? || @publish_request.published?
48
+ redirect_to @publish_request, notice: "Editing of approved requests is not allowed"
49
+ end
50
+
51
+ @definition = @publish_request.content.definition_hash.to_yaml
52
+ end
53
+
54
+ def update
55
+ if @publish_request.approved? || @publish_request.published?
56
+ redirect_to @publish_request, notice: "Editing of approved requests is not allowed"
57
+
58
+ elsif @publish_request.update publish_request_params
59
+ redirect_to @publish_request, notice: "Publish request was successfully updated."
60
+ else
61
+ render :edit
62
+ end
63
+ end
64
+
65
+ def destroy
66
+ @publish_request.destroy
67
+ redirect_to publish_requests_url, notice: "Publish request was successfully destroyed."
68
+ end
69
+
70
+ private
71
+
72
+ def check_approval_ability
73
+ if !riddler_user_can_approve?
74
+ redirect_to publish_requests_url, notice: "Approval not allowed"
75
+ return false
76
+ end
77
+ true
78
+ end
79
+
80
+ # Use callbacks to share common setup or constraints between actions.
81
+ def set_publish_request
82
+ @publish_request = PublishRequest.find params[:id]
83
+ end
84
+
85
+ # Only allow a trusted parameter "white list" through.
86
+ def publish_request_params
87
+ params.require(:publish_request).permit(:title, :description, :content_type, :content_id, :definition)
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,67 @@
1
+ require_dependency "riddler_admin/application_controller"
2
+
3
+ module RiddlerAdmin
4
+ class SlugsController < ApplicationController
5
+ before_action :set_slug, only: [:show, :edit, :update, :destroy, :toggle_status, :publish]
6
+ before_action :check_deploy_ability, only: [:create, :update]
7
+
8
+ def index
9
+ @slugs = Slug.all
10
+ end
11
+
12
+ def show
13
+ end
14
+
15
+ def new
16
+ @slug = Slug.new
17
+ end
18
+
19
+ def create
20
+ @slug = Slug.new slug_params
21
+
22
+ if @slug.save
23
+ redirect_to slugs_url, notice: "Slug was successfully created."
24
+ else
25
+ render :new
26
+ end
27
+ end
28
+
29
+ def edit
30
+ end
31
+
32
+ def update
33
+ if @slug.update slug_params
34
+ redirect_to slugs_url, notice: "Slug was successfully updated."
35
+ else
36
+ render :edit
37
+ end
38
+ end
39
+
40
+ def destroy
41
+ raise "Destroying slugs is not currently supported"
42
+ @slug.destroy
43
+ redirect_to slugs_url, notice: "Slug was successfully destroyed."
44
+ end
45
+
46
+ private
47
+
48
+ def check_deploy_ability
49
+ if !riddler_user_can_deploy?
50
+ redirect_to slugs_url, notice: "Slug creation/modification not allowed"
51
+ return false
52
+ end
53
+ true
54
+ end
55
+
56
+ # Use callbacks to share common setup or constraints between actions.
57
+ def set_slug
58
+ @slug = Slug.find params[:id]
59
+ end
60
+
61
+ # Only allow a trusted parameter "white list" through.
62
+ def slug_params
63
+ params.require(:slug).permit :name, :status, :content_definition_id,
64
+ :persist_interaction, :interaction_identity, :target_predicate
65
+ end
66
+ end
67
+ end
@@ -2,7 +2,7 @@ require_dependency "riddler_admin/application_controller"
2
2
 
3
3
  module RiddlerAdmin
4
4
  class StepsController < ApplicationController
5
- before_action :set_step, only: [:show, :edit, :update, :destroy, :preview]
5
+ before_action :set_step, only: [:show, :edit, :update, :destroy, :internal_preview, :preview, :toggle]
6
6
  before_action :set_step_class
7
7
 
8
8
  # GET /steps
@@ -12,24 +12,76 @@ module RiddlerAdmin
12
12
 
13
13
  # GET /steps/1
14
14
  def show
15
- step_definition = @step.definition_hash
15
+ @step_definition = @step.definition_hash
16
+ @preview_contexts = ::RiddlerAdmin::PreviewContext.all
16
17
  end
17
18
 
18
19
  # GET /steps/new
19
20
  def new
20
- @step = Step.new
21
+ hash = {}
22
+
23
+ if step = Step.find_by_id(params["step_id"])
24
+ hash[:stepable] = step
25
+ end
26
+
27
+ @step = @step_class.new hash
21
28
  end
22
29
 
23
30
  # GET /steps/1/edit
24
31
  def edit
25
32
  end
26
33
 
34
+ # Should always comes from the admin tool
35
+ def internal_preview
36
+ @preview_context = ::RiddlerAdmin::PreviewContext.find_by_id params["pctx_id"]
37
+ if @preview_context.nil?
38
+ render(status: 400, json: {message: "Invalid pctx_id"}) and return
39
+ end
40
+
41
+ @use_case = ::Riddler::UseCases::AdminPreviewStep.new @step.definition_hash,
42
+ preview_context_data: @preview_context.data
43
+
44
+ @preview_hash = @use_case.process
45
+ end
46
+
47
+ def sort
48
+ step_order = params.fetch "step_order"
49
+
50
+ step_order.each_with_index do |step_id, index|
51
+ step = Step.find_by_id step_id
52
+ step.update_attribute :position, index+1
53
+ end
54
+
55
+ head :no_content
56
+ end
57
+
58
+ # POST /steps/1/preview
59
+ def preview
60
+ if @step.preview_enabled
61
+ request_headers = PreviewContext.convert_headers request.headers.to_h
62
+ definition = @step.definition_hash
63
+
64
+ use_case = ::Riddler::UseCases::PreviewStep.new definition,
65
+ params: params.to_unsafe_h,
66
+ headers: request_headers
67
+
68
+ render json: use_case.process
69
+ else
70
+ render json: {status: "disabled"}
71
+ end
72
+ end
73
+
74
+ def toggle
75
+ @step.update_attributes(preview_enabled: !@step.preview_enabled)
76
+ redirect_to @step
77
+ end
78
+
27
79
  # POST /steps
28
80
  def create
29
81
  @step = @step_class.new(step_params)
30
82
 
31
83
  if @step.save
32
- redirect_to @step, notice: 'Step was successfully created.'
84
+ redirect_to @step, notice: "Step was successfully created."
33
85
  else
34
86
  render :new
35
87
  end
@@ -38,7 +90,7 @@ module RiddlerAdmin
38
90
  # PATCH/PUT /steps/1
39
91
  def update
40
92
  if @step.update(step_params)
41
- redirect_to @step, notice: 'Step was successfully updated.'
93
+ redirect_to @step, notice: "Step was successfully updated."
42
94
  else
43
95
  render :edit
44
96
  end
@@ -47,26 +99,27 @@ module RiddlerAdmin
47
99
  # DELETE /steps/1
48
100
  def destroy
49
101
  @step.destroy
50
- redirect_to steps_url, notice: 'Step was successfully destroyed.'
102
+ redirect_to steps_url, notice: "Step was successfully destroyed."
51
103
  end
52
104
 
53
105
  private
54
- # Use callbacks to share common setup or constraints between actions.
55
- def set_step
56
- @step = Step.find(params[:id])
57
- end
58
106
 
59
- def set_step_class
60
- class_name = params.fetch(:step, {}).delete(:type) ||
61
- params.delete(:type)
62
- class_name = RiddlerAdmin::Step.default_class.name if class_name.blank?
107
+ # Use callbacks to share common setup or constraints between actions.
108
+ def set_step
109
+ @step = Step.find(params[:id])
110
+ end
63
111
 
64
- @step_class = class_name.constantize
65
- end
112
+ def set_step_class
113
+ class_name = params.fetch(:step, {}).delete(:type) ||
114
+ params.delete(:type)
115
+ class_name = RiddlerAdmin::Step.default_class.name if class_name.blank?
66
116
 
67
- # Only allow a trusted parameter "white list" through.
68
- def step_params
69
- params.require(:step).permit(:name)
70
- end
117
+ @step_class = class_name.constantize
118
+ end
119
+
120
+ # Only allow a trusted parameter "white list" through.
121
+ def step_params
122
+ params.require(:step).permit(:title, :name, :type, :stepable_type, :stepable_id, :include_predicate)
123
+ end
71
124
  end
72
125
  end